diff --git a/lib/Makefile b/lib/Makefile deleted file mode 100644 index d40edd1da..000000000 --- a/lib/Makefile +++ /dev/null @@ -1,338 +0,0 @@ -# $NetBSD: Makefile,v 1.235 2015/09/28 17:12:12 christos Exp $ -# from: @(#)Makefile 5.25.1.1 (Berkeley) 5/7/91 - -.include - -SUBDIR= csu .WAIT - -.if (${MKGCC} != "no") -SUBDIR+= ../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libgcc .WAIT -.endif - -.if defined(__MINIX) -#LSC MINIX libc depends on -# - libmthread because of sys/lib/libunwind -SUBDIR+= .WAIT - -SUBDIR+= ../minix/lib/libsys -SUBDIR+= ../minix/lib/libmthread -SUBDIR+= .WAIT -.endif # defined(__MINIX) -SUBDIR+= libc -SUBDIR+= .WAIT - -.if defined(__MINIX) -SUBDIR+= ../minix/lib/libasyn \ - ../minix/lib/libaudiodriver \ - ../minix/lib/libbdev \ - ../minix/lib/libblockdriver \ - ../minix/lib/libchardriver \ - ../minix/lib/libddekit \ - ../minix/lib/libdevman \ - ../minix/lib/libexec \ - ../minix/lib/libfsdriver \ - ../minix/lib/libinputdriver \ - ../minix/lib/liblwip \ - ../minix/lib/libminc \ - ../minix/lib/libminixfs \ - ../minix/lib/libnetdriver \ - ../minix/lib/libsffs \ - ../minix/lib/libsockdriver \ - ../minix/lib/libsockevent \ - ../minix/lib/libtimers \ - ../minix/lib/libusb \ - ../minix/lib/libvtreefs - -.if (${HAVE_LIBGCC} == "no") -SUBDIR+= ../minix/lib/libgcc_s_empty -.endif - -.if (${MACHINE_ARCH} == "i386") -SUBDIR+= ../minix/lib/libacpi \ - ../minix/lib/libhgfs \ - ../minix/lib/libvassert \ - ../minix/lib/libvboxfs \ - ../minix/lib/libvirtio -.endif - -.if (${MACHINE_ARCH} == "earm") -SUBDIR+= ../minix/lib/libclkconf \ - ../minix/lib/libgpio \ - ../minix/lib/libi2cdriver -.endif - -.if (${MKMAGIC} == "yes") -SUBDIR+= ../minix/lib/libmagicrt -.endif - -.endif # defined(__MINIX) -# -# The SUBDIRs above are included here for completeness but should be built -# and installed prior to make(dependall) in this file, as libraries listed -# below will depend on versions from DESTDIR only. -# - -SUBDIR+= i18n_module - -SUBDIR+= \ - libbz2 \ - libcrypt \ - libintl libkvm libm \ - libpci libprop \ - libpuffs librmt \ - libtelnet libterminfo \ - libutil libwrap libz - -.if !defined(BSD_MK_COMPAT_FILE) -#SUBDIR+= libkern -.endif - -.if (${MACHINE_CPU} == "arm" || ${MACHINE_CPU} == "aarch64") -LIBC_MACHINE_ARCH?=${MACHINE_ARCH} -LIBC_MACHINE_CPU?=${MACHINE_CPU} -.if ${LIBC_MACHINE_CPU} == "arm" && empty(LIBC_MACHINE_ARCH:M*hf*) -.if !defined(__MINIX) -SUBDIR+= libc_vfp -.endif # !defined(__MINIX) -.endif -.endif -.if (${MKRUMP} != "no") -SUBDIR+= librumpclient -.endif -.if (${MKSKEY} != "no") -SUBDIR+= libskey -.endif - -.if (${MKMDNS} != "no") -SUBDIR+= ../external/apache2/mDNSResponder/lib -.endif - -#SUBDIR+= ../external/bsd/am-utils/lib -SUBDIR+= ../external/bsd/blacklist/lib - -SUBDIR+= ../external/bsd/flex/lib -#SUBDIR+= ../external/bsd/tre/lib -SUBDIR+= ../external/bsd/elftoolchain/lib/libelf -#SUBDIR+= ../external/bsd/liblzf/lib -SUBDIR+= ../external/bsd/libpcap/lib - -.if ${MKSLJIT} != "no" -SUBDIR+= ../external/bsd/sljit/lib -SUBDIR+= libbpfjit -.endif - -.if (${MKZFS} != "no") -SUBDIR+= ../external/cddl/osnet/lib/libavl -SUBDIR+= ../external/cddl/osnet/lib/libnvpair -SUBDIR+= ../external/cddl/osnet/lib/libumem -SUBDIR+= ../external/cddl/osnet/lib/libuutil -.endif - -SUBDIR+= ../external/mit/expat/lib - -SUBDIR+= ../external/public-domain/sqlite/lib - -#SUBDIR+= ../gnu/lib/libmalloc - -.if (${MKGCC} != "no") -. if !defined(__MINIX) || ${MKLIBSTDCXX} == "yes" -SUBDIR+= ../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libobjc -SUBDIR+= ../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libgomp -#SUBDIR+= ../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libmudflap -#SUBDIR+= ../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libmudflapth -. endif # !defined(__MINIX) || ${MKLIBSTDCXX} == "yes" -. if !defined(__MINIX) || ${MKLIBSTDCXX} == "yes" -# Should probably move GMP, MPFR and MPC builds into the GCC >= 4.5 -# specific build area, but we get better parallelism this way. -# We don't build compat versions of these. -. if !defined(MLIBDIR) -SUBDIR+= ../external/lgpl3/gmp/lib/libgmp -SUBDIR+= ../external/lgpl3/mpfr/lib/libmpfr -SUBDIR+= ../external/lgpl3/mpc/lib/libmpc -. endif # !defined(__MINIX) || ${MKLIBSTDCXX} == "yes" -. endif -.endif - -# -# Libraries that depend upon any listed previously -# (and those that depend upon these [and ...]) -# -#==================== 1st library dependency barrier ==================== -SUBDIR+= .WAIT - -.if ${MKDTRACE} != "no" -SUBDIR+= ../external/bsd/librtld_db/lib # depends on libutil -.endif - -.if ${MKDTRACE} != "no" || ${MKCTF} != "no" -SUBDIR+= ../external/cddl/osnet/lib/libctf -.endif - -SUBDIR+= ../external/public-domain/xz/lib # depends on libpthread - -.if (${MKCRYPTO} != "no") -SUBDIR+= ../crypto/external/bsd/netpgp/libmj -SUBDIR+= ../crypto/external/bsd/netpgp/lib/verify # depends on libz -.endif - -#SUBDIR+= ../external/bsd/libdwarf/lib # depends on libelf -SUBDIR+= ../external/mit/lua/lib # depends on libm -SUBDIR+= libcurses # depends on libterminfo -#SUBDIR+= libdm # depends on libprop -SUBDIR+= libedit # depends on libterminfo -SUBDIR+= libexecinfo # depends on libelf -#SUBDIR+= libppath # depends on libprop -#SUBDIR+= libperfuse # depends on libpuffs -#SUBDIR+= libquota # depends on libprop and librpcsvc -SUBDIR+= librefuse # depends on libpuffs -#SUBDIR+= libisns # depends on libpthread -.if (${MKRUMP} != "no") -SUBDIR+= librumpuser # depends on libpthread -SUBDIR+= librumphijack # depends on librumpclient and libpthread -.endif - -.if (${MKNPF} != "no") -SUBDIR+= libnpf # depends on libprop -.endif - -.if (${MKCRYPTO} != "no") -SUBDIR+= ../crypto/external/bsd/openssl/lib # depends on libcrypt -.endif - -SUBDIR+= ../external/bsd/file/lib # depends on libz - -.if (${MKISCSI} != "no") -SUBDIR+= ../external/bsd/iscsi/lib # depends on libpthread -.endif - -.if (${MKZFS} != "no") -SUBDIR+= ../external/cddl/osnet/lib/libzfs -SUBDIR+= ../external/cddl/osnet/lib/libzpool -.endif - -.if (${MKLVM} != "no") -SUBDIR+= ../external/gpl2/lvm2/lib # depends on libprop -.endif - -.if (${MKBINUTILS} != "no") -SUBDIR+= ../external/gpl3/binutils/lib # libbfd depends on libz -.endif - -.if (${MKLIBCXX} != "no") -SUBDIR+= ../external/bsd/libc++ -.endif - -.if (${MKGCC} != "no" && ${MKCXX} != "no" && ${MKLIBSTDCXX} != "no") -SUBDIR+= ../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libstdc++-v3 -SUBDIR+= ../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libsupc++ -.endif - -#==================== 2nd library dependency barrier ==================== -SUBDIR+= .WAIT - -SANITIZER_DIR=../external/gpl3/${EXTERNAL_GCC_SUBDIR}/lib/libasan -.if exists(${SANITIZER_DIR}) -#SUBDIR+= ${SANITIZER_DIR} -.endif - -SUBDIR+= ../external/bsd/libarchive/lib # depends on libxz - -.if (${MKNPF} != "no") -SUBDIR+= npf # depends on libnpf -.endif - -.if (${MKATF} != "no") -SUBDIR+= ../external/bsd/atf/lib # depends on libstdc++ -.endif - -.if (${MKKYUA} != "no") -SUBDIR+= ../external/bsd/lutok/lib # depends on lua and libstdc++ -.endif - -SUBDIR+= libform # depends on libcurses -SUBDIR+= libmenu # depends on libcurses -#SUBDIR+= libradius # depends on libcrypto if (${MKCRYPTO} != "no") -.if (${MKRUMP} != "no") -SUBDIR+= librump # depends on librumpuser -.endif - -.if (${MKKERBEROS} != "no") -SUBDIR+= ../crypto/external/bsd/heimdal/lib # depends on libcrypto - # libedit, libterminfo, -.endif - -.if (${MKCRYPTO} != "no") -#SUBDIR+= ../crypto/external/bsd/openssh/lib # depends on libcrypto, libz -SUBDIR+= ../crypto/external/bsd/netpgp/lib # depends on libcrypto, ... -.endif - -SUBDIR+= ../external/bsd/libevent/lib # depends on libcrypto -.if ${MKDTRACE} != "no" -SUBDIR+= ../external/bsd/libproc/lib # depends on libstdc++, libctf -.endif -SUBDIR+= ../external/bsd/fetch/lib # depends on libssl - -.if (${MKLDAP} != "no") -SUBDIR+= ../external/bsd/openldap/lib # depends on libcrypto, ... -.endif - -#==================== 3rd library dependency barrier ==================== -SUBDIR+= .WAIT - -SUBDIR+= ../external/bsd/bind/lib # depends on heimdal, libcrypto - -.if ${MKDTRACE} != "no" -SUBDIR+= ../external/cddl/osnet/lib/libdtrace # depends on libproc -.endif - -.if (${MKRUMP} != "no") -SUBDIR+= librumpdev # depends on librump -SUBDIR+= librumpnet # depends on librump -SUBDIR+= librumpvfs # depends on librump -.endif - -.if (${MKPAM} != "no") -SUBDIR+= libpam # depends on heimdal -.endif - -.if (${MKCRYPTO} != "no") -SUBDIR+= ../crypto/external/bsd/libsaslc # depends on heimdal, openssl -.endif - -SUBDIR+= ../external/bsd/mdocml/lib - -.if (${MKRUMP} != "no") -#==================== 4th library dependency barrier ==================== -SUBDIR+= .WAIT - -SUBDIR+= libukfs # depends on librumpvfs, librump - -.if (${MKTPM} != "no") -SUBDIR+= ../crypto/external/cpl/trousers/lib -.endif - -#==================== 5th library dependency barrier ==================== -SUBDIR+= .WAIT - -SUBDIR+= libp2k # depends on libukfs, librumpvfs, libpuffs - -.if (${MKTPM} != "no") -SUBDIR+= ../crypto/external/cpl/tpm-tools/lib # depends on trousers -.endif - -.if !defined(BSD_MK_COMPAT_FILE) -SUBDIR+= ../sys/rump/dev/lib -SUBDIR+= ../sys/rump/fs/lib -SUBDIR+= ../sys/rump/kern/lib -SUBDIR+= ../sys/rump/net/lib -.endif -.endif - -# Lua bindings come last, they might depend on anything -SUBDIR+= lua - -# Needed by rump and rescue which are outside the smbfs tree -#SUBDIR+= ../external/bsd/smbfs/lib - -.include -.include diff --git a/lib/Makefile.inc b/lib/Makefile.inc deleted file mode 100644 index 66295152a..000000000 --- a/lib/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.7 2012/03/21 05:39:21 matt Exp $ - -WARNS?= 5 diff --git a/lib/bumpversion b/lib/bumpversion deleted file mode 100755 index cc8d1296c..000000000 --- a/lib/bumpversion +++ /dev/null @@ -1,127 +0,0 @@ -#!/bin/sh -# $NetBSD: bumpversion,v 1.10 2003/07/26 19:24:24 salo Exp $ -# -# Copyright (c) 1993 Christopher G. Demetriou -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed for the -# NetBSD Project. See http://www.NetBSD.org/ for -# information about NetBSD. -# 4. The name of the author may not be used to endorse or promote products -# derived from this software without specific prior written permission. -# -# 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. -# -# <> - -while : - do case "$1" in - # -c says to create new shlib_version files - -c) - create=TRUE - shift ;; - - # -n sets 'do nothing mode' - -n) - donothing=TRUE - shift ;; - - # -m says to bump major number, rather than minor number - -m) - bumpmajor=TRUE - shift ;; - - *) - break ;; - esac -done - -if [ $# = 0 ] ; then - echo "usage: $0 [-c] [-m] [-n] dir ..." - exit 2 -fi - -TMP=/tmp/bump$$ -error=0 - -trap 'rm -f $TMP ; exit 1' 1 2 3 13 15 - -for dir in $@ ; do - versf=$dir/shlib_version - - if [ "X$create" != "X" ] ; then - if [ ! -d $dir ] ; then - echo $0: $dir is not a directory 1>&2 - error=1 - continue - fi - if [ -e $versf ] ; then - echo $0: $versf exists\; not replacing 1>&2 - error=1 - continue - fi - else - if [ ! -e $versf ] ; then - echo $0: $versf does not exist 1>&2 - error=1 - continue - fi - if [ ! -f $versf ] ; then - echo $0: $versf is not a regular file 1>&2 - error=1 - continue - fi - if [ ! -r $versf ] ; then - echo $0: $versf is not readable 1>&2 - error=1 - continue - fi - if [ ! -w $versf ] ; then - echo $0: $versf is not a writable 1>&2 - error=1 - continue - fi - - . $versf - fi - - if [ "X$create" != "X" ] ; then - nmajor=0 - nminor=0 - elif [ "X$bumpmajor" != "X" ] ; then - nmajor=`expr $major + 1` - nminor=0 - else - nmajor=$major - nminor=`expr $minor + 1` - fi - - if [ "X$donothing" = "X" ] ; then - echo major=$nmajor > $TMP - echo minor=$nminor >> $TMP - mv $TMP $versf - else - echo "$0: $versf -> $nmajor.$nminor" - fi -done - -exit $error diff --git a/lib/checkoldver b/lib/checkoldver deleted file mode 100755 index 6bd7eb18a..000000000 --- a/lib/checkoldver +++ /dev/null @@ -1,155 +0,0 @@ -#!/bin/sh -# $NetBSD: checkoldver,v 1.3 2008/04/30 13:10:50 martin Exp $ -# -# Copyright (c) 2002 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Christos Zoulas. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -# checkoldver [dir ...] -# -# Looks in the given directories for old shared libraries and lists them -# Useful for: 'checkoldver /usr/lib | xargs rm -f' - -delete() { - obsol="$1.so" - if [ ! -z "$2" ] - then - obsol="$obsol.$2" - fi - if [ ! -z "$3" ] - then - obsol="$obsol.$3" - fi - if [ ! -z "$4" ] - then - obsol="$obsol.$4" - fi - echo $PWD/$obsol -} - -comparelib() { - OIFS="$IFS" - IFS="$IFS." - set -- $1 - IFS="$OIFS" - if [ "$3" = "[0-9]*" ] - then - return - fi - - if [ -z "$libmajor" ] - then - libname="$1" - libmajor="$3" - libminor="$4" - libtiny="$5" - return - fi - if [ "$libmajor" -lt "$3" ] - then - delete "$libname" "$libmajor" "$libminor" "$libtiny" - libmajor="$3" - libminor="$4" - libtiny="$5" - return - elif [ "$3" -lt "$libmajor" ] - then - delete "$libname" "$3" "$4" "$5" - return - fi - - if [ -z "$libminor" ] - then - return - fi - if [ "$libminor" -lt "$4" ] - then - delete "$libname" "$libmajor" "$libminor" "$libtiny" - libmajor="$3" - libminor="$4" - libtiny="$5" - return - elif [ "$4" -lt "$libminor" ] - then - delete "$libname" "$3" "$4" "$5" - return - fi - - if [ -z "$libtiny" ] - then - return - fi - if [ "$libtiny" -lt "$5" ] - then - delete "$libname" "$libmajor" "$libminor" "$libtiny" - libmajor="$3" - libminor="$4" - libtiny="$5" - return - elif [ "$5" -lt "$libminor" ] - then - delete "$libname" "$3" "$4" "$5" - return - fi -} - -processonedir() { - cd "$1" - for lib in lib*.so - do - lib="${lib#lib}" - lib="${lib%.so}" - - libmajor= - libminor= - libtiny= - for link in lib$lib.so.[0-9]*.[0-9]*.[0-9]* - do - comparelib "$link" - done - - libmajor= - libminor= - libtiny= - for link in lib$lib.so.[0-9]*.[0-9]* - do - comparelib "$link" - done - - libmajor= - libminor= - libtiny= - for link in lib$lib.so.[0-9]* - do - comparelib "$link" - done - done -} - -for i -do - processonedir "$i" -done diff --git a/lib/checkver b/lib/checkver deleted file mode 100755 index e7ad92017..000000000 --- a/lib/checkver +++ /dev/null @@ -1,232 +0,0 @@ -#!/bin/sh -# $NetBSD: checkver,v 1.16 2013/02/17 02:36:21 christos Exp $ -# -# Copyright (c) 1998 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Eric Haszlakiewicz. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -#--------------------------------------------------------------------# -# checkver - -# Check for libraries that appear to be newer than the -# one we're about to install. -# -# checkver [-q] [-v shlib_version_file] -d [installedlibdir [library name]]" -# checkver [-q] [-v shlib_version_file] -s [setlistdir [library name]]" -# checkver [-q] [-v shlib_version_file] -f liblistfile [library name]" -# -# One of -d, -s or -f must be specified. -# -# all: If library name is not specified it is assumed to -# be the name of the current directory. -# -# -d: Checks the version against the installed libraries. -# If no further arguments are given "/usr/lib" is -# used as the location of installed libraries. -# -# -s: Checks the version against the sets. If no argument -# follows the sets directory defaults to "/usr/src/distrib/sets/lists". -# The directory may be specified as either the top of the -# source tree or as the lists directory. -# -# -f: Checks the version against the provided list. A filename -# must be supplied. -# -# -v: Specify the filename of the shlib_version file. Defaults -# to "./shlib_version". -# -# This script produces no output if all library version are not -# large than the source version. If an installed library with a -# version greater than the source is found, checkver prints a -# header and a list of the names of the offending installed libraries. -# -# The header may be supressed by passing "-q" as the first argument. -# - -TMP=/tmp/checkver.$$ -PROG="$(basename "$0")" -# Can't trap 11 (SEGV) in the Real Bourne Shell, since it uses it for -# internal malloc! -trap "exit 2" 1 2 3 4 5 6 7 8 10 12 13 14 15 -trap "[ -d $TMP ] && rm -rf $TMP" 0 - -Usage() { -cat << EOF 1>&2 -Usage: $PROG [-q] [-v version_file] -d [installedlibdir [library name]] - $PROG [-q] [-v version_file] -s [setlistdir [library name]] - $PROG [-q] [-v version_file] -f liblistfile [library name] - $PROG is a script that looks for installed libraries with - versions greater than that in the version file. - For more information, read the comments. -EOF - exit 1 -} - -basedir=/usr/src -setsdir=$basedir/distrib/sets/lists -libdir=/usr/lib -shlib_version=./shlib_version - -error=0 -quiet=0 -usedir=0 -usefile=0 -usesets=0 -CWD=$(pwd) - -fixone() { - local instmajor=$(basename $1 | awk 'BEGIN { FS="." } { print $3 }') - local instminor=$(basename $1 | awk 'BEGIN { FS="." } { print $4 }') - local instteeny=$(basename $1 | awk 'BEGIN { FS="." } { print $5 + 0 }') - local ms="The following libraries have versions greater than the source" - - # If they're greater than the source, complain. - if [ "0$major" -eq "0$instmajor" ]; then - if [ "0$minor" -eq "0$instminor" ]; then - if [ "0$teeny" -lt "0$instteeny" ]; then - if [ $error -eq 0 -a $quiet -eq 0 ]; then - echo "$ms" 1>&2 - fi - echo $1 1>&2 - error=1 - fi - elif [ "0$minor" -lt "0$instminor" ]; then - if [ $error -eq 0 -a $quiet -eq 0 ]; then - echo "$ms" 1>&2 - fi - echo $1 1>&2 - error=1 - fi - elif [ "0$major" -lt "0$instmajor" ]; then - if [ $error -eq 0 -a $quiet -eq 0 ]; then - echo "$ms" 1>&2 - fi - echo $1 1>&2 - error=1 - fi -} - -while getopts df:shqv: f; do - case $f in - d) usedir=1 - if [ $usefile -eq 1 -o $usesets -eq 1 ]; then - Usage - fi;; - f) usefile=1; arg1=$OPTARG - if [ $usedir -eq 1 -o $usesets -eq 1 ]; then - Usage - fi;; - s) usesets=1 - if [ $usedir -eq 1 -o $usefile -eq 1 ]; then - Usage - fi;; - v) shlib_version=$OPTARG;; - q) quiet=1;; - *) Usage;; - esac -done - -shift $(($OPTIND - 1)) - -if [ $usedir -eq 0 -a $usefile -eq 0 -a $usesets -eq 0 ]; then - Usage -fi - -if [ $usefile -eq 1 ]; then - LIBLIST="$arg1" -else - if ! mkdir -m 0700 $TMP; then - echo "$PROG: Unable to create temp directory." 1>&2 - exit 2 - fi - LIBLIST=$TMP/libs.lst -fi - -# Build list from the installed libraries. -if [ $usedir -eq 1 ]; then - if [ -n "$1" ]; then - libdir="$1" - fi - for f in $libdir; do - ls $f/lib*.so.*.* - done > $LIBLIST 2> /dev/null -fi - -# Build list from set lists. Parameter may be either -# the "lists" directory or the top of the source tree. -if [ $usesets -eq 1 ]; then - if [ -n "$1" ]; then - setsdir="$1" - if [ -d "$setsdir/distrib/sets/lists" ]; then - setsdir="$setsdir/distrib/sets/lists" - fi - fi - (cd $setsdir; - cat */[a-z]* | - grep '^./usr/lib/lib.*\.so\.[0-9][0-9]*\.[0-9][0-9]*' | - sort -u > $LIBLIST) -fi - -# -# The file $LIBLIST now contains a list of libraries. -# -if [ -z "$2" ]; then - makefile=$CWD/Makefile - libname=$(grep '^LIB=' $makefile | sed -e 's/^LIB=[[:space:]]*//') - - # Assume the library name is the name of the current directory. - if [ -z "$libname" ]; then - libname=$(basename $CWD) - fi -else - libname="$2" -fi -echo $libname | grep "^lib" 1>&2 2> /dev/null -if [ $? != 0 ]; then - libname="lib$libname" -fi - - -if [ ! -f $shlib_version ]; then - echo "$PROG: unable to find $shlib_version" 1>&2 - exit 2 -fi - -# Grab major and minor numbers from the source. -. $shlib_version - -if [ -z "$minor" -o -z "$major" ]; then - echo "$PROG: $shlib_version doesn't contain the version." 1>&2 - exit 2 -fi - -# Find every shared object library with the same base name. -for instlib in $(grep $libname.so "$LIBLIST"); do - # Grab the major and minor from the installed library. - fixone "$instlib" -done - -exit $error diff --git a/lib/checkvers b/lib/checkvers deleted file mode 100755 index ebf27ff30..000000000 --- a/lib/checkvers +++ /dev/null @@ -1,210 +0,0 @@ -#!/bin/ksh -# $NetBSD: checkvers,v 1.7 2008/04/30 13:10:50 martin Exp $ -# -# Copyright (c) 1998 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Eric Haszlakiewicz. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -#--------------------------------------------------------------------# -# checkvers [-q] [systemlibdir [library name]] -# -# This is a wrapper script around checkver. It will find -# all directories withing the current directory containing -# a shlib_version file and call checkver for each. -# -# As with checkver, a list of directories of installed libraries -# may be specified. This will replace the default of "/usr/lib" -# and search there instead. -# -# A library name may also be specified. However, this script -# will not work correctly if it finds shlib_version files -# corresponding to a different library. -# -# This script produces no output if all library version are ok. -# If the versions aren't ok the header will be displayed once -# followed by a list of problematic libraries. -# - -# checkvers: -# if "-s", build list, pass with -f to checkver. -# if "-d", build list, pass with -f to checkver. -# if "-f", pass with -f to checkver. - - -# Cleanup on exit. -TMP=/tmp/checkvers.$$ -trap "exit 2" 1 2 3 4 5 6 7 8 10 11 12 13 14 15 -trap "rm -rf $TMP" 0 - -Usage ( ) { - echo "Usage: $1 [-q] -d [installedlibdir [library name]]" - echo " $1 [-q] -s [setlistdir [library name]]" - echo " $1 [-q] -f liblistfile [library name]" -} - -basedir=/usr/src -setsdir=$basedir/distrib/sets/lists -libdir=/usr/lib - -error=0 -quiet=0 -usedir=0 -usefile=0 -usesets=0 -CWD=`pwd` -args=`getopt "df:shq" "$@"` -if [ $? -ne 0 ] ; then - Usage $0 - exit 0 -fi - -set -- $args - -while . ; do - case "$1" in - -d) usedir=1 ; shift - if [ $usefile -eq 1 -o $usesets -eq 1 ]; then - Usage $0 ; exit 2 - fi;; - -f) usefile=1 ; arg1=$2 ; shift ; shift - if [ $usedir -eq 1 -o $usesets -eq 1 ]; then - Usage $0 ; exit 2 - fi;; - -s) usesets=1 ; shift - if [ $usedir -eq 1 -o $usefile -eq 1 ]; then - Usage $0 ; exit 2 - fi;; - -h) Usage $0 ; exit 0;; - -q) quiet=1 ; shift;; - --) shift ; break;; - esac -done - -if [ $usedir -eq 0 -a $usefile -eq 0 -a $usesets -eq 0 ] ; then - Usage $0 ; exit 2 -fi -if [ $usefile -eq 0 -a $# -gt 2 ] ; then - Usage $0 ; exit 2 -fi -if [ $usefile -eq 1 -a $# -gt 1 ] ; then - Usage $0 ; exit 2 -fi - -#-------------------------# - -QUIET= -LIBNAME= - -# Supress header. -if [ quiet -eq 1 ] ; then - QUIET="-q" -fi - -if ! mkdir -m 700 $TMP ; then - echo "$0: Unable to create temp directory." - exit 2 -fi - -if [ $usefile -eq 1 ] ; then - # Just pass the file name to checkver. - LIBLIST="$arg1" -else - LIBLIST=$TMP/libs.lst -fi - -# Build list from the installed libraries. -if [ $usedir -eq 1 ] ; then - if [ "X$1" != "X" ] ; then - libdir="$1" - fi - for f in $libdir ; do - ls $f/lib*.so.*.* - done > $LIBLIST 2> /dev/null -fi - -# Build list from set lists. Parameter may be either -# the "lists" directory or the top of the source tree. -if [ $usesets -eq 1 ] ; then - if [ "X$1" != "X" ] ; then - setsdir="$1" - if [ -d "$setsdir/distrib/sets/lists" ] ; then - setsdir="$setsdir/distrib/sets/lists" - fi - fi - (cd $setsdir ; - cat */[a-z]* | grep '^./usr/lib/lib.*\.so\.[0-9][0-9]*\.[0-9][0-9]*' \ - | sort -u > $LIBLIST - ) -fi - -if [ "X$2" != "X" ] ; then - LIBNAME="$2" -fi - -EXECDIR=`eval "(cd \`dirname $0\` ; pwd)"` - -CWD=`pwd` -VERFILES=`find $CWD -name shlib_version -print` - -for f in $VERFILES ; do - # Call checkver. We always have a list of libraries - # here, whether given to us or built, so always - # pass the -f flag. - (cd `dirname $f` ; - "sh $EXECDIR"/checkver $QUIET -f "$LIBLIST" "$LIBNAME" ; - exit $?) - ERR=$? - if [ $ERR -eq 2 ] ; then - echo "$0: checkver failed. LIBLIST=$LIBLIST $LIBNAME=$LIBNAME" - exit 2 - fi - if [ $ERR -ne 0 ] ; then - QUIET="-q" - error=1 - fi - - if [ "X$LIBNAME" = "X" ] ; then - # Build the library name from the directory it's in. - libname=`dirname $f` - libname=`basename $libname` - if ! echo $libname | grep -q "^lib" ; then - libname="lib$libname" - fi - else - libname="$LIBNAME" - fi - - if [ -e $TMP/$libname ] ; then - echo "Warning: $libname sources encountered multiple times." - echo " Previous location: `cat $TMP/$libname`" - echo " Current location: `dirname $f`" - fi - echo "`dirname $f`" > $TMP/$libname - -done - -exit $error diff --git a/lib/csu/Makefile b/lib/csu/Makefile deleted file mode 100644 index 8659714a5..000000000 --- a/lib/csu/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# $NetBSD: Makefile,v 1.35 2014/08/10 23:25:49 matt Exp $ - -.include - -.if defined(__MINIX) -USE_BITCODE:= no -.endif # defined(__MINIX) - -CSU_MACHINE_ARCH?= ${MACHINE_ARCH} -CSU_MACHINE_CPU?= ${MACHINE_CPU} - -.if !empty(CSU_MACHINE_ARCH:Mearm*) -ARCHDIR:= ${.CURDIR}/arch/earm -.elif exists(${.CURDIR}/arch/${CSU_MACHINE_ARCH}/Makefile.inc) -ARCHDIR:= ${.CURDIR}/arch/${CSU_MACHINE_ARCH} -.elif exists(${.CURDIR}/arch/${CSU_MACHINE_CPU}/Makefile.inc) -ARCHDIR:= ${.CURDIR}/arch/${CSU_MACHINE_CPU} -.else -.error Architecture (${CSU_MACHINE_ARCH} or ${CSU_MACHINE_CPU}) unsupported -.endif - - -.PATH: ${ARCHDIR} -.include "${ARCHDIR}/Makefile.inc" -.include "${.CURDIR}/common/Makefile.inc" diff --git a/lib/csu/arch/aarch64/Makefile.inc b/lib/csu/arch/aarch64/Makefile.inc deleted file mode 100644 index b957404a8..000000000 --- a/lib/csu/arch/aarch64/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:36 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -CPPFLAGS+= -DHAVE_INITFINI_ARRAY -#CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\" diff --git a/lib/csu/arch/aarch64/crt0.S b/lib/csu/arch/aarch64/crt0.S deleted file mode 100644 index 4fff4f77e..000000000 --- a/lib/csu/arch/aarch64/crt0.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: crt0.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.1 2014/08/10 05:47:36 matt Exp $") - -STRONG_ALIAS(_start,__start) - -_ENTRY(__start) - /* - * void ___start(void (*cleanup)(void), const Obj_Entry *obj, - * struct ps_strings *ps_strings); - */ - b ___start -END(__start) diff --git a/lib/csu/arch/aarch64/crtbegin.h b/lib/csu/arch/aarch64/crtbegin.h deleted file mode 100644 index ffef0ada2..000000000 --- a/lib/csu/arch/aarch64/crtbegin.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -static void __do_global_ctors_aux(void) __attribute__((__constructor__)) __used; -#ifdef SHARED -static void __do_global_dtors_aux(void) __attribute__((__destructor__)) __used; -#endif diff --git a/lib/csu/arch/aarch64/crtend.S b/lib/csu/arch/aarch64/crtend.S deleted file mode 100644 index f90161f48..000000000 --- a/lib/csu/arch/aarch64/crtend.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.1 2014/08/10 05:47:36 matt Exp $") - - .section .eh_frame, "a", %progbits - .p2align 3 - .global __EH_FRAME_END__ - .hidden __EH_FRAME_END__ -__EH_FRAME_END__: - .space 8 - - .section .jcr, "aw", %progbits - .p2align 3 - .global __JCR_END__ - .hidden __JCR_END__ -__JCR_END__: - .space 8 diff --git a/lib/csu/arch/aarch64/crti.S b/lib/csu/arch/aarch64/crti.S deleted file mode 100644 index 32e4dbf47..000000000 --- a/lib/csu/arch/aarch64/crti.S +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2014/08/10 05:47:36 matt Exp $") - -#include "sysident.S" - -/* - * Since ARM EABI uses .init_array/.fini_array, - * there is no need for .init/.fini - */ diff --git a/lib/csu/arch/aarch64/crtn.S b/lib/csu/arch/aarch64/crtn.S deleted file mode 100644 index 8986480ab..000000000 --- a/lib/csu/arch/aarch64/crtn.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/* no need for anything here since AAPCS64 uses .init_array/.fini_array */ diff --git a/lib/csu/arch/alpha/Makefile.inc b/lib/csu/arch/alpha/Makefile.inc deleted file mode 100644 index d30d4e602..000000000 --- a/lib/csu/arch/alpha/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2013/07/11 16:40:27 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -DELFSIZE=64 diff --git a/lib/csu/arch/alpha/crt0.S b/lib/csu/arch/alpha/crt0.S deleted file mode 100644 index 69caabf86..000000000 --- a/lib/csu/arch/alpha/crt0.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: crt0.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.1 2013/07/11 16:40:27 matt Exp $") - -STRONG_ALIAS(_start,__start) - -/* - * Assumes kernel (or ld_elf.so) passes the following parameters to - * user-space in registers: - * - * a0 stack pointer - * a1 cleanup - * a2 Obj_Entry - * a3 ps_strings - */ - -LEAF(__start, 4) - LDGP(pv) - mov a1, a0 /* cleanup */ - mov a2, a1 /* Obj_Entry */ - mov a3, a2 /* ps_strings */ - CALL(___start) -END(__start) diff --git a/lib/csu/arch/alpha/crtbegin.h b/lib/csu/arch/alpha/crtbegin.h deleted file mode 100644 index 89571766f..000000000 --- a/lib/csu/arch/alpha/crtbegin.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.1 2013/07/11 16:40:27 matt Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -/* Assume we need to reload our GP. */ -__asm( ".pushsection .init" -"\n\t" "br $29, 1f" -"\n\t" "1: ldgp $29, 0($29)" -"\n\t" "unop" -"\n\t" "jsr $26, __do_global_ctors_aux" -"\n\t" ".p2align 3" -"\n\t" ".popsection"); - -/* Assume we need to reload our GP. */ -__asm( ".pushsection .fini" -"\n\t" "br $29, 1f" -"\n\t" "1: ldgp $29, 0($29)" -"\n\t" "unop" -"\n\t" "jsr $26, __do_global_dtors_aux" -"\n\t" ".p2align 3" -"\n\t" ".popsection"); diff --git a/lib/csu/arch/alpha/crtend.S b/lib/csu/arch/alpha/crtend.S deleted file mode 100644 index 931cb86ff..000000000 --- a/lib/csu/arch/alpha/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 16:40:27 matt Exp $") - - .section .ctors, "aw", @progbits - .p2align 3 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .word 0 - - .section .dtors, "aw", @progbits - .p2align 3 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .word 0 - - .section .eh_frame, "a", @progbits - .p2align 3 - .word 0 - - .section .jcr, "aw", @progbits - .p2align 3 - .word 0 diff --git a/lib/csu/arch/alpha/crtfm.c b/lib/csu/arch/alpha/crtfm.c deleted file mode 100644 index bfafe484f..000000000 --- a/lib/csu/arch/alpha/crtfm.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: crtfm.c,v 1.1 2013/08/05 13:38:35 matt Exp $ */ - -/* - * Copyright (c) 2002 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Jason R. Thorpe for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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. - */ - -/* - * Support for the GCC "-ffast-math" option on the Alpha. - */ - -#include - -#include -#include - -/* - * Must provide this wrapper around sysarch(2) so that statically-linked - * programs work properly. - */ - -extern void __alpha_sysarch(int, void *); - -__asm(".ent __alpha_sysarch 0 ;\n" -"__alpha_sysarch: ;\n" -" ldiq $0, 165 ;\n" /* v0 = SYS_sysarch */ -" call_pal 0x0083 ;\n" /* PAL_OSF1_callsys */ -" ret $31,($26),1 ;\n" -".end __alpha_sysarch"); - -static void __attribute__((__constructor__)) -__alpha_set_fast_math(void) -{ - struct alpha_fp_c_args args; - - args.fp_c = IEEE_MAP_DMZ|IEEE_MAP_UMZ; - __alpha_sysarch(ALPHA_SET_FP_C, &args); -} diff --git a/lib/csu/arch/alpha/crti.S b/lib/csu/arch/alpha/crti.S deleted file mode 100644 index 5385d8ccb..000000000 --- a/lib/csu/arch/alpha/crti.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2013/07/11 16:40:27 matt Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .global _init - .type _init, @function -_init: - LDGP(pv) - lda sp, -32(sp) - stq ra, 0(sp) - stq gp, 8(sp) - .p2align 5 - - .section ".fini", "ax", @progbits - .global _fini - .type _fini, @function -_fini: - LDGP(pv) - lda sp, -32(sp) - stq ra, 0(sp) - stq gp, 8(sp) - .p2align 5 diff --git a/lib/csu/arch/alpha/crtn.S b/lib/csu/arch/alpha/crtn.S deleted file mode 100644 index 1cebc5a97..000000000 --- a/lib/csu/arch/alpha/crtn.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2013/07/11 16:40:27 matt Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2013/07/11 16:40:27 matt Exp $") - - .section ".init", "ax", @progbits - ldq gp, 8(sp) - ldq ra, 0(sp) - lda sp, 32(sp) - RET - - .section ".fini", "ax", @progbits - ldq gp, 8(sp) - ldq ra, 0(sp) - lda sp, 32(sp) - RET diff --git a/lib/csu/arch/arm/Makefile.inc b/lib/csu/arch/arm/Makefile.inc deleted file mode 100644 index 8950d1e13..000000000 --- a/lib/csu/arch/arm/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.7 2013/09/10 22:00:01 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -.if (!empty(CPUFLAGS) && ${CPUFLAGS:M-mabi=aapcs*} != "") -CPPFLAGS+= -DHAVE_INITFINI_ARRAY -.endif -CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\" diff --git a/lib/csu/arch/arm/crt0.S b/lib/csu/arch/arm/crt0.S deleted file mode 100644 index a8f7d1961..000000000 --- a/lib/csu/arch/arm/crt0.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crt0.S,v 1.3 2012/08/11 07:25:44 matt Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.3 2012/08/11 07:25:44 matt Exp $") - -STRONG_ALIAS(_start,__start) - -_ENTRY(__start) - /* - * We need to swap ps_strings and cleanup - */ - mov ip, r0 /* ps_strings -> tmp */ - mov r0, r2 /* cleanup -> ps_strings */ - mov r2, ip /* tmp -> ps_strings */ - - /* Ensure the stack is properly aligned before calling C code. */ - bic sp, sp, #7 - - /* - * void ___start(void (*cleanup)(void), - * const Obj_Entry *obj, - * struct ps_strings *ps_strings); - */ - - b ___start diff --git a/lib/csu/arch/arm/crtbegin.h b/lib/csu/arch/arm/crtbegin.h deleted file mode 100644 index 134eecc38..000000000 --- a/lib/csu/arch/arm/crtbegin.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -__asm( - ".pushsection .init, \"ax\", %progbits" -"\n\t" "bl __do_global_ctors_aux" -"\n\t" ".popsection"); - -__asm( - ".pushsection .fini, \"ax\", %progbits" -"\n\t" "bl __do_global_dtors_aux" -"\n\t" ".popsection"); diff --git a/lib/csu/arch/arm/crtend.S b/lib/csu/arch/arm/crtend.S deleted file mode 100644 index fd8a62a7d..000000000 --- a/lib/csu/arch/arm/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.2 2012/08/11 07:26:25 matt Exp $ */ -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.2 2012/08/11 07:26:25 matt Exp $") - - .section .ctors, "aw", %progbits - .p2align 2 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .space 4 - - .section .dtors, "aw", %progbits - .p2align 2 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .space 4 - - .section .eh_frame, "a", %progbits - .p2align 2 - .space 4 - - .section .jcr, "aw", %progbits - .p2align 2 - .space 4 diff --git a/lib/csu/arch/arm/crti.S b/lib/csu/arch/arm/crti.S deleted file mode 100644 index 1e576fdbe..000000000 --- a/lib/csu/arch/arm/crti.S +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: crti.S,v 1.2 2012/08/11 01:33:36 matt Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.2 2012/08/11 01:33:36 matt Exp $") - -#include "sysident.S" - - .section ".init", "ax", %progbits - .align 0 - .globl _init - .type _init,%function -_init: - mov ip, sp - stmfd sp!, {fp, ip, lr, pc} - sub fp, ip, #4 - - .section ".fini", "ax", %progbits - .align 0 - .globl _fini - .type _fini,%function -_fini: - mov ip, sp - stmfd sp!, {fp, ip, lr, pc} - sub fp, ip, #4 diff --git a/lib/csu/arch/arm/crtn.S b/lib/csu/arch/arm/crtn.S deleted file mode 100644 index ce0939975..000000000 --- a/lib/csu/arch/arm/crtn.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: crtn.S,v 1.2 2012/08/11 01:33:36 matt Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.2 2012/08/11 01:33:36 matt Exp $") - - .section ".init", "ax", %progbits - ldmea fp, {fp, sp, pc} - - .section ".fini", "ax", %progbits - ldmea fp, {fp, sp, pc} diff --git a/lib/csu/arch/earm/Makefile.inc b/lib/csu/arch/earm/Makefile.inc deleted file mode 100644 index f70405821..000000000 --- a/lib/csu/arch/earm/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2013/09/10 16:45:33 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -CPPFLAGS+= -DHAVE_INITFINI_ARRAY -CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\" diff --git a/lib/csu/arch/earm/crt0.S b/lib/csu/arch/earm/crt0.S deleted file mode 100644 index 8c1ae23ed..000000000 --- a/lib/csu/arch/earm/crt0.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: crt0.S,v 1.3 2013/09/05 00:27:38 matt Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.3 2013/09/05 00:27:38 matt Exp $") - -STRONG_ALIAS(_start,__start) - -_ENTRY(__start) - /* - * We need to swap ps_strings and cleanup - */ - mov ip, r0 /* ps_strings -> tmp */ - mov r0, r2 /* cleanup -> ps_strings */ - mov r2, ip /* tmp -> ps_strings */ - - /* Ensure the stack is properly aligned before calling C code. */ -#if !defined(__thumb__) - bic sp, sp, #7 -#else - movs r6, #7 - mov r7, sp - bics r7, r7, r6 - mov sp, r7 -#endif - - /* - * void ___start(void (*cleanup)(void), - * const Obj_Entry *obj, - * struct ps_strings *ps_strings); - */ - - b ___start diff --git a/lib/csu/arch/earm/crtbegin.h b/lib/csu/arch/earm/crtbegin.h deleted file mode 100644 index c786bafa5..000000000 --- a/lib/csu/arch/earm/crtbegin.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.2 2014/05/06 16:02:10 joerg Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -static void __do_global_ctors_aux(void) __attribute__((__constructor__)) __used; -#ifdef SHARED -static void __do_global_dtors_aux(void) __attribute__((__destructor__)) __used; -#endif - -#if !defined(SHARED) && !defined(__ARM_DWARF_EH__) -static const void *find_exidx(void *, int *) __used; - -static const void * -find_exidx(void * pc, int * pcount) -{ - extern __dso_hidden const char __exidx_start[]; - extern __dso_hidden const char __exidx_end[]; - - *pcount = (__exidx_end - __exidx_start) / 8; - return __exidx_start; -} - -__weak_alias(__gnu_Uwind_find_exidx,find_exidx) -#endif /* !SHARED && !__ARM_DWARF_EH__ */ diff --git a/lib/csu/arch/earm/crtend.S b/lib/csu/arch/earm/crtend.S deleted file mode 100644 index f196954e4..000000000 --- a/lib/csu/arch/earm/crtend.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: crtend.S,v 1.2 2013/12/20 15:35:48 joerg Exp $ */ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.2 2013/12/20 15:35:48 joerg Exp $") - - .eabi_attribute 18, 4 /* sizeof(wchar_t) */ - .eabi_attribute 23, 0 /* doesn't use floating point */ - .eabi_attribute 24, 1 /* 8 byte alignment permitted */ - .eabi_attribute 25, 1 /* preserves 8-byte alignment */ - .eabi_attribute 26, 2 /* enums are 32-bits */ - - .section .eh_frame, "a", %progbits - .p2align 2 - .global __EH_FRAME_END__ - .hidden __EH_FRAME_END__ -__EH_FRAME_END__: - .space 4 - - .section .jcr, "aw", %progbits - .p2align 2 - .global __JCR_END__ - .hidden __JCR_END__ -__JCR_END__: - .space 4 diff --git a/lib/csu/arch/earm/crti.S b/lib/csu/arch/earm/crti.S deleted file mode 100644 index 6bec16b0f..000000000 --- a/lib/csu/arch/earm/crti.S +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2012/08/13 02:49:04 matt Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2012/08/13 02:49:04 matt Exp $") - -#include "sysident.S" - -/* - * Since ARM EABI uses .init_array/.fini_array, - * there is no need for .init/.fini - */ diff --git a/lib/csu/arch/earm/crtn.S b/lib/csu/arch/earm/crtn.S deleted file mode 100644 index 0544e7b63..000000000 --- a/lib/csu/arch/earm/crtn.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2012/08/13 02:49:04 matt Exp $ */ - -/* no need for anything here since ARM EABI uses .init_array/.fini_array */ diff --git a/lib/csu/arch/hppa/Makefile.inc b/lib/csu/arch/hppa/Makefile.inc deleted file mode 100644 index 454c25576..000000000 --- a/lib/csu/arch/hppa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2013/07/13 18:52:35 skrll Exp $ - -CPPFLAGS+= -DELFSIZE=32 -I${ARCHDIR} diff --git a/lib/csu/arch/hppa/crt0.S b/lib/csu/arch/hppa/crt0.S deleted file mode 100644 index 2d954ea4b..000000000 --- a/lib/csu/arch/hppa/crt0.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: crt0.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nick Hudson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.1 2013/07/13 18:52:35 skrll Exp $") - - .import _GLOBAL_OFFSET_TABLE_ - .hidden ___start - -STRONG_ALIAS(__start,_start) - -/* - * void _start(struct ps_strings *ps_strings, - * void (*cleanup)(void), - * const Obj_Entry *obj); - */ -_ENTRY(_start) - .callinfo frame=0, calls - .entry - - bl L$lpc, %r27 - depi 0, 31, 2, %r27 -L$lpc: addil L'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 8), %r27 - ldo R'_GLOBAL_OFFSET_TABLE_ - ($PIC_pcrel$0 - 12)(%r1),%r27 - copy %r27, %r19 - - /* - * void ___start(void (*cleanup)(void), - * const Obj_Entry *obj, - * struct ps_strings *ps_strings); - */ - copy %arg0, %arg3 ; ps_strings -> tmp - copy %arg1, %arg0 ; cleanup -> arg0 - copy %arg2, %arg1 ; obj -> arg1 - b ___start - copy %arg3, %arg2 ; ps_strings (tmp) -> arg2 - -EXIT(_start) diff --git a/lib/csu/arch/hppa/crtbegin.h b/lib/csu/arch/hppa/crtbegin.h deleted file mode 100644 index 9bbf129d1..000000000 --- a/lib/csu/arch/hppa/crtbegin.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD*/ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nick Hudson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__asm( "\n\t" - ".pushsection .init, \"ax\", @progbits" "\n\t" - "bl __do_global_ctors_aux, %rp" "\n\t" - " nop" "\n\t" - ".popsection"); - -__asm( "\n\t" - ".pushsection .fini, \"ax\", @progbits" "\n\t" - "bl __do_global_dtors_aux, %rp" "\n\t" - " nop" "\n\t" - ".popsection"); - diff --git a/lib/csu/arch/hppa/crtend.S b/lib/csu/arch/hppa/crtend.S deleted file mode 100644 index 9623c5000..000000000 --- a/lib/csu/arch/hppa/crtend.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */ - -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtend.S,v 1.1 2013/07/13 18:52:35 skrll Exp $") - - .section .ctors, "aw", @progbits - .align 4 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .long 0 - - .section .dtors, "aw", @progbits - .align 4 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .long 0 - - .section .eh_frame, "a", @progbits - .align 4 - .long 0 - - .section .jcr, "aw", @progbits - .align 4 - .long 0 diff --git a/lib/csu/arch/hppa/crti.S b/lib/csu/arch/hppa/crti.S deleted file mode 100644 index 925facc27..000000000 --- a/lib/csu/arch/hppa/crti.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nick Hudson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2013/07/13 18:52:35 skrll Exp $") - -#include "sysident.S" - -#define MD_SECTION_PROLOGUE(sect, entry_pt) \ - .section sect,"ax",@progbits ! \ - .global entry_pt ! \ - .proc ! \ - .callinfo frame=HPPA_FRAME_SIZE, calls, save_rp, save_sp, entry_gr=3 ! \ - .entry ! \ - entry_pt: ! \ - stw %rp, HPPA_FRAME_CRP(%sp) ! \ - copy %r3, %r1 ! \ - copy %sp, %r3 ! \ - stw,ma %r1, HPPA_FRAME_SIZE(%sp) ! \ - /* fall thru */ ! \ - .exit ! \ - .procend ! \ - .previous - -MD_SECTION_PROLOGUE(.init, _init) -MD_SECTION_PROLOGUE(.fini, _fini) diff --git a/lib/csu/arch/hppa/crtn.S b/lib/csu/arch/hppa/crtn.S deleted file mode 100644 index e1ac472b6..000000000 --- a/lib/csu/arch/hppa/crtn.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2013/07/13 18:52:35 skrll Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nick Hudson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2013/07/13 18:52:35 skrll Exp $") - -#define MD_SECTION_EPILOGUE(sect) \ - .section #sect,"ax",@progbits ! \ - ldw HPPA_FRAME_CRP(%r3) ,%rp ! \ - ldo HPPA_FRAME_SIZE(%r3), %sp ! \ - ldw,mb -HPPA_FRAME_SIZE(%sp), %r3 ! \ - bv,n %r0(%rp) ! \ - .previous - -MD_SECTION_EPILOGUE(.init) -MD_SECTION_EPILOGUE(.fini) diff --git a/lib/csu/arch/i386/Makefile.inc b/lib/csu/arch/i386/Makefile.inc deleted file mode 100644 index 77519435c..000000000 --- a/lib/csu/arch/i386/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:33 joerg Exp $ - -CPPFLAGS+= -DELFSIZE=32 - - diff --git a/lib/csu/arch/i386/crt0.S b/lib/csu/arch/i386/crt0.S deleted file mode 100644 index 9adabdd21..000000000 --- a/lib/csu/arch/i386/crt0.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $ */ - -/* - * Copyright (c) 1998 Christos Zoulas - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $") - - .hidden ___start - -STRONG_ALIAS(_start,__start) -_ENTRY(__start) - pushl %ebx - pushl %ecx - pushl %edx - call ___start diff --git a/lib/csu/arch/i386/crtbegin.S b/lib/csu/arch/i386/crtbegin.S deleted file mode 100644 index 0f44ed264..000000000 --- a/lib/csu/arch/i386/crtbegin.S +++ /dev/null @@ -1,174 +0,0 @@ -/* $NetBSD: crtbegin.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtbegin.S,v 1.1 2010/08/07 18:01:33 joerg Exp $") - - .section .ctors, "aw", @progbits - .align 4 -__CTOR_LIST__: - .long -1 - - .section .dtors, "aw", @progbits - .align 4 -__DTOR_LIST__: - .long -1 - - .section .eh_frame, "a", @progbits - .align 4 -__EH_FRAME_LIST__: - - .section .jcr, "aw", @progbits - .align 4 -__JCR_LIST__: - - .section .data.rel, "aw", @progbits - .align 4 - .type __dso_handle, @object - .size __dso_handle, 4 - .globl __dso_handle - .hidden __dso_handle -__dso_handle: -#ifdef SHARED - .long __dso_handle -#else - .long 0 -#endif - -__dwarf_eh_object: - .zero 32 - -__initialized: - .zero 1 -__finished: - .zero 1 - - .text - .weak __cxa_finalize - .weak __deregister_frame_info - .weak __register_frame_info - .weak _Jv_RegisterClasses - -__get_thunk: - movl (%esp), %ebx - ret - -__do_global_dtors_aux: - pushl %ebx - pushl %edi - subl $8, %esp - call __get_thunk - addl $_GLOBAL_OFFSET_TABLE_, %ebx - - cmpb $0, __finished@GOTOFF(%ebx) - jne 4f - movb $1, __finished@GOTOFF(%ebx) - -#ifdef SHARED - cmpl $0, __cxa_finalize@GOT(%ebx) - je 1f - movl __dso_handle@GOTOFF(%ebx), %eax - movl %eax, (%esp) - call __cxa_finalize@PLT -1: -#endif - - leal 4+__DTOR_LIST__@GOTOFF(%ebx), %edi -2: - movl (%edi), %eax - testl %eax, %eax - je 3f - call *%eax - addl $8, %edi - jmp 2b -3: - - cmpl $0, __deregister_frame_info@GOT(%ebx) - je 4f - leal __EH_FRAME_LIST__@GOTOFF(%ebx), %eax - movl %eax, (%esp) - call __deregister_frame_info@PLT -4: - addl $8, %esp - popl %edi - popl %ebx - ret - - -__do_global_ctors_aux: - pushl %ebx - pushl %edi - subl $8, %esp - call __get_thunk - addl $_GLOBAL_OFFSET_TABLE_, %ebx - - cmpb $0, __initialized@GOTOFF(%ebx) - jne 4f - movb $1, __initialized@GOTOFF(%ebx) - - cmpl $0, __register_frame_info@GOT(%ebx) - je 1f - leal __dwarf_eh_object@GOTOFF(%ebx), %edi - movl %edi, 4(%esp) - leal __EH_FRAME_LIST__@GOTOFF(%ebx), %edi - movl %edi, (%esp) - call __register_frame_info@PLT - -1: - cmpl $0, _Jv_RegisterClasses@GOT(%ebx) - je 2f - leal __JCR_LIST__@GOTOFF(%ebx), %edi - movl (%edi), %edi - testl %edi, %edi - je 2f - movl %edi, (%esp) - call _Jv_RegisterClasses@PLT -2: - - leal -4+__CTOR_LIST_END__@GOTOFF(%ebx), %edi -3: - movl (%edi), %eax - cmpl $-1, %eax - je 4f - call *%eax - subl $4, %edi - jmp 3b - -4: - addl $8, %esp - popl %edi - popl %ebx - ret - - .section .init, "ax", @progbits - call __do_global_ctors_aux - .section .fini, "ax", @progbits - call __do_global_dtors_aux diff --git a/lib/csu/arch/i386/crtend.S b/lib/csu/arch/i386/crtend.S deleted file mode 100644 index adef13d07..000000000 --- a/lib/csu/arch/i386/crtend.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtend.S,v 1.1 2010/08/07 18:01:33 joerg Exp $") - - .section .ctors, "aw", @progbits - .align 4 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .long 0 - - .section .dtors, "aw", @progbits - .align 4 - .long 0 - - .section .eh_frame, "a", @progbits - .align 4 - .long 0 - - .section .jcr, "aw", @progbits - .align 4 - .long 0 diff --git a/lib/csu/arch/i386/crti.S b/lib/csu/arch/i386/crti.S deleted file mode 100644 index fbc5ddd72..000000000 --- a/lib/csu/arch/i386/crti.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:33 joerg Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .align 16 - .globl _init -_init: - pushl %ebp - movl %esp, %ebp - - .section ".fini", "ax", @progbits - .align 16 - .globl _fini -_fini: - pushl %ebp - movl %esp, %ebp diff --git a/lib/csu/arch/i386/crtn.S b/lib/csu/arch/i386/crtn.S deleted file mode 100644 index 644d6a63e..000000000 --- a/lib/csu/arch/i386/crtn.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - - .section ".init", "ax", @progbits - leave - ret - - .section ".fini", "ax", @progbits - leave - ret diff --git a/lib/csu/arch/ia64/Makefile.inc b/lib/csu/arch/ia64/Makefile.inc deleted file mode 100644 index 9e5deaf99..000000000 --- a/lib/csu/arch/ia64/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/03/14 18:15:02 cherry Exp $ - -CPPFLAGS+= -DELFSIZE=64 -I${ARCHDIR} diff --git a/lib/csu/arch/ia64/crt0.S b/lib/csu/arch/ia64/crt0.S deleted file mode 100644 index 992a5ba8a..000000000 --- a/lib/csu/arch/ia64/crt0.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: crt0.S,v 1.1 2014/03/14 18:15:02 cherry Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Cherry G. Mathew of Backyard Innovations, UK, Ltd. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.1 2014/03/14 18:15:02 cherry Exp $") - -STRONG_ALIAS(_start,__start) - -.proc __start -.global __start - -/* - * Called with: - * in0 = cleanup - * in1 = obj - * in2 = ps_strings - * in3 = sp - * See: sys/arch/ia64/ia64/machdep.c:setregs() - */ - -__start: - .regstk 4, 0, 0, 0 - - mov sp = in3 /* Setup Memory Stack Pointer. */ - alloc r31 = ar.pfs, 3, 0, 0, 0 /* Adjust backingstore for ___start() */ - br.call.sptk.many rp = ___start - diff --git a/lib/csu/arch/ia64/crtbegin.h b/lib/csu/arch/ia64/crtbegin.h deleted file mode 100644 index aaa1b3640..000000000 --- a/lib/csu/arch/ia64/crtbegin.h +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2013, 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry and - * Cherry G. Mathew of Backyard Innovations, UK, Ltd. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__asm( "\n\t" - ".pushsection .init, \"ax\", @progbits" "\n\t" - "br.call.sptk.many b0 = __do_global_ctors_aux" "\n\t" - " nop 0" "\n\t" - ".popsection"); - -__asm( "\n\t" - ".pushsection .fini, \"ax\", @progbits" "\n\t" - "br.call.sptk.many b0 = __do_global_dtors_aux" "\n\t" - " nop 0" "\n\t" - ".popsection"); diff --git a/lib/csu/arch/ia64/crtend.S b/lib/csu/arch/ia64/crtend.S deleted file mode 100644 index 73b028f4d..000000000 --- a/lib/csu/arch/ia64/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2014/03/14 18:15:02 cherry Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtend.S,v 1.1 2014/03/14 18:15:02 cherry Exp $") - - .section .ctors, "aw", @progbits - .align 8 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .quad 0 - - .section .dtors, "aw", @progbits - .align 8 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .quad 0 - - .section .eh_frame, "a", @progbits - .align 8 - .quad 0 - - .section .jcr, "aw", @progbits - .align 8 - .quad 0 diff --git a/lib/csu/arch/ia64/crti.S b/lib/csu/arch/ia64/crti.S deleted file mode 100644 index 1511cea78..000000000 --- a/lib/csu/arch/ia64/crti.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2014/03/14 18:15:02 cherry Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Cherry G. Mathew of Backyard Innovations, UK, Ltd. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2014/03/14 18:15:02 cherry Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .align 64 - .proc _init - .global _init -_init: - .regstk 0, 2, 0, 0 - .prologue 12, loc0 - .save ar.pfs, loc1 - alloc loc1 = ar.pfs, 0, 2, 0, 0 - mov loc0 = b0 /* return addr */ - .endp _init - - .section ".fini", "ax", @progbits - .align 64 - .proc _fini - .global _fini -_fini: - .regstk 0, 2, 0, 0 - .prologue 12, loc0 - .save ar.pfs, loc1 - alloc loc1 = ar.pfs, 0, 2, 0, 0 - mov loc0 = b0 /* return addr */ - .endp _fini - - diff --git a/lib/csu/arch/ia64/crtn.S b/lib/csu/arch/ia64/crtn.S deleted file mode 100644 index a01536fa6..000000000 --- a/lib/csu/arch/ia64/crtn.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2014/03/14 18:15:02 cherry Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Cherry G. Mathew of Backyard Innovations, UK, Ltd. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2014/03/14 18:15:02 cherry Exp $") - - .section ".init", "ax", @progbits - .regstk 0, 2, 0, 0 - mov b0 = loc0 - mov ar.pfs = loc1 - br.ret.sptk.many b0 - - .section ".fini", "ax", @progbits - .regstk 0, 2, 0, 0 - mov b0 = loc0 - mov ar.pfs = loc1 - br.ret.sptk.many b0 diff --git a/lib/csu/arch/m68k/Makefile.inc b/lib/csu/arch/m68k/Makefile.inc deleted file mode 100644 index 2bc42704c..000000000 --- a/lib/csu/arch/m68k/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2013/07/11 17:07:35 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -DELFSIZE=32 - - diff --git a/lib/csu/arch/m68k/crt0.S b/lib/csu/arch/m68k/crt0.S deleted file mode 100644 index e27662228..000000000 --- a/lib/csu/arch/m68k/crt0.S +++ /dev/null @@ -1,48 +0,0 @@ -#include - -/* - * Copyright (c) 1999 Klaus Klein - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - * - * <> - */ - -RCSID("$NetBSD: crt0.S,v 1.4 2013/07/26 19:49:19 matt Exp $") - -STRONG_ALIAS(_start,__start) - -_ENTRY(__start) - movl %a2,-(%sp) | ps_strings - movl %a0,-(%sp) | obj - movl %a1,-(%sp) | cleanup - | call: ___start(cleanup, obj, ps_strings) - jbsr ___start -END(__start) diff --git a/lib/csu/arch/m68k/crtbegin.h b/lib/csu/arch/m68k/crtbegin.h deleted file mode 100644 index 167ea0804..000000000 --- a/lib/csu/arch/m68k/crtbegin.h +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.4 2013/07/27 13:07:06 martin Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__asm( ".pushsection .init" -#ifdef __pic__ -"\n\t" "bsrl __do_global_ctors_aux" -#else -"\n\t" "jsr __do_global_ctors_aux" -#endif -"\n\t" ".popsection"); - -__asm( ".pushsection .fini" -#ifdef __pic__ -"\n\t" "bsrl __do_global_dtors_aux" -#else -"\n\t" "jsr __do_global_dtors_aux" -#endif -"\n\t" ".popsection"); diff --git a/lib/csu/arch/m68k/crtend.S b/lib/csu/arch/m68k/crtend.S deleted file mode 100644 index 864d0bd7c..000000000 --- a/lib/csu/arch/m68k/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2013/07/11 17:07:35 matt Exp $ */ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 17:07:35 matt Exp $") - - .section .ctors, "aw", @progbits - .p2align 2 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .long 0 - - .section .dtors, "aw", @progbits - .p2align 2 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .long 0 - - .section .eh_frame, "a", @progbits - .p2align 2 - .long 0 - - .section .jcr, "aw", @progbits - .p2align 2 - .long 0 diff --git a/lib/csu/arch/m68k/crti.S b/lib/csu/arch/m68k/crti.S deleted file mode 100644 index df84a46ca..000000000 --- a/lib/csu/arch/m68k/crti.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .align 2 - .globl _init -_init: - - .section ".fini", "ax", @progbits - .align 2 - .globl _fini -_fini: diff --git a/lib/csu/arch/m68k/crtn.S b/lib/csu/arch/m68k/crtn.S deleted file mode 100644 index 9614561a0..000000000 --- a/lib/csu/arch/m68k/crtn.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - - .section ".init", "ax", @progbits - rts - - .section ".fini", "ax", @progbits - rts diff --git a/lib/csu/arch/mips/Makefile.inc b/lib/csu/arch/mips/Makefile.inc deleted file mode 100644 index 80826ffe5..000000000 --- a/lib/csu/arch/mips/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2013/07/10 15:05:46 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -DELFSIZE=_MIPS_SZPTR diff --git a/lib/csu/arch/mips/crt0.S b/lib/csu/arch/mips/crt0.S deleted file mode 100644 index ef7c8ddf3..000000000 --- a/lib/csu/arch/mips/crt0.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: crt0.S,v 1.3 2013/12/08 06:32:36 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.3 2013/12/08 06:32:36 matt Exp $") - -STRONG_ALIAS(_start,__start) - -/* - * Assumes kernel (or ld_elf.so) passes the following parameters to - * user-space in registers: - * - * a0 stack pointer (0 if setregs didn't fill this in) - * a1 cleanup - * a2 Obj_Entry - * a3 ps_strings - * - * XXX Does this violate the ABI? - * as well as the usual registers (pc, sp, and t9 == pc for ABI). - */ - -NESTED_NOPROFILE(__start, CALLFRAME_SIZ, ra) - SETUP_GP - SETUP_GP64(t3, __start) - move a0, a1 /* cleanup */ - move a1, a2 /* Obj_Entry */ - PTR_L t9,%call16(_C_LABEL(___start))(gp) - move a2, a3 /* ps_strings */ - .reloc 1f,R_MIPS_JALR,___start -1: jr t9 -END(__start) diff --git a/lib/csu/arch/mips/crtbegin.h b/lib/csu/arch/mips/crtbegin.h deleted file mode 100644 index cd8ac21f1..000000000 --- a/lib/csu/arch/mips/crtbegin.h +++ /dev/null @@ -1,66 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__asm( "\n\t" - ".pushsection .init, \"ax\", @progbits" "\n\t" -#ifdef __mips_o32 - ".set noreorder" "\n\t" - ".set nomacro" "\n\t" - "move $28,$16" "\n\t" - "lw $25,%got(__do_global_ctors_aux)($28)" "\n\t" - "nop" "\n\t" - "addiu $25,$25,%lo(__do_global_ctors_aux)" "\n\t" - ".reloc 1f,R_MIPS_JALR,__do_global_ctors_aux" "\n\t" - "1: jalr $25" "\n\t" - "nop" "\n\t" - ".set macro" "\n\t" - ".set reorder" "\n\t" -#else - "jal __do_global_ctors_aux" "\n\t" -#endif - ".popsection"); - -__asm( "\n\t" - ".pushsection .fini, \"ax\", @progbits" "\n\t" -#ifdef __mips_o32 - ".set noreorder" "\n\t" - ".set nomacro" "\n\t" - "move $28,$16" "\n\t" - "lw $25,%got(__do_global_dtors_aux)($28)" "\n\t" - "nop" "\n\t" - "addiu $25,$25,%lo(__do_global_dtors_aux)" "\n\t" - ".reloc 1f,R_MIPS_JALR,__do_global_dtors_aux" "\n\t" - "1: jalr $25" "\n\t" - "nop" "\n\t" - ".set macro" "\n\t" - ".set reorder" "\n\t" -#else - "jal __do_global_dtors_aux" "\n\t" -#endif - ".popsection"); diff --git a/lib/csu/arch/mips/crtend.S b/lib/csu/arch/mips/crtend.S deleted file mode 100644 index 59b4f32b7..000000000 --- a/lib/csu/arch/mips/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.3 2013/09/05 00:28:11 matt Exp $ */ -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.3 2013/09/05 00:28:11 matt Exp $") - - .section .ctors, "aw", @progbits - .p2align PTR_SCALESHIFT - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .word 0 - - .section .dtors, "aw", @progbits - .p2align PTR_SCALESHIFT - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .word 0 - - .section .eh_frame, "aw", @progbits - .p2align PTR_SCALESHIFT - .space _MIPS_SZPTR / 8 - - .section .jcr, "aw", @progbits - .p2align PTR_SCALESHIFT - .space _MIPS_SZPTR / 8 diff --git a/lib/csu/arch/mips/crti.S b/lib/csu/arch/mips/crti.S deleted file mode 100644 index 8c3485313..000000000 --- a/lib/csu/arch/mips/crti.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: crti.S,v 1.3 2015/05/01 21:35:56 matt Exp $ */ - -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.3 2015/05/01 21:35:56 matt Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .p2align 2 -NESTED_NOPROFILE(_init, CALLFRAME_SIZ, ra) - SETUP_GP - PTR_SUBU sp, sp, CALLFRAME_SIZ # allocate stack frame - REG_S ra, CALLFRAME_RA(sp) # save RA -#ifdef __mips_o32 - REG_S s0, CALLFRAME_S0(sp) # save s0 - move s0, gp -#endif - SETUP_GP64(CALLFRAME_GP, _init) -END(_init) - - .section ".fini", "ax", @progbits - .p2align 2 -NESTED_NOPROFILE(_fini, CALLFRAME_SIZ, ra) - SETUP_GP - PTR_SUBU sp, sp, CALLFRAME_SIZ # allocate stack frame - REG_S ra, CALLFRAME_RA(sp) # save RA -#ifdef __mips_o32 - REG_S s0, CALLFRAME_S0(sp) # save s0 - move s0, gp -#endif - SETUP_GP64(CALLFRAME_GP, _fini) -END(_fini) diff --git a/lib/csu/arch/mips/crtn.S b/lib/csu/arch/mips/crtn.S deleted file mode 100644 index 66f0efedc..000000000 --- a/lib/csu/arch/mips/crtn.S +++ /dev/null @@ -1,52 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.2 2013/06/30 08:00:34 matt Exp $") - - .section ".init", "ax", @progbits - REG_L ra, CALLFRAME_RA(sp) -#if defined(__mips_o32) || defined(__mips_o64) - REG_L s0, CALLFRAME_S0(sp) -#else - REG_L gp, CALLFRAME_GP(sp) -#endif - PTR_ADDU sp, sp, CALLFRAME_SIZ - jr ra - - .section ".fini", "ax", @progbits - REG_L ra, CALLFRAME_RA(sp) -#ifdef __mips_o32 - REG_L s0, CALLFRAME_S0(sp) -#else - REG_L gp, CALLFRAME_GP(sp) -#endif - PTR_ADDU sp, sp, CALLFRAME_SIZ - jr ra diff --git a/lib/csu/arch/or1k/Makefile.inc b/lib/csu/arch/or1k/Makefile.inc deleted file mode 100644 index db2c13cd5..000000000 --- a/lib/csu/arch/or1k/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/03 19:34:25 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -CPPFLAGS+= -DHAVE_INITFINI_ARRAY -#CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\" diff --git a/lib/csu/arch/or1k/crt0.S b/lib/csu/arch/or1k/crt0.S deleted file mode 100644 index 4247100be..000000000 --- a/lib/csu/arch/or1k/crt0.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: crt0.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.1 2014/09/03 19:34:25 matt Exp $") - -STRONG_ALIAS(_start,__start) - -_ENTRY(__start) - /* - * void ___start(void (*cleanup)(void), const Obj_Entry *obj, - * struct ps_strings *ps_strings); - */ - l.jal ___start -END(__start) diff --git a/lib/csu/arch/or1k/crtbegin.h b/lib/csu/arch/or1k/crtbegin.h deleted file mode 100644 index 4905fa8fe..000000000 --- a/lib/csu/arch/or1k/crtbegin.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -static void __do_global_ctors_aux(void) __attribute__((__constructor__)) __used; -#ifdef SHARED -static void __do_global_dtors_aux(void) __attribute__((__destructor__)) __used; -#endif diff --git a/lib/csu/arch/or1k/crtend.S b/lib/csu/arch/or1k/crtend.S deleted file mode 100644 index f2572e537..000000000 --- a/lib/csu/arch/or1k/crtend.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.1 2014/09/03 19:34:25 matt Exp $") - - .section .eh_frame, "a", @progbits - .p2align 2 - .global __EH_FRAME_END__ - .hidden __EH_FRAME_END__ -__EH_FRAME_END__: - .space 4 - - .section .jcr, "aw", @progbits - .p2align 2 - .global __JCR_END__ - .hidden __JCR_END__ -__JCR_END__: - .space 4 diff --git a/lib/csu/arch/or1k/crti.S b/lib/csu/arch/or1k/crti.S deleted file mode 100644 index 2b7df72b6..000000000 --- a/lib/csu/arch/or1k/crti.S +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2014/09/03 19:34:25 matt Exp $") - -#include "sysident.S" - -/* - * Since OR1K for NetBSD uses .init_array/.fini_array, - * there is no need for .init/.fini - */ diff --git a/lib/csu/arch/or1k/crtn.S b/lib/csu/arch/or1k/crtn.S deleted file mode 100644 index f46929451..000000000 --- a/lib/csu/arch/or1k/crtn.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* no need for anything here since OR1K for NetBSD uses .init_array/.fini_array */ diff --git a/lib/csu/arch/powerpc/Makefile.inc b/lib/csu/arch/powerpc/Makefile.inc deleted file mode 100644 index 1ebb11de2..000000000 --- a/lib/csu/arch/powerpc/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2013/06/27 21:24:39 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} diff --git a/lib/csu/arch/powerpc/crt0.S b/lib/csu/arch/powerpc/crt0.S deleted file mode 100644 index dc6175aeb..000000000 --- a/lib/csu/arch/powerpc/crt0.S +++ /dev/null @@ -1,57 +0,0 @@ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.6 2014/02/27 18:01:51 matt Exp $") - -STRONG_ALIAS(_start,__start) - - .hidden ___start - -#ifndef _LP64 - .weak _SDA_BASE_ -#endif - -ENTRY_NOPROFILE(__start) -#ifndef _LP64 - bcl 20,31,1f -1: - mflr %r11 - /* SVR4 ABI says small data is in r13 */ - addis %r13,%r11,_SDA_BASE_-1b@ha - addi %r13,%r13,_SDA_BASE_-1b@l -#endif - - mr %r3,%r7 /* cleanup */ - mr %r4,%r6 /* obj */ - mr %r5,%r8 /* ps_strings */ - - CALL(___start) -END(__start) diff --git a/lib/csu/arch/powerpc/crtbegin.h b/lib/csu/arch/powerpc/crtbegin.h deleted file mode 100644 index 8f0700aab..000000000 --- a/lib/csu/arch/powerpc/crtbegin.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.1 2013/06/27 21:24:39 matt Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -__asm( ".pushsection .init, \"ax\", @progbits" -"\n\t" "bl __do_global_ctors_aux" -"\n\t" ".popsection"); - -__asm( ".pushsection .fini, \"ax\", @progbits" -"\n\t" "bl __do_global_dtors_aux" -"\n\t" ".popsection"); diff --git a/lib/csu/arch/powerpc/crtend.S b/lib/csu/arch/powerpc/crtend.S deleted file mode 100644 index 19d89c0a6..000000000 --- a/lib/csu/arch/powerpc/crtend.S +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: crtend.S,v 1.3 2014/02/27 16:47:48 matt Exp $ */ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.3 2014/02/27 16:47:48 matt Exp $") - - .section .ctors, "aw", @progbits - .p2align P2SZREG - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: -#ifdef _LP64 - .quad 0 -#else - .long 0 -#endif - - .section .dtors, "aw", @progbits - .p2align P2SZREG - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: -#ifdef _LP64 - .quad 0 -#else - .long 0 -#endif - - .section .eh_frame, "a", @progbits - .p2align P2SZREG -#ifdef _LP64 - .quad 0 -#else - .long 0 -#endif - - .section .jcr, "aw", @progbits - .p2align P2SZREG -#ifdef _LP64 - .quad 0 -#else - .long 0 -#endif diff --git a/lib/csu/arch/powerpc/crti.S b/lib/csu/arch/powerpc/crti.S deleted file mode 100644 index f9306328f..000000000 --- a/lib/csu/arch/powerpc/crti.S +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: crti.S,v 1.4 2014/03/06 19:05:59 matt Exp $ */ - -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.4 2014/03/06 19:05:59 matt Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits -_XENTRY(_init) - mflr %r0 -#ifdef _LP64 - stdu %r1, -(6*SZREG)(%r1) - std %r0, (2*SZREG)(%r1) -#else - stw %r0, (1*SZREG)(%r1) - stwu %r1, -(4*SZREG)(%r1) -#endif - - .section ".fini", "ax", @progbits -_XENTRY(_fini) - mflr %r0 -#ifdef _LP64 - stdu %r1, -(6*SZREG)(%r1) - std %r0, (2*SZREG)(%r1) -#else - stw %r0, (1*SZREG)(%r1) - stwu %r1, -(4*SZREG)(%r1) -#endif diff --git a/lib/csu/arch/powerpc/crtn.S b/lib/csu/arch/powerpc/crtn.S deleted file mode 100644 index 161268310..000000000 --- a/lib/csu/arch/powerpc/crtn.S +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.2 2014/02/27 16:47:48 matt Exp $") - - .section ".init", "ax", @progbits -#ifdef _LP64 - ldreg %r0, (2*SZREG)(%r1) - addi %r1, %r1, (6*SZREG) -#else - addi %r1, %r1, (4*SZREG) - lwz %r0, (1*SZREG)(%r1) -#endif - mtlr %r0 - blr - - .section ".fini", "ax", @progbits -#ifdef _LP64 - ldreg %r0, (2*SZREG)(%r1) - addi %r1, %r1, (6*SZREG) -#else - addi %r1, %r1, (4*SZREG) - lwz %r0, (1*SZREG)(%r1) -#endif - mtlr %r0 - blr diff --git a/lib/csu/arch/riscv/Makefile.inc b/lib/csu/arch/riscv/Makefile.inc deleted file mode 100644 index 8c2c2c6c5..000000000 --- a/lib/csu/arch/riscv/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} -CPPFLAGS+= -DHAVE_INITFINI_ARRAY -#CPPFLAGS+= -DELF_NOTE_MARCH_DESC=\"${CSU_MACHINE_ARCH}\" diff --git a/lib/csu/arch/riscv/crt0.S b/lib/csu/arch/riscv/crt0.S deleted file mode 100644 index 8e29152b6..000000000 --- a/lib/csu/arch/riscv/crt0.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: crt0.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.1 2014/09/19 17:36:25 matt Exp $") - -STRONG_ALIAS(_start,__start) - -_ENTRY(__start) - /* - * void ___start(void (*cleanup)(void), const Obj_Entry *obj, - * struct ps_strings *ps_strings); - */ - j ___start -END(__start) diff --git a/lib/csu/arch/riscv/crtbegin.h b/lib/csu/arch/riscv/crtbegin.h deleted file mode 100644 index 633b651b0..000000000 --- a/lib/csu/arch/riscv/crtbegin.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: crtbegin.h,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -static void __do_global_ctors_aux(void) __attribute__((__constructor__)) __used; -#ifdef SHARED -static void __do_global_dtors_aux(void) __attribute__((__destructor__)) __used; -#endif diff --git a/lib/csu/arch/riscv/crtend.S b/lib/csu/arch/riscv/crtend.S deleted file mode 100644 index feb9896f2..000000000 --- a/lib/csu/arch/riscv/crtend.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.1 2014/09/19 17:36:25 matt Exp $") - - .section .eh_frame, "a", @progbits - .p2align PTR_SCALESHIFT - .global __EH_FRAME_END__ - .hidden __EH_FRAME_END__ -__EH_FRAME_END__: - .space (1 << PTR_SCALESHIFT) - - .section .jcr, "aw", @progbits - .p2align PTR_SCALESHIFT - .global __JCR_END__ - .hidden __JCR_END__ -__JCR_END__: - .space (1 << PTR_SCALESHIFT) diff --git a/lib/csu/arch/riscv/crti.S b/lib/csu/arch/riscv/crti.S deleted file mode 100644 index 3b77fa5da..000000000 --- a/lib/csu/arch/riscv/crti.S +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2014/09/19 17:36:25 matt Exp $") - -#include "sysident.S" - -/* - * Since OR1K for NetBSD uses .init_array/.fini_array, - * there is no need for .init/.fini - */ diff --git a/lib/csu/arch/riscv/crtn.S b/lib/csu/arch/riscv/crtn.S deleted file mode 100644 index 000824a9e..000000000 --- a/lib/csu/arch/riscv/crtn.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* no need for anything here since OR1K for NetBSD uses .init_array/.fini_array */ diff --git a/lib/csu/arch/sh3/Makefile.inc b/lib/csu/arch/sh3/Makefile.inc deleted file mode 100644 index ade41715e..000000000 --- a/lib/csu/arch/sh3/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:34 joerg Exp $ - -CPPFLAGS+= -DELFSIZE=32 - - diff --git a/lib/csu/arch/sh3/crt0.S b/lib/csu/arch/sh3/crt0.S deleted file mode 100644 index c4c9b4c0a..000000000 --- a/lib/csu/arch/sh3/crt0.S +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: crt0.S,v 1.4 2012/01/31 20:17:57 uwe Exp $ */ - -/* - * Copyright (c) 1998 Christos Zoulas - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.4 2012/01/31 20:17:57 uwe Exp $") - -STRONG_ALIAS(_start,__start) - -/* - * Kernel setregs() passes arguments for the 6-argument version of - * ___start (but with 5th and 6th in registers, to avoid copyout). - * Since we now use 3-argument version of ___start - that obtains - * argc, argv and environ from ps_strings - move its arguments to - * proper registers. - */ -_ENTRY(__start) - mov.l .L___start, r0 - mov r7, r4 ! void (*cleanup)(void) - mov r8, r5 ! const Obj_Entry *obj - jmp @r0 - mov r9, r6 ! struct ps_strings *ps_strings - - .p2align 2 -.L___start: .long _C_LABEL(___start) diff --git a/lib/csu/arch/sh3/crtbegin.S b/lib/csu/arch/sh3/crtbegin.S deleted file mode 100644 index aa7a879cd..000000000 --- a/lib/csu/arch/sh3/crtbegin.S +++ /dev/null @@ -1,366 +0,0 @@ -/* $NetBSD: crtbegin.S,v 1.3 2013/09/12 15:36:14 joerg Exp $ */ -/*- - * Copyright (c) 2012 Valeriy E. Ushakov - * 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 COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtbegin.S,v 1.3 2013/09/12 15:36:14 joerg Exp $") - - .section .ctors, "aw", @progbits - .p2align 2 -__CTOR_LIST__: - .long -1 - - .section .dtors, "aw", @progbits - .p2align 2 -__DTOR_LIST__: - .long -1 - - .section .eh_frame, "a", @progbits - .p2align 2 -__EH_FRAME_LIST__: - - .section .jcr, "aw", @progbits - .p2align 2 -__JCR_LIST__: - - .section .data.rel, "aw", @progbits - .p2align 2 - .globl __dso_handle - .hidden __dso_handle - .type __dso_handle, @object - .size __dso_handle, 4 -__dso_handle: -#ifdef SHARED - .long __dso_handle -#else - .long 0 -#endif - -__dwarf_eh_object: - .zero 32 - -__initialized: - .zero 1 -__finished: - .zero 1 - - .text - .weak __cxa_finalize - .weak __deregister_frame_info - .weak __register_frame_info - .weak _Jv_RegisterClasses - -/* - * A bit of CPP syntactic sugar for accessing variables. - * - * For PIC we are obliged to use @(r0, r12) since r12 has the GOT - * address and only r0 can be used in @(r0, Rm) addressing mode, so we - * always load variable address to r0. - */ -#ifdef __PIC__ -#define VAR_DATUM(var) var@GOTOFF -#define FUNC_DATUM(f) f@GOT -#define R0VAR (r0, r12) -#else -#define VAR_DATUM(var) var -#define FUNC_DATUM(f) f -#define R0VAR r0 -#endif - - -__do_global_ctors_aux: - mov.l r8, @-sp - mov.l r9, @-sp -#ifdef __PIC__ - mov.l r12, @-sp - mov.l .Lc_got, r12 - mova .Lc_got, r0 - add r0, r12 -#endif - mov.l r14, @-sp - sts.l pr, @-sp - mov sp, r14 - - !! if (__initialized) return; - mov.l .Lc___initialized, r0 - mov.b @R0VAR, r1 - tst r1, r1 - bf .Lc_return - - !! __initialized = 1; - mov #1, r1 - mov.b r1, @R0VAR - - - !! if (__register_frame_info) - !! __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object) -#ifdef __PIC__ - mov.l .Lc___register_frame_info_GOT, r0 - mov.l @R0VAR, r1 - tst r1, r1 - bt .Lc___register_frame_info_done - mov.l .Lc___register_frame_info, r0 - mov.l .Lc___EH_FRAME_LIST__, r4 - mov.l .Lc___dwarf_eh_object, r5 - add r12, r4 -.Lc___register_frame_info_call: - CALL r0 - add r12, r5 -#else /* !PIC */ - mov.l .Lc___register_frame_info, r0 - tst r0, r0 - bt .Lc___register_frame_info_done - mov.l .Lc___EH_FRAME_LIST__, r4 - mov.l .Lc___dwarf_eh_object, r5 - CALL r0 - nop -#endif -.Lc___register_frame_info_done: - - !! if (_Jv_RegisterClasses && __JCR_LIST__[0]) - !! _Jv_RegisterClasses(&__JCR_LIST__[0]); -#ifdef __PIC__ - mov.l .Lc__Jv_RegisterClasses_GOT, r0 - mov.l @R0VAR, r1 - tst r1, r1 - bt .Lc__Jv_RegisterClasses_done - - mov.l .Lc___JCR_LIST__, r0 - mov.l @R0VAR, r1 - tst r1, r1 - bt .Lc__Jv_RegisterClasses_done - - mov.l .Lc__Jv_RegisterClasses, r2 - mov r0, r4 -.Lc__Jv_RegisterClasses_call: - CALL r2 - add r12, r4 - -#else /* !PIC */ - mov.l .Lc__Jv_RegisterClasses, r2 - tst r2, r2 - bt .Lc__Jv_RegisterClasses_done - - mov.l .Lc___JCR_LIST__, r0 - mov.l @R0VAR, r1 - tst r1, r1 - bt .Lc__Jv_RegisterClasses_done - - mov r0, r4 -.Lc__Jv_RegisterClasses_call: - CALL r2 - add r12, r4 -#endif -.Lc__Jv_RegisterClasses_done: - - - !! call all constructors on __CTOR_LIST__ in reverse order - mov.l .Lc___CTOR_LIST_END__, r8 -#ifdef __PIC__ - add r12, r8 -#endif - add #-4, r8 - mov.l @r8, r9 - not r9, r0 ! sentinel at __CTOR_LIST__[0] is -1 -.Lc_ctor_list_loop: - tst r0, r0 - bt.s .Lc_ctor_list_done - add #-4, r8 - jsr @r9 - mov.l @r8, r9 - bra .Lc_ctor_list_loop - not r9, r0 -.Lc_ctor_list_done: - -.Lc_return: - mov r14, sp - lds.l @sp+, pr - mov.l @sp+, r14 -#ifdef __PIC__ - mov.l @sp+, r12 -#endif - mov.l @sp+, r9 - rts - mov.l @sp+, r8 - - .p2align 2 -.Lc_got: - PIC_GOT_DATUM -.Lc___initialized: - .long VAR_DATUM(__initialized) -#ifdef __PIC__ -.Lc___register_frame_info_GOT: - .long __register_frame_info@GOT -#endif -.Lc___register_frame_info: - CALL_DATUM(__register_frame_info, .Lc___register_frame_info_call) -.Lc___EH_FRAME_LIST__: - .long VAR_DATUM(__EH_FRAME_LIST__) -.Lc___dwarf_eh_object: - .long VAR_DATUM(__dwarf_eh_object) -#ifdef __PIC__ -.Lc__Jv_RegisterClasses_GOT: - .long _Jv_RegisterClasses@GOT -#endif -.Lc__Jv_RegisterClasses: - CALL_DATUM(_Jv_RegisterClasses, .Lc__Jv_RegisterClasses_call) -.Lc___JCR_LIST__: - .long VAR_DATUM(__JCR_LIST__) -.Lc___CTOR_LIST_END__: - .long VAR_DATUM(__CTOR_LIST_END__) - - -__do_global_dtors_aux: - mov.l r8, @-sp - mov.l r9, @-sp -#ifdef __PIC__ - mov.l r12, @-sp - mov.l .Ld_got, r12 - mova .Ld_got, r0 - add r0, r12 -#endif - mov.l r14, @-sp - sts.l pr, @-sp - mov sp, r14 - - !! if (__finished) return; - mov.l .Ld___finished, r0 - mov.b @R0VAR, r1 - tst r1, r1 - bf .Ld_return - - !! __finished = 1; - mov #1, r1 - mov.b r1, @R0VAR - -#ifdef SHARED /* implies PIC */ - !! if (__cxa_finalize) - !! __cxa_finalize(&__dso_handle); - mov.l .Ld___cxa_finalize_GOT, r0 - mov.l @R0VAR, r1 - tst r1, r1 - bt .Ld___cxa_finalize_done - mov.l .Ld___cxa_finalize, r0 - mov.l .Ld___dso_handle, r4 -.Ld___cxa_finalize_call: - CALL r0 - add r12, r4 -.Ld___cxa_finalize_done: -#endif /* SHARED */ - - !! call all destructors on __DTOR_LIST__ - mov.l .Ld___DTOR_LIST__, r8 -#ifdef __PIC__ - add r12, r8 -#endif - add #4, r8 ! skip first entry that we know to be -1 - mov.l @r8+, r9 - tst r9, r9 -.Ld_dtor_list_loop: - bt .Ld_dtor_list_done - jsr @r9 - mov.l @r8+, r9 - bra .Ld_dtor_list_loop - tst r9, r9 -.Ld_dtor_list_done: - - !! if (__deregister_frame_info) - !! __deregister_frame_info(&__EH_FRAME_LIST__[0]); -#ifdef __PIC__ - mov.l .Ld___deregister_frame_info_GOT, r0 - mov.l @R0VAR, r1 - tst r1, r1 - bt .Ld___deregister_frame_info_done - mov.l .Ld___deregister_frame_info, r0 - mov.l .Ld___EH_FRAME_LIST__, r4 -.Ld___deregister_frame_info_call: - CALL r0 - add r12, r4 -#else /* !PIC */ - mov.l .Ld___deregister_frame_info, r0 - tst r0, r0 - bt .Ld___deregister_frame_info_done - mov.l .Ld___EH_FRAME_LIST__, r4 - CALL r0 - nop -#endif -.Ld___deregister_frame_info_done: - -.Ld_return: - mov r14, sp - lds.l @sp+, pr - mov.l @sp+, r14 -#ifdef __PIC__ - mov.l @sp+, r12 -#endif - mov.l @sp+, r9 - rts - mov.l @sp+, r8 - - .p2align 2 -.Ld_got: - PIC_GOT_DATUM -.Ld___finished: - .long VAR_DATUM(__finished) -#ifdef SHARED /* implies PIC */ -.Ld___cxa_finalize_GOT: - .long __cxa_finalize@GOT -.Ld___cxa_finalize: - CALL_DATUM(__cxa_finalize, .Ld___cxa_finalize_call) -.Ld___dso_handle: - .long VAR_DATUM(__dso_handle) -#endif -.Ld___DTOR_LIST__: - .long VAR_DATUM(__DTOR_LIST__) -#ifdef __PIC__ -.Ld___deregister_frame_info_GOT: - .long __deregister_frame_info@GOT -#endif -.Ld___deregister_frame_info: - CALL_DATUM(__deregister_frame_info, .Ld___deregister_frame_info_call) -.Ld___EH_FRAME_LIST__: - .long VAR_DATUM(__EH_FRAME_LIST__) - - - -#define _CALL_INIT_FINI_FUNCTION(func) \ - mov.l 1f, r1; \ - mova 2f, r0; \ -0: braf r1; /* NB: branch, not call ... */ \ - lds r0, pr; /* skip the following .long when returning */ \ - .p2align 2; \ -1: .long func - (0b+4); \ -2: ; - - .section .init, "ax", @progbits - _CALL_INIT_FINI_FUNCTION(__do_global_ctors_aux) - - .section .fini, "ax", @progbits - _CALL_INIT_FINI_FUNCTION(__do_global_dtors_aux) diff --git a/lib/csu/arch/sh3/crtend.S b/lib/csu/arch/sh3/crtend.S deleted file mode 100644 index c7c37f269..000000000 --- a/lib/csu/arch/sh3/crtend.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: crtend.S,v 1.2 2012/01/31 20:12:47 uwe Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtend.S,v 1.2 2012/01/31 20:12:47 uwe Exp $") - - .section .ctors, "aw", @progbits - .p2align 2 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .long 0 - - .section .dtors, "aw", @progbits - .p2align 2 - .long 0 - - .section .eh_frame, "a", @progbits - .p2align 2 - .long 0 - - .section .jcr, "aw", @progbits - .p2align 2 - .long 0 diff --git a/lib/csu/arch/sh3/crti.S b/lib/csu/arch/sh3/crti.S deleted file mode 100644 index 7966c7f32..000000000 --- a/lib/csu/arch/sh3/crti.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: crti.S,v 1.3 2012/01/31 20:12:47 uwe Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.3 2012/01/31 20:12:47 uwe Exp $") - -#include "sysident.S" - - -/* - * Provide function prologues for the code in .init and .fini sections. - * Corresponding epilogues are in crtn.S - */ - - .section ".init", "ax", @progbits - .p2align 2 - .globl _init -_init: - mov.l r14, @-sp - sts.l pr, @-sp - mov sp, r14 - - .section ".fini", "ax", @progbits - .p2align 2 - .globl _fini -_fini: - mov.l r14, @-sp - sts.l pr, @-sp - mov sp, r14 diff --git a/lib/csu/arch/sh3/crtn.S b/lib/csu/arch/sh3/crtn.S deleted file mode 100644 index f950e1521..000000000 --- a/lib/csu/arch/sh3/crtn.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: crtn.S,v 1.2 2012/01/28 12:45:43 uwe Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.2 2012/01/28 12:45:43 uwe Exp $") - - -/* - * Provide function epilogues for the code in .init and .fini sections. - * Corresponding prologues are in crti.S - */ - - .section ".init", "ax", @progbits - mov r14, sp - lds.l @sp+, pr - rts - mov.l @sp+, r14 - - .section ".fini", "ax", @progbits - mov r14, sp - lds.l @sp+, pr - rts - mov.l @sp+, r14 diff --git a/lib/csu/arch/sparc/Makefile.inc b/lib/csu/arch/sparc/Makefile.inc deleted file mode 100644 index 51ce1cb8c..000000000 --- a/lib/csu/arch/sparc/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2013/07/11 06:57:15 martin Exp $ - -CPPFLAGS+= -DELFSIZE=32 -I${ARCHDIR} - - diff --git a/lib/csu/arch/sparc/crt0.S b/lib/csu/arch/sparc/crt0.S deleted file mode 100644 index 4789aafea..000000000 --- a/lib/csu/arch/sparc/crt0.S +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: crt0.S,v 1.2 2013/07/11 06:57:15 martin Exp $ */ - -/* - * Copyright (c) 1998 Christos Zoulas - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.2 2013/07/11 06:57:15 martin Exp $") - -STRONG_ALIAS(_start,__start) - - ! called with: - ! %g3 = cleanup - ! %g2 = obj - ! %g1 = ps_strings - ! call: ___start(cleanup, obj, ps_strings) -_ENTRY(__start) - mov 0, %fp - andn %sp, 7, %sp ! align stack - sub %sp, 24, %sp ! expand to standard stack frame size - mov %g3, %o0 - mov %g2, %o1 - call ___start - mov %g1, %o2 - diff --git a/lib/csu/arch/sparc/crtbegin.h b/lib/csu/arch/sparc/crtbegin.h deleted file mode 100644 index e3676ddcf..000000000 --- a/lib/csu/arch/sparc/crtbegin.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__asm( "\n\t" - ".pushsection .init, \"ax\", @progbits" "\n\t" - "call __do_global_ctors_aux" "\n\t" - " nop" "\n\t" - ".popsection"); - -__asm( "\n\t" - ".pushsection .fini, \"ax\", @progbits" "\n\t" - "call __do_global_dtors_aux" "\n\t" - " nop" "\n\t" - ".popsection"); diff --git a/lib/csu/arch/sparc/crtend.S b/lib/csu/arch/sparc/crtend.S deleted file mode 100644 index 8e92494e3..000000000 --- a/lib/csu/arch/sparc/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $") - - .section .ctors, "aw", @progbits - .align 4 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .long 0 - - .section .dtors, "aw", @progbits - .align 4 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .long 0 - - .section .eh_frame, "a", @progbits - .align 4 - .long 0 - - .section .jcr, "aw", @progbits - .align 4 - .long 0 diff --git a/lib/csu/arch/sparc/crti.S b/lib/csu/arch/sparc/crti.S deleted file mode 100644 index 8f8128a7e..000000000 --- a/lib/csu/arch/sparc/crti.S +++ /dev/null @@ -1,78 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ - -/* - * Copyright (c) 2001 Matthew R. Green - * 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 ``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. - */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .align 4 - .globl _init -_init: - save %sp, -96, %sp - - .section ".fini", "ax", @progbits - .align 4 - .globl _fini -_fini: - save %sp, -96, %sp diff --git a/lib/csu/arch/sparc/crtn.S b/lib/csu/arch/sparc/crtn.S deleted file mode 100644 index d86319a99..000000000 --- a/lib/csu/arch/sparc/crtn.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ - -/* - * Copyright (c) 2001 Matthew R. Green - * 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 ``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. - */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - - .section ".init", "ax", @progbits - .align 4 - ret - restore - - .section ".fini", "ax", @progbits - .align 4 - ret - restore diff --git a/lib/csu/arch/sparc64/Makefile.inc b/lib/csu/arch/sparc64/Makefile.inc deleted file mode 100644 index 71a9b3af2..000000000 --- a/lib/csu/arch/sparc64/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2013/07/11 06:57:15 martin Exp $ - -CPPFLAGS+= -DELFSIZE=64 -I${ARCHDIR} - - diff --git a/lib/csu/arch/sparc64/crt0.S b/lib/csu/arch/sparc64/crt0.S deleted file mode 100644 index db5b17bae..000000000 --- a/lib/csu/arch/sparc64/crt0.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: crt0.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */ - -/* - * Copyright (c) 1998 Christos Zoulas - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.1 2013/07/11 06:57:15 martin Exp $") - -STRONG_ALIAS(_start,__start) - - .align 4 - .register %g3,#scratch - .register %g2,#scratch - - ! called with: - ! %g3 = cleanup - ! %g2 = obj - ! %g1 = ps_strings - ! call: ___start(cleanup, obj, ps_strings) -_ENTRY(__start) - clr %fp - clr %g4 ! data base for some memory models - mov %g3, %o0 - mov %g2, %o1 - ba,pt %icc,___start - mov %g1, %o2 - diff --git a/lib/csu/arch/sparc64/crtbegin.h b/lib/csu/arch/sparc64/crtbegin.h deleted file mode 100644 index bb8272138..000000000 --- a/lib/csu/arch/sparc64/crtbegin.h +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__asm( "\n\t" - ".pushsection .init, \"ax\", @progbits" "\n\t" - "call __do_global_ctors_aux" "\n\t" - " nop" "\n\t" - ".popsection"); - -__asm( "\n\t" - ".pushsection .fini, \"ax\", @progbits" "\n\t" - "call __do_global_dtors_aux" "\n\t" - " nop" "\n\t" - ".popsection"); diff --git a/lib/csu/arch/sparc64/crtend.S b/lib/csu/arch/sparc64/crtend.S deleted file mode 100644 index 96cd5e4c8..000000000 --- a/lib/csu/arch/sparc64/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtend.S,v 1.1 2013/07/11 06:57:15 martin Exp $") - - .section .ctors, "aw", @progbits - .align 8 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .quad 0 - - .section .dtors, "aw", @progbits - .align 8 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .quad 0 - - .section .eh_frame, "a", @progbits - .align 8 - .quad 0 - - .section .jcr, "aw", @progbits - .align 8 - .quad 0 diff --git a/lib/csu/arch/sparc64/crti.S b/lib/csu/arch/sparc64/crti.S deleted file mode 100644 index 472ac5cf6..000000000 --- a/lib/csu/arch/sparc64/crti.S +++ /dev/null @@ -1,78 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */ - -/* - * Copyright (c) 2001 Matthew R. Green - * 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 ``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. - */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2013/07/11 06:57:15 martin Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .align 4 - .globl _init -_init: - save %sp, -176, %sp - - .section ".fini", "ax", @progbits - .align 4 - .globl _fini -_fini: - save %sp, -176, %sp diff --git a/lib/csu/arch/sparc64/crtn.S b/lib/csu/arch/sparc64/crtn.S deleted file mode 100644 index f7306017e..000000000 --- a/lib/csu/arch/sparc64/crtn.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2013/07/11 06:57:15 martin Exp $ */ - -/* - * Copyright (c) 2001 Matthew R. Green - * 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 ``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. - */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2013/07/11 06:57:15 martin Exp $") - - .section ".init", "ax", @progbits - .align 4 - ret - restore - - .section ".fini", "ax", @progbits - .align 4 - ret - restore diff --git a/lib/csu/arch/vax/Makefile.inc b/lib/csu/arch/vax/Makefile.inc deleted file mode 100644 index b659a66c1..000000000 --- a/lib/csu/arch/vax/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2013/06/25 00:30:07 matt Exp $ - -CPPFLAGS+= -I${ARCHDIR} diff --git a/lib/csu/arch/vax/crt0.S b/lib/csu/arch/vax/crt0.S deleted file mode 100644 index 04e90fb0b..000000000 --- a/lib/csu/arch/vax/crt0.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: crt0.S,v 1.3 2013/06/21 15:54:08 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.3 2013/06/21 15:54:08 matt Exp $") - -STRONG_ALIAS(_start,__start) - -_ENTRY(__start, 0x0101) - movq %r8,-(%sp) /* ps_strings / obj */ - pushl %r7 /* cleanup */ - calls $3,___start -END(__start) diff --git a/lib/csu/arch/vax/crtbegin.S b/lib/csu/arch/vax/crtbegin.S deleted file mode 100644 index 208c4658a..000000000 --- a/lib/csu/arch/vax/crtbegin.S +++ /dev/null @@ -1,182 +0,0 @@ -/* $NetBSD: crtbegin.S,v 1.7 2014/03/16 11:41:30 joerg Exp $ */ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtbegin.S,v 1.7 2014/03/16 11:41:30 joerg Exp $") - - .section .ctors, "aw", @progbits - .p2align 2 -__CTOR_LIST__: /* symbol is not used */ - .long -1 - - .section .dtors, "aw", @progbits - .p2align 2 -__DTOR_LIST__: - .long -1 - - .section .eh_frame, "a", @progbits - .p2align 2 -__EH_FRAME_LIST__: - - .section .jcr, "aw", @progbits - .p2align 2 -__JCR_LIST__: - - .section .data.rel, "aw", @progbits - .p2align 2 - .type __dso_handle, @object - .size __dso_handle, 4 - .globl __dso_handle - .hidden __dso_handle -__dso_handle: -#ifdef SHARED - .long __dso_handle -#else - .long 0 -#endif - - .local __dwarf_eh_object - .comm __dwarf_eh_object,32 - .local __initialized - .comm __initialized,1 - .local __finished - .comm __finished,1 - - .text -/* - * All variables are local to this DSO so we can skip using GOT references - * and instead use PCREL references to access them. We do this regardless - * of being PIC since it isn't any additional overhead to do so. - * - * We don't setup a TOC since all of ours calls are indirect so it isn't - * needed. - */ - - .hidden __do_global_dtors_aux - -_ENTRY(__do_global_dtors_aux, 0x0100) /* save r8 */ - tstb __finished /* done this already? */ - bneq 4f - movb $1, __finished /* mark it as done */ - -#ifdef SHARED - /* - * if (__cxa_finalize) - * __cxa_finalize(&__dso_handle); - */ - movab __cxa_finalize, %r0 - beql 1f - pushal __dso_handle - calls $0, (%r0) -1: -#endif /* SHARED */ - - /* - * We use load with postincrement to advance the pointer along. - * We know the list ends with 0. If we load one, we must be done. - */ - moval __DTOR_LIST__+4, %r8 /* skip first entry */ -2: movl (%r8)+, %r0 /* r0 = *r8++; */ - beql 3f - calls $0, (%r0) - brb 2b -3: - -#ifdef SHARED - /* - * if (__deregister_frame_info) - * __deregister_frame_info(&__EH_FRAME_LIST__[0]); - */ - moval __deregister_frame_info, %r0 - beql 4f - pushal __EH_FRAME_LIST__ - calls $0, (%r0) -#endif /* SHARED */ - -4: ret -END(__do_global_dtors_aux) - - .weak __deregister_frame_info - .weak __cxa_finalize - - .weak __register_frame_info - .weak _Jv_RegisterClasses - - .hidden __do_global_ctors_aux - -_ENTRY(__do_global_ctors_aux, 0x0800) - tstb __initialized - bneq 4f - movb $1, __initialized - - /* - * if (__register_frame_info) - * __register_frame_info(&__EH_FRAME_LIST__[0], &__dwarf_eh_object) - */ - movab __register_frame_info, %r0 - beql 1f - - pushal __dwarf_eh_object - pushal __EH_FRAME_LIST__ - calls $0, (%r0) -1: - - /* - * if (_Jv_RegisterClasses && __JCR_LIST__[0]) - * _Jv_RegisterClasses(&__JCR_LIST__[0]); - */ - movab _Jv_RegisterClasses, %r0 - beql 2f - - pushal __JCR_LIST__ - calls $0, (%r0) -2: - - /* - * Get the end of the CTOR list. The first entry is -1 so if we - * load a negative address, we know we are done. - */ - - moval __CTOR_LIST_END__, %r8 /* get end of list */ -3: movl -(%r8), %r0 /* get function pointer with predec */ - blss 4f /* negative? done. */ - calls $0, (%r0) /* call it */ - brb 3b /* get next one */ - -4: ret -END(__do_global_ctors_aux) - - .hidden _C_LABEL(__CTOR_LIST_END__) - - .section .init, "ax", @progbits - calls $0, __do_global_ctors_aux - .section .fini, "ax", @progbits - calls $0, __do_global_dtors_aux diff --git a/lib/csu/arch/vax/crtbegin.h b/lib/csu/arch/vax/crtbegin.h deleted file mode 100644 index 5bb3687e8..000000000 --- a/lib/csu/arch/vax/crtbegin.h +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__asm( ".pushsection .init, \"ax\", @progbits" "\n\t" - "calls $0, __do_global_ctors_aux" "\n\t" - ".popsection" "\n\t" - ".pushsection .fini, \"ax\", @progbits" "\n\t" - "calls $0, __do_global_dtors_aux" "\n\t" - ".popsection" - ); diff --git a/lib/csu/arch/vax/crtend.S b/lib/csu/arch/vax/crtend.S deleted file mode 100644 index 23d54f749..000000000 --- a/lib/csu/arch/vax/crtend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: crtend.S,v 1.2 2013/06/25 00:30:07 matt Exp $ */ -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtend.S,v 1.2 2013/06/25 00:30:07 matt Exp $") - - .section .ctors, "aw", @progbits - .p2align 2 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .long 0 - - .section .dtors, "aw", @progbits - .p2align 2 - .global __DTOR_LIST_END__ - .hidden __DTOR_LIST_END__ -__DTOR_LIST_END__: - .long 0 - - .section .eh_frame, "a", @progbits - .p2align 2 - .space 4 - - .section .jcr, "aw", @progbits - .p2align 2 - .space 4 diff --git a/lib/csu/arch/vax/crti.S b/lib/csu/arch/vax/crti.S deleted file mode 100644 index 6a554539a..000000000 --- a/lib/csu/arch/vax/crti.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .align 1 - .globl _init -_init: - .word 0 - - .section ".fini", "ax", @progbits - .align 1 - .globl _fini -_fini: - .word 0 diff --git a/lib/csu/arch/vax/crtn.S b/lib/csu/arch/vax/crtn.S deleted file mode 100644 index 3cfb46693..000000000 --- a/lib/csu/arch/vax/crtn.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - - .section ".init", "ax", @progbits - ret - - .section ".fini", "ax", @progbits - ret diff --git a/lib/csu/arch/x86_64/Makefile.inc b/lib/csu/arch/x86_64/Makefile.inc deleted file mode 100644 index 2cb588f95..000000000 --- a/lib/csu/arch/x86_64/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2010/08/07 18:01:34 joerg Exp $ - -CPPFLAGS+= -DELFSIZE=64 diff --git a/lib/csu/arch/x86_64/crt0.S b/lib/csu/arch/x86_64/crt0.S deleted file mode 100644 index 8ee9871a5..000000000 --- a/lib/csu/arch/x86_64/crt0.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $ */ - -/* - * Copyright (c) 1998 Christos Zoulas - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crt0.S,v 1.3 2011/07/01 02:59:05 joerg Exp $") - -STRONG_ALIAS(_start,__start) - .hidden ___start - -_ENTRY(__start) - andq $~15,%rsp - subq $8,%rsp - movq %rdx, %rdi - movq %rcx, %rsi - movq %rbx, %rdx - jmp ___start diff --git a/lib/csu/arch/x86_64/crtbegin.S b/lib/csu/arch/x86_64/crtbegin.S deleted file mode 100644 index 7efba6881..000000000 --- a/lib/csu/arch/x86_64/crtbegin.S +++ /dev/null @@ -1,156 +0,0 @@ -/* $NetBSD: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtbegin.S,v 1.2 2010/11/30 18:37:59 joerg Exp $") - - .section .ctors, "aw", @progbits - .align 8 -__CTOR_LIST__: - .quad -1 - - .section .dtors, "aw", @progbits - .align 8 -__DTOR_LIST__: - .quad -1 - - .section .eh_frame, "a", @progbits - .align 8 -__EH_FRAME_LIST__: - - .section .jcr, "aw", @progbits - .align 8 -__JCR_LIST__: - - .section .data.rel, "aw", @progbits - .align 8 - .type __dso_handle, @object - .size __dso_handle, 8 - .globl __dso_handle - .hidden __dso_handle -__dso_handle: -#ifdef SHARED - .quad __dso_handle -#else - .quad 0 -#endif - -__dwarf_eh_object: - .zero 64 - -__initialized: - .zero 1 -__finished: - .zero 1 - - .text - .weak __cxa_finalize - .weak __deregister_frame_info - .weak __register_frame_info - .weak _Jv_RegisterClasses - -__do_global_dtors_aux: - cmpb $0, __finished(%rip) - je 1f - ret -1: - pushq %rbx - movb $1, __finished(%rip) - - -#ifdef SHARED - cmpq $0, __cxa_finalize@GOTPCREL(%rip) - je 2f - movq __dso_handle(%rip), %rdi - call __cxa_finalize@PLT -2: -#endif - - leaq 8+__DTOR_LIST__(%rip), %rbx -3: - movq (%rbx), %rax - testq %rax, %rax - je 4f - call *%rax - addq $8, %rbx - jmp 3b -4: - - cmpq $0, __deregister_frame_info@GOTPCREL(%rip) - je 5f - leaq __EH_FRAME_LIST__(%rip), %rdi - call __deregister_frame_info@PLT -5: - popq %rbx - ret - - -__do_global_ctors_aux: - cmpb $0, __initialized(%rip) - je 1f - ret -1: - pushq %rbx - movb $1, __initialized(%rip) - - cmpq $0, __register_frame_info@GOTPCREL(%rip) - je 2f - leaq __dwarf_eh_object(%rip), %rsi - leaq __EH_FRAME_LIST__(%rip), %rdi - call __register_frame_info@PLT - -2: - cmpq $0, _Jv_RegisterClasses@GOTPCREL(%rip) - je 3f - leaq __JCR_LIST__(%rip), %rdi - cmpq $0, (%rdi) - je 3f - call _Jv_RegisterClasses@PLT -3: - - leaq -8+__CTOR_LIST_END__(%rip), %rbx -4: - movq (%rbx), %rax - cmpq $-1, %rax - je 5f - call *%rax - subq $8, %rbx - jmp 4b - -5: - popq %rbx - - ret - - .section .init, "ax", @progbits - call __do_global_ctors_aux - .section .fini, "ax", @progbits - call __do_global_dtors_aux diff --git a/lib/csu/arch/x86_64/crtend.S b/lib/csu/arch/x86_64/crtend.S deleted file mode 100644 index ae7f1e405..000000000 --- a/lib/csu/arch/x86_64/crtend.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: crtend.S,v 1.1 2010/08/07 18:01:34 joerg Exp $ */ -/*- - * Copyright (c) 2010 Joerg Sonnenberger - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 - -RCSID("$NetBSD: crtend.S,v 1.1 2010/08/07 18:01:34 joerg Exp $") - - .section .ctors, "aw", @progbits - .align 8 - .global __CTOR_LIST_END__ - .hidden __CTOR_LIST_END__ -__CTOR_LIST_END__: - .quad 0 - - .section .dtors, "aw", @progbits - .align 8 - .quad 0 - - .section .eh_frame, "a", @progbits - .align 8 - .quad 0 - - .section .jcr, "aw", @progbits - .align 8 - .quad 0 diff --git a/lib/csu/arch/x86_64/crti.S b/lib/csu/arch/x86_64/crti.S deleted file mode 100644 index 1b00f5aa9..000000000 --- a/lib/csu/arch/x86_64/crti.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: crti.S,v 1.1 2010/08/07 18:01:35 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crti.S,v 1.1 2010/08/07 18:01:35 joerg Exp $") - -#include "sysident.S" - - .section ".init", "ax", @progbits - .align 16 - .globl _init -_init: - subq $8, %rsp - - .section ".fini", "ax", @progbits - .align 16 - .globl _fini -_fini: - subq $8, %rsp diff --git a/lib/csu/arch/x86_64/crtn.S b/lib/csu/arch/x86_64/crtn.S deleted file mode 100644 index 3119cbdbf..000000000 --- a/lib/csu/arch/x86_64/crtn.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: crtn.S,v 1.1 2010/08/07 18:01:35 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: crtn.S,v 1.1 2010/08/07 18:01:35 joerg Exp $") - - .section ".init", "ax", @progbits - addq $8, %rsp - ret - - .section ".fini", "ax", @progbits - addq $8, %rsp - ret diff --git a/lib/csu/common/Makefile.inc b/lib/csu/common/Makefile.inc deleted file mode 100644 index 56762ce65..000000000 --- a/lib/csu/common/Makefile.inc +++ /dev/null @@ -1,134 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.25 2014/03/04 17:57:56 joerg Exp $ - -.include - -# XXX: FIXME: This is defined in bsd.lib.mk -PICFLAGS ?= -fPIC - -COMMON_DIR:= ${.CURDIR}/common -.PATH: ${COMMON_DIR} - -CPPFLAGS+= -I${NETBSDSRCDIR}/libexec/ld.elf_so -I${COMMON_DIR} -I. - -OBJS+= crt0.o gcrt0.o crti.o crtn.o -OBJS+= crtbegin.o crtend.o - -.if ${MKPIC} == "yes" -OBJS+= crtbeginS.o -CFLAGS.crtbegin.c+= -fPIE -.endif -.if ${MACHINE_ARCH} == "alpha" -OBJS+= crtfm.o -.endif - -.if ${CSU_MACHINE_ARCH} == "sparc64" -# create helper objects for the compiler to mark compiler memory models -.for m in medlow medmid medany -sparc_mc${m}.o: compident.S sysident_assym.h - ${CC} ${ASFLAGS} -I. -DCONTENT=\"${m}\\0\\0\" -DCONTENTLENGTH=8 -c \ - -o $@ ${COMMON_DIR}/compident.S -.endfor -OBJS += sparc_mcmedlow.o sparc_mcmedmid.o sparc_mcmedany.o -.endif - -realall: ${OBJS} - -.if exists(${ARCHDIR}/crtbegin.S) -crtbegin.o: crtbegin.S - ${_MKTARGET_COMPILE} - ${COMPILE.S} ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o -.else -crtbegin.o: crtbegin.c crtbegin.h - ${_MKTARGET_COMPILE} - ${COMPILE.c} ${CFLAGS.crtbegin.c} ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o -.endif - ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} - rm -f ${.TARGET}.o -.if ${MKSTRIPIDENT} != "no" - ${OBJCOPY} -R .ident ${.TARGET} -.endif - -.if exists(${ARCHDIR}/crtbegin.S) -crtbeginS.o: crtbegin.S - ${_MKTARGET_COMPILE} - ${COMPILE.S} ${PICFLAGS} -DSHARED ${ARCHDIR}/crtbegin.S -o ${.TARGET}.o -.else -crtbeginS.o: crtbegin.c crtbegin.h - ${_MKTARGET_COMPILE} - ${COMPILE.c} ${PICFLAGS} -DSHARED ${COMMON_DIR}/crtbegin.c -o ${.TARGET}.o -.endif - ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} - rm -f ${.TARGET}.o -.if ${MKSTRIPIDENT} != "no" - ${OBJCOPY} -R .ident ${.TARGET} -.endif - -crtend.o: crtend.S - ${_MKTARGET_COMPILE} - ${COMPILE.S} ${ARCHDIR}/crtend.S -o ${.TARGET}.o - ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} - rm -f ${.TARGET}.o -.if ${MKSTRIPIDENT} != "no" - ${OBJCOPY} -R .ident ${.TARGET} -.endif - -.if ${MKPIC} != "no" -MY_PICFLAGS= ${PICFLAGS} -.else -MY_PICFLAGS= -.endif - -crt0.o: crt0.S crt0-common.c - ${_MKTARGET_COMPILE} - ${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o - ${COMPILE.c} ${MY_PICFLAGS} ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o - ${LD} -r -o ${.TARGET}.o ${.TARGET}.S.o ${.TARGET}.c.o - ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} - rm -f ${.TARGET}.S.o ${.TARGET}.c.o ${.TARGET}.o -.if ${MKSTRIPIDENT} != "no" - ${OBJCOPY} -R .ident ${.TARGET} -.endif - -gcrt0.o: crt0.S crt0-common.c - ${_MKTARGET_COMPILE} - ${COMPILE.S} ${ARCHDIR}/crt0.S -o ${.TARGET}.S.o - ${COMPILE.c} ${MY_PICFLAGS} -DMCRT0 ${COMMON_DIR}/crt0-common.c -o ${.TARGET}.c.o - ${LD} -r -o ${.TARGET}.o ${.TARGET}.S.o ${.TARGET}.c.o - ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} - rm -f ${.TARGET}.S.o ${.TARGET}.c.o ${.TARGET}.o -.if ${MKSTRIPIDENT} != "no" - ${OBJCOPY} -R .ident ${.TARGET} -.endif - -.if ${MACHINE_ARCH} == "alpha" -# can't do this in Makefile.inc otherwise it will before realall: -crtfm.o: crtfm.c - ${_MKTARGET_COMPILE} - ${COMPILE.c} ${.ALLSRC} -o ${.TARGET}.o - ${OBJCOPY} ${OBJCOPYLIBFLAGS} ${.TARGET}.o ${.TARGET} - rm -f ${.TARGET}.o -.endif - -GENASSYM_CONF= ${COMMON_DIR}/sysident_assym.cf -sysident_assym.h: ${GENASSYM_CONF} ${GENASSYM_EXTRAS} ${NETBSDSRCDIR}/sys/sys/param.h - ${_MKTARGET_CREATE} - cat ${COMMON_DIR}/sysident_assym.cf | \ - ${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} ${CPPFLAGS} ${PROF} \ - ${GENASSYM_CPPFLAGS} > sysident_assym.h.tmp && \ - mv -f sysident_assym.h.tmp sysident_assym.h - -CLEANFILES+= sysident_assym.h - -crti.o: crti.S sysident_assym.h sysident.S -crtn.o: crtn.S - -FILES=${OBJS} -FILESDIR=${LIBDIR} -CLEANFILES+=${OBJS} - -.if ${MKPIC} == "yes" -SYMLINKS+= crtbegin.o ${LIBDIR}/crtbeginT.o -SYMLINKS+= crtend.o ${LIBDIR}/crtendS.o -.endif - -.include diff --git a/lib/csu/common/compident.S b/lib/csu/common/compident.S deleted file mode 100644 index aebea82b1..000000000 --- a/lib/csu/common/compident.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: compident.S,v 1.3 2014/05/14 14:59:14 joerg Exp $ */ - -/*- - * Copyright (c) 2002, 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -/* - * This file is used to generate a note describing the code model in use by - * the compiler on some architectures where this has consequences for the - * VA layout applied by the kernel. On sparc64 the topdown VA layout can - * only be enabled for processes compiled with -mcmodel=medany or greater, - * but not for processes without this note or -mcmodel=medlow. - * - * The note looks similar to the .note.netbsd.march note used (for example) - * on arm to note the ABI used by the process. - * - * [NOTE HEADER] - * long name size - * long content size - * long note type - * - * [NOTE DATUM] - * string code model (for sparc64: medlow, medmid, medany, - * the embedany model is never PIC, so not used here) - * - * The DATUM fields should be padded out such that their actual (not - * declared) sizes % 4 == 0. - */ - -#include "sysident_assym.h" - - .section .note.netbsd.mcmodel,"aM",@note,3*4+CONTENTLENGTH+ELF_NOTE_MCMODEL_NAMESZ+1 - .p2align 2 - - .long ELF_NOTE_MCMODEL_NAMESZ - .long CONTENTLENGTH - .long ELF_NOTE_TYPE_MCMODEL_TAG - .ascii "NetBSD\0\0" - .ascii CONTENT - .p2align 2 diff --git a/lib/csu/common/crt0-common.c b/lib/csu/common/crt0-common.c deleted file mode 100644 index 86f782398..000000000 --- a/lib/csu/common/crt0-common.c +++ /dev/null @@ -1,192 +0,0 @@ -/* $NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $ */ - -/* - * Copyright (c) 1998 Christos Zoulas - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -__RCSID("$NetBSD: crt0-common.c,v 1.13 2013/01/31 22:24:25 matt Exp $"); - -#include -#include -#if !defined(__minix) -#include -#else -#include -#endif /* !defined(__minix) */ -#include -#include -#include - -#include "rtld.h" - -extern int main(int, char **, char **); - -#ifndef HAVE_INITFINI_ARRAY -extern void _init(void); -extern void _fini(void); -#endif -extern void _libc_init(void); - -/* - * Arrange for _DYNAMIC to be weak and undefined (and therefore to show up - * as being at address zero, unless something else defines it). That way, - * if we happen to be compiling without -static but with without any - * shared libs present, things will still work. - */ - -__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC); - -#ifdef MCRT0 -extern void monstartup(u_long, u_long); -extern void _mcleanup(void); -extern unsigned char __etext, __eprol; -#endif /* MCRT0 */ - -char **environ; -struct ps_strings *__ps_strings = 0; - -static char empty_string[] = ""; -char *__progname = empty_string; - -__dead __dso_hidden void ___start(void (*)(void), const Obj_Entry *, - struct ps_strings *); - -#if !defined(__minix) -#define write(fd, s, n) __syscall(SYS_write, (fd), (s), (n)) -#else -#define write(fd, s, n) /* NO write() from here on minix */ -#endif /* !defined(__minix) */ - -#define _FATAL(str) \ -do { \ - write(2, str, sizeof(str)-1); \ - _exit(1); \ -} while (0) - -#ifdef HAVE_INITFINI_ARRAY -/* - * If we are using INIT_ARRAY/FINI_ARRAY and we are linked statically, - * we have to process these instead of relying on RTLD to do it for us. - * - * Since we don't need .init or .fini sections, just code them in C - * to make life easier. - */ -__weakref_visible const fptr_t preinit_array_start[1] - __weak_reference(__preinit_array_start); -__weakref_visible const fptr_t preinit_array_end[1] - __weak_reference(__preinit_array_end); -__weakref_visible const fptr_t init_array_start[1] - __weak_reference(__init_array_start); -__weakref_visible const fptr_t init_array_end[1] - __weak_reference(__init_array_end); -__weakref_visible const fptr_t fini_array_start[1] - __weak_reference(__fini_array_start); -__weakref_visible const fptr_t fini_array_end[1] - __weak_reference(__fini_array_end); - -static inline void -_preinit(void) -{ - for (const fptr_t *f = preinit_array_start; f < preinit_array_end; f++) { - (*f)(); - } -} - -static inline void -_init(void) -{ - for (const fptr_t *f = init_array_start; f < init_array_end; f++) { - (*f)(); - } -} - -static void -_fini(void) -{ - for (const fptr_t *f = fini_array_start; f < fini_array_end; f++) { - (*f)(); - } -} -#endif /* HAVE_INITFINI_ARRAY */ - -void -___start(void (*cleanup)(void), /* from shared loader */ - const Obj_Entry *obj, /* from shared loader */ - struct ps_strings *ps_strings) -{ - - if (ps_strings == NULL) - _FATAL("ps_strings missing\n"); - __ps_strings = ps_strings; - - environ = ps_strings->ps_envstr; - - if (ps_strings->ps_argvstr[0] != NULL) { - char *c; - __progname = ps_strings->ps_argvstr[0]; - for (c = ps_strings->ps_argvstr[0]; *c; ++c) { - if (*c == '/') - __progname = c + 1; - } - } else { - __progname = empty_string; - } - - if (&rtld_DYNAMIC != NULL) { - if (obj == NULL) - _FATAL("NULL Obj_Entry pointer in GOT\n"); - if (obj->magic != RTLD_MAGIC) - _FATAL("Corrupt Obj_Entry pointer in GOT\n"); - if (obj->version != RTLD_VERSION) - _FATAL("Dynamic linker version mismatch\n"); - atexit(cleanup); - } - - _libc_init(); - -#ifdef HAVE_INITFINI_ARRAY - _preinit(); -#endif - -#ifdef MCRT0 - atexit(_mcleanup); - monstartup((u_long)&__eprol, (u_long)&__etext); -#endif - - atexit(_fini); - _init(); - - exit(main(ps_strings->ps_nargvstr, ps_strings->ps_argvstr, environ)); -} diff --git a/lib/csu/common/crtbegin.c b/lib/csu/common/crtbegin.c deleted file mode 100644 index bf43358b5..000000000 --- a/lib/csu/common/crtbegin.c +++ /dev/null @@ -1,135 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -__RCSID("$NetBSD: crtbegin.c,v 1.9 2014/05/06 16:02:10 joerg Exp $"); - -#include "crtbegin.h" - -typedef void (*fptr_t)(void); - -__dso_hidden const fptr_t __JCR_LIST__[0] __section(".jcr"); - -__weakref_visible void Jv_RegisterClasses(const fptr_t *) - __weak_reference(_Jv_RegisterClasses); - -#if !defined(HAVE_INITFINI_ARRAY) -__dso_hidden const fptr_t __aligned(sizeof(void *)) __CTOR_LIST__[] __section(".ctors") = { - (fptr_t) -1, -}; -__dso_hidden extern const fptr_t __CTOR_LIST_END__[]; -#endif - -#ifdef SHARED -__dso_hidden void *__dso_handle = &__dso_handle; - -__weakref_visible void cxa_finalize(void *) - __weak_reference(__cxa_finalize); -#else -__dso_hidden void *__dso_handle; -#endif - -#if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) -__dso_hidden -#if !defined(__mips__) - const -#endif - long __EH_FRAME_LIST__[0] __section(".eh_frame"); - -__weakref_visible void register_frame_info(const void *, const void *) - __weak_reference(__register_frame_info); -__weakref_visible void deregister_frame_info(const void *) - __weak_reference(__deregister_frame_info); - -static long dwarf_eh_object[8]; -#endif - -static void __do_global_ctors_aux(void) __used; - -static void __section(".text.startup") -__do_global_ctors_aux(void) -{ - static unsigned char __initialized; - - if (__initialized) - return; - - __initialized = 1; - -#if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) - if (register_frame_info) - register_frame_info(__EH_FRAME_LIST__, &dwarf_eh_object); -#endif - - if (Jv_RegisterClasses && __JCR_LIST__[0] != 0) - Jv_RegisterClasses(__JCR_LIST__); - -#if !defined(HAVE_INITFINI_ARRAY) - for (const fptr_t *p = __CTOR_LIST_END__; p > __CTOR_LIST__ + 1; ) { - (*(*--p))(); - } -#endif -} - -#if !defined(__ARM_EABI__) || defined(SHARED) || defined(__ARM_DWARF_EH__) -#if !defined(HAVE_INITFINI_ARRAY) -__dso_hidden const fptr_t __aligned(sizeof(void *)) __DTOR_LIST__[] __section(".dtors") = { - (fptr_t) -1, -}; -__dso_hidden extern const fptr_t __DTOR_LIST_END__[]; -#endif - -static void __do_global_dtors_aux(void) __used; - -static void __section(".text.exit") -__do_global_dtors_aux(void) -{ - static unsigned char __finished; - - if (__finished) - return; - - __finished = 1; - -#ifdef SHARED - if (cxa_finalize) - (*cxa_finalize)(__dso_handle); -#endif - -#if !defined(HAVE_INITFINI_ARRAY) - for (const fptr_t *p = __DTOR_LIST__ + 1; p < __DTOR_LIST_END__; ) { - (*(*p++))(); - } -#endif - -#if !defined(__ARM_EABI__) || defined(__ARM_DWARF_EH__) - if (deregister_frame_info) - deregister_frame_info(__EH_FRAME_LIST__); -#endif -} -#endif /* !__ARM_EABI__ || SHARED || __ARM_DWARF_EH__ */ diff --git a/lib/csu/common/sysident.S b/lib/csu/common/sysident.S deleted file mode 100644 index fa261acac..000000000 --- a/lib/csu/common/sysident.S +++ /dev/null @@ -1,94 +0,0 @@ -/* $NetBSD: sysident.S,v 1.3 2014/05/14 14:59:14 joerg Exp $ */ - -/* - * Copyright (c) 1997 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - * - * <> - */ - -/* - * Here we define the NetBSD OS Version in an ELF .note section, structured - * like: - * - * [NOTE HEADER] - * long name size - * long description size - * long note type - * - * [NOTE DATUM] - * string OS name - * - * OSVERSION notes also have: - * long OS version (__NetBSD_Version__ constant from param.h) - * - * The DATUM fields should be padded out such that their actual (not - * declared) sizes % 4 == 0. - * - * These are used by the kernel to determine if this binary is really a - * NetBSD binary, or some other OS's. - */ - -#include "sysident_assym.h" - - .section ".note.netbsd.ident", "a" - .p2align 2 - - .long ELF_NOTE_NETBSD_NAMESZ - .long ELF_NOTE_NETBSD_DESCSZ - .long ELF_NOTE_TYPE_NETBSD_TAG -#if defined(__minix) - .ascii "Minix\0\0\0" /* ELF_NOTE_NETBSD_NAME */ - .long 300400000 /* Minix version as in "%d%03d%03d", MAJ-MIN-TEENY */ -#else - .ascii "NetBSD\0\0" /* ELF_NOTE_NETBSD_NAME */ - .long __NetBSD_Version__ -#endif /* defined(__minix) */ - - .section ".note.netbsd.pax", "a" - .p2align 2 - - .long ELF_NOTE_PAX_NAMESZ - .long ELF_NOTE_PAX_DESCSZ - .long ELF_NOTE_TYPE_PAX_TAG - .ascii "PaX\0" /* ELF_NOTE_PAX_NAME */ - .long 0 - -#ifdef ELF_NOTE_MARCH_DESC - .section ".note.netbsd.march", "a" - .p2align 2 - - .long ELF_NOTE_MARCH_NAMESZ - .long ELF_NOTE_MARCH_DESCSZ - .long ELF_NOTE_TYPE_MARCH_TAG - .ascii "NetBSD\0\0" - .asciz ELF_NOTE_MARCH_DESC - .p2align 2 -#endif diff --git a/lib/csu/common/sysident_assym.cf b/lib/csu/common/sysident_assym.cf deleted file mode 100644 index 2d4717def..000000000 --- a/lib/csu/common/sysident_assym.cf +++ /dev/null @@ -1,23 +0,0 @@ -include -include - -define ELF_NOTE_NETBSD_NAMESZ ELF_NOTE_NETBSD_NAMESZ -define ELF_NOTE_NETBSD_DESCSZ ELF_NOTE_NETBSD_DESCSZ -define ELF_NOTE_TYPE_NETBSD_TAG ELF_NOTE_TYPE_NETBSD_TAG -#define ELF_NOTE_NETBSD_NAME ELF_NOTE_NETBSD_NAME -define __NetBSD_Version__ __NetBSD_Version__ -define ELF_NOTE_PAX_NAMESZ ELF_NOTE_PAX_NAMESZ -define ELF_NOTE_PAX_DESCSZ ELF_NOTE_PAX_DESCSZ -define ELF_NOTE_TYPE_PAX_TAG ELF_NOTE_TYPE_PAX_TAG -#define ELF_NOTE_PAX_NAME ELF_NOTE_PAX_NAME - -ifdef ELF_NOTE_MARCH_DESC -define ELF_NOTE_MARCH_NAMESZ ELF_NOTE_MARCH_NAMESZ -define ELF_NOTE_MARCH_DESCSZ sizeof(ELF_NOTE_MARCH_DESC) -define ELF_NOTE_TYPE_MARCH_TAG ELF_NOTE_TYPE_MARCH_TAG -#define ELF_NOTE_MARCH_NAME ELF_NOTE_MARCH_NAME -#define ELF_NOTE_MARCH_DESC ELF_NOTE_MARCH_DESC -endif - -define ELF_NOTE_MCMODEL_NAMESZ ELF_NOTE_MCMODEL_NAMESZ -define ELF_NOTE_TYPE_MCMODEL_TAG ELF_NOTE_TYPE_MCMODEL_TAG diff --git a/lib/i18n_module/BIG5/Makefile b/lib/i18n_module/BIG5/Makefile deleted file mode 100644 index 17d26b258..000000000 --- a/lib/i18n_module/BIG5/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile,v 1.2 2006/11/22 23:38:27 tnozaki Exp $ - -SRCS= citrus_big5.c citrus_prop.c - -.include diff --git a/lib/i18n_module/DECHanyu/Makefile b/lib/i18n_module/DECHanyu/Makefile deleted file mode 100644 index e01737f0c..000000000 --- a/lib/i18n_module/DECHanyu/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2007/04/01 18:52:31 tnozaki Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/EUC/Makefile b/lib/i18n_module/EUC/Makefile deleted file mode 100644 index 4eec40960..000000000 --- a/lib/i18n_module/EUC/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2002/03/17 22:14:15 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/EUCTW/Makefile b/lib/i18n_module/EUCTW/Makefile deleted file mode 100644 index 4eec40960..000000000 --- a/lib/i18n_module/EUCTW/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2002/03/17 22:14:15 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/GBK2K/Makefile b/lib/i18n_module/GBK2K/Makefile deleted file mode 100644 index cb58cffa2..000000000 --- a/lib/i18n_module/GBK2K/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/03/25 18:26:54 tshiozak Exp $ - -SRCPRE=citrus_ -#CFLAGS+=-g -.include diff --git a/lib/i18n_module/HZ/Makefile b/lib/i18n_module/HZ/Makefile deleted file mode 100644 index 7d1fa0b98..000000000 --- a/lib/i18n_module/HZ/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2006/11/22 23:38:27 tnozaki Exp $ - -SRCS= citrus_hz.c citrus_prop.c - -.include diff --git a/lib/i18n_module/ISO2022/Makefile b/lib/i18n_module/ISO2022/Makefile deleted file mode 100644 index e12fd3a45..000000000 --- a/lib/i18n_module/ISO2022/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2002/03/17 22:14:16 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/JOHAB/Makefile b/lib/i18n_module/JOHAB/Makefile deleted file mode 100644 index 43ba852a1..000000000 --- a/lib/i18n_module/JOHAB/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2006/10/18 17:54:55 tnozaki Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/MSKanji/Makefile b/lib/i18n_module/MSKanji/Makefile deleted file mode 100644 index e12fd3a45..000000000 --- a/lib/i18n_module/MSKanji/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2002/03/17 22:14:16 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/Makefile b/lib/i18n_module/Makefile deleted file mode 100644 index 2928533e2..000000000 --- a/lib/i18n_module/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $NetBSD: Makefile,v 1.8 2007/04/01 18:52:31 tnozaki Exp $ - -SUBDIR= BIG5 DECHanyu EUC EUCTW GBK2K HZ ISO2022 JOHAB MSKanji UES UTF1632 UTF8 UTF7 VIQR ZW -SUBDIR+=iconv_none iconv_std -SUBDIR+=mapper_646 mapper_none mapper_serial mapper_parallel mapper_std \ - mapper_zone - -.include diff --git a/lib/i18n_module/Makefile.inc b/lib/i18n_module/Makefile.inc deleted file mode 100644 index f36470194..000000000 --- a/lib/i18n_module/Makefile.inc +++ /dev/null @@ -1,28 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.14 2012/08/23 21:21:15 joerg Exp $ - -NOLINT= # defined -NOPICINSTALL= # defined -NOPROFILE= # defined - -NOCLANGERROR= # defined - -.include - -SHLIB_VERSION_FILE= ${NETBSDSRCDIR}/lib/i18n_module/shlib_version -.if defined(MLIBDIR) -LIBDIR= /usr/lib/${MLIBDIR}/i18n -SHLIBDIR= /usr/lib/${MLIBDIR}/i18n -SHLIBINSTALLDIR=/usr/lib/${MLIBDIR}/i18n -.else -LIBDIR= /usr/lib/i18n -SHLIBDIR= /usr/lib/i18n -SHLIBINSTALLDIR=/usr/lib/i18n -.endif -CPPFLAGS+= -I${NETBSDSRCDIR}/lib/libc/citrus -CPPFLAGS+= -DLOCALEMOD_MAJOR=${SHLIB_MAJOR} -CPPFLAGS+= -DLIBC_SCCS -BASENAME= ${.CURDIR:T} -LIB= ${BASENAME} -SRCS?= ${SRCPRE:tl}${BASENAME:tl}.c - -.PATH: ${NETBSDSRCDIR}/lib/libc/citrus ${NETBSDSRCDIR}/lib/libc/citrus/modules diff --git a/lib/i18n_module/UES/Makefile b/lib/i18n_module/UES/Makefile deleted file mode 100644 index 9eea834c9..000000000 --- a/lib/i18n_module/UES/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2006/11/13 15:16:31 tnozaki Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/UTF1632/Makefile b/lib/i18n_module/UTF1632/Makefile deleted file mode 100644 index b203319a0..000000000 --- a/lib/i18n_module/UTF1632/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:03 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/UTF7/Makefile b/lib/i18n_module/UTF7/Makefile deleted file mode 100644 index 712c1515d..000000000 --- a/lib/i18n_module/UTF7/Makefile +++ /dev/null @@ -1,8 +0,0 @@ -# $NetBSD: Makefile,v 1.4 2011/06/20 06:52:36 mrg Exp $ - -SRCPRE=citrus_ -.include - -.if ${MACHINE_ARCH} == "vax" && defined(HAVE_GCC) -COPTS.citrus_utf7.c+= -O0 -.endif diff --git a/lib/i18n_module/UTF8/Makefile b/lib/i18n_module/UTF8/Makefile deleted file mode 100644 index 4ae199661..000000000 --- a/lib/i18n_module/UTF8/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2002/03/17 22:14:17 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/VIQR/Makefile b/lib/i18n_module/VIQR/Makefile deleted file mode 100644 index 9eea834c9..000000000 --- a/lib/i18n_module/VIQR/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2006/11/13 15:16:31 tnozaki Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/ZW/Makefile b/lib/i18n_module/ZW/Makefile deleted file mode 100644 index 6b2859209..000000000 --- a/lib/i18n_module/ZW/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2006/11/22 23:38:27 tnozaki Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/iconv_none/Makefile b/lib/i18n_module/iconv_none/Makefile deleted file mode 100644 index 20b61d5b6..000000000 --- a/lib/i18n_module/iconv_none/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:04 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/iconv_std/Makefile b/lib/i18n_module/iconv_std/Makefile deleted file mode 100644 index 20b61d5b6..000000000 --- a/lib/i18n_module/iconv_std/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:04 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/mapper_646/Makefile b/lib/i18n_module/mapper_646/Makefile deleted file mode 100644 index 20b61d5b6..000000000 --- a/lib/i18n_module/mapper_646/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:04 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/mapper_none/Makefile b/lib/i18n_module/mapper_none/Makefile deleted file mode 100644 index 2fc2ff512..000000000 --- a/lib/i18n_module/mapper_none/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:05 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/mapper_parallel/Makefile b/lib/i18n_module/mapper_parallel/Makefile deleted file mode 100644 index 804d1772d..000000000 --- a/lib/i18n_module/mapper_parallel/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:05 tshiozak Exp $ - -SRCS=citrus_mapper_serial.c -.include diff --git a/lib/i18n_module/mapper_serial/Makefile b/lib/i18n_module/mapper_serial/Makefile deleted file mode 100644 index 2fc2ff512..000000000 --- a/lib/i18n_module/mapper_serial/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:05 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/mapper_std/Makefile b/lib/i18n_module/mapper_std/Makefile deleted file mode 100644 index 21f2782d5..000000000 --- a/lib/i18n_module/mapper_std/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:06 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/mapper_zone/Makefile b/lib/i18n_module/mapper_zone/Makefile deleted file mode 100644 index 21f2782d5..000000000 --- a/lib/i18n_module/mapper_zone/Makefile +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile,v 1.1 2003/06/25 10:38:06 tshiozak Exp $ - -SRCPRE=citrus_ -.include diff --git a/lib/i18n_module/shlib_version b/lib/i18n_module/shlib_version deleted file mode 100644 index af2e1da43..000000000 --- a/lib/i18n_module/shlib_version +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: shlib_version,v 1.6 2009/01/11 03:07:47 christos Exp $ -# Remember to update distrib/sets/lists/base/shl.* when changing -# -major=5 -minor=0 diff --git a/lib/libbz2/Makefile b/lib/libbz2/Makefile deleted file mode 100644 index 11b6c1b49..000000000 --- a/lib/libbz2/Makefile +++ /dev/null @@ -1,43 +0,0 @@ -# $NetBSD: Makefile,v 1.18 2014/07/05 19:22:42 dholland Exp $ - -USE_FORT?= yes # data driven bugs? - -NOMAN= # defined - -.include - -LIB= bz2 -DIST= ${NETBSDSRCDIR}/external/bsd/bzip2/dist -.PATH: ${DIST} - -SRCS= blocksort.c huffman.c crctable.c randtable.c compress.c \ - decompress.c bzlib.c -INCS= bzlib.h -INCSDIR= /usr/include - -.if defined(__MINIX) -.if !empty(DBG:M-Og) || !empty(CFLAGS:M-Og) || \ - !empty(DBG:M-g) || !empty(CFLAGS:M-g) -#LSC: -Wno-maybe-uninitialized while compiling with -DNDEBUG -Og -CWARNFLAGS.gcc+= -Wno-maybe-uninitialized -.endif -.endif # defined(__MINIX) - -# XXX huffman.c gets mis-compiled with 2.95.3 -.if ${MACHINE_ARCH} == "vax" -COPTS+= -O0 -.endif - -# XXX blocksort.c gets mis-compiled with 4.1 -.if (${MACHINE_ARCH} == "sh3el" || ${MACHINE_ARCH} == "sh3eb") && \ - defined(HAVE_GCC) -COPTS.blocksort.c+= -fno-loop-optimize -.endif - -.if ${MKSHARE} != "no" -FILESDIR= /usr/share/doc/reference/ref1/bzip2 -FILES= manual.html -.endif - -.include -.include diff --git a/lib/libbz2/shlib_version b/lib/libbz2/shlib_version deleted file mode 100644 index 45ca00de4..000000000 --- a/lib/libbz2/shlib_version +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: shlib_version,v 1.4 2008/03/19 17:10:52 bjs Exp $ -# Remember to update distrib/sets/lists/base/shl.* when changing -# -major=1 -minor=1 diff --git a/lib/libc/Makefile b/lib/libc/Makefile deleted file mode 100644 index 76a8a37c1..000000000 --- a/lib/libc/Makefile +++ /dev/null @@ -1,186 +0,0 @@ -# $NetBSD: Makefile,v 1.169 2015/06/15 14:24:01 christos Exp $ -# @(#)Makefile 8.2 (Berkeley) 2/3/94 -# -# All library objects contain sccsid strings by default; they may be -# excluded as a space-saving measure. To produce a library that does -# not contain these strings, delete -DLIBC_SCCS and -DSYSLIBC_SCCS -# from CPPFLAGS below. To remove these strings from just the system call -# stubs, remove just -DSYSLIBC_SCCS from CPPFLAGS. -# -# The NLS (message catalog) functions are always in libc. To choose that -# strerror(), perror(), strsignal(), psignal(), etc. actually call the NLS -# functions, put -DNLS on the CPPFLAGS line below. -# -# The YP functions are always in libc. To choose that getpwent() and friends -# actually call the YP functions, put -DYP on the CPPFLAGS line below. -# -# The Hesiod functions are always in libc. To choose that getpwent() and friends -# actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below. - -.include "Makefile.inc" - -LIB= c -CPPFLAGS+= -I${.CURDIR}/include -I${.CURDIR} - -LIBCDIR= ${.CURDIR} - -.if exists (${ARCHDIR}/Makefile.inc) -.PATH: ${ARCHDIR} -.include "${ARCHDIR}/Makefile.inc" -.endif - -.if exists (${ARCHDIR}/genassym.cf) -DPSRCS+= assym.h -CLEANFILES+= assym.h assym.h.tmp - -assym.h: ${ARCHDIR}/genassym.cf - ${_MKTARGET_CREATE} - ${TOOL_GENASSYM} -- ${CC} ${CFLAGS:N-Wa,*} \ - ${CPPFLAGS} ${CPPFLAGS.assym.h} ${PROF} \ - ${GENASSYM_CPPFLAGS} < ${ARCHDIR}/genassym.cf > assym.h.tmp && \ - mv -f assym.h.tmp assym.h -.endif - -# The following controls how to build compatibility code for old NetBSD -# binaries. If BUILD_LEGACY is yes, then we build a separate library; otherwise -# we include the code in libc. -BUILD_LEGACY?= no -.if "${BUILD_LEGACY}" == "yes" -SUBDIR=compat -.include -.else -COMPATDIR=${.CURDIR}/compat -.include "${.CURDIR}/compat/Makefile.inc" -# Marker for compat code that can't be easily isolated -CPPFLAGS+= -D__BUILD_LEGACY -.endif - -.if defined(__MINIX) && 0 -SUBDIR+= pkgconfig -.include -.endif # defined(__MINIX) - -.include "${.CURDIR}/../../common/lib/libc/Makefile.inc" -.include "${.CURDIR}/atomic/Makefile.inc" -.include "${.CURDIR}/cdb/Makefile.inc" -.include "${.CURDIR}/db/Makefile.inc" -.include "${.CURDIR}/citrus/Makefile.inc" -.include "${.CURDIR}/compat-43/Makefile.inc" -.include "${.CURDIR}/compiler_rt/Makefile.inc" -.include "${.CURDIR}/dlfcn/Makefile.inc" -.include "${.CURDIR}/gdtoa/Makefile.inc" -.include "${.CURDIR}/gen/Makefile.inc" -.if defined(__MINIX) -# gmon needs profil() -.else -.include "${.CURDIR}/gmon/Makefile.inc" -.endif # defined(__MINIX) -.include "${.CURDIR}/hash/Makefile.inc" -.include "${.CURDIR}/iconv/Makefile.inc" -.include "${.CURDIR}/inet/Makefile.inc" -.include "${.CURDIR}/isc/Makefile.inc" -.include "${.CURDIR}/locale/Makefile.inc" -.include "${.CURDIR}/md/Makefile.inc" -.include "${.CURDIR}/misc/Makefile.inc" -.include "${.CURDIR}/net/Makefile.inc" -.include "${.CURDIR}/nameser/Makefile.inc" -.include "${.CURDIR}/nls/Makefile.inc" -.if (${USE_LIBTRE} == "yes") -.include "${NETBSDSRCDIR}/external/bsd/tre/Makefile.inc" -.else -.include "${.CURDIR}/regex/Makefile.inc" -.endif -.include "${.CURDIR}/resolv/Makefile.inc" -.if defined(__MINIX) -# RPC needs pollts() and a reserved port allocator. -.else -.include "${.CURDIR}/rpc/Makefile.inc" -.endif # defined(__MINIX) -.include "${.CURDIR}/ssp/Makefile.inc" -.include "${.CURDIR}/stdio/Makefile.inc" -.include "${.CURDIR}/stdlib/Makefile.inc" -.include "${.CURDIR}/string/Makefile.inc" -.include "${.CURDIR}/termios/Makefile.inc" -.include "${.CURDIR}/thread-stub/Makefile.inc" -.include "${.CURDIR}/time/Makefile.inc" -.if defined(__MINIX) -.include "${NETBSDSRCDIR}/minix/lib/libc/sys/Makefile.inc" -.else -.if ${RUMPRUN} != "yes" -.include "${.CURDIR}/tls/Makefile.inc" -.endif -.endif # defined(__MINIX) -.include "${.CURDIR}/sys/Makefile.inc" -.if ${HAVE_LIBGCC_EH} == "no" -.include "${NETBSDSRCDIR}/sys/lib/libunwind/Makefile.inc" -.endif -.include "${.CURDIR}/uuid/Makefile.inc" -.if (${MKYP} != "no") -.include "${.CURDIR}/yp/Makefile.inc" -.endif - -# Remove from SRCS the .c files for any .S files added by the MD makefiles, -# also remove from SRCS the .c files for the .S and .c files in NO_SRCS. -# Add the .c file for .S files (in both variables) to LSRCS so that the -# 'normal' .c file for assembly files is used for the lint librray. -# -# Usage: -# Add .S files to NO_SRSC when another .S file provides the entry points. -# Add .c files to NO_SRSC when another .c file provides the entry points. -# (lint is run on all .c files in SRCS) - -.for check_file in ${SRCS:M*.S} ${NO_SRCS} -unwanted_file := ${SRCS:M${check_file:.S=.c}} -.if "${unwanted_file}" != "" -SRCS := ${SRCS:N${unwanted_file}} -.if "${unwanted_file}" != "${check_file}" -LSRCS := ${LSRCS} ${unwanted_file} -.endif -.endif -.endfor - -NLS= C.msg Pig.msg ca.msg cs.msg de.msg es.msg fi.msg fr.msg nl.msg \ - no.msg pl.msg sk.msg sv.msg - -.if defined(__MINIX) -realall: -.else -.if ${MKREPRO:Uno} == "yes" -REGEX_SPECIALS=[][)(^$$.?*\\;] -MKREPRO_SED= -e 's;${NETBSDSRCDIR:C/${REGEX_SPECIALS}/\\\\&/g};/usr/src;' -.endif - -.if !defined(MLIBDIR) && ${RUMPRUN} != "yes" -realall: tags -tags: ${SRCS} - ${_MKTARGET_CREATE} - -${TOOL_CTAGS} -f ${.TARGET}.tmp -w ${.ALLSRC:M*.c} - -egrep "^ENTRY(.*)|^FUNC(.*)|^SYSCALL(.*)" /dev/null ${.ALLSRC:M*.S} | \ - sed "s;\([^:]*\):\([^(]*\)(\([^, )]*\)\(.*\);\3 \1 /^\2(\3\4$$/;" \ - >> ${.TARGET}.tmp -.if ${MKREPRO:Uno} == "yes" - sed ${MKREPRO_SED} <${.TARGET}.tmp | sort -o ${.TARGET} -.else - sort -o ${.TARGET} ${.TARGET}.tmp -.endif - rm -f ${.TARGET}.tmp - -FILES= tags -FILESNAME= libc.tags -FILESDIR= /var/db -.endif - - -# workaround for I18N stuffs: build singlebyte setlocale() for libc.a, -# multibyte for libc.so. the quirk should be removed when we support -# dlopen() from within statically linked binaries. -CSHLIBFLAGS+= -D_I18N_DYNAMIC -.endif # defined(__MINIX) - -.include - -# force the dynamic linker to initialize libc first -SHLIB_SHFLAGS+= -Wl,-z,initfirst -.if ${HAVE_LIBGCC} == "no" -SHLIB_SHFLAGS+= -Wl,-z,defs -.endif diff --git a/lib/libc/Makefile.inc b/lib/libc/Makefile.inc deleted file mode 100644 index 66e5cb402..000000000 --- a/lib/libc/Makefile.inc +++ /dev/null @@ -1,79 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.18 2015/08/28 11:45:02 joerg Exp $ -# @(#)Makefile 8.2 (Berkeley) 2/3/94 -# -# All library objects contain sccsid strings by default; they may be -# excluded as a space-saving measure. To produce a library that does -# not contain these strings, delete -DLIBC_SCCS and -DSYSLIBC_SCCS -# from CPPFLAGS below. To remove these strings from just the system call -# stubs, remove just -DSYSLIBC_SCCS from CPPFLAGS. -# -# The NLS (message catalog) functions are always in libc. To choose that -# strerror(), perror(), strsignal(), psignal(), etc. actually call the NLS -# functions, put -DNLS on the CPPFLAGS line below. -# -# The YP functions are always in libc. To choose that getpwent() and friends -# actually call the YP functions, put -DYP on the CPPFLAGS line below. -# -# The Hesiod functions are always in libc. To choose that getpwent() and friends -# actually call the Hesiod functions, put -DHESIOD on the CPPFLAGS line below. -.if defined(__MINIX) -MKYP=no #requires RPC -USE_JEMALLOC=no -USE_FORT=no -USE_LIBTRE=no - -# BJG too many warnings -NOGCCERROR?= yes -NOCLANGERROR?= yes -.endif # defined(__MINIX) - -USE_FORT?= yes - -USE_SHLIBDIR= yes - -.include - -# build libc suitable for rumprun software stack, i.e. are system calls -# rump kernel function calls instead of kernel traps? -RUMPRUN?= no - -WARNS=5 -.if !defined(__MINIX) -CPPFLAGS+= -D_LIBC -DLIBC_SCCS -DSYSLIBC_SCCS -D_REENTRANT -CPPFLAGS+= -D_DIAGNOSTIC -.else -CPPFLAGS+= -D_LIBC -.if defined(MLIBDIR) -CPPFLAGS+= -DMLIBDIR=\"${MLIBDIR}\" -.endif -.endif # !defined(__minix) - -.if (${USE_HESIOD} != "no") -CPPFLAGS+= -DHESIOD -.endif - -.if (${USE_INET6} != "no") -CPPFLAGS+= -DINET6 -.endif - -CPPFLAGS+= -DNLS - -.if (${USE_YP} != "no") -CPPFLAGS+= -DYP -.endif - -# Set lint to exit on warnings -#LINTFLAGS+= -w -# ignore 'empty translation unit' warnings. -LINTFLAGS+= -X 272 - -.include "libcincludes.mk" - -ARCHDIR= ${.CURDIR}/arch/${ARCHSUBDIR} -AFLAGS+= -I${ARCHDIR} -CLEANFILES+= tags - -# Don't try to lint the C library against itself when creating llib-lc.ln -LLIBS= - -INCSDIR= /usr/include diff --git a/lib/libc/arch/aarch64/Makefile.inc b/lib/libc/arch/aarch64/Makefile.inc deleted file mode 100644 index ff1c7dab7..000000000 --- a/lib/libc/arch/aarch64/Makefile.inc +++ /dev/null @@ -1,18 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2015/04/15 19:13:46 mrg Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S -#SRCS+= qdivrem.c - -CPPFLAGS += -I. - -.PATH: ${ARCHDIR}/softfloat -SRCS+= qp.c -CPPFLAGS+= -DSOFTFLOATAARCH64_FOR_GCC -DEXCEPTIONS_WITH_SOFTFLOAT -CPPFLAGS+= -DSOFTFLOAT_NEED_FIXUNS -# -# Can't directly use softfloat.c due to .PATH issues with the other source -# in softfloat. Just provide a wrapper which pulls it in via a #include -SRCS.softfloat= softfloat-wrapper.c -SRCS+= ${SRCS.softfloat} -CPPFLAGS+= -I${ARCHDIR}/softfloat -I${.CURDIR}/softfloat \ - -I${.CURDIR}/softfloat/bits64 diff --git a/lib/libc/arch/aarch64/SYS.h b/lib/libc/arch/aarch64/SYS.h deleted file mode 100644 index f70112472..000000000 --- a/lib/libc/arch/aarch64/SYS.h +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: SYS.h,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#ifndef __STDC__ -#error __STDC__ not defined -#endif - -#define SYSTRAP(x) svc #(SYS_ ## x) - -#define _SYSCALL_NOERROR(x,y) \ - ENTRY(x); \ - SYSTRAP(y) - -#define _INVOKE_CERROR() \ - b.cs _C_LABEL(__cerror) - -#define _SYSCALL(x, y) \ - _SYSCALL_NOERROR(x,y); \ - _INVOKE_CERROR() - -#define SYSCALL_NOERROR(x) \ - _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ - ret; \ - END(x) - -#define PSEUDO(x,y) \ - _SYSCALL(x,y); \ - ret; \ - END(x) - -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) \ - PSEUDO(x,x) - -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) - - .hidden __cerror - .globl __cerror diff --git a/lib/libc/arch/aarch64/gdtoa/Makefile.inc b/lib/libc/arch/aarch64/gdtoa/Makefile.inc deleted file mode 100644 index 844c4584c..000000000 --- a/lib/libc/arch/aarch64/gdtoa/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:36 matt Exp $ - -SRCS+= strtof.c -SRCS+= strtold_pQ.c -SRCS+= strtopQ.c diff --git a/lib/libc/arch/aarch64/gdtoa/arith.h b/lib/libc/arch/aarch64/gdtoa/arith.h deleted file mode 100644 index 40cb7d935..000000000 --- a/lib/libc/arch/aarch64/gdtoa/arith.h +++ /dev/null @@ -1,7 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -#ifdef __AARCH64EB__ -#define IEEE_BIG_ENDIAN -#else -#define IEEE_LITTLE_ENDIAN -#endif diff --git a/lib/libc/arch/aarch64/gdtoa/gd_qnan.h b/lib/libc/arch/aarch64/gdtoa/gd_qnan.h deleted file mode 100644 index ffeaefde0..000000000 --- a/lib/libc/arch/aarch64/gdtoa/gd_qnan.h +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -#define f_QNAN 0x7fc00000 -#ifdef __AARCH64EB__ -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 -#define ld_QNAN0 0x7ff80000 -#define ld_QNAN1 0x0 -#define ld_QNAN2 0x0 -#define ld_QNAN3 0x0 -#else -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff80000 -#define ld_QNAN0 0x0 -#define ld_QNAN1 0x0 -#define ld_QNAN2 0x0 -#define ld_QNAN3 0x7ff80000 -#endif diff --git a/lib/libc/arch/aarch64/gen/Makefile.inc b/lib/libc/arch/aarch64/gen/Makefile.inc deleted file mode 100644 index ffb5b87e1..000000000 --- a/lib/libc/arch/aarch64/gen/Makefile.inc +++ /dev/null @@ -1,33 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2015/07/07 21:40:19 matt Exp $ - -SRCS+= byte_swap_2.S byte_swap_4.S byte_swap_8.S -SRCS+= flt_rounds.c - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c fpclassifyl_ieee754.c -SRCS+= fpgetmask.c fpgetround.c fpgetsticky.c -SRCS+= fpsetmask.c fpsetround.c fpsetsticky.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c isfinitel_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c isinfl_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c isnanl_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c signbitl_ieee754.c -SRCS+= fixunsgen_ieee754.c fixunsgen64_ieee754.c -SRCS+= fixunstfsi_ieee754.c fixunstfdi_ieee754.c -SRCS+= fabs_ieee754.S -#SRCS+= fabsf_ieee754.S fabsl_ieee754.c - -SRCS+= nanf.c - -SRCS+= setjmp.S -SRCS+= _setjmp.S -SRCS+= sigsetjmp.S - -SRCS+= makecontext.c resumecontext.c swapcontext.S - -SRCS+= _lwp.c - -#LSRCS.arm.gen= Lint_bswap16.c Lint_bswap32.c Lint_swapcontext.c -#LSRCS+= ${LSRCS.arm.gen} -#DPSRCS+= ${LSRCS.arm.gen} -#CLEANFILES+= ${LSRCS.arm.gen} diff --git a/lib/libc/arch/aarch64/gen/_lwp.c b/lib/libc/arch/aarch64/gen/_lwp.c deleted file mode 100644 index e9a578ec3..000000000 --- a/lib/libc/arch/aarch64/gen/_lwp.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.1 2014/08/10 05:47:36 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - uintptr_t sp = (uintptr_t)stack_base + stack_size; - - /* - * Note: We make sure the stack is 16-byte aligned, here. - */ - - u->uc_mcontext.__gregs[_REG_X0] = (__greg_t)(uintptr_t)arg; - u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t)sp) & -16; - u->uc_mcontext.__gregs[_REG_X29] = (__greg_t)(uintptr_t)_lwp_exit; - u->uc_mcontext.__gregs[_REG_PC] = (__greg_t)(uintptr_t)start; - u->uc_mcontext.__gregs[_REG_TPIDR] = (__greg_t)(uintptr_t)private; -} diff --git a/lib/libc/arch/aarch64/gen/_setjmp.S b/lib/libc/arch/aarch64/gen/_setjmp.S deleted file mode 100644 index e7722f123..000000000 --- a/lib/libc/arch/aarch64/gen/_setjmp.S +++ /dev/null @@ -1,117 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "assym.h" - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a, v) - * will generate a "return v;" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - * - * Note: x0 is the return value - */ - .section .rodata.cst8,"aM",@progbits,8 - .align 3 -.L_MAGIC: - .xword _JB_MAGIC_AARCH64__SETJMP - -ENTRY(_setjmp) - adrp x7, .L_MAGIC - ldr x7, [x7, #:lo12:.L_MAGIC] - - mov x3, sp - - stp x7, x3, [x0, #_JB_MAGIC] - - stp x19, x20, [x0, #_JB_X19] - stp x21, x22, [x0, #_JB_X21] - stp x23, x24, [x0, #_JB_X23] - stp x25, x26, [x0, #_JB_X25] - stp x27, x28, [x0, #_JB_X27] - stp x29, x30, [x0, #_JB_X29] - - mrs x5, tpidr_el0 - str x5, [x0, #_JB_TPIDR] - - stp d8, d9, [x0, #_JB_D8] - stp d10, d11, [x0, #_JB_D10] - stp d12, d13, [x0, #_JB_D12] - stp d14, d15, [x0, #_JB_D14] - - mov x0, xzr - ret -END(_setjmp) - -ENTRY(_longjmp) - adrp x7, .L_MAGIC - ldr x7, [x7, #:lo12:.L_MAGIC] - - ldp x2, x3, [x0, #_JB_MAGIC] - ldp x4, x5, [x0, #_JB_X29] - - cbz x3, .Lbotch - cbz x4, .Lbotch - cbz x5, .Lbotch - cmp x2, x7 - b.ne .Lbotch - - ldp x19, x20, [x0, #_JB_X19] - ldp x21, x22, [x0, #_JB_X21] - ldp x23, x24, [x0, #_JB_X23] - ldp x25, x26, [x0, #_JB_X25] - ldp x27, x28, [x0, #_JB_X27] - - ldr x5, [x0, #_JB_TPIDR] - msr tpidr_el0, x5 - - ldp d8, d9, [x0, #_JB_D8] - ldp d10, d11, [x0, #_JB_D10] - ldp d12, d13, [x0, #_JB_D12] - ldp d14, d15, [x0, #_JB_D14] - - mov sp, x3 - mov x29, x4 - mov x30, x5 - - mov x0, x1 - ret - - /* validation failed, die die die. */ -.Lbotch: - bl _C_LABEL(longjmperror) - bl _C_LABEL(abort) -1: b 1b /* Cannot get here */ -END(_longjmp) diff --git a/lib/libc/arch/aarch64/gen/fabs_ieee754.S b/lib/libc/arch/aarch64/gen/fabs_ieee754.S deleted file mode 100644 index 0f90dbd49..000000000 --- a/lib/libc/arch/aarch64/gen/fabs_ieee754.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: fabs_ieee754.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: fabs_ieee754.S,v 1.1 2014/08/10 05:47:36 matt Exp $") - -ENTRY(fabs) - fabs d0, d0 - ret -END(fabs) diff --git a/lib/libc/arch/aarch64/gen/flt_rounds.c b/lib/libc/arch/aarch64/gen/flt_rounds.c deleted file mode 100644 index 9c59a6ed2..000000000 --- a/lib/libc/arch/aarch64/gen/flt_rounds.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.1 2014/08/10 05:47:36 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include - - -/* - * Return the current FP rounding mode - * - * Returns: - * 0 - round to zero - * 1 - round to nearest - * 2 - round to postive infinity - * 3 - round to negative infinity - * - * However, the rounding modes stored in the FPCR are: - * 0 - round to nearest - * 1 - round to postive infinity - * 2 - round to negative infinity - * 3 - round to zero - * - * To convert, just add 1 and then mask with 3. - */ - -int __flt_rounds(void); - -int -__flt_rounds(void) -{ - return (__SHIFTOUT(reg_fpcr_read(), FPCR_RMODE) + 1) & 3; -} diff --git a/lib/libc/arch/aarch64/gen/fpgetmask.c b/lib/libc/arch/aarch64/gen/fpgetmask.c deleted file mode 100644 index 72edba770..000000000 --- a/lib/libc/arch/aarch64/gen/fpgetmask.c +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 2015 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: fpgetmask.c,v 1.1 2015/07/05 22:07:09 matt Exp $"); - -#include -#include -#include - -#include "namespace.h" - -#include - -#include - -__weak_alias(fpgetmask,_fpgetmask); - -fp_except_t -fpgetmask(void) -{ - return __SHIFTOUT(reg_fpcr_read(), FPCR_ESUM); -} diff --git a/lib/libc/arch/aarch64/gen/fpgetround.c b/lib/libc/arch/aarch64/gen/fpgetround.c deleted file mode 100644 index 63ab49a1f..000000000 --- a/lib/libc/arch/aarch64/gen/fpgetround.c +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 2015 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: fpgetround.c,v 1.1 2015/07/05 22:07:09 matt Exp $"); - -#include -#include -#include - -#include "namespace.h" - -#include - -#include - -__weak_alias(fpgetround,_fpgetround); - -fp_rnd_t -fpgetround(void) -{ - return __SHIFTOUT(reg_fpcr_read(), FPCR_RMODE); -} diff --git a/lib/libc/arch/aarch64/gen/fpgetsticky.c b/lib/libc/arch/aarch64/gen/fpgetsticky.c deleted file mode 100644 index a27ce39a8..000000000 --- a/lib/libc/arch/aarch64/gen/fpgetsticky.c +++ /dev/null @@ -1,50 +0,0 @@ -/*- - * Copyright (c) 2015 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: fpgetsticky.c,v 1.1 2015/07/05 22:07:09 matt Exp $"); - -#include -#include -#include - -#include "namespace.h" - -#include - -#include - -__weak_alias(fpgetsticky,_fpgetsticky) - -fp_except_t -fpgetsticky(void) -{ - return __SHIFTOUT(reg_fpsr_read(), FPSR_CSUM); -} diff --git a/lib/libc/arch/aarch64/gen/fpsetmask.c b/lib/libc/arch/aarch64/gen/fpsetmask.c deleted file mode 100644 index 8662d58bd..000000000 --- a/lib/libc/arch/aarch64/gen/fpsetmask.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 2015 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: fpsetmask.c,v 1.1 2015/07/07 21:40:19 matt Exp $"); - -#include -#include -#include - -#include "namespace.h" - -#include - -#include - -__weak_alias(fpsetmask,_fpsetmask); - -fp_except_t -fpsetmask(fp_except_t mask) -{ - const uint32_t old_fpcr = reg_fpcr_read(); - const uint32_t new_fpcr = (old_fpcr & ~FPCR_ESUM) - | __SHIFTIN(mask, FPCR_ESUM); - reg_fpcr_write(new_fpcr); - return __SHIFTOUT(old_fpcr, FPCR_ESUM); -} diff --git a/lib/libc/arch/aarch64/gen/fpsetround.c b/lib/libc/arch/aarch64/gen/fpsetround.c deleted file mode 100644 index c554ace1d..000000000 --- a/lib/libc/arch/aarch64/gen/fpsetround.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 2015 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: fpsetround.c,v 1.1 2015/07/07 21:40:19 matt Exp $"); - -#include -#include -#include - -#include "namespace.h" - -#include - -#include - -__weak_alias(fpsetround,_fpsetround); - -fp_rnd_t -fpsetround(fp_rnd_t rnd) -{ - const uint32_t old_fpcr = reg_fpcr_read(); - const uint32_t new_fpcr = (~old_fpcr & ~FPCR_RMODE) - | __SHIFTIN(rnd, FPCR_RMODE); - reg_fpcr_write(new_fpcr); - return __SHIFTOUT(old_fpcr, FPCR_RMODE); -} diff --git a/lib/libc/arch/aarch64/gen/fpsetsticky.c b/lib/libc/arch/aarch64/gen/fpsetsticky.c deleted file mode 100644 index 4af29e508..000000000 --- a/lib/libc/arch/aarch64/gen/fpsetsticky.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 2015 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: fpsetsticky.c,v 1.1 2015/07/07 21:40:19 matt Exp $"); - -#include -#include -#include - -#include "namespace.h" - -#include - -#include - -__weak_alias(fpsetsticky,_fpsetsticky) - -fp_except_t -fpsetsticky(fp_except_t sticky) -{ - const uint32_t old_fpsr = reg_fpsr_read(); - const uint32_t new_fpsr = (old_fpsr & ~FPSR_CSUM) - | __SHIFTIN(sticky, FPSR_CSUM); - reg_fpsr_write(new_fpsr); - return __SHIFTOUT(old_fpsr, FPSR_CSUM); -} diff --git a/lib/libc/arch/aarch64/gen/makecontext.c b/lib/libc/arch/aarch64/gen/makecontext.c deleted file mode 100644 index ac7bb729c..000000000 --- a/lib/libc/arch/aarch64/gen/makecontext.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.1 2014/08/10 05:47:36 matt Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t * const gr = ucp->uc_mcontext.__gregs; - __uint64_t *sp; - - /* Compute and align stack pointer. */ - sp = (uint64_t *) - (((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & -16LL); - /* Allocate necessary stack space for arguments exceeding x0-7. */ - if (argc > 8) - sp -= argc - 8; - gr[_REG_SP] = (__greg_t)(uintptr_t)sp; - /* Wipe out frame pointer. */ - gr[_REG_X29] = 0; - /* Arrange for return via the trampoline code. */ - gr[_REG_X30] = (__greg_t)(uintptr_t)_resumecontext; - gr[_REG_PC] = (__greg_t)(uintptr_t)func; - - va_list ap; - va_start(ap, argc); - - /* Pass up to four arguments in r0-3. */ - for (int i = 0; i < argc && i < 8; i++) { - gr[_REG_X0 + i] = va_arg(ap, int); - } - - /* Pass any additional arguments on the stack. */ - for (int i = 8; i < argc; i++) { - *sp++ = va_arg(ap, uint64_t); - } - va_end(ap); -} diff --git a/lib/libc/arch/aarch64/gen/nanf.c b/lib/libc/arch/aarch64/gen/nanf.c deleted file mode 100644 index 9edcb9e04..000000000 --- a/lib/libc/arch/aarch64/gen/nanf.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: nanf.c,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.1 2014/08/10 05:47:36 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = -#ifdef __AARCH64EB__ - { { 0x7f, 0xc0, 0, 0 } }; -#else - { { 0, 0, 0xc0, 0x7f } }; -#endif - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/aarch64/gen/resumecontext.c b/lib/libc/arch/aarch64/gen/resumecontext.c deleted file mode 100644 index 33d48584c..000000000 --- a/lib/libc/arch/aarch64/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.1 2014/08/10 05:47:36 matt Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/aarch64/gen/setjmp.S b/lib/libc/arch/aarch64/gen/setjmp.S deleted file mode 100644 index 2c31db879..000000000 --- a/lib/libc/arch/aarch64/gen/setjmp.S +++ /dev/null @@ -1,133 +0,0 @@ -/*.$NetBSD: setjmp.S,v 1.1 2014/08/10 05:47:36 matt Exp $.*/ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "assym.h" - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - - .section .rodata.cst8,"aM",@progbits,8 - .align 3 -.L_MAGIC: - .xword _JB_MAGIC_AARCH64_SETJMP - -ENTRY(__setjmp14) - adrp x7, .L_MAGIC - ldr x7, [x7, #:lo12:.L_MAGIC] - - mov x3, sp - stp x7, x3, [x0, #_JB_MAGIC] - - stp x19, x20, [x0, #_JB_X19] - stp x21, x22, [x0, #_JB_X21] - stp x23, x24, [x0, #_JB_X23] - stp x25, x26, [x0, #_JB_X25] - stp x27, x28, [x0, #_JB_X27] - stp x29, x30, [x0, #_JB_X29] - - mrs x5, tpidr_el0 - str x5, [x0, #_JB_TPIDR] - - stp d8, d9, [x0, #_JB_D8] - stp d10, d11, [x0, #_JB_D10] - stp d12, d13, [x0, #_JB_D12] - stp d14, d15, [x0, #_JB_D14] - - /* Get the signal mask. */ - add x2, x0, #_JB_SIGMASK - mov x1, #0 - mov x0, #0 - - stp x29, x30, [sp, #-16]! - mov x29, sp - bl _C_LABEL(__sigprocmask14) - ldp x29, x30, [sp], #16 - - mov x0, xzr - ret -END(__setjmp14) - -ENTRY(__longjmp14) - adrp x7, .L_MAGIC - ldr x7, [x7, #:lo12:.L_MAGIC] - ldp x2, x3, [x0, #_JB_MAGIC] - cmp x2, x7 - b.ne .Lbotch - - ldp x4, x5, [x0, #_JB_X29] - cbz x3, .Lbotch - cbz x4, .Lbotch - cbz x5, .Lbotch - - ldp x19, x20, [x0, #_JB_X19] - ldp x21, x22, [x0, #_JB_X21] - ldp x23, x24, [x0, #_JB_X23] - ldp x25, x26, [x0, #_JB_X25] - ldp x27, x28, [x0, #_JB_X27] - - ldr x5, [x0, #_JB_TPIDR] - msr tpidr_el0, x5 - - ldp d8, d9, [x0, #_JB_D8] - ldp d10, d11, [x0, #_JB_D10] - ldp d12, d13, [x0, #_JB_D12] - ldp d14, d15, [x0, #_JB_D14] - - sub sp, x3, #32 - - stp x4, x5, [sp, #16] - str x1, [sp, #8] - add x29, sp, #16 - - mov x2, #0 - add x1, x0, #_JB_SIGMASK - mov x0, #3 /* SIG_SETMASK */ - bl _C_LABEL(__sigprocmask14) - - ldp x29, x30, [sp, #16] - ldr x0, [sp, #8] - add sp, sp, #32 - ret - - /* validation failed, die die die. */ -.Lbotch: - bl _C_LABEL(longjmperror) - bl _C_LABEL(abort) -1: b 1b /* Cannot get here */ -END(__longjmp14) diff --git a/lib/libc/arch/aarch64/gen/sigsetjmp.S b/lib/libc/arch/aarch64/gen/sigsetjmp.S deleted file mode 100644 index 16bbb21cd..000000000 --- a/lib/libc/arch/aarch64/gen/sigsetjmp.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "assym.h" - -#if (_JB_MAGIC_AARCH64__SETJMP ^ _JB_MAGIC_AARCH64_SETJMP) != 1 -#error _JB_MAGIC botch -#endif - -/* LINTSTUB: int __sigsetjmp14(sigjmp_buf *, int); */ - -ENTRY(__sigsetjmp14) - cbnz w1, _C_LABEL(__setjmp14) - b _C_LABEL(_setjmp) -END(__sigsetjmp14) - -/* LINTSTUB: int __sigsetlong14(sigjmp_buf *, int); */ - -ENTRY(__siglongjmp14) - ldr x3, [x0, #_JB_MAGIC] - tbz x3, #0, _C_LABEL(__longjmp14) - b _C_LABEL(_longjmp) -END(__siglongjmp14) diff --git a/lib/libc/arch/aarch64/gen/swapcontext.S b/lib/libc/arch/aarch64/gen/swapcontext.S deleted file mode 100644 index 7554afec0..000000000 --- a/lib/libc/arch/aarch64/gen/swapcontext.S +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.1 2014/08/10 05:47:36 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.1 2014/08/10 05:47:36 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -/* LINTSTUB: int swapcontext(ucontext_t * restrict, ucontext_t * restrict); */ - -ENTRY(swapcontext) - sub sp, sp, #32 /* allocate stack frame */ - stp x29, x30, [sp, #16] /* save FP & RA */ - add x29, sp, #16 /* new FP */ - stp x0, x1, [sp, #0] /* save oucp & ucp */ - - bl _C_LABEL(_getcontext) /* getcontext(oucp) */ - mov x3, x0 /* save return value */ - - ldp x2, x0, [sp, #0] /* restore oucp & ucp */ - ldp x29, x30, [sp, #16] /* restore FP & RA */ - add sp, sp, #32 /* free stack frame */ - - /* - * Assume _getcontext succeeded. - */ - mov x4, sp /* Get SP */ - str x4, [x2, #_UC_REGS_SP] /* Adjust saved SP. */ - str x30, [x2, #_UC_REGS_PC] /* Adjust saved LR. */ - - cbz x3, _C_LABEL(setcontext)/* setcontext if getcontext succeeded */ - mov x0, x3 /* restore getcontext return value */ - ret /* return on error from getcontext */ -END(swapcontext) diff --git a/lib/libc/arch/aarch64/genassym.cf b/lib/libc/arch/aarch64/genassym.cf deleted file mode 100644 index ffb5d0bb1..000000000 --- a/lib/libc/arch/aarch64/genassym.cf +++ /dev/null @@ -1,65 +0,0 @@ -# $NetBSD: genassym.cf,v 1.1 2014/08/10 05:47:36 matt Exp $ - -#- -# Copyright (c) 2014 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas of 3am Software Foundry. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include - -define _UC_REGS_X0 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_X0]) -define _UC_REGS_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_SP]) -define _UC_REGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC]) - -define _JB_MAGIC_AARCH64__SETJMP _JB_MAGIC_AARCH64__SETJMP -define _JB_MAGIC_AARCH64_SETJMP _JB_MAGIC_AARCH64_SETJMP -define _JB_MAGIC sizeof(_BSD_JBSLOT_T_ [_JB_MAGIC]) -define _JB_SP sizeof(_BSD_JBSLOT_T_ [_JB_SP]) -define _JB_X19 sizeof(_BSD_JBSLOT_T_ [_JB_X19]) -define _JB_X20 sizeof(_BSD_JBSLOT_T_ [_JB_X20]) -define _JB_X21 sizeof(_BSD_JBSLOT_T_ [_JB_X21]) -define _JB_X22 sizeof(_BSD_JBSLOT_T_ [_JB_X22]) -define _JB_X23 sizeof(_BSD_JBSLOT_T_ [_JB_X23]) -define _JB_X24 sizeof(_BSD_JBSLOT_T_ [_JB_X24]) -define _JB_X25 sizeof(_BSD_JBSLOT_T_ [_JB_X25]) -define _JB_X26 sizeof(_BSD_JBSLOT_T_ [_JB_X26]) -define _JB_X27 sizeof(_BSD_JBSLOT_T_ [_JB_X27]) -define _JB_X28 sizeof(_BSD_JBSLOT_T_ [_JB_X29]) -define _JB_X29 sizeof(_BSD_JBSLOT_T_ [_JB_X29]) -define _JB_X30 sizeof(_BSD_JBSLOT_T_ [_JB_X30]) -define _JB_TPIDR sizeof(_BSD_JBSLOT_T_ [_JB_TPIDR]) -define _JB_D8 sizeof(_BSD_JBSLOT_T_ [_JB_D8]) -define _JB_D9 sizeof(_BSD_JBSLOT_T_ [_JB_D9]) -define _JB_D10 sizeof(_BSD_JBSLOT_T_ [_JB_D10]) -define _JB_D11 sizeof(_BSD_JBSLOT_T_ [_JB_D11]) -define _JB_D12 sizeof(_BSD_JBSLOT_T_ [_JB_D12]) -define _JB_D13 sizeof(_BSD_JBSLOT_T_ [_JB_D13]) -define _JB_D14 sizeof(_BSD_JBSLOT_T_ [_JB_D14]) -define _JB_D15 sizeof(_BSD_JBSLOT_T_ [_JB_D15]) -define _JB_SIGMASK sizeof(_BSD_JBSLOT_T_ [_JB_SIGMASK]) diff --git a/lib/libc/arch/aarch64/net/Makefile.inc b/lib/libc/arch/aarch64/net/Makefile.inc deleted file mode 100644 index 3fcab6fb0..000000000 --- a/lib/libc/arch/aarch64/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:36 matt Exp $ - -# hton* and nto* functions provided by ../gen/byte_swap_*.S diff --git a/lib/libc/arch/aarch64/softfloat/aarch64-gcc.h b/lib/libc/arch/aarch64/softfloat/aarch64-gcc.h deleted file mode 100644 index fb543137c..000000000 --- a/lib/libc/arch/aarch64/softfloat/aarch64-gcc.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: aarch64-gcc.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#include -#if _BYTE_ORDER == _BIG_ENDIAN -#define BIGENDIAN -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef int uint8; -typedef int int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) diff --git a/lib/libc/arch/aarch64/softfloat/milieu.h b/lib/libc/arch/aarch64/softfloat/milieu.h deleted file mode 100644 index d615bc5a1..000000000 --- a/lib/libc/arch/aarch64/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "aarch64-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/aarch64/softfloat/qp.c b/lib/libc/arch/aarch64/softfloat/qp.c deleted file mode 100644 index 4e7fd4f49..000000000 --- a/lib/libc/arch/aarch64/softfloat/qp.c +++ /dev/null @@ -1,378 +0,0 @@ -/* $NetBSD: qp.c,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#include "milieu.h" -#include "softfloat.h" - -/* - * This file provides wrappers for the softfloat functions. We can't use - * invoke them directly since long double arguments are passed in FP/SIMD - * as well as being returned in them while float128 arguments are passed - * in normal registers. - */ - -long double __addtf3(long double, long double); -long double __divtf3(long double, long double); -long double __modtf3(long double, long double); -long double __multf3(long double, long double); -long double __negtf2(long double); -long double __subtf3(long double, long double); - -int __getf2(long double, long double); -int __lttf2(long double, long double); -int __gttf2(long double, long double); -int __letf2(long double, long double); -int __eqtf2(long double, long double); -int __netf2(long double, long double); -int __unordtf2(long double, long double); - -double __trunctfdf2(long double); -float __trunctfsf2(long double); - -long double __extendsftf2(float); -long double __extenddftf2(double); - -long double __floatsitf(int32_t); -long double __floatditf(int64_t); - -long double __floatunsitf(uint32_t); -long double __floatunditf(uint64_t); - -int32_t __fixtfsi(long double); -int64_t __fixtfdi(long double); - -uint32_t __fixuntfsi(long double); -uint64_t __fixuntfdi(long double); - -#if 0 -long double __floattitf(int128_t); -long double __floatuntitf(uint128_t); -int128_t __fixtfti(long double); -uint128_t __fixuntfti(long double); -#endif - -union sf_ieee_flt_u { - float fltu_f; - float32 fltu_f32; -}; - -union sf_ieee_dbl_u { - double dblu_d; - float64 dblu_f64; -}; - -union sf_ieee_ldbl_u { - long double ldblu_ld; - float128 ldblu_f128; -}; - -long double -__addtf3(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = float128_add(a.ldblu_f128, b.ldblu_f128) - }; - - return c.ldblu_ld; -} - -long double -__divtf3(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = float128_div(a.ldblu_f128, b.ldblu_f128) - }; - - return c.ldblu_ld; -} - -long double -__multf3(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = float128_mul(a.ldblu_f128, b.ldblu_f128) - }; - - return c.ldblu_ld; -} - -long double -__negtf2(long double ld_a) -{ - const union sf_ieee_ldbl_u zero = { .ldblu_ld = 0.0 }; - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { - .ldblu_f128 = float128_div(zero.ldblu_f128, a.ldblu_f128) - }; - - return b.ldblu_ld; -} - -long double -__subtf3(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = float128_sub(a.ldblu_f128, b.ldblu_f128) - }; - - return c.ldblu_ld; -} - -#if 0 -int -__cmptf3(float128 *a, float128 *b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - if (float128_eq(*a, *b)) - return 0; - - if (float128_le(*a, *b)) - return 1; - - return 2; -} - - -/* - * XXX - */ -int -_Qp_cmpe(float128 *a, float128 *b) -{ - return _Qp_cmp(a, b); -} -#endif - -int -__eqtf2(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - return float128_eq(a.ldblu_f128, b.ldblu_f128); -} - -int -__getf2(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - return float128_le(b.ldblu_f128, a.ldblu_f128); -} - -int -__gttf2(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - return float128_lt(b.ldblu_f128, a.ldblu_f128); -} - -int -__letf2(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - return float128_le(a.ldblu_f128, b.ldblu_f128); -} - -int -__lttf2(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - return float128_lt(a.ldblu_f128, b.ldblu_f128); -} - -int -__netf2(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - return !float128_eq(a.ldblu_f128, b.ldblu_f128); -} - -float -__trunctfsf2(long double ld_a) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_flt_u c = { - .fltu_f32 = float128_to_float32(a.ldblu_f128), - }; - - return c.fltu_f; -} - -double -__trunctfdf2(long double ld_a) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_dbl_u c = { - .dblu_f64 = float128_to_float64(a.ldblu_f128), - }; - - return c.dblu_d; -} - -int32_t -__fixtfsi(long double ld_a) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - return float128_to_int32_round_to_zero(a.ldblu_f128); -} - -int64_t -__fixtfdi(long double ld_a) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - - return float128_to_int64_round_to_zero(a.ldblu_f128); -} - -#if 0 -uint32_t -__fixuntfsi(long double ld_a) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - - return float128_to_uint32_round_to_zero(a.ldblu_f128); -} - -uint64_t -__fixuntfdi(long double ld_a) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - - return float128_to_uint64_round_to_zero(a.ldblu_f128); -} -#endif - -long double -__extendsftf2(float f_a) -{ - const union sf_ieee_flt_u a = { .fltu_f = f_a }; - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = float32_to_float128(a.fltu_f32) - }; - - return c.ldblu_ld; -} - -long double -__extenddftf2(double d_a) -{ - const union sf_ieee_dbl_u a = { .dblu_d = d_a }; - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = float64_to_float128(a.dblu_f64) - }; - - return c.ldblu_ld; -} - -long double -__floatunsitf(uint32_t a) -{ - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = int64_to_float128(a) - }; - - return c.ldblu_ld; -} - -long double -__floatunditf(uint64_t a) -{ - union sf_ieee_ldbl_u c; - const uint64_t msb64 = 1LL << 63; - - if (a & msb64) { - static const union sf_ieee_ldbl_u two63 = { - .ldblu_ld = 0x1.0p63 - }; - - c.ldblu_f128 = int64_to_float128(a ^ msb64); - c.ldblu_f128 = float128_add(c.ldblu_f128, two63.ldblu_f128); - } else { - c.ldblu_f128 = int64_to_float128(a); - } - return c.ldblu_ld; -} - -long double -__floatsitf(int32_t a) -{ - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = int64_to_float128(a) - }; - - return c.ldblu_ld; -} - -long double -__floatditf(int64_t a) -{ - const union sf_ieee_ldbl_u c = { - .ldblu_f128 = int64_to_float128(a) - }; - - return c.ldblu_ld; -} - -int -__unordtf2(long double ld_a, long double ld_b) -{ - const union sf_ieee_ldbl_u a = { .ldblu_ld = ld_a }; - const union sf_ieee_ldbl_u b = { .ldblu_ld = ld_b }; - - /* - * The comparison is unordered if either input is a NaN. - * Test for this by comparing each operand with itself. - * We must perform both comparisons to correctly check for - * signalling NaNs. - */ - return 1 ^ (float128_eq(a.ldblu_f128, a.ldblu_f128) & float128_eq(b.ldblu_f128, b.ldblu_f128)); -} diff --git a/lib/libc/arch/aarch64/softfloat/softfloat-qp.h b/lib/libc/arch/aarch64/softfloat/softfloat-qp.h deleted file mode 100644 index 9169889a1..000000000 --- a/lib/libc/arch/aarch64/softfloat/softfloat-qp.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Get everything SOFTFLOAT_FOR_GCC normally would rename out of the users - * namespace. Much of this isn't used but to avoid dissecting softloat.c - * all of it is pulled in even for just the _Qp* case - */ - -#if defined(SOFTFLOATAARCH64_FOR_GCC) && !defined(SOFTFLOAT_FOR_GCC) -#define float_exception_flags _softfloat_float_exception_flags -#define float_rounding_mode _softfloat_float_rounding_mode -#define float_raise _softfloat_float_raise - -#define float32_eq _softfloat_float32_eq -#define float32_le _softfloat_float32_le -#define float32_lt _softfloat_float32_lt -#define float64_eq _softfloat_float64_eq -#define float64_le _softfloat_float64_le -#define float64_lt _softfloat_float64_lt - -#define float32_add _softfloat_float32_add -#define float64_add _softfloat_float64_add -#define float32_sub _softfloat_float32_sub -#define float64_sub _softfloat_float64_sub -#define float32_mul _softfloat_float32_mul -#define float64_mul _softfloat_float64_mul -#define float32_div _softfloat_float32_div -#define float64_div _softfloat_float64_div -#define int32_to_float32 _softfloat_int32_to_float32 -#define int32_to_float64 _softfloat_int32_to_float64 -#define int64_to_float32 _softfloat_int64_to_float32 -#define int64_to_float64 _softfloat_int64_to_float64 -#define float32_to_int32_round_to_zero _softfloat_float32_to_int32_round_to_zero -#define float64_to_int32_round_to_zero _softfloat_float64_to_int32_round_to_zero -#define float32_to_int64_round_to_zero _softfloat_float32_to_int64_round_to_zero -#define float64_to_int64_round_to_zero _softfloat_float64_to_int64_round_to_zero -#define float32_to_uint32_round_to_zero _softfloat_float32_to_uint32_round_to_zero -#define float64_to_uint32_round_to_zero _softfloat_float64_to_uint32_round_to_zero -#define float32_to_float64 _softfloat_float32_to_float64 -#define float64_to_float32 _softfloat_float64_to_float32 -#define float32_is_signaling_nan _softfloat_float32_is_signaling_nan -#define float64_is_signaling_nan _softfloat_float64_is_signaling_nan - -#endif /* SOFTFLOATAARCH64_FOR_GCC and !SOFTFLOAT_FOR_GCC */ - -/* - * The following will always end up in the namespace if FLOAT128 is - * defined and SOFTFLOAT_FOR_GCC isn't. So rename them out of the user's - * namespace. - */ - -#ifdef SOFTFLOATAARCH64_FOR_GCC -#define float128_add _softfloat_float128_add -#define float128_div _softfloat_float128_div -#define float128_eq _softfloat_float128_eq -#define float128_eq_signaling _softfloat_float128_eq_signaling -#define float128_is_nan _softfloat_float128_is_nan -#define float128_is_signaling_nan _softfloat_float128_is_signaling_nan -#define float128_le _softfloat_float128_le -#define float128_le_quiet _softfloat_float128_le_quiet -#define float128_lt _softfloat_float128_lt -#define float128_lt_quiet _softfloat_float128_lt_quiet -#define float128_mul _softfloat_float128_mul -#define float128_rem _softfloat_float128_rem -#define float128_round_to_int _softfloat_float128_round_to_int -#define float128_sqrt _softfloat_float128_sqrt -#define float128_sub _softfloat_float128_sub -#define float128_to_float32 _softfloat_float128_to_float32 -#define float128_to_float64 _softfloat_float128_to_float64 -#define float128_to_int32 _softfloat_float128_to_int32 -#define float128_to_int32_round_to_zero _softfloat_float128_to_int32_round_to_zero -#define float128_to_int64 _softfloat_float128_to_int64 -#define float128_to_int64_round_to_zero _softfloat_float128_to_int64_round_to_zero -#define float128_to_uint64_round_to_zero _softfloat_float128_to_uint64_round_to_zero -#define float32_to_float128 _softfloat_float32_to_float128 -#define float64_to_float128 _softfloat_float64_to_float128 -#define int32_to_float128 _softfloat_int32_to_float128 -#define int64_to_float128 _softfloat_int64_to_float128 - -/* - * If this isn't defined go ahead and set it now since this is now past - * anywhere define's are happening and this will conditionally compile out - * a lot of extraneous code in softfloat.c - */ - -#ifndef SOFTFLOAT_FOR_GCC -#define SOFTFLOAT_FOR_GCC -#endif - -#endif /* SOFTFLOATAARCH64_FOR_GCC */ diff --git a/lib/libc/arch/aarch64/softfloat/softfloat-wrapper.c b/lib/libc/arch/aarch64/softfloat/softfloat-wrapper.c deleted file mode 100644 index ac5582aff..000000000 --- a/lib/libc/arch/aarch64/softfloat/softfloat-wrapper.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/arch/aarch64/softfloat/softfloat.h b/lib/libc/arch/aarch64/softfloat/softfloat.h deleted file mode 100644 index a317bd766..000000000 --- a/lib/libc/arch/aarch64/softfloat/softfloat.h +++ /dev/null @@ -1,305 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -#define FLOAT128 - -#include "softfloat-qp.h" - -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int8 float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -unsigned int float32_to_uint32_round_to_zero( float32 ); -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -flag float32_eq( float32, float32 ); -flag float32_le( float32, float32 ); -flag float32_lt( float32, float32 ); -flag float32_eq_signaling( float32, float32 ); -flag float32_le_quiet( float32, float32 ); -flag float32_lt_quiet( float32, float32 ); -flag float32_is_signaling_nan( float32 ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -unsigned int float64_to_uint32_round_to_zero( float64 ); -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -flag float64_eq( float64, float64 ); -flag float64_le( float64, float64 ); -flag float64_lt( float64, float64 ); -flag float64_eq_signaling( float64, float64 ); -flag float64_le_quiet( float64, float64 ); -flag float64_lt_quiet( float64, float64 ); -flag float64_is_signaling_nan( float64 ); - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -flag floatx80_eq( floatx80, floatx80 ); -flag floatx80_le( floatx80, floatx80 ); -flag floatx80_lt( floatx80, floatx80 ); -flag floatx80_eq_signaling( floatx80, floatx80 ); -flag floatx80_le_quiet( floatx80, floatx80 ); -flag floatx80_lt_quiet( floatx80, floatx80 ); -flag floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -unsigned long long float128_to_uint64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -flag float128_eq( float128, float128 ); -flag float128_le( float128, float128 ); -flag float128_lt( float128, float128 ); -flag float128_eq_signaling( float128, float128 ); -flag float128_le_quiet( float128, float128 ); -flag float128_lt_quiet( float128, float128 ); -flag float128_is_signaling_nan( float128 ); -flag float128_is_nan( float128 ); - -#endif diff --git a/lib/libc/arch/aarch64/stdlib/Makefile.inc b/lib/libc/arch/aarch64/stdlib/Makefile.inc deleted file mode 100644 index 4bcaf502f..000000000 --- a/lib/libc/arch/aarch64/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:37 matt Exp $ diff --git a/lib/libc/arch/aarch64/string/Makefile.inc b/lib/libc/arch/aarch64/string/Makefile.inc deleted file mode 100644 index 4bcaf502f..000000000 --- a/lib/libc/arch/aarch64/string/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:37 matt Exp $ diff --git a/lib/libc/arch/aarch64/sys/__clone.S b/lib/libc/arch/aarch64/sys/__clone.S deleted file mode 100644 index e852f2856..000000000 --- a/lib/libc/arch/aarch64/sys/__clone.S +++ /dev/null @@ -1,78 +0,0 @@ -/* $NetBSD: __clone.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include - -WEAK_ALIAS(clone, __clone) - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - - /* test stack and function are not null */ - cbz x0, .Leinval - cbz x1, .Leinval - - /* place the arg and func onto the child's stack */ - stp x3, x0, [x1, #-16]! - - /* syscall expects (flags, stack) */ - mov x0, x2 - - SYSTRAP(__clone) - _INVOKE_CERROR() - - /* - * x1 and x0 are the same as from fork: - * x1 == 0 in parent process, x1 == 1 in child process. - * x0 == pid of child in parent, x0 == pid of parent in child. - */ - /* if this is the parent then just return the pid */ - cbnz x1, 1f - - /* - * This is the child - * load the function and arg off the stack - */ - ldp x0, x1, [sp], #16 - - /* call the function */ - blr x1 - - /* call _exit with the returned value */ - bl _C_LABEL(_exit) -1: ret -.Leinval: - mov x0, #EINVAL - b _C_LABEL(__cerror) -END(__clone) diff --git a/lib/libc/arch/aarch64/sys/__sigaction14_sigtramp.c b/lib/libc/arch/aarch64/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 339dbd86e..000000000 --- a/lib/libc/arch/aarch64/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.1 2014/08/10 05:47:37 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specificed or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/aarch64/sys/__sigtramp2.S b/lib/libc/arch/aarch64/sys/__sigtramp2.S deleted file mode 100755 index 005884c67..000000000 --- a/lib/libc/arch/aarch64/sys/__sigtramp2.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The ARM signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, the stack looks like: - * - * ucontext structure - * sp-> siginfo structure - * and x28 points to the ucontext - */ -ENTRY_NP(__sigtramp_siginfo_2) - mov x0, x28 /* set the arg */ - SYSTRAP(setcontext) /* and call setcontext */ - - /* If that failed, exit with the error code. */ - SYSTRAP(exit) -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/aarch64/sys/__syscall.S b/lib/libc/arch/aarch64/sys/__syscall.S deleted file mode 100644 index 461b08690..000000000 --- a/lib/libc/arch/aarch64/sys/__syscall.S +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifndef FUNCNAME -#define FUNCNAME __syscall -#define SYSTRAP_SYSCALL SYSTRAP(__syscall) -#endif - -#if SYS_MAXSYSARGS > 8 -#error SYS_MAXSYSARGS is greater than 8 -#endif - -ENTRY(FUNCNAME) - /* - * AAPCS64 supplies the first 8 arguments in registers but since - * the first argument is the syscall #, we only have room for 7 - * arguments. Thus if the syscall uses all 8 arguments, the last - * argument will have been placed on the stack. Rather than - * complicating the kernel syscall code to deal with that, we fixup - * things here. - * - * First we move the syscall number to x17 freeing a register. - * Then we move the rest of the arguments to their proper register. - * Finally, load x7 from the stack. - * - * Now everything looks as if the syscall wrapper was directly called. - * (unless it was for pipe, fork, vfork, ptrace, or __clone). - */ - mov x17, x0 - mov x0, x1 - mov x1, x2 - mov x2, x3 - mov x3, x4 - mov x4, x5 - mov x5, x6 - mov x6, x7 - ldr x7, [sp, #0] - SYSTRAP_SYSCALL - _INVOKE_CERROR() - ret -END(FUNCNAME) diff --git a/lib/libc/arch/aarch64/sys/__vfork14.S b/lib/libc/arch/aarch64/sys/__vfork14.S deleted file mode 100644 index 77a8ef2b5..000000000 --- a/lib/libc/arch/aarch64/sys/__vfork14.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * pid = vfork(); - * - * On return from the SWI: - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - */ -ENTRY(__vfork14) - mov x8, x30 - SYSTRAP(__vfork14) - _INVOKE_CERROR() - sub w1, w1, #1 /* r1 == 0xffffffff if parent, 0 if child */ - and w0, w0, w1 /* r0 == 0 if child, else unchanged */ - ret x8 -END(__vfork14) diff --git a/lib/libc/arch/aarch64/sys/brk.S b/lib/libc/arch/aarch64/sys/brk.S deleted file mode 100644 index 518a586eb..000000000 --- a/lib/libc/arch/aarch64/sys/brk.S +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: brk.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - - .globl _C_LABEL(_end) - .globl _C_LABEL(__curbrk) - -WEAK_ALIAS(brk, _brk) - - .data - .globl _C_LABEL(__minbrk) - .hidden _C_LABEL(__minbrk) - .type _C_LABEL(__minbrk),#object - .align 3 -_C_LABEL(__minbrk): - .xword _C_LABEL(_end) - .size _C_LABEL(__minbrk), 8 - -/* - * Change the data segment size - */ -ENTRY(_brk) - adr x9, _C_LABEL(__minbrk) - ldr x10, [x9, #:lo12:_C_LABEL(__minbrk)] - - /* - * Valid the address specified and set to the minimum - * if the address is below minbrk. - */ - cmp x0, x10 - csel x0, x10, x0, lt - mov x11, x0 - SYSTRAP(break) - _INVOKE_CERROR() - - /* Store the new address in curbrk */ - adr x9, _C_LABEL(__curbrk) - str x11, [x9, #:lo12:_C_LABEL(__curbrk)] - - /* Return 0 for success */ - mov x0, xzr - ret -END(_brk) diff --git a/lib/libc/arch/aarch64/sys/cerror.S b/lib/libc/arch/aarch64/sys/cerror.S deleted file mode 100644 index 5d30791de..000000000 --- a/lib/libc/arch/aarch64/sys/cerror.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: cerror.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -ENTRY_NP(__cerror) - .cfi_startproc - stp x19, x30, [sp, #-16]! - .cfi_def_cfa sp, 16 - .cfi_offset x19, 0 - .cfi_offset x30, -8 - mov w19, w0 - bl _C_LABEL(__errno) - str w19, [x0] - ldp x19, x30, [sp], #16 - mvn w0,wzr - ret - .cfi_endproc -END(__cerror) diff --git a/lib/libc/arch/aarch64/sys/exect.S b/lib/libc/arch/aarch64/sys/exect.S deleted file mode 100644 index 54b12569e..000000000 --- a/lib/libc/arch/aarch64/sys/exect.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: exect.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)exect.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -PSEUDO(exect,execve) diff --git a/lib/libc/arch/aarch64/sys/fork.S b/lib/libc/arch/aarch64/sys/fork.S deleted file mode 100644 index be9830e61..000000000 --- a/lib/libc/arch/aarch64/sys/fork.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: fork.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * pid = fork(); - * - * On return from the SWI: - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - */ - -_SYSCALL(__fork,fork) - sub w1, w1, #1 /* r1 == 0xffffffff if parent, 0 if child */ - and w0, w0, w1 /* r0 == 0 if child, else unchanged */ - ret -END(__fork) diff --git a/lib/libc/arch/aarch64/sys/getcontext.S b/lib/libc/arch/aarch64/sys/getcontext.S deleted file mode 100644 index d6aac82df..000000000 --- a/lib/libc/arch/aarch64/sys/getcontext.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.1 2014/08/10 05:47:37 matt Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -WEAK_ALIAS(getcontext, _getcontext) - -ENTRY(_getcontext) - mov x9, x0 /* Must save argument pointer. */ - SYSTRAP (getcontext) - _INVOKE_CERROR() - str x30, [x9, #_UC_REGS_PC] /* Adjust PC. */ -#ifdef SOFTFLOAT - /* Ahem. */ - /* Judging from the softfloat code we should at least save - the exception codes and rounding mode here. */ -#endif - mov x0, xzr - str x0, [x9, #_UC_REGS_X0] /* Return 0. */ - ret -END(_getcontext) diff --git a/lib/libc/arch/aarch64/sys/pipe.S b/lib/libc/arch/aarch64/sys/pipe.S deleted file mode 100644 index 878130a4e..000000000 --- a/lib/libc/arch/aarch64/sys/pipe.S +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD: pipe.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WEAK_ALIAS(pipe, _pipe) - -ENTRY(_pipe) - mov x9, x0 - SYSTRAP(pipe) - _INVOKE_CERROR() - stp w0, w1, [x9] - mov w0, wzr - RET -END(_pipe) diff --git a/lib/libc/arch/aarch64/sys/ptrace.S b/lib/libc/arch/aarch64/sys/ptrace.S deleted file mode 100644 index 6b86db3cc..000000000 --- a/lib/libc/arch/aarch64/sys/ptrace.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -ENTRY(ptrace) - sub sp, sp, #48 - stp x29, x30, [sp, #32]! - add x29, sp, #32 - stp x0, x1, [sp, #0] - stp x2, x3, [sp, #16] - - bl _C_LABEL(__errno) - str wzr, [x0] - - ldp x2, x3, [sp, #16] - ldp x0, x1, [sp, #0] - - ldp x29, x30, [sp, #32] - add sp, sp, #48 - - SYSTRAP(ptrace) - _INVOKE_CERROR() - ret -END(ptrace) diff --git a/lib/libc/arch/aarch64/sys/sbrk.S b/lib/libc/arch/aarch64/sys/sbrk.S deleted file mode 100644 index 90f1d4e77..000000000 --- a/lib/libc/arch/aarch64/sys/sbrk.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - - .globl _C_LABEL(_end) - -WEAK_ALIAS(sbrk, _sbrk) - - .data - .align 3 - .globl _C_LABEL(__curbrk) - .hidden _C_LABEL(__curbrk) - .type _C_LABEL(__curbrk),#object -_C_LABEL(__curbrk): - .xword _C_LABEL(_end) - .size _C_LABEL(_end), 8 - -/* - * Change the data segment size - */ -ENTRY(_sbrk) - /* get address or offset to __curbrk */ - adrp x9, _C_LABEL(__curbrk) - - /* Get the current brk address */ - ldr x1, [x9, #:lo12:_C_LABEL(__curbrk)] - - /* Calculate new value */ - mov x10, x0 - add x0, x0, x1 - SYSTRAP(break) - _INVOKE_CERROR() - - /* Store new curbrk value */ - ldr x0, [x9, #:lo12:_C_LABEL(__curbrk)] - add x1, x0, x10 - str x1, [x9, #:lo12:_C_LABEL(__curbrk)] - - /* Return old curbrk value */ - ret -END(_sbrk) diff --git a/lib/libc/arch/aarch64/sys/shmat.S b/lib/libc/arch/aarch64/sys/shmat.S deleted file mode 100644 index cb8a99b91..000000000 --- a/lib/libc/arch/aarch64/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/aarch64/sys/syscall.S b/lib/libc/arch/aarch64/sys/syscall.S deleted file mode 100644 index 25f25c7e3..000000000 --- a/lib/libc/arch/aarch64/sys/syscall.S +++ /dev/null @@ -1,6 +0,0 @@ -/* $NetBSD: syscall.S,v 1.1 2014/08/10 05:47:37 matt Exp $ */ - -#define FUNCNAME syscall -#define SYSTRAP_SYSCALL SYSTRAP(syscall) - -#include "__syscall.S" diff --git a/lib/libc/arch/alpha/Makefile.inc b/lib/libc/arch/alpha/Makefile.inc deleted file mode 100644 index a89768201..000000000 --- a/lib/libc/arch/alpha/Makefile.inc +++ /dev/null @@ -1,44 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.20 2008/10/26 07:43:07 mrg Exp $ - -SRCS+= __longjmp14.c -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S - -# `source' files built from m4 source -SRCS+= __divqu.S __divq.S __divlu.S __divl.S -SRCS+= __remqu.S __remq.S __remlu.S __reml.S -CLEANFILES+= __divqu.S __divq.S __divlu.S __divl.S -CLEANFILES+= __remqu.S __remq.S __remlu.S __reml.S - -__divqu.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__divqu -DOP=div -DS=false -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__divq.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__divq -DOP=div -DS=true -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__divlu.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__divlu -DOP=div -DS=false -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} - -__divl.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__divl -DOP=div -DS=true -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} - -__remqu.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__remqu -DOP=rem -DS=false -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__remq.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__remq -DOP=rem -DS=true -DWORDSIZE=64 \ - ${.ALLSRC} > ${.TARGET} - -__remlu.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__remlu -DOP=rem -DS=false -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} - -__reml.S: ${LIBCDIR}/arch/alpha/gen/divrem.m4 - ${TOOL_M4} -DNAME=__reml -DOP=rem -DS=true -DWORDSIZE=32 \ - ${.ALLSRC} > ${.TARGET} - -CPPFLAGS+= -I. diff --git a/lib/libc/arch/alpha/SYS.h b/lib/libc/arch/alpha/SYS.h deleted file mode 100644 index 2cd48391a..000000000 --- a/lib/libc/arch/alpha/SYS.h +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: SYS.h,v 1.8 2002/01/14 00:55:55 thorpej 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 -#include - - -#define CALLSYS_ERROR(name) \ - CALLSYS_NOERROR(name); \ - br gp, LLABEL(name,0); \ -LLABEL(name,0): \ - LDGP(gp); \ - beq a3, LLABEL(name,1); \ - jmp zero, __cerror; \ -LLABEL(name,1): - - -#define SYSCALL(name) \ -LEAF(name,0); /* XXX # of args? */ \ - CALLSYS_ERROR(name) - -#define SYSCALL_NOERROR(name) \ -LEAF(name,0); /* XXX # of args? */ \ - CALLSYS_NOERROR(name) - -#define PSEUDO(label,name) \ -LEAF(label,0); /* XXX # of args? */ \ - CALLSYS_ERROR(name); \ - RET; \ -END(label); - -#define PSEUDO_NOERROR(label,name) \ -LEAF(label,0); /* XXX # of args? */ \ - CALLSYS_NOERROR(name); \ - RET; \ -END(label); - -#define RSYSCALL(name) \ - SYSCALL(name); \ - RET; \ -END(name) - -#define RSYSCALL_NOERROR(name) \ - SYSCALL_NOERROR(name); \ - RET; \ -END(name) - -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) diff --git a/lib/libc/arch/alpha/gdtoa/Makefile.inc b/lib/libc/arch/alpha/gdtoa/Makefile.inc deleted file mode 100644 index 1d786e010..000000000 --- a/lib/libc/arch/alpha/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/alpha/gdtoa/arith.h b/lib/libc/arch/alpha/gdtoa/arith.h deleted file mode 100644 index 650a936eb..000000000 --- a/lib/libc/arch/alpha/gdtoa/arith.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_LITTLE_ENDIAN -#ifndef _IEEE_FP -#define Sudden_Underflow -#endif diff --git a/lib/libc/arch/alpha/gdtoa/gd_qnan.h b/lib/libc/arch/alpha/gdtoa/gd_qnan.h deleted file mode 100644 index 36cb4afa4..000000000 --- a/lib/libc/arch/alpha/gdtoa/gd_qnan.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff80000 diff --git a/lib/libc/arch/alpha/gen/Makefile.inc b/lib/libc/arch/alpha/gen/Makefile.inc deleted file mode 100644 index c3f59d946..000000000 --- a/lib/libc/arch/alpha/gen/Makefile.inc +++ /dev/null @@ -1,28 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.22 2009/12/06 07:12:17 uebayasi Exp $ - -SRCS+= fabs.S - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c - -SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c -SRCS+= __setjmp14.S -SRCS+= __sigsetjmp14.S -SRCS+= byte_swap_2.S byte_swap_4.S bswap64.c -SRCS+= _resumecontext.S - -LSRCS.alpha.gen= Lint_bswap16.c Lint_bswap32.c Lint_swapcontext.c -LSRCS+= ${LSRCS.alpha.gen} -DPSRCS+= ${LSRCS.alpha.gen} -CLEANFILES+= ${LSRCS.alpha.gen} - -SRCS+= makecontext.c resumecontext.c swapcontext.S _lwp.c - diff --git a/lib/libc/arch/alpha/gen/__longjmp14.c b/lib/libc/arch/alpha/gen/__longjmp14.c deleted file mode 100644 index b641a0769..000000000 --- a/lib/libc/arch/alpha/gen/__longjmp14.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: __longjmp14.c,v 1.7 2013/03/13 08:05:46 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christian Limpach and Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include - -void -__longjmp14(jmp_buf env, int val) -{ - struct sigcontext *sc = (void *)env; - ucontext_t uc; - - /* Ensure non-zero SP */ - if (sc->sc_sp == 0 || sc->sc_regs[R_ZERO] != 0xacedbade) - goto err; - - /* Ensure non-zero return value */ - if (val == 0) - val = -1; - - /* Set _UC_SIGMASK and _UC_CPU */ - uc.uc_flags = _UC_SIGMASK | _UC_CPU; - - /* Clear uc_link */ - uc.uc_link = 0; - - /* Save return value in context */ - uc.uc_mcontext.__gregs[_REG_V0] = val; - - /* Copy saved registers */ - uc.uc_mcontext.__gregs[_REG_S0] = sc->sc_regs[R_S0]; - uc.uc_mcontext.__gregs[_REG_S1] = sc->sc_regs[R_S1]; - uc.uc_mcontext.__gregs[_REG_S2] = sc->sc_regs[R_S2]; - uc.uc_mcontext.__gregs[_REG_S3] = sc->sc_regs[R_S3]; - uc.uc_mcontext.__gregs[_REG_S4] = sc->sc_regs[R_S4]; - uc.uc_mcontext.__gregs[_REG_S5] = sc->sc_regs[R_S5]; - uc.uc_mcontext.__gregs[_REG_S6] = sc->sc_regs[R_S6]; - uc.uc_mcontext.__gregs[_REG_RA] = sc->sc_regs[R_RA]; - uc.uc_mcontext.__gregs[_REG_GP] = sc->sc_regs[R_GP]; - uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_sp; - uc.uc_mcontext.__gregs[_REG_PC] = sc->sc_pc; - uc.uc_mcontext.__gregs[_REG_PS] = - (sc->sc_ps | ALPHA_PSL_USERSET) & ~ALPHA_PSL_USERCLR; - - /* Copy FP state */ - if (sc->sc_ownedfp) { - memcpy(&uc.uc_mcontext.__fpregs.__fp_fr, - &sc->sc_fpregs, 31 * sizeof(unsigned long)); - uc.uc_mcontext.__fpregs.__fp_fpcr = sc->sc_fpcr; - /* XXX sc_fp_control */ - uc.uc_flags |= _UC_FPU; - } - - /* Copy signal mask */ - uc.uc_sigmask = sc->sc_mask; - - setcontext(&uc); - err: - longjmperror(); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/alpha/gen/__setjmp14.S b/lib/libc/arch/alpha/gen/__setjmp14.S deleted file mode 100644 index f9f193421..000000000 --- a/lib/libc/arch/alpha/gen/__setjmp14.S +++ /dev/null @@ -1,123 +0,0 @@ -/* $NetBSD: __setjmp14.S,v 1.7 2014/01/23 03:08:50 christos 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 -#include "assym.h" - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and the previous signal state. - */ - - .set noreorder - -LEAF(__setjmp14, 1) - LDGP(pv) - stq ra, SC_PC(a0) /* sc_pc = return address */ - stq s0, (SC_REGS+_REG_S0)(a0) /* saved bits of sc_regs */ - stq s1, (SC_REGS+_REG_S1)(a0) - stq s2, (SC_REGS+_REG_S2)(a0) - stq s3, (SC_REGS+_REG_S3)(a0) - stq s4, (SC_REGS+_REG_S4)(a0) - stq s5, (SC_REGS+_REG_S5)(a0) - stq s6, (SC_REGS+_REG_S6)(a0) - stq ra, (SC_REGS+_REG_RA)(a0) - stq sp, (SC_REGS+_REG_SP)(a0) - stq gp, (SC_REGS+_REG_GP)(a0) - - /* - * get signal information - */ - mov a0, s0 /* squirrel away ptr to sc */ - - /* see what's blocked */ - mov zero, a0 /* how (insignificant) */ - mov zero, a1 /* set (NULL) */ - lda a2, SC_MASK(s0) /* point to mask in sc */ - CALL(__sigprocmask14) - - lda sp, -24(sp) /* sizeof struct sigaltstack */ - mov zero, a0 - mov sp, a1 - CALL(__sigaltstack14) - ldl t0, 16(sp) /* offset of ss_flags */ - lda sp, 24(sp) /* sizeof struct sigaltstack */ - ldq ra, (SC_REGS+_REG_RA)(s0) /* restore return address */ - blt v0, botch /* check for error */ - and t0, 0x1, t0 /* get SA_ONSTACK flag */ - stq t0, SC_ONSTACK(s0) /* and save it in sc_onstack */ - /* - * Restore old s0 and a0, and continue saving registers - */ - mov s0, a0 - ldq s0, (SC_REGS+_REG_S0)(a0) - - ldq t0, magic /* sigcontext magic number */ - stq t0, (SC_REGS+_REG_UNIQUE)(a0) /* magic in sc_regs[31] */ - /* Too bad we can't check if we actually used FP */ - ldiq t0, 1 - stq t0, SC_OWNEDFP(a0) /* say we've used FP. */ - stt fs0, (2*8 + SC_FPREGS)(a0) /* saved bits of sc_fpregs */ - stt fs1, (3*8 + SC_FPREGS)(a0) - stt fs2, (4*8 + SC_FPREGS)(a0) - stt fs3, (5*8 + SC_FPREGS)(a0) - stt fs4, (6*8 + SC_FPREGS)(a0) - stt fs5, (7*8 + SC_FPREGS)(a0) - stt fs6, (8*8 + SC_FPREGS)(a0) - stt fs7, (9*8 + SC_FPREGS)(a0) - excb /* required 4.7.8.1 Alpha ARM */ - mf_fpcr ft0 /* get FP control reg */ - excb /* required 4.7.8.1 Alpha ARM */ - stt ft0, SC_FPCR(a0) /* and store it in sc_fpcr */ - stq zero, SC_FP_CONTROL(a0) /* FP software control XXX */ - stq zero, (SC_RESERVED + 0*8)(a0) /* sc_reserved[0] */ - stq zero, (SC_RESERVED + 1*8)(a0) /* sc_reserved[1] */ - stq zero, (SC_XXX + 0*8)(a0) /* sc_xxx[0] */ - stq zero, (SC_XXX + 1*8)(a0) /* sc_xxx[1] */ - stq zero, (SC_XXX + 2*8)(a0) /* sc_xxx[2] */ - stq zero, (SC_XXX + 3*8)(a0) /* sc_xxx[3] */ - stq zero, (SC_XXX + 4*8)(a0) /* sc_xxx[4] */ - stq zero, (SC_XXX + 5*8)(a0) /* sc_xxx[5] */ - stq zero, (SC_XXX + 6*8)(a0) /* sc_xxx[6] */ - stq zero, (SC_XXX + 7*8)(a0) /* sc_xxx[7] */ - - mov zero, v0 /* return zero */ - RET -botch: - CALL(abort) - RET /* "can't" get here... */ -magic: - .quad 0xacedbade /* sigcontext magic number */ -END(__setjmp14) diff --git a/lib/libc/arch/alpha/gen/__sigsetjmp14.S b/lib/libc/arch/alpha/gen/__sigsetjmp14.S deleted file mode 100644 index 4460f7e99..000000000 --- a/lib/libc/arch/alpha/gen/__sigsetjmp14.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.2 2000/06/14 06:49:01 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 - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, mask) - * by restoring registers from the stack. - * If `mask' is non-zero, the previous signal - * state will be restored. - */ - - .set noreorder - -LEAF(__sigsetjmp14, 2) - LDGP(pv) - stq a1, (83 * 8)(a0) /* save the mask */ - bne a1, Lsavesig /* if !zero, save signals */ - jmp zero, _setjmp /* else don't. */ -Lsavesig: - jmp zero, __setjmp14 -END(__sigsetjmp14) - -LEAF(__siglongjmp14, 2) - LDGP(pv) - ldq t0, (83 * 8)(a0) /* get the mask */ - bne t0, Lrestoresig /* if !zero, restore signals */ - jmp zero, _longjmp -Lrestoresig: - jmp zero, __longjmp14 -END(__siglongjmp14) diff --git a/lib/libc/arch/alpha/gen/_lwp.c b/lib/libc/arch/alpha/gen/_lwp.c deleted file mode 100644 index c2a7ce412..000000000 --- a/lib/libc/arch/alpha/gen/_lwp.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.7 2012/09/12 14:13:43 manu Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nathan J. Williams. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.7 2012/09/12 14:13:43 manu Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - __greg_t *gr; - - getcontext(u); - gr = u->uc_mcontext.__gregs; - - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - gr[_REG_PC] = (unsigned long)start; - gr[_REG_T12] = (unsigned long) start; - gr[_REG_RA] = (unsigned long) _lwp_exit; - gr[_REG_A0] = (unsigned long) arg; - gr[_REG_SP] = ((unsigned long) (stack_base + stack_size)) & ~0x7; - gr[_REG_S6] = 0; - gr[_REG_UNIQUE] = (unsigned long)private; - - u->uc_flags |= _UC_TLSBASE; -} diff --git a/lib/libc/arch/alpha/gen/_resumecontext.S b/lib/libc/arch/alpha/gen/_resumecontext.S deleted file mode 100644 index 8babf1596..000000000 --- a/lib/libc/arch/alpha/gen/_resumecontext.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: _resumecontext.S,v 1.3 2008/04/22 04:47:44 dogcow Exp $ */ - -/* - * Copyright (c) 2004 - * Matthias Drochner. 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 - -LEAF_NOPROFILE(__resumecontext, 0) - LDGP(ra) - CALL(_resumecontext) -END(__resumecontext) - diff --git a/lib/libc/arch/alpha/gen/divrem.m4 b/lib/libc/arch/alpha/gen/divrem.m4 deleted file mode 100644 index d8a1d2bd0..000000000 --- a/lib/libc/arch/alpha/gen/divrem.m4 +++ /dev/null @@ -1,197 +0,0 @@ -/* $NetBSD: divrem.m4,v 1.9 2002/01/21 23:40:41 ross 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. - */ - -/* - * Division and remainder. - * - * The use of m4 is modeled after the sparc code, but the algorithm is - * simple binary long division. - * - * Note that the loops could probably benefit from unrolling. - */ - -/* - * M4 Parameters - * NAME name of function to generate - * OP OP=div: t10 / t11 -> t12; OP=rem: t10 % t11 -> t12 - * S S=true: signed; S=false: unsigned - * WORDSIZE total number of bits - */ - -define(A, `t10') -define(B, `t11') -define(RESULT, `t12') - -define(BIT, `t0') -define(I, `t1') -define(CC, `t2') -define(T_0, `t3') -ifelse(S, `true', `define(NEG, `t4')') - -#include - -LEAF(NAME, 0) /* XXX */ - lda sp, -64(sp) - stq BIT, 0(sp) - stq I, 8(sp) - stq CC, 16(sp) - stq T_0, 24(sp) -ifelse(S, `true', -` stq NEG, 32(sp)') - stq A, 40(sp) - stq B, 48(sp) - mov zero, RESULT /* Initialize result to zero */ - -ifelse(S, `true', -` - /* Compute sign of result. If either is negative, this is easy. */ - or A, B, NEG /* not the sign, but... */ - srl NEG, WORDSIZE - 1, NEG /* rather, or of high bits */ - blbc NEG, Ldoit /* neither negative? do it! */ - -ifelse(OP, `div', -` xor A, B, NEG /* THIS is the sign! */ -', ` mov A, NEG /* sign follows A. */ -') - srl NEG, WORDSIZE - 1, NEG /* make negation the low bit. */ - - srl A, WORDSIZE - 1, I /* is A negative? */ - blbc I, LnegB /* no. */ - /* A is negative; flip it. */ -ifelse(WORDSIZE, `32', ` - /* top 32 bits may be random junk */ - zap A, 0xf0, A -') - subq zero, A, A - srl B, WORDSIZE - 1, I /* is B negative? */ - blbc I, Ldoit /* no. */ -LnegB: - /* B is definitely negative, no matter how we got here. */ -ifelse(WORDSIZE, `32', ` - /* top 32 bits may be random junk */ - zap B, 0xf0, B -') - subq zero, B, B -Ldoit: -') -ifelse(WORDSIZE, `32', ` - /* - * Clear the top 32 bits of each operand, as they may - * sign extension (if negated above), or random junk. - */ - zap A, 0xf0, A - zap B, 0xf0, B -') - - /* kill the special cases. */ - beq B, Ldotrap /* division by zero! */ - - cmpult A, B, CC /* A < B? */ - /* RESULT is already zero, from above. A is untouched. */ - bne CC, Lret_result - - cmpeq A, B, CC /* A == B? */ - cmovne CC, 1, RESULT - cmovne CC, zero, A - bne CC, Lret_result - - /* - * Find out how many bits of zeros are at the beginning of the divisor. - */ -LBbits: - ldiq T_0, 1 /* I = 0; BIT = 1< - -LEAF(fabs, 1) - cpys fzero, fa0, fv0 - RET -END(fabs) diff --git a/lib/libc/arch/alpha/gen/flt_rounds.c b/lib/libc/arch/alpha/gen/flt_rounds.c deleted file mode 100644 index 84887d11a..000000000 --- a/lib/libc/arch/alpha/gen/flt_rounds.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.10 2014/08/03 19:14:24 wiz Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.10 2014/08/03 19:14:24 wiz Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * These come from definition - */ -#define FLT_ROUND_MAP \ - ( (0 << (FP_RZ*2)) /* round to zero */ \ - | (1 << (FP_RN*2)) /* round to nearest */ \ - | (3 << (FP_RM*2)) /* round to negative infinity */ \ - | (2 << (FP_RP*2))) /* round to positive infinity */ - -int -__flt_rounds(void) -{ - union { - double d; - uint64_t u64; - } fpcrval; - uint64_t old; - - __asm("excb; mf_fpcr %0; excb" : "=f" (fpcrval.d)); - old = (fpcrval.u64 >> 58) & 3; - - return (FLT_ROUND_MAP >> (old << 1)) & 3; -} diff --git a/lib/libc/arch/alpha/gen/fpgetmask.c b/lib/libc/arch/alpha/gen/fpgetmask.c deleted file mode 100644 index b0fd56bd3..000000000 --- a/lib/libc/arch/alpha/gen/fpgetmask.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.5 2005/06/12 05:21:25 lukem Exp $ */ - -/* - * Copyright (c) 1999 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ross Harvey - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.5 2005/06/12 05:21:25 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -fp_except -fpgetmask __P((void)) -{ - return sysarch(ALPHA_FPGETMASK, 0L); -} diff --git a/lib/libc/arch/alpha/gen/fpgetround.c b/lib/libc/arch/alpha/gen/fpgetround.c deleted file mode 100644 index 263b195f7..000000000 --- a/lib/libc/arch/alpha/gen/fpgetround.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.11 2012/03/21 20:07:52 he Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.11 2012/03/21 20:07:52 he Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -fp_rnd -fpgetround(void) -{ - union { - double d; - uint64_t u64; - } fpcrval; - - __asm("excb; mf_fpcr %0; excb" : "=f" (fpcrval.d)); - - return ((fp_rnd)(fpcrval.u64 >> 58) & 0x3); -} diff --git a/lib/libc/arch/alpha/gen/fpgetsticky.c b/lib/libc/arch/alpha/gen/fpgetsticky.c deleted file mode 100644 index 55d7e660a..000000000 --- a/lib/libc/arch/alpha/gen/fpgetsticky.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.9 2008/05/10 15:31:04 martin Exp $ */ - -/*- - * Copyright (c) 2001 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.9 2008/05/10 15:31:04 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -fp_except -fpgetsticky(void) -{ - return sysarch(ALPHA_FPGETSTICKY, 0L); -} diff --git a/lib/libc/arch/alpha/gen/fpsetmask.c b/lib/libc/arch/alpha/gen/fpsetmask.c deleted file mode 100644 index 8ceec5fe4..000000000 --- a/lib/libc/arch/alpha/gen/fpsetmask.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.5 2013/11/02 23:54:04 christos Exp $ */ - -/* - * Copyright (c) 1995 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ross Harvey - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.5 2013/11/02 23:54:04 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -fp_except -fpsetmask(fp_except mask) -{ - struct alpha_fp_except_args a; - - a.mask = mask; - return sysarch(ALPHA_FPSETMASK, &a); -} diff --git a/lib/libc/arch/alpha/gen/fpsetround.c b/lib/libc/arch/alpha/gen/fpsetround.c deleted file mode 100644 index ec9b11e98..000000000 --- a/lib/libc/arch/alpha/gen/fpsetround.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.12 2012/03/21 20:07:52 he Exp $ */ - -/* - * Copyright (c) 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.12 2012/03/21 20:07:52 he Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - union { - double d; - uint64_t u64; - } fpcrval; - fp_rnd old; - - __asm("excb; mf_fpcr %0; excb" : "=f" (fpcrval.d)); - old = (fp_rnd)(fpcrval.u64 >> 58) & 0x3; - - rnd_dir ^= old; - - fpcrval.u64 ^= (long)rnd_dir << 58; - - __asm("excb; mt_fpcr %0; excb" : : "f" (fpcrval.d)); - - return old; -} diff --git a/lib/libc/arch/alpha/gen/fpsetsticky.c b/lib/libc/arch/alpha/gen/fpsetsticky.c deleted file mode 100644 index 8f3b82bdb..000000000 --- a/lib/libc/arch/alpha/gen/fpsetsticky.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.5 2013/11/02 23:54:04 christos Exp $ */ - -/* - * Copyright (c) 1999 Ross Harvey - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Ross Harvey - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.5 2013/11/02 23:54:04 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -fpsetsticky(fp_except sticky) -{ - struct alpha_fp_except_args a; - - a.mask = sticky; - return sysarch(ALPHA_FPSETSTICKY, &a); -} diff --git a/lib/libc/arch/alpha/gen/makecontext.c b/lib/libc/arch/alpha/gen/makecontext.c deleted file mode 100644 index aeabddf26..000000000 --- a/lib/libc/arch/alpha/gen/makecontext.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.6 2011/09/20 08:42:29 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.6 2011/09/20 08:42:29 joerg Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void __resumecontext(void) __dead; - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - int i; - unsigned long *sp; - va_list ap; - - /* Compute and align stack pointer. */ - sp = (unsigned long *) - (((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~0x7); - /* Allocate necessary stack space for arguments exceeding a0-5. */ - if (argc > 6) - sp -= (argc - 6); - gr[_REG_SP] = (__greg_t)sp; - /* Arrange for return via the trampoline code. */ - gr[_REG_RA] = (__greg_t)__resumecontext; - gr[_REG_PC] = (__greg_t)func; - gr[_REG_PV] = (__greg_t)func; - - va_start(ap, argc); - /* Pass up to six arguments in a0-5. */ - for (i = 0; i < argc && i < 6; i++) - gr[_REG_A0 + i] = va_arg(ap, unsigned long); - /* Pass any additional arguments on the stack. */ - for (argc -= i; argc > 0; argc--) - *sp++ = va_arg(ap, unsigned long); - va_end(ap); -} diff --git a/lib/libc/arch/alpha/gen/nanf.c b/lib/libc/arch/alpha/gen/nanf.c deleted file mode 100644 index 7a5b3a2f0..000000000 --- a/lib/libc/arch/alpha/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.5 2009/02/22 01:34:01 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.5 2009/02/22 01:34:01 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0, 0, 0xc0, 0x7f } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/alpha/gen/resumecontext.c b/lib/libc/arch/alpha/gen/resumecontext.c deleted file mode 100644 index d5b745c99..000000000 --- a/lib/libc/arch/alpha/gen/resumecontext.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (!uct.uc_link) { - exit(0); - /* NOTREACHED */ - } - - (void)setcontext(uct.uc_link); - /* NOTREACHED */ - - /* something is wrong, pull the brake */ - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/alpha/gen/swapcontext.S b/lib/libc/arch/alpha/gen/swapcontext.S deleted file mode 100644 index 2a91164c1..000000000 --- a/lib/libc/arch/alpha/gen/swapcontext.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.3 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -NESTED(swapcontext, 2, 24, ra, IM_RA|IM_A0|IM_A1, 0) - LDGP(pv) - lda sp, -24(sp) - stq ra, (24- 8)(sp) /* must save ra, oucp, ucp */ - stq a0, (24-16)(sp) - stq a1, (24-24)(sp) - CALL(_getcontext) /* getcontext(oucp) */ - ldq t0, (24-16)(sp) - bne v0, Lerr - ldq t1, (24- 8)(sp) - stq t1, (56 + 26 * 8)(t0) /* Adjust saved RA */ - stq t1, (56 + 32 * 8)(t0) /* Adjust saved PC */ - lda t1, 24(sp) - stq t1, (56 + 30 * 8)(t0) /* Adjust saved SP */ - - ldq a0, (24-24)(sp) - CALL(setcontext) /* setcontext(ucp) */ -Lerr: - ldq ra, (24- 8)(sp) - lda sp, 24(sp) - RET -END(swapcontext) diff --git a/lib/libc/arch/alpha/genassym.cf b/lib/libc/arch/alpha/genassym.cf deleted file mode 100644 index 64d4ed09a..000000000 --- a/lib/libc/arch/alpha/genassym.cf +++ /dev/null @@ -1,84 +0,0 @@ -# $NetBSD: genassym.cf,v 1.2 2008/04/28 20:22:55 martin Exp $ - -# -# Copyright (c) 2001 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include -include - -define _REG_V0 8*_REG_V0 /* 0 */ -define _REG_T0 8*_REG_T0 /* 1 */ -define _REG_T1 8*_REG_T1 /* 2 */ -define _REG_T2 8*_REG_T2 /* 3 */ -define _REG_T3 8*_REG_T3 /* 4 */ -define _REG_T4 8*_REG_T4 /* 5 */ -define _REG_T5 8*_REG_T5 /* 6 */ -define _REG_T6 8*_REG_T6 /* 7 */ -define _REG_T7 8*_REG_T7 /* 8 */ -define _REG_S0 8*_REG_S0 /* 9 */ -define _REG_S1 8*_REG_S1 /* 10 */ -define _REG_S2 8*_REG_S2 /* 11 */ -define _REG_S3 8*_REG_S3 /* 12 */ -define _REG_S4 8*_REG_S4 /* 13 */ -define _REG_S5 8*_REG_S5 /* 14 */ -define _REG_S6 8*_REG_S6 /* 15 */ -define _REG_A0 8*_REG_A0 /* 16 */ -define _REG_A1 8*_REG_A1 /* 17 */ -define _REG_A2 8*_REG_A2 /* 18 */ -define _REG_A3 8*_REG_A3 /* 19 */ -define _REG_A4 8*_REG_A4 /* 20 */ -define _REG_A5 8*_REG_A5 /* 21 */ -define _REG_T8 8*_REG_T8 /* 22 */ -define _REG_T9 8*_REG_T9 /* 23 */ -define _REG_T10 8*_REG_T10 /* 24 */ -define _REG_T11 8*_REG_T11 /* 25 */ -define _REG_RA 8*_REG_RA /* 26 */ -define _REG_T12 8*_REG_T12 /* 27 */ -define _REG_PV 8*_REG_PV /* 27 */ -define _REG_AT 8*_REG_AT /* 28 */ -define _REG_GP 8*_REG_GP /* 29 */ -define _REG_SP 8*_REG_SP /* 30 */ -define _REG_UNIQUE 8*_REG_UNIQUE /* 31 */ -define _REG_PC 8*_REG_PC /* 32 */ -define _REG_PS 8*_REG_PS /* 33 */ - -define SC_ONSTACK offsetof(struct sigcontext, sc_onstack) -define SC_SP offsetof(struct sigcontext, sc_sp) -define SC_PC offsetof(struct sigcontext, sc_pc) -define SC_PS offsetof(struct sigcontext, sc_ps) -define SC_REGS offsetof(struct sigcontext, sc_regs) -define SC_OWNEDFP offsetof(struct sigcontext, sc_regs) -define SC_FPREGS offsetof(struct sigcontext, sc_fpregs) -define SC_FPCR offsetof(struct sigcontext, sc_fpcr) -define SC_FP_CONTROL offsetof(struct sigcontext, sc_fp_control) -define SC_MASK offsetof(struct sigcontext, sc_mask) -define SC_RESERVED offsetof(struct sigcontext, sc_reserved) -define SC_XXX offsetof(struct sigcontext, sc_xxx) diff --git a/lib/libc/arch/alpha/gmon/Makefile.inc b/lib/libc/arch/alpha/gmon/Makefile.inc deleted file mode 100644 index 35d0bfd2a..000000000 --- a/lib/libc/arch/alpha/gmon/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2000/09/05 16:28:31 thorpej Exp $ - -SRCS+= _mcount.S diff --git a/lib/libc/arch/alpha/net/Makefile.inc b/lib/libc/arch/alpha/net/Makefile.inc deleted file mode 100644 index 9f1a4381e..000000000 --- a/lib/libc/arch/alpha/net/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/12/06 07:12:17 uebayasi Exp $ - -# objects built from assembler sources (need lint stubs) -# hton* and nto* functions provided by ../gen/byte_swap_*.S -SRCS+= - -LSRCS.alpha.net= Lint_htonl.c Lint_htons.c Lint_ntohl.c Lint_ntohs.c -LSRCS+= ${LSRCS.alpha.net} -DPSRCS+= ${LSRCS.alpha.net} -CLEANFILES+= ${LSRCS.alpha.net} diff --git a/lib/libc/arch/alpha/stdlib/Makefile.inc b/lib/libc/arch/alpha/stdlib/Makefile.inc deleted file mode 100644 index 0dbbca485..000000000 --- a/lib/libc/arch/alpha/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/31 20:39:59 dsl Exp $ diff --git a/lib/libc/arch/alpha/string/Makefile.inc b/lib/libc/arch/alpha/string/Makefile.inc deleted file mode 100644 index d7c479478..000000000 --- a/lib/libc/arch/alpha/string/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 2009/07/30 20:57:15 dsl Exp $ - -SRCS+= bcopy.S bzero.S ffs.S - -SRCS+= memcpy.S memmove.S diff --git a/lib/libc/arch/alpha/sys/__clone.S b/lib/libc/arch/alpha/sys/__clone.S deleted file mode 100644 index 824d1c967..000000000 --- a/lib/libc/arch/alpha/sys/__clone.S +++ /dev/null @@ -1,91 +0,0 @@ -/* $NetBSD: __clone.S,v 1.3 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -LEAF(__clone, 4) - br pv, 1f -1: LDGP(pv) - - /* - * Sanity checks: func and stack may not be NULL. - */ - beq a0, 9f - beq a1, 9f - - /* - * We need to be able to get at the func and arg arguments - * in the child. Luckily, we have a convenient place to - * do this; the child's stack. - */ - subq a1, 16, a1 - stq a0, 0(a1) - stq a3, 8(a1) - - /* - * The system call expects (flags, stack). - */ - mov a2, a0 - CALLSYS_ERROR(__clone) - - beq a4, 8f /* a4 (rv[1]) == 0, parent, child pid in v0 */ - - /* - * Fetch the function and argument from the new stack, and - * pop it back. - */ - ldq pv, 0(sp) - ldq a0, 8(sp) - addq sp, 16, sp - - /* Call the clone's entry point. */ - CALL((pv)) - - /* Pass return value to _exit(). */ - mov v0, a0 - CALL(_exit) - - /* NOTREACHED */ - -8: RET - -9: ldiq v0, EINVAL - jmp zero, __cerror - END(__clone) diff --git a/lib/libc/arch/alpha/sys/__sigaction14_sigtramp.c b/lib/libc/arch/alpha/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 77d089609..000000000 --- a/lib/libc/arch/alpha/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.7 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specified or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/alpha/sys/__sigtramp2.S b/lib/libc/arch/alpha/sys/__sigtramp2.S deleted file mode 100644 index 4c94fb2fd..000000000 --- a/lib/libc/arch/alpha/sys/__sigtramp2.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.2 2006/11/08 21:16:40 drochner Exp $ */ - -/* - * Copyright (c) 1994, 1995, 1996 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.h" - -/* - * The Alpha signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, the stack looks like: - * - * ucontext structure [128] == sp + sizeof(siginfo_t)] - * sp-> siginfo structure [0] - */ -NESTED_NOPROFILE(__sigtramp_siginfo_2,0,0,ra,0,0) - ldgp gp,0(ra) - lda a0,(128)(sp) /* get pointer to ucontext */ - CALLSYS_NOERROR(setcontext) /* and call setcontext() with it */ - ldiq a0,-1 /* if that failed, set an exit code */ - CALLSYS_NOERROR(exit) /* and call exit() */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/alpha/sys/__syscall.S b/lib/libc/arch/alpha/sys/__syscall.S deleted file mode 100644 index ca2b60017..000000000 --- a/lib/libc/arch/alpha/sys/__syscall.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.1 2000/12/13 07:49:17 mycroft 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.h" - -RSYSCALL(__syscall) diff --git a/lib/libc/arch/alpha/sys/__vfork14.S b/lib/libc/arch/alpha/sys/__vfork14.S deleted file mode 100644 index 2b4022c3c..000000000 --- a/lib/libc/arch/alpha/sys/__vfork14.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.2 2000/06/14 06:49:03 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.h" - -SYSCALL(__vfork14) - cmovne a4, zero, v0 /* a4 (rv[1]) != 0, child */ - RET -END(__vfork14) diff --git a/lib/libc/arch/alpha/sys/brk.S b/lib/libc/arch/alpha/sys/brk.S deleted file mode 100644 index 032640f65..000000000 --- a/lib/libc/arch/alpha/sys/brk.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: brk.S,v 1.9 2001/05/07 17:19:17 kleink 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.h" - - .globl _end -IMPORT(__curbrk, 8) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data -EXPORT(__minbrk) - .quad _end - - .text -LEAF(_brk, 1) - br pv, L1 /* XXX profiling */ -L1: LDGP(pv) - ldq v0, __minbrk - cmpult a0, v0, t0 - cmovne t0, v0, a0 - CALLSYS_ERROR(break) - stq a0, __curbrk - mov zero, v0 - RET -END(_brk) diff --git a/lib/libc/arch/alpha/sys/cerror.S b/lib/libc/arch/alpha/sys/cerror.S deleted file mode 100644 index 18788635b..000000000 --- a/lib/libc/arch/alpha/sys/cerror.S +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: cerror.S,v 1.6 2000/06/14 06:49:03 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.h" - -#ifdef _REENTRANT -#define FRAME_SIZE 16 -#define FRAME_RA_OFFSET 0 -#define FRAME_V0_OFFSET 8 -#endif - -#ifdef _REENTRANT -NESTED(__cerror, 0, FRAME_SIZE, ra, IM_RA|IM_V0, 0) -#else -LEAF(__cerror, 0) -#endif - br t0, L1 -L1: LDGP(t0) - -#ifdef _REENTRANT - lda sp, -FRAME_SIZE(sp) - stq ra, FRAME_RA_OFFSET(sp) - stq v0, FRAME_V0_OFFSET(sp) - - CALL(__errno) - - ldq t0, FRAME_V0_OFFSET(sp) - stl t0, 0(v0) -#else - stl v0, errno -#endif - - ldiq v0, -1 -#ifdef _REENTRANT - ldq ra, FRAME_RA_OFFSET(sp) - lda sp, FRAME_SIZE(sp) -#endif - RET -END(__cerror) diff --git a/lib/libc/arch/alpha/sys/exect.S b/lib/libc/arch/alpha/sys/exect.S deleted file mode 100644 index 57db0fa0f..000000000 --- a/lib/libc/arch/alpha/sys/exect.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: exect.S,v 1.3 2000/06/14 06:49:03 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.h" - -LEAF(exect, 3) - CALLSYS_ERROR(execve) - RET -END(exect) diff --git a/lib/libc/arch/alpha/sys/fork.S b/lib/libc/arch/alpha/sys/fork.S deleted file mode 100644 index 2b93d7bea..000000000 --- a/lib/libc/arch/alpha/sys/fork.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: fork.S,v 1.5 2003/02/13 02:50:48 nathanw 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.h" - -LEAF(__fork, 0) - CALLSYS_ERROR(fork) - cmovne a4, zero, v0 /* a4 (rv[1]) != 0, child */ - RET -END(__fork) diff --git a/lib/libc/arch/alpha/sys/getcontext.S b/lib/libc/arch/alpha/sys/getcontext.S deleted file mode 100644 index b97395745..000000000 --- a/lib/libc/arch/alpha/sys/getcontext.S +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.3 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -LEAF(_getcontext, 1) - CALLSYS_ERROR(getcontext) - stq ra, (56 + 32 * 8)(a0) /* Adjust saved PC */ - stq zero, (56 + 0 * 8)(a0) /* Arrange for a return value of 0 */ - RET -END(_getcontext) diff --git a/lib/libc/arch/alpha/sys/pipe.S b/lib/libc/arch/alpha/sys/pipe.S deleted file mode 100644 index cddc812c5..000000000 --- a/lib/libc/arch/alpha/sys/pipe.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: pipe.S,v 1.4 2001/05/07 17:19:18 kleink 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.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -LEAF(_pipe, 0) - CALLSYS_ERROR(pipe) - stl v0, 0(a0) - stl a4, 4(a0) - mov zero, v0 - RET -END(_pipe) diff --git a/lib/libc/arch/alpha/sys/ptrace.S b/lib/libc/arch/alpha/sys/ptrace.S deleted file mode 100644 index 46eff5b7f..000000000 --- a/lib/libc/arch/alpha/sys/ptrace.S +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.5 2000/06/14 06:49:03 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.h" - -LEAF(ptrace, 4) - LDGP(pv) - stl zero, errno - CALLSYS_ERROR(ptrace) - RET -END(ptrace) diff --git a/lib/libc/arch/alpha/sys/sbrk.S b/lib/libc/arch/alpha/sys/sbrk.S deleted file mode 100644 index afd80c4a2..000000000 --- a/lib/libc/arch/alpha/sys/sbrk.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.9 2001/05/07 17:19:18 kleink 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.h" - - .globl _end - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data -EXPORT(__curbrk) - .quad _end - - .text -LEAF(_sbrk, 1) - br pv, L1 /* XXX profiling */ -L1: LDGP(pv) - ldq a1, __curbrk - addq a0, a1, a0 - CALLSYS_ERROR(break) - stq a0, __curbrk - mov a1, v0 - RET -END(_sbrk) diff --git a/lib/libc/arch/alpha/sys/shmat.S b/lib/libc/arch/alpha/sys/shmat.S deleted file mode 100644 index 90e318516..000000000 --- a/lib/libc/arch/alpha/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:51 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/alpha/sys/syscall.S b/lib/libc/arch/alpha/sys/syscall.S deleted file mode 100644 index b97ef3fbf..000000000 --- a/lib/libc/arch/alpha/sys/syscall.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: syscall.S,v 1.2 2000/06/14 06:49:03 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.h" - -RSYSCALL(syscall) diff --git a/lib/libc/arch/arm/Makefile.inc b/lib/libc/arch/arm/Makefile.inc deleted file mode 100644 index b5ac83156..000000000 --- a/lib/libc/arch/arm/Makefile.inc +++ /dev/null @@ -1,37 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.28 2015/08/20 16:13:40 pooka Exp $ - -.include - -.if ${RUMPRUN} != "yes" && !defined(__MINIX) -SRCS+= __aeabi_read_tp.S __sigaction14_sigtramp.c __sigtramp2.S -.endif - -.if empty(LIBC_MACHINE_ARCH:Mearmv7*) -AFLAGS+= -marm -.endif - -CPPFLAGS += -I. - -.if !empty(LIBC_MACHINE_ARCH:Mearm*) -SRCS+= arm_initfini.c -.endif - -.if ${MKSOFTFLOAT} != "no" -CPPFLAGS += -DSOFTFLOAT - -# for earm, use the 64-bit softfloat -.if ${LIBC_MACHINE_ARCH} == "arm" || ${LIBC_MACHINE_ARCH} == "armeb" -SOFTFLOAT_BITS=32 -SRCS+= floatunsidf_ieee754.c floatunsisf_ieee754.c -.endif - -.include -.else -.PATH : ${ARCHDIR}/hardfloat -SRCS.hardfloat+= fpgetround.c fpgetsticky.S fpgetmask.S fabs_ieee754.S -SRCS.hardfloat+= fpsetround.c fpsetmask.S fpsetsticky.S -.for f in ${SRCS.hardfloat} -CPPFLAGS.${f} += -mfpu=vfp -.endfor -SRCS+= ${SRCS.hardfloat} -.endif diff --git a/lib/libc/arch/arm/SYS.h b/lib/libc/arch/arm/SYS.h deleted file mode 100644 index 528988ba8..000000000 --- a/lib/libc/arch/arm/SYS.h +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: SYS.h,v 1.15 2013/08/19 22:13:34 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - */ - -#define _TEXT_SECTION .section .text.hot, "ax" - -#include -#include -#include - -#ifndef __STDC__ -#error __STDC__ not defined -#endif - -#if !defined(__thumb__) -#define SYSTRAP(x) svc #SWI_OS_NETBSD | SYS_ ## x -#else -.macro emitsvc x - mov ip, r0 -.ifeq \x / 256 - movs r0, #\x -.else -#if defined(_ARM_ARCH_7) - movw r0, #\x -#else -.ifeq (\x & 3) - movs r0, #(\x / 4) - lsls r0, r0, #3 -.else -.ifeq (\x & 1) - movs r0, #(\x / 2) - lsls r0, r0, #1 -.else - movs r0, #(\x / 256) - lsls r0, r0, #8 - adds r0, r0, #(\x & 255) -.endif -.endif -#endif /* !_ARM_ARCH_7 */ -.endif - svc #255 -.endm -#define SYSTRAP(x) emitsvc SYS_ ## x -#endif /* __thumb__ */ - -#define CERROR _C_LABEL(__cerror) -#define CURBRK _C_LABEL(__curbrk) - -#define _SYSCALL_NOERROR(x,y) \ - ENTRY(x); \ - SYSTRAP(y) - -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) -#define _INVOKE_CERROR() bcs CERROR -#else -#define _INVOKE_CERROR() \ - bcc 86f; push {r3,lr}; bl CERROR; pop {r3,pc}; 86: -#endif -#define _SYSCALL(x, y) \ - _SYSCALL_NOERROR(x,y); \ - _INVOKE_CERROR() - -#define SYSCALL_NOERROR(x) \ - _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) \ - _SYSCALL(x,x) - - -#define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ - RET; \ - END(x) - -#define PSEUDO(x,y) \ - _SYSCALL(x,y); \ - RET; \ - END(x) - - -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) \ - PSEUDO(x,x) - -#ifdef WEAK_ALIAS -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) -#else -#define WSYSCALL(weak,strong) \ - PSEUDO(weak,weak) -#endif - - .hidden CERROR - .globl CERROR diff --git a/lib/libc/arch/arm/gdtoa/Makefile.inc b/lib/libc/arch/arm/gdtoa/Makefile.inc deleted file mode 100644 index 1d786e010..000000000 --- a/lib/libc/arch/arm/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/arm/gdtoa/arith.h b/lib/libc/arch/arm/gdtoa/arith.h deleted file mode 100644 index 40d3ed1fa..000000000 --- a/lib/libc/arch/arm/gdtoa/arith.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#include - -#if BYTE_ORDER == BIG_ENDIAN -#define IEEE_BIG_ENDIAN -#else -#define IEEE_LITTLE_ENDIAN -#endif diff --git a/lib/libc/arch/arm/gdtoa/gd_qnan.h b/lib/libc/arch/arm/gdtoa/gd_qnan.h deleted file mode 100644 index 9554f4991..000000000 --- a/lib/libc/arch/arm/gdtoa/gd_qnan.h +++ /dev/null @@ -1,12 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#include - -#define f_QNAN 0x7fc00000 -#if BYTE_ORDER == BIG_ENDIAN -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 -#else -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff80000 -#endif diff --git a/lib/libc/arch/arm/gen/Makefile.inc b/lib/libc/arch/arm/gen/Makefile.inc deleted file mode 100644 index 0eb81bf43..000000000 --- a/lib/libc/arch/arm/gen/Makefile.inc +++ /dev/null @@ -1,41 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.28 2014/01/29 23:37:18 joerg Exp $ - -SRCS+= alloca.S byte_swap_2.S byte_swap_4.S bswap64.c \ - fabs_ieee754.c flt_rounds.c - -CPUFLAGS.divide.S+= -marm - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -.if !empty(LIBC_MACHINE_ARCH:Mearm*) -SRCS+= __aeabi_fcmpun.c __aeabi_dcmpun.c -SRCS+= __aeabi_idiv0.c __aeabi_ldiv0.c -.endif - -AFLAGS._setjmp.S= -mfpu=vfp -AFLAGS.setjmp.S= -mfpu=vfp - -SRCS+= nanf.c - -SRCS+= setjmp.S -SRCS+= _setjmp.S -SRCS+= sigsetjmp.S - -.if defined(__MINIX) -# Already defined in minix/lib/libc/arch/arm/sys -.else -SRCS+= makecontext.c resumecontext.c swapcontext.S - -SRCS+= _lwp.c -.endif - -LSRCS.arm.gen= Lint_bswap16.c Lint_bswap32.c Lint_swapcontext.c -LSRCS+= ${LSRCS.arm.gen} -DPSRCS+= ${LSRCS.arm.gen} -CLEANFILES+= ${LSRCS.arm.gen} diff --git a/lib/libc/arch/arm/gen/__aeabi_dcmpun.c b/lib/libc/arch/arm/gen/__aeabi_dcmpun.c deleted file mode 100644 index 43354be19..000000000 --- a/lib/libc/arch/arm/gen/__aeabi_dcmpun.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_dcmpun.c,v 1.1 2013/01/26 07:04:22 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include - -/* - * result (1, 0) denotes (?, <=>) [2], use for C99 isunordered() - */ - -int -__aeabi_dcmpun(double x, double y) -{ - const union ieee_double_u ux = { .dblu_d = x }; - const union ieee_double_u uy = { .dblu_d = y }; - - return (ux.dblu_dbl.dbl_exp == DBL_EXP_INFNAN - && (ux.dblu_dbl.dbl_frach|ux.dblu_dbl.dbl_fracl) != 0) - || (uy.dblu_dbl.dbl_exp == DBL_EXP_INFNAN - && (uy.dblu_dbl.dbl_frach|uy.dblu_dbl.dbl_fracl) != 0); -} diff --git a/lib/libc/arch/arm/gen/__aeabi_fcmpun.c b/lib/libc/arch/arm/gen/__aeabi_fcmpun.c deleted file mode 100644 index 771bb4871..000000000 --- a/lib/libc/arch/arm/gen/__aeabi_fcmpun.c +++ /dev/null @@ -1,54 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_fcmpun.c,v 1.1 2013/01/26 07:04:22 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include - -/* - * result (1, 0) denotes (?, <=>) [2], use for C99 isunordered() - */ - -int -__aeabi_fcmpun(float x, float y) -{ - const union ieee_single_u ux = { .sngu_f = x }; - const union ieee_single_u uy = { .sngu_f = y }; - - return (ux.sngu_sng.sng_exp == SNG_EXP_INFNAN - && ux.sngu_sng.sng_frac != 0) - || (uy.sngu_sng.sng_exp == SNG_EXP_INFNAN - && uy.sngu_sng.sng_frac != 0); -} diff --git a/lib/libc/arch/arm/gen/_lwp.c b/lib/libc/arch/arm/gen/_lwp.c deleted file mode 100644 index 8ff945c59..000000000 --- a/lib/libc/arch/arm/gen/_lwp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.8 2012/03/22 09:32:04 he Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Jason R. Thorpe for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.8 2012/03/22 09:32:04 he Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - uintptr_t sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - sp = (uintptr_t)stack_base + stack_size; - /* - * Note: We make sure the stack is 8-byte aligned, here. - */ - - u->uc_mcontext.__gregs[_REG_R0] = (__greg_t)(uintptr_t)arg; - u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t)sp) & ~7; - u->uc_mcontext.__gregs[_REG_LR] = (__greg_t)(uintptr_t)_lwp_exit; - u->uc_mcontext.__gregs[_REG_PC] = (__greg_t)(uintptr_t)start; - u->uc_mcontext._mc_tlsbase = (__greg_t)(uintptr_t)private; - u->uc_flags |= _UC_TLSBASE; -} diff --git a/lib/libc/arch/arm/gen/_setjmp.S b/lib/libc/arch/arm/gen/_setjmp.S deleted file mode 100644 index 37a968375..000000000 --- a/lib/libc/arch/arm/gen/_setjmp.S +++ /dev/null @@ -1,194 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.16 2013/11/30 20:20:42 joerg Exp $ */ - -/* - * Copyright (c) 1997 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if !defined(__SOFTFP__) && !defined(__VFP_FP__) && !defined(__ARM_PCS) -#error FPA is not supported anymore -#endif - -#if defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) - .fpu vfp -#endif - -#include -#include - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - * - * Note: r0 is the return value - * r1-r3,ip are scratch registers in functions - */ - -ENTRY(_setjmp) - ldr r1, .L_setjmp_magic - -#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2)) - ldr r2, .Lfpu_present -#ifdef __PIC__ - add r2, r2, pc /* pc = &.LPIC0 */ -#endif - ldr r2, [r2] -.LPIC0: -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbz r2, 1f -#else - cmp r2, #0 /* do we have a FPU? */ - beq 1f /* no, don't save VFP registers */ -#endif - - orrs r1, r1, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP) - /* change magic to VFP magic */ - adds r2, r0, #(_JB_REG_D8 * 4) - vstmia r2, {d8-d15} - vmrs r2, fpscr - str r2, [r0, #(_JB_REG_FPSCR * 4)] -1: -#endif /* __ARM_EABI__ && (_ARM_ARCH_T2 || !__thumb__) */ - - str r1, [r0] - - adds r0, r0, #(_JB_REG_R4 * 4) - /* Store integer registers */ -#if !defined(__thumb__) || defined(_ARCH_ARCH_T2) - stmia r0, {r4-r14} -#else - stmia r0!, {r4-r7} - mov r1, r8 - mov r2, r9 - mov r3, r10 - stmia r0!, {r1-r3} - mov r2, r11 - mov r3, r12 - stmia r0!, {r2-r3} - mov r2, sp - mov r3, lr - stmia r0!, {r2-r3} -#endif - - movs r0, #0 - RET - -#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2)) - .align 0 -.Lfpu_present: - .word REL_SYM(_libc_arm_fpu_present, .LPIC0) -#endif /* __ARM_EABI__ && (_ARM_ARCH_T2 || !__thumb__) */ -END(_setjmp) - -ENTRY(_longjmp) - ldr r2, [r0] /* get magic from jmp_buf */ -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - bics r3, r2, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP) - /* ignore VFP-ness of magic */ - ldr ip, .L_setjmp_magic /* load magic */ -#else - ldr r3, .L_setjmp_magic /* load magic */ - mov ip, r3 - movs r3, #(_JB_MAGIC__SETJMP ^ _JB_MAGIC__SETJMP_VFP) - ands r3, r3, r2 - eors r3, r3, r2 /* ignore VFP-ness of magic */ -#endif - cmp ip, r3 /* magic correct? */ - bne botch /* no, botch */ - -#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2)) - cmp r3, r2 /* did magic change? */ - beq 1f /* no, don't restore VFP */ - adds r3, r0, #(_JB_REG_D8 * 4) - vldmia r3, {d8-d15} - ldr r3, [r0, #(_JB_REG_FPSCR * 4)] - vmsr fpscr, r3 -1: -#endif /* __ARM_EABI__ && (_ARM_ARCH_T2 || !__thumb__) */ - - adds r0, r0, #(_JB_REG_R4 * 4) - /* Restore integer registers */ -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - ldmia r0!, {r4-r12} -#else - ldmia r0!, {r4-r7} - ldmia r0!, {r2-r3} - mov r8, r2 - mov r9, r3 - ldmia r0!, {r2-r3} - mov r10, r2 - mov r1, r3 - adds r0, r0, #4 /* skip r12 */ -#endif - ldmia r0!, {r2-r3} /* r2 = sp, r3 = lr */ - - /* Validate sp and r14 */ -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbz r2, botch -#else - cmp r2, #0 - beq botch -#endif - mov sp, r2 - -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbz r3, botch -#else - cmp r3, #0 - beq botch -#endif - mov lr, r3 - - /* Set return value */ - movs r0, r1 -#ifdef __thumb__ - bne 1f - movs r0, #1 -1: -#else - moveq r0, #1 -#endif - RET - - /* validation failed, die die die. */ -botch: - bl PLT_SYM(_C_LABEL(longjmperror)) - bl PLT_SYM(_C_LABEL(abort)) -1: b 1b /* Cannot get here */ - - .align 0 -.L_setjmp_magic: - .word _JB_MAGIC__SETJMP -END(_longjmp) diff --git a/lib/libc/arch/arm/gen/alloca.S b/lib/libc/arch/arm/gen/alloca.S deleted file mode 100644 index 65d1cdb69..000000000 --- a/lib/libc/arch/arm/gen/alloca.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: alloca.S,v 1.5 2013/08/17 01:07:45 matt Exp $ */ - -/* - * Copyright (c) 1995 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* like alloc, but automatic automatic free in return */ - -#include - -ENTRY(alloca) - adds r0, r0, #7 /* round up to next 8 byte alignment */ -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - bics r0, r0, #7 - sub sp, sp, r0 /* Adjust the stack pointer */ - mov r0, sp /* r0 = base of new space */ -#else - lsrs r0, r0, #3 - lsls r0, r0, #3 - mov r1, sp - subs r0, r1, r0 /* Adjust the stack pointer */ - mov sp, r0 /* r0 = base of new space */ -#endif - RET -END(alloca) diff --git a/lib/libc/arch/arm/gen/flt_rounds.c b/lib/libc/arch/arm/gen/flt_rounds.c deleted file mode 100644 index f9e6a79ce..000000000 --- a/lib/libc/arch/arm/gen/flt_rounds.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.5 2015/03/19 21:22:59 joerg Exp $ */ - -/* - * Copyright (c) 1996 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.5 2015/03/19 21:22:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 2, /* round to positive infinity */ - 3, /* round to negative infinity */ - 0 /* round to zero */ -}; - -/* - * Return the current FP rounding mode - * - * Returns: - * 0 - round to zero - * 1 - round to nearest - * 2 - round to postive infinity - * 3 - round to negative infinity - * - * ok all we need to do is get the current FP rounding mode - * index our map table and return the appropriate value. - * - * HOWEVER: - * The ARM FPA codes the rounding mode into the actual FP instructions - * so there is no such thing as a global rounding mode. - * The default is round to nearest if rounding is not explicitly specified. - * FP instructions generated by GCC will not explicitly specify a rounding - * mode. - * - * So the best we can do it to return the rounding mode FP instructions - * use if rounding is not specified which is round to nearest. - * - * This could change in the future with new floating point emulators or - * soft float FP libraries. - */ - -int __flt_rounds(void); - -int -__flt_rounds(void) -{ - return(map[fpgetround()]); -} diff --git a/lib/libc/arch/arm/gen/makecontext.c b/lib/libc/arch/arm/gen/makecontext.c deleted file mode 100644 index 40cef0614..000000000 --- a/lib/libc/arch/arm/gen/makecontext.c +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.4 2012/03/21 14:03:06 christos Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.4 2012/03/21 14:03:06 christos Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - int i; - unsigned int *sp; - va_list ap; - - /* Compute and align stack pointer. */ - sp = (unsigned int *) - (((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~7); - /* Allocate necessary stack space for arguments exceeding r0-3. */ - if (argc > 4) - sp -= argc - 4; - gr[_REG_SP] = (__greg_t)(uintptr_t)sp; - /* Wipe out frame pointer. */ - gr[_REG_FP] = 0; - /* Arrange for return via the trampoline code. */ - gr[_REG_LR] = (__greg_t)(uintptr_t)_resumecontext; - gr[_REG_PC] = (__greg_t)(uintptr_t)func; - - va_start(ap, argc); - /* Pass up to four arguments in r0-3. */ - for (i = 0; i < argc && i < 4; i++) - gr[_REG_R0 + i] = va_arg(ap, int); - /* Pass any additional arguments on the stack. */ - for (argc -= i; argc > 0; argc--) - *sp++ = va_arg(ap, int); - va_end(ap); -} diff --git a/lib/libc/arch/arm/gen/nanf.c b/lib/libc/arch/arm/gen/nanf.c deleted file mode 100644 index 0be7edddb..000000000 --- a/lib/libc/arch/arm/gen/nanf.c +++ /dev/null @@ -1,19 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:01 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:01 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = -#if BYTE_ORDER == BIG_ENDIAN - { { 0x7f, 0xc0, 0, 0 } }; -#else - { { 0, 0, 0xc0, 0x7f } }; -#endif - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/arm/gen/resumecontext.c b/lib/libc/arch/arm/gen/resumecontext.c deleted file mode 100644 index 66781b68f..000000000 --- a/lib/libc/arch/arm/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/arm/gen/setjmp.S b/lib/libc/arch/arm/gen/setjmp.S deleted file mode 100644 index 84a77c134..000000000 --- a/lib/libc/arch/arm/gen/setjmp.S +++ /dev/null @@ -1,228 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.17 2013/11/30 20:20:42 joerg Exp $ */ - -/* - * Copyright (c) 1997 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if !defined(__SOFTFP__) && !defined(__VFP_FP__) && !defined(__ARM_PCS) -#error FPA is not supported anymore -#endif - -#if defined(__ARM_EABI__) && !defined(__ARM_PCS_VFP) - .fpu vfp -#endif - -#include -#include - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - /* Get the signal mask. */ - push {r0-r2, lr} -#if !defined(__thumb__) - adds r2, r0, #(_JB_SIGMASK * 4) -#else - mov r2, r0 - adds r2, r2, #(_JB_SIGMASK * 4) -#endif - movs r1, #0 - movs r0, #0 - bl PLT_SYM(_C_LABEL(__sigprocmask14)) -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - pop {r0-r2, lr} -#else - pop {r0-r3} - mov lr, r3 -#endif - - ldr r1, .Lsetjmp_magic - -#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2)) - ldr r2, .Lfpu_present -#ifdef __PIC__ - add r2, r2, pc /* pc = &.LPIC0 */ -#endif - ldr r2, [r2] -.LPIC0: -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbz r2, 1f /* don't save if we don't have a FPU */ -#else - cmp r2, #0 /* do we have a FPU? */ - beq 1f /* no, don't save VFP registers */ -#endif - - orrs r1, r1, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) - /* change magic to VFP magic */ - adds r2, r0, #(_JB_REG_D8 * 4) - vstmia r2, {d8-d15} - vmrs r2, fpscr - str r2, [r0, #(_JB_REG_FPSCR * 4)] -1: -#endif /* __ARM_EABI__ && (!__thumb__ || _ARM_ARCH_T2) */ - - str r1, [r0] /* store magic */ - - /* Store integer registers */ - adds r0, r0, #(_JB_REG_R4 * 4) -#if !defined(__thumb__) - stmia r0!, {r4-lr} -#else - stmia r0!, {r4-r7} - mov r2, r8 - mov r3, r9 - stmia r0!, {r2-r3} - mov r2, r10 - mov r3, r11 - stmia r0!, {r2-r3} - mov r2, sp - mov r3, lr - str r2, [r0, #4] - str r3, [r0, #8] -#endif - movs r0, #0 - RET - -#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2)) - .align 0 -.Lfpu_present: - .word REL_SYM(_libc_arm_fpu_present, .LPIC0) -#endif /* __ARM_EABI__ && (!__thumb__ || _ARM_ARCH_T2) */ -END(__setjmp14) - -ENTRY(__longjmp14) -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - ldr r2, [r0] - ldr ip, .Lsetjmp_magic - bic r3, r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) -#else - ldr r3, .Lsetjmp_magic - mov ip, r3 - ldr r3, [r0] - movs r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) - bics r3, r2 - /* r2 is not the magic but we don't need it since we can't do VFP */ -#endif - cmp r3, ip - bne .Lbotch - - /* Restore the signal mask. */ - push {r0-r2, lr} - movs r2, #0 -#if !defined(__thumb__) - adds r1, r0, #(_JB_SIGMASK * 4) -#else - mov r1, r0 - adds r1, r1, #(_JB_SIGMASK * 4) -#endif - movs r0, #3 /* SIG_SETMASK */ - bl PLT_SYM(_C_LABEL(__sigprocmask14)) -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - pop {r0-r2, lr} -#else - pop {r0-r3} - mov lr, r3 -#endif - -#if defined(__ARM_EABI__) && (!defined(__thumb__) || defined(_ARM_ARCH_T2)) - tst r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) - /* is this a VFP magic? */ - beq 1f /* no, don't restore VFP */ - adds r2, r0, #(_JB_REG_D8 * 4) - vldmia r2, {d8-d15} - ldr r2, [r0, #(_JB_REG_FPSCR * 4)] - vmsr fpscr, r2 -1: -#endif /* __ARM_EABI__ && (!__thumb__ || _ARM_ARCH_T2) */ - - adds r0, r0, #(_JB_REG_R4 * 4) - /* Restore integer registers */ -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - ldmia r0!, {r4-r12} -#else - ldmia r0!, {r4-r7} - ldmia r0!, {r2-r3} - mov r8, r2 - mov r9, r3 - ldmia r0!, {r2-r3} - mov r10, r2 - mov r11, r3 - adds r0, r0, #4 /* skip ip(r12) */ -#endif - - ldmia r0!, {r2-r3} - - /* Validate sp and lr */ -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbz r2, .Lbotch -#else - cmp r2, #0 - beq .Lbotch -#endif - mov sp, r2 - -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbz r3, .Lbotch -#else - cmp r3, #0 - beq .Lbotch -#endif - mov lr, r3 - - /* Set return value */ - movs r0, r1 -#if !defined(__thumb__) - moveq r0, #1 -#else - bne 1f - movs r0, #1 -1: -#endif - RET - - /* validation failed, die die die. */ -.Lbotch: - bl PLT_SYM(_C_LABEL(longjmperror)) - bl PLT_SYM(_C_LABEL(abort)) -1: b 1b /* Cannot get here */ - - .align 0 -.Lsetjmp_magic: - .word _JB_MAGIC_SETJMP -END(__longjmp14) diff --git a/lib/libc/arch/arm/gen/sigsetjmp.S b/lib/libc/arch/arm/gen/sigsetjmp.S deleted file mode 100644 index 94ad813f5..000000000 --- a/lib/libc/arch/arm/gen/sigsetjmp.S +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.8 2013/11/30 20:20:42 joerg Exp $ */ - -/* - * Copyright (c) 1997 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -/* - * C library -- sigsetjmp, siglongjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a, m) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__sigsetjmp14) -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbnz r1, 1f - b PLT_SYM(_C_LABEL(_setjmp)) -1: b PLT_SYM(_C_LABEL(__setjmp14)) -#elif !defined(__thumb__) - cmp r1, #0 - beq PLT_SYM(_C_LABEL(_setjmp)) - b PLT_SYM(_C_LABEL(__setjmp14)) -#else - push {r3, lr} - beq 1f - bl PLT_SYM(_C_LABEL(__setjmp14)) - b 2f -1: bl PLT_SYM(_C_LABEL(_setjmp)) -2: pop {r3, pc} -#endif -END(__sigsetjmp14) - -ENTRY(__siglongjmp14) - ldr r3, [r0] -#if !defined(__thumb__) - bics r3, r3, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) -#else - movs r2, #(_JB_MAGIC_SETJMP ^ _JB_MAGIC_SETJMP_VFP) - bics r3, r3, r2 -#endif - ldr r2, .L_setjmp_magic - cmp r2, r3 -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) -#ifdef __thumb__ - it eq -#endif - beq PLT_SYM(_C_LABEL(_longjmp)) - b PLT_SYM(_C_LABEL(__longjmp14)) -#else - push {r3, lr} - beq 11f - bl PLT_SYM(_C_LABEL(__longjmp14)) - pop {r3, pc} -11: bl PLT_SYM(_C_LABEL(_longjmp)) - pop {r3, pc} -#endif - - .align 0 -.L_setjmp_magic: - .word _JB_MAGIC__SETJMP -END(__siglongjmp14) diff --git a/lib/libc/arch/arm/gen/swapcontext.S b/lib/libc/arch/arm/gen/swapcontext.S deleted file mode 100644 index 31289da90..000000000 --- a/lib/libc/arch/arm/gen/swapcontext.S +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.14 2013/11/30 20:20:42 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.14 2013/11/30 20:20:42 joerg Exp $") -#endif /* LIBC_SCCS && !lint */ - -ENTRY(swapcontext) -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .fnstart - .cfi_startproc -#endif - push {r0-r2, lr} /* Must save oucp, ucp, lr. */ -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .save {r0-r2, lr} - .cfi_def_cfa_offset 16 - .cfi_offset 14, -4 - .cfi_offset 2, -8 - .cfi_offset 1, -12 - .cfi_offset 0, -16 -#endif - bl PLT_SYM(_C_LABEL(_getcontext)) /* getcontext(oucp) */ - cmp r0, #0 -#if !defined(__thumb__) - pop {r0-r2, lr} -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .cfi_def_cfa_offset 0 -#endif - RETc(ne) -#else - pop {r0-r3} - beq 1f -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .cfi_def_cfa_offset 0 - .cfi_register 14, 3 -#endif - RETr(r3) -1: -#endif -#if !defined(__thumb__) - str sp, [r0, #_UC_REGS_SP] /* Adjust saved SP. */ - str lr, [r0, #_UC_REGS_PC] /* Adjust saved SP. */ -#else - mov r2, sp - str r2, [r0, #_UC_REGS_SP] /* Adjust saved SP. */ - str r3, [r0, #_UC_REGS_PC] /* Adjust saved PC. */ - mov lr, r3 -#endif -#ifdef SOFTFLOAT - /* Ahem. */ -#endif - mov r0, r1 -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - b PLT_SYM(_C_LABEL(setcontext)) -#else - push {lr} - bl PLT_SYM(_C_LABEL(setcontext)) - pop {pc} -#endif -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .cfi_endproc - .fnend -#endif -END(swapcontext) diff --git a/lib/libc/arch/arm/hardfloat/fabs_ieee754.S b/lib/libc/arch/arm/hardfloat/fabs_ieee754.S deleted file mode 100644 index 0e1c1f426..000000000 --- a/lib/libc/arch/arm/hardfloat/fabs_ieee754.S +++ /dev/null @@ -1,40 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: fabs_ieee754.S,v 1.1 2014/01/17 22:19:46 joerg Exp $") - - .fpu vfp - -ENTRY(fabsl) -ENTRY(fabs) - vabs.f64 d0, d0 - RET -END(fabs) diff --git a/lib/libc/arch/arm/hardfloat/fpgetmask.S b/lib/libc/arch/arm/hardfloat/fpgetmask.S deleted file mode 100644 index 2faa3307d..000000000 --- a/lib/libc/arch/arm/hardfloat/fpgetmask.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: fpgetmask.S,v 1.7 2013/08/02 02:07:00 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __VFP_FP__ -#error FPA is not supported anymore -#endif -#include -#include - -/* - * Return the current FP exception enable mask - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetmask, _fpgetmask) -#define fpgetmask _fpgetmask -#endif - -ENTRY(fpgetmask) - vmrs r0, fpscr - mov r0, r0, lsr #8 - and r0, r0, #VFP_FPSCR_CSUM - RET -END(fpgetmask) diff --git a/lib/libc/arch/arm/hardfloat/fpgetround.c b/lib/libc/arch/arm/hardfloat/fpgetround.c deleted file mode 100644 index 70d467a22..000000000 --- a/lib/libc/arch/arm/hardfloat/fpgetround.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.6 2013/01/11 13:55:26 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __VFP_FP__ -#error FPA is not supported anymore -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.6 2013/01/11 13:55:26 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -/* - * Return the current FP rounding mode - */ - -fp_rnd -fpgetround(void) -{ - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RN, VFP_FPSCR_RMODE) == FP_RN); - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RP, VFP_FPSCR_RMODE) == FP_RP); - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RM, VFP_FPSCR_RMODE) == FP_RM); - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RZ, VFP_FPSCR_RMODE) == FP_RZ); - uint32_t fpscr; - __asm __volatile("vmrs %0, fpscr" : "=r" (fpscr)); - return __SHIFTOUT(fpscr, VFP_FPSCR_RMODE); -} diff --git a/lib/libc/arch/arm/hardfloat/fpgetsticky.S b/lib/libc/arch/arm/hardfloat/fpgetsticky.S deleted file mode 100644 index d0382e282..000000000 --- a/lib/libc/arch/arm/hardfloat/fpgetsticky.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: fpgetsticky.S,v 1.6 2013/01/11 13:55:26 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef __VFP_FP__ -#error FPA is not supported anymore -#endif - -#include -#include - -/* - * Return the current FP cumulative flags - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetsticky, _fpgetsticky) -#define fpgetsticky _fpgetsticky -#endif - -ENTRY(fpgetsticky) - vmrs r0, fpscr - and r0, r0, #VFP_FPSCR_CSUM - RET -END(fpgetsticky) diff --git a/lib/libc/arch/arm/hardfloat/fpsetmask.S b/lib/libc/arch/arm/hardfloat/fpsetmask.S deleted file mode 100644 index 943d23005..000000000 --- a/lib/libc/arch/arm/hardfloat/fpsetmask.S +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: fpsetmask.S,v 1.7 2014/01/23 00:00:16 joerg Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __VFP_FP__ -#error FPA is not supported anymore -#endif - -#include -#include - -/* - * Set the current FP exception enable mask - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetmask, _fpsetmask) -#define fpsetmask _fpsetmask -#endif - -ENTRY(fpsetmask) - and r2, r0, #VFP_FPSCR_CSUM - vmrs r1, fpscr - mov r0, r1, lsr #8 /* Return old mask */ - bic r1, r1, #VFP_FPSCR_ESUM - orr r1, r1, r2, lsl #8 - vmsr fpscr, r1 - and r0, r0, #VFP_FPSCR_CSUM - RET -END(fpsetmask) diff --git a/lib/libc/arch/arm/hardfloat/fpsetround.c b/lib/libc/arch/arm/hardfloat/fpsetround.c deleted file mode 100644 index cd4f95416..000000000 --- a/lib/libc/arch/arm/hardfloat/fpsetround.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.8 2013/02/03 01:50:54 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __VFP_FP__ -#error FPA is not supported anymore -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.8 2013/02/03 01:50:54 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -/* - * Return the current FP rounding mode - */ - -fp_rnd -fpsetround(fp_rnd new_rnd) -{ - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RN, VFP_FPSCR_RMODE) == FP_RN); - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RP, VFP_FPSCR_RMODE) == FP_RP); - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RM, VFP_FPSCR_RMODE) == FP_RM); - __CTASSERT(__SHIFTOUT(VFP_FPSCR_RZ, VFP_FPSCR_RMODE) == FP_RZ); - uint32_t fpscr; - __asm __volatile("vmrs %0, fpscr" : "=r" (fpscr)); - fp_rnd old_rnd = __SHIFTOUT(fpscr, VFP_FPSCR_RMODE); - fpscr ^= __SHIFTIN(new_rnd ^ old_rnd, VFP_FPSCR_RMODE); - __asm __volatile("vmsr fpscr, %0" :: "r" (fpscr)); - return old_rnd; -} diff --git a/lib/libc/arch/arm/hardfloat/fpsetsticky.S b/lib/libc/arch/arm/hardfloat/fpsetsticky.S deleted file mode 100644 index 2b4d01c86..000000000 --- a/lib/libc/arch/arm/hardfloat/fpsetsticky.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: fpsetsticky.S,v 1.6 2013/01/11 13:55:26 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef __VFP_FP__ -#error FPA is not supported anymore -#endif - -#include -#include - -/* - * Set the current FP cumulative flags - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetsticky, _fpsetsticky) -#define fpsetsticky _fpsetsticky -#endif - -ENTRY(fpsetsticky) - and r1, r0, #VFP_FPSCR_CSUM - vmrs r0, fpscr - bic r2, r0, #VFP_FPSCR_CSUM - orr r1, r1, r2 - vmsr fpscr, r1 - and r0, r0, #VFP_FPSCR_CSUM - RET -END(fpsetsticky) diff --git a/lib/libc/arch/arm/misc/arm_initfini.c b/lib/libc/arch/arm/misc/arm_initfini.c deleted file mode 100644 index 28109be89..000000000 --- a/lib/libc/arch/arm/misc/arm_initfini.c +++ /dev/null @@ -1,74 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: arm_initfini.c,v 1.7 2013/09/08 13:15:53 matt Exp $"); - -#include "namespace.h" - -/* - * To properly implement setjmp/longjmp for the ARM AAPCS ABI, it has to be - * aware of whether there is a FPU is present or not. Regardless of whether - * the hard-float ABI is being used, setjmp needs to save D8-D15. But it can - * only do this if those instructions won't cause an exception. - */ - -#include -#include - -#include -#include - -__dso_hidden int _libc_arm_fpu_present; -#ifndef __ARM_ARCH_EXT_IDIV__ -__dso_hidden int _libc_arm_hwdiv_present; -#endif -static bool _libc_aapcs_initialized; - -void _libc_aapcs_init(void) __attribute__((__constructor__, __used__)); - -void __section(".text.startup") -_libc_aapcs_init(void) -{ - if (!_libc_aapcs_initialized) { -#if !defined(__minix) - size_t len = sizeof(_libc_arm_fpu_present); -#endif - _libc_aapcs_initialized = true; -#if !defined(__minix) - (void)sysctlbyname("machdep.fpu_present", - &_libc_arm_fpu_present, &len, NULL, 0); -#ifndef __ARM_ARCH_EXT_IDIV__ - (void)sysctlbyname("machdep.hwdiv_present", - &_libc_arm_hwdiv_present, &len, NULL, 0); -#endif -#endif /* !defined(__minix) */ - } -} diff --git a/lib/libc/arch/arm/net/Makefile.inc b/lib/libc/arch/arm/net/Makefile.inc deleted file mode 100644 index 10fabd39b..000000000 --- a/lib/libc/arch/arm/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2000/12/29 20:13:53 bjh21 Exp $ - -# hton* and nto* functions provided by ../gen/byte_swap_*.S -SRCS+= diff --git a/lib/libc/arch/arm/softfloat/__aeabi_dcmpeq.c b/lib/libc/arch/arm/softfloat/__aeabi_dcmpeq.c deleted file mode 100644 index 6725c668b..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_dcmpeq.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_dcmpeq.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_dcmpeq.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -int __aeabi_dcmpeq(float64, float64); - -int -__aeabi_dcmpeq(float64 a, float64 b) -{ - - return float64_eq(a, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_dcmpge.c b/lib/libc/arch/arm/softfloat/__aeabi_dcmpge.c deleted file mode 100644 index 01dd38a89..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_dcmpge.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_dcmpge.c,v 1.2 2013/04/16 13:38:34 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_dcmpge.c,v 1.2 2013/04/16 13:38:34 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_dcmpge(float64, float64); - -int -__aeabi_dcmpge(float64 a, float64 b) -{ - - return !float64_lt(a, b) && float64_eq(a, a) && float64_eq(b, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_dcmpgt.c b/lib/libc/arch/arm/softfloat/__aeabi_dcmpgt.c deleted file mode 100644 index e1782129c..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_dcmpgt.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_dcmpgt.c,v 1.2 2013/04/16 13:38:34 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_dcmpgt.c,v 1.2 2013/04/16 13:38:34 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_dcmpgt(float64, float64); - -int -__aeabi_dcmpgt(float64 a, float64 b) -{ - - return !float64_le(a, b) && float64_eq(a, a) && float64_eq(b, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_dcmple.c b/lib/libc/arch/arm/softfloat/__aeabi_dcmple.c deleted file mode 100644 index c8202f870..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_dcmple.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_dcmple.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_dcmple.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_dcmple(float64, float64); - -int -__aeabi_dcmple(float64 a, float64 b) -{ - - return float64_le(a, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_dcmplt.c b/lib/libc/arch/arm/softfloat/__aeabi_dcmplt.c deleted file mode 100644 index 99b80d858..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_dcmplt.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_dcmplt.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_dcmplt.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_dcmplt(float64, float64); - -int -__aeabi_dcmplt(float64 a, float64 b) -{ - - return float64_lt(a, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_dcmpun.c b/lib/libc/arch/arm/softfloat/__aeabi_dcmpun.c deleted file mode 100644 index 7b13d0106..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_dcmpun.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: __aeabi_dcmpun.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Richard Earnshaw, 2003. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_dcmpun.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_dcmpun(float64, float64); - -int -__aeabi_dcmpun(float64 a, float64 b) -{ - /* - * The comparison is unordered if either input is a NaN. - * Test for this by comparing each operand with itself. - * We must perform both comparisons to correctly check for - * signalling NaNs. - */ - return !float64_eq(a, a) || !float64_eq(b, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_fcmpeq.c b/lib/libc/arch/arm/softfloat/__aeabi_fcmpeq.c deleted file mode 100644 index 02f5f0b69..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_fcmpeq.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_fcmpeq.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_fcmpeq.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -int __aeabi_fcmpeq(float32, float32); - -int -__aeabi_fcmpeq(float32 a, float32 b) -{ - - return float32_eq(a, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_fcmpge.c b/lib/libc/arch/arm/softfloat/__aeabi_fcmpge.c deleted file mode 100644 index 3d52d907d..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_fcmpge.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_fcmpge.c,v 1.2 2013/04/16 13:38:34 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_fcmpge.c,v 1.2 2013/04/16 13:38:34 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_fcmpge(float32, float32); - -int -__aeabi_fcmpge(float32 a, float32 b) -{ - - return !float32_lt(a, b) && float32_eq(a, a) && float32_eq(b, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_fcmpgt.c b/lib/libc/arch/arm/softfloat/__aeabi_fcmpgt.c deleted file mode 100644 index 71c28534e..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_fcmpgt.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_fcmpgt.c,v 1.2 2013/04/16 13:38:34 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_fcmpgt.c,v 1.2 2013/04/16 13:38:34 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_fcmpgt(float32, float32); - -int -__aeabi_fcmpgt(float32 a, float32 b) -{ - - return !float32_le(a, b) && float32_eq(a, a) && float32_eq(b, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_fcmple.c b/lib/libc/arch/arm/softfloat/__aeabi_fcmple.c deleted file mode 100644 index a51b29118..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_fcmple.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_fcmple.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_fcmple.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_fcmple(float32, float32); - -int -__aeabi_fcmple(float32 a, float32 b) -{ - - return float32_le(a, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_fcmplt.c b/lib/libc/arch/arm/softfloat/__aeabi_fcmplt.c deleted file mode 100644 index c734fe5e3..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_fcmplt.c +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: __aeabi_fcmplt.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Ben Harris, 2000. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_fcmplt.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_fcmplt(float32, float32); - -int -__aeabi_fcmplt(float32 a, float32 b) -{ - - return float32_lt(a, b); -} diff --git a/lib/libc/arch/arm/softfloat/__aeabi_fcmpun.c b/lib/libc/arch/arm/softfloat/__aeabi_fcmpun.c deleted file mode 100644 index 7b71b3aab..000000000 --- a/lib/libc/arch/arm/softfloat/__aeabi_fcmpun.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: __aeabi_fcmpun.c,v 1.1 2013/04/16 10:37:39 matt Exp $ */ - -/* - * Written by Richard Earnshaw, 2003. This file is in the Public Domain. - */ - -#include "softfloat-for-gcc.h" -#include "milieu.h" -#include "softfloat.h" - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __aeabi_fcmpun.c,v 1.1 2013/04/16 10:37:39 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int __aeabi_fcmpun(float32, float32); - -int -__aeabi_fcmpun(float32 a, float32 b) -{ - /* - * The comparison is unordered if either input is a NaN. - * Test for this by comparing each operand with itself. - * We must perform both comparisons to correctly check for - * signalling NaNs. - */ - return !float32_eq(a, a) || !float32_eq(b, b); -} diff --git a/lib/libc/arch/arm/softfloat/arm-gcc.h b/lib/libc/arch/arm/softfloat/arm-gcc.h deleted file mode 100644 index c52f5b8be..000000000 --- a/lib/libc/arch/arm/softfloat/arm-gcc.h +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: arm-gcc.h,v 1.4 2013/01/26 07:08:14 matt Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#ifdef __ARMEB__ -#define BIGENDIAN -#else -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef int uint8; -typedef int int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##ULL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -/* -------------------------------------------------------------------------------- -The ARM FPA is odd in that it stores doubles high-order word first, no matter -what the endianness of the CPU. VFP is sane. -------------------------------------------------------------------------------- -*/ -#if defined(SOFTFLOAT_FOR_GCC) -#if defined(__VFP_FP__) || defined(__ARMEB__) -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) -#else -#define FLOAT64_DEMANGLE(a) (((a) << 32) | ((a) >> 32)) -#define FLOAT64_MANGLE(a) FLOAT64_DEMANGLE(a) -#endif -#endif diff --git a/lib/libc/arch/arm/softfloat/milieu.h b/lib/libc/arch/arm/softfloat/milieu.h deleted file mode 100644 index a3f829c42..000000000 --- a/lib/libc/arch/arm/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.1 2000/12/29 20:13:54 bjh21 Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "arm-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/arm/softfloat/softfloat.h b/lib/libc/arch/arm/softfloat/softfloat.h deleted file mode 100644 index b45649d43..000000000 --- a/lib/libc/arch/arm/softfloat/softfloat.h +++ /dev/null @@ -1,317 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.10 2013/04/24 18:04:46 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -/* #define FLOAT128 */ - -#include -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */ -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned int float32_to_uint32_round_to_zero( float32 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -#endif -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -int float32_eq( float32, float32 ); -int float32_le( float32, float32 ); -int float32_lt( float32, float32 ); -int float32_eq_signaling( float32, float32 ); -int float32_le_quiet( float32, float32 ); -int float32_lt_quiet( float32, float32 ); -#ifndef SOFTFLOAT_FOR_GCC -int float32_is_signaling_nan( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned int float64_to_uint32_round_to_zero( float64 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -#endif -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -int float64_eq( float64, float64 ); -int float64_le( float64, float64 ); -int float64_lt( float64, float64 ); -int float64_eq_signaling( float64, float64 ); -int float64_le_quiet( float64, float64 ); -int float64_lt_quiet( float64, float64 ); -#ifndef SOFTFLOAT_FOR_GCC -int float64_is_signaling_nan( float64 ); -#endif - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -int floatx80_eq( floatx80, floatx80 ); -int floatx80_le( floatx80, floatx80 ); -int floatx80_lt( floatx80, floatx80 ); -int floatx80_eq_signaling( floatx80, floatx80 ); -int floatx80_le_quiet( floatx80, floatx80 ); -int floatx80_lt_quiet( floatx80, floatx80 ); -int floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -int float128_eq( float128, float128 ); -int float128_le( float128, float128 ); -int float128_lt( float128, float128 ); -int float128_eq_signaling( float128, float128 ); -int float128_le_quiet( float128, float128 ); -int float128_lt_quiet( float128, float128 ); -int float128_is_signaling_nan( float128 ); - -#endif - diff --git a/lib/libc/arch/arm/stdlib/Makefile.inc b/lib/libc/arch/arm/stdlib/Makefile.inc deleted file mode 100644 index d1dda0262..000000000 --- a/lib/libc/arch/arm/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/07/31 20:39:59 dsl Exp $ diff --git a/lib/libc/arch/arm/string/Makefile.inc b/lib/libc/arch/arm/string/Makefile.inc deleted file mode 100644 index ac3055860..000000000 --- a/lib/libc/arch/arm/string/Makefile.inc +++ /dev/null @@ -1,29 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.9 2013/08/21 03:05:35 matt Exp $ - -SRCS.string+= memcmp.S memcpy.S memmove.S memset.S -SRCS.string+= ffs.S -SRCS.string+= bcopy.S bzero.S -SRCS.string+= strcat.S -SRCS.string+= strcpy.S strlcpy.S strncpy.S -.if empty(LIBC_MACHINE_ARCH:M*v7*) -SRCS.string+= strcmp.S strncmp.S -SRCS.string+= strlen.S strnlen.S -SRCS.string+= strchr.S strrchr.S -.endif - -.for f in ${SRCS.string} -CPUFLAGS.${f}+= -marm -.for s in o po pico ln d -${f:.S=.${s}}: ${ARCHDIR}/string/Makefile.inc -.endfor -.endfor - -.if !empty(LIBC_MACHINE_ARCH:M*v7*) -SRCS.string+= strcmp.S strncmp.S -SRCS.string+= strlen.S strnlen.S -SRCS.string+= strchr.S strrchr.S -.endif - -SRCS.string+= strlcat.S - -SRCS+= ${SRCS.string} diff --git a/lib/libc/arch/arm/string/bcopy.S b/lib/libc/arch/arm/string/bcopy.S deleted file mode 100644 index 71fb90905..000000000 --- a/lib/libc/arch/arm/string/bcopy.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: bcopy.S,v 1.3 2003/10/14 07:51:45 scw Exp $ */ - -#define _BCOPY -#include "memmove.S" diff --git a/lib/libc/arch/arm/string/bzero.S b/lib/libc/arch/arm/string/bzero.S deleted file mode 100644 index 1c9d39085..000000000 --- a/lib/libc/arch/arm/string/bzero.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: bzero.S,v 1.4 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Neil A. Carson and Mark Brinicombe - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#define _BZERO -#include "memset.S" diff --git a/lib/libc/arch/arm/string/strncat_naive.S b/lib/libc/arch/arm/string/strncat_naive.S deleted file mode 100644 index 2d7e8a73e..000000000 --- a/lib/libc/arch/arm/string/strncat_naive.S +++ /dev/null @@ -1,53 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: strncat_naive.S,v 1.1 2013/01/23 05:44:52 matt Exp $") - -/* LINTSTUB: char *strncat(char *, const char *, size_t) */ -ENTRY(strncat) - teq r2, #0 /* count is 0? */ - RETc(eq) /* yes, just return dst */ - mov ip, r0 /* need to preserve r0 */ -1: ldrb r3, [ip], #1 /* load next byte */ - teq r3, #0 /* was it a NUL? */ - bne 1b /* no, get next byte */ - sub ip, ip, #1 /* back up one to the NUL */ -2: subs r2, r2, #1 /* subtract 1 from the count */ - blt 3f /* <0? write terminating NUL */ - ldrb r3, [r1], #1 /* load next byte from append */ - strb r3, [ip], #1 /* store it */ - teq r3, #0 /* was it a NUL? */ - bne 2b /* no, get next byte */ - RET /* return */ -3: mov r3, #0 /* load a NUL */ - strb r3, [ip] /* store it */ - RET /* return */ -END(strncat) diff --git a/lib/libc/arch/arm/sys/__aeabi_read_tp.S b/lib/libc/arch/arm/sys/__aeabi_read_tp.S deleted file mode 100644 index 725692fdb..000000000 --- a/lib/libc/arch/arm/sys/__aeabi_read_tp.S +++ /dev/null @@ -1,21 +0,0 @@ -/* $NetBSD: __aeabi_read_tp.S,v 1.5 2013/08/19 22:10:51 matt Exp $ */ - -#undef __thumb__ -#include "SYS.h" - -/* - * Implementations of this function should corrupt only the result register - * (r0) and the non-parameter integer core registers allowed to be corrupted - * by the [AAPCS] (ip, lr, and CPSR). - */ -ARM_ENTRY(__aeabi_read_tp) - mrc p15, 0, r0, c13, c0, 3 -#ifndef _ARM_ARCH_6 - cmp r0, #0 /* was it zero? */ - RETc(ne) /* return it's not zero */ - mov ip, r1 /* syscall zeroes r1 */ - SYSTRAP(_lwp_getprivate) /* can't fail */ - mov r1, ip /* restore r1 */ -#endif - RET -END(__aeabi_read_tp) diff --git a/lib/libc/arch/arm/sys/__clone.S b/lib/libc/arch/arm/sys/__clone.S deleted file mode 100644 index df9a6cbfa..000000000 --- a/lib/libc/arch/arm/sys/__clone.S +++ /dev/null @@ -1,128 +0,0 @@ -/* $NetBSD: __clone.S,v 1.9 2013/11/30 20:20:42 joerg Exp $ */ - -/* - * Copyright (c) 2001 Christopher Gilbert - * All rights reserved. - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the company nor the name of the author may be used to - * endorse or promote products derived from this software without specific - * prior written permission. - * - * 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 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.h" -#include - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - - /* test stack and function are not null */ -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbz r0, .Leinval - cbz r1, .Leinval -#elif !defined(__thumb__) - cmp r0, #0x00 - cmpne r1, #0x00 - beq .Leinval -#else - cmp r0, #0x00 - beq .Leinval - cmp r1, #0x00 - beq .Leinval -#endif - - /* place the func and its arg onto the child's stack */ -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - stmfd r1!, {r0, r3} -#else - subs r1, r1, #8 - stmia r1!, {r0, r3} -#endif - - /* syscall expects (flags, stack) */ - mov r0, r2 - - SYSTRAP(__clone) -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - _INVOKE_CERROR() -#else - bcs .Lcerror -#endif - - /* - * r1 and r0 are the same as from fork: - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - */ - /* if this is the parent then just return the pid */ -#if defined(__thumb__) -#if defined(_ARM_ARCH_T2) - cbz r1, 1f -#else - cmp r1, #0x00 - bne 1f -#endif - RET -1: -#else - cmp r1, #0x00 - RETc(eq) -#endif - - /* - * This is the child - * load the function and arg off the stack - */ - pop {r1, r2} - - /* place arg in r0 */ - mov r0, r2 - - /* call the function */ -#ifdef _ARM_ARCH_5T - blx r1 -#else - /* setup return address */ - mov lr, pc - RETr(r1) -#endif - /* call _exit with the returned value */ - bl PLT_SYM(_C_LABEL(_exit)) - - /* NOTREACHED */ - - /* error handler if func or stack is NULL */ - .align 0 -.Leinval: - movs r0, #EINVAL -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - b CERROR -#else -.Lcerror: - push {lr} - bl CERROR - pop {pc} -#endif -END(__clone) diff --git a/lib/libc/arch/arm/sys/__sigaction14_sigtramp.c b/lib/libc/arch/arm/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 615ebe816..000000000 --- a/lib/libc/arch/arm/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.7 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.7 2008/04/28 20:22:55 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specificed or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/arm/sys/__sigtramp2.S b/lib/libc/arch/arm/sys/__sigtramp2.S deleted file mode 100755 index 4ee638e35..000000000 --- a/lib/libc/arch/arm/sys/__sigtramp2.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.3 2013/08/16 23:20:59 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The ARM signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, the stack looks like: - * - * ucontext structure - * sp-> siginfo structure - * and r5 points to the ucontext - */ -ENTRY_NP(__sigtramp_siginfo_2) - mov r0, r5 /* set the arg */ - SYSTRAP(setcontext) /* and call setcontext */ - - /* If that failed, exit with the error code. */ - SYSTRAP(exit) -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/arm/sys/__syscall.S b/lib/libc/arch/arm/sys/__syscall.S deleted file mode 100644 index 563aaad57..000000000 --- a/lib/libc/arch/arm/sys/__syscall.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.4 2003/08/07 16:42:03 agc Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -RSYSCALL(__syscall) diff --git a/lib/libc/arch/arm/sys/__vfork14.S b/lib/libc/arch/arm/sys/__vfork14.S deleted file mode 100644 index 2bb1dfca6..000000000 --- a/lib/libc/arch/arm/sys/__vfork14.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.10 2013/09/03 00:30:19 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -/* - * pid = vfork(); - * - * On return from the SWI: - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - */ -ENTRY(__vfork14) - mov r2, lr - SYSTRAP(__vfork14) - _INVOKE_CERROR() - subs r1, r1, #1 /* r1 == 0xffffffff if parent, 0 if child */ - ands r0, r0, r1 /* r0 == 0 if child, else unchanged */ - RETr(r2) -END(__vfork14) diff --git a/lib/libc/arch/arm/sys/brk.S b/lib/libc/arch/arm/sys/brk.S deleted file mode 100644 index 347c3f7b4..000000000 --- a/lib/libc/arch/arm/sys/brk.S +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: brk.S,v 1.13 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)brk.s 5.2 (Berkeley) 12/17/90 - */ - -#include "SYS.h" - - .globl _C_LABEL(_end) - .globl _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data - .align 0 - .globl _C_LABEL(__minbrk) - .hidden _C_LABEL(__minbrk) - .type _C_LABEL(__minbrk),#object -_C_LABEL(__minbrk): - .word _C_LABEL(_end) - -/* - * Change the data segment size - */ -ENTRY(_brk) - ldr r1, .Lminbrk -#ifdef __PIC__ - adr r3, .Lminbrk - adds r1, r1, r3 -#endif - /* Get the minimum allowable brk address */ - ldr r1, [r1] - - /* - * Valid the address specified and set to the minimum - * if the address is below minbrk. - */ - cmp r0, r1 -#ifdef __thumb__ - bcs 1f - mov r0, r1 -1: -#else - movcc r0, r1 -#endif - mov r2, r0 - SYSTRAP(break) - _INVOKE_CERROR() - - ldr r1, .Lcurbrk -#ifdef __PIC__ - adds r1, r1, r3 -#endif - /* Store the new address in curbrk */ - str r2, [r1] - - /* Return 0 for success */ - movs r0, #0 - RET - - .align 0 -.Lminbrk: - .word REL_SYM(_C_LABEL(__minbrk), .Lminbrk) -.Lcurbrk: - .word REL_SYM(_C_LABEL(__curbrk), .Lminbrk) -END(_brk) diff --git a/lib/libc/arch/arm/sys/cerror.S b/lib/libc/arch/arm/sys/cerror.S deleted file mode 100644 index 04d48b777..000000000 --- a/lib/libc/arch/arm/sys/cerror.S +++ /dev/null @@ -1,102 +0,0 @@ -/* $NetBSD: cerror.S,v 1.13 2013/11/30 20:20:42 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -ENTRY_NP(CERROR) -#ifdef _REENTRANT -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .fnstart - .cfi_startproc -#endif - push {r4, lr} -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .save {r4, lr} - .cfi_def_cfa_offset 8 - .cfi_offset 14, -4 - .cfi_offset 4, -8 -#endif - mov r4, r0 - bl PLT_SYM(_C_LABEL(__errno)) - str r4, [r0] -#ifdef __thumb__ - movs r0, #0 - mvns r0, r0 -#else - mvn r0, #0 -#endif - mov r1, r0 - pop {r4, pc} -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .cfi_endproc - .fnend -#endif -#else /* !_REENTRANT */ -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .fnstart - .cfi_startproc -#endif -#ifdef __PIC__ - /* Setup the GOT */ - ldr r3, .Lgot - add r3, r3, pc /* pc = &.LPIC0 */ - ldr r1, .Lerrno -.LPIC0: ldr r1, [r3, r1] -#else - ldr r1, .Lerrno -#endif /* __PIC__ */ - str r0, [r1] -#ifdef __thumb__ - movs r0, #0 - mvns r0, r0 -#else - mvn r0, #0 -#endif /* __thumb__ */ - mov r1, r0 - RET -#if defined(__ARM_EABI__) && defined(__UNWIND_TABLES__) - .cfi_endproc - .fnend -#endif - -#ifdef __PIC__ - .align 0 -.Lgot: - .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - .LPIC0 -#endif /* __PIC__ */ - .globl _C_LABEL(errno) - -.Lerrno: - .word PIC_SYM(_C_LABEL(errno), GOT) -#endif /* _REENTRANT */ -END(CERROR) diff --git a/lib/libc/arch/arm/sys/exect.S b/lib/libc/arch/arm/sys/exect.S deleted file mode 100644 index 07d9c5d86..000000000 --- a/lib/libc/arch/arm/sys/exect.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: exect.S,v 1.4 2003/08/07 16:42:04 agc Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)exect.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -PSEUDO(exect,execve) diff --git a/lib/libc/arch/arm/sys/fork.S b/lib/libc/arch/arm/sys/fork.S deleted file mode 100644 index 3f1a80e91..000000000 --- a/lib/libc/arch/arm/sys/fork.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: fork.S,v 1.7 2013/08/16 22:28:05 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)fork.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -/* - * pid = fork(); - * - * On return from the SWI: - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - */ - -_SYSCALL(__fork,fork) - subs r1, r1, #1 /* r1 == 0xffffffff if parent, 0 if child */ - ands r0, r0, r1 /* r0 == 0 if child, else unchanged */ - RET -END(__fork) diff --git a/lib/libc/arch/arm/sys/getcontext.S b/lib/libc/arch/arm/sys/getcontext.S deleted file mode 100644 index 446477076..000000000 --- a/lib/libc/arch/arm/sys/getcontext.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.10 2013/09/03 00:30:19 matt Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -ENTRY(_getcontext) - mov r2, r0 /* Must save argument pointer. */ - SYSTRAP (getcontext) - _INVOKE_CERROR() -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - str lr, [r2, #_UC_REGS_PC] /* Adjust PC. */ -#else - mov r3, lr - str r3, [r2, #_UC_REGS_PC] /* Adjust PC. */ -#endif -#ifdef SOFTFLOAT - /* Ahem. */ - /* Judging from the softfloat code we should at least save - the exception codes and rounding mode here. */ -#endif - movs r0, #0 - str r0, [r2, #_UC_REGS_R0] /* Return 0. */ - RET -END(_getcontext) diff --git a/lib/libc/arch/arm/sys/pipe.S b/lib/libc/arch/arm/sys/pipe.S deleted file mode 100644 index cc0d98b01..000000000 --- a/lib/libc/arch/arm/sys/pipe.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: pipe.S,v 1.8 2013/08/16 22:21:59 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)pipe.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe) - mov r2, r0 - SYSTRAP(pipe) - _INVOKE_CERROR() - stmia r2!, {r0-r1} - movs r0, #0 - RET -END(_pipe) diff --git a/lib/libc/arch/arm/sys/ptrace.S b/lib/libc/arch/arm/sys/ptrace.S deleted file mode 100644 index a01078658..000000000 --- a/lib/libc/arch/arm/sys/ptrace.S +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.12 2013/11/30 20:20:42 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)ptrace.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -ENTRY(ptrace) -#ifdef _REENTRANT -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - push {r0-r3, lr} -#else - push {r0-r4} - mov r4, lr -#endif - sub sp, sp, #4 /* align stack */ - bl PLT_SYM(_C_LABEL(__errno)) - add sp, sp, #4 /* unalign stack */ - movs r1, #0 - str r1, [r0] -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) - pop {r0-r3, lr} -#else - mov lr, r4 - pop {r0-r4} -#endif -#else - push {r0, r1} -#ifdef __PIC__ - /* Setup the GOT */ - ldr r0, .Lgot - adr r1, .Lgot - add r0, r0, r1 - ldr r1, .Lerrno - ldr r1, [r0, r1] -#else - ldr r1, .Lerrno -#endif /* __PIC__ */ - movs r0, #0 - str r0, [r1] - pop {r0, r1} -#endif /* _REENTRANT */ - - SYSTRAP(ptrace) - _INVOKE_CERROR() - RET - -#ifndef _REENTRANT -#ifdef __PIC__ - .align 0 -.Lgot: - .word _C_LABEL(_GLOBAL_OFFSET_TABLE_) - .Lgot -#endif /* __PIC__ */ - -.Lerrno: - .word PIC_SYM(_C_LABEL(errno), GOT) -#endif /* !_REENTRANT */ -END(ptrace) diff --git a/lib/libc/arch/arm/sys/sbrk.S b/lib/libc/arch/arm/sys/sbrk.S deleted file mode 100644 index c9008dfe0..000000000 --- a/lib/libc/arch/arm/sys/sbrk.S +++ /dev/null @@ -1,80 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.12 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data - .align 0 - .globl _C_LABEL(__curbrk) - .hidden _C_LABEL(__curbrk) - .type _C_LABEL(__curbrk),#object -_C_LABEL(__curbrk): - .word _C_LABEL(_end) - -/* - * Change the data segment size - */ -ENTRY(_sbrk) - /* get address or offset to __curbrk */ - ldr r2, .Lcurbrk -#ifdef __PIC__ - add r2, r2, pc /* pc = &.LPIC0 */ -#endif - - /* Get the current brk address */ - ldr r1, [r2] - - /* Calculate new value */ -.LPIC0: mov r3, r0 - adds r0, r0, r1 - SYSTRAP(break) - _INVOKE_CERROR() - - /* Store new curbrk value */ - ldr r0, [r2] - adds r1, r0, r3 - str r1, [r2] - - /* Return old curbrk value */ - RET - - .align 0 -.Lcurbrk: - .word REL_SYM(_C_LABEL(__curbrk), .LPIC0) -END(_sbrk) diff --git a/lib/libc/arch/arm/sys/shmat.S b/lib/libc/arch/arm/sys/shmat.S deleted file mode 100644 index 13bdd0d87..000000000 --- a/lib/libc/arch/arm/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/12/29 20:14:04 bjh21 Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/arm/sys/syscall.S b/lib/libc/arch/arm/sys/syscall.S deleted file mode 100644 index 43c826145..000000000 --- a/lib/libc/arch/arm/sys/syscall.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: syscall.S,v 1.4 2003/08/07 16:42:05 agc Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -RSYSCALL(syscall) diff --git a/lib/libc/arch/hppa/DEFS.h b/lib/libc/arch/hppa/DEFS.h deleted file mode 100644 index 6e0125943..000000000 --- a/lib/libc/arch/hppa/DEFS.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: DEFS.h,v 1.1 2002/06/06 20:31:20 fredette Exp $ */ - -#include diff --git a/lib/libc/arch/hppa/Makefile.inc b/lib/libc/arch/hppa/Makefile.inc deleted file mode 100644 index 56254ab7d..000000000 --- a/lib/libc/arch/hppa/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.10 2014/02/19 13:01:51 skrll Exp $ - -# $OpenBSD: Makefile.inc,v 1.3 1999/12/25 06:02:10 mickey Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S - -SRCS+= bcopy.c - -CPPFLAGS+= -I. diff --git a/lib/libc/arch/hppa/SYS.h b/lib/libc/arch/hppa/SYS.h deleted file mode 100644 index 77287d3fe..000000000 --- a/lib/libc/arch/hppa/SYS.h +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: SYS.h,v 1.9 2014/03/06 19:02:58 skrll Exp $ */ - -/* $OpenBSD: SYS.h,v 1.9 2001/09/20 20:52:09 millert Exp $ */ - -/* - * Copyright (c) 1998-2002 Michael Shalayeff - * 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 ``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 MIND - * 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 -#include -#include -#undef _LOCORE -#define _LOCORE -#include - -#define SYSENTRY(x) LEAF_ENTRY(x) -#define SYSEXIT(x) EXIT(x) - -#define SYSCALL(x) !\ - stw %rp, HPPA_FRAME_ERP(%sr0,%sp) !\ - ldil L%SYSCALLGATE, %r1 !\ - ble 4(%sr2, %r1) !\ - ldi __CONCAT(SYS_,x), %t1 !\ - .import __cerror, code !\ - comb,<> %r0, %t1, __cerror !\ - ldw HPPA_FRAME_ERP(%sr0,%sp), %rp - -#define PSEUDO(x,y) !\ -SYSENTRY(x) !\ - SYSCALL(y) !\ - bv %r0(%rp) !\ - nop !\ -SYSEXIT(x) - -#define PSEUDO_NOERROR(x,y) !\ -SYSENTRY(x) !\ - stw %rp, HPPA_FRAME_ERP(%sr0,%sp) !\ - ldil L%SYSCALLGATE, %r1 !\ - ble 4(%sr2, %r1) !\ - ldi __CONCAT(SYS_,y), %t1 !\ - ldw HPPA_FRAME_ERP(%sr0,%sp), %rp !\ - bv %r0(%rp) !\ - nop !\ -SYSEXIT(x) - -#define RSYSCALL(x) PSEUDO(x,x) -#define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x) - -#ifdef WEAK_ALIAS -#define WSYSCALL(weak,strong) !\ - WEAK_ALIAS(weak,strong) !\ - PSEUDO(strong,weak) -#else -#define WSYSCALL(weak,strong) !\ - PSEUDO(weak,weak) -#endif diff --git a/lib/libc/arch/hppa/gdtoa/Makefile.inc b/lib/libc/arch/hppa/gdtoa/Makefile.inc deleted file mode 100644 index 1d786e010..000000000 --- a/lib/libc/arch/hppa/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/hppa/gdtoa/arith.h b/lib/libc/arch/hppa/gdtoa/arith.h deleted file mode 100644 index 4674f629c..000000000 --- a/lib/libc/arch/hppa/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_BIG_ENDIAN diff --git a/lib/libc/arch/hppa/gdtoa/gd_qnan.h b/lib/libc/arch/hppa/gdtoa/gd_qnan.h deleted file mode 100644 index b9e91e70f..000000000 --- a/lib/libc/arch/hppa/gdtoa/gd_qnan.h +++ /dev/null @@ -1,11 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define f_QNAN 0x7fa00000 -#define d_QNAN0 0x7ff40000 -#define d_QNAN1 0x0 -#ifdef _LP64 -#define ld_QNAN0 0x7fff4000 -#define ld_QNAN1 0x0 -#define ld_QNAN2 0x0 -#define ld_QNAN3 0x0 -#endif diff --git a/lib/libc/arch/hppa/gen/Makefile.inc b/lib/libc/arch/hppa/gen/Makefile.inc deleted file mode 100644 index 24ab0e5cc..000000000 --- a/lib/libc/arch/hppa/gen/Makefile.inc +++ /dev/null @@ -1,20 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.15 2006/06/28 14:46:32 drochner Exp $ - -SRCS+= bswap16.c bswap32.c bswap64.c -SRCS+= fabs.c -SRCS+= __sigsetjmp14.S __setjmp14.S _setjmp.S __longjmp14.c - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c - -SRCS+= makecontext.c resumecontext.c _resumecontext.S swapcontext.S _lwp.c - -SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c diff --git a/lib/libc/arch/hppa/gen/__longjmp14.c b/lib/libc/arch/hppa/gen/__longjmp14.c deleted file mode 100644 index 04ab4ee73..000000000 --- a/lib/libc/arch/hppa/gen/__longjmp14.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $NetBSD: __longjmp14.c,v 1.5 2012/03/22 12:31:32 skrll Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christian Limpach. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include - -#include -#include - -ssize_t _sys_write(int, void *, size_t); - -void -__longjmp14(jmp_buf env, int val) -{ - ucontext_t uc; - struct sigcontext *sc = (void *)env; - register_t *regs = (void *)(sc + 1); - register register_t dp __asm("r27"); - - /* Ensure non-zero SP */ - if (sc->sc_sp == 0) - goto err; - - /* Make return value non-zero */ - if (val == 0) - val = 1; - - /* Copy callee-saved regs */ - regs -= 3; - uc.uc_mcontext.__gregs[3] = regs[3]; - uc.uc_mcontext.__gregs[4] = regs[4]; - uc.uc_mcontext.__gregs[5] = regs[5]; - uc.uc_mcontext.__gregs[6] = regs[6]; - uc.uc_mcontext.__gregs[7] = regs[7]; - uc.uc_mcontext.__gregs[8] = regs[8]; - uc.uc_mcontext.__gregs[9] = regs[9]; - uc.uc_mcontext.__gregs[10] = regs[10]; - uc.uc_mcontext.__gregs[11] = regs[11]; - uc.uc_mcontext.__gregs[12] = regs[12]; - uc.uc_mcontext.__gregs[13] = regs[13]; - uc.uc_mcontext.__gregs[14] = regs[14]; - uc.uc_mcontext.__gregs[15] = regs[15]; - uc.uc_mcontext.__gregs[16] = regs[16]; - uc.uc_mcontext.__gregs[17] = regs[17]; - uc.uc_mcontext.__gregs[18] = regs[18]; - - /* Preserve the current value of DP */ - /* LINTED dp is r27, so is "initialized" */ - uc.uc_mcontext.__gregs[27] = dp; - - /* Set the desired return value. */ - uc.uc_mcontext.__gregs[_REG_RET0] = val; - - /* - * Set _UC_{SET,CLR}STACK according to SS_ONSTACK. - * - * Restore the signal mask with sigprocmask() instead of _UC_SIGMASK, - * since libpthread may want to interpose on signal handling. - */ - uc.uc_flags = _UC_CPU | (sc->sc_onstack ? _UC_SETSTACK : _UC_CLRSTACK); - - sigprocmask(SIG_SETMASK, &sc->sc_mask, NULL); - - /* Clear uc_link */ - uc.uc_link = 0; - - /* Copy signal mask */ - uc.uc_sigmask = sc->sc_mask; - - /* Copy special regs */ - uc.uc_mcontext.__gregs[_REG_PSW] = sc->sc_ps; - uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_sp; - uc.uc_mcontext.__gregs[_REG_PCSQH] = sc->sc_pcsqh; - uc.uc_mcontext.__gregs[_REG_PCOQH] = sc->sc_pcoqh; - uc.uc_mcontext.__gregs[_REG_PCSQT] = sc->sc_pcsqt; - uc.uc_mcontext.__gregs[_REG_PCOQT] = sc->sc_pcoqt; - - setcontext(&uc); - err: - longjmperror(); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/hppa/gen/__setjmp14.S b/lib/libc/arch/hppa/gen/__setjmp14.S deleted file mode 100644 index 4777b21f8..000000000 --- a/lib/libc/arch/hppa/gen/__setjmp14.S +++ /dev/null @@ -1,131 +0,0 @@ -/* $NetBSD: __setjmp14.S,v 1.5 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matthew Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -/* XXX fredette - this is awful */ -#define _LOCORE -#include -#undef _LOCORE -#include - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __setjmp14.S,v 1.5 2008/04/28 20:22:55 martin Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -ENTRY(__setjmp14,0) - /* Finish our stack frame. */ - stw %rp, HPPA_FRAME_CRP(%sp) - stw %arg0, HPPA_FRAME_ARG(0)(%sp) - - /* A sigcontext is at the beginning of our jmp_buf. */ - stw %r0, 4(%arg0) ; unused word (old style signal mask) - stw %sp, 8(%arg0) ; sc.sc_sp = %sp - stw %r0, 16(%arg0) ; sc.sc_ap = NULL - mfsp %sr0, %r1 - stw %r1, 20(%arg0) ; sc.sc_pcsqh = %sr0 - stw %rp, 24(%arg0) ; sc.sc_pcoqh = %rp - stw %r1, 28(%arg0) ; sc.sc_pcsqh = %sr0 - ldo 4(%rp), %r1 - stw %r1, 32(%arg0) ; sc.sc_pcoqt = %rp + 4 -#define PSW_MBS (PSW_C|PSW_Q|PSW_P|PSW_D|PSW_I) - ldil L%PSW_MBS, %r1 - ldo R%PSW_MBS(%r1), %r1 - stw %r1, 36(%arg0) ; set sc.sc_ps - - /* We store all callee-saved registers after the sigcontext. */ - ldo 56(%arg0), %r1 - stwm %r3, 4(%r1) - stwm %r4, 4(%r1) - stwm %r5, 4(%r1) - stwm %r6, 4(%r1) - stwm %r7, 4(%r1) - stwm %r8, 4(%r1) - stwm %r9, 4(%r1) - stwm %r10, 4(%r1) - stwm %r11, 4(%r1) - stwm %r12, 4(%r1) - stwm %r13, 4(%r1) - stwm %r14, 4(%r1) - stwm %r15, 4(%r1) - stwm %r16, 4(%r1) - stwm %r17, 4(%r1) - stwm %r18, 4(%r1) - - /* - * Start the stack frame for the calls we will make. - * The minimum frame is 48 bytes, but the stack must - * always be 64-byte aligned; we use the top 4 bytes - * to save our caller's %r3, and the following 12 bytes - * as the stack_t for our sigaltstack call. - * XXX - this assumes that sizeof(stack_t) <= 12 - */ - copy %r3, %r1 - copy %sp, %r3 - stwm %r1, HPPA_FRAME_SIZE(%sp) - - /* Get signal stack info. */ - ldo 4(%r3), %arg1 ; set up oss - bl __sigaltstack14, %rp - copy %r0, %arg0 ; set up ss - - /* Recover our jmp_buf and extract SS_ONSTACK */ - ldw HPPA_FRAME_ARG(0)(%r3), %arg0 - ldw 12(%r3), %r1 ; get ss_flags - ldi 1, %r20 ; SS_ONSTACK - and %r1, %r20, %r1 - stw %r1, 0(%arg0) ; sc.sc_onstack - - /* Get the signal mask. */ - ldo 40(%arg0), %arg2 ; oset = &sc.sc_mask - copy %r0, %arg1 ; set = NULL - bl __sigprocmask14, %rp - copy %r0, %arg0 ; action = 0 - - /* Return 0. */ - ldo HPPA_FRAME_SIZE(%r3),%sp - ldwm -HPPA_FRAME_SIZE(%sp),%r3 - ldw HPPA_FRAME_CRP(%sp), %rp - bv %r0(%rp) - copy %r0, %ret0 -EXIT(__setjmp14) - - .end diff --git a/lib/libc/arch/hppa/gen/__sigsetjmp14.S b/lib/libc/arch/hppa/gen/__sigsetjmp14.S deleted file mode 100644 index 6e1f154e3..000000000 --- a/lib/libc/arch/hppa/gen/__sigsetjmp14.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.2 2008/04/28 20:22:55 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matthew Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __sigsetjmp14.S,v 1.2 2008/04/28 20:22:55 martin Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a,m) - * by restoring registers from the stack, - * The previous signal state is restored if 'm' was non-zero. - */ - -/* grab _JBLEN */ -#include - -ENTRY(__sigsetjmp14,0) - stw %arg1, (_JBLEN * 4)(%arg0) ; save mask at end of area - add,<> %r0, %arg0, %r0 - b,n _setjmp - b,n __setjmp14 -EXIT(__sigsetjmp14) - - -ENTRY(__siglongjmp14,0) - ldw (_JBLEN * 4)(%arg0), %r1 - add,<> %r0, %r1, %r0 - b,n _longjmp - b,n __longjmp14 -EXIT(__siglongjmp14) - - .end diff --git a/lib/libc/arch/hppa/gen/_lwp.c b/lib/libc/arch/hppa/gen/_lwp.c deleted file mode 100644 index 631ce8b66..000000000 --- a/lib/libc/arch/hppa/gen/_lwp.c +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $ */ - -/* - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Wayne Knowles - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.5 2011/02/24 04:28:42 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - caddr_t sp; - __greg_t *gr; - __greg_t *gp; - __greg_t fp; - - getcontext(u); - gr = u->uc_mcontext.__gregs; - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - sp = stack_base + HPPA_FRAME_SIZE; - - fp = (__greg_t)start; - if (fp & 2) { - gp = (__greg_t *)(fp & ~3); - fp = gp[0]; - gr[_REG_R19] = gp[1]; - } - gr[_REG_PCOQH] = fp | HPPA_PC_PRIV_USER; - gr[_REG_PCOQT] = (fp + 4) | HPPA_PC_PRIV_USER; - gr[_REG_RP] = (__greg_t) _lwp_exit; - gr[_REG_ARG0] = (__greg_t) arg; - gr[_REG_SP] = (__greg_t) sp; - gr[_REG_CR27] = (__greg_t) private; -} diff --git a/lib/libc/arch/hppa/gen/_resumecontext.S b/lib/libc/arch/hppa/gen/_resumecontext.S deleted file mode 100644 index 2209e13ed..000000000 --- a/lib/libc/arch/hppa/gen/_resumecontext.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: _resumecontext.S,v 1.4 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Wayne Knowles. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#include -#include - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: _resumecontext.S,v 1.4 2013/09/12 15:36:15 joerg Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - - .import _resumecontext, code - -LEAF_ENTRY_NOPROFILE(__resumecontext) -#ifdef __PIC__ - ldw HPPA_FRAME_EDP(%sp), %r19 - addil LT%_C_LABEL(_resumecontext), %r19 - ldw RT%_C_LABEL(_resumecontext)(%r1), %r1 -#else - ldil L%_C_LABEL(_resumecontext), %r1 - ldo R%_C_LABEL(_resumecontext)(%r1), %r1 -#endif - bv,n %r0(%r1) -EXIT(__resumecontext) - .end diff --git a/lib/libc/arch/hppa/gen/_setjmp.S b/lib/libc/arch/hppa/gen/_setjmp.S deleted file mode 100644 index 9d7c74cb4..000000000 --- a/lib/libc/arch/hppa/gen/_setjmp.S +++ /dev/null @@ -1,128 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.4 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matthew Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -/* XXX fredette - this is awful */ -#define _LOCORE -#include -#undef _LOCORE - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: _setjmp.S,v 1.4 2008/04/28 20:22:56 martin Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -ENTRY(_setjmp,0) - /* A sigcontext is at the beginning of our jmp_buf. */ - stw %r0, 0(%arg0) ; no onstack - stw %r0, 4(%arg0) ; unused word (old style signal mask) - stw %sp, 8(%arg0) ; sc.sc_sp = %sp - stw %r0, 16(%arg0) ; sc.sc_ap = NULL - mfsp %sr0, %r1 - stw %r1, 20(%arg0) ; sc.sc_pcsqh = %sr0 - stw %rp, 24(%arg0) ; sc.sc_pcoqh = %rp - stw %r1, 28(%arg0) ; sc.sc_pcsqh = %sr0 - ldo 4(%rp), %r1 - stw %r1, 32(%arg0) ; sc.sc_pcoqt = %rp + 4 - stw %r0, 36(%arg0) ; set sc.sc_ps - - /* We store all callee-saved registers after the sigcontext. */ - ldo 56(%arg0), %r1 - stwm %r3, 4(%r1) - stwm %r4, 4(%r1) - stwm %r5, 4(%r1) - stwm %r6, 4(%r1) - stwm %r7, 4(%r1) - stwm %r8, 4(%r1) - stwm %r9, 4(%r1) - stwm %r10, 4(%r1) - stwm %r11, 4(%r1) - stwm %r12, 4(%r1) - stwm %r13, 4(%r1) - stwm %r14, 4(%r1) - stwm %r15, 4(%r1) - stwm %r16, 4(%r1) - stwm %r17, 4(%r1) - stwm %r18, 4(%r1) - - /* Return 0. */ - bv %r0(%rp) - copy %r0, %ret0 -EXIT(_setjmp) - -ENTRY(_longjmp,0) - ldw 8(%arg0), %r1 ; ensure non-zero SP - combt,=,n %r0, %r1, botch ; oops! - add,<> %r0, %arg1, %ret0 ; ensure return value non-zero - ldi 1, %ret0 - - /* restore callee-saved registers */ - ldo 56(%arg0), %r1 - ldwm 4(%r1), %r3 - ldwm 4(%r1), %r4 - ldwm 4(%r1), %r5 - ldwm 4(%r1), %r6 - ldwm 4(%r1), %r7 - ldwm 4(%r1), %r8 - ldwm 4(%r1), %r9 - ldwm 4(%r1), %r10 - ldwm 4(%r1), %r11 - ldwm 4(%r1), %r12 - ldwm 4(%r1), %r13 - ldwm 4(%r1), %r14 - ldwm 4(%r1), %r15 - ldwm 4(%r1), %r16 - ldwm 4(%r1), %r17 - ldwm 4(%r1), %r18 - - /* restore the rest */ - ldw 8(%arg0), %sp - ldw 24(%arg0), %rp - bv %r0(%rp) - nop -botch: - bl longjmperror, %rp - nop - bl abort, %rp - nop -EXIT(_longjmp) - - .end diff --git a/lib/libc/arch/hppa/gen/fabs.c b/lib/libc/arch/hppa/gen/fabs.c deleted file mode 100644 index f08f504c2..000000000 --- a/lib/libc/arch/hppa/gen/fabs.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: fabs.c,v 1.4 2005/12/24 21:42:32 perry Exp $ */ - -/* $OpenBSD: fabs.c,v 1.3 2002/10/21 18:41:05 mickey Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain - */ - -#include - -double -fabs(double val) -{ - - __asm volatile("fabs,dbl %0,%0" : "+f" (val)); - return (val); -} diff --git a/lib/libc/arch/hppa/gen/flt_rounds.c b/lib/libc/arch/hppa/gen/flt_rounds.c deleted file mode 100644 index 179fb60b0..000000000 --- a/lib/libc/arch/hppa/gen/flt_rounds.c +++ /dev/null @@ -1,31 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.5 2012/03/23 09:34:09 skrll Exp $ */ - -/* $OpenBSD: flt_rounds.c,v 1.3 2002/10/21 18:41:05 mickey Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.5 2012/03/23 09:34:09 skrll Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 0, /* round to zero */ - 2, /* round to positive infinity */ - 3 /* round to negative infinity */ -}; - -int -__flt_rounds(void) -{ - uint64_t fpsr; - - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); - return map[(unsigned int)(fpsr >> 41) & 0x03]; -} diff --git a/lib/libc/arch/hppa/gen/fpgetmask.c b/lib/libc/arch/hppa/gen/fpgetmask.c deleted file mode 100644 index cedf4797a..000000000 --- a/lib/libc/arch/hppa/gen/fpgetmask.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.5 2012/03/23 09:34:09 skrll Exp $ */ - -/* $OpenBSD: fpgetmask.c,v 1.3 2002/10/21 18:41:05 mickey Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.5 2012/03/23 09:34:09 skrll Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -fp_except -fpgetmask(void) -{ - uint64_t fpsr; - - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); - return ((fp_except)(fpsr >> 32) & 0x1f); -} diff --git a/lib/libc/arch/hppa/gen/fpgetround.c b/lib/libc/arch/hppa/gen/fpgetround.c deleted file mode 100644 index f0feb3167..000000000 --- a/lib/libc/arch/hppa/gen/fpgetround.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.5 2012/03/23 09:34:09 skrll Exp $ */ - -/* $OpenBSD: fpgetround.c,v 1.3 2002/10/21 18:41:05 mickey Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.5 2012/03/23 09:34:09 skrll Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -fp_rnd -fpgetround(void) -{ - uint64_t fpsr; - - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); - return ((fp_rnd)(fpsr >> 41) & 0x3); -} diff --git a/lib/libc/arch/hppa/gen/fpgetsticky.c b/lib/libc/arch/hppa/gen/fpgetsticky.c deleted file mode 100644 index 9e424abeb..000000000 --- a/lib/libc/arch/hppa/gen/fpgetsticky.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.5 2012/03/23 09:34:09 skrll Exp $ */ - -/* $OpenBSD: fpgetsticky.c,v 1.3 2002/10/21 18:41:05 mickey Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.5 2012/03/23 09:34:09 skrll Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -fp_except -fpgetsticky(void) -{ - uint64_t fpsr; - - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr)); - return ((fp_except)(fpsr >> 59) & 0x1f); -} diff --git a/lib/libc/arch/hppa/gen/fpsetmask.c b/lib/libc/arch/hppa/gen/fpsetmask.c deleted file mode 100644 index b1761b07e..000000000 --- a/lib/libc/arch/hppa/gen/fpsetmask.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.6 2012/03/23 09:34:09 skrll Exp $ */ - -/* $OpenBSD: fpsetmask.c,v 1.4 2004/01/05 06:06:16 otto Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.6 2012/03/23 09:34:09 skrll Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -fp_except -fpsetmask(fp_except mask) -{ - uint64_t fpsr; - fp_except old; - - __asm volatile("fstd %%fr0,0(%1)" : "=m"(fpsr) : "r"(&fpsr) : "memory"); - old = (fp_except)(fpsr >> 32) & 0x1f; - fpsr = (fpsr & 0xffffffe000000000LL) | ((uint64_t)(mask & 0x1f) << 32); - __asm volatile("fldd 0(%0),%%fr0" : : "r"(&fpsr) : "memory"); - return (old); -} diff --git a/lib/libc/arch/hppa/gen/fpsetround.c b/lib/libc/arch/hppa/gen/fpsetround.c deleted file mode 100644 index f9f631666..000000000 --- a/lib/libc/arch/hppa/gen/fpsetround.c +++ /dev/null @@ -1,29 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.6 2012/03/23 09:34:09 skrll Exp $ */ - -/* $OpenBSD: fpsetround.c,v 1.3 2002/10/21 18:41:05 mickey Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.6 2012/03/23 09:34:09 skrll Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - uint64_t fpsr; - fp_rnd old; - - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr) : "memory"); - old = (fp_rnd)(fpsr >> 41) & 0x03; - fpsr = (fpsr & 0xfffff9ff00000000LL) | - ((uint64_t)(rnd_dir & 0x03) << 41); - __asm volatile("fldd 0(%0),%%fr0" : : "r" (&fpsr) : "memory"); - return (old); -} diff --git a/lib/libc/arch/hppa/gen/fpsetsticky.c b/lib/libc/arch/hppa/gen/fpsetsticky.c deleted file mode 100644 index c9dce7a73..000000000 --- a/lib/libc/arch/hppa/gen/fpsetsticky.c +++ /dev/null @@ -1,29 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.6 2012/03/23 09:34:09 skrll Exp $ */ - -/* $OpenBSD: fpsetsticky.c,v 1.4 2004/01/05 06:06:16 otto Exp $ */ - -/* - * Written by Miodrag Vallat. Public domain - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.6 2012/03/23 09:34:09 skrll Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -fp_except -fpsetsticky(fp_except mask) -{ - uint64_t fpsr; - fp_except old; - - __asm volatile("fstd %%fr0,0(%1)" : "=m" (fpsr) : "r" (&fpsr) : "memory"); - old = (fp_except)(fpsr >> 59) & 0x1f; - fpsr = (fpsr & 0x07ffffff00000000LL) | ((uint64_t)(mask & 0x1f) << 59); - __asm volatile("fldd 0(%0),%%fr0" : : "r" (&fpsr) : "memory"); - - return (old); -} diff --git a/lib/libc/arch/hppa/gen/makecontext.c b/lib/libc/arch/hppa/gen/makecontext.c deleted file mode 100644 index 5a03f2388..000000000 --- a/lib/libc/arch/hppa/gen/makecontext.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.6 2012/03/22 12:31:32 skrll Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.6 2012/03/22 12:31:32 skrll Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -#include -#include - -void __resumecontext(void) __dead; - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - __greg_t *gp, rp, fp; - register __greg_t dp __asm("r27"); - uintptr_t *sp; - int i; - va_list ap; - - /* LINTED uintptr_t is safe */ - sp = (uintptr_t *)ucp->uc_stack.ss_sp; - /* LINTED uintptr_t is safe */ - sp += 16; /* standard frame */ - sp += (argc >= 4 ? argc : 4); /* Make room for >=4 arguments. */ - sp = (uintptr_t *) - ((uintptr_t)(sp + 16) & ~0x3f); /* Align on 64-byte boundary. */ - - /* Save away the registers that we'll need. */ - gr[_REG_SP] = (__greg_t)sp; - rp = (__greg_t)__resumecontext; - if (rp & 2) { - gp = (__greg_t *)(rp & ~3); - rp = gp[0]; - sp[-8] = gp[1]; - } - gr[_REG_RP] = rp; - fp = (__greg_t)func; - if (fp & 2) { - gp = (__greg_t *)(fp & ~3); - fp = gp[0]; - gr[_REG_R19] = gp[1]; - } - gr[_REG_PCOQH] = fp | HPPA_PC_PRIV_USER; - gr[_REG_PCOQT] = (fp + 4) | HPPA_PC_PRIV_USER; - /* LINTED dp is reg27, ref. above, so initialized */ - gr[_REG_DP] = dp; - - /* Construct argument list. */ - va_start(ap, argc); - /* Up to the first four arguments are passed in %arg0-3. */ - for (i = 0; i < argc && i < 4; i++) { - /* LINTED uintptr_t is safe */ - gr[_REG_ARG0 - i] = va_arg(ap, uintptr_t); - } - /* Pass remaining arguments on the stack below the %arg0-3 gap. */ - for (; i < argc; i++) { - /* LINTED uintptr_t is safe */ - sp[-9 - i] = va_arg(ap, uintptr_t); - } - va_end(ap); -} diff --git a/lib/libc/arch/hppa/gen/nanf.c b/lib/libc/arch/hppa/gen/nanf.c deleted file mode 100644 index b95319bf9..000000000 --- a/lib/libc/arch/hppa/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.2 2009/02/22 01:34:01 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.2 2009/02/22 01:34:01 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xa0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/hppa/gen/resumecontext.c b/lib/libc/arch/hppa/gen/resumecontext.c deleted file mode 100644 index c01ed2f17..000000000 --- a/lib/libc/arch/hppa/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2013/08/24 07:12:13 skrll Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2013/08/24 07:12:13 skrll Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/hppa/gen/swapcontext.S b/lib/libc/arch/hppa/gen/swapcontext.S deleted file mode 100644 index 7d20617ba..000000000 --- a/lib/libc/arch/hppa/gen/swapcontext.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.6 2014/02/19 13:01:51 skrll Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#include - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.6 2014/02/19 13:01:51 skrll Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -LEAF_ENTRY(swapcontext) - stw %rp, HPPA_FRAME_CRP(%sp) - stw %arg0, HPPA_FRAME_ARG(0)(%sp) - stw %arg1, HPPA_FRAME_ARG(1)(%sp) - SYSCALL(getcontext) - - ldw HPPA_FRAME_ARG(0)(%sp), %arg1 - ldw HPPA_FRAME_ARG(1)(%sp), %arg0 - - ldw HPPA_FRAME_CRP(%sp), %rp - ldo 4(%rp), %r1 - stw %r1, (_OFFSETOF_UC_GREGS + _REG_PCOQT * SZREG)(%arg1) - stw %rp, (_OFFSETOF_UC_GREGS + _REG_PCOQH * SZREG)(%arg1) - bl setcontext, %rp - stw %r0, (_OFFSETOF_UC_GREGS + _REG_RET0 * SZREG)(%arg1) - - ldw HPPA_FRAME_CRP(%sp), %rp - bv,n %r0(%rp) -EXIT(swapcontext) - .end diff --git a/lib/libc/arch/hppa/genassym.cf b/lib/libc/arch/hppa/genassym.cf deleted file mode 100644 index ac3221044..000000000 --- a/lib/libc/arch/hppa/genassym.cf +++ /dev/null @@ -1,39 +0,0 @@ -# $NetBSD: genassym.cf,v 1.1 2014/02/19 13:01:51 skrll Exp $ - -# -# Copyright (c) 2014 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Nick Hudson -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include - -define _REG_PCOQH _REG_PCOQH -define _REG_PCOQT _REG_PCOQT -define _REG_RET0 _REG_RET0 - -define _OFFSETOF_UC_GREGS offsetof(ucontext_t, uc_mcontext.__gregs[0]) diff --git a/lib/libc/arch/hppa/net/Makefile.inc b/lib/libc/arch/hppa/net/Makefile.inc deleted file mode 100644 index e3e9f6774..000000000 --- a/lib/libc/arch/hppa/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2002/06/06 20:31:21 fredette Exp $ - -SRCS += ntohl.c ntohs.c htons.c htonl.c - diff --git a/lib/libc/arch/hppa/stdlib/Makefile.inc b/lib/libc/arch/hppa/stdlib/Makefile.inc deleted file mode 100644 index d1dda0262..000000000 --- a/lib/libc/arch/hppa/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/07/31 20:39:59 dsl Exp $ diff --git a/lib/libc/arch/hppa/string/Makefile.inc b/lib/libc/arch/hppa/string/Makefile.inc deleted file mode 100644 index f00669afd..000000000 --- a/lib/libc/arch/hppa/string/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2009/07/30 20:57:16 dsl Exp $ - -# $OpenBSD: Makefile.inc,v 1.4 1999/09/14 00:46:18 mickey Exp $ - -SRCS+= bcmp.S bzero.S ffs.S - -# NetBSD doesn't currently let archs supply a strlcpy.S. -# plus, the one that fredette made is untested. -#SRCS+= strlcpy.S - diff --git a/lib/libc/arch/hppa/string/bcmp.S b/lib/libc/arch/hppa/string/bcmp.S deleted file mode 100644 index 6e2263fe8..000000000 --- a/lib/libc/arch/hppa/string/bcmp.S +++ /dev/null @@ -1,84 +0,0 @@ -/* $NetBSD: bcmp.S,v 1.2 2003/10/06 05:30:21 matt Exp $ */ - -/* $OpenBSD: bcmp.S,v 1.3 2001/06/04 23:14:02 mickey Exp $ */ - -/* - * Copyright 1996 1995 by Open Software Foundation, Inc. - * All Rights Reserved - * - * Permission to use, copy, modify, and distribute this software and - * its documentation for any purpose and without fee is hereby granted, - * provided that the above copyright notice appears in all copies and - * that both the copyright notice and this permission notice appear in - * supporting documentation. - * - * OSF DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE. - * - * IN NO EVENT SHALL OSF BE LIABLE FOR ANY SPECIAL, INDIRECT, OR - * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN ACTION OF CONTRACT, - * NEGLIGENCE, OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION - * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -/* - * (c) Copyright 1988 HEWLETT-PACKARD COMPANY - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the - * suitability of this software for any purpose. - */ -/* - * Copyright (c) 1990,1991,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS" - * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES - * WHATSOEVER RESULTING FROM ITS USE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah Hdr: movc.s 1.26 94/12/14 - */ - -#include - -#ifdef SYSLIBC_SCCS - .text - .asciz "$OpenBSD: bcmp.S,v 1.3 2001/06/04 23:14:02 mickey Exp $" - .align 4 -#endif - -/* - * int - * bcmp(src, dst, count) - * vaddr_t src; - * vaddr_t dst; - * size_t count; - */ -LEAF_ENTRY(bcmp) - comb,>= %r0,%arg2,$bcmp_exit - copy %t1,%t2 - -$bcmp_loop: - ldbs,ma 1(%arg0),%t1 - ldbs,ma 1(%arg1),%t2 - comb,<>,n %t1,%t2,$bcmp_exit - addib,<> -1,%arg2,$bcmp_loop - nop - -$bcmp_exit: - bv 0(%r2) - sub %t1,%t2,%ret0 - -EXIT(bcmp) - diff --git a/lib/libc/arch/hppa/string/bzero.S b/lib/libc/arch/hppa/string/bzero.S deleted file mode 100644 index c14de6205..000000000 --- a/lib/libc/arch/hppa/string/bzero.S +++ /dev/null @@ -1,119 +0,0 @@ -/* $NetBSD: bzero.S,v 1.2 2003/10/06 05:30:21 matt Exp $ */ - -/* $OpenBSD: bzero.S,v 1.3 2001/06/04 23:14:02 mickey Exp $ */ - -/* - * (c) Copyright 1988 HEWLETT-PACKARD COMPANY - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the - * suitability of this software for any purpose. - */ -/* - * Copyright (c) 1990,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS" - * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES - * WHATSOEVER RESULTING FROM ITS USE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: bzero.s 1.9 94/12/14$ - * Author: Bob Wheeler, University of Utah CSL - */ - -#include - -#ifdef SYSLIBC_SCCS - .text - .asciz "$OpenBSD: bzero.S,v 1.3 2001/06/04 23:14:02 mickey Exp $" - .align 4 -#endif - -/* - * void - * bzero(dst, count) - * void *dst; - * size_t count; - */ -LEAF_ENTRY(bzero) - comb,>=,n %r0,%arg1,$bzero_exit - - /* - * If we need to clear less than a word do it a byte at a time - */ - - comib,>>,n 4,%arg1,$bzero_bytes - - /* - * Since we are only clearing memory the alignment restrictions - * are simplified. Figure out how many "extra" bytes we need to - * store with stbys. - */ - - extru %arg0,31,2,%t1 - add %arg1,%t1,%arg1 - - /* - * We will zero the destination in blocks of 16 bytes as long as we - * can and then we'll go to the 4 byte moves. - */ - - comib,>>= 15, %arg1, $bzero_word - addi -16, %arg1, %arg1 - -$bzero_loop_16: - stbys,b,m %r0,4(%arg0) - stwm %r0,4(%arg0) - stwm %r0,4(%arg0) - stwm %r0,4(%arg0) - comib,<< 15, %arg1, $bzero_loop_16 - addi -16, %arg1, %arg1 - - /* - * see if there is anything left that needs to be zeroed in a word - * move. Since the count was decremented by 16, add 12 to test if - * there are any full word moves left to do. - */ - -$bzero_word: - addib,<,n 12,%arg1,$bzero_cleanup - -$bzero_loop_4: - addib,>= -4,%arg1,$bzero_loop_4 - stbys,b,m %r0,4(%arg0) - - /* - * zero the last bytes that may be unaligned on a word boundary - */ - -$bzero_cleanup: - addib,=,n 4,%arg1,$bzero_exit - add %arg0,%arg1,%arg0 - b $bzero_exit - stbys,e %r0,0(%arg0) - b,n $bzero_exit - - - /* - * zero by bytes - */ - -$bzero_bytes: - addib,> -1,%arg1,$bzero_bytes - stbs,ma %r0,1(%arg0) - -$bzero_exit: - bv,n %r0(%rp) -EXIT(bzero) - - .end diff --git a/lib/libc/arch/hppa/string/ffs.S b/lib/libc/arch/hppa/string/ffs.S deleted file mode 100644 index a4754a721..000000000 --- a/lib/libc/arch/hppa/string/ffs.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: ffs.S,v 1.3 2004/07/18 20:30:04 chs Exp $ */ - -/* $OpenBSD: ffs.S,v 1.3 2001/06/04 23:14:02 mickey Exp $ */ - -/* - * Copyright (c) 1990, 1991, 1992, 1994, The University of Utah and - * the Computer Systems Laboratory at the University of Utah (CSL). - * All rights reserved. - * - * 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. - * - * THE UNIVERSITY OF UTAH AND CSL ALLOW FREE USE OF THIS SOFTWARE IN ITS "AS - * IS" CONDITION. THE UNIVERSITY OF UTAH AND CSL DISCLAIM ANY LIABILITY OF - * ANY KIND FOR ANY DAMAGES WHATSOEVER RESULTING FROM THE USE OF THIS SOFTWARE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - */ - -#include - -#ifdef SYSLIBC_SCCS - .text - .asciz "$OpenBSD: ffs.S,v 1.3 2001/06/04 23:14:02 mickey Exp $" - .align 4 -#endif - -/* - * ffs(bitmask) - * - * Return the position of the "most significant" bit in `bitmask'. - * Since this is similar to the VAX ffs instruction, bits in a word - * are numbered as "32, 31, ... 1", 0 is returned if no bits are set. - */ - -LEAF_ENTRY(ffs) - comb,= %arg0,%r0,ffsdone ; If arg0 is 0 - or %r0,%r0,%ret0 ; return 0 - ldi 32,%ret0 ; Set return to high bit - extru,= %arg0,31,16,%r0 ; If low 16 bits are non-zero - addi,tr -16,%ret0,%ret0 ; subtract 16 from bitpos - shd %r0,%arg0,16,%arg0 ; else shift right 16 bits - extru,= %arg0,31,8,%r0 ; If low 8 bits are non-zero - addi,tr -8,%ret0,%ret0 ; subtract 8 from bitpos - shd %r0,%arg0,8,%arg0 ; else shift right 8 bits - extru,= %arg0,31,4,%r0 ; If low 4 bits are non-zero - addi,tr -4,%ret0,%ret0 ; subtract 4 from bitpos - shd %r0,%arg0,4,%arg0 ; else shift right 4 bits - extru,= %arg0,31,2,%r0 ; If low 2 bits are non-zero - addi,tr -2,%ret0,%ret0 ; subtract 2 from bitpos - shd %r0,%arg0,2,%arg0 ; else shift right 2 bits - extru,= %arg0,31,1,%r0 ; If low bit is non-zero - addi -1,%ret0,%ret0 ; subtract 1 from bitpos -ffsdone: - bv,n %r0(%rp) -EXIT(ffs) - - .end diff --git a/lib/libc/arch/hppa/string/strlcpy.S b/lib/libc/arch/hppa/string/strlcpy.S deleted file mode 100644 index ec199b13a..000000000 --- a/lib/libc/arch/hppa/string/strlcpy.S +++ /dev/null @@ -1,84 +0,0 @@ -/* $NetBSD: strlcpy.S,v 1.3 2008/04/28 20:22:56 martin Exp $ */ - -/* - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matthew Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: strlcpy.S,v 1.3 2008/04/28 20:22:56 martin Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * size_t strlcpy(char *dst, const char *src, size_t size); - */ -LEAF_ENTRY(_strlcpy) - .weak strlcpy - strlcpy = _strlcpy - - /* Always load the first byte of the source string. */ - ldbs,ma 1(%arg1), %r1 - - /* - * If our dst buffer is zero bytes, branch immediately - * to the code that counts the (remaining) length - * of the src string. - */ - comb,= %r0, %arg2, $strlcpy_dst_done - copy %arg1, %ret0 - - /* - * If our dst buffer is one byte, branch immediately - * to the code that NUL-terminates the dst buffer and - * counts the (remaining) length of the src string. - */ - addib,=,n -1, %arg2, $strlcpy_dst_full - - /* - * Loop copying bytes. At the top of this loop, - * %arg2 is always the number of bytes we can still - * store, and %r1 holds the next byte to store. - */ -$strlcpy_loop: - comb,= %r0, %r1, $strlcpy_exit - stbs,ma %r1, 1(%arg0) - addib,<> -1, %arg2, $strlcpy_loop - ldbs,ma 1(%arg1), %r1 - -$strlcpy_dst_full: - stbs,ma %r0, 1(%arg0) - -$strlcpy_dst_done: - comb,<>,n %r0, %r1, $strlcpy_dst_done - ldbs,ma 1(%arg1), %r1 - -$strlcpy_exit: - bv %r0(%rp) - sub %arg1, %ret0, %ret0 -EXIT(strlcpy) diff --git a/lib/libc/arch/hppa/sys/__clone.S b/lib/libc/arch/hppa/sys/__clone.S deleted file mode 100644 index b3ee7a2ea..000000000 --- a/lib/libc/arch/hppa/sys/__clone.S +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: __clone.S,v 1.6 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -#ifdef WEAK_ALIAS - WEAK_ALIAS(clone, __clone) -#endif - - .import __cerror, code - -/* - * int clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone, 0) - - /* - * Sanity checks: func and stack may not be NULL. - */ - ldi EINVAL, %t1 - comb,= %r0, %arg0, __cerror - nop - comb,= %r0, %arg1, __cerror - nop - - /* - * Put the func and arg arguments into a frame in the child's stack. - */ - ldo (HPPA_FRAME_SIZE * 2)(%arg1), %arg1 - stw %arg0, HPPA_FRAME_ARG(0)(%arg1) - stw %arg3, HPPA_FRAME_ARG(1)(%arg1) - - /* - * The system call expects (flags, stack). - */ - copy %arg2, %arg0 - SYSCALL(__clone) - comb,<>,n %r0, %ret1, 9f - bv,n %r0(%rp) - -9: /* - * Child: Reload the function and argument from the new stack. - */ - ldw HPPA_FRAME_ARG(0)(%sp), %r22 - ldw HPPA_FRAME_ARG(1)(%sp), %arg0 - - /* Call the clone's entry point. */ - stw %r19, HPPA_FRAME_ARG(2)(%sp) - bl $$dyncall, %r31 - copy %r31, %rp - ldw HPPA_FRAME_ARG(2)(%sp), %r19 - - /* Pass the return value to _exit(). */ - copy %ret0, %arg0 - PIC_CALL(_exit) - - /* NOTREACHED */ -EXIT(__clone) diff --git a/lib/libc/arch/hppa/sys/__sigaction14_sigtramp.c b/lib/libc/arch/hppa/sys/__sigaction14_sigtramp.c deleted file mode 100644 index dbfb30046..000000000 --- a/lib/libc/arch/hppa/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.4 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.4 2008/04/28 20:22:56 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern int __sigtramp_siginfo_2[]; - - return (__sigaction_sigtramp(sig, act, oact, - __sigtramp_siginfo_2, 2)); -} diff --git a/lib/libc/arch/hppa/sys/__sigtramp2.S b/lib/libc/arch/hppa/sys/__sigtramp2.S deleted file mode 100644 index b76a48706..000000000 --- a/lib/libc/arch/hppa/sys/__sigtramp2.S +++ /dev/null @@ -1,133 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.5 2014/03/06 19:02:58 skrll Exp $ */ - -/* - * Copyright (c) 1998-2001 Michael Shalayeff - * 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 ``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 HIS RELATIVES 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 MIND, 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. - * - * Portitions of this file are derived from other sources, see - * the copyrights and acknowledgements below. - */ -/* - * Copyright (c) 1990,1991,1992,1994 The University of Utah and - * the Computer Systems Laboratory (CSL). All rights reserved. - * - * THE UNIVERSITY OF UTAH AND CSL PROVIDE THIS SOFTWARE IN ITS "AS IS" - * CONDITION, AND DISCLAIM ANY LIABILITY OF ANY KIND FOR ANY DAMAGES - * WHATSOEVER RESULTING FROM ITS USE. - * - * CSL requests users of this software to return to csl-dist@cs.utah.edu any - * improvements that they make and grant CSL redistribution rights. - * - * Utah $Hdr: locore.s 1.62 94/12/15$ - */ -/* - * (c) Copyright 1988 HEWLETT-PACKARD COMPANY - * - * To anyone who acknowledges that this file is provided "AS IS" - * without any express or implied warranty: - * permission to use, copy, modify, and distribute this file - * for any purpose is hereby granted without fee, provided that - * the above copyright notice and this notice appears in all - * copies, and that the name of Hewlett-Packard Company not be - * used in advertising or publicity pertaining to distribution - * of the software without specific, written prior permission. - * Hewlett-Packard Company makes no representations about the - * suitability of this software for any purpose. - */ - -#include "SYS.h" - -/* - * The hppa signal trampoline is required to call the handler - * possibily via a PLABEL. - * - * On entry, stack looks like: - * - * sp-> [x] - * r3,arg2-> ucontext structure - * arg1-> siginfo structure [0] - * - * where - * x = HPPA_FRAME_ROUND(sizeof(sigframe_siginfo)) - * - * and - * struct sigframe_siginfo { - * siginfo_t sf_si; - * ucontext_t sf_uc; - * }; - */ - -ENTRY_NOPROFILE(__sigtramp_siginfo_2, 0) - .call - - /* - * Our sendsig() places the address of the signal handler in %arg3. - * It may actually be a PLABEL. - */ - bb,>=,n %arg3, 30, L$sigcode_bounce ; branch if not a PLABEL - depi 0, 31, 2, %arg3 ; zero L bit in PLABEL pointer - ldw 4(%arg3), %r19 ; load shared library linkage - ldw 0(%arg3), %arg3 ; load real catcher address - -L$sigcode_bounce: - - /* - * This blr puts the address of the following nop in rp. - * It also schedules the nop for execution, which is why - * that instruction has to be a nop, or, rather, not any - * instruction only meant to execute once the signal handler - * returns. - */ - blr %r0, %rp - - /* - * This bv schedules the instruction pointed to by arg3 - * for execution. So, arg3 is the address of the signal - * handler. - */ - bv,n %r0(%arg3) - nop - - /* - * The signal handler has returned. Since r3 is on the list - * of callee-saved registers, it's whatever the sendsig - * code wanted it set to. Since we copy it into arg0, - * it looks like sendsig leaves r3 holding the desired - * single argument to sys_setcontext, i.e., the ucontext_t *. - */ - - /* Make a SYS_setcontext system call. */ - copy %r3, %arg0 - ldil L%SYSCALLGATE, %r1 - .call - ble 4(%sr2, %r1) - ldi SYS_setcontext, %t1 - - /* Make a SYS_exit system call. */ - copy %ret0, %arg0 - ldil L%SYSCALLGATE, %r1 - .call - ble 4(%sr2, %r1) - ldi SYS_exit, %t1 -EXIT(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/hppa/sys/__syscall.S b/lib/libc/arch/hppa/sys/__syscall.S deleted file mode 100644 index bdef76fdd..000000000 --- a/lib/libc/arch/hppa/sys/__syscall.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.1 2002/06/06 20:31:23 fredette Exp $ */ - -#include "SYS.h" -RSYSCALL(__syscall) diff --git a/lib/libc/arch/hppa/sys/__vfork14.S b/lib/libc/arch/hppa/sys/__vfork14.S deleted file mode 100644 index 41d156683..000000000 --- a/lib/libc/arch/hppa/sys/__vfork14.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.6 2014/03/06 19:02:58 skrll Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -ENTRY(__vfork14, 0) - /* - * NB: __vfork14 is a tricky syscall. We can't save - * any values on the stack, because the stack will be - * trashed by the child, leaving garbage for when the - * parent returns. - * - * So we must save values in registers, specifically, - * registers that the kernel is willing to preserve - * across the syscall. Normally, this would be callee- - * saved registers, with the kernel being the callee, - * but the problem is that we, too, are a callee, and - * would have to save that very same register somewhere, - * because *our* caller is counting on us to do so. - * - * What we need is a normally caller-saved register, - * that the kernel is willing to save for us. The - * syscall entry code in locore.S has been modified - * to do just this for the t4 register. - */ - .import __cerror, code - - copy %rp, %t4 - ldil L%SYSCALLGATE, %r1 - ble 4(%sr2, %r1) - ldi SYS___vfork14, %t1 - comb,<> %r0, %t1, __cerror - copy %t4, %rp - addi -1, %ret1, %ret1 - bv %r0(%rp) - and %ret0, %ret1, %ret0 -EXIT(__vfork14) diff --git a/lib/libc/arch/hppa/sys/brk.S b/lib/libc/arch/hppa/sys/brk.S deleted file mode 100644 index d16612706..000000000 --- a/lib/libc/arch/hppa/sys/brk.S +++ /dev/null @@ -1,78 +0,0 @@ -/* $NetBSD: brk.S,v 1.6 2013/09/12 15:36:15 joerg Exp $ */ - -/* $OpenBSD: brk.S,v 1.7 2001/06/04 23:14:04 mickey Exp $ */ - -/* - * Copyright (c) 1999 Michael Shalayeff - * 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 ``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 HIS RELATIVES 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 MIND, 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.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: brk.S,v 1.6 2013/09/12 15:36:15 joerg Exp $") -#endif /* LIBC_SCCS and not lint */ - - .import curbrk, data - .global _end - -#ifdef WEAK_ALIAS - WEAK_ALIAS(brk, _brk) -#endif - - .data - .export __minbrk, data -__minbrk: - .long _end - -ENTRY(_brk,0) -#ifdef __PIC__ - addil LT%__minbrk, %r19 - ldw RT%__minbrk(%r1), %r1 - ldw 0(%r1), %t2 -#else /* !__PIC__ */ - ldil L%__minbrk, %t1 - ldw R%__minbrk(%t1), %t2 -#endif /* !__PIC__ */ - sub,<< %t2, %arg0, %r0 - copy %t2, %arg0 - stw %arg0, HPPA_FRAME_ARG(0)(%sp) - - SYSCALL(break) - - ldw HPPA_FRAME_ARG(0)(%sp), %arg0 -#ifdef __PIC__ - addil LT%curbrk, %r19 - ldw RT%curbrk(%r1), %r1 - bv %r0(%rp) - stw %arg0, 0(%r1) -#else /* !__PIC__ */ - ldil L%curbrk, %t1 - bv %r0(%rp) - stw %arg0, R%curbrk(%t1) -#endif /* !__PIC__ */ -EXIT(brk) - - .end - diff --git a/lib/libc/arch/hppa/sys/cerror.S b/lib/libc/arch/hppa/sys/cerror.S deleted file mode 100644 index 47d8f157c..000000000 --- a/lib/libc/arch/hppa/sys/cerror.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: cerror.S,v 1.5 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nick Hudson - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifdef _REENTRANT -ENTRY(__cerror,HPPA_FRAME_SIZE) -#else -LEAF_ENTRY(__cerror) -#endif -#ifdef _REENTRANT - stw %rp, HPPA_FRAME_CRP(%sp) - stw %t1, HPPA_FRAME_ARG(0)(%sp) - ldo HPPA_FRAME_SIZE(%sp),%sp - bl __errno, %rp - nop - ldo -HPPA_FRAME_SIZE(%sp), %sp - ldw HPPA_FRAME_ARG(0)(%sp), %t1 - ldw HPPA_FRAME_CRP(%sp), %rp - stw %t1, 0(%ret0) -#else -#ifdef __PIC__ - addil LT%errno, %r19 - ldw RT%errno(%r1), %r1 - stw %t1, 0(%r1) -#else - ldil L%errno, %r1 - stw %t1, R%errno(%r1) -#endif -#endif - ldi -1, %ret0 - bv %r0(%rp) - ldi -1, %ret1 -EXIT(__cerror) diff --git a/lib/libc/arch/hppa/sys/exect.S b/lib/libc/arch/hppa/sys/exect.S deleted file mode 100644 index 5bb0ce1e5..000000000 --- a/lib/libc/arch/hppa/sys/exect.S +++ /dev/null @@ -1,40 +0,0 @@ -/* $NetBSD: exect.S,v 1.2 2009/11/03 05:07:25 snj Exp $ */ - -/* $OpenBSD: exect.S,v 1.5 2001/03/29 01:43:52 mickey Exp $ */ - -/* - * Copyright (c) 1999 Michael Shalayeff - * 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 ``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 HIS RELATIVES 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 MIND, 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.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: exect.S,v 1.2 2009/11/03 05:07:25 snj Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* we do no tracing yet */ -PSEUDO(exect,execve) - - .end diff --git a/lib/libc/arch/hppa/sys/fork.S b/lib/libc/arch/hppa/sys/fork.S deleted file mode 100644 index 0ee7ddf54..000000000 --- a/lib/libc/arch/hppa/sys/fork.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: fork.S,v 1.4 2009/11/03 05:07:25 snj Exp $ */ - -/* $OpenBSD: fork.S,v 1.7 2001/06/04 23:14:04 mickey Exp $ */ - -/* - * Copyright (c) 1999 Michael Shalayeff - * 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 ``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 HIS RELATIVES 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 MIND, 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.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: fork.S,v 1.4 2009/11/03 05:07:25 snj Exp $") -#endif /* LIBC_SCCS and not lint */ - -ENTRY(__fork,0) - SYSCALL(fork) - addi -1, %ret1, %ret1 - bv %r0(%rp) - and %ret0, %ret1, %ret0 -EXIT(__fork) - - .end diff --git a/lib/libc/arch/hppa/sys/getcontext.S b/lib/libc/arch/hppa/sys/getcontext.S deleted file mode 100644 index ee13db61e..000000000 --- a/lib/libc/arch/hppa/sys/getcontext.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.5 2014/02/19 13:01:51 skrll Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -ENTRY(_getcontext, 0) - SYSCALL(getcontext) - stw %rp, (_OFFSETOF_UC_GREGS + _REG_PCOQH * SZREG)(%arg0) - ldo 4(%rp), %r1 - stw %r1, (_OFFSETOF_UC_GREGS + _REG_PCOQT * SZREG)(%arg0) - bv %r0(%rp) - stw %r0, (_OFFSETOF_UC_GREGS + _REG_RET0 * SZREG)(%arg0) -EXIT(_getcontext) diff --git a/lib/libc/arch/hppa/sys/pipe.S b/lib/libc/arch/hppa/sys/pipe.S deleted file mode 100644 index 00970ae79..000000000 --- a/lib/libc/arch/hppa/sys/pipe.S +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: pipe.S,v 1.3 2003/10/06 05:30:21 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)pipe.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: pipe.S,v 1.3 2003/10/06 05:30:21 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef WEAK_ALIAS - WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe,0) - stw %arg0, HPPA_FRAME_ARG(0)(%sp) - SYSCALL(pipe) - ldw HPPA_FRAME_ARG(0)(%sp), %arg0 - stw %ret0, 0(%arg0) - stw %ret1, 4(%arg0) - bv %r0(%rp) - copy %r0, %ret0 -EXIT(_pipe) diff --git a/lib/libc/arch/hppa/sys/ptrace.S b/lib/libc/arch/hppa/sys/ptrace.S deleted file mode 100644 index 623525993..000000000 --- a/lib/libc/arch/hppa/sys/ptrace.S +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.6 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - - .import __cerror, code - -/* - * int ptrace(int request, pid_t pid, void * addr, int data); - */ - -ENTRY(ptrace, HPPA_FRAME_SIZE) - stw %rp, HPPA_FRAME_CRP(%sp) - stw %arg0, HPPA_FRAME_ARG(0)(%sp) - stw %arg1, HPPA_FRAME_ARG(1)(%sp) - stw %arg2, HPPA_FRAME_ARG(2)(%sp) - stw %arg3, HPPA_FRAME_ARG(3)(%sp) - ldo HPPA_FRAME_SIZE(%sp),%sp - bl __cerror, %rp - copy %r0, %t1 - ldo -HPPA_FRAME_SIZE(%sp), %sp - ldw HPPA_FRAME_ARG(0)(%sp), %arg0 - ldw HPPA_FRAME_ARG(1)(%sp), %arg1 - ldw HPPA_FRAME_ARG(2)(%sp), %arg2 - ldw HPPA_FRAME_ARG(3)(%sp), %arg3 - ldw HPPA_FRAME_CRP(%sp), %rp - - SYSCALL(ptrace) - bv,n %r0(%rp) -EXIT(ptrace) diff --git a/lib/libc/arch/hppa/sys/sbrk.S b/lib/libc/arch/hppa/sys/sbrk.S deleted file mode 100644 index 592141387..000000000 --- a/lib/libc/arch/hppa/sys/sbrk.S +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.6 2013/09/12 15:36:15 joerg Exp $ */ - -/* $OpenBSD: sbrk.S,v 1.7 2001/06/04 23:14:04 mickey Exp $ */ - -/* - * Copyright (c) 1999 Michael Shalayeff - * 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 ``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 HIS RELATIVES 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 MIND, 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.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: sbrk.S,v 1.6 2013/09/12 15:36:15 joerg Exp $") -#endif /* LIBC_SCCS and not lint */ - - .global _end - -#ifdef WEAK_ALIAS - WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data - .export curbrk, data -curbrk: - .long _end - -ENTRY(_sbrk,0) -#ifdef __PIC__ - addil LT%curbrk, %r19 - ldw RT%curbrk(%r1), %r1 - ldw 0(%r1), %t2 -#else /* !__PIC__ */ - ldil L%curbrk, %t1 - ldw R%curbrk(%t1), %t2 -#endif /* !__PIC__ */ - add %arg0, %t2, %arg0 - stw %arg0, HPPA_FRAME_ARG(0)(%sp) - - SYSCALL(break) - -#ifdef __PIC__ - addil LT%curbrk, %r19 - ldw RT%curbrk(%r1), %r1 -#else /* !__PIC__ */ - ldil L%curbrk, %t1 - ldo R%curbrk(%t1), %r1 -#endif /* !__PIC__ */ - ldw 0(%r1), %ret0 - ldw HPPA_FRAME_ARG(0)(%sp), %arg0 - bv %r0(%rp) - stw %arg0, 0(%r1) - -EXIT(sbrk) - - .end diff --git a/lib/libc/arch/hppa/sys/shmat.S b/lib/libc/arch/hppa/sys/shmat.S deleted file mode 100644 index 0eaf832c3..000000000 --- a/lib/libc/arch/hppa/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.3 2004/07/18 20:48:04 chs Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/hppa/sys/syscall.S b/lib/libc/arch/hppa/sys/syscall.S deleted file mode 100644 index fbf8ee412..000000000 --- a/lib/libc/arch/hppa/sys/syscall.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: syscall.S,v 1.2 2009/11/03 05:07:25 snj Exp $ */ - -/* $OpenBSD: syscall.S,v 1.4 2001/03/29 01:43:53 mickey Exp $ */ - -/* - * Copyright (c) 1999 Michael Shalayeff - * 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 ``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 HIS RELATIVES 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 MIND, 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.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: syscall.S,v 1.2 2009/11/03 05:07:25 snj Exp $") -#endif /* LIBC_SCCS and not lint */ - -RSYSCALL(syscall) - - .end diff --git a/lib/libc/arch/i386/Makefile.inc b/lib/libc/arch/i386/Makefile.inc deleted file mode 100644 index 80d6db9fa..000000000 --- a/lib/libc/arch/i386/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.21 2015/07/15 14:27:49 pooka Exp $ - -.if ${RUMPRUN} != "yes" && !defined(__MINIX) -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S -.endif diff --git a/lib/libc/arch/i386/SYS.h b/lib/libc/arch/i386/SYS.h deleted file mode 100644 index 9188871c5..000000000 --- a/lib/libc/arch/i386/SYS.h +++ /dev/null @@ -1,154 +0,0 @@ -/* $NetBSD: SYS.h,v 1.25 2014/05/23 02:17:43 uebayasi Exp $ */ - -/*- - * Copyright (c) 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - */ - -#include -#include - -#ifdef __STDC__ -#define _SYSNAM(x) $(SYS_ ## x) -#else -#define _SYSNAM(x) $(SYS_/**/x) -#endif - -#define OSYSTRAP(x) \ - movl _SYSNAM(x),%eax ;\ - int $0x80 - -#ifdef I686_LIBC -#define SYSTRAP(x) \ - pushl %ebx ;\ - movl _SYSNAM(x),%eax ;\ - movl $123f,%edx ;\ - movl %esp,%ecx ;\ - sysenter ;\ -123: movl %ebx,%edx ;\ - popl %ebx -#else /* I686_LIBC */ -#define SYSTRAP(x) OSYSTRAP(x) -#endif /* I686_LIBC */ - -#ifdef __ELF__ -#define CERROR _C_LABEL(__cerror) -#define CURBRK _C_LABEL(__curbrk) -#else -#define CERROR _ASM_LABEL(cerror) -#define CURBRK _ASM_LABEL(curbrk) -#endif - -#define _SYSCALL_NOERROR(x,y) \ - ENTRY(x); \ - SYSTRAP(y) - -#ifdef __PIC__ -#define _SYSCALL_ERR \ - PIC_PROLOGUE; \ - mov PIC_GOT(CERROR), %ecx; \ - PIC_EPILOGUE; \ - jmp *%ecx -#else -#define _SYSCALL_ERR \ - jmp CERROR -#endif - -#define _SYSCALL(x,y) \ - .text; _ALIGN_TEXT; \ - 2: _SYSCALL_ERR; \ - _SYSCALL_NOERROR(x,y); \ - jc 2b - -#define SYSCALL_NOERROR(x) \ - _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ - ret; \ - END(x) - -#define PSEUDO(x,y) \ - _SYSCALL_NOERROR(x,y); \ - jc 2f; \ - ret; \ - 2: _SYSCALL_ERR; \ - END(x) - -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) \ - PSEUDO(x,x) - -#ifdef WEAK_ALIAS -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) -#else -#define WSYSCALL(weak,strong) \ - PSEUDO(weak,weak) -#endif - - .globl CERROR diff --git a/lib/libc/arch/i386/gdtoa/Makefile.inc b/lib/libc/arch/i386/gdtoa/Makefile.inc deleted file mode 100644 index ce2f4854d..000000000 --- a/lib/libc/arch/i386/gdtoa/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c strtold_px.c -SRCS+= strtopx.c diff --git a/lib/libc/arch/i386/gdtoa/arith.h b/lib/libc/arch/i386/gdtoa/arith.h deleted file mode 100644 index 1513f1fd2..000000000 --- a/lib/libc/arch/i386/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_LITTLE_ENDIAN diff --git a/lib/libc/arch/i386/gdtoa/gd_qnan.h b/lib/libc/arch/i386/gdtoa/gd_qnan.h deleted file mode 100644 index 915d0ced5..000000000 --- a/lib/libc/arch/i386/gdtoa/gd_qnan.h +++ /dev/null @@ -1,11 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.2 2011/06/05 14:43:12 christos Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff80000 -#define ldus_QNAN0 0x0 -#define ldus_QNAN1 0x0 -#define ldus_QNAN2 0x0 -#define ldus_QNAN3 0xc000 -#define ldus_QNAN4 0x7fff -/* 2 bytes of tail padding follow, per i386 ABI */ diff --git a/lib/libc/arch/i386/gen/Makefile.inc b/lib/libc/arch/i386/gen/Makefile.inc deleted file mode 100644 index 1b3df5fc9..000000000 --- a/lib/libc/arch/i386/gen/Makefile.inc +++ /dev/null @@ -1,42 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.29 2015/07/15 14:27:49 pooka Exp $ - -# objects built from assembler sources (need lint stubs) -SRCS+= alloca.S byte_swap_2.S byte_swap_4.S fabs.S \ - flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S \ - fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \ - fpsetprec.S - -SRCS+= setjmp.S _setjmp.S sigsetjmp.S - -.if ${RUMPRUN} != "yes" && ! defined(__MINIX) -# Already defined in minix/lib/libc/arch/i386/sys -SRCS+= resumecontext.S swapcontext.S -SRCS+= _lwp.c makecontext.c -.endif - -SRCS+= bswap64.c - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c infinityl.c -SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c signbitl.c - -# "internal" objects (don't provide part of the user-visible API) -SRCS+= divsi3.S fixdfsi.S fixunsdfsi.S udivsi3.S - -LSRCS.i386.gen=\ - Lint__setjmp.c Lint_alloca.c Lint_bswap16.c Lint_bswap32.c \ - Lint_fabs.c \ - Lint___setjmp14.c Lint___sigsetjmp14.c Lint_flt_rounds.c \ - Lint_fpgetmask.c Lint_fpgetround.c Lint_fpgetsticky.c \ - Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c \ - Lint_resumecontext.c Lint_swapcontext.c Lint__setjmp.c -LSRCS+= ${LSRCS.i386.gen} -DPSRCS+= ${LSRCS.i386.gen} -CLEANFILES+= ${LSRCS.i386.gen} diff --git a/lib/libc/arch/i386/gen/_lwp.c b/lib/libc/arch/i386/gen/_lwp.c deleted file mode 100644 index a8b486d5f..000000000 --- a/lib/libc/arch/i386/gen/_lwp.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nathan J. Williams. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.8 2012/08/31 20:57:24 drochner Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - void **sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - /* LINTED uintptr_t is safe */ - u->uc_mcontext.__gregs[_REG_EIP] = (uintptr_t)start; - - /* Align to a 16-byte boundary for SSE */ - /* LINTED uintptr_t is safe */ - sp = (void **) (((uintptr_t)(stack_base + stack_size - 4) & ~0xf) + 4); - - *--sp = arg; - *--sp = (void *) _lwp_exit; - - /* LINTED uintptr_t is safe */ - u->uc_mcontext.__gregs[_REG_UESP] = (uintptr_t) sp; - - u->uc_mcontext._mc_tlsbase = (uintptr_t)private; - u->uc_flags |= _UC_TLSBASE; -} diff --git a/lib/libc/arch/i386/gen/_setjmp.S b/lib/libc/arch/i386/gen/_setjmp.S deleted file mode 100644 index ef7b8e341..000000000 --- a/lib/libc/arch/i386/gen/_setjmp.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.9 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)_setjmp.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: _setjmp.S,v 1.9 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - movl 4(%esp),%eax - movl 0(%esp),%edx - movl %edx, 0(%eax) /* rta */ - movl %ebx, 4(%eax) - movl %esp, 8(%eax) - movl %ebp,12(%eax) - movl %esi,16(%eax) - movl %edi,20(%eax) - xorl %eax,%eax - ret -END(_setjmp) - -ENTRY(_longjmp) - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret -END(_longjmp) diff --git a/lib/libc/arch/i386/gen/alloca.S b/lib/libc/arch/i386/gen/alloca.S deleted file mode 100644 index 0b975bc34..000000000 --- a/lib/libc/arch/i386/gen/alloca.S +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: alloca.S,v 1.9 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)alloca.s 5.2 (Berkeley) 5/14/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: alloca.S,v 1.9 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -/* like alloc, but automatic free in return */ - -ENTRY(alloca) - popl %edx /* pop return addr */ - popl %eax /* pop amount to allocate */ - movl %esp,%ecx - addl $3,%eax /* round up to next word */ - andl $-4,%eax - subl %eax,%esp - movl %esp,%eax /* base of newly allocated space */ - pushl 8(%ecx) /* copy possible saved registers */ - pushl 4(%ecx) - pushl 0(%ecx) - pushl %eax /* dummy to pop at callsite */ - jmp *%edx /* "return" */ -END(alloca) diff --git a/lib/libc/arch/i386/gen/divsi3.S b/lib/libc/arch/i386/gen/divsi3.S deleted file mode 100644 index b00571edd..000000000 --- a/lib/libc/arch/i386/gen/divsi3.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: divsi3.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)divsi3.s 5.1 (Berkeley) 5/15/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: divsi3.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(__divsi3) - movl 4(%esp),%eax - cltd - idivl 8(%esp) - ret -END(__divsi3) diff --git a/lib/libc/arch/i386/gen/fabs.S b/lib/libc/arch/i386/gen/fabs.S deleted file mode 100644 index d97314209..000000000 --- a/lib/libc/arch/i386/gen/fabs.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: fabs.S,v 1.6 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)fabs.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: fabs.S,v 1.6 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(fabs) - fldl 4(%esp) - fabs - ret -END(fabs) diff --git a/lib/libc/arch/i386/gen/fixdfsi.S b/lib/libc/arch/i386/gen/fixdfsi.S deleted file mode 100644 index a26896eef..000000000 --- a/lib/libc/arch/i386/gen/fixdfsi.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: fixdfsi.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1991 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)fixdfsi.s 5.4 (Berkeley) 4/12/91 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: fixdfsi.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(__fixdfsi) - fldl 4(%esp) - fistpl 4(%esp) - movl 4(%esp),%eax - ret -END(__fixdfsi) diff --git a/lib/libc/arch/i386/gen/fixunsdfsi.S b/lib/libc/arch/i386/gen/fixunsdfsi.S deleted file mode 100644 index f2d0e2603..000000000 --- a/lib/libc/arch/i386/gen/fixunsdfsi.S +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: fixunsdfsi.S,v 1.14 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)fixunsdfsi.s 5.1 12/17/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: fixunsdfsi.S,v 1.14 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(__fixunsdfsi) - fldl 4(%esp) /* argument double to accum stack */ - frndint /* create integer */ -#ifdef __PIC__ - PIC_PROLOGUE - leal PIC_GOTOFF(fbiggestsigned),%eax - PIC_EPILOGUE - fcoml (%eax) -#else - fcoml fbiggestsigned /* bigger than biggest signed? */ -#endif - fstsw %ax - sahf - jnb 2f - - fistpl 4(%esp) - movl 4(%esp),%eax - ret - -2: -#ifdef __PIC__ - PIC_PROLOGUE - leal PIC_GOTOFF(fbiggestsigned),%eax - PIC_EPILOGUE - fsubl (%eax) -#else - fsubl fbiggestsigned /* reduce for proper conversion */ -#endif - fistpl 4(%esp) /* convert */ - movl 4(%esp),%eax - orl $0x80000000,%eax /* restore bias */ - ret -END(__fixunsdfsi) - -fbiggestsigned: .double 2147483648.0 diff --git a/lib/libc/arch/i386/gen/flt_rounds.S b/lib/libc/arch/i386/gen/flt_rounds.S deleted file mode 100644 index 140394eea..000000000 --- a/lib/libc/arch/i386/gen/flt_rounds.S +++ /dev/null @@ -1,22 +0,0 @@ -/* $NetBSD: flt_rounds.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $ */ - -#include - -/* - * 00 0 round to zero - * 01 1 round to nearest - * 10 2 round to positive infinity - * 11 3 round to negative infinity - */ - .text - _ALIGN_TEXT -ENTRY(__flt_rounds) - fnstcw -4(%esp) - movl -4(%esp), %ecx - shrl $9, %ecx - andl $6, %ecx - movl $0x2d, %eax /* 0x2d = 00.10.11.01 */ - sarl %cl, %eax /* 0,1,2,3 -> 1,3,2,0 */ - andl $3, %eax - ret -END(__flt_rounds) diff --git a/lib/libc/arch/i386/gen/fpclassifyl.c b/lib/libc/arch/i386/gen/fpclassifyl.c deleted file mode 100644 index 185ee0c5b..000000000 --- a/lib/libc/arch/i386/gen/fpclassifyl.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: fpclassifyl.c,v 1.3 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyl.c,v 1.3 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__fpclassifyl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - _DIAGASSERT(u.extu_ext.ext_exp == 0 || - (u.extu_ext.ext_frach & 0x80000000)); - - if (u.extu_ext.ext_exp == 0) { - if ((u.extu_ext.ext_frach & 0x7fffffff) == 0 && - u.extu_ext.ext_fracl == 0) - return FP_ZERO; - else - return FP_SUBNORMAL; - } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) { - if ((u.extu_ext.ext_frach & 0x7fffffff) == 0 && - u.extu_ext.ext_fracl == 0) - return FP_INFINITE; - else - return FP_NAN; - } - - return FP_NORMAL; -} diff --git a/lib/libc/arch/i386/gen/fpgetmask.S b/lib/libc/arch/i386/gen/fpgetmask.S deleted file mode 100644 index 04cac7d2d..000000000 --- a/lib/libc/arch/i386/gen/fpgetmask.S +++ /dev/null @@ -1,27 +0,0 @@ -/* $NetBSD: fpgetmask.S,v 1.5 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by J.T. Conklin, Apr 4, 1995 - * Public domain. - */ - -#include - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetmask, _fpgetmask) -ENTRY(_fpgetmask) -#else -ENTRY(fpgetmask) -#endif - subl $4,%esp - fnstcw (%esp) - movl (%esp),%eax - notl %eax - andl $63,%eax - addl $4,%esp - ret -#ifdef WEAK_ALIAS -END(_fpgetmask) -#else -END(fpgetmask) -#endif diff --git a/lib/libc/arch/i386/gen/fpgetprec.S b/lib/libc/arch/i386/gen/fpgetprec.S deleted file mode 100644 index aa7974e7c..000000000 --- a/lib/libc/arch/i386/gen/fpgetprec.S +++ /dev/null @@ -1,27 +0,0 @@ -/* $NetBSD: fpgetprec.S,v 1.2 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by J.T. Conklin, Apr 4, 1995 - * Public domain. - */ - -#include - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetprec, _fpgetprec) -ENTRY(_fpgetprec) -#else -ENTRY(fpgetprec) -#endif - subl $4,%esp - fnstcw (%esp) - movl (%esp),%eax - rorl $8,%eax - andl $3,%eax - addl $4,%esp - ret -#ifdef WEAK_ALIAS -END(_fpgetprec) -#else -END(fpgetprec) -#endif diff --git a/lib/libc/arch/i386/gen/fpgetround.S b/lib/libc/arch/i386/gen/fpgetround.S deleted file mode 100644 index c934fd31a..000000000 --- a/lib/libc/arch/i386/gen/fpgetround.S +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpgetround.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by J.T. Conklin, Apr 4, 1995 - * Public domain. - */ - -#include - -/* - * XXX load only x87 state. - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetround, _fpgetround) -ENTRY(_fpgetround) -#else -ENTRY(fpgetround) -#endif - fnstcw -4(%esp) - movl -4(%esp), %eax - andl $0x00000c00, %eax - ret -#ifdef WEAK_ALIAS -END(_fpgetround) -#else -END(fpgetround) -#endif diff --git a/lib/libc/arch/i386/gen/fpgetsticky.S b/lib/libc/arch/i386/gen/fpgetsticky.S deleted file mode 100644 index 977957ffe..000000000 --- a/lib/libc/arch/i386/gen/fpgetsticky.S +++ /dev/null @@ -1,26 +0,0 @@ -/* $NetBSD: fpgetsticky.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by J.T. Conklin, Apr 4, 1995 - * Public domain. - */ - -#include - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetsticky, _fpgetsticky) -ENTRY(_fpgetsticky) -#else -ENTRY(fpgetsticky) -#endif - subl $4,%esp - fnstsw (%esp) - movl (%esp),%eax - andl $63,%eax - addl $4,%esp - ret -#ifdef WEAK_ALIAS -END(_fpgetsticky) -#else -END(fpgetsticky) -#endif diff --git a/lib/libc/arch/i386/gen/fpsetmask.S b/lib/libc/arch/i386/gen/fpsetmask.S deleted file mode 100644 index 81cc7f195..000000000 --- a/lib/libc/arch/i386/gen/fpsetmask.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: fpsetmask.S,v 1.5 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by Charles M. Hannum, Apr 9, 1995 - * Public domain. - */ - -#include - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetmask, _fpsetmask) -ENTRY(_fpsetmask) -#else -ENTRY(fpsetmask) -#endif - subl $4,%esp - - fnstcw (%esp) - movl (%esp),%eax - movl %eax,%edx - - notl %eax - andl $63,%eax - - addl %eax,%edx - movl 8(%esp),%ecx - andl $63,%ecx - subl %ecx,%edx - movl %edx,(%esp) - fldcw (%esp) - - addl $4,%esp - ret -#ifdef WEAK_ALIAS -END(_fpsetmask) -#else -END(fpsetmask) -#endif diff --git a/lib/libc/arch/i386/gen/fpsetprec.S b/lib/libc/arch/i386/gen/fpsetprec.S deleted file mode 100644 index 19e88246f..000000000 --- a/lib/libc/arch/i386/gen/fpsetprec.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: fpsetprec.S,v 1.2 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by Charles M. Hannum, Apr 9, 1995 - * Public domain. - */ - -#include - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetprec, _fpsetprec) -ENTRY(_fpsetprec) -#else -ENTRY(fpsetprec) -#endif - subl $4,%esp - - fnstcw (%esp) - movl (%esp),%eax - - rorl $8,%eax - movl %eax,%edx - andl $3,%eax - - subl %eax,%edx - movl 8(%esp),%ecx - andl $3,%ecx - orl %ecx,%edx - roll $8,%edx - movl %edx,(%esp) - fldcw (%esp) - - addl $4,%esp - ret -#ifdef WEAK_ALIAS -END(_fpsetprec) -#else -END(fpsetprec) -#endif diff --git a/lib/libc/arch/i386/gen/fpsetround.S b/lib/libc/arch/i386/gen/fpsetround.S deleted file mode 100644 index 578d37645..000000000 --- a/lib/libc/arch/i386/gen/fpsetround.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: fpsetround.S,v 1.6 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by Frank van der Linden at Wasabi Systems for NetBSD. - * Public domain. - */ - -#include - -/* - * XXX set both the x87 control word - * Applications should only set exception and round flags - */ - - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetround, _fpsetround) -ENTRY(_fpsetround) -#else -ENTRY(fpsetround) -#endif - - fnstcw -4(%esp) - movl -4(%esp), %edx - movl %edx, %eax - andl $0x00000c00, %eax - andl $0xfffff3ff, %edx - movl 4(%esp), %ecx - orl %ecx, %edx - movl %edx, -4(%esp) - fldcw -4(%esp) - - ret -#ifdef WEAK_ALIAS -END(_fpsetround) -#else -END(fpsetround) -#endif diff --git a/lib/libc/arch/i386/gen/fpsetsticky.S b/lib/libc/arch/i386/gen/fpsetsticky.S deleted file mode 100644 index acdd8503a..000000000 --- a/lib/libc/arch/i386/gen/fpsetsticky.S +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: fpsetsticky.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Written by Charles M. Hannum, Apr 9, 1995 - * Public domain. - */ - -#include - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetsticky, _fpsetsticky) -ENTRY(_fpsetsticky) -#else -ENTRY(fpsetsticky) -#endif - subl $28,%esp - - fnstenv (%esp) - movl 4(%esp),%eax - movl %eax,%edx - - andl $63,%eax - - subl %eax,%edx - movl 32(%esp),%ecx - andl $63,%ecx - addl %ecx,%edx - movl %edx,4(%esp) - fldenv (%esp) - - addl $28,%esp - ret -#ifdef WEAK_ALIAS -END(_fpsetsticky) -#else -END(fpsetsticky) -#endif diff --git a/lib/libc/arch/i386/gen/infinityl.c b/lib/libc/arch/i386/gen/infinityl.c deleted file mode 100644 index de21245c5..000000000 --- a/lib/libc/arch/i386/gen/infinityl.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:30 drochner Exp $ */ - -/* - * IEEE-compatible infinityl.c for little-endian 80-bit format -- public domain. - * Note that the representation includes 16 bits of tail padding per i386 ABI. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:30 drochner Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include - -const union __long_double_u __infinityl = - { { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0 } }; diff --git a/lib/libc/arch/i386/gen/isfinitel.c b/lib/libc/arch/i386/gen/isfinitel.c deleted file mode 100644 index 8b0c8a7d2..000000000 --- a/lib/libc/arch/i386/gen/isfinitel.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: isfinitel.c,v 1.3 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinitel.c,v 1.3 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__isfinitel(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - _DIAGASSERT(u.extu_ext.ext_exp == 0 || - (u.extu_ext.ext_frach & 0x80000000)); - - if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) - return 0; - - return 1; -} diff --git a/lib/libc/arch/i386/gen/isinfl.c b/lib/libc/arch/i386/gen/isinfl.c deleted file mode 100644 index b1675e921..000000000 --- a/lib/libc/arch/i386/gen/isinfl.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: isinfl.c,v 1.6 2007/02/02 23:14:09 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinfl.c,v 1.6 2007/02/02 23:14:09 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.3 isinf - test for infinity - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__isinfl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - u.extu_ext.ext_frach == 0x80000000 && u.extu_ext.ext_fracl == 0); -} diff --git a/lib/libc/arch/i386/gen/isnanl.c b/lib/libc/arch/i386/gen/isnanl.c deleted file mode 100644 index 045798c8d..000000000 --- a/lib/libc/arch/i386/gen/isnanl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.4 isnan - test for a NaN - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__isnanl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - (u.extu_ext.ext_frach & 0x80000000) != 0 && - (u.extu_ext.ext_frach != 0x80000000 || u.extu_ext.ext_fracl != 0)); -} diff --git a/lib/libc/arch/i386/gen/makecontext.c b/lib/libc/arch/i386/gen/makecontext.c deleted file mode 100644 index 11e8ec711..000000000 --- a/lib/libc/arch/i386/gen/makecontext.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.4 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.4 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#if __STDC__ -#include -#else -#include -#endif - - -void -#if __STDC__ -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -#else -makecontext(ucp, func, argc, va_alist) - ucontext_t *ucp; - void (*func)(); - int argc; - va_dcl -#endif -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - unsigned int *sp; - va_list ap; - - /* LINTED __greg_t is safe */ - gr[_REG_EIP] = (__greg_t)func; - - /* LINTED uintptr_t is safe */ - sp = (unsigned int *)((uintptr_t)ucp->uc_stack.ss_sp + - ucp->uc_stack.ss_size); - /* Align on word boundary. */ - /* LINTED uintptr_t is safe */ - sp = (unsigned int *)((uintptr_t)sp & ~0x3); - sp -= argc + 1; /* Make room for ret and args. */ - /* LINTED __greg_t is safe */ - gr[_REG_UESP] = (__greg_t)sp; - gr[_REG_EBP] = (__greg_t)0; /* Wipe out frame pointer. */ - - /* Put return address on top of stack. */ - /* LINTED uintptr_t is safe */ - *sp++ = (uintptr_t)_resumecontext; - - /* Construct argument list. */ -#if __STDC__ - va_start(ap, argc); -#else - va_start(ap); -#endif - while (argc-- > 0) { - /* LINTED uintptr_t is safe */ - *sp++ = va_arg(ap, uintptr_t); - } - va_end(ap); -} diff --git a/lib/libc/arch/i386/gen/nanf.c b/lib/libc/arch/i386/gen/nanf.c deleted file mode 100644 index ac1fde339..000000000 --- a/lib/libc/arch/i386/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:01 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:01 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0, 0, 0xc0, 0x7f } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/i386/gen/resumecontext.S b/lib/libc/arch/i386/gen/resumecontext.S deleted file mode 100644 index 0a847c7bc..000000000 --- a/lib/libc/arch/i386/gen/resumecontext.S +++ /dev/null @@ -1,84 +0,0 @@ -/* $NetBSD: resumecontext.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: resumecontext.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* LIBC_SCCS && !lint */ - -/* - * This assembly-language implementation differs from the (obvious) - * C-language implementation only in not clobbering the previous - * function's return address (us), which is the point of the exercise. - */ - -NENTRY(_resumecontext) /* profiling prologue would clobber TOS */ - leal -(4 + 776)(%esp),%ecx /* retaddr + sizeof (ucontext_t) */ - andl $~(0xf),%ecx /* align on _UC_UCONTEXT_ALIGN */ - movl %ecx,%esp - PIC_PROLOGUE - pushl %ecx -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(_getcontext)) -#else - call _C_LABEL(_getcontext) -#endif - addl $4,%esp - PIC_EPILOGUE - movl 4(%esp),%ecx /* uc_link */ - PIC_PROLOGUE - pushl %ecx /* argument for exit() or setcontext() */ - testl %ecx,%ecx /* link end? */ - jnz 9f /* watch out for local label use in PIC_* */ - - /* normal exit */ -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(exit)) -#else - call _C_LABEL(exit) -#endif - /* NOTREACHED */ - -9: -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(setcontext)) -#else - call _C_LABEL(setcontext) -#endif - /* NOTREACHED */ - - /* something is wrong, pull the brake */ - pushl $-1 - pushl %eax /* unused return address */ - SYSTRAP(exit) -END(_resumecontext) diff --git a/lib/libc/arch/i386/gen/setjmp.S b/lib/libc/arch/i386/gen/setjmp.S deleted file mode 100644 index 0bc6ce0e8..000000000 --- a/lib/libc/arch/i386/gen/setjmp.S +++ /dev/null @@ -1,111 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.17 2014/05/23 03:05:56 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: setjmp.S,v 1.17 2014/05/23 03:05:56 uebayasi Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - - /* Get the signal mask. */ - leal 24(%ecx),%edx - - PIC_PROLOGUE - pushl %edx - pushl $0 - pushl $0 -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif - addl $12,%esp - PIC_EPILOGUE - - xorl %eax,%eax - ret -END(__setjmp14) - -ENTRY(__longjmp14) - /* Restore the signal mask. */ - movl 4(%esp),%ecx - leal 24(%ecx),%edx - - PIC_PROLOGUE - pushl $0 - pushl %edx - pushl $3 /* SIG_SETMASK */ -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif - addl $12,%esp - PIC_EPILOGUE - - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret -END(__longjmp14) diff --git a/lib/libc/arch/i386/gen/signbitl.c b/lib/libc/arch/i386/gen/signbitl.c deleted file mode 100644 index 8ea9a1f4e..000000000 --- a/lib/libc/arch/i386/gen/signbitl.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitl.c,v 1.2 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: signbitl.c,v 1.2 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__signbitl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_sign == 1); -} diff --git a/lib/libc/arch/i386/gen/sigsetjmp.S b/lib/libc/arch/i386/gen/sigsetjmp.S deleted file mode 100644 index 25924de52..000000000 --- a/lib/libc/arch/i386/gen/sigsetjmp.S +++ /dev/null @@ -1,111 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.18 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90" - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: sigsetjmp.S,v 1.18 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(__sigsetjmp14) - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - - /* Check if we should save the signal mask, and remember it. */ - movl 8(%esp),%eax - movl %eax,40(%ecx) - testl %eax,%eax - jz 2f /* no, skip */ - - /* Get the signal mask. */ - leal 24(%ecx),%edx - - PIC_PROLOGUE - pushl %edx - pushl $0 - pushl $0 -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif - addl $12,%esp - PIC_EPILOGUE - -2: xorl %eax,%eax - ret -END(__sigsetjmp14) - -ENTRY(__siglongjmp14) - /* Check to see if we need to restore the signal mask. */ - movl 4(%esp),%ecx - cmpl $0,40(%ecx) - jz 2f /* no, skip */ - - /* Restore the signal mask. */ - leal 24(%ecx),%edx - - PIC_PROLOGUE - pushl $0 - pushl %edx - pushl $3 /* SIG_SETMASK */ -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif - addl $12,%esp - PIC_EPILOGUE - -2: movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jnz 3f - incl %eax -3: movl %ecx,0(%esp) - ret -END(__siglongjmp14) diff --git a/lib/libc/arch/i386/gen/swapcontext.S b/lib/libc/arch/i386/gen/swapcontext.S deleted file mode 100644 index 94180bb75..000000000 --- a/lib/libc/arch/i386/gen/swapcontext.S +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* LIBC_SCCS && !lint */ - -ENTRY(swapcontext) - movl 4(%esp),%ecx - PIC_PROLOGUE - pushl %ecx /* push oucp */ -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(_getcontext)) -#else - call _C_LABEL(_getcontext) -#endif - addl $4,%esp /* pop oucp */ - PIC_EPILOGUE - testl %eax,%eax - jnz 2f - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx,(36 + 14 * 4)(%ecx) /* Adjust saved %eip ... */ -#ifdef __PIC__ - movl %ebx,(36 + 8 * 4)(%ecx) /* ... clobbered PIC reg ... */ -#endif - leal 4(%esp),%edx - movl %edx,(36 + 17 * 4)(%ecx) /* ... and %esp. */ - /* Note: oucp->%eax has been cleared by getcontext(). */ - movl 8(%esp),%ecx - PIC_PROLOGUE - pushl %ecx /* push ucp */ -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(setcontext)) -#else - call _C_LABEL(setcontext) -#endif - addl $4,%esp /* pop ucp */ - PIC_EPILOGUE - /* No need to error-check: setcontext() must have failed. */ -2: ret -END(swapcontext) diff --git a/lib/libc/arch/i386/gen/udivsi3.S b/lib/libc/arch/i386/gen/udivsi3.S deleted file mode 100644 index d22609866..000000000 --- a/lib/libc/arch/i386/gen/udivsi3.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: udivsi3.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)udivsi3.s 5.1 (Berkeley) 5/15/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: udivsi3.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(__udivsi3) - movl 4(%esp),%eax - xorl %edx,%edx - divl 8(%esp) - ret -END(__udivsi3) diff --git a/lib/libc/arch/i386/net/Makefile.inc b/lib/libc/arch/i386/net/Makefile.inc deleted file mode 100644 index 0185ca659..000000000 --- a/lib/libc/arch/i386/net/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/12/06 07:12:17 uebayasi Exp $ - -# objects built from assembler sources (need lint stubs) -# hton* and nto* functions provided by ../gen/byte_swap_*.S -SRCS+= - -LSRCS.i386.net= Lint_htonl.c Lint_htons.c Lint_ntohl.c Lint_ntohs.c -LSRCS+= ${LSRCS.i386.net} -DPSRCS+= ${LSRCS.i386.net} -CLEANFILES+= ${LSRCS.i386.net} diff --git a/lib/libc/arch/i386/stdlib/Makefile.inc b/lib/libc/arch/i386/stdlib/Makefile.inc deleted file mode 100644 index 189f574a9..000000000 --- a/lib/libc/arch/i386/stdlib/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.9 2009/08/11 17:30:43 dsl Exp $ - -# objects built from assembler sources -SRCS+= abs.S div.S labs.S ldiv.S llabs.S -NO_SRCS+= imaxabs.S diff --git a/lib/libc/arch/i386/stdlib/abs.S b/lib/libc/arch/i386/stdlib/abs.S deleted file mode 100644 index 356ea60fb..000000000 --- a/lib/libc/arch/i386/stdlib/abs.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: abs.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)abs.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: abs.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(abs) - movl 4(%esp),%eax - testl %eax,%eax - jns 1f - negl %eax -1: ret -END(abs) diff --git a/lib/libc/arch/i386/stdlib/div.S b/lib/libc/arch/i386/stdlib/div.S deleted file mode 100644 index ae46c3601..000000000 --- a/lib/libc/arch/i386/stdlib/div.S +++ /dev/null @@ -1,25 +0,0 @@ -/* $NetBSD: div.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $ */ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) -RCSID("$NetBSD: div.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(div) - pushl %ebx - movl 8(%esp),%ebx - movl 12(%esp),%eax - movl 16(%esp),%ecx - cdq - idiv %ecx - movl %eax,(%ebx) - movl %edx,4(%ebx) - movl %ebx,%eax - popl %ebx - ret $4 -END(div) diff --git a/lib/libc/arch/i386/stdlib/labs.S b/lib/libc/arch/i386/stdlib/labs.S deleted file mode 100644 index e308ed970..000000000 --- a/lib/libc/arch/i386/stdlib/labs.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: labs.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)abs.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: labs.S,v 1.8 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(labs) - movl 4(%esp),%eax - testl %eax,%eax - jns 1f - negl %eax -1: ret -END(labs) diff --git a/lib/libc/arch/i386/stdlib/ldiv.S b/lib/libc/arch/i386/stdlib/ldiv.S deleted file mode 100644 index 94085f472..000000000 --- a/lib/libc/arch/i386/stdlib/ldiv.S +++ /dev/null @@ -1,25 +0,0 @@ -/* $NetBSD: ldiv.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $ */ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) -RCSID("$NetBSD: ldiv.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(ldiv) - pushl %ebx - movl 8(%esp),%ebx - movl 12(%esp),%eax - movl 16(%esp),%ecx - cdq - idiv %ecx - movl %eax,(%ebx) - movl %edx,4(%ebx) - movl %ebx,%eax - popl %ebx - ret $4 -END(ldiv) diff --git a/lib/libc/arch/i386/stdlib/llabs.S b/lib/libc/arch/i386/stdlib/llabs.S deleted file mode 100644 index d1d0ba2cb..000000000 --- a/lib/libc/arch/i386/stdlib/llabs.S +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: llabs.S,v 1.6 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)abs.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: llabs.S,v 1.6 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(llabs, _llabs) -WEAK_ALIAS(imaxabs, _llabs) -#endif - -#ifdef WEAK_ALIAS -ENTRY(_llabs) -#else -STRONG_ALIAS(imaxabs, llabs) -ENTRY(llabs) -#endif - movl 8(%esp),%edx - movl 4(%esp),%eax - testl %edx,%edx - jns 1f - negl %eax - adcl $0,%edx - negl %edx -1: ret -#ifdef WEAK_ALIAS -END(_llabs) -#else -END(llabs) -#endif diff --git a/lib/libc/arch/i386/string/Makefile.inc b/lib/libc/arch/i386/string/Makefile.inc deleted file mode 100644 index c1611747a..000000000 --- a/lib/libc/arch/i386/string/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/30 20:57:16 dsl Exp $ - -# objects built from assembler sources -SRCS+= bcmp.S bcopy.S bzero.S ffs.S memchr.S memcmp.S \ - memcpy.S memmove.S memset.S strcat.S strchr.S \ - strcmp.S strcpy.S strlen.S strncmp.S strrchr.S swab.S diff --git a/lib/libc/arch/i386/string/bcmp.S b/lib/libc/arch/i386/string/bcmp.S deleted file mode 100644 index 85c682356..000000000 --- a/lib/libc/arch/i386/string/bcmp.S +++ /dev/null @@ -1,35 +0,0 @@ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: bcmp.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -ENTRY(bcmp) - pushl %edi - pushl %esi - movl 12(%esp),%edi - movl 16(%esp),%esi - xorl %eax,%eax /* clear return value */ - - movl 20(%esp),%ecx /* compare by words */ - shrl $2,%ecx - repe - cmpsl - jne L1 - - movl 20(%esp),%ecx /* compare remainder by bytes */ - andl $3,%ecx - repe - cmpsb - je L2 - -L1: incl %eax -L2: popl %esi - popl %edi - ret -END(bcmp) diff --git a/lib/libc/arch/i386/string/bcopy.S b/lib/libc/arch/i386/string/bcopy.S deleted file mode 100644 index 35fb1df2d..000000000 --- a/lib/libc/arch/i386/string/bcopy.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: bcopy.S,v 1.15 2005/02/09 18:15:16 christos Exp $ */ - -#define BCOPY -#include "memcpy.S" diff --git a/lib/libc/arch/i386/string/bzero.S b/lib/libc/arch/i386/string/bzero.S deleted file mode 100644 index f83744741..000000000 --- a/lib/libc/arch/i386/string/bzero.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: bzero.S,v 1.12 2005/02/09 18:15:16 christos Exp $ */ - -#define BZERO -#include "memset.S" diff --git a/lib/libc/arch/i386/string/index.S b/lib/libc/arch/i386/string/index.S deleted file mode 100644 index bda26bbe1..000000000 --- a/lib/libc/arch/i386/string/index.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: index.S,v 1.14 2005/02/09 18:15:16 christos Exp $ */ - -#define INDEX -#include "strchr.S" diff --git a/lib/libc/arch/i386/string/rindex.S b/lib/libc/arch/i386/string/rindex.S deleted file mode 100644 index f39cc2c47..000000000 --- a/lib/libc/arch/i386/string/rindex.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: rindex.S,v 1.14 2005/02/09 18:15:16 christos Exp $ */ - -#define RINDEX -#include "strrchr.S" diff --git a/lib/libc/arch/i386/string/strncmp.S b/lib/libc/arch/i386/string/strncmp.S deleted file mode 100644 index 12be5b791..000000000 --- a/lib/libc/arch/i386/string/strncmp.S +++ /dev/null @@ -1,117 +0,0 @@ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: strncmp.S,v 1.15 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -/* - * NOTE: I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cache. - */ - -ENTRY(strncmp) - pushl %ebx - movl 8(%esp),%eax - movl 12(%esp),%ecx - movl 16(%esp),%edx - testl %edx,%edx - jmp L2 /* Jump into the loop! */ - - _ALIGN_TEXT,0x90 -L1: incl %eax - incl %ecx - decl %edx -L2: jz L4 /* strings are equal */ - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - jne L3 - - incl %eax - incl %ecx - decl %edx - jz L4 - movb (%eax),%bl - testb %bl,%bl - jz L3 - cmpb %bl,(%ecx) - je L1 - - _ALIGN_TEXT,0x90 -L3: movzbl (%eax),%eax /* unsigned comparison */ - movzbl (%ecx),%ecx - subl %ecx,%eax - popl %ebx - ret - _ALIGN_TEXT,0x90 -L4: xorl %eax,%eax - popl %ebx - ret -END(strncmp) diff --git a/lib/libc/arch/i386/string/swab.S b/lib/libc/arch/i386/string/swab.S deleted file mode 100644 index f9ba179af..000000000 --- a/lib/libc/arch/i386/string/swab.S +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: swab.S,v 1.14 2014/05/23 02:34:19 uebayasi Exp $") -#endif - -/* - * On the i486, this code is negligibly faster than the code generated - * by gcc at about half the size. If my i386 databook is correct, it - * should be considerably faster than the gcc code on a i386. - */ - -ENTRY(swab) - pushl %esi - pushl %edi - movl 12(%esp),%esi - movl 16(%esp),%edi - movl 20(%esp),%ecx - - shrl $1,%ecx - testl $7,%ecx # copy first group of 1 to 7 words - jz L2 # while swapping alternate bytes. - _ALIGN_TEXT,0x90 -L1: lodsw - rorw $8,%ax - stosw - decl %ecx - testl $7,%ecx - jnz L1 - -L2: shrl $3,%ecx # copy remainder 8 words at a time - jz L4 # while swapping alternate bytes. - _ALIGN_TEXT,0x90 -L3: lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - lodsw - rorw $8,%ax - stosw - decl %ecx - jnz L3 - -L4: popl %edi - popl %esi - ret -END(swab) diff --git a/lib/libc/arch/i386/sys/__clone.S b/lib/libc/arch/i386/sys/__clone.S deleted file mode 100644 index 077347850..000000000 --- a/lib/libc/arch/i386/sys/__clone.S +++ /dev/null @@ -1,104 +0,0 @@ -/* $NetBSD: __clone.S,v 1.6 2014/05/23 02:34:19 uebayasi Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#include -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - .text - -/* - * int clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - pushl %ebp - - /* - * Sanity checks: func and stack may not be NULL. - */ - movl 8(%esp), %ebp - cmpl $0,%ebp /* function */ - je 3f - movl 12(%esp),%eax /* stack */ - cmpl $0,%eax - je 3f - - /* - * Set up the stack for the clone. - */ - movl 20(%esp),%ecx - movl %ecx,-4(%eax) /* argument */ - leal -4(%eax),%eax /* sp points to arg */ - - pushl %eax /* stack */ - pushl 20(%esp) /* flags */ - pushl $0 /* dummy return address */ - - SYSTRAP(__clone) - jc 4f - cmpl $0,%eax - jne 2f /* we're the parent */ - call *%ebp /* this is the clone, call the function */ - -#ifdef __PIC__ - PIC_PROLOGUE - pushl %eax /* clone does _exit(func(arg)); */ - call PIC_PLT(_C_LABEL(_exit)) - addl $4,%esp - PIC_EPILOGUE -#else - pushl %eax - call _C_LABEL(_exit) - addl $4,%esp -#endif - -2: - addl $12,%esp - popl %ebp - ret -3: - movl $EINVAL,%eax - jmp 5f -4: - addl $12,%esp -5: - popl %ebp - jmp CERROR -END(__clone) diff --git a/lib/libc/arch/i386/sys/__sigaction14_sigtramp.c b/lib/libc/arch/i386/sys/__sigaction14_sigtramp.c deleted file mode 100644 index dab72d14b..000000000 --- a/lib/libc/arch/i386/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.12 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.12 2008/04/28 20:22:56 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specified or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/i386/sys/__sigtramp2.S b/lib/libc/arch/i386/sys/__sigtramp2.S deleted file mode 100644 index d1a8415b5..000000000 --- a/lib/libc/arch/i386/sys/__sigtramp2.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.5 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The i386 signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * ucontext structure [12+sizeof(siginfo_t)] - * siginfo structure [12] - * pointer to ucontext structure [8] - * pointer to siginfo structure [4] - * sp-> signal number [0] - */ -NENTRY(__sigtramp_siginfo_2) - leal 12+128(%esp),%eax /* get address of ucontext */ - movl %eax,4(%esp) /* put it in the argument slot */ - /* fake return address already there */ - SYSTRAP(setcontext) /* do setcontext */ - movl $-1,4(%esp) /* if we return here, something is wrong */ - SYSTRAP(exit) /* exit */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/i386/sys/__syscall.S b/lib/libc/arch/i386/sys/__syscall.S deleted file mode 100644 index 796e56e26..000000000 --- a/lib/libc/arch/i386/sys/__syscall.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.5 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __syscall.S,v 1.5 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(__syscall) - pop %ecx /* rta */ - pop %eax /* syscall number */ - pop %edx /* junk */ - push %ecx - int $0x80 - push %ecx /* Keep stack frame consistant */ - push %ecx /* Keep stack frame consistant */ - jc err - ret -err: - jmp CERROR -END(__syscall) diff --git a/lib/libc/arch/i386/sys/__vfork14.S b/lib/libc/arch/i386/sys/__vfork14.S deleted file mode 100644 index d3e923ff8..000000000 --- a/lib/libc/arch/i386/sys/__vfork14.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __vfork14.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ -ENTRY(__vfork14) - popl %ecx /* my rta into %ecx */ - OSYSTRAP(__vfork14) /* don't clobber %ecx */ - jc err - decl %edx - andl %edx,%eax - jmp *%ecx -err: - pushl %ecx - jmp CERROR -END(__vfork14) diff --git a/lib/libc/arch/i386/sys/brk.S b/lib/libc/arch/i386/sys/brk.S deleted file mode 100644 index e4761a41a..000000000 --- a/lib/libc/arch/i386/sys/brk.S +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: brk.S,v 1.24 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)brk.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: brk.S,v 1.24 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl _C_LABEL(__minbrk) - .globl CURBRK - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data -_C_LABEL(__minbrk): - .long _end - .text - -ENTRY(_brk) -#ifdef __PIC__ - movl 4(%esp),%ecx - PIC_PROLOGUE - movl PIC_GOT(_C_LABEL(__minbrk)),%edx - PIC_EPILOGUE - cmpl %ecx,(%edx) - jb 1f - movl (%edx),%ecx - movl %ecx,4(%esp) -1: - OSYSTRAP(break) /* don't clobber %ecx */ - jc err - PIC_PROLOGUE - movl PIC_GOT(CURBRK),%edx # set up GOT addressing - PIC_EPILOGUE - movl %ecx,(%edx) - xorl %eax,%eax - ret -err: - jmp CERROR -#else - movl 4(%esp),%ecx - cmpl %ecx,_C_LABEL(__minbrk) - jb 1f - movl _C_LABEL(__minbrk),%ecx - movl %ecx,4(%esp) -1: - OSYSTRAP(break) /* don't clobber %ecx */ - jc err - movl %ecx,CURBRK - xorl %eax,%eax - ret -err: - jmp CERROR -#endif -END(_brk) diff --git a/lib/libc/arch/i386/sys/cerror.S b/lib/libc/arch/i386/sys/cerror.S deleted file mode 100644 index 927d6f80f..000000000 --- a/lib/libc/arch/i386/sys/cerror.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: cerror.S,v 1.18 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: cerror.S,v 1.18 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _C_LABEL(__errno) - .protected CERROR - -_ENTRY(CERROR) - pushl %eax -#ifdef __PIC__ - PIC_PROLOGUE - call PIC_PLT(_C_LABEL(__errno)) - PIC_EPILOGUE -#else - call _C_LABEL(__errno) -#endif /* __PIC__ */ - popl (%eax) - movl $-1,%eax - movl $-1,%edx - ret -END(CERROR) diff --git a/lib/libc/arch/i386/sys/exect.S b/lib/libc/arch/i386/sys/exect.S deleted file mode 100644 index 63e53806a..000000000 --- a/lib/libc/arch/i386/sys/exect.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: exect.S,v 1.15 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)exect.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: exect.S,v 1.15 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" -#include - -ENTRY(exect) - pushfl - orb $(PSL_T>>8),1(%esp) - popfl - SYSTRAP(execve) - jmp CERROR -END(exect) diff --git a/lib/libc/arch/i386/sys/fork.S b/lib/libc/arch/i386/sys/fork.S deleted file mode 100644 index 61dd06ff8..000000000 --- a/lib/libc/arch/i386/sys/fork.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: fork.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)fork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: fork.S,v 1.10 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -_SYSCALL(__fork,fork) - decl %edx /* from 1 to 0 in child, 0 to -1 in parent */ - andl %edx,%eax - ret /* pid = fork(); */ -END(__fork) diff --git a/lib/libc/arch/i386/sys/getcontext.S b/lib/libc/arch/i386/sys/getcontext.S deleted file mode 100644 index deb05098a..000000000 --- a/lib/libc/arch/i386/sys/getcontext.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.4 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.4 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -_SYSCALL(_getcontext,getcontext) - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx,(36 + 14 * 4)(%ecx) /* Adjust saved %eip ... */ - leal 4(%esp),%edx - movl %edx,(36 + 17 * 4)(%ecx) /* ... and %esp. */ - movl $0,(36 + 11 * 4)(%ecx) /* Arrange for return of 0. */ - xorl %eax,%eax - ret -END(_getcontext) diff --git a/lib/libc/arch/i386/sys/pipe.S b/lib/libc/arch/i386/sys/pipe.S deleted file mode 100644 index f6b30bf9b..000000000 --- a/lib/libc/arch/i386/sys/pipe.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: pipe.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)pipe.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: pipe.S,v 1.7 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -_SYSCALL(_pipe,pipe) - movl 4(%esp),%ecx - movl %eax,(%ecx) - movl %edx,4(%ecx) - xorl %eax,%eax - ret -END(_pipe) diff --git a/lib/libc/arch/i386/sys/ptrace.S b/lib/libc/arch/i386/sys/ptrace.S deleted file mode 100644 index 7f5e4e507..000000000 --- a/lib/libc/arch/i386/sys/ptrace.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.19 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)ptrace.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: ptrace.S,v 1.19 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _C_LABEL(__errno) - -ENTRY(ptrace) -#ifdef __PIC__ - PIC_PROLOGUE - call PIC_PLT(_C_LABEL(__errno)) - PIC_EPILOGUE -#else - call _C_LABEL(__errno) -#endif /* __PIC__ */ - xorl %edx,%edx - movl %edx,(%eax) - SYSTRAP(ptrace) - jc err - ret -err: - jmp CERROR -END(ptrace) diff --git a/lib/libc/arch/i386/sys/sbrk.S b/lib/libc/arch/i386/sys/sbrk.S deleted file mode 100644 index 35b9d18a3..000000000 --- a/lib/libc/arch/i386/sys/sbrk.S +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.22 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: sbrk.S,v 1.22 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl CURBRK - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data -CURBRK: .long _end - .text - -ENTRY(_sbrk) -#ifdef __PIC__ - movl 4(%esp),%ecx - PIC_PROLOGUE - movl PIC_GOT(CURBRK),%edx - PIC_EPILOGUE - movl (%edx),%eax - test %ecx,%ecx - jz out - addl %eax,%ecx - movl %ecx,4(%esp) - OSYSTRAP(break) /* don't clobber %ecx */ - jc err - PIC_PROLOGUE - movl PIC_GOT(CURBRK),%edx - PIC_EPILOGUE - movl (%edx),%eax - movl %ecx,(%edx) -out: - ret -err: - jmp CERROR -#else - movl 4(%esp),%ecx - movl CURBRK,%eax - test %ecx,%ecx - jz out - addl %eax,4(%esp) - OSYSTRAP(break) /* don't clobber %ecx */ - jc err - movl CURBRK,%eax - addl %ecx,CURBRK -out: - ret -err: - jmp CERROR -#endif -END(_sbrk) diff --git a/lib/libc/arch/i386/sys/shmat.S b/lib/libc/arch/i386/sys/shmat.S deleted file mode 100644 index 0e7842254..000000000 --- a/lib/libc/arch/i386/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:52 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/i386/sys/syscall.S b/lib/libc/arch/i386/sys/syscall.S deleted file mode 100644 index 86b7c4dcf..000000000 --- a/lib/libc/arch/i386/sys/syscall.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: syscall.S,v 1.13 2014/05/23 02:34:19 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: syscall.S,v 1.13 2014/05/23 02:34:19 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(syscall) - pop %ecx /* rta */ - pop %eax /* syscall number */ - push %ecx - int $0x80 - push %ecx /* Keep stack frame consistant */ - jc err - ret -err: - jmp CERROR -END(syscall) diff --git a/lib/libc/arch/ia64/Makefile.inc b/lib/libc/arch/ia64/Makefile.inc deleted file mode 100644 index 6c135b17b..000000000 --- a/lib/libc/arch/ia64/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2006/09/23 17:39:34 cherry Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S diff --git a/lib/libc/arch/ia64/SYS.h b/lib/libc/arch/ia64/SYS.h deleted file mode 100644 index 8ee7fb443..000000000 --- a/lib/libc/arch/ia64/SYS.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: SYS.h,v 1.1 2006/09/10 21:22:33 cherry 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 - -#include -#include - -#define RET { br.ret.sptk.few rp;; } - -#define CALLSYS_ERROR(name) \ - CALLSYS_NOERROR(name) \ -{ cmp.ne p6,p0=r0,r10; \ -(p6) br.cond.sptk.few __cerror ;; } - -#define SYSCALL(name) \ -ENTRY(name,0); /* XXX # of args? */ \ - CALLSYS_ERROR(name) - -#define SYSCALL_NOERROR(name) \ -ENTRY(name,0); /* XXX # of args? */ \ - CALLSYS_NOERROR(name) - -#define PSEUDO(label,name) \ -ENTRY(label,0); /* XXX # of args? */ \ - CALLSYS_ERROR(name); \ - RET; \ -END(label); - -#define PSEUDO_NOERROR(label,name) \ -ENTRY(label,0); /* XXX # of args? */ \ - CALLSYS_NOERROR(name); \ - RET; \ -END(label); - -#define RSYSCALL(name) \ - SYSCALL(name); \ - RET; \ -END(name) - -#define RSYSCALL_NOERROR(name) \ - SYSCALL_NOERROR(name); \ - RET; \ -END(name) - -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) diff --git a/lib/libc/arch/ia64/gdtoa/Makefile.inc b/lib/libc/arch/ia64/gdtoa/Makefile.inc deleted file mode 100644 index 43505eaa3..000000000 --- a/lib/libc/arch/ia64/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/09/22 12:09:24 cherry Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/ia64/gdtoa/arith.h b/lib/libc/arch/ia64/gdtoa/arith.h deleted file mode 100644 index 4fb91e5d4..000000000 --- a/lib/libc/arch/ia64/gdtoa/arith.h +++ /dev/null @@ -1,6 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/09/10 21:22:33 cherry Exp $ */ - -#define IEEE_LITTLE_ENDIAN -#ifndef _IEEE_FP -#define Sudden_Underflow -#endif diff --git a/lib/libc/arch/ia64/gdtoa/gd_qnan.h b/lib/libc/arch/ia64/gdtoa/gd_qnan.h deleted file mode 100644 index 92b073466..000000000 --- a/lib/libc/arch/ia64/gdtoa/gd_qnan.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/09/10 21:22:33 cherry Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff80000 diff --git a/lib/libc/arch/ia64/gen/Makefile.inc b/lib/libc/arch/ia64/gen/Makefile.inc deleted file mode 100644 index b6a01e782..000000000 --- a/lib/libc/arch/ia64/gen/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 2015/04/17 12:51:05 martin Exp $ - -SRCS+= _lwp.c -SRCS+= bswap16.c bswap32.c bswap64.c -SRCS+= setjmp.S _setjmp.S sigsetjmp.S -SRCS+= flt_rounds.c fpgetround.c fpsetround.c fpgetmask.c fpsetmask.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c - diff --git a/lib/libc/arch/ia64/gen/_lwp.c b/lib/libc/arch/ia64/gen/_lwp.c deleted file mode 100644 index f3c5f10fd..000000000 --- a/lib/libc/arch/ia64/gen/_lwp.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.1 2015/04/17 12:51:05 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nathan J. Williams. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.1 2015/04/17 12:51:05 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ -#if 0 - __greg_t *gr; - - getcontext(u); - gr = u->uc_mcontext.__gregs; - - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - gr[_REG_PC] = (unsigned long)start; - gr[_REG_T12] = (unsigned long) start; - gr[_REG_RA] = (unsigned long) _lwp_exit; - gr[_REG_A0] = (unsigned long) arg; - gr[_REG_SP] = ((unsigned long) (stack_base + stack_size)) & ~0x7; - gr[_REG_S6] = 0; - gr[_REG_UNIQUE] = (unsigned long)private; - - u->uc_flags |= _UC_TLSBASE; -#endif -} diff --git a/lib/libc/arch/ia64/gen/_setjmp.S b/lib/libc/arch/ia64/gen/_setjmp.S deleted file mode 100644 index 227fb42a8..000000000 --- a/lib/libc/arch/ia64/gen/_setjmp.S +++ /dev/null @@ -1,308 +0,0 @@ -// -// Copyright (c) 1999, 2000 -// Intel Corporation. -// All rights reserved. -// -// Redistribution and use in source and binary forms, with or without -// modification, are permitted provided that the following conditions -// are met: -// -// 1. Redistributions of source code must retain the above copyright -// notice, this list of conditions and the following disclaimer. -// -// 2. Redistributions in binary form must reproduce the above copyright -// notice, this list of conditions and the following disclaimer in the -// documentation and/or other materials provided with the distribution. -// -// 3. All advertising materials mentioning features or use of this software -// must display the following acknowledgement: -// -// This product includes software developed by Intel Corporation and -// its contributors. -// -// 4. Neither the name of Intel Corporation or its contributors may be -// used to endorse or promote products derived from this software -// without specific prior written permission. -// -// THIS SOFTWARE IS PROVIDED BY INTEL CORPORATION 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 INTEL CORPORATION 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. -// -// - -// -// Module Name: -// -// setjmp.s -// -// Abstract: -// -// Contains an implementation of setjmp and longjmp for the -// IA-64 architecture. - - .file "setjmp.s" - -#include -RCSID("$NetBSD: _setjmp.S,v 1.1 2015/04/17 12:51:05 martin Exp $"); - -#include - -// int _setjmp(struct jmp_buffer *) -// -// Setup a non-local goto. -// -// Description: -// -// SetJump stores the current register set in the area pointed to -// by "save". It returns zero. Subsequent calls to "LongJump" will -// restore the registers and return non-zero to the same location. -// -// On entry, r32 contains the pointer to the jmp_buffer -// - -ENTRY(_setjmp, 1) - add r10 = J_PREDS, r32 // skip Unats & pfs save area - add r11 = J_BSP, r32 - // - // save immediate context - // - mov r2 = ar.bsp // save backing store pointer - mov r3 = pr // save predicates - flushrs - ;; - // - // save user Unat register - // - mov r16 = ar.lc // save loop count register - mov r14 = ar.unat // save user Unat register - - st8 [r10] = r3, J_LC-J_PREDS - st8 [r11] = r2, J_R4-J_BSP - ;; - st8 [r10] = r16, J_R5-J_LC - st8 [r32] = r14, J_NATS // Note: Unat at the - // beginning of the save area - mov r15 = ar.pfs - ;; - // - // save preserved general registers & NaT's - // - .mem.offset 0,0 - st8.spill [r11] = r4, J_R6-J_R4 - .mem.offset 8,0 - st8.spill [r10] = r5, J_R7-J_R5 - ;; - .mem.offset 16,0 - st8.spill [r11] = r6, J_SP-J_R6 - .mem.offset 24,0 - st8.spill [r10] = r7, J_F3-J_R7 - ;; - st8.spill [r11] = sp, J_F2-J_SP - mov r16 = ar.rsc - ;; - // - // save spilled Unat and pfs registers - // - mov r2 = ar.unat // save Unat register after spill - mov ar.rsc = r0 - ;; - st8 [r32] = r2, J_PFS-J_NATS // save unat for spilled regs - mov r17 = ar.rnat - ;; - st8 [r32] = r15, J_RNAT-J_PFS // save pfs - mov ar.rsc = r16 - // - // save floating registers - // - stf.spill [r11] = f2, J_F4-J_F2 - stf.spill [r10] = f3, J_F5-J_F3 - ;; - stf.spill [r11] = f4, J_F16-J_F4 - stf.spill [r10] = f5, J_F17-J_F5 - ;; - stf.spill [r11] = f16, J_F18-J_F16 - stf.spill [r10] = f17, J_F19-J_F17 - ;; - stf.spill [r11] = f18, J_F20-J_F18 - stf.spill [r10] = f19, J_F21-J_F19 - ;; - stf.spill [r11] = f20, J_F22-J_F20 - stf.spill [r10] = f21, J_F23-J_F21 - ;; - stf.spill [r11] = f22, J_F24-J_F22 - stf.spill [r10] = f23, J_F25-J_F23 - ;; - stf.spill [r11] = f24, J_F26-J_F24 - stf.spill [r10] = f25, J_F27-J_F25 - ;; - stf.spill [r11] = f26, J_F28-J_F26 - stf.spill [r10] = f27, J_F29-J_F27 - ;; - stf.spill [r11] = f28, J_F30-J_F28 - stf.spill [r10] = f29, J_F31-J_F29 - ;; - stf.spill [r11] = f30, J_FPSR-J_F30 - stf.spill [r10] = f31, J_B0-J_F31 // size of f31 + fpsr - ;; - st8 [r32] = r17 - // - // save FPSR register & branch registers - // - mov r2 = ar.fpsr // save fpsr register - mov r3 = b0 - ;; - st8 [r11] = r2, J_B1-J_FPSR - st8 [r10] = r3, J_B2-J_B0 - mov r2 = b1 - mov r3 = b2 - ;; - st8 [r11] = r2, J_B3-J_B1 - st8 [r10] = r3, J_B4-J_B2 - mov r2 = b3 - mov r3 = b4 - ;; - st8 [r11] = r2, J_B5-J_B3 - st8 [r10] = r3 - mov r2 = b5 - ;; - st8 [r11] = r2 - ;; - // - // return - // - mov r8 = r0 // return 0 from setjmp - mov ar.unat = r14 // restore unat - br.ret.sptk b0 - -END(_setjmp) - - -// -// void _longjmp(struct jmp_buffer *, int val) -// -// Perform a non-local goto. -// -// Description: -// -// LongJump initializes the register set to the values saved by a -// previous 'SetJump' and jumps to the return location saved by that -// 'SetJump'. This has the effect of unwinding the stack and returning -// for a second time to the 'SetJump'. -// - -ENTRY(_longjmp, 2) - mov r14 = ar.rsc // get user RSC conf - mov r8 = r33 // return value - add r10 = J_PFS, r32 // get address of pfs - ;; - mov ar.rsc = r0 - add r11 = J_NATS, r32 - add r17 = J_RNAT, r32 - ;; - ld8 r15 = [r10], J_BSP-J_PFS // get pfs - ld8 r2 = [r11], J_LC-J_NATS // get unat for spilled regs - mov r31 = r32 - ;; - loadrs - mov ar.unat = r2 - cmp.eq p6,p0=0,r8 // Return value 0? - ;; - ld8 r16 = [r10], J_PREDS-J_BSP // get backing store pointer - ld8 r17 = [r17] // ar.rnat - mov ar.pfs = r15 - ;; - mov ar.bspstore = r16 -(p6) add r8 = 1, r0 - ;; - mov ar.rnat = r17 - mov ar.rsc = r14 // restore RSC conf - - ld8 r3 = [r11], J_R4-J_LC // get lc register - ld8 r2 = [r10], J_R5-J_PREDS // get predicates - ;; - mov pr = r2, -1 - mov ar.lc = r3 - // - // restore preserved general registers & NaT's - // - ld8.fill r4 = [r11], J_R6-J_R4 - ;; - ld8.fill r5 = [r10], J_R7-J_R5 - ld8.fill r6 = [r11], J_SP-J_R6 - ;; - ld8.fill r7 = [r10], J_F2-J_R7 - ld8.fill sp = [r11], J_F3-J_SP - ;; - // - // restore floating registers - // - ldf.fill f2 = [r10], J_F4-J_F2 - ldf.fill f3 = [r11], J_F5-J_F3 - ;; - ldf.fill f4 = [r10], J_F16-J_F4 - ldf.fill f5 = [r11], J_F17-J_F5 - ;; - ldf.fill f16 = [r10], J_F18-J_F16 - ldf.fill f17 = [r11], J_F19-J_F17 - ;; - ldf.fill f18 = [r10], J_F20-J_F18 - ldf.fill f19 = [r11], J_F21-J_F19 - ;; - ldf.fill f20 = [r10], J_F22-J_F20 - ldf.fill f21 = [r11], J_F23-J_F21 - ;; - ldf.fill f22 = [r10], J_F24-J_F22 - ldf.fill f23 = [r11], J_F25-J_F23 - ;; - ldf.fill f24 = [r10], J_F26-J_F24 - ldf.fill f25 = [r11], J_F27-J_F25 - ;; - ldf.fill f26 = [r10], J_F28-J_F26 - ldf.fill f27 = [r11], J_F29-J_F27 - ;; - ldf.fill f28 = [r10], J_F30-J_F28 - ldf.fill f29 = [r11], J_F31-J_F29 - ;; - ldf.fill f30 = [r10], J_FPSR-J_F30 - ldf.fill f31 = [r11], J_B0-J_F31 ;; - - // - // restore branch registers and fpsr - // - ld8 r16 = [r10], J_B1-J_FPSR // get fpsr - ld8 r17 = [r11], J_B2-J_B0 // get return pointer - ;; - mov ar.fpsr = r16 - mov b0 = r17 - ld8 r2 = [r10], J_B3-J_B1 - ld8 r3 = [r11], J_B4-J_B2 - ;; - mov b1 = r2 - mov b2 = r3 - ld8 r2 = [r10], J_B5-J_B3 - ld8 r3 = [r11] - ;; - mov b3 = r2 - mov b4 = r3 - ld8 r2 = [r10] - ld8 r21 = [r31] // get user unat - ;; - mov b5 = r2 - mov ar.unat = r21 - - // - // invalidate ALAT - // - invala ;; - - br.ret.sptk b0 - -END(_longjmp) diff --git a/lib/libc/arch/ia64/gen/flt_rounds.c b/lib/libc/arch/ia64/gen/flt_rounds.c deleted file mode 100644 index a48a42376..000000000 --- a/lib/libc/arch/ia64/gen/flt_rounds.c +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -/* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/flt_rounds.c,v 1.1 2004/07/19 08:17:24 das Exp $"); */ - -#include - -static const int map[] = { - 1, /* round to nearest */ - 3, /* round to zero */ - 2, /* round to negative infinity */ - 0 /* round to positive infinity */ -}; - -int -__flt_rounds(void) -{ - int x; - - __asm("mov %0=ar.fpsr" : "=r" (x)); - return (map[(x >> 10) & 0x03]); -} diff --git a/lib/libc/arch/ia64/gen/fpgetmask.c b/lib/libc/arch/ia64/gen/fpgetmask.c deleted file mode 100644 index 6bf750cbd..000000000 --- a/lib/libc/arch/ia64/gen/fpgetmask.c +++ /dev/null @@ -1,41 +0,0 @@ -/*- - * Copyright (c) 2001 Doug Rabson - * 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 -/* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/fpgetmask.c,v 1.4 2003/10/22 09:00:07 marcel Exp $"); */ - -#include -#include - -/* XXX: Move to sysarchs() */ -fp_except -fpgetmask(void) -{ - uint64_t fpsr; - - __asm __volatile("mov %0=ar.fpsr" : "=r" (fpsr)); - return (~fpsr & 0x3d); -} diff --git a/lib/libc/arch/ia64/gen/fpgetround.c b/lib/libc/arch/ia64/gen/fpgetround.c deleted file mode 100644 index 407edce74..000000000 --- a/lib/libc/arch/ia64/gen/fpgetround.c +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2003 Marcel Moolenaar - * 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 ``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. - * - * $FreeBSD: src/lib/libc/ia64/gen/fpgetround.c,v 1.1 2003/01/11 07:24:54 marcel Exp $ - */ - -#include -#include - -fp_rnd -fpgetround(void) -{ - uint64_t fpsr; - - __asm __volatile("mov %0=ar.fpsr" : "=r"(fpsr)); - return ((fp_rnd)((fpsr >> 10) & 3)); -} diff --git a/lib/libc/arch/ia64/gen/fpsetmask.c b/lib/libc/arch/ia64/gen/fpsetmask.c deleted file mode 100644 index ea87938c1..000000000 --- a/lib/libc/arch/ia64/gen/fpsetmask.c +++ /dev/null @@ -1,44 +0,0 @@ -/*- - * Copyright (c) 2001 Doug Rabson - * 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 -/* __FBSDID("$FreeBSD: src/lib/libc/ia64/gen/fpsetmask.c,v 1.4 2003/10/22 09:00:07 marcel Exp $"); */ - -#include -#include - -fp_except -fpsetmask(fp_except mask) -{ - int64_t fpsr; - int64_t oldmask; - - __asm __volatile("mov %0=ar.fpsr" : "=r" (fpsr)); - oldmask = ~fpsr & 0x3d; - fpsr = (fpsr & ~0x3d) | (~mask & 0x3d); - __asm __volatile("mov ar.fpsr=%0" :: "r" (fpsr)); - return (oldmask); -} diff --git a/lib/libc/arch/ia64/gen/fpsetround.c b/lib/libc/arch/ia64/gen/fpsetround.c deleted file mode 100644 index 695540692..000000000 --- a/lib/libc/arch/ia64/gen/fpsetround.c +++ /dev/null @@ -1,43 +0,0 @@ -/* - * Copyright (c) 2003 Marcel Moolenaar - * 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 ``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. - * - * $FreeBSD: src/lib/libc/ia64/gen/fpsetround.c,v 1.1 2003/01/11 07:24:54 marcel Exp $ - */ - -#include -#include - -fp_rnd -fpsetround(fp_rnd rnd) -{ - uint64_t fpsr; - fp_rnd prev; - - __asm __volatile("mov %0=ar.fpsr" : "=r"(fpsr)); - prev = (fp_rnd)((fpsr >> 10) & 3); - fpsr = (fpsr & ~0xC00ULL) | ((unsigned int)rnd << 10); - __asm __volatile("mov ar.fpsr=%0" :: "r"(fpsr)); - return (prev); -} diff --git a/lib/libc/arch/ia64/gen/setjmp.S b/lib/libc/arch/ia64/gen/setjmp.S deleted file mode 100644 index f35e8cd57..000000000 --- a/lib/libc/arch/ia64/gen/setjmp.S +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.1 2015/04/17 12:51:05 martin 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. - */ - -#define _LOCORE -#include - -RCSID("$NetBSD: setjmp.S,v 1.1 2015/04/17 12:51:05 martin Exp $") - -#include - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and the previous signal state. - */ - -ENTRY(__setjmp14, 1) - alloc loc0=ar.pfs,1,2,3,0 - mov loc1=rp - ;; - mov out0=1 // how = SIG_BLOCK - mov out1=0 // set = NULL - add out2=J_SIGSET,in0 // oset = &jb[J_SIGSET] - br.call.sptk.few rp=_sys___sigprocmask14 - ;; - mov rp=loc1 - mov r14=loc0 - ;; - alloc r15=ar.pfs,1,0,0,0 // drop register frame - ;; - mov ar.pfs=r14 // restore ar.pfs - br.sptk.many _setjmp // finish saving state -END(__setjmp14) - -ENTRY(__longjmp14, 2) - alloc loc0=ar.pfs,2,2,3,0 - mov loc1=rp - ;; - mov out0=3 // how = SIG_SETMASK - add out1=J_SIGSET,in0 // set = &jb[J_SIGSET] - mov out2=0 // oset = NULL - br.call.sptk.few rp=_sys___sigprocmask14 - ;; - mov rp=loc1 - mov r14=loc0 - ;; - alloc r15=ar.pfs,2,0,0,0 // drop register frame - ;; - mov ar.pfs=r14 // restore ar.pfs - br.sptk.many _longjmp // finish restoring state -END(__longjmp14) diff --git a/lib/libc/arch/ia64/gen/sigsetjmp.S b/lib/libc/arch/ia64/gen/sigsetjmp.S deleted file mode 100644 index 1ac0dc149..000000000 --- a/lib/libc/arch/ia64/gen/sigsetjmp.S +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.1 2015/04/17 12:51:05 martin 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 -RCSID("$NetBSD: sigsetjmp.S,v 1.1 2015/04/17 12:51:05 martin Exp $"); - -#include - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, mask) - * by restoring registers from the stack. - * If `mask' is non-zero, the previous signal - * state will be restored. - */ - -ENTRY(__sigsetjmp14, 2) - add r14=J_SIGMASK,in0 // place to save mask - cmp.ne p6,p7=0,in1 // save signal state? - ;; - st8 [r14]=in1 // save mask value -(p6) br.cond.dptk.many __setjmp14 -(p7) br.cond.dpnt.many _setjmp -END(__sigsetjmp14) - -ENTRY(__siglongjmp14, 2) - add r14=J_SIGMASK,in0 // address of mask value - ;; - ld8 r14=[r14] - ;; - cmp.ne p6,p7=0,r14 // did we save signals? -(p6) br.cond.dptk.many __longjmp14 -(p7) br.cond.dpnt.many _longjmp -END(__siglongjmp14) diff --git a/lib/libc/arch/ia64/net/Makefile.inc b/lib/libc/arch/ia64/net/Makefile.inc deleted file mode 100644 index fa364cfe5..000000000 --- a/lib/libc/arch/ia64/net/Makefile.inc +++ /dev/null @@ -1,2 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/09/10 21:22:33 cherry Exp $ -# XXX: Stub diff --git a/lib/libc/arch/ia64/stdlib/Makefile.inc b/lib/libc/arch/ia64/stdlib/Makefile.inc deleted file mode 100644 index d1dda0262..000000000 --- a/lib/libc/arch/ia64/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/07/31 20:39:59 dsl Exp $ diff --git a/lib/libc/arch/ia64/string/Makefile.inc b/lib/libc/arch/ia64/string/Makefile.inc deleted file mode 100644 index eebf40a43..000000000 --- a/lib/libc/arch/ia64/string/Makefile.inc +++ /dev/null @@ -1,2 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/07/30 20:57:16 dsl Exp $ - diff --git a/lib/libc/arch/ia64/sys/__clone.S b/lib/libc/arch/ia64/sys/__clone.S deleted file mode 100644 index a62702e14..000000000 --- a/lib/libc/arch/ia64/sys/__clone.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: __clone.S,v 1.1 2006/09/10 21:22:34 cherry Exp $ */ - -/* XXX: Stub */ \ No newline at end of file diff --git a/lib/libc/arch/ia64/sys/__sigaction14_sigtramp.c b/lib/libc/arch/ia64/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 77451d093..000000000 --- a/lib/libc/arch/ia64/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specified or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/ia64/sys/__sigtramp2.S b/lib/libc/arch/ia64/sys/__sigtramp2.S deleted file mode 100644 index a305ed4ff..000000000 --- a/lib/libc/arch/ia64/sys/__sigtramp2.S +++ /dev/null @@ -1,12 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.1 2006/09/23 17:39:34 cherry Exp $ */ - -#include "SYS.h" - -/* XXX: Fix this when we look at signal handling */ - -ENTRY(__sigtramp_siginfo_2, 2) - /* XXX: get pointer to ucontext */ - /* setcontext() ie. CALLSYS_NOERROR(setcontext) */ - /* get error code */ - CALLSYS_NOERROR(exit) /* exit */ -END(__sigtramp_siginfo_2) \ No newline at end of file diff --git a/lib/libc/arch/ia64/sys/__syscall.S b/lib/libc/arch/ia64/sys/__syscall.S deleted file mode 100644 index e3312dbea..000000000 --- a/lib/libc/arch/ia64/sys/__syscall.S +++ /dev/null @@ -1,7 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.2 2006/09/22 12:09:25 cherry Exp $ */ - -#include "SYS.h" - - -RSYSCALL(__syscall) - diff --git a/lib/libc/arch/ia64/sys/__vfork14.S b/lib/libc/arch/ia64/sys/__vfork14.S deleted file mode 100644 index 324396f02..000000000 --- a/lib/libc/arch/ia64/sys/__vfork14.S +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.2 2006/09/22 17:59:47 cherry Exp $ */ - -#include "SYS.h" - -SYSCALL(__vfork14) - /* XXX: watchout for return values for child/parent */ - RET -END(__vfork14) diff --git a/lib/libc/arch/ia64/sys/brk.S b/lib/libc/arch/ia64/sys/brk.S deleted file mode 100644 index 8be7e907f..000000000 --- a/lib/libc/arch/ia64/sys/brk.S +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: brk.S,v 1.2 2006/09/23 17:39:34 cherry 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 -/* __FBSDID("$FreeBSD: src/lib/libc/ia64/sys/brk.S,v 1.4 2003/05/16 21:26:39 marcel Exp $"); */ - -#include "SYS.h" - - .globl _end -IMPORT(__curbrk, 8) - - .data -EXPORT(__minbrk) - .quad _end - - .text -ENTRY(_brk, 1) - add r14=@ltoff(__minbrk),gp ;; - ld8 r14=[r14] ;; - ld8 r14=[r14] ;; - cmp.ltu p6,p0=r32,r14 ;; -(p6) mov r32=r14 ;; - st8 [sp]=r32 - CALLSYS_ERROR(break) - ld8 r15=[sp] - add r14=@ltoff(__curbrk),gp ;; - ld8 r14=[r14] ;; - st8 [r14]=r15 - mov ret0=0 - br.ret.sptk.few rp -END(_brk) diff --git a/lib/libc/arch/ia64/sys/cerror.S b/lib/libc/arch/ia64/sys/cerror.S deleted file mode 100644 index 769824104..000000000 --- a/lib/libc/arch/ia64/sys/cerror.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: cerror.S,v 1.2 2006/09/22 17:59:47 cherry Exp $ */ - -/*- - * Copyright (c) 2000 Doug Rabson - * 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 -/* __FBSDID("$FreeBSD: src/lib/libc/ia64/sys/cerror.S,v 1.2 2003/03/03 01:09:46 obrien Exp $"); */ - - -ENTRY(__cerror, 0) - alloc loc0=ar.pfs,0,3,1,0 - ;; - mov loc1=rp - mov loc2=ret0 - mov out0=ret0 - ;; - br.call.sptk.few rp=__errno - st4 [ret0]=loc2 - ;; - mov ret0=-1 - mov ar.pfs=loc0 - mov rp=loc1 - ;; - br.ret.sptk.few rp -END(__cerror) diff --git a/lib/libc/arch/ia64/sys/exect.S b/lib/libc/arch/ia64/sys/exect.S deleted file mode 100644 index 5a78ec0eb..000000000 --- a/lib/libc/arch/ia64/sys/exect.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: exect.S,v 1.1 2006/09/10 21:22:34 cherry Exp $ */ - -/* XXX: Stub */ \ No newline at end of file diff --git a/lib/libc/arch/ia64/sys/fork.S b/lib/libc/arch/ia64/sys/fork.S deleted file mode 100644 index c0df388ee..000000000 --- a/lib/libc/arch/ia64/sys/fork.S +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: fork.S,v 1.2 2006/09/23 17:39:34 cherry Exp $ */ - -#include "SYS.h" - -ENTRY(__fork, 0) - CALLSYS_ERROR(fork) - /* XXX: get return value for child */ - RET -END(__fork) \ No newline at end of file diff --git a/lib/libc/arch/ia64/sys/getcontext.S b/lib/libc/arch/ia64/sys/getcontext.S deleted file mode 100644 index ea491ab90..000000000 --- a/lib/libc/arch/ia64/sys/getcontext.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.1 2006/09/10 21:22:34 cherry Exp $ */ - -/* XXX: Stub */ \ No newline at end of file diff --git a/lib/libc/arch/ia64/sys/pipe.S b/lib/libc/arch/ia64/sys/pipe.S deleted file mode 100644 index e545e5a50..000000000 --- a/lib/libc/arch/ia64/sys/pipe.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: pipe.S,v 1.2 2006/09/23 17:39:34 cherry 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 -/* __FBSDID("$FreeBSD: src/lib/libc/ia64/sys/pipe.S,v 1.4 2003/05/16 21:26:39 marcel Exp $"); */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif -/* XXX: Relook param passing */ - -ENTRY(_pipe, 1) - st8 [sp]=r32 - CALLSYS_ERROR(pipe) - ld8 r14=[sp] - ;; - st4 [r14]=ret0,4 - ;; - st4 [r14]=ret1 - mov ret0=0 - br.ret.sptk.few rp -END(_pipe) diff --git a/lib/libc/arch/ia64/sys/ptrace.S b/lib/libc/arch/ia64/sys/ptrace.S deleted file mode 100644 index bea78b23a..000000000 --- a/lib/libc/arch/ia64/sys/ptrace.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.1 2006/09/10 21:22:34 cherry Exp $ */ - -/* XXX: Stub */ \ No newline at end of file diff --git a/lib/libc/arch/ia64/sys/sbrk.S b/lib/libc/arch/ia64/sys/sbrk.S deleted file mode 100644 index 2340e2fa4..000000000 --- a/lib/libc/arch/ia64/sys/sbrk.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.2 2006/09/23 17:39:34 cherry 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 -/* __FBSDID("$FreeBSD: src/lib/libc/ia64/sys/sbrk.S,v 1.5 2003/05/16 21:26:39 marcel Exp $"); */ - -#include "SYS.h" - - .globl _end - - .data -EXPORT(__curbrk) - .quad _end - - .text -ENTRY(_sbrk, 1) - add r14 = @ltoff(__curbrk), gp - ;; - ld8 r14 = [r14] - cmp.eq p6, p0 = r32, r0 - ;; - ld8 ret0 = [r14] -(p6) br.ret.sptk.few rp - ;; - add r32 = ret0, r32 - ;; - st8 [sp] = r32 - CALLSYS_ERROR(break) - ld8 r15 = [sp] - add r14 = @ltoff(__curbrk), gp - ;; - ld8 r14 = [r14] - ;; - ld8 ret0 = [r14] - st8 [r14] = r15 - br.ret.sptk.few rp -END(_sbrk) diff --git a/lib/libc/arch/ia64/sys/shmat.S b/lib/libc/arch/ia64/sys/shmat.S deleted file mode 100644 index cacc70093..000000000 --- a/lib/libc/arch/ia64/sys/shmat.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2006/09/10 21:22:34 cherry Exp $ */ - -/* XXX: Stub */ \ No newline at end of file diff --git a/lib/libc/arch/ia64/sys/syscall.S b/lib/libc/arch/ia64/sys/syscall.S deleted file mode 100644 index 21359c595..000000000 --- a/lib/libc/arch/ia64/sys/syscall.S +++ /dev/null @@ -1,7 +0,0 @@ -/* $NetBSD: syscall.S,v 1.2 2006/09/22 12:09:25 cherry Exp $ */ - -#include "SYS.h" - - -RSYSCALL(syscall) - diff --git a/lib/libc/arch/m68k/DEFS.h b/lib/libc/arch/m68k/DEFS.h deleted file mode 100644 index 1abc2d6b0..000000000 --- a/lib/libc/arch/m68k/DEFS.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: DEFS.h,v 1.3 1995/12/13 22:21:23 thorpej Exp $ */ - -#include diff --git a/lib/libc/arch/m68k/Makefile.inc b/lib/libc/arch/m68k/Makefile.inc deleted file mode 100644 index 34657e9e9..000000000 --- a/lib/libc/arch/m68k/Makefile.inc +++ /dev/null @@ -1,16 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.17 2014/03/04 06:30:40 matt Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S __m68k_read_tp.S __mmap.S - -ASM+= _lwp_getprivate.S mremap.S - -CPPFLAGS+= -I. # for assym.h - -.if ${MKSOFTFLOAT} != "no" -#CPPFLAGS+= -DSOFTFLOAT_NEED_FIXUNS -CPPFLAGS+= -DSOFTFLOAT -DSOFTFLOATM68K_FOR_GCC -. include -.elif ${MACHINE_ARCH} != "m68000" -.PATH : ${ARCHDIR}/hardfloat -. include "${ARCHDIR}/hardfloat/Makefile.inc" -.endif diff --git a/lib/libc/arch/m68k/SYS.h b/lib/libc/arch/m68k/SYS.h deleted file mode 100644 index e3393c695..000000000 --- a/lib/libc/arch/m68k/SYS.h +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: SYS.h,v 1.18 2013/07/24 15:38:07 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - */ - -#include -#include - -#ifdef __STDC__ -#define IMMEDIATE # -#define SYSTRAP(x) movl IMMEDIATE SYS_ ## x ## ,%d0; trap IMMEDIATE 0 -#else -#define SYSTRAP(x) movl #SYS_/**/x,%d0; trap #0 -#endif - -#define CERROR _C_LABEL(__cerror) - -#define _SYSCALL_NOERROR(x,y) \ - ENTRY(x); \ - SYSTRAP(y) - -#define _SYSCALL(x,y) \ - _SYSCALL_NOERROR(x,y); \ - jcs CERROR - -#define SYSCALL_NOERROR(x) \ - _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ - rts; \ - END(x) - -#define PSEUDO(x,y) \ - _SYSCALL(x,y); \ - rts; \ - END(x) - -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) \ - PSEUDO(x,x) - -#ifdef WEAK_ALIAS -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) -#else -#define WSYSCALL(weak,strong) \ - PSEUDO(weak,weak) -#endif - -#define ASMSTR .asciz - - .globl CERROR - .hidden CERROR diff --git a/lib/libc/arch/m68k/gdtoa/Makefile.inc b/lib/libc/arch/m68k/gdtoa/Makefile.inc deleted file mode 100644 index ee69deb22..000000000 --- a/lib/libc/arch/m68k/gdtoa/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2014/03/18 18:20:37 riastradh Exp $ - -SRCS+= strtof.c - -.if ${MACHINE_ARCH} == "m68k" -SRCS+= strtold_pxL.c -SRCS+= strtopxL.c -.endif diff --git a/lib/libc/arch/m68k/gdtoa/arith.h b/lib/libc/arch/m68k/gdtoa/arith.h deleted file mode 100644 index 4674f629c..000000000 --- a/lib/libc/arch/m68k/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_BIG_ENDIAN diff --git a/lib/libc/arch/m68k/gdtoa/gd_qnan.h b/lib/libc/arch/m68k/gdtoa/gd_qnan.h deleted file mode 100644 index eb22e0b82..000000000 --- a/lib/libc/arch/m68k/gdtoa/gd_qnan.h +++ /dev/null @@ -1,10 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 -#ifndef __mc68010__ -#define ld_QNAN0 0x7fff0000 -#define ld_QNAN1 0x40000000 -#define ld_QNAN2 0x0 -#endif diff --git a/lib/libc/arch/m68k/gen/Makefile.inc b/lib/libc/arch/m68k/gen/Makefile.inc deleted file mode 100644 index 8ff2517f4..000000000 --- a/lib/libc/arch/m68k/gen/Makefile.inc +++ /dev/null @@ -1,58 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.33 2014/03/18 18:20:37 riastradh Exp $ - -SRCS+= alloca.S fabs.S - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c - -# 68000-based machines use a double-extended `long double' type -# for which the generic ieee754 versions can be used -.if ${MACHINE_ARCH} != "m68k" -SRCS+= infinityl_dbl_ieee754.c -.else -SRCS+= infinityl.c -SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c signbitl.c -.endif - -SRCS+= ashlsi3.S ashrsi3.S \ - lshlsi3.S lshrsi3.S \ - negdf2.S negsf2.S -SRCS+= bswap16.S bswap32.S bswap64.S -SRCS+= _lwp.c -CPPFLAGS._lwp.c += -D_LIBC_SOURCE - -# 68000-based machines build with a libgcc that includes -# much of the (soft)float and integer support that would -# otherwise be compiled here. -.if (${MACHINE_ARCH} == "m68000" || ${MKSOFTFLOAT} == "yes") -SRCS+= modf_ieee754.c # generic ieee754 version -SRCS+= flt_rounds_softfloat.S -.if ${MKSOFTFLOAT} != "yes" -SRCS+= fpfake.c -.endif -.endif - -.if ${MACHINE_ARCH} == "m68k" -SRCS+= divsi3.S modsi3.S mulsi3.S udivsi3.S umodsi3.S umulsi3.S -.endif - -SRCS+= setjmp.S longjmp.c -SRCS+= _setjmp.S -SRCS+= sigsetjmp.S - -SRCS+= makecontext.c resumecontext.S swapcontext.S - -SRCS+= ldexp_ieee754.c # generic ieee754 version - -LSRCS.m68k.gen= Lint_bswap16.c Lint_bswap32.c Lint_bswap64.c \ - Lint_resumecontext.c Lint_swapcontext.c -LSRCS+= ${LSRCS.m68k.gen} -DPSRCS+= ${LSRCS.m68k.gen} -CLEANFILES+= ${LSRCS.m68k.gen} diff --git a/lib/libc/arch/m68k/gen/_lwp.c b/lib/libc/arch/m68k/gen/_lwp.c deleted file mode 100644 index ce0e16d47..000000000 --- a/lib/libc/arch/m68k/gen/_lwp.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.8 2012/03/18 16:26:34 christos Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nathan J. Williams and Steve C. Woodford. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.8 2012/03/18 16:26:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *tcb, caddr_t stack_base, size_t stack_size) -{ - void **sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - u->uc_mcontext.__gregs[_REG_PC] = (int)start; - - sp = (void **)(void *)(stack_base + stack_size); - - *--sp = arg; - *--sp = (void *) _lwp_exit; - - u->uc_mcontext.__gregs[_REG_A7] = (int) sp; - u->uc_mcontext._mc_tlsbase = (uintptr_t)tcb + TLS_TP_OFFSET + - sizeof(struct tls_tcb); - u->uc_flags |= _UC_TLSBASE; -} diff --git a/lib/libc/arch/m68k/gen/_setjmp.S b/lib/libc/arch/m68k/gen/_setjmp.S deleted file mode 100644 index 99add3220..000000000 --- a/lib/libc/arch/m68k/gen/_setjmp.S +++ /dev/null @@ -1,90 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.9 2013/07/16 22:12:20 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)_setjmp.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: _setjmp.S,v 1.9 2013/07/16 22:12:20 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * _setjmp(a) - * by restoring registers from the stack, - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - movl 4(%sp),%a0 /* save area pointer */ - clrl (%a0)+ /* no old onstack */ - clrl (%a0)+ /* no old sigmask */ - movl %sp,(%a0)+ /* save old SP */ - movl %a6,(%a0)+ /* save old FP */ - clrl (%a0)+ /* no old AP */ - movl (%sp),(%a0)+ /* save old PC */ - clrl (%a0)+ /* clear PS */ - moveml #0x3CFC,(%a0) /* save other non-scratch regs */ - clrl %d0 /* return zero */ - rts -END(_setjmp) - -ENTRY(_longjmp) - movl 4(%sp),%a0 /* save area pointer */ - addql #8,%a0 /* skip onstack/sigmask */ - tstl (%a0) /* ensure non-zero SP */ - jeq botch /* oops! */ - movl 8(%sp),%d0 /* grab return value */ - jne ok /* non-zero ok */ - moveq #1,%d0 /* else make non-zero */ -ok: - movl (%a0)+,%sp /* restore SP */ - movl (%a0)+,%a6 /* restore FP */ - addql #4,%a0 /* skip AP */ - movl (%a0)+,(%sp) /* restore PC */ - moveml 4(%a0),#0x3CFC /* restore non-scratch regs */ - rts - -botch: - jbsr PIC_PLT(_C_LABEL(longjmperror)) - stop #0 -END(_longjmp) diff --git a/lib/libc/arch/m68k/gen/alloca.S b/lib/libc/arch/m68k/gen/alloca.S deleted file mode 100644 index 106edad5d..000000000 --- a/lib/libc/arch/m68k/gen/alloca.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: alloca.S,v 1.9 2013/07/17 04:57:55 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)alloca.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: alloca.S,v 1.9 2013/07/17 04:57:55 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* like alloc, but automatic free in return */ - -ENTRY(alloca) - movl (%sp),%a1 /* save return addr */ - movl %sp,%d0 /* get current SP value */ - subl 4(%sp),%d0 /* allocate requested space */ - movql #-4,%d1 /* sign extend a mask */ - andl %d1,%d0 /* longword align for efficiency */ - addql #8,%d0 /* reuse space of call frame */ - movl %d0,%sp /* set new SP value */ - subql #4,%sp /* account for argument pop in caller */ -#ifdef __SVR4_ABI__ - moveal %d0,%a0 -#endif - jmp (%a1) /* funny return */ -END(alloca) diff --git a/lib/libc/arch/m68k/gen/ashlsi3.S b/lib/libc/arch/m68k/gen/ashlsi3.S deleted file mode 100644 index 15dd43947..000000000 --- a/lib/libc/arch/m68k/gen/ashlsi3.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: ashlsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)ashlsi3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: ashlsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* int << int */ -ENTRY(__ashlsi3) - movel 8(%sp),%d1 - movel 4(%sp),%d0 - asll %d1,%d0 - rts -END(__ashlsi3) diff --git a/lib/libc/arch/m68k/gen/ashrsi3.S b/lib/libc/arch/m68k/gen/ashrsi3.S deleted file mode 100644 index c8556e19b..000000000 --- a/lib/libc/arch/m68k/gen/ashrsi3.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: ashrsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)ashrsi3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: ashrsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* int >> int */ -ENTRY(__ashrsi3) - movel 8(%sp),%d1 - movel 4(%sp),%d0 - asrl %d1,%d0 - rts -END(__ashrsi3) diff --git a/lib/libc/arch/m68k/gen/fabs.S b/lib/libc/arch/m68k/gen/fabs.S deleted file mode 100644 index faee6429a..000000000 --- a/lib/libc/arch/m68k/gen/fabs.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: fabs.S,v 1.11 2013/07/17 06:43:32 matt Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -RCSID("$NetBSD: fabs.S,v 1.11 2013/07/17 06:43:32 matt Exp $") - -ENTRY(fabs) -#if defined(__SVR4_ABI__) && defined(__HAVE_FPU__) - bclr #31,4(%sp) - fmoved 4(%sp),%fp0 -#else - movl 4(%sp),%d0 - movl 8(%sp),%d1 - bclr #31,%d0 -#endif - rts -END(fabs) diff --git a/lib/libc/arch/m68k/gen/flt_rounds_softfloat.S b/lib/libc/arch/m68k/gen/flt_rounds_softfloat.S deleted file mode 100644 index c3c5755ed..000000000 --- a/lib/libc/arch/m68k/gen/flt_rounds_softfloat.S +++ /dev/null @@ -1,30 +0,0 @@ -/* $NetBSD: flt_rounds_softfloat.S,v 1.6 2014/03/18 18:20:37 riastradh Exp $ */ - -/* - * Written by J.T. Conklin, Apr 6, 1995 - * Public domain. - - * Broken by Bruce O'Neel Aug 4 2003 - gcc no longer seems to export fpCCR so this fails. - for now just return 0. - */ - -#include - - .text -#if 0 - /* NB: this is tied to the gcc-2.95 lb1sf68.asm: */ -_map: - .byte 1 /* round to nearest */ - .byte 0 /* round to zero */ - .byte 2 /* round to positive infinity */ - .byte 3 /* round to negative infinity */ -#endif - -ENTRY(__flt_rounds) - /* lea _C_LABEL(_fpCCR),%a0 | check the rounding mode */ - /* movew 6(%a0),%d0 | rounding mode in d0 */ - /* lea _map,%a0 */ - moveb #0,%d0 - rts -END(__flt_rounds) diff --git a/lib/libc/arch/m68k/gen/fpclassifyl.c b/lib/libc/arch/m68k/gen/fpclassifyl.c deleted file mode 100644 index 5caeebf56..000000000 --- a/lib/libc/arch/m68k/gen/fpclassifyl.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: fpclassifyl.c,v 1.3 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyl.c,v 1.3 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * IEEE 754 compatible 80-bit extended-precision Motorola 68k version - */ -int -__fpclassifyl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - _DIAGASSERT(u.extu_ext.ext_zero == 0); - - if (u.extu_ext.ext_exp == 0 && - (u.extu_ext.ext_frach & 0x80000000) == 0) { - if ((u.extu_ext.ext_frach & 0x7fffffff) == 0 && - u.extu_ext.ext_fracl == 0) - return FP_ZERO; - else - return FP_SUBNORMAL; - } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) { - if ((u.extu_ext.ext_frach & 0x7fffffff) == 0 && - u.extu_ext.ext_fracl == 0) - return FP_INFINITE; - else - return FP_NAN; - } - - return FP_NORMAL; -} diff --git a/lib/libc/arch/m68k/gen/fpfake.c b/lib/libc/arch/m68k/gen/fpfake.c deleted file mode 100644 index 6911f0173..000000000 --- a/lib/libc/arch/m68k/gen/fpfake.c +++ /dev/null @@ -1,40 +0,0 @@ -#include - -fp_except -fpgetmask(void) -{ - return 0; -} - -fp_rnd -fpgetround(void) -{ - return 0; -} - -fp_except -fpgetsticky(void) -{ - return 0; -} - -/* ARGSUSED */ -fp_except -fpsetmask(fp_except mask) -{ - return 0; -} - -/* ARGSUSED */ -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - return 0; -} - -/* ARGSUSED */ -fp_except -fpsetsticky(fp_except sticky) -{ - return 0; -} diff --git a/lib/libc/arch/m68k/gen/infinityl.c b/lib/libc/arch/m68k/gen/infinityl.c deleted file mode 100644 index 775388c04..000000000 --- a/lib/libc/arch/m68k/gen/infinityl.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:26 lukem Exp $ */ - -/* - * IEEE-compatible infinityl.c for Motorola 68k 80-bit format -- public domain. - * Note that the representation includes 16 bits of padding between exponent - * and mantissa. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:26 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include - -const union __long_double_u __infinityl = - { { 0x7f, 0xff, 0, 0, 0x80, 0, 0, 0, 0, 0, 0, 0 } }; diff --git a/lib/libc/arch/m68k/gen/isfinitel.c b/lib/libc/arch/m68k/gen/isfinitel.c deleted file mode 100644 index 8b1fd9781..000000000 --- a/lib/libc/arch/m68k/gen/isfinitel.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: isfinitel.c,v 1.2 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinitel.c,v 1.2 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * IEEE 754 compatible 80-bit extended-precision Motorola 68k version - */ -int -__isfinitel(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - _DIAGASSERT(u.extu_ext.ext_zero == 0); - - if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) - return 0; - - return 1; -} diff --git a/lib/libc/arch/m68k/gen/isinfl.c b/lib/libc/arch/m68k/gen/isinfl.c deleted file mode 100644 index b67676f22..000000000 --- a/lib/libc/arch/m68k/gen/isinfl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: isinfl.c,v 1.6 2009/01/30 07:00:45 mhitch Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinfl.c,v 1.6 2009/01/30 07:00:45 mhitch Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.3 isinf - test for infinity - * IEEE 754 compatible 80-bit extended-precision Motorola 68k version - */ -int -__isinfl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - /* Note: the explicit integer bit is "don't care". */ - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - ((u.extu_ext.ext_frach & 0x7fffffff) == 0 && u.extu_ext.ext_fracl == 0)); -} diff --git a/lib/libc/arch/m68k/gen/isnanl.c b/lib/libc/arch/m68k/gen/isnanl.c deleted file mode 100644 index d046f7d33..000000000 --- a/lib/libc/arch/m68k/gen/isnanl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnanl.c,v 1.5 2004/03/04 23:42:38 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.4 isnan - test for a NaN - * IEEE 754 compatible 80-bit extended-precision Motorola 68k version - */ -int -__isnanl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - /* Note: the explicit integer bit is "don't care". */ - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - (u.extu_ext.ext_frach != 0 || u.extu_ext.ext_fracl != 0)); -} diff --git a/lib/libc/arch/m68k/gen/ldexp_881.c b/lib/libc/arch/m68k/gen/ldexp_881.c deleted file mode 100644 index ab4a0a4e1..000000000 --- a/lib/libc/arch/m68k/gen/ldexp_881.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: ldexp_881.c,v 1.3 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ldexp_881.c,v 1.3 2008/04/28 20:22:56 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * ldexp(value, exp): return value * (2 ** exp). - */ -double -ldexp(value, exp2) - double value; - int exp2; -{ - double temp; - - __asm ("fscalel %2,%1" - : "=f" (temp) - : "0" (value), "g" (exp2)); - return (temp); -} diff --git a/lib/libc/arch/m68k/gen/longjmp.c b/lib/libc/arch/m68k/gen/longjmp.c deleted file mode 100644 index e8d5d0387..000000000 --- a/lib/libc/arch/m68k/gen/longjmp.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $NetBSD: longjmp.c,v 1.2 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christian Limpach. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include - -typedef struct { - __greg_t __data[6]; - __greg_t __addr[4]; -} __jmp_buf_regs_t; - -void -__longjmp14(jmp_buf env, int val) -{ - struct sigcontext *sc = (void *)env; - __jmp_buf_regs_t *r = (void *)&sc[1]; - ucontext_t uc; - - /* Ensure non-zero SP */ - if (sc->sc_sp == 0) - goto err; - - /* Make return value non-zero */ - if (val == 0) - val = 1; - - /* Save return value in context */ - uc.uc_mcontext.__gregs[_REG_D0] = val; - - /* - * Set _UC_SIGMASK, _UC_CPU and _UC_M68K_UC_USER - * Set _UC_{SET,CLR}STACK according to SS_ONSTACK - */ - uc.uc_flags = _UC_SIGMASK | _UC_CPU | _UC_M68K_UC_USER | - (sc->sc_onstack ? _UC_SETSTACK : _UC_CLRSTACK); - - /* Clear uc_link */ - uc.uc_link = 0; - - /* Copy signal mask */ - uc.uc_sigmask = sc->sc_mask; - - /* Copy SP/PC/PS/FP */ - uc.uc_mcontext.__gregs[_REG_A7] = sc->sc_sp; - uc.uc_mcontext.__gregs[_REG_PC] = sc->sc_pc; - uc.uc_mcontext.__gregs[_REG_PS] = sc->sc_ps; - uc.uc_mcontext.__gregs[_REG_A6] = sc->sc_fp; - - /* Copy remaining non-scratch regs. */ - memcpy(&uc.uc_mcontext.__gregs[_REG_D2], - &r->__data, sizeof(r->__data)); - memcpy(&uc.uc_mcontext.__gregs[_REG_A2], - &r->__addr, sizeof(r->__addr)); - - setcontext(&uc); - err: - longjmperror(); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/m68k/gen/lshlsi3.S b/lib/libc/arch/m68k/gen/lshlsi3.S deleted file mode 100644 index 7a20b8092..000000000 --- a/lib/libc/arch/m68k/gen/lshlsi3.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: lshlsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)lshlsi3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: lshlsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* unsigned << unsigned */ -ENTRY(__lshlsi3) - movel 8(%sp),%d1 - movel 4(%sp),%d0 - lsll %d1,%d0 - rts -END(__lshlsi3) diff --git a/lib/libc/arch/m68k/gen/lshrsi3.S b/lib/libc/arch/m68k/gen/lshrsi3.S deleted file mode 100644 index 53601346b..000000000 --- a/lib/libc/arch/m68k/gen/lshrsi3.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: lshrsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)lshrsi3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: lshrsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* unsigned >> unsigned */ -ENTRY(__lshrsi3) - movel 8(%sp),%d1 - movel 4(%sp),%d0 - lsrl %d1,%d0 - rts -END(__lshrsi3) diff --git a/lib/libc/arch/m68k/gen/makecontext.c b/lib/libc/arch/m68k/gen/makecontext.c deleted file mode 100644 index 173904ea6..000000000 --- a/lib/libc/arch/m68k/gen/makecontext.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - mcontext_t *mcp = &ucp->uc_mcontext; - int *sp; - va_list ap; - - mcp->__gregs[_REG_PC] = (__greg_t)func; - - sp = (int *)((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - sp = (int *)((uintptr_t)sp & ~0x3); /* Align on word boundary. */ - sp -= (argc + 1); /* Make room for retaddr and args. */ - mcp->__gregs[_REG_A7] = (__greg_t)sp; - mcp->__gregs[_REG_A6] = 0; /* Wipe out frame pointer. */ - - *sp++ = (int)_resumecontext; - - va_start(ap, argc); - while (argc-- > 0) - *sp++ = va_arg(ap, int); - va_end(ap); -} diff --git a/lib/libc/arch/m68k/gen/nanf.c b/lib/libc/arch/m68k/gen/nanf.c deleted file mode 100644 index 8516c1b23..000000000 --- a/lib/libc/arch/m68k/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:01 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:01 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xc0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/m68k/gen/negdf2.S b/lib/libc/arch/m68k/gen/negdf2.S deleted file mode 100644 index 0ea21656e..000000000 --- a/lib/libc/arch/m68k/gen/negdf2.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: negdf2.S,v 1.10 2013/07/17 06:43:32 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)negdf2.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: negdf2.S,v 1.10 2013/07/17 06:43:32 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* -double */ -ENTRY(__negdf2) -#if defined(__SVR4_ABI__) && defined(__HAVE_FPU__) - fnegd 4(%sp),%fp0 -#else - movel 4(%sp),%d0 - movel 8(%sp),%d1 - bchg #31,%d0 -#endif - rts -END(__negdf2) diff --git a/lib/libc/arch/m68k/gen/negsf2.S b/lib/libc/arch/m68k/gen/negsf2.S deleted file mode 100644 index 9c2384b1d..000000000 --- a/lib/libc/arch/m68k/gen/negsf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: negsf2.S,v 1.10 2013/07/17 06:43:32 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID"from: @(#)negsf2.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: negsf2.S,v 1.10 2013/07/17 06:43:32 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* -single */ -ENTRY(__negsf2) -#if defined(__SVR4_ABI__) && defined(__HAVE_FPU__) - fnegs 4(%sp),%fp0 -#else - movel 4(%sp),%d0 - bchg #31,%d0 -#endif - rts -END(__negsf2) diff --git a/lib/libc/arch/m68k/gen/resumecontext.S b/lib/libc/arch/m68k/gen/resumecontext.S deleted file mode 100644 index 6169eed63..000000000 --- a/lib/libc/arch/m68k/gen/resumecontext.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: resumecontext.S,v 1.8 2013/07/17 03:04:54 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: resumecontext.S,v 1.8 2013/07/17 03:04:54 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -/* - * This assembly-language implementation differs from the (obvious) - * C-language implementation only in not clobbering the previous - * function's return address (us), which is the point of the exercise. - */ - -ENTRY(_resumecontext) - subl #(4 + UC_SIZE),%sp /* retaddr preservation + ucontext_t */ - lea (%sp),%a0 - movl %a0,-(%sp) - jbsr PIC_PLT(_C_LABEL(_getcontext)) - movl (4 + UC_LINK)(%sp),(%sp) /* uc_link */ - tstl (%sp) /* check for NULL */ - jne 1f - jbsr PIC_PLT(_C_LABEL(exit)) /* cleanly exit(0) */ - jmp 2f -1: jbsr PIC_PLT(_C_LABEL(setcontext)) - /* NOTREACHED */ - /* But just in case... */ -2: movl #-1,(%sp) - jbsr PIC_PLT(_C_LABEL(_exit)) - /* NOTREACHED */ -END(_resumecontext) diff --git a/lib/libc/arch/m68k/gen/setjmp.S b/lib/libc/arch/m68k/gen/setjmp.S deleted file mode 100644 index 3b6ff8d7d..000000000 --- a/lib/libc/arch/m68k/gen/setjmp.S +++ /dev/null @@ -1,94 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.15 2013/07/17 03:05:41 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)setjmp.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: setjmp.S,v 1.15 2013/07/17 03:05:41 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -ENTRY(__setjmp14) - /* Get signal stack info. Note overlay of ss_sp and ss_size! */ - lea -12(%sp),%sp /* sizeof(stack_t) */ - clrl (%sp) /* ss = NULL */ - movl %sp,4(%sp) /* oss = stack_t on stack */ - jbsr PIC_PLT(_C_LABEL(__sigaltstack14)) - - movl 8(%sp),%d0 /* ss_flags */ - andl #1,%d0 /* extract SS_ONSTACK */ - lea 12(%sp),%sp /* pop stack_t */ - - /* Get pointer to jmp_buf; a sigcontext is at the beginning. */ - movl 4(%sp),%a0 - movl %d0,SC_ONSTACK(%a0) /* store onstack */ - clrl SC___MASK13(%a0) /* unused word (old style signal mask) */ - - /* Get the signal mask. */ - pea SC_MASK(%a0) /* oset = &sc.sc_mask */ - movl #0,-(%sp) /* set = NULL */ - movl #0,-(%sp) /* action = 0 */ - jbsr PIC_PLT(_C_LABEL(__sigprocmask14)) - addl #12,%sp - - movl 4(%sp),%a0 /* get jmp_buf pointer again */ - lea 4(%sp),%a1 /* adjust SP since we won't rts */ - movl %a1,SC_SP(%a0) /* save SP */ - movl %a6,SC_FP(%a0) /* save FP */ - clrl SC_AP(%a0) /* no AP */ - movl (%sp),SC_PC(%a0)/* save return PC */ - clrl SC_PS(%a0) /* clear PS */ - - /* Save remaining non-scratch regs after signal mask. */ - moveml #0x3CFC,SC_SIZE(%a0) - - clrl %d0 /* return 0 */ - rts -END(__setjmp14) diff --git a/lib/libc/arch/m68k/gen/signbitl.c b/lib/libc/arch/m68k/gen/signbitl.c deleted file mode 100644 index 157471634..000000000 --- a/lib/libc/arch/m68k/gen/signbitl.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitl.c,v 1.2 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: signbitl.c,v 1.2 2008/04/28 20:22:56 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * IEEE 754 compatible 80-bit extended-precision Motorola 68k version - */ -int -__signbitl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_sign == 1); -} diff --git a/lib/libc/arch/m68k/gen/sigsetjmp.S b/lib/libc/arch/m68k/gen/sigsetjmp.S deleted file mode 100644 index 5f9af733a..000000000 --- a/lib/libc/arch/m68k/gen/sigsetjmp.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.10 2013/07/16 22:12:20 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)_setjmp.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: sigsetjmp.S,v 1.10 2013/07/16 22:12:20 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a,m) - * by restoring registers from the stack, - * The previous signal state is restored if 'm' was non-zero. - */ - -/* grab _JBLEN */ -#include - -ENTRY(__sigsetjmp14) - movl 8(%sp),%d1 /* grab the mask */ - movl 4(%sp),%a0 /* grab the area pointer */ - movl %d1,(_JBLEN * 4)(%a0) /* save at end of area */ - tstl %d1 - bne dosig - jra PIC_PLT(_C_LABEL(_setjmp)) -dosig: - jra PIC_PLT(_C_LABEL(__setjmp14)) -END(__sigsetjmp14) - - -ENTRY(__siglongjmp14) - movl 4(%sp),%a0 /* save area pointer */ - tstl (_JBLEN * 4)(%a0) /* check mask... */ - bne didsig - jra PIC_PLT(_C_LABEL(_longjmp)) -didsig: - jra PIC_PLT(_C_LABEL(__longjmp14)) -END(__siglongjmp14) diff --git a/lib/libc/arch/m68k/gen/swapcontext.S b/lib/libc/arch/m68k/gen/swapcontext.S deleted file mode 100644 index 142e311e6..000000000 --- a/lib/libc/arch/m68k/gen/swapcontext.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.6 2013/07/17 03:05:17 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.6 2013/07/17 03:05:17 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -ENTRY(swapcontext) - movl 4(%sp),-(%sp) | push oucp on stack - jbsr PIC_PLT(_C_LABEL(_getcontext)) | getcontext(oucp) - tstl %d0 | OK? - jne L1 - movl (%sp),%a0 - addql #8,UC_MCONTEXT_SP(%a0) | adjust saved stack pointer (again) - movl %sp@(4),UC_MCONTEXT_PC(%a0) | adjust saved program counter (again) - movl 12(%sp),(%sp) | push ucp on stack - jbsr PIC_PLT(_C_LABEL(setcontext)) | setcontext(ucp) -L1: addql #4,%sp | pop ucp - rts -END(swapcontext) diff --git a/lib/libc/arch/m68k/gen/umulsi3.S b/lib/libc/arch/m68k/gen/umulsi3.S deleted file mode 100644 index a60790302..000000000 --- a/lib/libc/arch/m68k/gen/umulsi3.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: umulsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)umulsi3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: umulsi3.S,v 1.7 2013/07/16 22:12:20 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* unsigned * unsigned */ -ENTRY(__umulsi3) - movel 4(%sp),%d0 - mulul 8(%sp),%d0 - rts -END(__umulsi3) diff --git a/lib/libc/arch/m68k/genassym.cf b/lib/libc/arch/m68k/genassym.cf deleted file mode 100644 index a9cad0aa4..000000000 --- a/lib/libc/arch/m68k/genassym.cf +++ /dev/null @@ -1,52 +0,0 @@ -# $NetBSD: genassym.cf,v 1.1 2013/07/17 01:41:17 matt Exp $ - -# -# Copyright (c) 2013 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include -include - -define UC_LINK offsetof(ucontext_t, uc_link) -define UC_SIGMASK offsetof(ucontext_t, uc_sigmask) -define UC_MCONTEXT_D0 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_D0]) -define UC_MCONTEXT_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_A7]) -define UC_MCONTEXT_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC]) -define UC_SIZE sizeof(ucontext_t) - -define SC_ONSTACK offsetof(struct sigcontext, sc_onstack) -define SC___MASK13 offsetof(struct sigcontext, __sc_mask13) -define SC_SP offsetof(struct sigcontext, sc_sp) -define SC_FP offsetof(struct sigcontext, sc_fp) -define SC_AP offsetof(struct sigcontext, sc_ap) -define SC_PC offsetof(struct sigcontext, sc_pc) -define SC_PS offsetof(struct sigcontext, sc_ps) -define SC_MASK offsetof(struct sigcontext, sc_mask) -define SC_SIZE sizeof(struct sigcontext) diff --git a/lib/libc/arch/m68k/hardfloat/Makefile.inc b/lib/libc/arch/m68k/hardfloat/Makefile.inc deleted file mode 100644 index 16af53557..000000000 --- a/lib/libc/arch/m68k/hardfloat/Makefile.inc +++ /dev/null @@ -1,16 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2014/03/18 18:20:37 riastradh Exp $ - -SRCS+= modf.S -SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c -# -# These allow softfloat programs to use the FPU. -# -SRCS+= adddf3.S addsf3.S cmpdf2.S cmpsf2.S divdf3.S divsf3.S \ - extendsfdf2.S fixdfsi.S fixunsdfsi.S fixunssfsi.S floatsidf.S \ - muldf3.S mulsf3.S subdf3.S subsf3.S truncdfsf2.S - -SRCS+= floatunsidf.S floatunsisf.S - -SRCS+= lesf2.S ltsf2.S nesf2.S unordsf2.S -SRCS+= ledf2.S ltdf2.S nedf2.S unorddf2.S diff --git a/lib/libc/arch/m68k/hardfloat/adddf3.S b/lib/libc/arch/m68k/hardfloat/adddf3.S deleted file mode 100644 index 7cc8dc39a..000000000 --- a/lib/libc/arch/m68k/hardfloat/adddf3.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: adddf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)adddf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: adddf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* double + double */ -ENTRY(__adddf3) - fmoved 4(%sp),%fp0 - faddd 12(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(__adddf3) diff --git a/lib/libc/arch/m68k/hardfloat/addsf3.S b/lib/libc/arch/m68k/hardfloat/addsf3.S deleted file mode 100644 index 27893dcaf..000000000 --- a/lib/libc/arch/m68k/hardfloat/addsf3.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: addsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)addsf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: addsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* single + single */ -ENTRY(__addsf3) - fmoves 4(%sp),%fp0 - fadds 8(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoves %fp0,%d0 -#endif - rts -END(__addsf3) diff --git a/lib/libc/arch/m68k/hardfloat/cmpdf2.S b/lib/libc/arch/m68k/hardfloat/cmpdf2.S deleted file mode 100644 index e75b9d673..000000000 --- a/lib/libc/arch/m68k/hardfloat/cmpdf2.S +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: cmpdf2.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)cmpdf2.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: cmpdf2.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* double > double: 1 */ -/* double < double: -1 */ -/* double == double: 0 */ -ENTRY(__cmpdf2) - fmoved 4(%sp),%fp0 - fcmpd 12(%sp),%fp0 - fbgt Lbgt -#ifdef __mcoldfire__ - fbeq Lbeq - movql #-1,%d0 -#else - fslt %d0 - extbl %d0 -#endif - rts -Lbgt: - moveq #1,%d0 - rts -#ifdef __mcoldfire__ -Lbeq: - clrl %d0 - rts -#endif -END(__cmpdf2) diff --git a/lib/libc/arch/m68k/hardfloat/cmpsf2.S b/lib/libc/arch/m68k/hardfloat/cmpsf2.S deleted file mode 100644 index 934d364e2..000000000 --- a/lib/libc/arch/m68k/hardfloat/cmpsf2.S +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: cmpsf2.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)cmpsf2.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: cmpsf2.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* single > single: 1 */ -/* single < single: -1 */ -/* single == single: 0 */ -ENTRY(__cmpsf2) - fmoves 4(%sp),%fp0 - fcmps 8(%sp),%fp0 - fbgt Lbgt -#ifdef __mcoldfire__ - fbeq Lbeq - movql #-1,%d0 -#else - fslt %d0 - extbl %d0 -#endif - rts -Lbgt: - moveq #1,%d0 - rts -#ifdef __mcoldfire__ -Lbeq: - clrl %d0 - rts -#endif -END(__cmpsf2) diff --git a/lib/libc/arch/m68k/hardfloat/divdf3.S b/lib/libc/arch/m68k/hardfloat/divdf3.S deleted file mode 100644 index 222d22367..000000000 --- a/lib/libc/arch/m68k/hardfloat/divdf3.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: divdf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)divdf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: divdf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* double / double */ -ENTRY(__divdf3) - fmoved 4(%sp),%fp0 - fdivd 12(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(__divdf3) diff --git a/lib/libc/arch/m68k/hardfloat/divsf3.S b/lib/libc/arch/m68k/hardfloat/divsf3.S deleted file mode 100644 index 0ee7b5c6d..000000000 --- a/lib/libc/arch/m68k/hardfloat/divsf3.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: divsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)divsf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: divsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* single / single */ -ENTRY(__divsf3) - fmoves 4(%sp),%fp0 - fdivs 8(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoves %fp0,%d0 -#endif - rts -END(__divsf3) diff --git a/lib/libc/arch/m68k/hardfloat/extendsfdf2.S b/lib/libc/arch/m68k/hardfloat/extendsfdf2.S deleted file mode 100644 index e3088d513..000000000 --- a/lib/libc/arch/m68k/hardfloat/extendsfdf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: extendsfdf2.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)extendsfdf2.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: extendsfdf2.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* (double) float */ -ENTRY(__extendsfdf2) - fmoves 4(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(__extendsfdf2) diff --git a/lib/libc/arch/m68k/hardfloat/fixdfsi.S b/lib/libc/arch/m68k/hardfloat/fixdfsi.S deleted file mode 100644 index 1303c786e..000000000 --- a/lib/libc/arch/m68k/hardfloat/fixdfsi.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: fixdfsi.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)fixdfsi.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: fixdfsi.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* (int) double */ -ENTRY(__fixdfsi) - fintrzd 4(%sp),%fp0 - fmovel %fp0,%d0 - rts -END(__fixdfsi) diff --git a/lib/libc/arch/m68k/hardfloat/fixunsdfsi.S b/lib/libc/arch/m68k/hardfloat/fixunsdfsi.S deleted file mode 100644 index f4f3f18aa..000000000 --- a/lib/libc/arch/m68k/hardfloat/fixunsdfsi.S +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: fixunsdfsi.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)fixunsdfsi.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: fixunsdfsi.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef __mcoldfire__ - .section .rodata,"a" - .p2align 4 -L2G: .double 0r2147483648.0 -#endif - -/* (unsigned) double */ -ENTRY(__fixunsdfsi) - fintrzd 4(%sp),%fp0 -#ifdef __mcoldfire__ - LEA_LCL(L2G,%a0) - fmoved (%a0),%fp1 - fcmpd %fp1,%fp0 -#else - fmoved #0r2147483648.0,%fp1 - fcmpx %fp1,%fp0 -#endif - fbge Lwaybig - fmovel %fp0,%d0 - rts -Lwaybig: -#ifdef __mcoldfire__ - fsubd %fp1,%fp0 -#else - fsubx %fp1,%fp0 -#endif - fmovel %fp0,%d0 - bset #31,%d0 - rts -END(__fixunsdfsi) diff --git a/lib/libc/arch/m68k/hardfloat/fixunssfsi.S b/lib/libc/arch/m68k/hardfloat/fixunssfsi.S deleted file mode 100644 index 5c77bee8b..000000000 --- a/lib/libc/arch/m68k/hardfloat/fixunssfsi.S +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: fixunssfsi.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)fixunssfsi.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: fixunssfsi.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef __mcoldfire__ - .section .rodata,"a" - .p2align 4 -L2G: .double 0r2147483648.0 -#endif - -/* single -> unsigned */ -ENTRY(__fixunssfsi) - fintrzs 4(%sp),%fp0 -#ifdef __mcoldfire__ - LEA_LCL(L2G,%a0) - fmoved (%a0),%fp1 - fcmpd %fp1,%fp0 -#else - fmoved #0r2147483648.0,%fp1 - fcmpx %fp1,%fp0 -#endif - fbge Lwaybig - fmovel %fp0,%d0 - rts -Lwaybig: -#ifdef __mcoldfire__ - fsubd %fp1,%fp0 -#else - fsubx %fp1,%fp0 -#endif - fmovel %fp0,%d0 - bset #31,%d0 - rts -END(__fixunssfsi) diff --git a/lib/libc/arch/m68k/hardfloat/floatsidf.S b/lib/libc/arch/m68k/hardfloat/floatsidf.S deleted file mode 100644 index 08f07a129..000000000 --- a/lib/libc/arch/m68k/hardfloat/floatsidf.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: floatsidf.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)floatsidf.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: floatsidf.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* (double) int */ -ENTRY(__floatsidf) - fmovel 4(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(__floatsidf) diff --git a/lib/libc/arch/m68k/hardfloat/floatunsidf.S b/lib/libc/arch/m68k/hardfloat/floatunsidf.S deleted file mode 100644 index 10a337f73..000000000 --- a/lib/libc/arch/m68k/hardfloat/floatunsidf.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: floatunsidf.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: floatunsidf.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -#ifdef __mcoldfire__ - .section .rodata,"a" - .p2align 2 -L2G: .double 0r2147483648.0 -#endif - -/* LINTSTUB: double __floatunsidf(unsigned int); */ -ENTRY(__floatunsidf) - movl 4(%sp),%d0 - jpl 1f - fmovel %d0,%fp0 -#ifdef __SVR4_ABI__ - rts -#else - jra Lret -#endif -1: - bclr #31,%d0 - fmovel %d0,%fp0 -#ifdef __mcoldfire__ - LEA_LCL(L2G,%a0) - faddd (%a0),%fp0 -#else - faddd #0r2147483648.0,%fp0 -#endif -#ifndef __SVR4_ABI__ -Lret: - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(__floatunsidf) diff --git a/lib/libc/arch/m68k/hardfloat/floatunsisf.S b/lib/libc/arch/m68k/hardfloat/floatunsisf.S deleted file mode 100644 index 864b5cc1d..000000000 --- a/lib/libc/arch/m68k/hardfloat/floatunsisf.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: floatunsisf.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: floatunsisf.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -#ifdef __mcoldfire__ - .section .rodata,"a" - .p2align 2 -L2G: .double 0r2147483648.0 -#endif - -/* LINTSTUB: double __floatunsisf(unsigned int); */ -ENTRY(__floatunsisf) - movl 4(%sp),%d0 - jpl 1f - fmovel %d0,%fp0 -#ifndef __SVR4_ABI__ - fmoves %fp0,%d0 -#endif - rts -1: - bclr #31,%d0 - fmovel %d0,%fp0 -#ifdef __mcoldfire__ - LEA_LCL(L2G,%a0) - faddd (%a0),%fp0 -#else - faddd #0r2147483648.0,%fp0 -#endif -#ifndef __SVR4_ABI__ - fmoves %fp0,%d0 -#endif - rts -END(__floatunsisf) diff --git a/lib/libc/arch/m68k/hardfloat/flt_rounds.c b/lib/libc/arch/m68k/hardfloat/flt_rounds.c deleted file mode 100644 index 81aaef6b0..000000000 --- a/lib/libc/arch/m68k/hardfloat/flt_rounds.c +++ /dev/null @@ -1,45 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" - -#include -#include - -int __flt_rounds(void); - -int -__flt_rounds(void) -{ - int fpcr; - - __asm("fmovel %%fpcr,%0" : "=d"(fpcr)); - - return __SHIFTOUT(fpcr, FPCR_ROUND) ^ 1; -} diff --git a/lib/libc/arch/m68k/hardfloat/fpgetmask.c b/lib/libc/arch/m68k/hardfloat/fpgetmask.c deleted file mode 100644 index 48adb2ab4..000000000 --- a/lib/libc/arch/m68k/hardfloat/fpgetmask.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -fp_except -_fpgetmask(void) -{ - int fpcr; - - __asm("fmovel %%fpcr,%0" : "=d"(fpcr)); - - return __SHIFTOUT(fpcr, FPCR_EXCP2); -} diff --git a/lib/libc/arch/m68k/hardfloat/fpgetround.c b/lib/libc/arch/m68k/hardfloat/fpgetround.c deleted file mode 100644 index 9965d1102..000000000 --- a/lib/libc/arch/m68k/hardfloat/fpgetround.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -fp_rnd -_fpgetround(void) -{ - int fpcr; - - __asm("fmovel %%fpcr,%0" : "=d"(fpcr)); - - return __SHIFTOUT(fpcr, FPCR_ROUND); -} diff --git a/lib/libc/arch/m68k/hardfloat/fpgetsticky.c b/lib/libc/arch/m68k/hardfloat/fpgetsticky.c deleted file mode 100644 index 69973abe2..000000000 --- a/lib/libc/arch/m68k/hardfloat/fpgetsticky.c +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -fp_except -_fpgetsticky(void) -{ - int fpsr; - - __asm("fmovel %%fpsr,%0" : "=d"(fpsr)); - - return __SHIFTOUT(fpsr, FPSR_AEX); -} diff --git a/lib/libc/arch/m68k/hardfloat/fpsetmask.c b/lib/libc/arch/m68k/hardfloat/fpsetmask.c deleted file mode 100644 index b619224de..000000000 --- a/lib/libc/arch/m68k/hardfloat/fpsetmask.c +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -fp_except -_fpsetmask(fp_except new) -{ - int old_fpcr, new_fpcr; - - __asm("fmovel %%fpcr,%0" : "=d"(old_fpcr)); - - new_fpcr = (old_fpcr & ~FPCR_EXCP2) | __SHIFTIN(new, FPCR_EXCP2); - - __asm("fmovel %0,%%fpcr" :: "d"(new_fpcr)); - - return __SHIFTOUT(old_fpcr, FPCR_EXCP2); -} diff --git a/lib/libc/arch/m68k/hardfloat/fpsetround.c b/lib/libc/arch/m68k/hardfloat/fpsetround.c deleted file mode 100644 index 2c93f39ac..000000000 --- a/lib/libc/arch/m68k/hardfloat/fpsetround.c +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -fp_rnd -_fpsetround(fp_rnd new) -{ - int old_fpcr, new_fpcr; - - __asm("fmovel %%fpcr,%0" : "=d"(old_fpcr)); - - new_fpcr = (old_fpcr & ~FPCR_ROUND) | __SHIFTIN(new, FPCR_ROUND); - - __asm("fmovel %0,%%fpcr" :: "d"(new_fpcr)); - - return __SHIFTOUT(old_fpcr, FPCR_ROUND); -} diff --git a/lib/libc/arch/m68k/hardfloat/fpsetsticky.c b/lib/libc/arch/m68k/hardfloat/fpsetsticky.c deleted file mode 100644 index f202ef926..000000000 --- a/lib/libc/arch/m68k/hardfloat/fpsetsticky.c +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -_fpsetsticky(fp_except new) -{ - int old_fpsr, new_fpsr; - - __asm("fmovel %%fpsr,%0" : "=d"(old_fpsr)); - - new_fpsr = (old_fpsr & ~FPSR_AEX) | __SHIFTIN(new, FPSR_AEX); - - __asm("fmovel %0,%%fpsr" :: "d"(new_fpsr)); - - return __SHIFTOUT(old_fpsr, FPSR_AEX); -} diff --git a/lib/libc/arch/m68k/hardfloat/ldexp_881.c b/lib/libc/arch/m68k/hardfloat/ldexp_881.c deleted file mode 100644 index 319271a5c..000000000 --- a/lib/libc/arch/m68k/hardfloat/ldexp_881.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: ldexp_881.c,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ldexp_881.c,v 1.1 2013/07/17 06:39:06 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * ldexp(value, exp): return value * (2 ** exp). - */ -double -ldexp(value, exp2) - double value; - int exp2; -{ - double temp; - - __asm ("fscalel %2,%1" - : "=f" (temp) - : "0" (value), "g" (exp2)); - return (temp); -} diff --git a/lib/libc/arch/m68k/hardfloat/ledf2.S b/lib/libc/arch/m68k/hardfloat/ledf2.S deleted file mode 100644 index 434a23485..000000000 --- a/lib/libc/arch/m68k/hardfloat/ledf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: ledf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: ledf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -STRONG_ALIAS(__gtdf2,__ledf2) - -/* libgcc1.c says a > b */ -/* libgcc1.c says 1 - (a <= b) */ -ENTRY(__ledf2) - fmoved 4(%sp),%fp0 - fcmpd 12(%sp),%fp0 - fbgt Lbgt - movql #1,%d0 - rts -Lbgt: - clrl %d0 - rts -END(__ledf2) diff --git a/lib/libc/arch/m68k/hardfloat/lesf2.S b/lib/libc/arch/m68k/hardfloat/lesf2.S deleted file mode 100644 index 33b89b3fe..000000000 --- a/lib/libc/arch/m68k/hardfloat/lesf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: lesf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: lesf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -STRONG_ALIAS(__gtsf2,__lesf2) - -/* libgcc1.c says a > b */ -/* libgcc1.c says 1 - (a <= b) */ -ENTRY(__lesf2) - fmoves 4(%sp),%fp0 - fcmps 8(%sp),%fp0 - fbgt Lbgt - movql #1,%d0 - rts -Lbgt: - clrl %d0 - rts -END(__lesf2) diff --git a/lib/libc/arch/m68k/hardfloat/ltdf2.S b/lib/libc/arch/m68k/hardfloat/ltdf2.S deleted file mode 100644 index 5a99e3e0a..000000000 --- a/lib/libc/arch/m68k/hardfloat/ltdf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: ltdf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: ltdf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -STRONG_ALIAS(__gedf2,__ltdf2) - -/* libgcc1.c says (a >= b) - 1 */ -/* libgcc1.c says -(a < b) */ -ENTRY(__ltdf2) - fmoved 4(%sp),%fp0 - fcmpd 12(%sp),%fp0 - fbge Lbge - movql #-1,%d0 - rts -Lbge: - clrl %d0 - rts -END(__ltdf2) diff --git a/lib/libc/arch/m68k/hardfloat/ltsf2.S b/lib/libc/arch/m68k/hardfloat/ltsf2.S deleted file mode 100644 index 43a4103f3..000000000 --- a/lib/libc/arch/m68k/hardfloat/ltsf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: ltsf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: ltsf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -STRONG_ALIAS(__gesf2,__ltsf2) - -/* libgcc1.c says (a >= b) - 1 */ -/* libgcc1.c says -(a < b) */ -ENTRY(__ltsf2) - fmoves 4(%sp),%fp0 - fcmps 8(%sp),%fp0 - fbge Lbge - movql #-1,%d0 - rts -Lbge: - clrl %d0 - rts -END(__ltsf2) diff --git a/lib/libc/arch/m68k/hardfloat/modf.S b/lib/libc/arch/m68k/hardfloat/modf.S deleted file mode 100644 index 6ef2d89ad..000000000 --- a/lib/libc/arch/m68k/hardfloat/modf.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: modf.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)modf.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: modf.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * double modf(val, iptr) - * returns: xxx and n (in *iptr) where val == n.xxx - */ -ENTRY(modf) - fmoved 4(%sp),%fp0 - movel 12(%sp),%a0 -#ifdef __mcoldfire__ - fintrzd %fp0,%fp1 -#else - fintrzx %fp0,%fp1 -#endif - fmoved %fp1,(%a0) -#ifdef __mcoldfire__ - fsubd %fp1,%fp0 -#else - fsubx %fp1,%fp0 -#endif -#ifndef __SVR4_ABI__ - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(modf) diff --git a/lib/libc/arch/m68k/hardfloat/muldf3.S b/lib/libc/arch/m68k/hardfloat/muldf3.S deleted file mode 100644 index 13c5f9492..000000000 --- a/lib/libc/arch/m68k/hardfloat/muldf3.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: muldf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)muldf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: muldf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* double * double */ -ENTRY(__muldf3) - fmoved 4(%sp),%fp0 - fmuld 12(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(__muldf3) diff --git a/lib/libc/arch/m68k/hardfloat/mulsf3.S b/lib/libc/arch/m68k/hardfloat/mulsf3.S deleted file mode 100644 index 896c370a0..000000000 --- a/lib/libc/arch/m68k/hardfloat/mulsf3.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: mulsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)mulsf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: mulsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* single * single */ -ENTRY(__mulsf3) - fmoves 4(%sp),%fp0 - fmuls 8(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoves %fp0,%d0 -#endif - rts -END(__mulsf3) diff --git a/lib/libc/arch/m68k/hardfloat/nedf2.S b/lib/libc/arch/m68k/hardfloat/nedf2.S deleted file mode 100644 index 9ed331b43..000000000 --- a/lib/libc/arch/m68k/hardfloat/nedf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: nedf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: nedf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -STRONG_ALIAS(__eqdf2,__nedf2) - -/* single != single: 1 */ -/* single == single: 0 */ -ENTRY(__nedf2) - fmoved 4(%sp),%fp0 - fcmpd 12(%sp),%fp0 - fbeq Lbeq - movql #1,%d0 - rts -Lbeq: - clrl %d0 - rts -END(__nedf2) diff --git a/lib/libc/arch/m68k/hardfloat/nesf2.S b/lib/libc/arch/m68k/hardfloat/nesf2.S deleted file mode 100644 index 311062a88..000000000 --- a/lib/libc/arch/m68k/hardfloat/nesf2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: nesf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: nesf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -STRONG_ALIAS(__eqsf2,__nesf2) - -/* single != single: 1 */ -/* single == single: 0 */ -ENTRY(__nesf2) - fmoves 4(%sp),%fp0 - fcmps 8(%sp),%fp0 - fbeq Lbeq - movql #1,%d0 - rts -Lbeq: - clrl %d0 - rts -END(__nesf2) diff --git a/lib/libc/arch/m68k/hardfloat/subdf3.S b/lib/libc/arch/m68k/hardfloat/subdf3.S deleted file mode 100644 index 7f2b988e7..000000000 --- a/lib/libc/arch/m68k/hardfloat/subdf3.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: subdf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)subdf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: subdf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* double - double */ -ENTRY(__subdf3) - fmoved 4(%sp),%fp0 - fsubd 12(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoved %fp0,-(%sp) - movel (%sp)+,%d0 - movel (%sp)+,%d1 -#endif - rts -END(__subdf3) diff --git a/lib/libc/arch/m68k/hardfloat/subsf3.S b/lib/libc/arch/m68k/hardfloat/subsf3.S deleted file mode 100644 index 10e7af8b5..000000000 --- a/lib/libc/arch/m68k/hardfloat/subsf3.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: subsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)subsf3.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: subsf3.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* single - single */ -ENTRY(__subsf3) - fmoves 4(%sp),%fp0 - fsubs 8(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoves %fp0,%d0 -#endif - rts -END(__subsf3) diff --git a/lib/libc/arch/m68k/hardfloat/truncdfsf2.S b/lib/libc/arch/m68k/hardfloat/truncdfsf2.S deleted file mode 100644 index 234d617e4..000000000 --- a/lib/libc/arch/m68k/hardfloat/truncdfsf2.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: truncdfsf2.S,v 1.1 2013/07/17 06:39:06 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)truncdfsf2.s 5.1 (Berkeley) 6/7/90") -#else - RCSID("$NetBSD: truncdfsf2.S,v 1.1 2013/07/17 06:39:06 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* (float) double */ -ENTRY(__truncdfsf2) - fmoved 4(%sp),%fp0 -#ifndef __SVR4_ABI__ - fmoves %fp0,%d0 -#endif - rts -END(__truncdfsf2) diff --git a/lib/libc/arch/m68k/hardfloat/unorddf2.S b/lib/libc/arch/m68k/hardfloat/unorddf2.S deleted file mode 100644 index d407a267f..000000000 --- a/lib/libc/arch/m68k/hardfloat/unorddf2.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: unorddf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: unorddf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* libgcc1.c says 0 if both are ordered */ -ENTRY(__unordsf2) - fmoves 4(%sp),%fp0 - fcmps 8(%sp),%fp0 - fbor Lbor - movql #1,%d0 - rts -Lbor: - clrl %d0 - rts -END(__unordsf2) diff --git a/lib/libc/arch/m68k/hardfloat/unordsf2.S b/lib/libc/arch/m68k/hardfloat/unordsf2.S deleted file mode 100644 index 38756b00b..000000000 --- a/lib/libc/arch/m68k/hardfloat/unordsf2.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: unordsf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: unordsf2.S,v 1.2 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* libgcc1.c says (a >= b) - 1 */ -/* libgcc1.c says -(a < b) */ -ENTRY(__unorddf2) - fmoved 4(%sp),%fp0 - fcmpd 12(%sp),%fp0 - fbor Lbor - movql #1,%d0 - rts -Lbor: - clrl %d0 - rts -END(__unorddf2) diff --git a/lib/libc/arch/m68k/net/Makefile.inc b/lib/libc/arch/m68k/net/Makefile.inc deleted file mode 100644 index dc2ddf344..000000000 --- a/lib/libc/arch/m68k/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 1995/02/25 14:58:55 cgd Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/m68k/quad/ashldi3.S b/lib/libc/arch/m68k/quad/ashldi3.S deleted file mode 100644 index f3b654822..000000000 --- a/lib/libc/arch/m68k/quad/ashldi3.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: ashldi3.S,v 1.8 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -| d0 msw -| d1 lsw -| d2 shift -| d3 offset (32 - shift) - -ENTRY(__ashldi3) - link %fp,#-12 - moveml %d2-%d4,(%sp) - movel 8(%fp),%d0 - movel 12(%fp),%d1 - movel 16(%fp),%d2 - moveq #32,%d3 - subl %d2,%d3 - jgt L2 - negl %d3 - movel %d1,%d0 - asll %d3,%d0 - clrl %d1 - jra L3 -L2: asll %d2,%d0 - movel %d1,%d4 - lsrl %d3,%d4 - orl %d4,%d0 - asll %d2,%d1 -L3: moveml -12(%fp),%d2-%d4 - unlk %fp - rts -END(__ashldi3) diff --git a/lib/libc/arch/m68k/quad/ashrdi3.S b/lib/libc/arch/m68k/quad/ashrdi3.S deleted file mode 100644 index 354488af4..000000000 --- a/lib/libc/arch/m68k/quad/ashrdi3.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: ashrdi3.S,v 1.8 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -| d0 msw -| d1 lsw -| d2 shift -| d3 offset (32 - shift) - -ENTRY(__ashrdi3) - link %fp,#-12 - moveml %d2-%d4,(%sp) - movel 8(%fp),%d0 - movel 12(%fp),%d1 - movel 16(%fp),%d2 - moveq #32,%d3 - subl %d2,%d3 - jgt L2 - negl %d3 - movel %d0,%d1 - asrl %d3,%d1 - smi %d0 - extbl %d0 - jra L3 -L2: lsrl %d2,%d1 - movel %d0,%d4 - asll %d3,%d4 - orl %d4,%d1 - asrl %d2,%d0 -L3: moveml -12(%fp),%d2-%d4 - unlk %fp - rts -END(__ashrdi3) diff --git a/lib/libc/arch/m68k/quad/lshrdi3.S b/lib/libc/arch/m68k/quad/lshrdi3.S deleted file mode 100644 index 1ff0aa7c3..000000000 --- a/lib/libc/arch/m68k/quad/lshrdi3.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: lshrdi3.S,v 1.9 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -| d0 msw -| d1 lsw -| d2 shift -| d3 offset (32 - shift) - -ENTRY(__lshrdi3) - link %fp,#-12 - moveml %d2-%d4,(%sp) - movel 8(%fp),%d0 - movel 12(%fp),%d1 - movel 16(%fp),%d2 - moveq #32,%d3 - subl %d2,%d3 - jgt L2 - negl %d3 - movel %d0,%d1 - lsrl %d3,%d1 - clrl %d0 - jra L3 -L2: lsrl %d2,%d1 - movel %d0,%d4 - asll %d3,%d4 - orl %d4,%d1 - lsrl %d2,%d0 -L3: moveml -12(%fp),%d2-%d4 - unlk %fp - rts -END(__lshrdi3) diff --git a/lib/libc/arch/m68k/softfloat/m68k-gcc.h b/lib/libc/arch/m68k/softfloat/m68k-gcc.h deleted file mode 100644 index 07bd45b37..000000000 --- a/lib/libc/arch/m68k/softfloat/m68k-gcc.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: m68k-gcc.h,v 1.2 2005/12/24 21:11:16 perry Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#include -#if _BYTE_ORDER == _BIG_ENDIAN -#define BIGENDIAN -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef int uint8; -typedef int int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) diff --git a/lib/libc/arch/m68k/softfloat/milieu.h b/lib/libc/arch/m68k/softfloat/milieu.h deleted file mode 100644 index 462472b23..000000000 --- a/lib/libc/arch/m68k/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.1 2004/09/26 21:13:27 jmmv Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "m68k-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/m68k/softfloat/softfloat.h b/lib/libc/arch/m68k/softfloat/softfloat.h deleted file mode 100644 index 054a236e5..000000000 --- a/lib/libc/arch/m68k/softfloat/softfloat.h +++ /dev/null @@ -1,306 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.7 2014/09/01 07:33:31 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -#ifndef __mcoldfire__ -#define FLOATX80 -#endif -/* #define FLOAT128 */ - -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int8 float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -unsigned int float32_to_uint32_round_to_zero( float32 ); -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -flag float32_eq( float32, float32 ); -flag float32_le( float32, float32 ); -flag float32_lt( float32, float32 ); -flag float32_eq_signaling( float32, float32 ); -flag float32_le_quiet( float32, float32 ); -flag float32_lt_quiet( float32, float32 ); -#if !defined(SOFTFLOAT_FOR_GCC) || defined(SOFTFLOATM68K_FOR_GCC) -flag float32_is_signaling_nan( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -unsigned int float64_to_uint32_round_to_zero( float64 ); -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -flag float64_eq( float64, float64 ); -flag float64_le( float64, float64 ); -flag float64_lt( float64, float64 ); -flag float64_eq_signaling( float64, float64 ); -flag float64_le_quiet( float64, float64 ); -flag float64_lt_quiet( float64, float64 ); -flag float64_is_signaling_nan( float64 ); - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -flag floatx80_eq( floatx80, floatx80 ); -flag floatx80_le( floatx80, floatx80 ); -flag floatx80_lt( floatx80, floatx80 ); -flag floatx80_eq_signaling( floatx80, floatx80 ); -flag floatx80_le_quiet( floatx80, floatx80 ); -flag floatx80_lt_quiet( floatx80, floatx80 ); -flag floatx80_is_signaling_nan( floatx80 ); -flag floatx80_is_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -flag float128_eq( float128, float128 ); -flag float128_le( float128, float128 ); -flag float128_lt( float128, float128 ); -flag float128_eq_signaling( float128, float128 ); -flag float128_le_quiet( float128, float128 ); -flag float128_lt_quiet( float128, float128 ); -flag float128_is_signaling_nan( float128 ); - -#endif diff --git a/lib/libc/arch/m68k/stdlib/Makefile.inc b/lib/libc/arch/m68k/stdlib/Makefile.inc deleted file mode 100644 index 4945ed9a0..000000000 --- a/lib/libc/arch/m68k/stdlib/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.7 2009/08/11 17:30:43 dsl Exp $ - -SRCS+= abs.S llabs.S -NO_SRCS+= labs.S imaxabs.S diff --git a/lib/libc/arch/m68k/stdlib/abs.S b/lib/libc/arch/m68k/stdlib/abs.S deleted file mode 100644 index 835b406e1..000000000 --- a/lib/libc/arch/m68k/stdlib/abs.S +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: abs.S,v 1.8 2013/07/16 21:48:32 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)abs.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: abs.S,v 1.8 2013/07/16 21:48:32 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* labs - long int absolute value */ - -ENTRY_NOPROFILE(labs) -/* fall through to: */ - -/* abs - int absolute value */ - -ENTRY(abs) - movl 4(%sp),%d0 - jge L1 - negl %d0 -L1: - rts -END(abs) diff --git a/lib/libc/arch/m68k/stdlib/llabs.S b/lib/libc/arch/m68k/stdlib/llabs.S deleted file mode 100644 index 5b456cae1..000000000 --- a/lib/libc/arch/m68k/stdlib/llabs.S +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: llabs.S,v 1.6 2013/07/16 21:48:32 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)abs.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: llabs.S,v 1.6 2013/07/16 21:48:32 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WEAK_ALIAS(llabs, _llabs) -WEAK_ALIAS(imaxabs, _llabs) - -/* llabs - long long int absolute value */ - -ENTRY(_llabs) - movl 8(%sp),%d1 - movl 4(%sp),%d0 - jge L1 - negl %d1 - negxl %d0 -L1: - rts -END(_llabs) diff --git a/lib/libc/arch/m68k/string/Makefile.inc b/lib/libc/arch/m68k/string/Makefile.inc deleted file mode 100644 index 239dce29d..000000000 --- a/lib/libc/arch/m68k/string/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/30 20:57:16 dsl Exp $ - -SRCS+= bcmp.S bcopy.S bzero.S ffs.S memcmp.S memset.S \ - strcat.S strcmp.S strcpy.S strlen.S \ - strncmp.S strncpy.S \ - swab.S -SRCS+= memcpy.S memccpy.S memmove.S strchr.S strrchr.S diff --git a/lib/libc/arch/m68k/string/memccpy.S b/lib/libc/arch/m68k/string/memccpy.S deleted file mode 100644 index c453f3a78..000000000 --- a/lib/libc/arch/m68k/string/memccpy.S +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: memccpy.S,v 1.5 2014/03/18 18:20:37 riastradh Exp $ */ - -/* - * Copyright (C) 1999 Scott Reynolds. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: memccpy.S,v 1.5 2014/03/18 18:20:37 riastradh Exp $") -#endif /* LIBC_SCCS and not lint */ - -ENTRY(memccpy) - movl 16(%sp),%d0 | count - jeq Lmcbail | nothing to do - - movl 4(%sp),%a0 | a0 = toaddr -#ifndef __mcoldfire__ - subql #1,%d0 | prepare count for DBcc loop -#endif - movl 8(%sp),%a1 | a1 = fromaddr - movl 12(%sp),%d1 | d1 = terminator - jeq Lmcloop | handle ASCII NUL specially - - movl %d2,-(%sp) | save scratch register -Lmcnzloop: - movb (%a1)+,%d2 | move a byte - movb %d2,(%a0)+ - cmpb %d2,%d1 | found the terminator? -#ifndef __mcoldfire__ - dbeq %d0,Lmcnzloop | if not, keep transferring, -#endif - jeq Lmcnzdone | otherwise done -#ifdef __mcoldfire__ - subql #1,%d0 - jne Lmcnzloop -#else - clrw %d0 | check to see if more to do - subql #1,%d0 - jcc Lmcnzloop | yes, keep going... -#endif - - movl (%sp)+,%d2 | restore scratch register - movql #0,%d0 | no terminator found, return NULL -#ifdef __SVR4_ABI__ - movl %d0,%a0 | XXX maybe use lea to avoid stall? -#endif - rts - -Lmcloop: - movb (%a1)+,(%a0)+ | move a byte; was it NUL? -#ifndef __mcoldfire__ - dbeq %d0,Lmcloop | if not, keep transferring, -#endif - jeq Lmcdone | otherwise done -#ifdef __mcoldfire__ - subql #1,%d0 - jne Lmcloop -#else - clrw %d0 | check to see if more to do - subql #1,%d0 - jcc Lmcloop | yes, keep going... -#endif - | Note: %d0 is now -1! - movql #0,%d0 | no terminator found, return NULL -Lmcbail: -#ifdef __SVR4_ABI__ - movl %d0,%a0 | XXX maybe use lea to avoid stall? -#endif - rts - -Lmcnzdone: - movl (%sp)+,%d2 | restore scratch register -Lmcdone: - movl %a0,%d0 - rts -END(memccpy) diff --git a/lib/libc/arch/m68k/string/swab.S b/lib/libc/arch/m68k/string/swab.S deleted file mode 100644 index abb33a69f..000000000 --- a/lib/libc/arch/m68k/string/swab.S +++ /dev/null @@ -1,27 +0,0 @@ -/* $NetBSD: swab.S,v 1.11 2014/03/18 18:20:37 riastradh Exp $ */ - -#include - -ENTRY(swab) - movl 4(%sp),%a0 | source - movl 8(%sp),%a1 | destination - movl 12(%sp),%d0 | count - lsrl #1,%d0 | count is in bytes; we need words - jeq swdone - -swloop: -#ifdef __mcoldfire__ - movb (%a0)+,1(%a1) - movb (%a0)+,(%a1) - addql #2,%a1 -#else - movw (%a0)+,%d1 - rorw #8,%d1 - movw %d1,(%a1)+ -#endif - subql #1,%d0 - jne swloop - -swdone: - rts -END(swab) diff --git a/lib/libc/arch/m68k/sys/__clone.S b/lib/libc/arch/m68k/sys/__clone.S deleted file mode 100644 index 9eaa6c78d..000000000 --- a/lib/libc/arch/m68k/sys/__clone.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: __clone.S,v 1.5 2013/07/16 23:00:15 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Steve C. Woodford. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - movl 4(%sp),%d0 /* NULL function pointer? */ - jeq 2f /* Yup, bomb out */ - movl %d0,%a1 - movl 8(%sp),%d0 /* NULL stack? */ - jeq 2f /* Yup, bomb out */ - movl %d0,%a0 - movl 16(%sp),-(%a0) /* Push clone's `arg' on its new stack */ - lea -12(%a0),%a0 /* Fake syscall args for the clone */ - movl %a0,-(%sp) /* Syscall arg: stack */ - movl 16(%sp),-(%sp) /* Syscall arg: flags */ - clrl -(%sp) /* Fake return address */ - SYSTRAP(__clone) /* Note: `fn' in (a1) is preserved */ - lea 12(%sp),%sp /* Zap syscall args */ - jcs 3f /* Punt if syscall failed */ - tstl %d0 - jne 1f /* We're the parent, just return. */ - jsr (%a1) /* We're the clone, call the function */ - movl %d0,-(%sp) /* If clone returns, invoke _exit(3) */ - jbsr PIC_PLT(_C_LABEL(_exit)) - /* NOTREACHED */ -1: rts -2: movl #EINVAL,%d0 -3: jbra CERROR -END(__clone) diff --git a/lib/libc/arch/m68k/sys/__m68k_read_tp.S b/lib/libc/arch/m68k/sys/__m68k_read_tp.S deleted file mode 100644 index 5eebab60b..000000000 --- a/lib/libc/arch/m68k/sys/__m68k_read_tp.S +++ /dev/null @@ -1,7 +0,0 @@ -#include "SYS.h" - -ENTRY(__m68k_read_tp) - SYSTRAP(_lwp_getprivate) - movl %d0,%a0 - rts -END(__m68k_read_tp) diff --git a/lib/libc/arch/m68k/sys/__mmap.S b/lib/libc/arch/m68k/sys/__mmap.S deleted file mode 100644 index bba2da734..000000000 --- a/lib/libc/arch/m68k/sys/__mmap.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: __mmap.S,v 1.3 2013/07/16 22:19:37 matt Exp $ */ - -/*- - * Copyright (c) 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -_SYSCALL(__mmap,mmap) -#ifdef __SVR4_ABI__ - movl %d0,%a0 -#endif - rts -END(__mmap) diff --git a/lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c b/lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 256a99084..000000000 --- a/lib/libc/arch/m68k/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.9 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.9 2008/04/28 20:22:56 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) -#ifdef __LIBC12_SOURCE__ -extern const int __sigtramp_sigcontext_1[] - __weak_reference(__sigtramp_sigcontext_1); -#endif - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specified or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/m68k/sys/__sigtramp2.S b/lib/libc/arch/m68k/sys/__sigtramp2.S deleted file mode 100755 index e1c78c5a1..000000000 --- a/lib/libc/arch/m68k/sys/__sigtramp2.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.4 2013/07/16 22:19:16 matt Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The m68k signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * ucontext structure [12+sizeof(siginfo_t)] - * siginfo structure [12] - * pointer to ucontext structure [8] - * pointer to siginfo structure [4] - * sp-> signal number [0] - */ -ENTRY_NOPROFILE(__sigtramp_siginfo_2) - movl 8(%sp),%a0 /* get pointer to ucontext */ - movl %a0,4(%sp) /* put it in the argument slot */ - /* fake return address already there */ - SYSTRAP(setcontext) - movl %d0,4(%sp) /* error code */ - SYSTRAP(exit) /* exit */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/m68k/sys/__syscall.S b/lib/libc/arch/m68k/sys/__syscall.S deleted file mode 100644 index 8c4174e3e..000000000 --- a/lib/libc/arch/m68k/sys/__syscall.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.1 2000/12/13 21:46:23 scw Exp $ */ - -#include "SYS.h" -RSYSCALL(__syscall) diff --git a/lib/libc/arch/m68k/sys/__vfork14.S b/lib/libc/arch/m68k/sys/__vfork14.S deleted file mode 100644 index 57f60f579..000000000 --- a/lib/libc/arch/m68k/sys/__vfork14.S +++ /dev/null @@ -1,94 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.12 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)Ovfork.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: __vfork14.S,v 1.12 2013/09/12 15:36:15 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * @(#)vfork.s 4.1 (Berkeley) 12/21/80 - * C library -- vfork - */ - -/* - * pid = vfork(); - * - * d1 == 0 in parent process, d1 == 1 in child process. - * d0 == pid of child in parent, d0 == pid of parent in child. - * - * trickery here, due to keith sklower, uses ret to clear the stack, - * and then returns with a jump indirect, since only one person can return - * with a ret off this stack... we do the ret before we vfork! - */ - -ENTRY(__vfork14) - movl (%sp)+,%a1 - SYSTRAP(__vfork14) - jcs err - subql #1,%d1 /* from 1 to 0 in child, 0 to -1 in parent */ - andl %d1,%d0 - jmp (%a1) -err: -#ifdef _REENTRANT - .globl _C_LABEL(__errno) - movl %a1,-(%sp) - movl %d0,-(%sp) - jbsr PIC_PLT(_C_LABEL(__errno)) -#ifdef __SVR4_ABI__ - movl (%sp)+,(%a0) -#else - movl %d0,%a1 - movl (%sp)+,(%a1) -#endif - movl (%sp)+,%a1 -#else -#ifdef __PIC__ - GOT_SETUP(%a0) - movl _C_LABEL(errno)@GOT:w(%a0),%a0 - movl %d0,(%a0) -#else - .globl _C_LABEL(errno) - movl %d0,_C_LABEL(errno) -#endif /* __PIC__ */ -#endif /* _REENTRANT */ - moveq #-1,%d0 - jmp (%a1) -END(__vfork14) diff --git a/lib/libc/arch/m68k/sys/_lwp_getprivate.S b/lib/libc/arch/m68k/sys/_lwp_getprivate.S deleted file mode 100644 index 45b0a1319..000000000 --- a/lib/libc/arch/m68k/sys/_lwp_getprivate.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: _lwp_getprivate.S,v 1.3 2013/07/16 22:19:16 matt Exp $ */ - -/*- - * Copyright (c) 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -SYSCALL(_lwp_getprivate) -#ifdef __SVR4_ABI__ - movl %d0,%a0 -#endif - rts -END(_lwp_getprivate) diff --git a/lib/libc/arch/m68k/sys/brk.S b/lib/libc/arch/m68k/sys/brk.S deleted file mode 100644 index a46445295..000000000 --- a/lib/libc/arch/m68k/sys/brk.S +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: brk.S,v 1.19 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)brk.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: brk.S,v 1.19 2013/09/12 15:36:15 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - - .globl _end - .globl _C_LABEL(__minbrk) - .hidden _C_LABEL(__minbrk) - .globl _C_LABEL(__curbrk) - .hidden _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data -_C_LABEL(__minbrk): - .long _end - - .text - -ENTRY(_brk) -#ifdef __PIC__ - LEA_LCL(_C_LABEL(__minbrk),%a1) - movl (%a1),%a1 -#else - movl _C_LABEL(__minbrk),%a1 -#endif - cmpl 4(%sp),%a1 - jls ok - movl %a1,4(%sp) -ok: - SYSTRAP(break) - jcs CERROR -#ifdef __PIC__ - LEA_LCL(_C_LABEL(__curbrk),%a0) - movl %a1,(%a0) -#else - movl %a1,_C_LABEL(__curbrk) -#endif - clrl %d0 - rts -END(_brk) diff --git a/lib/libc/arch/m68k/sys/cerror.S b/lib/libc/arch/m68k/sys/cerror.S deleted file mode 100644 index 507a23402..000000000 --- a/lib/libc/arch/m68k/sys/cerror.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: cerror.S,v 1.18 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)cerror.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: cerror.S,v 1.18 2013/09/12 15:36:15 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef _REENTRANT - .globl _C_LABEL(__errno) -#else - .globl _C_LABEL(errno) -#endif -_ENTRY(CERROR) -#ifdef _REENTRANT - movl %d0,-(%sp) - jbsr PIC_PLT(_C_LABEL(__errno)) -#ifndef __SVR4_ABI__ - movl %d0,%a0 -#endif - movl (%sp)+,(%a0) -#else -#ifdef __PIC__ - GOT_SETUP(%a0) - movl _C_LABEL(errno)@GOT:w(%a0),%a0 - movl %d0,(%a0) -#else - movl %d0,_C_LABEL(errno) -#endif -#endif /* _REENTRANT */ - movl #-1,%d0 - movl #-1,%d1 -#ifdef __SVR4_ABI__ - movl %d0,%a0 -#endif - rts -END(CERROR) diff --git a/lib/libc/arch/m68k/sys/exect.S b/lib/libc/arch/m68k/sys/exect.S deleted file mode 100644 index 98471ceca..000000000 --- a/lib/libc/arch/m68k/sys/exect.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: exect.S,v 1.8 2013/07/16 22:20:35 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" -#include - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)exect.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: exect.S,v 1.8 2013/07/16 22:20:35 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -ENTRY(exect) - SYSTRAP(execve) - jbra CERROR /* exect(file, argv, env) */ -END(exect) diff --git a/lib/libc/arch/m68k/sys/fork.S b/lib/libc/arch/m68k/sys/fork.S deleted file mode 100644 index 14af51564..000000000 --- a/lib/libc/arch/m68k/sys/fork.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: fork.S,v 1.8 2013/07/16 22:15:55 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)fork.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: fork.S,v 1.8 2013/07/16 22:15:55 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -_SYSCALL(__fork,fork) - subql #1,%d1 /* from 1 to 0 in child, 0 to -1 in parent */ - andl %d1,%d0 - rts /* pid = fork() */ -END(__fork) diff --git a/lib/libc/arch/m68k/sys/getcontext.S b/lib/libc/arch/m68k/sys/getcontext.S deleted file mode 100644 index 415934b91..000000000 --- a/lib/libc/arch/m68k/sys/getcontext.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.6 2013/07/17 03:01:27 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.6 2013/07/17 03:01:27 matt Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -_SYSCALL(_getcontext,getcontext) - movl 4(%sp),%a0 - addql #4,UC_MCONTEXT_SP(%a0) | adjust saved stack pointer - movl %sp@,UC_MCONTEXT_PC(%a0)| adjust saved program counter - clrl UC_MCONTEXT_D0(%a0) | arrange for return value of 0 - rts -END(_getcontext) diff --git a/lib/libc/arch/m68k/sys/mremap.S b/lib/libc/arch/m68k/sys/mremap.S deleted file mode 100644 index c2ec75df0..000000000 --- a/lib/libc/arch/m68k/sys/mremap.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: mremap.S,v 1.3 2013/07/16 22:15:55 matt Exp $ */ - -/*- - * Copyright (c) 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -SYSCALL(mremap) -#ifdef __SVR4_ABI__ - movl %d0,%a0 -#endif - rts -END(mremap) diff --git a/lib/libc/arch/m68k/sys/pipe.S b/lib/libc/arch/m68k/sys/pipe.S deleted file mode 100644 index 37960a3c1..000000000 --- a/lib/libc/arch/m68k/sys/pipe.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: pipe.S,v 1.8 2013/07/16 22:16:53 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)pipe.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: pipe.S,v 1.8 2013/07/16 22:16:53 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -_SYSCALL(_pipe,pipe) - movl 4(%sp),%a0 - movl %d0,(%a0)+ - movl %d1,(%a0) - clrl %d0 - rts -END(_pipe) diff --git a/lib/libc/arch/m68k/sys/ptrace.S b/lib/libc/arch/m68k/sys/ptrace.S deleted file mode 100644 index 82038b2bd..000000000 --- a/lib/libc/arch/m68k/sys/ptrace.S +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.15 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)ptrace.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: ptrace.S,v 1.15 2013/09/12 15:36:15 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef _REENTRANT - .globl _C_LABEL(__errno) -#else - .globl _C_LABEL(errno) -#endif - -ENTRY(ptrace) -#ifdef _REENTRANT - jbsr PIC_PLT(_C_LABEL(__errno)) -#ifndef __SVR4_ABI__ - movl %d0,%a0 -#endif - clrl (%a0) -#else -#ifdef __PIC__ - GOT_SETUP(%a0) - movl _C_LABEL(errno)@GOT:w(%a0),%a0 - clrl (%a0) -#else - clrl _C_LABEL(errno) -#endif /* __PIC__ */ -#endif /* _REENTRANT */ - SYSTRAP(ptrace) - jcs CERROR - rts -END(ptrace) diff --git a/lib/libc/arch/m68k/sys/sbrk.S b/lib/libc/arch/m68k/sys/sbrk.S deleted file mode 100644 index 9a1707a30..000000000 --- a/lib/libc/arch/m68k/sys/sbrk.S +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.17 2013/07/24 15:38:07 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sbrk.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: sbrk.S,v 1.17 2013/07/24 15:38:07 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - - .globl _end - .globl _C_LABEL(__curbrk) - .hidden _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data -_C_LABEL(__curbrk): - .long _end - - .text - -ENTRY(_sbrk) - LEA_LCL(_C_LABEL(__curbrk),%a1) - movl (%a1),%d0 - addl %d0,4(%sp) - SYSTRAP(break) - jcs CERROR - movl (%a1),%d0 - movl 4(%sp),(%a1) -#ifdef __SVR4_ABI__ - movl %d0,%a0 -#endif - rts -END(_sbrk) diff --git a/lib/libc/arch/m68k/sys/shmat.S b/lib/libc/arch/m68k/sys/shmat.S deleted file mode 100644 index 10af3e777..000000000 --- a/lib/libc/arch/m68k/sys/shmat.S +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: shmat.S,v 1.3 2013/07/16 22:16:53 matt Exp $ */ - -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -SYSCALL(shmat) -#ifdef __SVR4_ABI__ - movl %d0,%a0 -#endif - rts -END(shmat) diff --git a/lib/libc/arch/m68k/sys/syscall.S b/lib/libc/arch/m68k/sys/syscall.S deleted file mode 100644 index 71bc6d67e..000000000 --- a/lib/libc/arch/m68k/sys/syscall.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: syscall.S,v 1.9 2013/07/24 15:38:07 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)syscall.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: syscall.S,v 1.9 2013/07/24 15:38:07 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -ENTRY(syscall) - clrl %d0 - trap #0 - jcs CERROR - rts -END(syscall) diff --git a/lib/libc/arch/mips/Makefile.inc b/lib/libc/arch/mips/Makefile.inc deleted file mode 100644 index 7db58be61..000000000 --- a/lib/libc/arch/mips/Makefile.inc +++ /dev/null @@ -1,25 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.13 2014/01/30 15:05:49 joerg Exp $ - -.include - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S - -CPPFLAGS+= -I. -CPPFLAGS.assym.h+=-D__LIBC12_SOURCE__ - -.if ${MKSOFTFLOAT} != "no" -.include -CPPFLAGS+= -DSOFTFLOAT - -SRCS+= fixunsgen_ieee754.c -SRCS+= fixunsgen64_ieee754.c #fixunssfdi.c fixunsdfdi.c -.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") \ - && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32)) -SRCS+= fixunstfsi_ieee754.c fixunstfdi_ieee754.c -.endif -.endif - -.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") \ - && (!defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32)) -SRCS+= floatunditf_ieee754.c -.endif diff --git a/lib/libc/arch/mips/SYS.h b/lib/libc/arch/mips/SYS.h deleted file mode 100644 index 2bafcc08b..000000000 --- a/lib/libc/arch/mips/SYS.h +++ /dev/null @@ -1,141 +0,0 @@ -/* $NetBSD: SYS.h,v 1.19 2009/12/14 01:07:41 matt Exp $ */ - -/*- - * Copyright (c) 1996 Jonathan Stone - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Jonathan Stone for - * the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - */ - -/*- - * Copyright (c) 1991, 1993 - * 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. - * - * from: @(#)SYS.h 8.1 (Berkeley) 6/4/93 - */ - -#include -#include - - -/* - * If compiling for shared libs, Emit sysV ABI PIC segment pseudo-ops. - * - * i) Emit .abicalls before .LEAF entrypoint, and .cpload/.cprestore after. - * ii) Do interprocedure jumps indirectly via t9, with the side-effect of - * preserving the callee's entry address in t9. - */ -#ifdef __ABICALLS__ - .abicalls -# if defined(__mips_o32) || defined(__mips_o64) -# define PIC_PROLOGUE(x) SETUP_GP -# define PIC_TAILCALL(l) PTR_LA t9, _C_LABEL(l); jr t9 -# define PIC_RETURN() j ra -# else -# define PIC_PROLOGUE(x) SETUP_GP64(t3, x) -# define PIC_TAILCALL(l) PTR_LA t9, _C_LABEL(l); RESTORE_GP64; jr t9 -# define PIC_RETURN() RESTORE_GP64; j ra -# endif -#else -# define PIC_PROLOGUE(x) -# define PIC_TAILCALL(l) j _C_LABEL(l) -# define PIC_RETURN() -#endif /* __ABICALLS__ */ - - -#ifdef __STDC__ -# define SYSTRAP(x) li v0,SYS_ ## x; syscall; -#else -# define SYSTRAP(x) li v0,SYS_/**/x; syscall; -#endif - - -/* - * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id) - */ -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -/* - * Do a normal syscall. - */ -#define RSYSCALL(x) \ - PSEUDO(x,x) - -/* - * Do a syscall that has an internal name and a weak external alias. - */ -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) - -/* - * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint - * and syscall name are not the same. - */ -#define PSEUDO_NOERROR(x,y) \ -LEAF(x); \ - SYSTRAP(y); \ - j ra; \ - END(x) - -#define PSEUDO(x,y) \ -LEAF(x); \ - PIC_PROLOGUE(x); \ - SYSTRAP(y); \ - bne a3,zero,err; \ - PIC_RETURN(); \ -err: \ - PIC_TAILCALL(__cerror); \ -END(x) diff --git a/lib/libc/arch/mips/gdtoa/Makefile.inc b/lib/libc/arch/mips/gdtoa/Makefile.inc deleted file mode 100644 index 51535fa03..000000000 --- a/lib/libc/arch/mips/gdtoa/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2011/01/20 18:41:39 matt Exp $ - -SRCS+= strtof.c -.if (${MACHINE_ARCH} == "mips64eb" || ${MACHINE_ARCH} == "mips64el") -.if !defined(CPUFLAGS) || empty(CPUFLAGS:M-mabi=32) -SRCS+= strtold_pQ.c -SRCS+= strtopQ.c -.endif -.endif diff --git a/lib/libc/arch/mips/gdtoa/arith.h b/lib/libc/arch/mips/gdtoa/arith.h deleted file mode 100644 index 40d3ed1fa..000000000 --- a/lib/libc/arch/mips/gdtoa/arith.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#include - -#if BYTE_ORDER == BIG_ENDIAN -#define IEEE_BIG_ENDIAN -#else -#define IEEE_LITTLE_ENDIAN -#endif diff --git a/lib/libc/arch/mips/gdtoa/gd_qnan.h b/lib/libc/arch/mips/gdtoa/gd_qnan.h deleted file mode 100644 index 7fcafc099..000000000 --- a/lib/libc/arch/mips/gdtoa/gd_qnan.h +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.2 2011/01/17 23:53:03 matt Exp $ */ - -#include - -#define f_QNAN 0x7fa00000 -#if BYTE_ORDER == BIG_ENDIAN -#define d_QNAN0 0x7ff40000 -#define d_QNAN1 0x0 -#define ld_QNAN0 0x7fff8000 -#define ld_QNAN1 0x0 -#define ld_QNAN2 0x0 -#define ld_QNAN3 0x0 -#else -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff40000 -#define ld_QNAN0 0x0 -#define ld_QNAN1 0x0 -#define ld_QNAN2 0x0 -#define ld_QNAN3 0x7fff8000 -#endif diff --git a/lib/libc/arch/mips/gen/Makefile.inc b/lib/libc/arch/mips/gen/Makefile.inc deleted file mode 100644 index acaccca82..000000000 --- a/lib/libc/arch/mips/gen/Makefile.inc +++ /dev/null @@ -1,40 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.33 2011/03/15 07:40:18 matt Exp $ - -.if ${MKSOFTFLOAT} == "no" -SRCS+= fabs.S ldexp.S modf.S -.else -SRCS+= fabs_ieee754.c ldexp_ieee754.c modf_ieee754.c -.endif - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c fpclassifyl_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c isinfl_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c isnanl_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c isfinitel_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c signbitl_ieee754.c - -SRCS+= nanf.c -SRCS+= flt_rounds.c - -.if ${MKSOFTFLOAT} == "no" -SRCS+= fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c -.endif - -SRCS+= setjmp.S longjmp.c -SRCS+= _setjmp.S -SRCS+= sigsetjmp.S -SRCS+= byte_swap_2.S byte_swap_4.S byte_swap_8.S - -SRCS+= makecontext.c resumecontext.c _resumecontext.S swapcontext.S _lwp.c - -# mips abi builtin extensions (used by GCC for lexical-closure trampoline) -SRCS+= cacheflush.c - -CPPFLAGS._lwp.c += -D_LIBC_SOURCE - -LSRCS.mips.gen= Lint__setjmp.c Lint_bswap16.c Lint_bswap32.c Lint_swapcontext.c -LSRCS+= ${LSRCS.mips.gen} -DPSRCS+= ${LSRCS.mips.gen} -CLEANFILES+= ${LSRCS.mips.gen} diff --git a/lib/libc/arch/mips/gen/_lwp.c b/lib/libc/arch/mips/gen/_lwp.c deleted file mode 100644 index f987f4a1a..000000000 --- a/lib/libc/arch/mips/gen/_lwp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.8 2011/04/29 08:05:22 matt Exp $ */ - -/* - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Wayne Knowles - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.8 2011/04/29 08:05:22 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#if defined(__mips_o32) || defined(__mips_o64) -#define CALLFRAME_SIZ (6 * sizeof(void *)) -#else -#define CALLFRAME_SIZ (4 * sizeof(uint64_t)) -#endif - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *tcb, caddr_t stack_base, size_t stack_size) -{ - caddr_t sp; - __greg_t *gr; - - getcontext(u); - gr = u->uc_mcontext.__gregs; - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - sp = stack_base + stack_size - CALLFRAME_SIZ; - - gr[_REG_EPC] = (uintptr_t) start; - gr[_REG_T9] = (uintptr_t) start; /* required for .abicalls */ - gr[_REG_RA] = (uintptr_t) _lwp_exit; - gr[_REG_A0] = (uintptr_t) arg; - gr[_REG_SP] = (uintptr_t) sp; - u->uc_mcontext._mc_tlsbase = - (uintptr_t)tcb + TLS_TP_OFFSET + sizeof(struct tls_tcb); - u->uc_flags |= _UC_TLSBASE; -} diff --git a/lib/libc/arch/mips/gen/_resumecontext.S b/lib/libc/arch/mips/gen/_resumecontext.S deleted file mode 100644 index a8b3e2c40..000000000 --- a/lib/libc/arch/mips/gen/_resumecontext.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: _resumecontext.S,v 1.7 2012/09/12 02:00:52 manu Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Wayne Knowles. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: _resumecontext.S,v 1.7 2012/09/12 02:00:52 manu Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - - .set reorder - .hidden _C_LABEL(__resumecontext) - -LEAF_NOPROFILE(__resumecontext) - /* - * We get here not by a call through $t9 but thru $ra after the - * function passed to makecontext returns. - */ - PTR_SUBU sp, sp, UCONTEXT_SIZE # get space for ucontext - move a0, sp # arg0 for getcontext - PTR_S zero, _OFFSETOF_UC_LINK(a0) # make sure uc_link is 0 - SYSTRAP(getcontext) # get context - PTR_L a0, _OFFSETOF_UC_LINK(a0) # linked context? - beq a0, zero, 1f # nope, exit process - nop - PIC_TAILCALL(setcontext) # yes, become it. - /* NOTREACHED (in theory) */ - li a0, -1 # failure, -1: - SYSTRAP(exit) # all hope is lost. - /* NOTREACHED */ -END(__resumecontext) diff --git a/lib/libc/arch/mips/gen/_setjmp.S b/lib/libc/arch/mips/gen/_setjmp.S deleted file mode 100644 index 9e91ce26b..000000000 --- a/lib/libc/arch/mips/gen/_setjmp.S +++ /dev/null @@ -1,191 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.24 2012/07/08 00:59:34 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 -#include -#include -#include -#include /* XXX */ - -#include "assym.h" - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)_setjmp.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: _setjmp.S,v 1.24 2012/07/08 00:59:34 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * _setjmp(a) - * by restoring registers from the stack, - * The previous signal state is NOT restored. - */ - - .set noreorder - -LEAF(_setjmp) - REG_PROLOGUE - REG_LI v0, 0xACEDBADE # sigcontext magic number - REG_S ra, _OFFSETOF_SC_PC(a0) # sc_pc = return address - REG_S v0, _OFFSETOF_SC_REGS(a0) # saved in sc_regs[0] - REG_S s0, _OFFSETOF_SC_REGS_S0(a0) - REG_S s1, _OFFSETOF_SC_REGS_S1(a0) - REG_S s2, _OFFSETOF_SC_REGS_S2(a0) - REG_S s3, _OFFSETOF_SC_REGS_S3(a0) - REG_S s4, _OFFSETOF_SC_REGS_S4(a0) - REG_S s5, _OFFSETOF_SC_REGS_S5(a0) - REG_S s6, _OFFSETOF_SC_REGS_S6(a0) - REG_S s7, _OFFSETOF_SC_REGS_S7(a0) - REG_S sp, _OFFSETOF_SC_REGS_SP(a0) - REG_S s8, _OFFSETOF_SC_REGS_S8(a0) -#if defined(__mips_n32) || defined(__mips_n64) - REG_S gp, _OFFSETOF_SC_REGS_GP(a0) # newabi gp is callee-saved -#endif - /* - * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved. - * In N64, FP registers F23 .. F31 are callee-saved. - * In O32, FP registers F20 .. F23 are callee-saved. - */ -#ifndef SOFTFLOAT_FOR_GCC - cfc1 v0, $31 # too bad cant check if FP used -#if defined(__mips_n64) || defined(__mips_n32) - FP_S $f30, _OFFSETOF_SC_FPREGS_F30(a0) - FP_S $f28, _OFFSETOF_SC_FPREGS_F28(a0) - FP_S $f26, _OFFSETOF_SC_FPREGS_F26(a0) - FP_S $f24, _OFFSETOF_SC_FPREGS_F24(a0) -#endif -#if defined(__mips_n32) || defined(__mips_o32) || defined(__mips_o64) - FP_S $f22, _OFFSETOF_SC_FPREGS_F22(a0) - FP_S $f20, _OFFSETOF_SC_FPREGS_F20(a0) -#endif -#if defined(__mips_o32) || defined(__mips_o64) - FP_S $f21, _OFFSETOF_SC_FPREGS_F21(a0) - FP_S $f23, _OFFSETOF_SC_FPREGS_F23(a0) -#endif -#if defined(__mips_n64) - FP_S $f25, _OFFSETOF_SC_FPREGS_F25(a0) - FP_S $f27, _OFFSETOF_SC_FPREGS_F27(a0) - FP_S $f29, _OFFSETOF_SC_FPREGS_F29(a0) - FP_S $f31, _OFFSETOF_SC_FPREGS_F31(a0) -#endif - INT_S v0, _OFFSETOF_SC_FPREGS_FCSR(a0) -#endif /* SOFTFLOAT_FOR_GCC */ - REG_EPILOGUE - - j ra - move v0, zero -END(_setjmp) - -LEAF(_longjmp) - PIC_PROLOGUE(_longjmp) - PTR_SUBU sp, sp, CALLFRAME_SIZ - SAVE_GP(CALLFRAME_GP) - - REG_PROLOGUE - REG_L v0, _OFFSETOF_SC_REGS(a0) # get magic number - REG_L ra, _OFFSETOF_SC_PC(a0) - REG_LI t0, 0xACEDBADE - bne v0, t0, botch # jump if error - PTR_ADDU sp, sp, CALLFRAME_SIZ # does not matter, sanity - REG_S a1, _OFFSETOF_SC_REGS_V0(a0) # save return value - REG_L s0, _OFFSETOF_SC_REGS_S0(a0) - REG_L s1, _OFFSETOF_SC_REGS_S1(a0) - REG_L s2, _OFFSETOF_SC_REGS_S2(a0) - REG_L s3, _OFFSETOF_SC_REGS_S3(a0) - REG_L s4, _OFFSETOF_SC_REGS_S4(a0) - REG_L s5, _OFFSETOF_SC_REGS_S5(a0) - REG_L s6, _OFFSETOF_SC_REGS_S6(a0) - REG_L s7, _OFFSETOF_SC_REGS_S7(a0) -#if defined(__mips_n32) || defined(__mips_n64) - REG_L gp, _OFFSETOF_SC_REGS_GP(a0) -#endif -#ifndef SOFTFLOAT_FOR_GCC - # get fpu status - INT_L v0, _OFFSETOF_SC_FPREGS_FCSR(a0) -#endif - REG_L sp, _OFFSETOF_SC_REGS_SP(a0) - REG_L s8, _OFFSETOF_SC_REGS_S8(a0) -#ifndef SOFTFLOAT_FOR_GCC - ctc1 v0, $31 - /* - * In N32, FP registers F20, F22, F24, F26, F28, F30 are callee-saved. - * In N64, FP registers F23 .. F31 are callee-saved. - * In O32, FP registers F20 .. F23 are callee-saved. - */ -#if defined(__mips_n64) || defined(__mips_n32) - FP_L $f30, _OFFSETOF_SC_FPREGS_F30(a0) - FP_L $f28, _OFFSETOF_SC_FPREGS_F28(a0) - FP_L $f26, _OFFSETOF_SC_FPREGS_F26(a0) - FP_L $f24, _OFFSETOF_SC_FPREGS_F24(a0) -#endif -#if defined(__mips_n32) || defined(__mips_o32) || defined(__mips_o64) - FP_L $f22, _OFFSETOF_SC_FPREGS_F22(a0) - FP_L $f20, _OFFSETOF_SC_FPREGS_F20(a0) -#endif -#if defined(__mips_o32) || defined(__mips_o64) - FP_L $f21, _OFFSETOF_SC_FPREGS_F21(a0) - FP_L $f23, _OFFSETOF_SC_FPREGS_F23(a0) -#endif -#if defined(__mips_n64) - FP_L $f25, _OFFSETOF_SC_FPREGS_F25(a0) - FP_L $f27, _OFFSETOF_SC_FPREGS_F27(a0) - FP_L $f29, _OFFSETOF_SC_FPREGS_F29(a0) - FP_L $f31, _OFFSETOF_SC_FPREGS_F31(a0) -#endif -#endif /* SOFTFLOAT_FOR_GCC */ - - REG_EPILOGUE - j ra - move v0, a1 # get return value in 1st arg - -botch: - /* - * We know we aren't returning so we don't care about restoring - * our caller's GP. - */ - jal _C_LABEL(longjmperror) - nop - - PIC_TAILCALL(abort) - nop -END(_longjmp) diff --git a/lib/libc/arch/mips/gen/cacheflush.c b/lib/libc/arch/mips/gen/cacheflush.c deleted file mode 100644 index b63b4b647..000000000 --- a/lib/libc/arch/mips/gen/cacheflush.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: cacheflush.c,v 1.6 2012/03/29 21:21:04 christos Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jonathan Stone. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -int -_cacheflush(void *addr, size_t nbytes, int whichcache) -{ - struct mips_cacheflush_args cfa; - - cfa.va = (vaddr_t)(intptr_t)addr; - cfa.nbytes = nbytes; - cfa.whichcache = whichcache; - return sysarch(MIPS_CACHEFLUSH, (void *)&cfa); -} diff --git a/lib/libc/arch/mips/gen/fabs.S b/lib/libc/arch/mips/gen/fabs.S deleted file mode 100644 index 812b70e54..000000000 --- a/lib/libc/arch/mips/gen/fabs.S +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: fabs.S,v 1.8 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1993 - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)fabs.s 8.1 (Berkeley) 2/16/94") -#else - RCSID("$NetBSD: fabs.S,v 1.8 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - - - .set noreorder - -/* - * fabs(x) - * double x; - * - * Return absolute value of x. - */ -LEAF(fabs) - j ra - abs.d $f0, $f12 # compute absolute value of x -END(fabs) diff --git a/lib/libc/arch/mips/gen/flt_rounds.c b/lib/libc/arch/mips/gen/flt_rounds.c deleted file mode 100644 index b37a6f99d..000000000 --- a/lib/libc/arch/mips/gen/flt_rounds.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.9 2015/03/19 21:22:59 joerg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.9 2015/03/19 21:22:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 0, /* round to zero */ - 2, /* round to positive infinity */ - 3 /* round to negative infinity */ -}; - -int -__flt_rounds(void) -{ -#ifdef SOFTFLOAT_FOR_GCC - return map[fpgetround()]; -#else - int x; - - __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (x)); - return map[x & 0x03]; -#endif -} diff --git a/lib/libc/arch/mips/gen/fpgetmask.c b/lib/libc/arch/mips/gen/fpgetmask.c deleted file mode 100644 index 9d640bfb7..000000000 --- a/lib/libc/arch/mips/gen/fpgetmask.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.9 2014/09/17 11:02:55 joerg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.9 2014/09/17 11:02:55 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -fp_except -fpgetmask(void) -{ - fp_except x; - - __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (x)); - return (x >> 7) & 0x1f; -} diff --git a/lib/libc/arch/mips/gen/fpgetround.c b/lib/libc/arch/mips/gen/fpgetround.c deleted file mode 100644 index 21775ce88..000000000 --- a/lib/libc/arch/mips/gen/fpgetround.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.7 2014/09/17 11:02:55 joerg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.7 2014/09/17 11:02:55 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -fp_rnd -fpgetround(void) -{ - fp_rnd x; - - __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (x)); - return x & 0x03; -} diff --git a/lib/libc/arch/mips/gen/fpgetsticky.c b/lib/libc/arch/mips/gen/fpgetsticky.c deleted file mode 100644 index 2c04eab25..000000000 --- a/lib/libc/arch/mips/gen/fpgetsticky.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.9 2014/09/17 11:02:55 joerg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.9 2014/09/17 11:02:55 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -fp_except -fpgetsticky(void) -{ - fp_except x; - - __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (x)); - return (x >> 2) & 0x1f; -} diff --git a/lib/libc/arch/mips/gen/fpsetmask.c b/lib/libc/arch/mips/gen/fpsetmask.c deleted file mode 100644 index 3a9f90bd9..000000000 --- a/lib/libc/arch/mips/gen/fpsetmask.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.9 2014/09/17 11:02:55 joerg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.9 2014/09/17 11:02:55 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -fp_except -fpsetmask(fp_except mask) -{ - fp_except old; - fp_except new; - - __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (old)); - - new = old & ~(0x1f << 7); - new |= ((mask & 0x1f) << 7); - - __asm(".set push; .set noat; ctc1 %0,$31; .set pop" : "=r" (new)); - - return (old >> 7) & 0x1f; -} diff --git a/lib/libc/arch/mips/gen/fpsetround.c b/lib/libc/arch/mips/gen/fpsetround.c deleted file mode 100644 index 34770c33b..000000000 --- a/lib/libc/arch/mips/gen/fpsetround.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.7 2014/09/17 11:02:55 joerg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.7 2014/09/17 11:02:55 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - fp_rnd old; - fp_rnd new; - - __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (old)); - - new = old & ~0x03; - new |= rnd_dir & 0x03; - - __asm(".set push; .set noat; ctc1 %0,$31; .set pop" : "=r" (new)); - - return old & 0x03; -} diff --git a/lib/libc/arch/mips/gen/fpsetsticky.c b/lib/libc/arch/mips/gen/fpsetsticky.c deleted file mode 100644 index ade9ed23c..000000000 --- a/lib/libc/arch/mips/gen/fpsetsticky.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.9 2014/09/17 11:02:55 joerg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 11, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.9 2014/09/17 11:02:55 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -fpsetsticky(fp_except sticky) -{ - fp_except old; - fp_except new; - - __asm(".set push; .set noat; cfc1 %0,$31; .set pop" : "=r" (old)); - - new = old & ~(0x1f << 2); - new |= (sticky & 0x1f) << 2; - - __asm(".set push; .set noat; ctc1 %0,$31; .set pop" : "=r" (new)); - - return (old >> 2) & 0x1f; -} diff --git a/lib/libc/arch/mips/gen/ldexp.S b/lib/libc/arch/mips/gen/ldexp.S deleted file mode 100644 index a80605dec..000000000 --- a/lib/libc/arch/mips/gen/ldexp.S +++ /dev/null @@ -1,217 +0,0 @@ -/* $NetBSD: ldexp.S,v 1.10 2014/09/17 11:01:05 joerg Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)ldexp.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: ldexp.S,v 1.10 2014/09/17 11:01:05 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#define DEXP_INF 0x7ff -#define DEXP_BIAS 1023 -#define DEXP_MIN -1022 -#define DEXP_MAX 1023 -#define DFRAC_BITS 52 -#define DIMPL_ONE 0x00100000 -#define DLEAD_ZEROS 31 - 20 -#define STICKYBIT 1 -#define GUARDBIT 0x80000000 -#define DSIGNAL_NAN 0x00040000 -#define DQUIET_NAN0 0x0007ffff -#define DQUIET_NAN1 0xffffffff - -/* - * double ldexp(x, N) - * double x; int N; - * - * Return x * (2**N), for integer values N. - */ -LEAF(ldexp) - mfc1 v1, $f13 # get MSW of x - mfc1 t3, $f12 # get LSW of x - sll t1, v1, 1 # get x exponent - srl t1, t1, 32 - 11 - beq t1, DEXP_INF, 9f # is it a NAN or infinity? - beq t1, zero, 1f # zero or denormalized number? - addu t1, t1, a2 # scale exponent - sll v0, a2, 20 # position N for addition - bge t1, DEXP_INF, 8f # overflow? - addu v0, v0, v1 # multiply by (2**N) - ble t1, zero, 4f # underflow? - mtc1 v0, $f1 # save MSW of result - mtc1 t3, $f0 # save LSW of result - j ra -1: - sll t2, v1, 32 - 20 # get x fraction - srl t2, t2, 32 - 20 - srl t0, v1, 31 # get x sign - bne t2, zero, 1f - beq t3, zero, 9f # result is zero -1: -/* - * Find out how many leading zero bits are in t2,t3 and put in t9. - */ - move v0, t2 - move t9, zero - bne t2, zero, 1f - move v0, t3 - addu t9, 32 -1: - srl ta0, v0, 16 - bne ta0, zero, 1f - addu t9, 16 - sll v0, 16 -1: - srl ta0, v0, 24 - bne ta0, zero, 1f - addu t9, 8 - sll v0, 8 -1: - srl ta0, v0, 28 - bne ta0, zero, 1f - addu t9, 4 - sll v0, 4 -1: - srl ta0, v0, 30 - bne ta0, zero, 1f - addu t9, 2 - sll v0, 2 -1: - srl ta0, v0, 31 - bne ta0, zero, 1f - addu t9, 1 -/* - * Now shift t2,t3 the correct number of bits. - */ -1: - subu t9, t9, DLEAD_ZEROS # dont count normal leading zeros - li t1, DEXP_MIN + DEXP_BIAS - subu t1, t1, t9 # adjust exponent - addu t1, t1, a2 # scale exponent - li v0, 32 - blt t9, v0, 1f - subu t9, t9, v0 # shift fraction left >= 32 bits - sll t2, t3, t9 - move t3, zero - b 2f -1: - subu v0, v0, t9 # shift fraction left < 32 bits - sll t2, t2, t9 - srl ta0, t3, v0 - or t2, t2, ta0 - sll t3, t3, t9 -2: - bge t1, DEXP_INF, 8f # overflow? - ble t1, zero, 4f # underflow? - sll t2, t2, 32 - 20 # clear implied one bit - srl t2, t2, 32 - 20 -3: - sll t1, t1, 31 - 11 # reposition exponent - sll t0, t0, 31 # reposition sign - or t0, t0, t1 # put result back together - or t0, t0, t2 - mtc1 t0, $f1 # save MSW of result - mtc1 t3, $f0 # save LSW of result - j ra -4: - li v0, 0x80000000 - ble t1, -52, 7f # is result too small for denorm? - sll t2, v1, 31 - 20 # clear exponent, extract fraction - or t2, t2, v0 # set implied one bit - blt t1, -30, 2f # will all bits in t3 be shifted out? - srl t2, t2, 31 - 20 # shift fraction back to normal position - subu t1, t1, 1 - sll ta0, t2, t1 # shift right t2,t3 based on exponent - srl t8, t3, t1 # save bits shifted out - negu t1 - srl t3, t3, t1 - or t3, t3, ta0 - srl t2, t2, t1 - bge t8, zero, 1f # does result need to be rounded? - addu t3, t3, 1 # round result - sltu ta0, t3, 1 - sll t8, t8, 1 - addu t2, t2, ta0 - bne t8, zero, 1f # round result to nearest - and t3, t3, ~1 -1: - mtc1 t3, $f0 # save denormalized result (LSW) - mtc1 t2, $f1 # save denormalized result (MSW) - bge v1, zero, 1f # should result be negative? - neg.d $f0, $f0 # negate result -1: - j ra -2: - mtc1 zero, $f1 # exponent and upper fraction - addu t1, t1, 20 # compute amount to shift right by - sll t8, t2, t1 # save bits shifted out - negu t1 - srl t3, t2, t1 - bge t8, zero, 1f # does result need to be rounded? - addu t3, t3, 1 # round result - sltu ta0, t3, 1 - sll t8, t8, 1 - mtc1 ta0, $f1 # exponent and upper fraction - bne t8, zero, 1f # round result to nearest - and t3, t3, ~1 -1: - mtc1 t3, $f0 - bge v1, zero, 1f # is result negative? - neg.d $f0, $f0 # negate result -1: - j ra -7: - mtc1 zero, $f0 # result is zero - mtc1 zero, $f1 - beq t0, zero, 1f # is result positive? - neg.d $f0, $f0 # negate result -1: - j ra -8: - li t1, 0x7ff00000 # result is infinity (MSW) - mtc1 t1, $f1 - mtc1 zero, $f0 # result is infinity (LSW) - bge v1, zero, 1f # should result be negative infinity? - neg.d $f0, $f0 # result is negative infinity -1: - add.d $f0, $f0, $f0 # cause overflow faults if enabled - j ra -9: - mov.d $f0, $f12 # yes, result is just x - j ra -END(ldexp) diff --git a/lib/libc/arch/mips/gen/longjmp.c b/lib/libc/arch/mips/gen/longjmp.c deleted file mode 100644 index 547fd399f..000000000 --- a/lib/libc/arch/mips/gen/longjmp.c +++ /dev/null @@ -1,108 +0,0 @@ -/* $NetBSD: longjmp.c,v 1.5 2012/03/29 19:27:05 christos Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christian Limpach and Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include - -#define __LIBC12_SOURCE__ -#include -#include - -void -__longjmp14(jmp_buf env, int val) -{ - struct sigcontext *sc = (void *)env; - ucontext_t uc; - - /* Ensure non-zero SP and sigcontext magic number is present */ - if (sc->sc_regs[_R_SP] == 0 || sc->sc_regs[_R_ZERO] != (mips_reg_t)0xACEDBADEU) - goto err; - - /* Ensure non-zero return value */ - if (val == 0) - val = 1; - - /* - * Set _UC_{SET,CLR}STACK according to SS_ONSTACK. - * - * Restore the signal mask with sigprocmask() instead of _UC_SIGMASK, - * since libpthread may want to interpose on signal handling. - */ - uc.uc_flags = _UC_CPU | (sc->sc_onstack ? _UC_SETSTACK : _UC_CLRSTACK); - - sigprocmask(SIG_SETMASK, &sc->sc_mask, NULL); - - /* Clear uc_link */ - uc.uc_link = 0; - - /* Save return value in context */ - uc.uc_mcontext.__gregs[_REG_V0] = val; - - /* Copy saved registers */ - uc.uc_mcontext.__gregs[_REG_S0] = sc->sc_regs[_R_S0]; - uc.uc_mcontext.__gregs[_REG_S1] = sc->sc_regs[_R_S1]; - uc.uc_mcontext.__gregs[_REG_S2] = sc->sc_regs[_R_S2]; - uc.uc_mcontext.__gregs[_REG_S3] = sc->sc_regs[_R_S3]; - uc.uc_mcontext.__gregs[_REG_S4] = sc->sc_regs[_R_S4]; - uc.uc_mcontext.__gregs[_REG_S5] = sc->sc_regs[_R_S5]; - uc.uc_mcontext.__gregs[_REG_S6] = sc->sc_regs[_R_S6]; - uc.uc_mcontext.__gregs[_REG_S7] = sc->sc_regs[_R_S7]; - uc.uc_mcontext.__gregs[_REG_S8] = sc->sc_regs[_R_S8]; -#if defined(__mips_n32) || defined(__mips_n64) - uc.uc_mcontext.__gregs[_REG_GP] = sc->sc_regs[_R_GP]; -#endif - uc.uc_mcontext.__gregs[_REG_SP] = sc->sc_regs[_R_SP]; - uc.uc_mcontext.__gregs[_REG_RA] = sc->sc_regs[_R_RA]; - uc.uc_mcontext.__gregs[_REG_EPC] = sc->sc_pc; - - /* Copy FP state */ - if (sc->sc_fpused) { - /* FP saved regs are $f20 .. $f31 */ - memcpy(&uc.uc_mcontext.__fpregs.__fp_r.__fp_regs[20], - &sc->sc_fpregs[20], 32 - 20); - uc.uc_mcontext.__fpregs.__fp_csr = - sc->sc_fpregs[_R_FSR - _FPBASE]; - /* XXX sc_fp_control */ - uc.uc_flags |= _UC_FPU; - } - - setcontext(&uc); - err: - longjmperror(); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/mips/gen/makecontext.c b/lib/libc/arch/mips/gen/makecontext.c deleted file mode 100644 index 932f071d5..000000000 --- a/lib/libc/arch/mips/gen/makecontext.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.7 2011/09/20 08:42:29 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.7 2011/09/20 08:42:29 joerg Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void __resumecontext(void) __dead; - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - __greg_t *sp; - int i; - va_list ap; - - /* LINTED uintptr_t is safe */ - sp = (__greg_t *) - ((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - /* LINTED uintptr_t is safe */ -#if defined(__mips_o32) || defined(__mips_o64) - sp -= (argc >= 4 ? argc : 4); /* Make room for >=4 arguments. */ - sp = (__greg_t *) - ((uintptr_t)sp & ~0x7); /* Align on double-word boundary. */ -#elif defined(__mips_n32) || defined(__mips_n64) - sp -= (argc > 8 ? argc - 8 : 0); /* Make room for > 8 arguments. */ - sp = (__greg_t *) - ((uintptr_t)sp & ~0xf); /* Align on quad-word boundary. */ -#endif - - gr[_REG_SP] = (intptr_t)sp; - gr[_REG_RA] = (intptr_t)__resumecontext; - gr[_REG_T9] = (intptr_t)func; /* required for .abicalls */ - gr[_REG_EPC] = (intptr_t)func; - - /* Construct argument list. */ - va_start(ap, argc); -#if defined(__mips_o32) || defined(__mips_o64) - /* Up to the first four arguments are passed in $a0-3. */ - for (i = 0; i < argc && i < 4; i++) - /* LINTED __greg_t is safe */ - gr[_REG_A0 + i] = va_arg(ap, __greg_t); - /* Pass remaining arguments on the stack above the $a0-3 gap. */ - sp += i; -#endif -#if defined(__mips_n32) || defined(__mips_n64) - /* Up to the first 8 arguments are passed in $a0-7. */ - for (i = 0; i < argc && i < 8; i++) - /* LINTED __greg_t is safe */ - gr[_REG_A0 + i] = va_arg(ap, __greg_t); - /* Pass remaining arguments on the stack above the $a0-3 gap. */ -#endif - /* Pass remaining arguments on the stack above the $a0-3 gap. */ - for (; i < argc; i++) - /* LINTED uintptr_t is safe */ - *sp++ = va_arg(ap, __greg_t); - va_end(ap); -} diff --git a/lib/libc/arch/mips/gen/modf.S b/lib/libc/arch/mips/gen/modf.S deleted file mode 100644 index 7e523af27..000000000 --- a/lib/libc/arch/mips/gen/modf.S +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: modf.S,v 1.11 2009/12/14 01:07:42 matt 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)modf.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: modf.S,v 1.11 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * double modf(val, iptr) - * double val, *iptr; - * returns: xxx and n (in *iptr) where val == n.xxx - */ -LEAF(modf) - 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/arch/mips/gen/nanf.c b/lib/libc/arch/mips/gen/nanf.c deleted file mode 100644 index 6fbda2885..000000000 --- a/lib/libc/arch/mips/gen/nanf.c +++ /dev/null @@ -1,19 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = -#if BYTE_ORDER == BIG_ENDIAN - { { 0x7f, 0xa0, 0, 0 } }; -#else - { { 0, 0, 0xa0, 0x7f } }; -#endif - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/mips/gen/resumecontext.c b/lib/libc/arch/mips/gen/resumecontext.c deleted file mode 100644 index 66781b68f..000000000 --- a/lib/libc/arch/mips/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:57 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/mips/gen/setjmp.S b/lib/libc/arch/mips/gen/setjmp.S deleted file mode 100644 index c75325bc6..000000000 --- a/lib/libc/arch/mips/gen/setjmp.S +++ /dev/null @@ -1,148 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.19 2010/09/03 17:22:51 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 -#include - -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: setjmp.S,v 1.19 2010/09/03 17:22:51 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#define SETJMP_FRAME_SIZE (CALLFRAME_SIZ + STACK_T_SIZE) - -NON_LEAF(__setjmp14, SETJMP_FRAME_SIZE, ra) - .mask 0x80010000, (CALLFRAME_RA - CALLFRAME_SIZ) - SETUP_GP - PTR_SUBU sp, sp, SETJMP_FRAME_SIZE # allocate stack frame - SAVE_GP(CALLFRAME_GP) - SETUP_GP64(CALLFRAME_GP, __setjmp14) - - REG_S ra, CALLFRAME_RA(sp) # save RA - REG_S s0, CALLFRAME_S0(sp) # save S0 - move s0, a0 # save sigcontext - - /* Get the signal mask. */ - PTR_ADDU a2, a0, _OFFSETOF_SC_MASK # &sc.sc_mask - move a1, zero - jal _C_LABEL(__sigprocmask14) # get current signal mask - - /* Get the signal stack. */ - move a0, zero - PTR_ADDU a1, sp, CALLFRAME_SIZ # pointer to stack_t - jal _C_LABEL(__sigaltstack14) - - move a0, s0 # restore jmpbuf - INT_L v1, CALLFRAME_SIZ+_OFFSETOF_STACK_T_FLAGS(sp) - # get old ss_onstack - and v1, v1, SS_ONSTACK # extract onstack flag - INT_S v1, _OFFSETOF_SC_ONSTACK(a0) # save it in sc_onstack - - REG_L s0, CALLFRAME_S0(sp) # restore S0 - REG_L ra, CALLFRAME_RA(sp) # restore RA - blt v0, zero, botch # check for sigaltstack() error - nop - /* - * We know we won't need this routine's GP anymore. - */ - RESTORE_GP64 - PTR_ADDU sp, sp, SETJMP_FRAME_SIZE # pop stack frame - - - REG_PROLOGUE - REG_S ra, _OFFSETOF_SC_PC(a0) # sc_pc = return address - REG_LI v0, 0xACEDBADE # sigcontext magic number - REG_S v0, _OFFSETOF_SC_REGS(a0) # saved in sc_regs[0] - REG_S s0, _OFFSETOF_SC_REGS_S0(a0) - REG_S s1, _OFFSETOF_SC_REGS_S1(a0) - REG_S s2, _OFFSETOF_SC_REGS_S2(a0) - REG_S s3, _OFFSETOF_SC_REGS_S3(a0) - REG_S s4, _OFFSETOF_SC_REGS_S4(a0) - REG_S s5, _OFFSETOF_SC_REGS_S5(a0) - REG_S s6, _OFFSETOF_SC_REGS_S6(a0) - REG_S s7, _OFFSETOF_SC_REGS_S7(a0) - REG_S gp, _OFFSETOF_SC_REGS_GP(a0) - REG_S sp, _OFFSETOF_SC_REGS_SP(a0) - REG_S s8, _OFFSETOF_SC_REGS_S8(a0) -#ifdef SOFTFLOAT_FOR_GCC - INT_S zero, _OFFSETOF_SC_FPUSED(a0) # sc_fpused = 0 -#else - li v0, 1 # be nice if we could tell - INT_S v0, _OFFSETOF_SC_FPUSED(a0) # sc_fpused = 1 - cfc1 v0, $31 - INT_S v0, _OFFSETOF_SC_FPREGS_FCSR(a0) -#if defined(__mips_o32) || defined(__mips_o64) || defined(__mips_n32) - FP_S $f20, _OFFSETOF_SC_FPREGS_F20(a0) - FP_S $f22, _OFFSETOF_SC_FPREGS_F22(a0) -#endif -#if defined(__mips_o32) || defined(__mips_o64) - FP_S $f21, _OFFSETOF_SC_FPREGS_F21(a0) - FP_S $f23, _OFFSETOF_SC_FPREGS_F23(a0) -#endif -#if defined(__mips_n32) || defined(__mips_n64) - FP_S $f24, _OFFSETOF_SC_FPREGS_F24(a0) - FP_S $f26, _OFFSETOF_SC_FPREGS_F26(a0) - FP_S $f28, _OFFSETOF_SC_FPREGS_F28(a0) - FP_S $f30, _OFFSETOF_SC_FPREGS_F30(a0) -#endif -#if defined(__mips_n64) - FP_S $f25, _OFFSETOF_SC_FPREGS_F25(a0) - FP_S $f27, _OFFSETOF_SC_FPREGS_F27(a0) - FP_S $f29, _OFFSETOF_SC_FPREGS_F29(a0) - FP_S $f31, _OFFSETOF_SC_FPREGS_F31(a0) -#endif -#endif /* SOFTFLOAT_FOR_GCC */ - REG_EPILOGUE - move v0, zero - j ra - -botch: - jal _C_LABEL(abort) -END(__setjmp14) diff --git a/lib/libc/arch/mips/gen/sigsetjmp.S b/lib/libc/arch/mips/gen/sigsetjmp.S deleted file mode 100644 index 5cbe82d80..000000000 --- a/lib/libc/arch/mips/gen/sigsetjmp.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.9 2009/12/14 01:07:42 matt 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 - * Havard Eidnes. - * - * 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 -#include -#include -#include - -#include "assym.h" -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: sigsetjmp.S,v 1.9 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, savemask) - * by restoring registers from the stack, - * and dependent on savemask restores the - * signal mask. - */ - -LEAF(__sigsetjmp14) - PIC_PROLOGUE(__sigsetjmp14) - REG_S a1, _JBLEN*SZREG(a0) # save "savemask" - bne a1, 0x0, 1f # do saving of signal mask? - PIC_TAILCALL(_setjmp) - -1: PIC_TAILCALL(__setjmp14) -END(__sigsetjmp14) - -LEAF(__siglongjmp14) - PIC_PROLOGUE(__siglongjmp14) - REG_L t0, _JBLEN*SZREG(a0) # get "savemask" - bne t0, 0x0, 1f # restore signal mask? - PIC_TAILCALL(_longjmp) - -1: PIC_TAILCALL(__longjmp14) -END(__siglongjmp14) diff --git a/lib/libc/arch/mips/gen/swapcontext.S b/lib/libc/arch/mips/gen/swapcontext.S deleted file mode 100644 index e2aff9d39..000000000 --- a/lib/libc/arch/mips/gen/swapcontext.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.5 2012/09/12 02:00:52 manu Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.5 2012/09/12 02:00:52 manu Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - - .set reorder - -NESTED(swapcontext, CALLFRAME_SIZ, ra) - .mask 0x80000030, (CALLFRAME_RA - CALLFRAME_SIZ) - PTR_SUBU sp, sp, CALLFRAME_SIZ - PTR_S ra, CALLFRAME_RA(sp) # save ra - PTR_S a0, 0(sp) # stash away oucp - PTR_S a1, SZREG(sp) # stash away ucp - SYSTRAP(getcontext) - PTR_L ra, CALLFRAME_RA(sp) - bne a3, zero, 1f - - PTR_L v1, 0(sp) # load oucp again for adjustment - PTR_L a0, SZREG(sp) # load ucp - PTR_ADDIU v0, sp, CALLFRAME_SIZ - REG_PROLOGUE - REG_S zero, _OFFSETOF_UC_GREGS_V0(v1) - REG_S ra, _OFFSETOF_UC_GREGS_EPC(v1) - REG_S v0, _OFFSETOF_UC_GREGS_SP(v1) - REG_EPILOGUE - - PIC_TAILCALL(setcontext) - /* NOTREACHED */ -1: - PTR_ADDU sp, sp, CALLFRAME_SIZ - SETUP_GPX(t0); - SETUP_GP64(t3,swapcontext); - PIC_TAILCALL(__cerror) -END(swapcontext) diff --git a/lib/libc/arch/mips/genassym.cf b/lib/libc/arch/mips/genassym.cf deleted file mode 100644 index 512d3f953..000000000 --- a/lib/libc/arch/mips/genassym.cf +++ /dev/null @@ -1,86 +0,0 @@ -# $NetBSD: genassym.cf,v 1.2 2009/12/14 01:07:41 matt Exp $ - -# -# Copyright (c) 2001 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include -include -include -include - -define _OFFSETOF_UC_GREGS offsetof(ucontext_t, uc_mcontext.__gregs[0]) -define _OFFSETOF_UC_GREGS_V0 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_V0]) -define _OFFSETOF_UC_GREGS_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_SP]) -define _OFFSETOF_UC_GREGS_EPC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_EPC]) -define _OFFSETOF_UC_LINK offsetof(ucontext_t, uc_link) -define UCONTEXT_SIZE sizeof(ucontext_t) - -define _OFFSETOF_SC_REGS offsetof(struct sigcontext, sc_regs[0]) -define _OFFSETOF_SC_REGS_V0 offsetof(struct sigcontext, sc_regs[_R_V0]) -define _OFFSETOF_SC_REGS_S0 offsetof(struct sigcontext, sc_regs[_R_S0]) -define _OFFSETOF_SC_REGS_S1 offsetof(struct sigcontext, sc_regs[_R_S1]) -define _OFFSETOF_SC_REGS_S2 offsetof(struct sigcontext, sc_regs[_R_S2]) -define _OFFSETOF_SC_REGS_S3 offsetof(struct sigcontext, sc_regs[_R_S3]) -define _OFFSETOF_SC_REGS_S4 offsetof(struct sigcontext, sc_regs[_R_S4]) -define _OFFSETOF_SC_REGS_S5 offsetof(struct sigcontext, sc_regs[_R_S5]) -define _OFFSETOF_SC_REGS_S6 offsetof(struct sigcontext, sc_regs[_R_S6]) -define _OFFSETOF_SC_REGS_S7 offsetof(struct sigcontext, sc_regs[_R_S7]) -define _OFFSETOF_SC_REGS_S8 offsetof(struct sigcontext, sc_regs[_R_S8]) -define _OFFSETOF_SC_REGS_SP offsetof(struct sigcontext, sc_regs[_R_SP]) -define _OFFSETOF_SC_REGS_GP offsetof(struct sigcontext, sc_regs[_R_GP]) -define _OFFSETOF_SC_FPREGS offsetof(struct sigcontext, sc_fpregs[0]) -define _OFFSETOF_SC_FPREGS_F20 offsetof(struct sigcontext, sc_fpregs[20]) -define _OFFSETOF_SC_FPREGS_F21 offsetof(struct sigcontext, sc_fpregs[21]) -define _OFFSETOF_SC_FPREGS_F22 offsetof(struct sigcontext, sc_fpregs[22]) -define _OFFSETOF_SC_FPREGS_F23 offsetof(struct sigcontext, sc_fpregs[23]) -define _OFFSETOF_SC_FPREGS_F24 offsetof(struct sigcontext, sc_fpregs[24]) -define _OFFSETOF_SC_FPREGS_F25 offsetof(struct sigcontext, sc_fpregs[25]) -define _OFFSETOF_SC_FPREGS_F26 offsetof(struct sigcontext, sc_fpregs[26]) -define _OFFSETOF_SC_FPREGS_F27 offsetof(struct sigcontext, sc_fpregs[27]) -define _OFFSETOF_SC_FPREGS_F28 offsetof(struct sigcontext, sc_fpregs[28]) -define _OFFSETOF_SC_FPREGS_F29 offsetof(struct sigcontext, sc_fpregs[29]) -define _OFFSETOF_SC_FPREGS_F30 offsetof(struct sigcontext, sc_fpregs[30]) -define _OFFSETOF_SC_FPREGS_F31 offsetof(struct sigcontext, sc_fpregs[31]) -define _OFFSETOF_SC_FPREGS_FCSR offsetof(struct sigcontext, sc_fpregs[32]) -define _OFFSETOF_SC_PC offsetof(struct sigcontext, sc_pc) -define _OFFSETOF_SC_MASK offsetof(struct sigcontext, sc_mask) -define _OFFSETOF_SC_MASK13 offsetof(struct sigcontext, __sc_mask13) -define _OFFSETOF_SC_ONSTACK offsetof(struct sigcontext, sc_onstack) -define _OFFSETOF_SC_FPUSED offsetof(struct sigcontext, sc_fpused) - -define SIGINFO_SIZE sizeof(siginfo_t) - -define STACK_T_SIZE ((sizeof(stack_t) + 2 * sizeof(register_t) - 1) & -(2 * sizeof(register_t))) -define _OFFSETOF_STACK_T_SP offsetof(stack_t, ss_sp) -define _OFFSETOF_STACK_T_SIZE offsetof(stack_t, ss_size) -define _OFFSETOF_STACK_T_FLAGS offsetof(stack_t, ss_flags) - -define SS_ONSTACK SS_ONSTACK diff --git a/lib/libc/arch/mips/net/Makefile.inc b/lib/libc/arch/mips/net/Makefile.inc deleted file mode 100644 index a76082951..000000000 --- a/lib/libc/arch/mips/net/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/12/06 07:12:17 uebayasi Exp $ - -# objects built from assembler sources (need lint stubs) -# hton* and nto* functions provided by ../gen/byte_swap_*.S -SRCS+= - -LSRCS.mips.net= Lint_htonl.c Lint_htons.c Lint_ntohl.c Lint_ntohs.c -LSRCS+= ${LSRCS.mips.net} -DPSRCS+= ${LSRCS.mips.net} -CLEANFILES+= ${LSRCS.mips.net} diff --git a/lib/libc/arch/mips/softfloat/milieu.h b/lib/libc/arch/mips/softfloat/milieu.h deleted file mode 100644 index e66eb2efc..000000000 --- a/lib/libc/arch/mips/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.2 2009/12/14 01:07:42 matt Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "mips-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/mips/softfloat/mips-gcc.h b/lib/libc/arch/mips/softfloat/mips-gcc.h deleted file mode 100644 index 364924614..000000000 --- a/lib/libc/arch/mips/softfloat/mips-gcc.h +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: mips-gcc.h,v 1.5 2011/06/27 06:40:26 matt Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#ifdef __MIPSEB__ -#define BIGENDIAN -#else -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef int uint8; -typedef int int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -/* -------------------------------------------------------------------------------- -The MIPS FPA is odd in that it stores doubles high-order word first, no matter -what the endianness of the CPU. VFP is sane. -------------------------------------------------------------------------------- -*/ -#if defined(SOFTFLOAT_FOR_GCC) -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) -#endif diff --git a/lib/libc/arch/mips/softfloat/softfloat.h b/lib/libc/arch/mips/softfloat/softfloat.h deleted file mode 100644 index c731604e7..000000000 --- a/lib/libc/arch/mips/softfloat/softfloat.h +++ /dev/null @@ -1,325 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.5 2011/07/07 07:14:57 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -#if defined(__mips_n32) || defined(__mips_n64) -#define FLOAT128 -#endif - -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */ -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned int float32_to_uint32_round_to_zero( float32 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -#endif -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -int float32_eq( float32, float32 ); -int float32_le( float32, float32 ); -int float32_lt( float32, float32 ); -int float32_eq_signaling( float32, float32 ); -int float32_le_quiet( float32, float32 ); -int float32_lt_quiet( float32, float32 ); -#ifndef SOFTFLOAT_FOR_GCC -int float32_is_signaling_nan( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned int float64_to_uint32_round_to_zero( float64 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -#endif -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -int float64_eq( float64, float64 ); -int float64_le( float64, float64 ); -int float64_lt( float64, float64 ); -int float64_eq_signaling( float64, float64 ); -int float64_le_quiet( float64, float64 ); -int float64_lt_quiet( float64, float64 ); -#ifndef SOFTFLOAT_FOR_GCC -int float64_is_signaling_nan( float64 ); -#endif - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -int floatx80_eq( floatx80, floatx80 ); -int floatx80_le( floatx80, floatx80 ); -int floatx80_lt( floatx80, floatx80 ); -int floatx80_eq_signaling( floatx80, floatx80 ); -int floatx80_le_quiet( floatx80, floatx80 ); -int floatx80_lt_quiet( floatx80, floatx80 ); -int floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned int float128_to_uint32_round_to_zero( float64 ); -#endif -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned long long float128_to_uint64_round_to_zero( float128 ); -#endif -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -int float128_eq( float128, float128 ); -int float128_le( float128, float128 ); -int float128_lt( float128, float128 ); -int float128_eq_signaling( float128, float128 ); -int float128_le_quiet( float128, float128 ); -int float128_lt_quiet( float128, float128 ); -int float128_is_signaling_nan( float128 ); -flag float128_is_nan( float128 ); - -#endif - diff --git a/lib/libc/arch/mips/stdlib/Makefile.inc b/lib/libc/arch/mips/stdlib/Makefile.inc deleted file mode 100644 index 2f91b992a..000000000 --- a/lib/libc/arch/mips/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/31 20:40:00 dsl Exp $ diff --git a/lib/libc/arch/mips/string/Makefile.inc b/lib/libc/arch/mips/string/Makefile.inc deleted file mode 100644 index 0213864d4..000000000 --- a/lib/libc/arch/mips/string/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/12/14 01:07:42 matt Exp $ - -SRCS+= bcmp.S bcopy.S bzero.S \ - ffs.S \ - memcpy.S memmove.S \ - strchr.S strrchr.S \ - strcmp.S strlen.S diff --git a/lib/libc/arch/mips/string/bcmp.S b/lib/libc/arch/mips/string/bcmp.S deleted file mode 100644 index c90fa2c36..000000000 --- a/lib/libc/arch/mips/string/bcmp.S +++ /dev/null @@ -1,124 +0,0 @@ -/* $NetBSD: bcmp.S,v 1.9 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 -#define _LOCORE /* XXX not really, just assembly-code source */ -#include /* LWLO/LWHI, SWLO/SWHI */ - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)bcmp.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: bcmp.S,v 1.9 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* bcmp(s1, s2, n) */ - - -LEAF(bcmp) - .set noreorder - blt a2, 16, small # is it worth any trouble? - xor v0, a0, a1 # compare low two bits of addresses - and v0, v0, 3 - PTR_SUBU a3, zero, a1 # compute # bytes to word align address - bne v0, zero, unaligned # not possible to align addresses - and a3, a3, 3 - - beq a3, zero, 1f - PTR_SUBU a2, a2, a3 # subtract from remaining count - move v0, v1 # init v0,v1 so unmodified bytes match - LWHI v0, 0(a0) # read 1, 2, or 3 bytes - LWHI v1, 0(a1) - PTR_ADDU a1, a1, a3 - bne v0, v1, nomatch - PTR_ADDU a0, a0, a3 -1: - and a3, a2, ~3 # compute number of whole words left - PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 - PTR_ADDU a3, a3, a0 # compute ending address -2: - lw v0, 0(a0) # compare words - lw v1, 0(a1) - PTR_ADDU a0, a0, 4 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 4 - bne a0, a3, 2b - nop - b small # finish remainder - nop -unaligned: - beq a3, zero, 2f - PTR_SUBU a2, a2, a3 # subtract from remaining count - PTR_ADDU a3, a3, a0 # compute ending address -1: - lbu v0, 0(a0) # compare bytes until a1 word aligned - lbu v1, 0(a1) - PTR_ADDU a0, a0, 1 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 1 - bne a0, a3, 1b - nop -2: - and a3, a2, ~3 # compute number of whole words left - PTR_SUBU a2, a2, a3 # which has to be >= (16-3) & ~3 - PTR_ADDU a3, a3, a0 # compute ending address -3: - LWHI v0, 0(a0) # compare words a0 unaligned, a1 aligned - LWLO v0, 3(a0) - lw v1, 0(a1) - PTR_ADDU a0, a0, 4 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 4 - bne a0, a3, 3b - nop -small: - ble a2, zero, match - PTR_ADDU a3, a2, a0 # compute ending address -1: - lbu v0, 0(a0) - lbu v1, 0(a1) - PTR_ADDU a0, a0, 1 - bne v0, v1, nomatch - PTR_ADDU a1, a1, 1 - bne a0, a3, 1b - nop -match: - j ra - move v0, zero -nomatch: - j ra - li v0, 1 - .set reorder -END(bcmp) diff --git a/lib/libc/arch/mips/string/bzero.S b/lib/libc/arch/mips/string/bzero.S deleted file mode 100644 index f25c02055..000000000 --- a/lib/libc/arch/mips/string/bzero.S +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: bzero.S,v 1.10 2009/12/14 02:53:52 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)bzero.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: bzero.S,v 1.10 2009/12/14 02:53:52 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - - -#define _LOCORE /* XXX not really, just assembly-code source */ -#include - -/* bzero(s1, n) */ - -LEAF(bzero) - .set noreorder - blt a1, 3*SZREG, smallclr # small amount to clear? - PTR_SUBU a3, zero, a0 # compute # bytes to word align address - and a3, a3, SZREG-1 - beq a3, zero, 1f # skip if word aligned -#if SZREG == 4 - PTR_SUBU a1, a1, a3 # subtract from remaining count - SWHI zero, 0(a0) # clear 1, 2, or 3 bytes to align - PTR_ADDU a0, a0, a3 -#endif -#if SZREG == 8 - PTR_SUBU a1, a1, a3 # subtract from remaining count - PTR_ADDU a0, a0, a3 # align dst to next word - sll a3, a3, 3 # bits to bytes - li a2, -1 # make a mask -#if _BYTE_ORDER == _BIG_ENDIAN - REG_SRLV a2, a2, a3 # we want to keep the MSB bytes -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN - REG_SLLV a2, a2, a3 # we want to keep the LSB bytes -#endif - nor a2, zero, a2 # complement the mask - REG_L v0, -SZREG(a0) # load the word to partially clear - and v0, v0, a2 # clear the bytes - REG_S v0, -SZREG(a0) # store it back -#endif -1: - and v0, a1, SZREG-1 # compute number of words left - PTR_SUBU a3, a1, v0 - move a1, v0 - PTR_ADDU a3, a3, a0 # compute ending address -2: - PTR_ADDU a0, a0, SZREG # clear words - bne a0, a3, 2b # unrolling loop doesnt help - REG_S zero, -SZREG(a0) # since we are limited by memory speed -smallclr: - ble a1, zero, 2f - PTR_ADDU a3, a1, a0 # compute ending address -1: - PTR_ADDU a0, a0, 1 # clear bytes - bne a0, a3, 1b - sb zero, -1(a0) -2: - j ra - nop -END(bzero) diff --git a/lib/libc/arch/mips/sys/__clone.S b/lib/libc/arch/mips/sys/__clone.S deleted file mode 100644 index de7ef4792..000000000 --- a/lib/libc/arch/mips/sys/__clone.S +++ /dev/null @@ -1,103 +0,0 @@ -/* $NetBSD: __clone.S,v 1.8 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __clone.S,v 1.8 2009/12/14 01:07:42 matt Exp $"); -#endif /* SYSLIBC_SCCS and not lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -LEAF(__clone) - PIC_PROLOGUE(__clone) - - /* - * Sanity checks: func and stack may not be NULL. - */ - li v0, EINVAL - beq a0, zero, 8f - beq a1, zero, 8f - - /* - * We need to be able to get at the func and arg arguments - * in the child. Luckily, we have a convenient place to - * do this: the child's stack. - */ - PTR_SUBU a1, a1, CALLFRAME_SIZ - REG_S a0, 0(a1) - REG_S a3, SZREG(a1) - - /* - * The system call expects (flags, stack). - */ - move a0, a2 - SYSTRAP(__clone) - bne a3, zero, 8f - - bne v1, zero, 9f # v1 (rv[1]) == 0, parent, child pid in v0 - - PIC_RETURN() # parent return - -8: PIC_TAILCALL(__cerror) - /* NOTREACHED */ - -9: /* - * Child: Fetch the function and argument from the new stack and create - a frame so that the child can be safely called. - * - * There are already register slots on the stack from above. - * They already include the o32 argument save area. The - * highest is unused. a1 should equal sp now. - */ - - REG_L t9, 0(sp) - REG_L a0, SZREG(sp) - - REG_S zero, CALLFRAME_RA(sp) /* make sure stack frame ends */ - - /* Call the clone's entry point. */ - SAVE_GP(CALLFRAME_GP) - jal t9 - - /* Pass the return value to _exit. */ - move a0, v0 - PIC_TAILCALL(_exit) - - /* NOTREACHED */ -END(__clone) diff --git a/lib/libc/arch/mips/sys/__sigaction14_sigtramp.c b/lib/libc/arch/mips/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 929edac97..000000000 --- a/lib/libc/arch/mips/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.7 2008/04/28 20:22:56 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.7 2008/04/28 20:22:56 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specified or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/mips/sys/__sigtramp2.S b/lib/libc/arch/mips/sys/__sigtramp2.S deleted file mode 100644 index 63b0661de..000000000 --- a/lib/libc/arch/mips/sys/__sigtramp2.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.3 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __sigtramp2.S,v 1.3 2009/12/14 01:07:42 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - - -/* - * The MIPS signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * sp -> siginfo_t structure - * sp + SIGINFO_SIZE -> ucontext_t structure - */ -LEAF_NOPROFILE(__sigtramp_siginfo_2) - PTR_ADDU a0, sp, SIGINFO_SIZE /* address of ucontext */ - SYSTRAP(setcontext) /* and do setcontext */ - move a0, v0 /* exit with errno */ - SYSTRAP(exit) /* if sigreturn fails */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/mips/sys/__syscall.S b/lib/libc/arch/mips/sys/__syscall.S deleted file mode 100644 index 0841e4795..000000000 --- a/lib/libc/arch/mips/sys/__syscall.S +++ /dev/null @@ -1,27 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.2 2014/01/31 18:06:26 matt Exp $ */ - -#include "SYS.h" - -#ifdef __mips_o32 -RSYSCALL(__syscall) -#else - -LEAF(__syscall) - PIC_PROLOGUE(__syscall) - move v0, a0 - move a0, a1 - move a1, a2 - move a2, a3 - move a3, a4 - move a4, a5 - move a5, a6 - move a6, a7 - REG_L a7, (sp) - SYSTRAP(__syscall) - bne a3,zero,1f - PIC_RETURN() -1: - PIC_TAILCALL(__cerror) -END(__syscall) -STRONG_ALIAS(syscall, __syscall) -#endif diff --git a/lib/libc/arch/mips/sys/__vfork14.S b/lib/libc/arch/mips/sys/__vfork14.S deleted file mode 100644 index dcb309fd9..000000000 --- a/lib/libc/arch/mips/sys/__vfork14.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.6 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)Ovfork.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: __vfork14.S,v 1.6 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * pid = vfork(); - * - * v1 == 0 in parent process, v1 == 1 in child process. - * v0 == pid of child in parent, v0 == pid of parent in child. - */ - -LEAF(__vfork14) - PIC_PROLOGUE(__vfork14) - li v0, SYS___vfork14 # system call number for vfork - syscall - beq a3, zero, 1f # jump if no errors - PIC_TAILCALL(__cerror) -1: - beq v1, zero, 2f # parent process ? - move v0, zero # return zero in child -2: - PIC_RETURN() -END(__vfork14) diff --git a/lib/libc/arch/mips/sys/brk.S b/lib/libc/arch/mips/sys/brk.S deleted file mode 100644 index f0571d075..000000000 --- a/lib/libc/arch/mips/sys/brk.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: brk.S,v 1.18 2010/12/12 09:00:37 tsutsui Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)brk.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: brk.S,v 1.18 2010/12/12 09:00:37 tsutsui Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - - .globl _C_LABEL(__minbrk) - .globl _C_LABEL(__curbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data -_C_LABEL(__minbrk): - PTR_WORD _C_LABEL(_end) - .text - -LEAF(_brk) - PIC_PROLOGUE(_brk) - PTR_LA t0, _C_LABEL(__minbrk) - PTR_L v0, 0(t0) - bgeu a0, v0, 1f - move a0, v0 # dont allow break < minbrk -1: - li v0, SYS_break - syscall - bne a3, zero, 2f - PTR_LA t0, _C_LABEL(__curbrk) - PTR_S a0, 0(t0) - move v0, zero - PIC_RETURN() -2: - PIC_TAILCALL(__cerror) -END(_brk) diff --git a/lib/libc/arch/mips/sys/cerror.S b/lib/libc/arch/mips/sys/cerror.S deleted file mode 100644 index 5c2a45f7c..000000000 --- a/lib/libc/arch/mips/sys/cerror.S +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: cerror.S,v 1.19 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)cerror.s 8.1 (Berkeley) 6/16/93") -#else - RCSID("$NetBSD: cerror.S,v 1.19 2013/09/12 15:36:15 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef __PIC__ - .protected __cerror -#endif - -#ifdef _REENTRANT - .globl _C_LABEL(__errno) -NESTED_NOPROFILE(__cerror, CALLFRAME_SIZ, ra) - .mask 0x80000000, (CALLFRAME_RA - CALLFRAME_SIZ) - PIC_PROLOGUE(__cerror) - PTR_SUBU sp, CALLFRAME_SIZ - PTR_S ra, CALLFRAME_RA(sp) - INT_S v0, CALLFRAME_S0(sp) # save errno value - - SAVE_GP(CALLFRAME_GP) - - PTR_LA t9, _C_LABEL(__errno) # locate address of errno - RESTORE_GP64 # restore GP (from t3) - jalr t9 # __errno() - - INT_L t0, CALLFRAME_S0(sp) - PTR_L ra, CALLFRAME_RA(sp) - INT_S t0, 0(v0) # update errno value - PTR_ADDU sp, CALLFRAME_SIZ - li v0, -1 - li v1, -1 - j ra # GP has been restored. -END(__cerror) -#else - .globl _C_LABEL(errno) -LEAF_NOPROFILE(__cerror) - PIC_PROLOGUE(__cerror) - INT_S v0, _C_LABEL(errno) - li v0, -1 - li v1, -1 - PIC_RETURN() -END(__cerror) -#endif /* _REENTRANT */ diff --git a/lib/libc/arch/mips/sys/exect.S b/lib/libc/arch/mips/sys/exect.S deleted file mode 100644 index 4f69e12ec..000000000 --- a/lib/libc/arch/mips/sys/exect.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: exect.S,v 1.10 2009/12/14 01:07:42 matt Exp $ */ -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)exect.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: exect.S,v 1.10 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -LEAF(exect) - PIC_PROLOGUE(exect) - li v0, SYS_execve - syscall - bne a3, zero, 1f - PIC_RETURN() -1: - PIC_TAILCALL(__cerror) -END(exect) diff --git a/lib/libc/arch/mips/sys/fork.S b/lib/libc/arch/mips/sys/fork.S deleted file mode 100644 index 1a532fc70..000000000 --- a/lib/libc/arch/mips/sys/fork.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: fork.S,v 1.12 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)fork.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: fork.S,v 1.12 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -LEAF(__fork) - PIC_PROLOGUE(__fork) - - SYSTRAP(fork) # pid = fork() - bne a3, zero, 2f - beq v1, zero, 1f # v1 == 0 in parent, 1 in child - move v0, zero -1: - PIC_RETURN() -2: - PIC_TAILCALL(__cerror) -END(__fork) diff --git a/lib/libc/arch/mips/sys/getcontext.S b/lib/libc/arch/mips/sys/getcontext.S deleted file mode 100644 index 34743c69a..000000000 --- a/lib/libc/arch/mips/sys/getcontext.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.4 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" -#include - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.4 2009/12/14 01:07:42 matt Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - .set reorder - -LEAF(_getcontext) - PIC_PROLOGUE(_getcontext) - SYSTRAP(getcontext) - bne a3, zero, 1f - REG_PROLOGUE - REG_S zero, (_OFFSETOF_UC_GREGS + _REG_V0 * SZREG)(a0) - REG_S ra, (_OFFSETOF_UC_GREGS + _REG_EPC * SZREG)(a0) - REG_EPILOGUE - PIC_RETURN() -1: - PIC_TAILCALL(__cerror) -END(_getcontext) diff --git a/lib/libc/arch/mips/sys/pipe.S b/lib/libc/arch/mips/sys/pipe.S deleted file mode 100644 index d4047e241..000000000 --- a/lib/libc/arch/mips/sys/pipe.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: pipe.S,v 1.12 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)pipe.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: pipe.S,v 1.12 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -LEAF(_pipe) - PIC_PROLOGUE(_pipe); - - SYSTRAP(pipe) # pipe(fildes) int fildes[2]; - - bne a3, zero, 1f - INT_S v0, 0(a0) # store the two file descriptors - INT_S v1, 4(a0) - move v0, zero - PIC_RETURN() -1: - PIC_TAILCALL(__cerror) -END(_pipe) diff --git a/lib/libc/arch/mips/sys/ptrace.S b/lib/libc/arch/mips/sys/ptrace.S deleted file mode 100644 index a1817e3d6..000000000 --- a/lib/libc/arch/mips/sys/ptrace.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.10 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)ptrace.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: ptrace.S,v 1.10 2009/12/14 01:07:42 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -LEAF(ptrace) - PIC_PROLOGUE(ptrace) - INT_S zero, _C_LABEL(errno) /* BOGUS */ - - SYSTRAP(ptrace) - bne a3, zero, 1f - PIC_RETURN() -1: - PIC_TAILCALL(__cerror) -END(ptrace) diff --git a/lib/libc/arch/mips/sys/sbrk.S b/lib/libc/arch/mips/sys/sbrk.S deleted file mode 100644 index 5098b0c7c..000000000 --- a/lib/libc/arch/mips/sys/sbrk.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.19 2013/06/26 08:38:34 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sbrk.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: sbrk.S,v 1.19 2013/06/26 08:38:34 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - - .globl _C_LABEL(__curbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data -_C_LABEL(__curbrk): - PTR_WORD _C_LABEL(_end) - .text - -LEAF(_sbrk) - PIC_PROLOGUE(_sbrk) - PTR_LA t0, _C_LABEL(__curbrk) - PTR_L t1, 0(t0) - PTR_ADDU a0, a0, t1 # compute current break - SYSTRAP(break) - bne a3, zero, 1f - move v0, t1 # return old val of curbrk from above - PTR_LA t0, _C_LABEL(__curbrk) - PTR_S a0, 0(t0) # save current val of curbrk from above - PIC_RETURN() -1: - PIC_TAILCALL(__cerror) -END(_sbrk) diff --git a/lib/libc/arch/mips/sys/shmat.S b/lib/libc/arch/mips/sys/shmat.S deleted file mode 100644 index 0e7842254..000000000 --- a/lib/libc/arch/mips/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:52 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/mips/sys/syscall.S b/lib/libc/arch/mips/sys/syscall.S deleted file mode 100644 index 1ff15719e..000000000 --- a/lib/libc/arch/mips/sys/syscall.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: syscall.S,v 1.7 2014/01/31 18:06:26 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)syscall.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: syscall.S,v 1.7 2014/01/31 18:06:26 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef __mips_o32 -RSYSCALL(syscall) -#endif diff --git a/lib/libc/arch/or1k/Makefile.inc b/lib/libc/arch/or1k/Makefile.inc deleted file mode 100644 index be1925404..000000000 --- a/lib/libc/arch/or1k/Makefile.inc +++ /dev/null @@ -1,25 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2014/09/05 18:09:37 matt Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S -SRCS+= mulsi3.S - -CPPFLAGS+= -I. - -DPSRCS+= sysassym.h -CLEANFILES+= sysassym.h sysassym.h.tmp - -sysassym.h: ${DESTDIR}/usr/include/sys/syscall.h \ - ${DESTDIR}/usr/include/sys/syscallargs.h ${ARCHDIR}/syscallargs.awk - ${_MKTARGET_CREATE} - ${TOOL_CAT} \ - ${DESTDIR}/usr/include/sys/syscall.h \ - ${DESTDIR}/usr/include/sys/syscallargs.h | \ - ${TOOL_AWK} -f ${ARCHDIR}/syscallargs.awk | \ - ${TOOL_GENASSYM} -- ${CC} -ffreestanding ${CFLAGS:N-Wa,*} \ - ${CPPFLAGS:N-D*} -D_KMEMUSER \ - ${GENASSYM_CPPFLAGS} > $@.tmp && \ - mv -f $@.tmp $@ - -.if ${MKSOFTFLOAT} != "no" -.include -.endif diff --git a/lib/libc/arch/or1k/SYS.h b/lib/libc/arch/or1k/SYS.h deleted file mode 100644 index 7bd09a660..000000000 --- a/lib/libc/arch/or1k/SYS.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: SYS.h,v 1.2 2014/09/05 18:09:37 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include "sysassym.h" - -#define _DOSYSCALL(x) l.addi r13,r0,(SYS_ ## x) ;\ - l.sys 0 ;\ - l.nop - -#define _SYSCALL_NOERROR(x,y) ENTRY(x) ;\ - .if NSYSARGS_##y > 6 ;\ - l.lwz r11, 0(r1) ;\ - .endif ;\ - .if NSYSARGS_##y > 7 ;\ - l.lwz r12, 4(r1) ;\ - .endif ;\ - _DOSYSCALL(y) - -#define _SYSCALL(x,y) _SYSCALL_NOERROR(x,y) ;\ - l.bf _C_LABEL(__cerror) ;\ - l.nop - -#define SYSCALL_NOERROR(x) _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) _SYSCALL_NOERROR(x,y) ;\ - l.jr lr ;\ - l.nop ;\ - END(x) - -#define PSEUDO(x,y) _SYSCALL_NOERROR(x,y) ;\ - l.bf _C_LABEL(__cerror) ;\ - l.nop ;\ - l.jr lr ;\ - l.nop ;\ - END(x) - -#define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) PSEUDO(x,x) - -#define WSYSCALL(weak,strong) WEAK_ALIAS(weak,strong) ;\ - PSEUDO(strong,weak) diff --git a/lib/libc/arch/or1k/gdtoa/Makefile.inc b/lib/libc/arch/or1k/gdtoa/Makefile.inc deleted file mode 100644 index ba631cb9b..000000000 --- a/lib/libc/arch/or1k/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/03 19:34:25 matt Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/or1k/gdtoa/arith.h b/lib/libc/arch/or1k/gdtoa/arith.h deleted file mode 100644 index 66326b852..000000000 --- a/lib/libc/arch/or1k/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -#define IEEE_BIG_ENDIAN diff --git a/lib/libc/arch/or1k/gdtoa/gd_qnan.h b/lib/libc/arch/or1k/gdtoa/gd_qnan.h deleted file mode 100644 index f3f58b191..000000000 --- a/lib/libc/arch/or1k/gdtoa/gd_qnan.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 diff --git a/lib/libc/arch/or1k/gen/Makefile.inc b/lib/libc/arch/or1k/gen/Makefile.inc deleted file mode 100644 index ab8fbb088..000000000 --- a/lib/libc/arch/or1k/gen/Makefile.inc +++ /dev/null @@ -1,29 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/03 19:34:25 matt Exp $ - -SRCS+= __setjmp14.S __sigsetjmp14.S _setjmp.S -SRCS+= bswap16.c bswap32.c bswap64.c -SRCS+= flt_rounds.c -SRCS+= _lwp.c makecontext.c resumecontext.c swapcontext.S - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c -SRCS+= fabs_ieee754.c - -SRCS+= nanf.c - -.if (${MKSOFTFLOAT} == "no") -SRCS+= fpgetround.c fpsetround.c fpgetmask.c fpsetmask.c -SRCS+= fpgetsticky.c fpsetsticky.c -.endif - -CPPFLAGS._lwp.c += -D_LIBC_SOURCE - -LSRCS.powerpc.gen=Lint_swapcontext.c -LSRCS+= ${LSRCS.powerpc.gen} -DPSRCS+= ${LSRCS.powerpc.gen} -CLEANFILES+= ${LSRCS.powerpc.gen} diff --git a/lib/libc/arch/or1k/gen/__setjmp14.S b/lib/libc/arch/or1k/gen/__setjmp14.S deleted file mode 100644 index 5f4e97bc1..000000000 --- a/lib/libc/arch/or1k/gen/__setjmp14.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: __setjmp14.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: __setjmp14.S,v 1.1 2014/09/03 19:34:25 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - l.sw JB_PC(r3), lr /* save return address */ - l.sw JB_LR(r3), lr /* save return address */ - l.sw JB_SP(r3), r1 /* save stack pointer */ - l.sw JB_FP(r3), r2 /* save frame pointer */ - l.sw JB_R10(r3), r10 /* save callee saved register */ - l.sw JB_R14(r3), r14 /* save callee saved register */ - l.sw JB_R16(r3), r16 /* save callee saved register */ - l.sw JB_R18(r3), r18 /* save callee saved register */ - l.sw JB_R20(r3), r20 /* save callee saved register */ - l.sw JB_R22(r3), r22 /* save callee saved register */ - l.sw JB_R24(r3), r24 /* save callee saved register */ - l.sw JB_R26(r3), r26 /* save callee saved register */ - l.sw JB_R28(r3), r28 /* save callee saved register */ - l.sw JB_R30(r3), r30 /* save callee saved register */ - l.addi r4, r0, 1 - l.sw JB_MAGIC(r3), r4 /* note we saved sigmask */ - l.addi r5, r3, JB_SIGMASK # &sigmask - l.xor r4, r4, r4 - l.addi r3, r0, SIG_BLOCK - _DOSYSCALL(__sigprocmask14) # assume no error XXX - l.xor r11, r11, r11 - l.jr lr - l.nop -END(__setjmp14) - -ENTRY(__longjmp14) - l.lwz lr, JB_LR(r3) /* get return address */ - l.lwz r1, JB_SP(r3) /* get stack pointer */ - l.lwz r2, JB_FP(r3) /* get frame pointer */ - l.lwz r10, JB_R10(r3) /* get callee saved register */ - l.lwz r14, JB_R14(r3) /* get callee saved register */ - l.lwz r16, JB_R16(r3) /* get callee saved register */ - l.lwz r18, JB_R18(r3) /* get callee saved register */ - l.lwz r20, JB_R20(r3) /* get callee saved register */ - l.lwz r22, JB_R22(r3) /* get callee saved register */ - l.lwz r24, JB_R24(r3) /* get callee saved register */ - l.lwz r26, JB_R26(r3) /* get callee saved register */ - l.lwz r28, JB_R28(r3) /* get callee saved register */ - l.lwz r30, JB_R30(r3) /* get callee saved register */ - l.ori r11, r4, 0 - l.xor r5, r5, r5 - l.addi r4, r3, JB_SIGMASK # &sigmask - l.addi r3, r0, SIG_SETMASK - _DOSYSCALL(__sigprocmask14) # assume no error XXX - l.addi r6, r0, 1 - l.sfeqi r11, 0 - l.cmov r11, r6, r11 - l.jr lr - l.nop -END(__longjmp14) diff --git a/lib/libc/arch/or1k/gen/__sigsetjmp14.S b/lib/libc/arch/or1k/gen/__sigsetjmp14.S deleted file mode 100644 index c0ebabc2e..000000000 --- a/lib/libc/arch/or1k/gen/__sigsetjmp14.S +++ /dev/null @@ -1,25 +0,0 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: __sigsetjmp14.S,v 1.1 2014/09/03 19:34:25 matt Exp $") -#endif - -ENTRY(__sigsetjmp14) - l.sfeqi r4, 0 - l.bf PLT(_C_LABEL(_setjmp)) - l.nop - l.j PLT(_C_LABEL(__setjmp14)) - l.nop -END(__sigsetjmp14) - -ENTRY(__siglongjmp14) - l.lwz r5, JB_MAGIC(r3) - l.sfeqi r5, 0 - l.bf PLT(_C_LABEL(_longjmp)) - l.nop - l.j PLT(_C_LABEL(__longjmp14)) - l.nop -END(__siglongjmp14) diff --git a/lib/libc/arch/or1k/gen/_lwp.c b/lib/libc/arch/or1k/gen/_lwp.c deleted file mode 100644 index d5d92fa5c..000000000 --- a/lib/libc/arch/or1k/gen/_lwp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Allen Briggs for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), void *arg, - void *tcb, caddr_t stack_base, size_t stack_size) -{ - uintptr_t sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - sp = (uintptr_t)stack_base + stack_size; - sp -= STACK_ALIGNBYTES + 1; - sp &= ~STACK_ALIGNBYTES; - - u->uc_mcontext.__gregs[_REG_RV] = (uintptr_t)arg; /* arg1 */ - u->uc_mcontext.__gregs[_REG_SP] = (uintptr_t)sp; /* stack */ - u->uc_mcontext.__gregs[_REG_LR] = (uintptr_t)_lwp_exit; /* LR */ - u->uc_mcontext.__gregs[_REG_PC] = (uintptr_t)start; /* PC */ - u->uc_mcontext.__gregs[_REG_TP] = - (uintptr_t)tcb + TLS_TP_OFFSET + sizeof(struct tls_tcb); -} diff --git a/lib/libc/arch/or1k/gen/_setjmp.S b/lib/libc/arch/or1k/gen/_setjmp.S deleted file mode 100644 index 9694862a0..000000000 --- a/lib/libc/arch/or1k/gen/_setjmp.S +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: _setjmp.S,v 1.1 2014/09/03 19:34:25 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - l.sw JB_MAGIC(r3), r0 /* indicate no sigmask */ - l.sw JB_PC(r3), lr /* save return address */ - l.sw JB_LR(r3), lr /* save return address */ - l.sw JB_SP(r3), r1 /* save stack pointer */ - l.sw JB_FP(r3), r2 /* save frame pointer */ - l.sw JB_R10(r3), r10 /* save callee saved register */ - l.sw JB_R14(r3), r14 /* save callee saved register */ - l.sw JB_R16(r3), r16 /* save callee saved register */ - l.sw JB_R18(r3), r18 /* save callee saved register */ - l.sw JB_R20(r3), r20 /* save callee saved register */ - l.sw JB_R22(r3), r22 /* save callee saved register */ - l.sw JB_R24(r3), r24 /* save callee saved register */ - l.sw JB_R26(r3), r26 /* save callee saved register */ - l.sw JB_R28(r3), r28 /* save callee saved register */ - l.sw JB_R30(r3), r30 /* save callee saved register */ - l.xor r11, r11, r11 /* indicate success */ - l.jr lr /* return */ - l.nop -END(_setjmp) - -ENTRY(_longjmp) - l.lwz lr, JB_LR(r3) /* get return address */ - l.lwz r1, JB_SP(r3) /* get stack pointer */ - l.lwz r2, JB_FP(r3) /* get frame pointer */ - l.lwz r10, JB_R10(r3) /* get callee saved register */ - l.lwz r14, JB_R14(r3) /* get callee saved register */ - l.lwz r16, JB_R16(r3) /* get callee saved register */ - l.lwz r18, JB_R18(r3) /* get callee saved register */ - l.lwz r20, JB_R20(r3) /* get callee saved register */ - l.lwz r22, JB_R22(r3) /* get callee saved register */ - l.lwz r24, JB_R24(r3) /* get callee saved register */ - l.lwz r26, JB_R26(r3) /* get callee saved register */ - l.lwz r28, JB_R28(r3) /* get callee saved register */ - l.lwz r30, JB_R30(r3) /* get callee saved register */ - l.ori r11, r0, 1 /* default return value */ - l.sfeqi r4, 0 /* test return value */ - l.cmov r11, r11, r4 /* use it if not 0 */ - l.jr lr /* return */ - l.nop -END(_longjmp) diff --git a/lib/libc/arch/or1k/gen/flt_rounds.c b/lib/libc/arch/or1k/gen/flt_rounds.c deleted file mode 100644 index 259581ec2..000000000 --- a/lib/libc/arch/or1k/gen/flt_rounds.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.2 2015/03/19 21:22:59 joerg Exp $ */ - -/* - * Copyright (c) 1996 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.2 2015/03/19 21:22:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -static const int rounding_map = - (1 << (FP_RN * 2)) /* round to nearest */ - | (0 << (FP_RZ * 2)) /* round to zero */ - | (2 << (FP_RP * 2)) /* round to positive infinity */ - | (3 << (FP_RM * 2)); /* round to negative infinity */ - -int -__flt_rounds(void) -{ - return (rounding_map >> (fpgetround() * 2)) & 3; -} diff --git a/lib/libc/arch/or1k/gen/fpgetmask.c b/lib/libc/arch/or1k/gen/fpgetmask.c deleted file mode 100644 index 45a66a39a..000000000 --- a/lib/libc/arch/or1k/gen/fpgetmask.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -#define MASKBITS (FPSCR_VE|FPSCR_OE|FPSCR_UE|FPSCR_ZE|FPSCR_XE) -#define MASKSHFT 3 - -fp_except -fpgetmask(void) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - return (((uint32_t)ud.u_fpscr & MASKBITS) >> MASKSHFT); -} diff --git a/lib/libc/arch/or1k/gen/fpgetround.c b/lib/libc/arch/or1k/gen/fpgetround.c deleted file mode 100644 index 3b2d26049..000000000 --- a/lib/libc/arch/or1k/gen/fpgetround.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -#define SPR_FPCSR 20 -#define FPCSR_RND __BITS(2,1) - -fp_rnd -fpgetround(void) -{ - uint32_t fpcsr; - - __asm volatile("l.mfspr %0,r0,%1" : "=r"(fpscr) : "n" (SPR_FPCSR)); - return __SHIFTOUT(fpcsr, FPCSR_RND); -} diff --git a/lib/libc/arch/or1k/gen/fpgetsticky.c b/lib/libc/arch/or1k/gen/fpgetsticky.c deleted file mode 100644 index df17a3c57..000000000 --- a/lib/libc/arch/or1k/gen/fpgetsticky.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -#define STICKYBITS (FPSCR_XX|FPSCR_ZX|FPSCR_UX|FPSCR_OX|FPSCR_VX) -#define STICKYSHFT 25 - -fp_except -fpgetsticky(void) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - return (((uint32_t)ud.u_fpscr & STICKYBITS) >> STICKYSHFT); -} diff --git a/lib/libc/arch/or1k/gen/fpsetmask.c b/lib/libc/arch/or1k/gen/fpsetmask.c deleted file mode 100644 index b5ac19177..000000000 --- a/lib/libc/arch/or1k/gen/fpsetmask.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -#define MASKBITS (FPSCR_XE|FPSCR_ZE|FPSCR_UE|FPSCR_OE|FPSCR_VE) -#define MASKSHFT 3 - -fp_except -fpsetmask(fp_except mask) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - fp_except old; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - old = ((uint32_t)ud.u_fpscr & MASKBITS) >> MASKSHFT; - ud.u_fpscr &= ~MASKBITS; - ud.u_fpscr |= ((uint32_t)mask << MASKSHFT) & MASKBITS; - __asm volatile("mtfsf 0xff,%0" :: "f"(ud.u_d)); - return (old); -} diff --git a/lib/libc/arch/or1k/gen/fpsetround.c b/lib/libc/arch/or1k/gen/fpsetround.c deleted file mode 100644 index 4105e1e1e..000000000 --- a/lib/libc/arch/or1k/gen/fpsetround.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -#define ROUNDBITS FPSCR_RN - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - fp_rnd old; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - old = (uint32_t)ud.u_fpscr & ROUNDBITS; - ud.u_fpscr &= ~ROUNDBITS; - ud.u_fpscr |= rnd_dir & ROUNDBITS; - __asm volatile("mtfsf 0xff,%0" :: "f"(ud.u_d)); - return (old); -} diff --git a/lib/libc/arch/or1k/gen/fpsetsticky.c b/lib/libc/arch/or1k/gen/fpsetsticky.c deleted file mode 100644 index 49119f4f0..000000000 --- a/lib/libc/arch/or1k/gen/fpsetsticky.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#define STICKYBITS (FPSCR_XX|FPSCR_ZX|FPSCR_UX|FPSCR_OX|FPSCR_VX) -#define INVBITS (FPSCR_VXCVI|FPSCR_VXSQRT|FPSCR_VXSOFT|FPSCR_VXVC|\ - FPSCR_VXIMZ|FPSCR_VXZDZ|FPSCR_VXIDI|FPSCR_VXISI|\ - FPSCR_VXSNAN) -#define STICKYSHFT 25 - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -fpsetsticky(fp_except mask) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - fp_except old; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - old = ((uint32_t)ud.u_fpscr & STICKYBITS) >> STICKYSHFT; - /* - * FPSCR_VX (aka FP_X_INV) is not a sticky bit but a summary of the - * all the FPSCR_VX* sticky bits. So when FP_X_INV is cleared then - * clear all of those bits, likewise when it's set, set them all. - */ - if ((mask & FP_X_INV) == 0) - ud.u_fpscr &= ~INVBITS; - else - ud.u_fpscr |= INVBITS; - ud.u_fpscr &= ~STICKYBITS; - ud.u_fpscr |= ((uint32_t)mask << STICKYSHFT) & STICKYBITS; - /* - * Make FPSCR_FX reflect the presence of a set sticky bit (or not). - */ - if (ud.u_fpscr & (STICKYBITS|INVBITS)) - ud.u_fpscr |= FPSCR_FX; - else - ud.u_fpscr &= ~FPSCR_FX; - /* - * Write back the fpscr. - */ - __asm volatile("mtfsf 0xff,%0" :: "f"(ud.u_d)); - return (old); -} diff --git a/lib/libc/arch/or1k/gen/makecontext.c b/lib/libc/arch/or1k/gen/makecontext.c deleted file mode 100644 index 561da3f91..000000000 --- a/lib/libc/arch/or1k/gen/makecontext.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#if __STDC__ -#include -#else -#include -#endif - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - int *sp; - int i; - va_list ap; - - /* LINTED uintptr_t is safe */ - sp = (int *) - ((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - /* LINTED uintptr_t is safe */ - sp -= 1 + (argc > 6 ? argc - 6: 0); /* Make room for call frame. */ - sp = (int *) ((uintptr_t)sp & ~0x3); /* Align on word boundary. */ - - /* - * Start executing at -- when completes, return to - * <_resumecontext>. - */ - gr[_REG_SP] = (uintptr_t)sp; - gr[_REG_LR] = (uintptr_t)_resumecontext; - gr[_REG_PC] = (uintptr_t)func; - - /* Wipe out stack frame backchain pointer. */ - *sp = 0; - - /* Construct argument list. */ - va_start(ap, argc); - /* Up to the first six arguments are passed in r3-r8. */ - for (i = 0; i < argc && i < 6; i++) - gr[_REG_R3 + i] = va_arg(ap, int); - /* Pass remaining arguments on the stack above the backchain/lr gap. */ - for (sp += 2; i < argc; i++) - *sp++ = va_arg(ap, int); - va_end(ap); -} diff --git a/lib/libc/arch/or1k/gen/nanf.c b/lib/libc/arch/or1k/gen/nanf.c deleted file mode 100644 index 485ded44c..000000000 --- a/lib/libc/arch/or1k/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xc0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/or1k/gen/resumecontext.c b/lib/libc/arch/or1k/gen/resumecontext.c deleted file mode 100644 index 3c4ea5df3..000000000 --- a/lib/libc/arch/or1k/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.1 2014/09/03 19:34:25 matt Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/or1k/gen/swapcontext.S b/lib/libc/arch/or1k/gen/swapcontext.S deleted file mode 100644 index adbdd486b..000000000 --- a/lib/libc/arch/or1k/gen/swapcontext.S +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.1 2014/09/03 19:34:25 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -__RCSID("$NetBSD: swapcontext.S,v 1.1 2014/09/03 19:34:25 matt Exp $") - -#define CALLFRAME_LR (-1*4) -#define CALLFRAME_UCP (-2*4) -#define CALLFRAME_OUCP (-3*4) -#define CALLFRAME_GP (-4*4) -#define CALLFRAME_SP (-5*4) -#define CALLFRAME_LEN (-CALLFRAME_SP) - -ENTRY(swapcontext) - l.sw CALLFRAME_LR(r1),lr # save link register - l.sw CALLFRAME_OUCP(r1),r3 # save oucp - l.sw CALLFRAME_UCP(r1),r4 # save ucp - l.sw CALLFRAME_SP(r1),r1 # set up stack chain -#ifdef __PIC__ - l.sw CALLFRAME_GP(r1),r16 # save r16 - PIC_GOTSETUP(r16) # setup got pointer -#endif - l.addi r1,r1,-CALLFRAME_LEN # adjust stack - l.jal PLT(_C_LABEL(_getcontext)) # getcontext(oucp) - l.nop # -- delay slot -- - l.sfeqi r11,0 # error? - l.bnf 1f # yes, cleanup - l.nop # -- delay slot -- - l.addi r5,r1,CALLFRAME_LEN # adjust stack - l.lwz r4,CALLFRAME_OUCP(r5) # load oucp for adjustment - l.sw UC_GREGS_PC(r4),lr # pc <- lr - l.sw UC_GREGS_SP(r4),r1 # adjust sp - l.lwz r3,CALLFRAME_UCP(r5) # load ucp - # can't do a tail call due to needing r16 for PLT - l.jal PLT(_C_LABEL(setcontext)) # setcontext(ucp) - l.nop # -- delay slot -- -1: - l.addi r1,r1,CALLFRAME_LEN # restore stack -#ifdef __PIC__ - l.lwz r16,CALLFRAME_GP(r1) # restore r16 -#endif - l.lwz lr,CALLFRAME_LR(r1) # refetch lr - l.jr lr # simply return - l.nop # -- delay slot -- -END(swapcontext) diff --git a/lib/libc/arch/or1k/genassym.cf b/lib/libc/arch/or1k/genassym.cf deleted file mode 100644 index 4f3aa02bc..000000000 --- a/lib/libc/arch/or1k/genassym.cf +++ /dev/null @@ -1,64 +0,0 @@ -# $NetBSD: genassym.cf,v 1.1 2014/09/03 19:34:25 matt Exp $ - -# -# Copyright (c) 2001 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include -include -include - -include -include - -define UC_GREGS_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_SP]) -define UC_GREGS_RV offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RV]) -define UC_GREGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC]) - -define SIG_BLOCK SIG_BLOCK -define SIG_SETMASK SIG_SETMASK - -define JBLEN 32 * sizeof(_BSD_JBSLOT_T_) -define JB_MAGIC 0 * sizeof(_BSD_JBSLOT_T_) -define JB_SP 1 * sizeof(_BSD_JBSLOT_T_) -define JB_FP 2 * sizeof(_BSD_JBSLOT_T_) -define JB_LR 3 * sizeof(_BSD_JBSLOT_T_) -define JB_R10 4 * sizeof(_BSD_JBSLOT_T_) -define JB_R14 5 * sizeof(_BSD_JBSLOT_T_) -define JB_R16 6 * sizeof(_BSD_JBSLOT_T_) -define JB_R18 7 * sizeof(_BSD_JBSLOT_T_) -define JB_R20 8 * sizeof(_BSD_JBSLOT_T_) -define JB_R22 9 * sizeof(_BSD_JBSLOT_T_) -define JB_R24 10 * sizeof(_BSD_JBSLOT_T_) -define JB_R26 11 * sizeof(_BSD_JBSLOT_T_) -define JB_R28 12 * sizeof(_BSD_JBSLOT_T_) -define JB_R30 13 * sizeof(_BSD_JBSLOT_T_) -define JB_PC 14 * sizeof(_BSD_JBSLOT_T_) -define JB_SIGMASK 15 * sizeof(_BSD_JBSLOT_T_) diff --git a/lib/libc/arch/or1k/net/Makefile.inc b/lib/libc/arch/or1k/net/Makefile.inc deleted file mode 100644 index 686b2e444..000000000 --- a/lib/libc/arch/or1k/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/03 19:34:26 matt Exp $ - -SRCS+= htonl.c htons.c ntohl.c ntohs.c diff --git a/lib/libc/arch/or1k/softfloat/milieu.h b/lib/libc/arch/or1k/softfloat/milieu.h deleted file mode 100644 index 48cc368d5..000000000 --- a/lib/libc/arch/or1k/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "or1k-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/or1k/softfloat/or1k-gcc.h b/lib/libc/arch/or1k/softfloat/or1k-gcc.h deleted file mode 100644 index 7e034edcb..000000000 --- a/lib/libc/arch/or1k/softfloat/or1k-gcc.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: or1k-gcc.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#include -#if _BYTE_ORDER == _BIG_ENDIAN -#define BIGENDIAN -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef int uint8; -typedef int int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) diff --git a/lib/libc/arch/or1k/softfloat/softfloat.h b/lib/libc/arch/or1k/softfloat/softfloat.h deleted file mode 100644 index 7258eabfc..000000000 --- a/lib/libc/arch/or1k/softfloat/softfloat.h +++ /dev/null @@ -1,305 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -/* #define FLOAT128 */ - -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int8 float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -unsigned int float32_to_uint32_round_to_zero( float32 ); -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -flag float32_eq( float32, float32 ); -flag float32_le( float32, float32 ); -flag float32_lt( float32, float32 ); -flag float32_eq_signaling( float32, float32 ); -flag float32_le_quiet( float32, float32 ); -flag float32_lt_quiet( float32, float32 ); -#ifndef SOFTFLOAT_FOR_GCC -flag float32_is_signaling_nan( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -unsigned int float64_to_uint32_round_to_zero( float64 ); -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -flag float64_eq( float64, float64 ); -flag float64_le( float64, float64 ); -flag float64_lt( float64, float64 ); -flag float64_eq_signaling( float64, float64 ); -flag float64_le_quiet( float64, float64 ); -flag float64_lt_quiet( float64, float64 ); -#ifndef SOFTFLOAT_FOR_GCC -flag float64_is_signaling_nan( float64 ); -#endif - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -flag floatx80_eq( floatx80, floatx80 ); -flag floatx80_le( floatx80, floatx80 ); -flag floatx80_lt( floatx80, floatx80 ); -flag floatx80_eq_signaling( floatx80, floatx80 ); -flag floatx80_le_quiet( floatx80, floatx80 ); -flag floatx80_lt_quiet( floatx80, floatx80 ); -flag floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -flag float128_eq( float128, float128 ); -flag float128_le( float128, float128 ); -flag float128_lt( float128, float128 ); -flag float128_eq_signaling( float128, float128 ); -flag float128_le_quiet( float128, float128 ); -flag float128_lt_quiet( float128, float128 ); -flag float128_is_signaling_nan( float128 ); - -#endif diff --git a/lib/libc/arch/or1k/stdlib/Makefile.inc b/lib/libc/arch/or1k/stdlib/Makefile.inc deleted file mode 100644 index 809ac4d83..000000000 --- a/lib/libc/arch/or1k/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/03 19:34:26 matt Exp $ diff --git a/lib/libc/arch/or1k/string/Makefile.inc b/lib/libc/arch/or1k/string/Makefile.inc deleted file mode 100644 index 37edc5888..000000000 --- a/lib/libc/arch/or1k/string/Makefile.inc +++ /dev/null @@ -1,24 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/03 19:34:26 matt Exp $ - -SRCS+= bzero.S clz.S ctz.S ffs.S strlen.S memset.S - -memcpy.o: memcpy.c -memcpy.po: memcpy.c -memcpy.pico: memcpy.c - -# disable the asm versions of these because they break the explora. -# the special rules here are to override the suffix rules which seem -# to prefer .S files over .c -.if ${MACHINE} == "evbppc" -bcopy.o: bcopy.c -bcopy.po: bcopy.c -bcopy.pico: bcopy.c -memcmp.o: memcmp.c -memcmp.po: memcmp.c -memcmp.pico: memcmp.c -memmove.o: memmove.c -memmove.po: memmove.c -memmove.pico: memmove.c -.else -SRCS+= memcmp.S bcopy.S memmove.S -.endif diff --git a/lib/libc/arch/or1k/sys/__clone.S b/lib/libc/arch/or1k/sys/__clone.S deleted file mode 100644 index 4b910fd7e..000000000 --- a/lib/libc/arch/or1k/sys/__clone.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: __clone.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/*- - * Copyright (c) 2001 Tsubai Masanari. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __clone.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - /* - * Sanity checks: func and stack may not be NULL. - */ - l.sfeqi r3,0 - l.bf 2f - l.sfeqi r4,0 - l.bf 2f - - l.or r7,r3,r0 /* Save fn in r7. */ - l.or r3,r5,r0 - _DOSYSCALL(__clone) /* (flags, stack) */ - l.bf _C_LABEL(__cerror) /* error... */ - l.nop - - l.sfeqi r11,0 - l.bf 1f /* We're the parent, just return. */ - l.nop - l.jr lr - l.nop - -1: l.or r3,r6,r0 /* arg */ - l.jalr r7 /* Call the clone's entry point. */ - l.nop - -#ifdef __PIC__ - // We don't need to save r9 or r16 since we aren't ever coming back - PIC_GOTSETUP(r16) -#endif - l.jal plt(_C_LABEL(_exit)) - l.nop - -2: - l.addi r11,r0,EINVAL - l.j _C_LABEL(__cerror) - l.nop -END(__clone) diff --git a/lib/libc/arch/or1k/sys/__sigaction14_sigtramp.c b/lib/libc/arch/or1k/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 33217d6d3..000000000 --- a/lib/libc/arch/or1k/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.1 2014/09/03 19:34:26 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) -#ifdef __LIBC12_SOURCE__ -extern const int __sigtramp_sigcontext_1[] - __weak_reference(__sigtramp_sigcontext_1); -#endif - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specificed or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/or1k/sys/__sigtramp2.S b/lib/libc/arch/or1k/sys/__sigtramp2.S deleted file mode 100644 index 5534b87b3..000000000 --- a/lib/libc/arch/or1k/sys/__sigtramp2.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigtramp2.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -/* - * On entry to user space, stack and registers look like: - * - * r3 signal number - * r4 pointer to siginfo structure - * r5 pointer to ucontext structure - * r14 pointer to ucontext structure - * lr address of this trampoline - * - */ -ENTRY(__sigtramp_siginfo_2) - l.ori r3,r14,0 /* restore ucontext pointer */ - _DOSYSCALL(setcontext) /* restore machine state */ - _DOSYSCALL(exit) /* or exit with errno if failed */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/or1k/sys/__syscall.S b/lib/libc/arch/or1k/sys/__syscall.S deleted file mode 100644 index ebefb6b98..000000000 --- a/lib/libc/arch/or1k/sys/__syscall.S +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include - -ENTRY(__syscall) - l.or r13,r3,r0 /* syscall number */ - l.or r3,r4,r0 - l.or r4,r5,r0 - l.or r5,r6,r0 - l.or r6,r7,r0 - l.or r7,r8,r0 - // at most 5 arguments can be passed via registers so the others - // must be on the stack. - l.lwz r8,0(r1) - l.lwz r11,4(r1) /* use return value regs for last 2 */ - l.lwz r12,8(r1) /* use return value regs for last 2 */ - l.sys 0 - l.bf _C_LABEL(__cerror) - l.nop - l.jr lr - l.nop -END(__syscall) - -STRONG_ALIAS(syscall, __syscall) diff --git a/lib/libc/arch/or1k/sys/__vfork14.S b/lib/libc/arch/or1k/sys/__vfork14.S deleted file mode 100644 index 7f24dc1cb..000000000 --- a/lib/libc/arch/or1k/sys/__vfork14.S +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/* - * pid = vfork(); - * - * r12 == 0 in parent process, 1 in child process. - * r11 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -SYSCALL(__vfork14) - l.addi r12,r12,-1 # from 1 to 0 in child, 0 to -1 in parent - l.and r11,r11,r12 # return 0 in child, pid in parent - l.jr lr - l.nop -END(__vfork14) diff --git a/lib/libc/arch/or1k/sys/brk.S b/lib/libc/arch/or1k/sys/brk.S deleted file mode 100644 index a7007b57f..000000000 --- a/lib/libc/arch/or1k/sys/brk.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: brk.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: brk.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - - .hidden _C_LABEL(__curbrk) - .hidden _C_LABEL(__minbrk) - .globl _C_LABEL(__curbrk) - .globl _C_LABEL(__minbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - .data - .p2align 2 -_C_LABEL(__minbrk): - .long _C_LABEL(_end) -_C_LABEL(__curbrk): - .long _C_LABEL(_end) - - .text -ENTRY(_brk) -#ifdef __PIC__ - l.or r8,r9,r0 - PIC_GOTSETUP(r7) - l.or r9,r8,r0 - l.movhi r6,gotoffhi(_C_LABEL(__minbrk)) - l.ori r6,r6,gotofflo(_C_LABEL(__minbrk)) - l.add r6,r6,r7 -#else - l.movhi r6,hi(_C_LABEL(__minbrk)) - l.ori r6,r6,lo(_C_LABEL(__minbrk)) -#endif - l.lwz r5,0(r6) # r5 = __minbrk - l.sfgts r5,r3 # if (__minbrk <= r3) - l.cmov r5,r5,r3 # choose larger - l.or r3,r5,r0 # new break value - _DOSYSCALL(break) # assume, that r5 is kept - l.bf _C_LABEL(__cerror) - l.nop - l.sw __SIZEOF_POINTER__(r6),r5 - l.xor r11, r11, r11 # return 0 - l.jr lr # return 0 - l.nop -END(_brk) diff --git a/lib/libc/arch/or1k/sys/cerror.S b/lib/libc/arch/or1k/sys/cerror.S deleted file mode 100644 index 7f91a2023..000000000 --- a/lib/libc/arch/or1k/sys/cerror.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: cerror.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: cerror.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifndef _REENTRANT - .globl _C_LABEL(errno) -#endif -#ifdef __PIC__ - .protected _C_LABEL(__cerror) -#endif - -ENTRY(__cerror) -#ifdef _REENTRANT - l.sw -4(r1),r3 - l.sw -8(r1),lr - l.sw -16(r1),r1 - l.addi r1,r1,-16 -#ifdef __PIC__ - l.sw -12(r1),r16 - PIC_GOTSETUP(r16) -#endif - l.jal PLT(_C_LABEL(__errno)) # needs got in r16 - l.nop - l.addi r1,r1,16 -#ifdef __PIC__ - l.lwz r16,-12(r1) -#endif - l.lwz lr,-8(r1) - l.lwz r3,-4(r1) -#else -#ifdef __PIC__ - l.or r8,r9,r0 - PIC_GOTSETUP(r4) - l.lwz r11,got(_C_LABEL(errno))(r4) - l.or r9,r8,r0 -#else - l.movi r11,hi(_C_LABEL(errno)) - l.ori r11,lo(_C_LABEL(errno)) -#endif /* __PIC__ */ -#endif /* _REENTRANT */ - l.sw 0(r11),r3 - l.addi r11,r0,-1 - l.addi r12,r0,-1 - l.jr lr - l.nop -END(__cerror) diff --git a/lib/libc/arch/or1k/sys/exect.S b/lib/libc/arch/or1k/sys/exect.S deleted file mode 100644 index 218bbec8f..000000000 --- a/lib/libc/arch/or1k/sys/exect.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: exect.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include "SYS.h" - -PSEUDO(exect,execve) diff --git a/lib/libc/arch/or1k/sys/fork.S b/lib/libc/arch/or1k/sys/fork.S deleted file mode 100644 index 3ba300e40..000000000 --- a/lib/libc/arch/or1k/sys/fork.S +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: fork.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/* - * pid = fork(); - * - * r12 == 0 in parent process, 1 in child process. - * r11 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -_SYSCALL(__fork,fork) - l.addi r12,r12,-1 # from 1 to 0 in child, 0 to -1 in parent - l.and r11,r11,r12 # return 0 in child, pid in parent - l.jr lr - l.nop -END(__fork) diff --git a/lib/libc/arch/or1k/sys/getcontext.S b/lib/libc/arch/or1k/sys/getcontext.S deleted file mode 100644 index 821431adc..000000000 --- a/lib/libc/arch/or1k/sys/getcontext.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getcontext.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -ENTRY(_getcontext) - _DOSYSCALL(getcontext) - l.bf _C_LABEL(__cerror) - l.nop - l.sw UC_GREGS_PC(r3),r9 # saved pc <- lr - l.sw UC_GREGS_RV(r3),r11 # arrange for return value 0 - l.jr lr - l.nop -END(_getcontext) diff --git a/lib/libc/arch/or1k/sys/pipe.S b/lib/libc/arch/or1k/sys/pipe.S deleted file mode 100644 index b6eb7988e..000000000 --- a/lib/libc/arch/or1k/sys/pipe.S +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: pipe.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pipe.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe) - l.or r5,r3,r0 # save pointer - _DOSYSCALL(pipe) # assume, that r5 is kept - l.bf _C_LABEL(__cerror) - l.nop - l.sw 0(r5),r11 # success, store fds - l.sw 4(r5),r12 - l.xor r11,r11,r11 - l.jr lr # and return 0 - l.nop -END(_pipe) diff --git a/lib/libc/arch/or1k/sys/ptrace.S b/lib/libc/arch/or1k/sys/ptrace.S deleted file mode 100644 index 56da80edc..000000000 --- a/lib/libc/arch/or1k/sys/ptrace.S +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ptrace.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#define XCALLFRAME_LR (-1*4) -#define XCALLFRAME_DATA (-2*4) -#define XCALLFRAME_ADDR (-3*4) -#define XCALLFRAME_PID (-4*4) -#define XCALLFRAME_REQUEST (-5*4) -#define XCALLFRAME_GP (-6*4) -#define XCALLFRAME_SP (-7*4) -#define XCALLFRAMELEN (-XCALLFRAME_SP) - -ENTRY(ptrace) -#ifdef _REENTRANT - l.sw XCALLFRAME_LR(r1),lr - l.sw XCALLFRAME_REQUEST(r1),r3 - l.sw XCALLFRAME_PID(r1),r4 - l.sw XCALLFRAME_ADDR(r1),r5 - l.sw XCALLFRAME_DATA(r1),r6 - -#ifdef __PIC__ - l.sw XCALLFRAME_GP(r1),r16 - PIC_GOTSETUP(r16) -#endif - - l.addi r1,r1,-XCALLFRAMELEN - l.jal PLT(_C_LABEL(__errno)) - l.nop - l.sw 0(r11),r0 - l.addi r1,r1,XCALLFRAMELEN - -#ifdef __PIC__ - l.lwz r16,XCALLFRAME_GP(r1) -#endif - - l.lwz r6,XCALLFRAME_DATA(r1) - l.lwz r4,XCALLFRAME_PID(r1) - l.lwz r5,XCALLFRAME_ADDR(r1) - l.lwz r3,XCALLFRAME_REQUEST(r1) - l.lwz lr,XCALLFRAME_LR(r1) -#else -#ifdef __PIC__ - l.or r8,r9,r0 - PIC_GOTSETUP(r7) - lwz r7,_C_LABEL(errno)@got(r7) - l.or r9,r8,r0 -#else - l.movhi r7,hi(_C_LABEL(errno)) - l.ori r7,r7,lo(_C_LABEL(errno)) -#endif /* __PIC__ */ -#endif /* _REENTRANT */ - l.sw 0(r7),r0 - _DOSYSCALL(ptrace) - l.bf _C_LABEL(__cerror) - l.nop - l.jr lr - l.nop -END(ptrace) diff --git a/lib/libc/arch/or1k/sys/sbrk.S b/lib/libc/arch/or1k/sys/sbrk.S deleted file mode 100644 index 547d530de..000000000 --- a/lib/libc/arch/or1k/sys/sbrk.S +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sbrk.S,v 1.1 2014/09/03 19:34:26 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - - .hidden _C_LABEL(__curbrk) - .globl _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - -ENTRY(_sbrk) -#ifdef __PIC__ - l.or r8,r9,r0 - PIC_GOTSETUP(r6) - l.or r9,r8,r0 - l.movhi r5,gotoffhi(_C_LABEL(__curbrk)) - l.ori r5,r5,gotofflo(_C_LABEL(__curbrk)) - l.add r5,r5,r6 -#else - l.movhi r5,hi(_C_LABEL(__curbrk)) - l.ori r5,r5,lo(_C_LABEL(__curbrk)) # r5 = old break; -#endif - l.lwz r6,0(r5) # r6 = old break, r5 = &curbrk - l.add r3,r3,r6 - _DOSYSCALL(break) # break(new_break) - l.bf _C_LABEL(__cerror) - l.nop - l.sw 0(r5),r3 # record new break - l.or r11,r6,r0 # set return value - l.jr lr - l.nop -END(_sbrk) diff --git a/lib/libc/arch/or1k/sys/shmat.S b/lib/libc/arch/or1k/sys/shmat.S deleted file mode 100644 index 1c381168e..000000000 --- a/lib/libc/arch/or1k/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/or1k/sys/syscall.S b/lib/libc/arch/or1k/sys/syscall.S deleted file mode 100644 index a847f1c2b..000000000 --- a/lib/libc/arch/or1k/sys/syscall.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: syscall.S,v 1.1 2014/09/03 19:34:26 matt Exp $ */ - -/* aliased to __syscall */ diff --git a/lib/libc/arch/or1k/syscallargs.awk b/lib/libc/arch/or1k/syscallargs.awk deleted file mode 100644 index 5c7c64f14..000000000 --- a/lib/libc/arch/or1k/syscallargs.awk +++ /dev/null @@ -1,56 +0,0 @@ -# $NetBSD: syscallargs.awk,v 1.1 2014/09/05 18:09:37 matt Exp $ -# -# Copyright (c) 2014 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas of 3am Software Foundry. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. - -BEGIN { -} - -/#define.SYS_MAXSYS.*/ { next; } - -/#define.SYS_.*/ { - x = substr($2, 5); - syscall[x] = "0"; -} - -/^check_syscall_args/ { - l = length() - 20; - x = substr($0, 20, l); - y = gensub("sys_", "", 1, x); - syscall[y] = sprintf("sizeof(struct %s_args) / sizeof(register_t)", x); -} - -END { - print "include " - print "include " - print "include " - print "include " - print; - for (i in syscall) { - printf "define NSYSARGS_%s %s\n", i, syscall[i]; - } -} diff --git a/lib/libc/arch/powerpc/Makefile.inc b/lib/libc/arch/powerpc/Makefile.inc deleted file mode 100644 index bbe362e00..000000000 --- a/lib/libc/arch/powerpc/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.14 2013/08/30 21:28:59 matt Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S -SRCS+= powerpc_initfini.c - -CPPFLAGS+= -I. - -.if defined(MKSOFTFLOAT) && (${MKSOFTFLOAT} != "no") -.include -.endif diff --git a/lib/libc/arch/powerpc/SYS.h b/lib/libc/arch/powerpc/SYS.h deleted file mode 100644 index d35a74daf..000000000 --- a/lib/libc/arch/powerpc/SYS.h +++ /dev/null @@ -1,40 +0,0 @@ -/* $NetBSD: SYS.h,v 1.13 2014/08/23 02:24:22 matt Exp $ */ - -#include -#include - -#define BRANCH_TO_CERROR() b _C_LABEL(__cerror) - -#define _DOSYSCALL(x) li %r0,(SYS_ ## x) ;\ - sc - -#define _SYSCALL_NOERROR(x,y) .text ;\ - .p2align 2 ;\ - ENTRY(x) ;\ - _DOSYSCALL(y) - -#define _SYSCALL(x,y) .text ;\ - .p2align 2 ;\ - 2: BRANCH_TO_CERROR() ;\ - _SYSCALL_NOERROR(x,y) ;\ - bso 2b - -#define SYSCALL_NOERROR(x) _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) _SYSCALL_NOERROR(x,y) ;\ - blr ;\ - END(x) - -#define PSEUDO(x,y) _SYSCALL_NOERROR(x,y) ;\ - bnslr ;\ - BRANCH_TO_CERROR() ;\ - END(x) - -#define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) PSEUDO(x,x) - -#define WSYSCALL(weak,strong) WEAK_ALIAS(weak,strong) ;\ - PSEUDO(strong,weak) diff --git a/lib/libc/arch/powerpc/gdtoa/Makefile.inc b/lib/libc/arch/powerpc/gdtoa/Makefile.inc deleted file mode 100644 index 1d786e010..000000000 --- a/lib/libc/arch/powerpc/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/powerpc/gdtoa/arith.h b/lib/libc/arch/powerpc/gdtoa/arith.h deleted file mode 100644 index 4674f629c..000000000 --- a/lib/libc/arch/powerpc/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_BIG_ENDIAN diff --git a/lib/libc/arch/powerpc/gdtoa/gd_qnan.h b/lib/libc/arch/powerpc/gdtoa/gd_qnan.h deleted file mode 100644 index 75f636b54..000000000 --- a/lib/libc/arch/powerpc/gdtoa/gd_qnan.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 diff --git a/lib/libc/arch/powerpc/gen/Makefile.inc b/lib/libc/arch/powerpc/gen/Makefile.inc deleted file mode 100644 index befa59533..000000000 --- a/lib/libc/arch/powerpc/gen/Makefile.inc +++ /dev/null @@ -1,32 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.26 2014/01/28 13:47:04 macallan Exp $ - -SRCS+= __setjmp14.S __sigsetjmp14.S _setjmp.S -SRCS+= bswap16.c bswap32.c bswap64.c -SRCS+= flt_rounds.c -SRCS+= syncicache.c -SRCS+= _lwp.c makecontext.c resumecontext.c swapcontext.S - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c - -.if (${MKSOFTFLOAT} == "no") -SRCS+= fpgetround.c fpsetround.c fpgetmask.c fpsetmask.c -SRCS+= fpgetsticky.c fpsetsticky.c -SRCS+= fabs_ieee754.S -.else -SRCS+= fabs_ieee754.c -.endif - -CPPFLAGS._lwp.c += -D_LIBC_SOURCE - -LSRCS.powerpc.gen=Lint_swapcontext.c -LSRCS+= ${LSRCS.powerpc.gen} -DPSRCS+= ${LSRCS.powerpc.gen} -CLEANFILES+= ${LSRCS.powerpc.gen} diff --git a/lib/libc/arch/powerpc/gen/__setjmp14.S b/lib/libc/arch/powerpc/gen/__setjmp14.S deleted file mode 100644 index f8cf9556d..000000000 --- a/lib/libc/arch/powerpc/gen/__setjmp14.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: __setjmp14.S,v 1.5 2011/01/15 07:31:12 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: __setjmp14.S,v 1.5 2011/01/15 07:31:12 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - mr %r6,%r3 - li %r3,SIG_BLOCK - li %r4,0 - addi %r5,%r6,4*(1+24) # &sigmask - _DOSYSCALL(__sigprocmask14) # assume no error XXX - mflr %r11 - mfcr %r12 - mr %r10,%r1 - mr %r9,%r2 - stmw %r8,4(%r6) # save r8-r31 - li %r3,0 - blr -END(__setjmp14) - -ENTRY(__longjmp14) - lmw %r8,4(%r3) # load r8-r31 - mr %r6,%r4 - mtlr %r11 - mtcr %r12 - mr %r2,%r9 - mr %r1,%r10 - addi %r4,%r3,4*(1+24) # &sigmask - li %r3,SIG_SETMASK - li %r5,0 - _DOSYSCALL(__sigprocmask14) # assume no error XXX - or. %r3,%r6,%r6 - bnelr - li %r3,1 - blr -END(__longjmp14) diff --git a/lib/libc/arch/powerpc/gen/__sigsetjmp14.S b/lib/libc/arch/powerpc/gen/__sigsetjmp14.S deleted file mode 100644 index e026982c1..000000000 --- a/lib/libc/arch/powerpc/gen/__sigsetjmp14.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.5 2011/01/15 07:31:12 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: __sigsetjmp14.S,v 1.5 2011/01/15 07:31:12 matt Exp $") -#endif - -ENTRY(__sigsetjmp14) - mr %r6,%r3 - or. %r7,%r4,%r4 - beq 1f - li %r3,SIG_BLOCK - li %r4,0 - addi %r5,%r6,4*(1+24) # &sigmask - _DOSYSCALL(__sigprocmask14) # assume no error XXX -1: - mflr %r11 - mfcr %r12 - mr %r10,%r1 - mr %r9,%r2 - stmw %r7,0(%r6) # save r7-r31 - li %r3,0 - blr -END(__sigsetjmp14) - -ENTRY(__siglongjmp14) - lmw %r7,0(%r3) # load r7-r31 - mr %r6,%r4 - mtlr %r11 - mtcr %r12 - mr %r2,%r9 - mr %r1,%r10 - or. %r7,%r7,%r7 - beq 1f - addi %r4,%r3,4*(1+24) # &sigmask - li %r3,SIG_SETMASK - li %r5,0 - _DOSYSCALL(__sigprocmask14) # assume no error XXX -1: - or. %r3,%r6,%r6 - bnelr - li %r3,1 - blr -END(__siglongjmp14) diff --git a/lib/libc/arch/powerpc/gen/_lwp.c b/lib/libc/arch/powerpc/gen/_lwp.c deleted file mode 100644 index f2e914e4e..000000000 --- a/lib/libc/arch/powerpc/gen/_lwp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.7 2012/03/22 05:36:50 matt Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Allen Briggs for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.7 2012/03/22 05:36:50 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), void *arg, - void *tcb, caddr_t stack_base, size_t stack_size) -{ - uintptr_t sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - sp = (uintptr_t)stack_base + stack_size; - sp -= STACK_ALIGNBYTES + 1; - sp &= ~STACK_ALIGNBYTES; - - u->uc_mcontext.__gregs[3] = (uintptr_t) arg; /* arg1 */ - u->uc_mcontext.__gregs[1] = sp; /* stack */ - u->uc_mcontext.__gregs[33] = (uintptr_t) _lwp_exit; /* LR */ - u->uc_mcontext.__gregs[34] = (uintptr_t) start; /* PC */ - u->uc_mcontext.__gregs[_REG_R2] = - (uintptr_t)tcb + TLS_TP_OFFSET + sizeof(struct tls_tcb); -} diff --git a/lib/libc/arch/powerpc/gen/_setjmp.S b/lib/libc/arch/powerpc/gen/_setjmp.S deleted file mode 100644 index 44f2a5733..000000000 --- a/lib/libc/arch/powerpc/gen/_setjmp.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */ - -#include - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: _setjmp.S,v 1.3 2011/01/15 07:31:12 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - mflr %r11 /* save return address */ - mfcr %r12 /* save condition register */ - mr %r10,%r1 /* save stack pointer */ - mr %r9,%r2 /* save GPR2 (not needed) */ - stmw %r9,8(%r3) /* save r9..r31 */ - li %r3,0 /* indicate success */ - blr /* return */ -END(_setjmp) - -ENTRY(_longjmp) - lmw %r9,8(%r3) /* save r9..r31 */ - mtlr %r11 /* restore LR */ - mtcr %r12 /* restore CR */ - mr %r2,%r9 /* restore GPR2 (not needed) */ - mr %r1,%r10 /* restore stack */ - or. %r3,%r4,%r4 /* get return value */ - bnelr /* return if not 0 */ - li %r3,1 /* what's the point? */ - blr /* return */ -END(_longjmp) diff --git a/lib/libc/arch/powerpc/gen/fabs_ieee754.S b/lib/libc/arch/powerpc/gen/fabs_ieee754.S deleted file mode 100644 index d079c150d..000000000 --- a/lib/libc/arch/powerpc/gen/fabs_ieee754.S +++ /dev/null @@ -1,12 +0,0 @@ -/* $NetBSD: fabs_ieee754.S,v 1.1 2014/01/28 13:47:04 macallan Exp $ */ - -#include - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: fabs_ieee754.S,v 1.1 2014/01/28 13:47:04 macallan Exp $") -#endif - -ENTRY(fabs) - fabs %f1,%f1 - blr -END(fabs) diff --git a/lib/libc/arch/powerpc/gen/flt_rounds.c b/lib/libc/arch/powerpc/gen/flt_rounds.c deleted file mode 100644 index 430649509..000000000 --- a/lib/libc/arch/powerpc/gen/flt_rounds.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.12 2015/03/19 21:22:59 joerg Exp $ */ - -/* - * Copyright (c) 1996 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.12 2015/03/19 21:22:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 0, /* round to zero */ - 2, /* round to positive infinity */ - 3 /* round to negative infinity */ -}; - -int -__flt_rounds(void) -{ -#ifdef _SOFT_FLOAT - return map[fpgetround()]; -#else - union { - double u_d; - uint64_t u_fpscr; - } ud; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - return map[((uint32_t)ud.u_fpscr & FPSCR_RN)]; -#endif -} diff --git a/lib/libc/arch/powerpc/gen/fpgetmask.c b/lib/libc/arch/powerpc/gen/fpgetmask.c deleted file mode 100644 index 6bc3f91cf..000000000 --- a/lib/libc/arch/powerpc/gen/fpgetmask.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.10 2011/07/10 21:18:47 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.10 2011/07/10 21:18:47 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -#define MASKBITS (FPSCR_VE|FPSCR_OE|FPSCR_UE|FPSCR_ZE|FPSCR_XE) -#define MASKSHFT 3 - -fp_except -fpgetmask(void) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - return (((uint32_t)ud.u_fpscr & MASKBITS) >> MASKSHFT); -} diff --git a/lib/libc/arch/powerpc/gen/fpgetround.c b/lib/libc/arch/powerpc/gen/fpgetround.c deleted file mode 100644 index 58cfe030f..000000000 --- a/lib/libc/arch/powerpc/gen/fpgetround.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.10 2011/07/10 21:18:47 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.10 2011/07/10 21:18:47 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -#define ROUNDBITS FPSCR_RN -#define ROUNDSHFT 0 - -fp_rnd -fpgetround(void) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - return (((uint32_t)ud.u_fpscr & ROUNDBITS) >> ROUNDSHFT); -} diff --git a/lib/libc/arch/powerpc/gen/fpgetsticky.c b/lib/libc/arch/powerpc/gen/fpgetsticky.c deleted file mode 100644 index 079acc0c0..000000000 --- a/lib/libc/arch/powerpc/gen/fpgetsticky.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.10 2011/07/10 21:18:47 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.10 2011/07/10 21:18:47 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -#define STICKYBITS (FPSCR_XX|FPSCR_ZX|FPSCR_UX|FPSCR_OX|FPSCR_VX) -#define STICKYSHFT 25 - -fp_except -fpgetsticky(void) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - return (((uint32_t)ud.u_fpscr & STICKYBITS) >> STICKYSHFT); -} diff --git a/lib/libc/arch/powerpc/gen/fpsetmask.c b/lib/libc/arch/powerpc/gen/fpsetmask.c deleted file mode 100644 index ef298c591..000000000 --- a/lib/libc/arch/powerpc/gen/fpsetmask.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.10 2011/07/10 21:18:47 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.10 2011/07/10 21:18:47 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -#define MASKBITS (FPSCR_XE|FPSCR_ZE|FPSCR_UE|FPSCR_OE|FPSCR_VE) -#define MASKSHFT 3 - -fp_except -fpsetmask(fp_except mask) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - fp_except old; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - old = ((uint32_t)ud.u_fpscr & MASKBITS) >> MASKSHFT; - ud.u_fpscr &= ~MASKBITS; - ud.u_fpscr |= ((uint32_t)mask << MASKSHFT) & MASKBITS; - __asm volatile("mtfsf 0xff,%0" :: "f"(ud.u_d)); - return (old); -} diff --git a/lib/libc/arch/powerpc/gen/fpsetround.c b/lib/libc/arch/powerpc/gen/fpsetround.c deleted file mode 100644 index c2ed35eaa..000000000 --- a/lib/libc/arch/powerpc/gen/fpsetround.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.10 2011/07/10 21:18:47 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.10 2011/07/10 21:18:47 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -#define ROUNDBITS FPSCR_RN - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - fp_rnd old; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - old = (uint32_t)ud.u_fpscr & ROUNDBITS; - ud.u_fpscr &= ~ROUNDBITS; - ud.u_fpscr |= rnd_dir & ROUNDBITS; - __asm volatile("mtfsf 0xff,%0" :: "f"(ud.u_d)); - return (old); -} diff --git a/lib/libc/arch/powerpc/gen/fpsetsticky.c b/lib/libc/arch/powerpc/gen/fpsetsticky.c deleted file mode 100644 index 71df9c058..000000000 --- a/lib/libc/arch/powerpc/gen/fpsetsticky.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.11 2011/07/10 21:18:47 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.11 2011/07/10 21:18:47 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#define STICKYBITS (FPSCR_XX|FPSCR_ZX|FPSCR_UX|FPSCR_OX|FPSCR_VX) -#define INVBITS (FPSCR_VXCVI|FPSCR_VXSQRT|FPSCR_VXSOFT|FPSCR_VXVC|\ - FPSCR_VXIMZ|FPSCR_VXZDZ|FPSCR_VXIDI|FPSCR_VXISI|\ - FPSCR_VXSNAN) -#define STICKYSHFT 25 - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -fpsetsticky(fp_except mask) -{ - union { - double u_d; - uint64_t u_fpscr; - } ud; - fp_except old; - - __asm volatile("mffs %0" : "=f"(ud.u_d)); - old = ((uint32_t)ud.u_fpscr & STICKYBITS) >> STICKYSHFT; - /* - * FPSCR_VX (aka FP_X_INV) is not a sticky bit but a summary of the - * all the FPSCR_VX* sticky bits. So when FP_X_INV is cleared then - * clear all of those bits, likewise when it's set, set them all. - */ - if ((mask & FP_X_INV) == 0) - ud.u_fpscr &= ~INVBITS; - else - ud.u_fpscr |= INVBITS; - ud.u_fpscr &= ~STICKYBITS; - ud.u_fpscr |= ((uint32_t)mask << STICKYSHFT) & STICKYBITS; - /* - * Make FPSCR_FX reflect the presence of a set sticky bit (or not). - */ - if (ud.u_fpscr & (STICKYBITS|INVBITS)) - ud.u_fpscr |= FPSCR_FX; - else - ud.u_fpscr &= ~FPSCR_FX; - /* - * Write back the fpscr. - */ - __asm volatile("mtfsf 0xff,%0" :: "f"(ud.u_d)); - return (old); -} diff --git a/lib/libc/arch/powerpc/gen/makecontext.c b/lib/libc/arch/powerpc/gen/makecontext.c deleted file mode 100644 index 3d8f763a0..000000000 --- a/lib/libc/arch/powerpc/gen/makecontext.c +++ /dev/null @@ -1,84 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.4 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.4 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#if __STDC__ -#include -#else -#include -#endif - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - int *sp; - int i; - va_list ap; - - /* LINTED uintptr_t is safe */ - sp = (int *) - ((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - /* LINTED uintptr_t is safe */ - sp -= 2 + (argc > 8 ? argc - 8: 0); /* Make room for call frame. */ - sp = (int *) - ((uintptr_t)sp & ~0xf); /* Align on quad-word boundary. */ - - /* - * Start executing at -- when completes, return to - * <_resumecontext>. - */ - gr[_REG_R1] = (__greg_t)sp; - gr[_REG_LR] = (__greg_t)_resumecontext; - gr[_REG_PC] = (__greg_t)func; - - /* Wipe out stack frame backchain pointer. */ - *sp = 0; - - /* Construct argument list. */ - va_start(ap, argc); - /* Up to the first eight arguments are passed in r3-10. */ - for (i = 0; i < argc && i < 8; i++) - gr[_REG_R3 + i] = va_arg(ap, int); - /* Pass remaining arguments on the stack above the backchain/lr gap. */ - for (sp += 2; i < argc; i++) - *sp++ = va_arg(ap, int); - va_end(ap); -} diff --git a/lib/libc/arch/powerpc/gen/nanf.c b/lib/libc/arch/powerpc/gen/nanf.c deleted file mode 100644 index 1688d0eae..000000000 --- a/lib/libc/arch/powerpc/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xc0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/powerpc/gen/resumecontext.c b/lib/libc/arch/powerpc/gen/resumecontext.c deleted file mode 100644 index 57d68fdf8..000000000 --- a/lib/libc/arch/powerpc/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/powerpc/gen/swapcontext.S b/lib/libc/arch/powerpc/gen/swapcontext.S deleted file mode 100644 index 7d5389e84..000000000 --- a/lib/libc/arch/powerpc/gen/swapcontext.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.7 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -__RCSID("$NetBSD: swapcontext.S,v 1.7 2013/09/12 15:36:15 joerg Exp $") - -#define XCALLFRAMELEN (((2+3)*SZREG + CALLFRAMELEN - 1) & -CALLFRAMELEN) -#define XCALLFRAME_R30 (XCALLFRAMELEN-1*SZREG) -#define XCALLFRAME_UCP (XCALLFRAMELEN-2*SZREG) -#define XCALLFRAME_OUCP (XCALLFRAMELEN-3*SZREG) - -ENTRY(swapcontext) - stwu %r1,-XCALLFRAMELEN(%r1) # set up new stack frame - mflr %r0 - stw %r0,XCALLFRAMELEN+CALLFRAME_LR(%r1) # save link register - stw %r3,XCALLFRAME_OUCP(%r1) # must save oucp - stw %r4,XCALLFRAME_UCP(%r1) # must save ucp -#ifdef __PIC__ - stw %r30,XCALLFRAME_R30(%r1) # must save r30 - PIC_TOCSETUP(swapcontext,%r30) # setup toc pointer -#endif - bl PIC_PLT(_C_LABEL(_getcontext)) # getcontext(oucp) - cmpwi %r3,0 - bne 1f - lwz %r11,XCALLFRAME_OUCP(%r1) # load oucp for adjustment - lwz %r0,XCALLFRAMELEN+CALLFRAME_LR(%r1) - stw %r0,UC_GREGS_PC(%r11) # pc <- lr - addi %r0,%r1,XCALLFRAMELEN - stw %r0,UC_GREGS_R1(%r11) # adjust sp - lwz %r3,XCALLFRAME_UCP(%r1) # load ucp - bl PIC_PLT(_C_LABEL(setcontext)) # setcontext(ucp) -1: - lwz %r0,XCALLFRAMELEN+CALLFRAME_LR(%r1) -#ifdef __PIC__ - lwz %r30,XCALLFRAME_R30(%r1) -#endif - mtlr %r0 - addi %r1,%r1,XCALLFRAMELEN - blr -END(swapcontext) diff --git a/lib/libc/arch/powerpc/gen/syncicache.c b/lib/libc/arch/powerpc/gen/syncicache.c deleted file mode 100644 index 2c16406a1..000000000 --- a/lib/libc/arch/powerpc/gen/syncicache.c +++ /dev/null @@ -1,140 +0,0 @@ -/* $NetBSD: syncicache.c,v 1.15 2008/03/18 20:11:43 he Exp $ */ - -/* - * Copyright (C) 1995-1997, 1999 Wolfgang Solfrank. - * Copyright (C) 1995-1997, 1999 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 -#if defined(_KERNEL) -#include -#include -#include -#endif -#if !defined(_STANDALONE) -#include -#endif - -#include - - -#if defined(_STANDALONE) -#ifndef CACHELINESIZE -#error "Must know the size of a cache line" -#endif -static struct cache_info _cache_info = { - CACHELINESIZE, - CACHELINESIZE, - CACHELINESIZE, - CACHELINESIZE -}; -#define CACHEINFO _cache_info -#elif defined(_KERNEL) -#define CACHEINFO (curcpu()->ci_ci) -#else -#include - -size_t __getcachelinesize (void); - -static int _cachelinesize = 0; - -static struct cache_info _cache_info; -#define CACHEINFO _cache_info - -size_t -__getcachelinesize(void) -{ - static int cachemib[] = { CTL_MACHDEP, CPU_CACHELINE }; - static int cacheinfomib[] = { CTL_MACHDEP, CPU_CACHEINFO }; - size_t clen = sizeof(_cache_info); - - if (_cachelinesize) - return _cachelinesize; - - if (sysctl(cacheinfomib, sizeof(cacheinfomib) / sizeof(cacheinfomib[0]), - &_cache_info, &clen, NULL, 0) == 0) { - _cachelinesize = _cache_info.dcache_line_size; - return _cachelinesize; - } - - /* Try older deprecated sysctl */ - clen = sizeof(_cachelinesize); - if (sysctl(cachemib, sizeof(cachemib) / sizeof(cachemib[0]), - &_cachelinesize, &clen, NULL, 0) < 0 - || !_cachelinesize) - abort(); - - _cache_info.dcache_size = _cachelinesize; - _cache_info.dcache_line_size = _cachelinesize; - _cache_info.icache_size = _cachelinesize; - _cache_info.icache_line_size = _cachelinesize; - - /* If there is no cache, indicate we have issued the sysctl. */ - if (!_cachelinesize) - _cachelinesize = 1; - - return _cachelinesize; -} -#endif - -void -__syncicache(void *from, size_t len) -{ - size_t l, off; - size_t linesz; - char *p; - -#if !defined(_KERNEL) && !defined(_STANDALONE) - if (!_cachelinesize) - __getcachelinesize(); -#endif - - if (CACHEINFO.dcache_size > 0) { - linesz = CACHEINFO.dcache_line_size; - off = (uintptr_t)from & (linesz - 1); - l = (len + off + linesz - 1) & ~(linesz - 1); - p = (char *)from - off; - do { - __asm volatile ("dcbst 0,%0" :: "r"(p)); - p += linesz; - } while ((l -= linesz) != 0); - } - __asm volatile ("sync"); - - if (CACHEINFO.icache_size > 0 ) { - linesz = CACHEINFO.icache_line_size; - off = (uintptr_t)from & (linesz - 1); - l = (len + off + linesz - 1) & ~(linesz - 1); - p = (char *)from - off; - do { - __asm volatile ("icbi 0,%0" :: "r"(p)); - p += linesz; - } while ((l -= linesz) != 0); - } - __asm volatile ("sync; isync"); -} diff --git a/lib/libc/arch/powerpc/genassym.cf b/lib/libc/arch/powerpc/genassym.cf deleted file mode 100644 index e48bb6f2a..000000000 --- a/lib/libc/arch/powerpc/genassym.cf +++ /dev/null @@ -1,52 +0,0 @@ -# $NetBSD: genassym.cf,v 1.4 2013/08/30 21:28:59 matt Exp $ - -# -# Copyright (c) 2001 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include -include -include - -include - -define CALLFRAMELEN sizeof(struct callframe) -define CALLFRAME_LR offsetof(struct callframe, cf_lr) -define CALLFRAME_R30 offsetof(struct callframe, cf_r30) -define CALLFRAME_R31 offsetof(struct callframe, cf_r31) - -define UC_GREGS_R1 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R1]) -define UC_GREGS_R3 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R3]) -define UC_GREGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC]) - -define SIG_BLOCK SIG_BLOCK -define SIG_SETMASK SIG_SETMASK - -define CACHE_INFO_DCACHE_LINE_SIZE offsetof(struct cache_info, dcache_line_size) diff --git a/lib/libc/arch/powerpc/misc/powerpc_initfini.c b/lib/libc/arch/powerpc/misc/powerpc_initfini.c deleted file mode 100644 index 01b84a04d..000000000 --- a/lib/libc/arch/powerpc/misc/powerpc_initfini.c +++ /dev/null @@ -1,64 +0,0 @@ -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -__RCSID("$NetBSD: powerpc_initfini.c,v 1.1 2013/08/30 21:28:59 matt Exp $"); - -#include "namespace.h" - -/* - * Grab the cache_info at load time. - */ - -#include -#include -#include -#include - -#include -#include - -__dso_hidden struct cache_info _libc_powerpc_cache_info; - -static void _libc_cache_info_init(void) - __attribute__((__constructor__, __used__)); - -void __section(".text.startup") -_libc_cache_info_init(void) -{ - static bool initialized; - if (!initialized) { - const int name[2] = { CTL_MACHDEP, CPU_CACHEINFO }; - size_t len = sizeof(_libc_powerpc_cache_info); - (void)sysctl(name, __arraycount(name), - &_libc_powerpc_cache_info, &len, NULL, 0); - initialized = 1; - } -} diff --git a/lib/libc/arch/powerpc/net/Makefile.inc b/lib/libc/arch/powerpc/net/Makefile.inc deleted file mode 100644 index 80be36301..000000000 --- a/lib/libc/arch/powerpc/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2003/05/12 09:32:10 kleink Exp $ - -SRCS+= htonl.c htons.c ntohl.c ntohs.c diff --git a/lib/libc/arch/powerpc/softfloat/milieu.h b/lib/libc/arch/powerpc/softfloat/milieu.h deleted file mode 100644 index 52c2bc3cf..000000000 --- a/lib/libc/arch/powerpc/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.1 2001/05/25 11:38:57 simonb Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "powerpc-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/powerpc/softfloat/powerpc-gcc.h b/lib/libc/arch/powerpc/softfloat/powerpc-gcc.h deleted file mode 100644 index 9a1784211..000000000 --- a/lib/libc/arch/powerpc/softfloat/powerpc-gcc.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: powerpc-gcc.h,v 1.2 2005/12/24 21:11:16 perry Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#include -#if _BYTE_ORDER == _BIG_ENDIAN -#define BIGENDIAN -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef int uint8; -typedef int int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) diff --git a/lib/libc/arch/powerpc/softfloat/softfloat.h b/lib/libc/arch/powerpc/softfloat/softfloat.h deleted file mode 100644 index dfb038ab8..000000000 --- a/lib/libc/arch/powerpc/softfloat/softfloat.h +++ /dev/null @@ -1,305 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.7 2011/07/07 07:14:57 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -/* #define FLOAT128 */ - -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int8 float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -unsigned int float32_to_uint32_round_to_zero( float32 ); -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -flag float32_eq( float32, float32 ); -flag float32_le( float32, float32 ); -flag float32_lt( float32, float32 ); -flag float32_eq_signaling( float32, float32 ); -flag float32_le_quiet( float32, float32 ); -flag float32_lt_quiet( float32, float32 ); -#ifndef SOFTFLOAT_FOR_GCC -flag float32_is_signaling_nan( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -unsigned int float64_to_uint32_round_to_zero( float64 ); -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -flag float64_eq( float64, float64 ); -flag float64_le( float64, float64 ); -flag float64_lt( float64, float64 ); -flag float64_eq_signaling( float64, float64 ); -flag float64_le_quiet( float64, float64 ); -flag float64_lt_quiet( float64, float64 ); -#ifndef SOFTFLOAT_FOR_GCC -flag float64_is_signaling_nan( float64 ); -#endif - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -flag floatx80_eq( floatx80, floatx80 ); -flag floatx80_le( floatx80, floatx80 ); -flag floatx80_lt( floatx80, floatx80 ); -flag floatx80_eq_signaling( floatx80, floatx80 ); -flag floatx80_le_quiet( floatx80, floatx80 ); -flag floatx80_lt_quiet( floatx80, floatx80 ); -flag floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -flag float128_eq( float128, float128 ); -flag float128_le( float128, float128 ); -flag float128_lt( float128, float128 ); -flag float128_eq_signaling( float128, float128 ); -flag float128_le_quiet( float128, float128 ); -flag float128_lt_quiet( float128, float128 ); -flag float128_is_signaling_nan( float128 ); - -#endif diff --git a/lib/libc/arch/powerpc/stdlib/Makefile.inc b/lib/libc/arch/powerpc/stdlib/Makefile.inc deleted file mode 100644 index 2f91b992a..000000000 --- a/lib/libc/arch/powerpc/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/31 20:40:00 dsl Exp $ diff --git a/lib/libc/arch/powerpc/string/Makefile.inc b/lib/libc/arch/powerpc/string/Makefile.inc deleted file mode 100644 index 5814c9a6b..000000000 --- a/lib/libc/arch/powerpc/string/Makefile.inc +++ /dev/null @@ -1,24 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.13 2010/03/14 00:26:10 mrg Exp $ - -SRCS+= bzero.S ffs.S strlen.S -NO_SRCS+= memset.S - -# disable the asm versions of these because they break the explora. -# the special rules here are to override the suffix rules which seem -# to prefer .S files over .c -.if ${MACHINE} == "evbppc" -bcopy.o: bcopy.c -bcopy.po: bcopy.c -bcopy.pico: bcopy.c -memcpy.o: memcpy.c -memcpy.po: memcpy.c -memcpy.pico: memcpy.c -memcmp.o: memcmp.c -memcmp.po: memcmp.c -memcmp.pico: memcmp.c -memmove.o: memmove.c -memmove.po: memmove.c -memmove.pico: memmove.c -.else -SRCS+= memcmp.S bcopy.S memcpy.S memmove.S -.endif diff --git a/lib/libc/arch/powerpc/string/bzero.S b/lib/libc/arch/powerpc/string/bzero.S deleted file mode 100644 index 9c632b668..000000000 --- a/lib/libc/arch/powerpc/string/bzero.S +++ /dev/null @@ -1,265 +0,0 @@ -/* $NetBSD: bzero.S,v 1.14 2013/09/12 15:36:15 joerg Exp $ */ - -/*- - * Copyright (C) 2001 Martin J. Laubach - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -/*----------------------------------------------------------------------*/ - -#include - - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: bzero.S,v 1.14 2013/09/12 15:36:15 joerg Exp $") -#endif /* LIBC_SCCS && !lint */ - -#include "assym.h" - -#define USE_STSWX 0 /* don't. slower than trivial copy loop */ - -/*----------------------------------------------------------------------*/ -/* - void bzero(void *b %r3, size_t len %r4); - void * memset(void *b %r3, int c %r4, size_t len %r5); -*/ -/*----------------------------------------------------------------------*/ - -#define r_dst %r3 -#define r_len %r4 -#define r_val %r0 - - .text - .align 4 -ENTRY(bzero) - li r_val, 0 /* Value to stuff in */ - b cb_memset -END(bzero) - -ENTRY(memset) - cmplwi %cr1, %r5, 0 - mr. %r0, %r4 - mr %r8, %r3 - beqlr- %cr1 /* Nothing to do */ - - rlwimi %r0, %r4, 8, 16, 23 /* word extend fill value */ - rlwimi %r0, %r0, 16, 0, 15 - mr %r4, %r5 - bne- simple_fill /* =! 0, use trivial fill */ -cb_memset: - -/*----------------------------------------------------------------------*/ -#ifndef _KERNEL -#ifdef __PIC__ - /* First get cache line size */ - mflr %r9 - bcl 20,31,1f -1: mflr %r10 - mtlr %r9 - addis %r10,%r10,_libc_powerpc_cache_info+CACHE_INFO_DCACHE_LINE_SIZE-1b@ha - lwz %r9,_libc_powerpc_cache_info+CACHE_INFO_DCACHE_LINE_SIZE-1b@l(%r10) -#else - lis %r10,_libc_powerpc_cache_info+CACHE_INFO_DCACHE_LINE_SIZE@ha - lwz %r9,_libc_powerpc_cache_info+CACHE_INFO_DCACHE_LINE_SIZE@l(%r10) -#endif - cmplwi %cr1, %r9, 0 /* Unknown? */ - beq- simple_fill /* a trivial fill routine */ -#else /* _KERNEL */ -#ifdef MULTIPROCESSOR - mfsprg %r10, 0 /* Get cpu_info pointer */ -#else - lis %r10, cpu_info_store@ha - addi %r10, %r10, cpu_info_store@l -#endif - lwz %r9, CPU_CI+CACHE_INFO_DCACHE_LINE_SIZE(%r10) /* Load D$ line size */ -#endif /* _KERNEL */ - cntlzw %r10, %r9 /* Calculate shift.. */ - li %r6, 31 - subf %r10, %r10, %r6 - /* Back in memory filling business */ - - cmplwi %cr1, r_len, 0 /* Nothing to do? */ - add %r5, %r9, %r9 - cmplw r_len, %r5 /* <= 2*CL bytes to move? */ - beqlr- %cr1 /* then do nothing */ - - blt+ simple_fill /* a trivial fill routine */ - - /* Word align the block, fill bytewise until dst even*/ - - andi. %r5, r_dst, 0x03 - li %r6, 4 - beq+ cb_aligned_w /* already aligned to word? */ - - subf %r5, %r5, %r6 /* bytes to fill to align4 */ -#if USE_STSWX - mtxer %r5 - stswx %r0, 0, r_dst - add r_dst, %r5, r_dst -#else - mtctr %r5 - - subi r_dst, r_dst, 1 -1: stbu r_val, 1(r_dst) /* Fill bytewise */ - bdnz 1b - - addi r_dst, r_dst, 1 -#endif - subf r_len, %r5, r_len - -cb_aligned_w: /* Cache block align, fill wordwise until dst aligned */ - - /* I know I have something to do since we had > 2*CL initially */ - /* so no need to check for r_len = 0 */ - - subi %r6, %r9, 1 /* CL mask */ - and. %r5, r_dst, %r6 - srwi %r5, %r5, 2 - srwi %r6, %r9, 2 - beq cb_aligned_cb /* already on CL boundary? */ - - subf %r5, %r5, %r6 /* words to fill to alignment */ - mtctr %r5 - slwi %r5, %r5, 2 - subf r_len, %r5, r_len - - subi r_dst, r_dst, 4 -1: stwu r_val, 4(r_dst) /* Fill wordwise */ - bdnz 1b - addi r_dst, r_dst, 4 - -cb_aligned_cb: /* no need to check r_len, see above */ - - srw. %r5, r_len, %r10 /* Number of cache blocks */ - mtctr %r5 - beq cblocks_done - - slw %r5, %r5, %r10 - subf r_len, %r5, r_len - -1: dcbz 0, r_dst /* Clear blockwise */ - add r_dst, r_dst, %r9 - bdnz 1b - -cblocks_done: /* still CL aligned, but less than CL bytes left */ - cmplwi %cr1, r_len, 0 - cmplwi r_len, 8 - beq- %cr1, sf_return - - blt- sf_bytewise /* <8 remaining? */ - b sf_aligned_w - -/*----------------------------------------------------------------------*/ -wbzero: li r_val, 0 - - cmplwi r_len, 0 - beqlr- /* Nothing to do */ - -simple_fill: -#if USE_STSWX - cmplwi %cr1, r_len, 12 /* < 12 bytes to move? */ -#else - cmplwi %cr1, r_len, 8 /* < 8 bytes to move? */ -#endif - andi. %r5, r_dst, 0x03 /* bytes to fill to align4 */ - blt %cr1, sf_bytewise /* trivial byte mover */ - - li %r6, 4 - subf %r5, %r5, %r6 - beq+ sf_aligned_w /* dest is word aligned */ - -#if USE_STSWX - mtxer %r5 - stswx %r0, 0, r_dst - add r_dst, %r5, r_dst -#else - mtctr %r5 /* nope, then fill bytewise */ - subi r_dst, r_dst, 1 /* until it is */ -1: stbu r_val, 1(r_dst) - bdnz 1b - - addi r_dst, r_dst, 1 -#endif - subf r_len, %r5, r_len - -sf_aligned_w: /* no need to check r_len since it were >= 8 bytes initially */ -#if USE_STSWX - mr %r6, %r0 - mr %r7, %r0 - - srwi %r5, r_len, 3 - mtctr %r5 - - slwi %r5, %r5, 3 /* adjust len */ - subf. r_len, %r5, r_len - -1: stswi %r6, r_dst, 8 - addi r_dst, r_dst, 8 - bdnz 1b -#else - srwi %r5, r_len, 2 /* words to fill */ - mtctr %r5 - - slwi %r5, %r5, 2 - subf. r_len, %r5, r_len /* adjust len for fill */ - - subi r_dst, r_dst, 4 -1: stwu r_val, 4(r_dst) - bdnz 1b - addi r_dst, r_dst, 4 -#endif - -sf_word_done: bne- sf_bytewise - -sf_return: mr %r3, %r8 /* restore orig ptr */ - blr /* for memset functionality */ - -sf_bytewise: -#if USE_STSWX - mr %r5, %r0 - mr %r6, %r0 - mr %r7, %r0 - - mtxer r_len - stswx %r5, 0, r_dst -#else - mtctr r_len - - subi r_dst, r_dst, 1 -1: stbu r_val, 1(r_dst) - bdnz 1b -#endif - mr %r3, %r8 /* restore orig ptr */ - blr /* for memset functionality */ -END(memset) - -/*----------------------------------------------------------------------*/ -#ifndef _KERNEL - .data - .p2align 2 -cache_info: .long -1, -1, -1, -1 -cache_sh: .long 0 - -#endif -/*----------------------------------------------------------------------*/ diff --git a/lib/libc/arch/powerpc/sys/__clone.S b/lib/libc/arch/powerpc/sys/__clone.S deleted file mode 100644 index e6ad7c880..000000000 --- a/lib/libc/arch/powerpc/sys/__clone.S +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: __clone.S,v 1.6 2014/08/23 02:24:22 matt Exp $ */ - -/*- - * Copyright (c) 2001 Tsubai Masanari. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __clone.S,v 1.6 2014/08/23 02:24:22 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - /* - * Sanity checks: func and stack may not be NULL. - */ - cmpptri %r3,0 - beq 1f - cmpptri %r4,0 - beq 1f - - mr %r7,%r3 /* Save fn in r7. */ - mr %r3,%r5 - _DOSYSCALL(__clone) /* (flags, stack) */ - bso 2f /* error... */ - - cmpptri %r3,0 - bnelr /* We're the parent, just return. */ - - mtlr %r7 /* fn */ - mr %r3,%r6 /* arg */ - blrl /* Call the clone's entry point. */ - -#ifdef __PIC__ - PIC_TOCSETUP(__clone, %r30) /* exit won't return so blow away r30 */ -#endif - bl PIC_PLT(_C_LABEL(_exit)) - -1: - li %r3,EINVAL -2: - BRANCH_TO_CERROR() -END(__clone) diff --git a/lib/libc/arch/powerpc/sys/__sigaction14_sigtramp.c b/lib/libc/arch/powerpc/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 71f97406a..000000000 --- a/lib/libc/arch/powerpc/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.9 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.9 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) -#ifdef __LIBC12_SOURCE__ -extern const int __sigtramp_sigcontext_1[] - __weak_reference(__sigtramp_sigcontext_1); -#endif - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specificed or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/powerpc/sys/__sigtramp2.S b/lib/libc/arch/powerpc/sys/__sigtramp2.S deleted file mode 100644 index 132b347c5..000000000 --- a/lib/libc/arch/powerpc/sys/__sigtramp2.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.3 2011/01/15 07:31:12 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigtramp2.S,v 1.3 2011/01/15 07:31:12 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -/* - * On entry to user space, stack and registers look like: - * - * r3 signal number - * r4 pointer to siginfo structure - * r5 pointer to ucontext structure - * r30 pointer to ucontext structure - * srr0 address of handler - * lr address of this trampoline - * - */ -ENTRY_NOPROFILE(__sigtramp_siginfo_2) - mr %r3,%r30 /* restore ucontext pointer */ - _DOSYSCALL(setcontext) /* restore machine state */ - _DOSYSCALL(exit) /* or exit with errno if failed */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/powerpc/sys/__syscall.S b/lib/libc/arch/powerpc/sys/__syscall.S deleted file mode 100644 index 295a1d32b..000000000 --- a/lib/libc/arch/powerpc/sys/__syscall.S +++ /dev/null @@ -1,22 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - - .text - .p2align 2 -ENTRY(__syscall) - mr %r0,%r3 /* syscall number */ - mr %r3,%r4 - mr %r4,%r5 - mr %r5,%r6 - mr %r6,%r7 - mr %r7,%r8 - mr %r8,%r9 - mr %r9,%r10 - ldreg %r10,(2*__SIZEOF_POINTER__)(%r1) /* final argument is on the stack */ - sc - bnslr - BRANCH_TO_CERROR() -END(__syscall) - -STRONG_ALIAS(syscall, __syscall) diff --git a/lib/libc/arch/powerpc/sys/__vfork14.S b/lib/libc/arch/powerpc/sys/__vfork14.S deleted file mode 100644 index c2894d053..000000000 --- a/lib/libc/arch/powerpc/sys/__vfork14.S +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.4 2011/01/15 07:31:12 matt Exp $ */ - -/* - * pid = vfork(); - * - * r4 == 0 in parent process, 1 in child process. - * r3 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -SYSCALL(__vfork14) - addi %r4,%r4,-1 # from 1 to 0 in child, 0 to -1 in parent - and %r3,%r3,%r4 # return 0 in child, pid in parent - blr -END(__vfork14) diff --git a/lib/libc/arch/powerpc/sys/brk.S b/lib/libc/arch/powerpc/sys/brk.S deleted file mode 100644 index 8c83ed280..000000000 --- a/lib/libc/arch/powerpc/sys/brk.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: brk.S,v 1.14 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: brk.S,v 1.14 2014/08/23 02:24:22 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - - .hidden _C_LABEL(__curbrk) - .globl _C_LABEL(__curbrk) - .hidden _C_LABEL(__minbrk) - .globl _C_LABEL(__minbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data - .p2align 2 -_C_LABEL(__minbrk): - .long _C_LABEL(_end) -_C_LABEL(__curbrk): - .long _C_LABEL(_end) - -ENTRY(_brk) -#ifdef __PIC__ - mflr %r0 - bcl 20,31,.LPIC0 -.LPIC0: mflr %r9 - mtlr %r0 - addis %r9,%r9,(_C_LABEL(__minbrk)-.LPIC0)@ha - ldptru %r5,(_C_LABEL(__minbrk)-.LPIC0)@l(%r9) # r5 = &_end -#else - lis %r9,_C_LABEL(__minbrk)@ha - ldptru %r5,_C_LABEL(__minbrk)@l(%r9) # r5 = &_end -#endif - cmpptrl %r5,%r3 # if (__minbrk <= r3) -#ifdef __PPC_ISEL__ - iselgt %r3,%r5,%r3 -#else - bgt 0f - mr %r5,%r3 # r5 = r3 -0: - mr %r3,%r5 # new break value -#endif - _DOSYSCALL(break) # assume that r5 is preserved - bso 1f - stptr %r5,__SIZEOF_POINTER__(%r9) - blr # return 0 - -1: - BRANCH_TO_CERROR() -END(_brk) diff --git a/lib/libc/arch/powerpc/sys/cerror.S b/lib/libc/arch/powerpc/sys/cerror.S deleted file mode 100644 index 954bf0bd1..000000000 --- a/lib/libc/arch/powerpc/sys/cerror.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: cerror.S,v 1.11 2013/09/12 15:36:15 joerg Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: cerror.S,v 1.11 2013/09/12 15:36:15 joerg Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifndef _REENTRANT - .globl _C_LABEL(errno) -#endif -#ifdef __PIC__ - .protected _C_LABEL(__cerror) -#endif - -ENTRY(__cerror) -#ifdef _REENTRANT - mflr %r0 - stwu %r1,-CALLFRAMELEN(%r1) # allocate new stack frame - stw %r0,CALLFRAMELEN+CALLFRAME_LR(%r1) -#ifdef __PIC__ - stw %r30,CALLFRAME_R30(%r1) - PIC_TOCSETUP(__cerror, %r30) -#endif - stw %r31,CALLFRAME_R31(%r1) - mr %r31,%r3 # stash away in callee-saved register - bl PIC_PLT(_C_LABEL(__errno)) - stw %r31,0(%r3) - lwz %r0,CALLFRAMELEN+CALLFRAME_LR(%r1) - lwz %r31,CALLFRAME_R31(%r1) -#ifdef __PIC__ - lwz %r30,CALLFRAME_R30(%r1) -#endif - mtlr %r0 - addi %r1,%r1,CALLFRAMELEN -#else -#ifdef __PIC__ - mflr %r10 - PIC_GOTSETUP(%r4) - lwz %r4,_C_LABEL(errno)@got(%r4) - stw %r3,0(%r4) - mtlr %r10 -#else - lis %r4,_C_LABEL(errno)@ha - stw %r3,_C_LABEL(errno)@l(%r4) -#endif /* __PIC__ */ -#endif /* _REENTRANT */ - li %r3,-1 - li %r4,-1 - blr -END(__cerror) diff --git a/lib/libc/arch/powerpc/sys/exect.S b/lib/libc/arch/powerpc/sys/exect.S deleted file mode 100644 index 362cbf6ea..000000000 --- a/lib/libc/arch/powerpc/sys/exect.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: exect.S,v 1.3 1998/05/25 15:28:03 ws Exp $ */ - -#include "SYS.h" - -PSEUDO(exect,execve) diff --git a/lib/libc/arch/powerpc/sys/fork.S b/lib/libc/arch/powerpc/sys/fork.S deleted file mode 100644 index c442b8241..000000000 --- a/lib/libc/arch/powerpc/sys/fork.S +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: fork.S,v 1.6 2011/01/15 07:31:13 matt Exp $ */ - -/* - * pid = fork(); - * - * r4 == 0 in parent process, 1 in child process. - * r3 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -_SYSCALL(__fork,fork) - addi %r4,%r4,-1 # from 1 to 0 in child, 0 to -1 in parent - and %r3,%r3,%r4 # return 0 in child, pid in parent - blr -END(__fork) diff --git a/lib/libc/arch/powerpc/sys/getcontext.S b/lib/libc/arch/powerpc/sys/getcontext.S deleted file mode 100644 index abd92c82d..000000000 --- a/lib/libc/arch/powerpc/sys/getcontext.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.6 2014/08/23 02:24:22 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getcontext.S,v 1.6 2014/08/23 02:24:22 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -ENTRY(_getcontext) - mr %r5,%r3 # must save pointer - _DOSYSCALL(getcontext) - bso 1f - mflr %r4 - stptr %r4,UC_GREGS_PC(%r5) # saved pc <- lr - stint %r3,UC_GREGS_R3(%r5) # arrange for return value 0 - blr -1: - BRANCH_TO_CERROR() -END(_getcontext) diff --git a/lib/libc/arch/powerpc/sys/pipe.S b/lib/libc/arch/powerpc/sys/pipe.S deleted file mode 100644 index 8d6f041e5..000000000 --- a/lib/libc/arch/powerpc/sys/pipe.S +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: pipe.S,v 1.9 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pipe.S,v 1.9 2014/08/23 02:24:22 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe) - mr %r5,%r3 # save pointer - _DOSYSCALL(pipe) # assume, that r5 is kept - bso 1f - stint %r3,0(%r5) # success, store fds - stint %r4,4(%r5) - li %r3,0 - blr # and return 0 -1: - BRANCH_TO_CERROR() -END(_pipe) diff --git a/lib/libc/arch/powerpc/sys/ptrace.S b/lib/libc/arch/powerpc/sys/ptrace.S deleted file mode 100644 index 2fc542d9c..000000000 --- a/lib/libc/arch/powerpc/sys/ptrace.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.7 2013/09/12 15:36:15 joerg Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ptrace.S,v 1.7 2013/09/12 15:36:15 joerg Exp $") -#endif /* LIBC_SCCS && !lint */ - -#define XCALLFRAMELEN ((((2+5)*SZREG) + CALLFRAMELEN - 1) & -CALLFRAMELEN) -#define XCALLFRAME_DATA (XCALLFRAMELEN - 1*SZREG) -#define XCALLFRAME_ADDR (XCALLFRAMELEN - 2*SZREG) -#define XCALLFRAME_PID (XCALLFRAMELEN - 3*SZREG) -#define XCALLFRAME_REQUEST (XCALLFRAMELEN - 4*SZREG) -#define XCALLFRAME_R30 (XCALLFRAMELEN - 5*SZREG) - -ENTRY(ptrace) -#ifdef _REENTRANT - mflr %r0 - stw %r0,CALLFRAME_LR(%r1) - stwu %r1,-XCALLFRAMELEN(%r1) - stw %r3,XCALLFRAME_REQUEST(%r1) - stw %r4,XCALLFRAME_PID(%r1) - stw %r5,XCALLFRAME_ADDR(%r1) - stw %r6,XCALLFRAME_DATA(%r1) -#ifdef __PIC__ - stw %r30,XCALLFRAME_R30(%r1) - PIC_TOCSETUP(ptrace, %r30) -#endif - - bl PIC_PLT(_C_LABEL(__errno)) - li %r7,0 - stw %r7,0(%r3) - -#ifdef __PIC__ - lwz %r30,XCALLFRAME_R30(%r1) -#endif - lwz %r6,XCALLFRAME_DATA(%r1) - lwz %r4,XCALLFRAME_PID(%r1) - lwz %r5,XCALLFRAME_ADDR(%r1) - lwz %r3,XCALLFRAME_REQUEST(%r1) - addi %r1,%r1,XCALLFRAMELEN - lwz %r0,CALLFRAME_LR(%r1) - mtlr %r0 -#else -#ifdef __PIC__ - mflr %r0 - PIC_GOTSETUP(%r7) - lwz %r7,_C_LABEL(errno)@got(%r7) - li %r8,0 - stw %r8,0(%r7) - mtlr 0 -#else - lis %r7,_C_LABEL(errno)@ha - li %r8,0 - stw %r8,_C_LABEL(errno)@l(%r7) -#endif /* __PIC__ */ -#endif /* _REENTRANT */ - _DOSYSCALL(ptrace) - bnslr - b _C_LABEL(__cerror) diff --git a/lib/libc/arch/powerpc/sys/sbrk.S b/lib/libc/arch/powerpc/sys/sbrk.S deleted file mode 100644 index 308f4c93f..000000000 --- a/lib/libc/arch/powerpc/sys/sbrk.S +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.13 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sbrk.S,v 1.13 2014/08/23 02:24:22 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - - .hidden _C_LABEL(__curbrk) - .globl _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - -ENTRY(_sbrk) -#ifdef __PIC__ - mflr %r0 - bcl 20,31,.LPIC0 -.LPIC0: mflr %r5 - mtlr %r0 - addis %r8,%r5,(_C_LABEL(__curbrk)-.LPIC0)@ha - ldptru %r6,(_C_LABEL(__curbrk)-.LPIC0)@l(%r8) -#else - lis %r8,_C_LABEL(__curbrk)@ha - ldptru %r6,_C_LABEL(__curbrk)@l(%r8) # r6 = old break, r5 = &curbrk -#endif - add %r3,%r3,%r6 - mr %r7,%r3 # r7 = new break - _DOSYSCALL(break) # break(new_break) - bso 1f - mr %r3,%r6 # set return value - stptr %r7,0(%r8) # record new break - blr -1: - BRANCH_TO_CERROR() -END(_sbrk) diff --git a/lib/libc/arch/powerpc/sys/shmat.S b/lib/libc/arch/powerpc/sys/shmat.S deleted file mode 100644 index b72046bf8..000000000 --- a/lib/libc/arch/powerpc/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:53 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/powerpc/sys/syscall.S b/lib/libc/arch/powerpc/sys/syscall.S deleted file mode 100644 index e8200bc78..000000000 --- a/lib/libc/arch/powerpc/sys/syscall.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: syscall.S,v 1.3 2014/02/01 20:26:21 matt Exp $ */ - -/* aliased to __syscall */ diff --git a/lib/libc/arch/powerpc64/Makefile.inc b/lib/libc/arch/powerpc64/Makefile.inc deleted file mode 100644 index c7220ea40..000000000 --- a/lib/libc/arch/powerpc64/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2014/08/23 02:24:22 matt Exp $ - -KMINCLUDES= -KMSRCS= - -CPPFLAGS+= -I. - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S diff --git a/lib/libc/arch/powerpc64/SYS.h b/lib/libc/arch/powerpc64/SYS.h deleted file mode 100644 index 39c1ee399..000000000 --- a/lib/libc/arch/powerpc64/SYS.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: SYS.h,v 1.4 2015/01/12 02:48:20 dennis Exp $ */ - -#include -#include - -/* - * Inline what __cerror() is generally used to do since branching - * to __cerror() can't be done reliably with the powerpc64 ABI. - */ -#ifdef _REENTRANT -#define _DO_CERROR_SF_SZ (SF_SZ + SF_ALIGN(8)) -#define _DO_CERROR() mflr %r0 ;\ - streg %r31,-8(%r1) ;\ - streg %r0,SF_LR(%r1) ;\ - stptru %r1,-_DO_CERROR_SF_SZ(%r1) ;\ - mr %r31,%r3 ;\ - bl PIC_PLT(_C_LABEL(__errno)) ;\ - nop ;\ - stint %r31,0(%r3) ;\ - addi %r1,%r1,_DO_CERROR_SF_SZ ;\ - ldreg %r0,SF_LR(%r1) ;\ - ldreg %r31,-8(%r1) ;\ - mtlr %r0 ;\ - li %r3,-1 ;\ - li %r4,-1 ;\ - blr -#else /* !_REENTRANT */ -#define _DO_CERROR() lwz %r4,_C_LABEL(errno)@got(%r2) ;\ - stw %r3,0(%r4) ;\ - li %r3,-1 ;\ - li %r4,-1 ;\ - blr -#endif /* _REENTRANT */ - -/* Clearly BRANCH_TO_CERROR() no longer does that... */ -#define BRANCH_TO_CERROR() _DO_CERROR() - -#define _DOSYSCALL(x) li %r0,(SYS_ ## x) ;\ - sc - -#define _SYSCALL_NOERROR(x,y) .text ;\ - .p2align 2 ;\ - ENTRY(x) ;\ - _DOSYSCALL(y) - -#define _SYSCALL(x,y) .text ;\ - .p2align 2 ;\ - 2: _DO_CERROR() ;\ - _SYSCALL_NOERROR(x,y) ;\ - bso 2b - -#define SYSCALL_NOERROR(x) _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) _SYSCALL_NOERROR(x,y) ;\ - blr ;\ - END(x) - -#define PSEUDO(x,y) _SYSCALL_NOERROR(x,y) ;\ - bnslr ;\ - _DO_CERROR() ;\ - END(x) - -#define RSYSCALL_NOERROR(x) PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) PSEUDO(x,x) - -#define WSYSCALL(weak,strong) WEAK_ALIAS(weak,strong) ;\ - PSEUDO(strong,weak) diff --git a/lib/libc/arch/powerpc64/gdtoa/Makefile.inc b/lib/libc/arch/powerpc64/gdtoa/Makefile.inc deleted file mode 100644 index 98cc03a7d..000000000 --- a/lib/libc/arch/powerpc64/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/07/01 16:37:20 ross Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/powerpc64/gdtoa/arith.h b/lib/libc/arch/powerpc64/gdtoa/arith.h deleted file mode 100644 index 6ea59e97f..000000000 --- a/lib/libc/arch/powerpc64/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/07/01 16:37:20 ross Exp $ */ - -#define IEEE_BIG_ENDIAN diff --git a/lib/libc/arch/powerpc64/gdtoa/gd_qnan.h b/lib/libc/arch/powerpc64/gdtoa/gd_qnan.h deleted file mode 100644 index a37738ff2..000000000 --- a/lib/libc/arch/powerpc64/gdtoa/gd_qnan.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/07/01 16:37:20 ross Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 diff --git a/lib/libc/arch/powerpc64/gen/Makefile.inc b/lib/libc/arch/powerpc64/gen/Makefile.inc deleted file mode 100644 index 36713d375..000000000 --- a/lib/libc/arch/powerpc64/gen/Makefile.inc +++ /dev/null @@ -1,27 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/12/06 07:12:17 uebayasi Exp $ - -SRCS+= __setjmp14.S __sigsetjmp14.S _setjmp.S -SRCS+= bswap16.c bswap32.c bswap64.c -SRCS+= fabs.c flt_rounds.c -SRCS+= syncicache.c -SRCS+= _lwp.c makecontext.c resumecontext.c swapcontext.S - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c - -.if (${MKSOFTFLOAT} == "no") -SRCS+= fpgetround.c fpsetround.c fpgetmask.c fpsetmask.c -SRCS+= fpgetsticky.c fpsetsticky.c -.endif - -LSRCS.powerpc.gen=Lint_swapcontext.c -LSRCS+= ${LSRCS.powerpc.gen} -DPSRCS+= ${LSRCS.powerpc.gen} -CLEANFILES+= ${LSRCS.powerpc.gen} diff --git a/lib/libc/arch/powerpc64/gen/__setjmp14.S b/lib/libc/arch/powerpc64/gen/__setjmp14.S deleted file mode 100644 index 80fe15eb9..000000000 --- a/lib/libc/arch/powerpc64/gen/__setjmp14.S +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: __setjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: __setjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - mr %r6,%r3 - li %r3,1 # SIG_BLOCK - li %r4,0 - addi %r5,%r6,100 # &sigmask - _DOSYSCALL(__sigprocmask14) # assume no error XXX - mflr %r11 - mfcr %r12 - mr %r10,%r1 - mr %r9,%r2 - - std %r8,8(%r6) # save r8-r31 - std %r9,16(%r6) - std %r10,24(%r6) - std %r11,32(%r6) - std %r12,40(%r6) - std %r13,48(%r6) - std %r14,56(%r6) - std %r15,64(%r6) - std %r16,72(%r6) - std %r17,80(%r6) - std %r18,88(%r6) - std %r19,96(%r6) - std %r20,104(%r6) - std %r21,112(%r6) - std %r22,120(%r6) - std %r23,128(%r6) - std %r24,136(%r6) - std %r25,144(%r6) - std %r26,152(%r6) - std %r27,160(%r6) - std %r28,168(%r6) - std %r29,176(%r6) - std %r30,184(%r6) - std %r31,192(%r6) - - li %r3,0 - blr -END(__setjmp14) - -ENTRY(__longjmp14) - ld %r8,8(%r6) # load r8-r31 - ld %r9,16(%r6) - ld %r10,24(%r6) - ld %r11,32(%r6) - ld %r12,40(%r6) - ld %r13,48(%r6) - ld %r14,56(%r6) - ld %r15,64(%r6) - ld %r16,72(%r6) - ld %r17,80(%r6) - ld %r18,88(%r6) - ld %r19,96(%r6) - ld %r20,104(%r6) - ld %r21,112(%r6) - ld %r22,120(%r6) - ld %r23,128(%r6) - ld %r24,136(%r6) - ld %r25,144(%r6) - ld %r26,152(%r6) - ld %r27,160(%r6) - ld %r28,168(%r6) - ld %r29,176(%r6) - ld %r30,184(%r6) - ld %r31,192(%r6) - - mr %r6,%r4 - mtlr %r11 - mtcr %r12 - mr %r2,%r9 - mr %r1,%r10 - addi %r4,%r3,100 # &sigmask - li %r3,3 # SIG_SETMASK - li %r5,0 - _DOSYSCALL(__sigprocmask14) # assume no error XXX - or. %r3,%r6,%r6 - bnelr - li %r3,1 - blr -END(__longjmp14) diff --git a/lib/libc/arch/powerpc64/gen/__sigsetjmp14.S b/lib/libc/arch/powerpc64/gen/__sigsetjmp14.S deleted file mode 100644 index 1ed304d80..000000000 --- a/lib/libc/arch/powerpc64/gen/__sigsetjmp14.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) - .text - .asciz "$NetBSD: __sigsetjmp14.S,v 1.3 2014/08/23 02:24:22 matt Exp $" -#endif - -ENTRY(__sigsetjmp14) - mr %r6,%r3 - or. %r7,%r4,%r4 - beq 1f - li %r3,1 # SIG_BLOCK - li %r4,0 - addi %r5,%r6,100 # &sigmask - _DOSYSCALL(__sigprocmask14) # assume no error XXX -1: - mflr %r11 - mfcr %r12 - mr %r10,%r1 - mr %r9,%r2 - i = 0 - .rept 32-7 - std 7+i,i*8(%r6) # save r7-r31 - i = i + 1 - .endr - li %r3,0 - blr -END(__sigsetjmp14) - -ENTRY(__siglongjmp14) - i = 0 - .rept 32-7 - ld 7+i,i*8(%r3) # load r7-r31 - i = i + 1 - .endr - mr %r6,%r4 - mtlr %r11 - mtcr %r12 - mr %r2,%r9 - mr %r1,%r10 - or. %r7,%r7,%r7 - beq 1f - addi %r4,%r3,100 # &sigmask - li %r3,3 # SIG_SETMASK - li %r5,0 - _DOSYSCALL(__sigprocmask14) # assume no error XXX -1: - or. %r3,%r6,%r6 - bnelr - li %r3,1 - blr -END(__siglongjmp14) diff --git a/lib/libc/arch/powerpc64/gen/_lwp.c b/lib/libc/arch/powerpc64/gen/_lwp.c deleted file mode 100644 index c299d00f8..000000000 --- a/lib/libc/arch/powerpc64/gen/_lwp.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.3 2012/11/24 15:20:58 christos Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Allen Briggs for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.3 2012/11/24 15:20:58 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -/*ARGSUSED*/ -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), void *arg, - void *private, caddr_t stack_base, size_t stack_size) -{ - void **sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - sp = (void *)(stack_base + stack_size); - - u->uc_mcontext.__gregs[3] = (__greg_t) arg; /* arg1 */ - u->uc_mcontext.__gregs[1] = ((__greg_t) sp) - 112; /* stack */ - u->uc_mcontext.__gregs[33] = (__greg_t) _lwp_exit; /* LR */ - u->uc_mcontext.__gregs[34] = (__greg_t) start; /* PC */ -} diff --git a/lib/libc/arch/powerpc64/gen/_setjmp.S b/lib/libc/arch/powerpc64/gen/_setjmp.S deleted file mode 100644 index 3d8da049a..000000000 --- a/lib/libc/arch/powerpc64/gen/_setjmp.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.2 2006/07/05 18:06:47 ross Exp $ */ - -#include - -#if defined(LIBC_SCCS) - .text - .asciz "$NetBSD: _setjmp.S,v 1.2 2006/07/05 18:06:47 ross Exp $" -#endif - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - mflr %r11 /* save return address */ - mfcr %r12 /* save condition register */ - mr %r10,%r1 /* save stack pointer */ - mr %r9,%r2 /* save GPR2 (not needed) */ - i = 0 - .rept 32-9 - std 9+i,i*8+16(%r3) - i = i + 1 - .endr - li %r3,0 /* indicate success */ - blr /* return */ - -ENTRY(_longjmp) - i = 0 - .rept 32-9 - ld 9+i,i*8+16(%r3) - i = i + 1 - .endr - mtlr %r11 /* restore LR */ - mtcr %r12 /* restore CR */ - mr %r2,%r9 /* restore GPR2 (not needed) */ - mr %r1,%r10 /* restore stack */ - or. %r3,%r4,%r4 /* get return value */ - bnelr /* return if not 0 */ - li %r3,1 /* what's the point? */ - blr /* return */ diff --git a/lib/libc/arch/powerpc64/gen/fabs.c b/lib/libc/arch/powerpc64/gen/fabs.c deleted file mode 100644 index 4cc21a901..000000000 --- a/lib/libc/arch/powerpc64/gen/fabs.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: fabs.c,v 1.2 2006/07/05 18:07:22 ross Exp $ */ - -#include - -double -fabs(double x) -{ -#ifdef _SOFT_FLOAT - if (x < 0) - x = -x; -#else - __asm volatile("fabs %0,%1" : "=f"(x) : "f"(x)); -#endif - return (x); -} diff --git a/lib/libc/arch/powerpc64/gen/flt_rounds.c b/lib/libc/arch/powerpc64/gen/flt_rounds.c deleted file mode 100644 index 1e2799a29..000000000 --- a/lib/libc/arch/powerpc64/gen/flt_rounds.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.2 2015/03/19 21:22:59 joerg Exp $ */ - -/* - * Copyright (c) 1996 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.2 2015/03/19 21:22:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 0, /* round to zero */ - 2, /* round to positive infinity */ - 3 /* round to negative infinity */ -}; - -int -__flt_rounds(void) -{ -#ifdef _SOFT_FLOAT - return map[fpgetround()]; -#else - uint64_t fpscr; - - __asm volatile("mffs %0" : "=f"(fpscr)); - return map[((uint32_t)fpscr & FPSCR_RN)]; -#endif -} diff --git a/lib/libc/arch/powerpc64/gen/fpgetmask.c b/lib/libc/arch/powerpc64/gen/fpgetmask.c deleted file mode 100644 index 5e44e336c..000000000 --- a/lib/libc/arch/powerpc64/gen/fpgetmask.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -#define MASKBITS (FPSCR_VE|FPSCR_OE|FPSCR_UE|FPSCR_ZE|FPSCR_XE) -#define MASKSHFT 3 - -fp_except -fpgetmask(void) -{ - uint64_t fpscr; - - __asm volatile("mffs %0" : "=f"(fpscr)); - return (((uint32_t)fpscr & MASKBITS) >> MASKSHFT); -} diff --git a/lib/libc/arch/powerpc64/gen/fpgetround.c b/lib/libc/arch/powerpc64/gen/fpgetround.c deleted file mode 100644 index 8cc346ee7..000000000 --- a/lib/libc/arch/powerpc64/gen/fpgetround.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -#define ROUNDBITS FPSCR_RN -#define ROUNDSHFT 0 - -fp_rnd -fpgetround(void) -{ - uint64_t fpscr; - - __asm volatile("mffs %0" : "=f"(fpscr)); - return (((uint32_t)fpscr & ROUNDBITS) >> ROUNDSHFT); -} diff --git a/lib/libc/arch/powerpc64/gen/fpgetsticky.c b/lib/libc/arch/powerpc64/gen/fpgetsticky.c deleted file mode 100644 index f46aa8387..000000000 --- a/lib/libc/arch/powerpc64/gen/fpgetsticky.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -#define STICKYBITS (FPSCR_XX|FPSCR_ZX|FPSCR_UX|FPSCR_OX|FPSCR_VX) -#define STICKYSHFT 25 - -fp_except -fpgetsticky(void) -{ - uint64_t fpscr; - - __asm volatile("mffs %0" : "=f"(fpscr)); - return (((uint32_t)fpscr & STICKYBITS) >> STICKYSHFT); -} diff --git a/lib/libc/arch/powerpc64/gen/fpsetmask.c b/lib/libc/arch/powerpc64/gen/fpsetmask.c deleted file mode 100644 index 0ede2542b..000000000 --- a/lib/libc/arch/powerpc64/gen/fpsetmask.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -#define MASKBITS (FPSCR_XE|FPSCR_ZE|FPSCR_UE|FPSCR_OE|FPSCR_VE) -#define MASKSHFT 3 - -fp_except -fpsetmask(fp_except mask) -{ - uint64_t fpscr; - fp_except old; - - __asm volatile("mffs %0" : "=f"(fpscr)); - old = ((uint32_t)fpscr & MASKBITS) >> MASKSHFT; - fpscr &= ~MASKBITS; - fpscr |= ((uint32_t)mask << MASKSHFT) & MASKBITS; - __asm volatile("mtfsf 0xff,%0" :: "f"(fpscr)); - return (old); -} diff --git a/lib/libc/arch/powerpc64/gen/fpsetround.c b/lib/libc/arch/powerpc64/gen/fpsetround.c deleted file mode 100644 index 90fe8297a..000000000 --- a/lib/libc/arch/powerpc64/gen/fpsetround.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -#define ROUNDBITS FPSCR_RN - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - uint64_t fpscr; - fp_rnd old; - - __asm volatile("mffs %0" : "=f"(fpscr)); - old = (uint32_t)fpscr & ROUNDBITS; - fpscr &= ~ROUNDBITS; - fpscr |= rnd_dir & ROUNDBITS; - __asm volatile("mtfsf 0xff,%0" :: "f"(fpscr)); - return (old); -} diff --git a/lib/libc/arch/powerpc64/gen/fpsetsticky.c b/lib/libc/arch/powerpc64/gen/fpsetsticky.c deleted file mode 100644 index 30e1bd855..000000000 --- a/lib/libc/arch/powerpc64/gen/fpsetsticky.c +++ /dev/null @@ -1,84 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#define STICKYBITS (FPSCR_XX|FPSCR_ZX|FPSCR_UX|FPSCR_OX|FPSCR_VX) -#define INVBITS (FPSCR_VXCVI|FPSCR_VXSQRT|FPSCR_VXSOFT|FPSCR_VXVC|\ - FPSCR_VXIMZ|FPSCR_VXZDZ|FPSCR_VXIDI|FPSCR_VXISI|\ - FPSCR_VXSNAN) -#define STICKYSHFT 25 - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -fpsetsticky(fp_except mask) -{ - uint64_t fpscr; - fp_except old; - - __asm volatile("mffs %0" : "=f"(fpscr)); - old = ((uint32_t)fpscr & STICKYBITS) >> STICKYSHFT; - /* - * FPSCR_VX (aka FP_X_INV) is not a sticky bit but a summary of the - * all the FPSCR_VX* sticky bits. So when FP_X_INV is cleared then - * clear all of those bits, likewise when it's set, set them all. - */ - if ((mask & FP_X_INV) == 0) - fpscr &= ~INVBITS; - else - fpscr |= INVBITS; - fpscr &= ~STICKYBITS; - fpscr |= ((uint32_t)mask << STICKYSHFT) & STICKYBITS; - /* - * Make FPSCR_FX reflect the presence of a set sticky bit (or not). - */ - if (fpscr & (STICKYBITS|INVBITS)) - fpscr |= FPSCR_FX; - else - fpscr &= ~FPSCR_FX; - /* - * Write back the fpscr. - */ - __asm volatile("mtfsf 0xff,%0" :: "f"(fpscr)); - return (old); -} diff --git a/lib/libc/arch/powerpc64/gen/makecontext.c b/lib/libc/arch/powerpc64/gen/makecontext.c deleted file mode 100644 index fbfe1ecdd..000000000 --- a/lib/libc/arch/powerpc64/gen/makecontext.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#if __STDC__ -#include -#else -#include -#endif - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - __greg_t sp, *spp; - int i; - va_list ap; - - sp = (__greg_t) ((uintptr_t)ucp->uc_stack.ss_sp - + ucp->uc_stack.ss_size); - sp -= 2 + (argc > 8 ? argc - 8: 0); /* Make room for call frame. */ - sp = (__greg_t) ((uintptr_t)sp & ~0xf); - - /* - * Start executing at -- when completes, return to - * <_resumecontext>. - */ - gr[_REG_R1] = sp; - gr[_REG_LR] = (__greg_t)_resumecontext; - gr[_REG_PC] = (__greg_t)func; // XXX -- this is the descriptor address! - - /* Wipe out stack frame backchain pointer. */ - spp = (__greg_t *)sp; - *spp = 0; - - /* Construct argument list. */ - va_start(ap, argc); - /* Up to the first eight arguments are passed in r3-10. */ - for (i = 0; i < argc && i < 8; i++) - gr[_REG_R3 + i] = va_arg(ap, long); - /* Pass remaining arguments on the stack above the backchain/lr gap. */ - for (spp += 2; i < argc; i++) - *spp++ = va_arg(ap, long); - va_end(ap); -} diff --git a/lib/libc/arch/powerpc64/gen/nanf.c b/lib/libc/arch/powerpc64/gen/nanf.c deleted file mode 100644 index 5007de780..000000000 --- a/lib/libc/arch/powerpc64/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.2 2009/02/22 01:34:02 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.2 2009/02/22 01:34:02 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xc0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/powerpc64/gen/resumecontext.c b/lib/libc/arch/powerpc64/gen/resumecontext.c deleted file mode 100644 index f604739da..000000000 --- a/lib/libc/arch/powerpc64/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.4 2011/09/19 21:24:58 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.4 2011/09/19 21:24:58 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/powerpc64/gen/swapcontext.S b/lib/libc/arch/powerpc64/gen/swapcontext.S deleted file mode 100644 index 1bf7c797e..000000000 --- a/lib/libc/arch/powerpc64/gen/swapcontext.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.5 2014/08/13 15:41:21 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - .text - .asciz "$NetBSD: swapcontext.S,v 1.5 2014/08/13 15:41:21 joerg Exp $" -#endif /* LIBC_SCCS && !lint */ - -ENTRY(swapcontext) - mc_off = 56 # offset of uc_mcontext - stdu %r1,-SF_SZ(%r1) # set up new stack frame - mflr %r0 - std %r0,(SF_SZ+SF_LR)(%r1) # save link register - std %r3,SF_PARAM(%r1) # must save oucp (was 8) - std %r4,SF_PARAM+8(%r1) # must save ucp (was 12) - bl ._getcontext # getcontext(oucp) - nop - cmpdi %r3,0 - bne 1f - ld %r11,SF_PARAM(%r1) # load oucp for adjustment - ld %r0,SF_SZ+SF_LR(%r1) # get LR back - std %r0,mc_off+34*8(%r11) # pc <- lr - la %r0,16(%r1) - std %r0,mc_off+1*8(%r11) # adjust sp - ld %r3,SF_PARAM+8(%r1) # load ucp - bl PIC_PLT(_C_LABEL(setcontext)) # setcontext(ucp) - nop -1: - ld %r0,SF_SZ+SF_LR(%r1) - mtlr %r0 - la %r1,SF_SZ(%r1) - blr diff --git a/lib/libc/arch/powerpc64/gen/syncicache.c b/lib/libc/arch/powerpc64/gen/syncicache.c deleted file mode 100644 index 3a3b220ee..000000000 --- a/lib/libc/arch/powerpc64/gen/syncicache.c +++ /dev/null @@ -1,137 +0,0 @@ -/* $NetBSD: syncicache.c,v 1.2 2012/11/24 07:16:04 christos Exp $ */ - -/* - * Copyright (C) 1995-1997, 1999 Wolfgang Solfrank. - * Copyright (C) 1995-1997, 1999 TooLs GmbH. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by TooLs GmbH. - * 4. The name of TooLs GmbH may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY TOOLS GMBH ``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 TOOLS GMBH 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 -#if defined(_KERNEL) || defined(_STANDALONE) -#include -#include -#include -#endif -#include - -#include - - -#if defined(_STANDALONE) -#ifndef CACHELINESIZE -#error "Must know the size of a cache line" -#endif -static struct cache_info _cache_info = { - CACHELINESIZE, - CACHELINESIZE, - CACHELINESIZE, - CACHELINESIZE -}; -#define CACHEINFO _cache_info -#elif defined(_KERNEL) -#define CACHEINFO (curcpu()->ci_ci) -#else -#include - -size_t __getcachelinesize (void); - -static int _cachelinesize = 0; - -static struct cache_info _cache_info; -#define CACHEINFO _cache_info - -size_t -__getcachelinesize(void) -{ - static int cachemib[] = { CTL_MACHDEP, CPU_CACHELINE }; - static int cacheinfomib[] = { CTL_MACHDEP, CPU_CACHEINFO }; - size_t clen = sizeof(_cache_info); - - if (_cachelinesize) - return _cachelinesize; - - if (sysctl(cacheinfomib, (u_int)__arraycount(cacheinfomib), - &_cache_info, &clen, NULL, 0) == 0) { - _cachelinesize = _cache_info.dcache_line_size; - return _cachelinesize; - } - - /* Try older deprecated sysctl */ - clen = sizeof(_cachelinesize); - if (sysctl(cachemib, (u_int)__arraycount(cachemib), - &_cachelinesize, &clen, NULL, 0) < 0 || !_cachelinesize) - abort(); - - _cache_info.dcache_size = _cachelinesize; - _cache_info.dcache_line_size = _cachelinesize; - _cache_info.icache_size = _cachelinesize; - _cache_info.icache_line_size = _cachelinesize; - - /* If there is no cache, indicate we have issued the sysctl. */ - if (!_cachelinesize) - _cachelinesize = 1; - - return _cachelinesize; -} -#endif - -void -__syncicache(void *from, size_t len) -{ - size_t l, off; - size_t linesz; - char *p; - -#if !defined(_KERNEL) && !defined(_STANDALONE) - if (!_cachelinesize) - __getcachelinesize(); -#endif - - if (CACHEINFO.dcache_size > 0) { - linesz = CACHEINFO.dcache_line_size; - off = (uintptr_t)from & (linesz - 1); - l = (len + off + linesz - 1) & ~(linesz - 1); - p = (char *)from - off; - do { - __asm volatile ("dcbst 0,%0" :: "r"(p)); - p += linesz; - } while ((l -= linesz) != 0); - } - __asm volatile ("sync"); - - if (CACHEINFO.icache_size > 0 ) { - linesz = CACHEINFO.icache_line_size; - off = (uintptr_t)from & (linesz - 1); - l = (len + off + linesz - 1) & ~(linesz - 1); - p = (char *)from - off; - do { - __asm volatile ("icbi 0,%0" :: "r"(p)); - p += linesz; - } while ((l -= linesz) != 0); - } - __asm volatile ("sync; isync"); -} diff --git a/lib/libc/arch/powerpc64/genassym.cf b/lib/libc/arch/powerpc64/genassym.cf deleted file mode 100644 index 86ba53855..000000000 --- a/lib/libc/arch/powerpc64/genassym.cf +++ /dev/null @@ -1,45 +0,0 @@ -# $NetBSD: genassym.cf,v 1.1 2014/08/23 02:24:22 matt Exp $ - -# -# Copyright (c) 2001 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include -include -include - -include - -define UC_GREGS_R1 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R1]) -define UC_GREGS_R3 offsetof(ucontext_t, uc_mcontext.__gregs[_REG_R3]) -define UC_GREGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC]) - -define SIG_BLOCK SIG_BLOCK -define SIG_SETMASK SIG_SETMASK diff --git a/lib/libc/arch/powerpc64/net/Makefile.inc b/lib/libc/arch/powerpc64/net/Makefile.inc deleted file mode 100644 index 74baf8322..000000000 --- a/lib/libc/arch/powerpc64/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/07/01 16:37:20 ross Exp $ - -SRCS+= htonl.c htons.c ntohl.c ntohs.c diff --git a/lib/libc/arch/powerpc64/stdlib/Makefile.inc b/lib/libc/arch/powerpc64/stdlib/Makefile.inc deleted file mode 100644 index f12f78d35..000000000 --- a/lib/libc/arch/powerpc64/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2009/07/31 20:40:00 dsl Exp $ diff --git a/lib/libc/arch/powerpc64/string/Makefile.inc b/lib/libc/arch/powerpc64/string/Makefile.inc deleted file mode 100644 index b724ef5f9..000000000 --- a/lib/libc/arch/powerpc64/string/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 2009/08/11 17:30:43 dsl Exp $ - -SRCS+= bzero.S ffs.S strlen.S -NO_SRCS+= memset.S diff --git a/lib/libc/arch/powerpc64/string/bzero.S b/lib/libc/arch/powerpc64/string/bzero.S deleted file mode 100644 index 096725fdf..000000000 --- a/lib/libc/arch/powerpc64/string/bzero.S +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: bzero.S,v 1.4 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Ross Harvey. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - - .file "bzero.c" -ENTRY(bzero) - mr 5, 4 # translate to memcpy signature - li 4, 0 # add missing memcpy param -ENTRY(memset) - cmpldi 7, 5, 7 # only optimize if len >= 8 - mr 9, 3 - ble 7, 2f - rldicl. 0, 3, 0, 61 # only optimize if aligned - beq 0, 4f -2: - cmpdi 7, 5, 0 - beqlr 7 -3: - mtctr 5 - rldicl 0, 4, 0, 56 - .p2align 4,, 15 -2: - stb 0, 0(9) # byte-at-a-time loop - addi 9, 9, 1 - bdnz 2b - blr # done -4: - rldicl 4, 4, 0, 56 # construct parallel store - cmpldi 7, 5, 31 - mr 10, 3 - sldi 0, 4, 8 - or 0, 0, 4 - sldi 9, 0, 16 - or 0, 0, 9 - sldi 11, 0, 32 - or 0, 0, 11 - ble 7, 5f - addi 9, 5, -32 - srdi 9, 9, 5 - addi 9, 9, 1 - mtctr 9 - .p2align 4,, 15 -2: - std 0, 0(10) # 8-way + unrolled store loop - std 0, 8(10) - addi 5, 5, -32 # schedule count decrement - std 0, 16(10) - std 0, 24(10) - addi 10, 10, 32 - bdnz 2b - cmpldi 7, 5, 7 - ble 7, 8f -5: - addi 9, 5, -8 - srdi 9, 9, 3 - addi 9, 9, 1 - mtctr 9 - .p2align 4,, 15 -14: - std 0, 0(10) # 8-way not-unrolled loop - addi 5, 5, -8 - addi 10, 10, 8 - bdnz 14b -8: - cmpdi 7, 5, 0 - mr 9, 10 - bne 7, 3b - blr - .long 0 - .byte 0, 0, 0, 0, 0, 0, 0, 0 - .size .memset, .-.memset diff --git a/lib/libc/arch/powerpc64/sys/Makefile.inc b/lib/libc/arch/powerpc64/sys/Makefile.inc deleted file mode 100644 index 7d5f09434..000000000 --- a/lib/libc/arch/powerpc64/sys/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/07/07 06:40:45 ross Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S diff --git a/lib/libc/arch/powerpc64/sys/__clone.S b/lib/libc/arch/powerpc64/sys/__clone.S deleted file mode 100644 index 552aaae64..000000000 --- a/lib/libc/arch/powerpc64/sys/__clone.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: __clone.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */ - -/*- - * Copyright (c) 2001 Tsubai Masanari. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - /* - * Sanity checks: func and stack may not be NULL. - */ - cmpptri %r3,0 - beq 1f - cmpptri %r4,0 - beq 1f - - mr %r7,%r3 /* Save fn in r7. */ - mr %r3,%r5 - _DOSYSCALL(__clone) /* (flags, stack) */ - bso 2f /* error... */ - - cmpptri %r3,0 - bnelr /* We're the parent, just return. */ - - mtlr %r7 /* fn */ - mr %r3,%r6 /* arg */ - blrl /* Call the clone's entry point. */ - - bl PIC_PLT(_C_LABEL(_exit)) - nop - -1: - li %r3,EINVAL -2: - BRANCH_TO_CERROR() -END(__clone) diff --git a/lib/libc/arch/powerpc64/sys/__sigaction14_sigtramp.c b/lib/libc/arch/powerpc64/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 092c2bc27..000000000 --- a/lib/libc/arch/powerpc64/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) -#ifdef __LIBC12_SOURCE__ -extern const int __sigtramp_sigcontext_1[] - __weak_reference(__sigtramp_sigcontext_1); -#endif - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specificed or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/powerpc64/sys/__sigtramp2.S b/lib/libc/arch/powerpc64/sys/__sigtramp2.S deleted file mode 100644 index cf57c1bd3..000000000 --- a/lib/libc/arch/powerpc64/sys/__sigtramp2.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.4 2014/08/23 02:24:22 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * On entry to user space, stack and registers look like: - * - * r3 signal number - * r4 pointer to siginfo structure - * r5 pointer to ucontext structure - * r30 pointer to ucontext structure - * srr0 address of handler - * lr address of this trampoline - * - */ -ENTRY_NOPROFILE(__sigtramp_siginfo_2) - mr %r3,%r30 /* restore ucontext pointer */ - _DOSYSCALL(setcontext) /* restore machine state */ - _DOSYSCALL(exit) /* or exit with errno if failed */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/powerpc64/sys/__syscall.S b/lib/libc/arch/powerpc64/sys/__syscall.S deleted file mode 100644 index b2a58da86..000000000 --- a/lib/libc/arch/powerpc64/sys/__syscall.S +++ /dev/null @@ -1,22 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - - .text - .p2align 2 -ENTRY(__syscall) - mr %r0,%r3 /* syscall number */ - mr %r3,%r4 - mr %r4,%r5 - mr %r5,%r6 - mr %r6,%r7 - mr %r7,%r8 - mr %r8,%r9 - mr %r9,%r10 - ldreg %r10,(2*__SIZEOF_POINTER__)(%r1) /* final argument is on the stack */ - sc - bnslr - BRANCH_TO_CERROR() -END(__syscall) - -STRONG_ALIAS(syscall, __syscall) diff --git a/lib/libc/arch/powerpc64/sys/__vfork14.S b/lib/libc/arch/powerpc64/sys/__vfork14.S deleted file mode 100644 index 605cafe10..000000000 --- a/lib/libc/arch/powerpc64/sys/__vfork14.S +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */ - -/* - * pid = vfork(); - * - * r4 == 0 in parent process, 1 in child process. - * r3 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -SYSCALL(__vfork14) - addi %r4,%r4,-1 # from 1 to 0 in child, 0 to -1 in parent - and %r3,%r3,%r4 # return 0 in child, pid in parent - blr -END(__vfork14) diff --git a/lib/libc/arch/powerpc64/sys/brk.S b/lib/libc/arch/powerpc64/sys/brk.S deleted file mode 100644 index eff339d4b..000000000 --- a/lib/libc/arch/powerpc64/sys/brk.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: brk.S,v 1.5 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - - - .hidden _C_LABEL(__curbrk) - .globl _C_LABEL(__curbrk) - .hidden _C_LABEL(__minbrk) - .globl _C_LABEL(__minbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data - .p2align 3 -_C_LABEL(__minbrk): - .quad _C_LABEL(_end) -_C_LABEL(__curbrk): - .quad _C_LABEL(_end) - -ENTRY(_brk) - addis %r9,%r2,_C_LABEL(__minbrk)@toc@ha - ldptru %r5,_C_LABEL(__minbrk)@toc@l(%r9) - cmpptrl %r5,%r3 # if (__minbrk <= r3) -#ifdef __PPC_ISEL__ - iselgt %r3,%r5,%r3 -#else - bgt 0f - mr %r5,%r3 # r5 = r3 -0: - mr %r3,%r5 # new break value -#endif - _DOSYSCALL(break) # assume that r5 is preserved - bso 1f - stptr %r5,__SIZEOF_POINTER__(%r9) - blr # return 0 - -1: - BRANCH_TO_CERROR() -END(_brk) diff --git a/lib/libc/arch/powerpc64/sys/cerror.S b/lib/libc/arch/powerpc64/sys/cerror.S deleted file mode 100644 index 25940a154..000000000 --- a/lib/libc/arch/powerpc64/sys/cerror.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: cerror.S,v 1.7 2015/01/12 02:48:20 dennis Exp $ */ - -/* Now inlined in the syscall stubs. Keep code for a while for mind changes. */ - -#if 0 -#include -#include "SYS.h" - -#ifndef _REENTRANT - .globl _C_LABEL(errno) -#endif -#ifdef __PIC__ - .protected _C_LABEL(__cerror) -#endif - -ENTRY(__cerror) -#ifdef _REENTRANT - mflr %r0 - streg %r0,SF_LR(%r1) - streg %r31,-8(%r1) - stptru %r1,-(SF_SZ+16)(%r1) # allocate new stack frame - mr %r31,%r3 # stash away in callee-saved register - bl PIC_PLT(_C_LABEL(__errno)) - nop - stint %r31,0(%r3) - - addi %r1,%r1,(SF_SZ+16) - ldreg %r31,-8(%r1) - ldreg %r0,SF_LR(%r1) - mtlr %r0 -#else - lwz %r4,_C_LABEL(errno)@got(%r2) - stw %r3,0(%r4) -#endif /* _REENTRANT */ - li %r3,-1 - li %r4,-1 - blr -END(__cerror) -#endif /* 0 */ diff --git a/lib/libc/arch/powerpc64/sys/exect.S b/lib/libc/arch/powerpc64/sys/exect.S deleted file mode 100644 index 197230950..000000000 --- a/lib/libc/arch/powerpc64/sys/exect.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: exect.S,v 1.1 2006/07/01 16:37:20 ross Exp $ */ - -#include "SYS.h" - -PSEUDO(exect,execve) diff --git a/lib/libc/arch/powerpc64/sys/fork.S b/lib/libc/arch/powerpc64/sys/fork.S deleted file mode 100644 index 7aec22035..000000000 --- a/lib/libc/arch/powerpc64/sys/fork.S +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: fork.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */ - -/* - * pid = fork(); - * - * r4 == 0 in parent process, 1 in child process. - * r3 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -_SYSCALL(__fork,fork) - addi %r4,%r4,-1 # from 1 to 0 in child, 0 to -1 in parent - and %r3,%r3,%r4 # return 0 in child, pid in parent - blr -END(__fork) diff --git a/lib/libc/arch/powerpc64/sys/getcontext.S b/lib/libc/arch/powerpc64/sys/getcontext.S deleted file mode 100644 index 3cb1e323d..000000000 --- a/lib/libc/arch/powerpc64/sys/getcontext.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.5 2014/08/23 02:24:22 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getcontext.S,v 1.5 2014/08/23 02:24:22 matt Exp $") -#endif /* LIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -ENTRY(_getcontext) - mr %r5,%r3 # must save pointer - _DOSYSCALL(getcontext) - bso 1f - mflr %r4 - stptr %r4,UC_GREGS_PC(%r5) # saved pc <- lr - stint %r3,UC_GREGS_R3(%r5) # arrange for return value 0 - blr -1: - BRANCH_TO_CERROR() -END(_getcontext) diff --git a/lib/libc/arch/powerpc64/sys/pipe.S b/lib/libc/arch/powerpc64/sys/pipe.S deleted file mode 100644 index 2f66db9c6..000000000 --- a/lib/libc/arch/powerpc64/sys/pipe.S +++ /dev/null @@ -1,19 +0,0 @@ -/* $NetBSD: pipe.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe) - mr %r5,%r3 # save pointer - _DOSYSCALL(pipe) # assume, that r5 is kept - bso 1f - stint %r3,0(%r5) # success, store fds - stint %r4,4(%r5) - li %r3,0 - blr # and return 0 -1: - BRANCH_TO_CERROR() -END(_pipe) diff --git a/lib/libc/arch/powerpc64/sys/ptrace.S b/lib/libc/arch/powerpc64/sys/ptrace.S deleted file mode 100644 index 582f153a9..000000000 --- a/lib/libc/arch/powerpc64/sys/ptrace.S +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.3 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - -ENTRY(ptrace) -#ifdef _REENTRANT - mflr %r0 - streg %r0,SZREG(%r1) - stregu %r1,-(SZREG*6)(%r1) - streg %r3,(SZREG*2)(%r1) - streg %r4,(SZREG*3)(%r1) - streg %r5,(SZREG*4)(%r1) - streg %r6,(SZREG*5)(%r1) - - bl PIC_PLT(_C_LABEL(__errno)) - nop - li %r7,0 - stint %r7,0(%r3) - - ldreg %r3,(SZREG*2)(%r1) - ldreg %r4,(SZREG*3)(%r1) - ldreg %r5,(SZREG*4)(%r1) - ldreg %r6,(SZREG*5)(%r1) - addi %r1,%r1,SZREG*6 - ldreg %r0,SZREG(%r1) - mtlr %r0 -#else - .pushsection ".toc","aw" -.Lerrno: - .tc errno[TC], errno - .popsection - addis %r7,%r2,_C_LABEL(errno)@toc@ha - ldptr %r7,_C_LABEL(errno)@toc@l(%r7) - li %r8,0 - stint %r8,0(%r7) - mtlr 0 -#endif /* _REENTRANT */ - _DOSYSCALL(ptrace) - bso 1f - blr -1: - BRANCH_TO_CERROR() -END(ptrace) diff --git a/lib/libc/arch/powerpc64/sys/sbrk.S b/lib/libc/arch/powerpc64/sys/sbrk.S deleted file mode 100644 index 541eb7ce3..000000000 --- a/lib/libc/arch/powerpc64/sys/sbrk.S +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.5 2014/08/23 02:24:22 matt Exp $ */ - -#include "SYS.h" - - .hidden _C_LABEL(__curbrk) - .globl _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - -ENTRY(_sbrk) - addis %r8,%r2,_C_LABEL(__curbrk)@toc@ha - ldptru %r6,_C_LABEL(__curbrk)@toc@l(%r8) - add %r3,%r3,%r6 - mr %r7,%r3 # r7 = new break - _DOSYSCALL(break) # break(new_break) - bso 1f - mr %r3,%r6 # set return value - stptr %r7,0(%r8) # record new break - blr -1: - BRANCH_TO_CERROR() -END(_sbrk) diff --git a/lib/libc/arch/powerpc64/sys/shmat.S b/lib/libc/arch/powerpc64/sys/shmat.S deleted file mode 100644 index 92f9beccc..000000000 --- a/lib/libc/arch/powerpc64/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2006/07/01 16:37:20 ross Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/powerpc64/sys/syscall.S b/lib/libc/arch/powerpc64/sys/syscall.S deleted file mode 100644 index 6624d8b39..000000000 --- a/lib/libc/arch/powerpc64/sys/syscall.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: syscall.S,v 1.2 2014/08/23 02:24:22 matt Exp $ */ - -/* aliased to __syscall */ diff --git a/lib/libc/arch/riscv/Makefile.inc b/lib/libc/arch/riscv/Makefile.inc deleted file mode 100644 index 43edc8aa1..000000000 --- a/lib/libc/arch/riscv/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S - -CPPFLAGS+= -I. - -.if ${MKSOFTFLOAT} != "no" -.include -.endif diff --git a/lib/libc/arch/riscv/SYS.h b/lib/libc/arch/riscv/SYS.h deleted file mode 100644 index dacded557..000000000 --- a/lib/libc/arch/riscv/SYS.h +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: SYS.h,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#define SYSTRAP(x) li t6,SYS_ ## x; scall -#define JUMP_TO_CERROR() j _C_LABEL(__cerror) - -/* - * Do a syscall that cannot fail (sync, get{p,u,g,eu,eg)id) - */ -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -/* - * Do a normal syscall. - */ -#define RSYSCALL(x) \ - PSEUDO(x,x) - -/* - * Do a syscall that has an internal name and a weak external alias. - */ -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong) ;\ - PSEUDO(strong,weak) - -/* - * Do a renamed or pseudo syscall (e.g., _exit()), where the entrypoint - * and syscall name are not the same. - */ -#define PSEUDO_NOERROR(x,y) \ -ENTRY(x); ;\ - SYSTRAP(y) ;\ - ret /* error */ ;\ - ret /* success */ ;\ - END(x) - -#define PSEUDO(x,y) \ -ENTRY(x); ;\ - SYSTRAP(y) ;\ - JUMP_TO_CERROR() /* error */ ;\ - ret /* success */ ;\ - END(x) diff --git a/lib/libc/arch/riscv/gdtoa/Makefile.inc b/lib/libc/arch/riscv/gdtoa/Makefile.inc deleted file mode 100644 index d88c421e9..000000000 --- a/lib/libc/arch/riscv/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/riscv/gdtoa/arith.h b/lib/libc/arch/riscv/gdtoa/arith.h deleted file mode 100644 index 0b455d6c6..000000000 --- a/lib/libc/arch/riscv/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -#define IEEE_LITTLE_ENDIAN diff --git a/lib/libc/arch/riscv/gdtoa/gd_qnan.h b/lib/libc/arch/riscv/gdtoa/gd_qnan.h deleted file mode 100644 index 8ced8a42d..000000000 --- a/lib/libc/arch/riscv/gdtoa/gd_qnan.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -#define f_QNAN 0x7fe00000 -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ffc0000 diff --git a/lib/libc/arch/riscv/gen/Makefile.inc b/lib/libc/arch/riscv/gen/Makefile.inc deleted file mode 100644 index fd329858c..000000000 --- a/lib/libc/arch/riscv/gen/Makefile.inc +++ /dev/null @@ -1,29 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ - -SRCS+= __setjmp14.S __sigsetjmp14.S _setjmp.S -SRCS+= bswap16.c bswap32.c bswap64.c -SRCS+= flt_rounds.c -SRCS+= _lwp.c makecontext.c resumecontext.c swapcontext.S - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c -SRCS+= fabs_ieee754.c - -SRCS+= nanf.c - -.if (${MKSOFTFLOAT} == "no") -SRCS+= fpgetround.c fpsetround.c fpgetmask.c fpsetmask.c -SRCS+= fpgetsticky.c fpsetsticky.c -.endif - -CPPFLAGS._lwp.c += -D_LIBC_SOURCE - -LSRCS.powerpc.gen=Lint_swapcontext.c -LSRCS+= ${LSRCS.powerpc.gen} -DPSRCS+= ${LSRCS.powerpc.gen} -CLEANFILES+= ${LSRCS.powerpc.gen} diff --git a/lib/libc/arch/riscv/gen/__setjmp14.S b/lib/libc/arch/riscv/gen/__setjmp14.S deleted file mode 100644 index 802a953ae..000000000 --- a/lib/libc/arch/riscv/gen/__setjmp14.S +++ /dev/null @@ -1,107 +0,0 @@ -/* $NetBSD: __setjmp14.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: __setjmp14.S,v 1.2 2015/03/27 06:44:28 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - li a1, 1 - REG_S a1, JB_MAGIC(a0) /* indicate sigmask */ - REG_S ra, JB_RA(a0) /* save return address */ - REG_S sp, JB_SP(a0) /* save stack pointer */ - REG_S gp, JB_GP(a0) /* save global pointer */ - REG_S tp, JB_TP(a0) /* save thread pointer */ - REG_S s0, JB_S0(a0) /* save callee saved register */ - REG_S s1, JB_S1(a0) /* save callee saved register */ - REG_S s2, JB_S2(a0) /* save callee saved register */ - REG_S s3, JB_S3(a0) /* save callee saved register */ - REG_S s4, JB_S4(a0) /* save callee saved register */ - REG_S s5, JB_S5(a0) /* save callee saved register */ - REG_S s6, JB_S6(a0) /* save callee saved register */ - REG_S s7, JB_S7(a0) /* save callee saved register */ - REG_S s8, JB_S8(a0) /* save callee saved register */ - REG_S s9, JB_S9(a0) /* save callee saved register */ - REG_S s10, JB_S10(a0) /* save callee saved register */ - REG_S s11, JB_S11(a0) /* save callee saved register */ -#ifndef _SOFT_FLOAT - frcsr t2 /* get FSCR */ - REG_S t2, JB_FCSR(a0) /* save it */ - fsd fs0, JB_FS0(a0) /* save callee saved register */ - fsd fs1, JB_FS1(a0) /* save callee saved register */ - fsd fs2, JB_FS2(a0) /* save callee saved register */ - fsd fs3, JB_FS3(a0) /* save callee saved register */ - fsd fs4, JB_FS4(a0) /* save callee saved register */ - fsd fs5, JB_FS5(a0) /* save callee saved register */ - fsd fs6, JB_FS6(a0) /* save callee saved register */ - fsd fs7, JB_FS7(a0) /* save callee saved register */ - fsd fs8, JB_FS8(a0) /* save callee saved register */ - fsd fs9, JB_FS9(a0) /* save callee saved register */ - fsd fs10, JB_FS10(a0) /* save callee saved register */ - fsd fs11, JB_FS11(a0) /* save callee saved register */ -#endif - - addi a2, a0, JB_SIGMASK /* &sigmask */ - li a1, 0 - li a0, SIG_BLOCK - SYSTRAP(__sigprocmask14) /* assume no error */ - li a0, 0 /* success */ /* indicate success */ - ret /* error */ /* return */ -END(__setjmp14) - -ENTRY(__longjmp14) - REG_L ra, JB_RA(a0) /* restore return address */ - REG_L sp, JB_SP(a0) /* restore stack pointer */ - REG_L gp, JB_GP(a0) /* restore global pointer */ - #REG_L tp, JB_TP(a0) /* restore thread pointer */ - REG_L s0, JB_S0(a0) /* restore callee saved register */ - REG_L s1, JB_S1(a0) /* restore callee saved register */ - REG_L s2, JB_S2(a0) /* restore callee saved register */ - REG_L s3, JB_S3(a0) /* restore callee saved register */ - REG_L s4, JB_S4(a0) /* restore callee saved register */ - REG_L s5, JB_S5(a0) /* restore callee saved register */ - REG_L s6, JB_S6(a0) /* restore callee saved register */ - REG_L s7, JB_S7(a0) /* restore callee saved register */ - REG_L s8, JB_S8(a0) /* restore callee saved register */ - REG_L s9, JB_S9(a0) /* restore callee saved register */ - REG_L s10, JB_S10(a0) /* restore callee saved register */ - REG_L s11, JB_S11(a0) /* restore callee saved register */ -#ifndef _SOFT_FLOAT - REG_L t2, JB_FCSR(a0) /* get it */ - fscsr t2 /* restore FSCR */ - fld fs0, JB_FS0(a0) /* restore callee saved register */ - fld fs1, JB_FS1(a0) /* restore callee saved register */ - fld fs2, JB_FS2(a0) /* restore callee saved register */ - fld fs3, JB_FS3(a0) /* restore callee saved register */ - fld fs4, JB_FS4(a0) /* restore callee saved register */ - fld fs5, JB_FS5(a0) /* restore callee saved register */ - fld fs6, JB_FS6(a0) /* restore callee saved register */ - fld fs7, JB_FS7(a0) /* restore callee saved register */ - fld fs8, JB_FS8(a0) /* restore callee saved register */ - fld fs9, JB_FS9(a0) /* restore callee saved register */ - fld fs10, JB_FS10(a0) /* restore callee saved register */ - fld fs11, JB_FS11(a0) /* restore callee saved register */ -#endif - move t1, a1 /* save return value */ - li a2, 0 - addi a1, a0, JB_SIGMASK /* &sigmask */ - li a0, SIG_SETMASK - SYSTRAP(__sigprocmask14) /* assume no error */ - nop /* error */ - li a0, 1 /* success */ /* default return value */ - beqz t1, 1f /* test return value */ - move a0, t1 /* use it if not 0 */ -1: ret -END(__longjmp14) diff --git a/lib/libc/arch/riscv/gen/__sigsetjmp14.S b/lib/libc/arch/riscv/gen/__sigsetjmp14.S deleted file mode 100644 index 4365ac696..000000000 --- a/lib/libc/arch/riscv/gen/__sigsetjmp14.S +++ /dev/null @@ -1,21 +0,0 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.2 2015/03/27 23:23:14 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: __sigsetjmp14.S,v 1.2 2015/03/27 23:23:14 matt Exp $") -#endif - -ENTRY(__sigsetjmp14) - bnez a1, 1f - tail PLT(_C_LABEL(_setjmp)) -1: tail PLT(_C_LABEL(__setjmp14)) -END(__sigsetjmp14) - -ENTRY(__siglongjmp14) - REG_L a2, JB_MAGIC(a0) - bnez a2, 1f - tail PLT(_C_LABEL(_longjmp)) -1: tail PLT(_C_LABEL(__longjmp14)) -END(__siglongjmp14) diff --git a/lib/libc/arch/riscv/gen/_lwp.c b/lib/libc/arch/riscv/gen/_lwp.c deleted file mode 100644 index 63c8ab6e7..000000000 --- a/lib/libc/arch/riscv/gen/_lwp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Allen Briggs for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), void *arg, - void *tcb, caddr_t stack_base, size_t stack_size) -{ - uintptr_t sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - sp = (uintptr_t)stack_base + stack_size; - sp -= STACK_ALIGNBYTES + 1; - sp &= ~STACK_ALIGNBYTES; - - u->uc_mcontext.__gregs[_REG_RV] = (uintptr_t)arg; /* arg1 */ - u->uc_mcontext.__gregs[_REG_SP] = (uintptr_t)sp; /* stack */ - u->uc_mcontext.__gregs[_REG_RA] = (uintptr_t)_lwp_exit; /* RA */ - u->uc_mcontext.__gregs[_REG_PC] = (uintptr_t)start; /* PC */ - u->uc_mcontext.__gregs[_REG_TP] = - (uintptr_t)tcb + TLS_TP_OFFSET + sizeof(struct tls_tcb); -} diff --git a/lib/libc/arch/riscv/gen/_setjmp.S b/lib/libc/arch/riscv/gen/_setjmp.S deleted file mode 100644 index 6d430c52f..000000000 --- a/lib/libc/arch/riscv/gen/_setjmp.S +++ /dev/null @@ -1,124 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: _setjmp.S,v 1.2 2015/03/27 06:44:28 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - REG_S zero, JB_MAGIC(a0) /* indicate no sigmask */ - REG_S ra, JB_RA(a0) /* save return address */ - REG_S sp, JB_SP(a0) /* save stack pointer */ - REG_S gp, JB_GP(a0) /* save global pointer */ - REG_S tp, JB_TP(a0) /* save thread pointer */ - REG_S s0, JB_S0(a0) /* save callee saved register */ - REG_S s1, JB_S1(a0) /* save callee saved register */ - REG_S s2, JB_S2(a0) /* save callee saved register */ - REG_S s3, JB_S3(a0) /* save callee saved register */ - REG_S s4, JB_S4(a0) /* save callee saved register */ - REG_S s5, JB_S5(a0) /* save callee saved register */ - REG_S s6, JB_S6(a0) /* save callee saved register */ - REG_S s7, JB_S7(a0) /* save callee saved register */ - REG_S s8, JB_S8(a0) /* save callee saved register */ - REG_S s9, JB_S9(a0) /* save callee saved register */ - REG_S s10, JB_S10(a0) /* save callee saved register */ - REG_S s11, JB_S11(a0) /* save callee saved register */ -#ifndef _SOFT_FLOAT - frcsr t2 /* get FSCR */ - REG_S t2, JB_FCSR(a0) /* save it */ - fsd fs0, JB_FS0(a0) /* save callee saved register */ - fsd fs1, JB_FS1(a0) /* save callee saved register */ - fsd fs2, JB_FS2(a0) /* save callee saved register */ - fsd fs3, JB_FS3(a0) /* save callee saved register */ - fsd fs4, JB_FS4(a0) /* save callee saved register */ - fsd fs5, JB_FS5(a0) /* save callee saved register */ - fsd fs6, JB_FS6(a0) /* save callee saved register */ - fsd fs7, JB_FS7(a0) /* save callee saved register */ - fsd fs8, JB_FS8(a0) /* save callee saved register */ - fsd fs9, JB_FS9(a0) /* save callee saved register */ - fsd fs10, JB_FS10(a0) /* save callee saved register */ - fsd fs11, JB_FS11(a0) /* save callee saved register */ -#endif - li a0, 0 /* indicate success */ - ret /* return */ -END(_setjmp) - -ENTRY(_longjmp) - REG_L ra, JB_RA(a0) /* save return address */ - REG_L sp, JB_SP(a0) /* save stack pointer */ - REG_L gp, JB_GP(a0) /* save global pointer */ - #REG_L tp, JB_TP(a0) /* save thread pointer */ - REG_L s0, JB_S0(a0) /* save callee saved register */ - REG_L s1, JB_S1(a0) /* save callee saved register */ - REG_L s2, JB_S2(a0) /* save callee saved register */ - REG_L s3, JB_S3(a0) /* save callee saved register */ - REG_L s4, JB_S4(a0) /* save callee saved register */ - REG_L s5, JB_S5(a0) /* save callee saved register */ - REG_L s6, JB_S6(a0) /* save callee saved register */ - REG_L s7, JB_S7(a0) /* save callee saved register */ - REG_L s8, JB_S8(a0) /* save callee saved register */ - REG_L s9, JB_S9(a0) /* save callee saved register */ - REG_L s10, JB_S10(a0) /* save callee saved register */ - REG_L s11, JB_S11(a0) /* save callee saved register */ -#ifndef _SOFT_FLOAT - REG_L t2, JB_FCSR(a0) /* get it */ - fscsr t2 /* restore FSCR */ - fld fs0, JB_FS0(a0) /* restore callee saved register */ - fld fs1, JB_FS1(a0) /* restore callee saved register */ - fld fs2, JB_FS2(a0) /* restore callee saved register */ - fld fs3, JB_FS3(a0) /* restore callee saved register */ - fld fs4, JB_FS4(a0) /* restore callee saved register */ - fld fs5, JB_FS5(a0) /* restore callee saved register */ - fld fs6, JB_FS6(a0) /* restore callee saved register */ - fld fs7, JB_FS7(a0) /* restore callee saved register */ - fld fs8, JB_FS8(a0) /* restore callee saved register */ - fld fs9, JB_FS9(a0) /* restore callee saved register */ - fld fs10, JB_FS10(a0) /* restore callee saved register */ - fld fs11, JB_FS11(a0) /* restore callee saved register */ -#endif - li a0, 1 /* default return value */ - beqz a1, 1f /* test return value */ - move a0, a1 /* use it if not 0 */ -1: ret -END(_longjmp) diff --git a/lib/libc/arch/riscv/gen/flt_rounds.c b/lib/libc/arch/riscv/gen/flt_rounds.c deleted file mode 100644 index a337f4192..000000000 --- a/lib/libc/arch/riscv/gen/flt_rounds.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.2 2015/03/19 21:22:59 joerg Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.2 2015/03/19 21:22:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -static const int rounding_map = - (1 << (FP_RN * 2)) /* round to nearest */ - | (0 << (FP_RZ * 2)) /* round to zero */ - | (2 << (FP_RP * 2)) /* round to positive infinity */ - | (3 << (FP_RM * 2)); /* round to negative infinity */ - -int -__flt_rounds(void) -{ - return (rounding_map >> (fpgetround() * 2)) & 3; -} diff --git a/lib/libc/arch/riscv/gen/fpgetmask.c b/lib/libc/arch/riscv/gen/fpgetmask.c deleted file mode 100644 index 790d6f22c..000000000 --- a/lib/libc/arch/riscv/gen/fpgetmask.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -fp_except -fpgetmask(void) -{ -#if FCSR_FMASK == 0 - return 0; -#else - return __SHIFTOUT(riscvreg_fcsr_read(), FCSR_FMASK); -#endif -} diff --git a/lib/libc/arch/riscv/gen/fpgetround.c b/lib/libc/arch/riscv/gen/fpgetround.c deleted file mode 100644 index 2a98db5d8..000000000 --- a/lib/libc/arch/riscv/gen/fpgetround.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -fp_rnd -fpgetround(void) -{ - return __SHIFTOUT(riscvreg_fcsr_read(), FCSR_FRM); -} diff --git a/lib/libc/arch/riscv/gen/fpgetsticky.c b/lib/libc/arch/riscv/gen/fpgetsticky.c deleted file mode 100644 index 017a669d5..000000000 --- a/lib/libc/arch/riscv/gen/fpgetsticky.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -fp_except -fpgetsticky(void) -{ - return __SHIFTOUT(riscvreg_fcsr_read(), FCSR_FFLAGS); -} diff --git a/lib/libc/arch/riscv/gen/fpsetmask.c b/lib/libc/arch/riscv/gen/fpsetmask.c deleted file mode 100644 index f348665e1..000000000 --- a/lib/libc/arch/riscv/gen/fpsetmask.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -fp_except -fpsetmask(fp_except mask) -{ -#if 0 - return __SHIFTOUT(riscvreg_fcsr_write_fmask(__SHIFTIN(mask, FCSR_MASK)), FCSR_FMASK); -#else - return 0; -#endif -} diff --git a/lib/libc/arch/riscv/gen/fpsetround.c b/lib/libc/arch/riscv/gen/fpsetround.c deleted file mode 100644 index 4d4bf8b59..000000000 --- a/lib/libc/arch/riscv/gen/fpsetround.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - return __SHIFTOUT(riscvreg_fcsr_write_frm(__SHIFTIN(rnd_dir, FCSR_FRM)), FCSR_FRM); -} diff --git a/lib/libc/arch/riscv/gen/fpsetsticky.c b/lib/libc/arch/riscv/gen/fpsetsticky.c deleted file mode 100644 index bef211416..000000000 --- a/lib/libc/arch/riscv/gen/fpsetsticky.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Dan Winship. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -fpsetsticky(fp_except mask) -{ - return __SHIFTOUT(riscvreg_fcsr_write_fflags(__SHIFTIN(mask, FCSR_FFLAGS)), FCSR_FFLAGS); -} diff --git a/lib/libc/arch/riscv/gen/makecontext.c b/lib/libc/arch/riscv/gen/makecontext.c deleted file mode 100644 index ac1529abb..000000000 --- a/lib/libc/arch/riscv/gen/makecontext.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#if __STDC__ -#include -#else -#include -#endif - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - long *sp; - int i; - va_list ap; - - /* LINTED uintptr_t is safe */ - sp = (long *) - ((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - /* LINTED uintptr_t is safe */ - sp -= 1 + (argc > 8 ? argc - 8: 0); /* Make room for call frame. */ - sp = (long *) ((uintptr_t)sp & -16L); /* Align on 16byte boundary. */ - - /* - * Start executing at -- when completes, return to - * <_resumecontext>. - */ - gr[_REG_SP] = (uintptr_t)sp; - gr[_REG_RA] = (uintptr_t)_resumecontext; - gr[_REG_PC] = (uintptr_t)func; - - /* Wipe out stack frame backchain pointer. */ - *sp = 0; - - /* Construct argument list. */ - va_start(ap, argc); - /* Up to the first six arguments are passed in x18-x25 */ - for (i = 0; i < argc && i < 8; i++) - gr[_REG_A0 + i] = va_arg(ap, int); - /* Pass remaining arguments on the stack above the backchain/lr gap. */ - for (sp += 0; i < argc; i++) - *sp++ = va_arg(ap, long); - va_end(ap); -} diff --git a/lib/libc/arch/riscv/gen/nanf.c b/lib/libc/arch/riscv/gen/nanf.c deleted file mode 100644 index 39b64f3cb..000000000 --- a/lib/libc/arch/riscv/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xc0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/riscv/gen/resumecontext.c b/lib/libc/arch/riscv/gen/resumecontext.c deleted file mode 100644 index 3b9fdd777..000000000 --- a/lib/libc/arch/riscv/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/riscv/gen/swapcontext.S b/lib/libc/arch/riscv/gen/swapcontext.S deleted file mode 100644 index 865116ff5..000000000 --- a/lib/libc/arch/riscv/gen/swapcontext.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.3 2015/03/27 23:23:14 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -__RCSID("$NetBSD: swapcontext.S,v 1.3 2015/03/27 23:23:14 matt Exp $") - -#define CALLFRAME_UCP CALLFRAME_S1 -#define CALLFRAME_OUCP CALLFRAME_S0 - -ENTRY(swapcontext) - addi sp, sp, -CALLFRAME_SIZ # adjust stack - REG_S ra, CALLFRAME_RA(sp) # save return address - REG_S a0, CALLFRAME_OUCP(sp) # save oucp - REG_S a1, CALLFRAME_UCP(sp) # save ucp - - call PLT(_C_LABEL(_getcontext)) # getcontext(oucp) - mv t0, a0 # save return value - - REG_L ra, CALLFRAME_RA(sp) # restore return address - REG_L a0, CALLFRAME_UCP(sp) # load ucp - REG_L a1, CALLFRAME_OUCP(sp) # load oucp for adjustment - addi sp, sp, CALLFRAME_SIZ # restore stack - - bnez t0, 1f # error? yes, cleanup - - REG_S ra, UC_GREGS_PC(a1) # pc <- ra - REG_S sp, UC_GREGS_SP(a1) # adjust sp - - tail PLT(_C_LABEL(setcontext)) # setcontext(ucp) - -1: ret # simply return -END(swapcontext) diff --git a/lib/libc/arch/riscv/genassym.cf b/lib/libc/arch/riscv/genassym.cf deleted file mode 100644 index 3e7df0925..000000000 --- a/lib/libc/arch/riscv/genassym.cf +++ /dev/null @@ -1,81 +0,0 @@ -# $NetBSD: genassym.cf,v 1.2 2015/03/27 23:22:20 matt Exp $ - -# -# Copyright (c) 2001 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include -include -include - -include - -define UC_GREGS_SP offsetof(ucontext_t, uc_mcontext.__gregs[_REG_SP]) -define UC_GREGS_RV offsetof(ucontext_t, uc_mcontext.__gregs[_REG_RV]) -define UC_GREGS_PC offsetof(ucontext_t, uc_mcontext.__gregs[_REG_PC]) - -define SIG_BLOCK SIG_BLOCK -define SIG_SETMASK SIG_SETMASK -define SIGINFO_SIZE (sizeof(siginfo_t) + __ALIGNBYTES) & ~__ALIGNBYTES - -define JBLEN _JBLEN * sizeof(_BSD_JBSLOT_T_) -define JB_MAGIC _JB_MAGIC * sizeof(_BSD_JBSLOT_T_) -define JB_RA _JB_RA * sizeof(_BSD_JBSLOT_T_) -define JB_S0 _JB_S0 * sizeof(_BSD_JBSLOT_T_) -define JB_S1 _JB_S1 * sizeof(_BSD_JBSLOT_T_) -define JB_S2 _JB_S2 * sizeof(_BSD_JBSLOT_T_) -define JB_S3 _JB_S3 * sizeof(_BSD_JBSLOT_T_) -define JB_S4 _JB_S4 * sizeof(_BSD_JBSLOT_T_) -define JB_S5 _JB_S5 * sizeof(_BSD_JBSLOT_T_) -define JB_S6 _JB_S6 * sizeof(_BSD_JBSLOT_T_) -define JB_S7 _JB_S7 * sizeof(_BSD_JBSLOT_T_) -define JB_S8 _JB_S8 * sizeof(_BSD_JBSLOT_T_) -define JB_S9 _JB_S9 * sizeof(_BSD_JBSLOT_T_) -define JB_S10 _JB_S10 * sizeof(_BSD_JBSLOT_T_) -define JB_S11 _JB_S11 * sizeof(_BSD_JBSLOT_T_) -define JB_SP _JB_SP * sizeof(_BSD_JBSLOT_T_) -define JB_TP _JB_TP * sizeof(_BSD_JBSLOT_T_) -define JB_GP _JB_GP * sizeof(_BSD_JBSLOT_T_) -define JB_FCSR _JB_FCSR * sizeof(_BSD_JBSLOT_T_) - -define JB_FS0 _JB_FS0 * sizeof(_BSD_JBSLOT_T_) -define JB_FS1 _JB_FS1 * sizeof(_BSD_JBSLOT_T_) -define JB_FS2 _JB_FS2 * sizeof(_BSD_JBSLOT_T_) -define JB_FS3 _JB_FS3 * sizeof(_BSD_JBSLOT_T_) -define JB_FS4 _JB_FS4 * sizeof(_BSD_JBSLOT_T_) -define JB_FS5 _JB_FS5 * sizeof(_BSD_JBSLOT_T_) -define JB_FS6 _JB_FS6 * sizeof(_BSD_JBSLOT_T_) -define JB_FS7 _JB_FS7 * sizeof(_BSD_JBSLOT_T_) -define JB_FS8 _JB_FS8 * sizeof(_BSD_JBSLOT_T_) -define JB_FS9 _JB_FS9 * sizeof(_BSD_JBSLOT_T_) -define JB_FS10 _JB_FS10 * sizeof(_BSD_JBSLOT_T_) -define JB_FS11 _JB_FS11 * sizeof(_BSD_JBSLOT_T_) - -define JB_SIGMASK _JB_SIGMASK * sizeof(_BSD_JBSLOT_T_) diff --git a/lib/libc/arch/riscv/net/Makefile.inc b/lib/libc/arch/riscv/net/Makefile.inc deleted file mode 100644 index 3cb7a1a1c..000000000 --- a/lib/libc/arch/riscv/net/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ diff --git a/lib/libc/arch/riscv/stdlib/Makefile.inc b/lib/libc/arch/riscv/stdlib/Makefile.inc deleted file mode 100644 index 3cb7a1a1c..000000000 --- a/lib/libc/arch/riscv/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ diff --git a/lib/libc/arch/riscv/string/Makefile.inc b/lib/libc/arch/riscv/string/Makefile.inc deleted file mode 100644 index 3cb7a1a1c..000000000 --- a/lib/libc/arch/riscv/string/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ diff --git a/lib/libc/arch/riscv/strlib b/lib/libc/arch/riscv/strlib deleted file mode 100644 index 65b84742a..000000000 --- a/lib/libc/arch/riscv/strlib +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: strlib,v 1.1 2014/09/19 17:36:25 matt Exp $ diff --git a/lib/libc/arch/riscv/sys/__clone.S b/lib/libc/arch/riscv/sys/__clone.S deleted file mode 100644 index e987be19d..000000000 --- a/lib/libc/arch/riscv/sys/__clone.S +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: __clone.S,v 1.3 2015/03/27 23:23:14 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __clone.S,v 1.3 2015/03/27 23:23:14 matt Exp $"); -#endif /* SYSLIBC_SCCS and not lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - /* - * Sanity checks: func and stack may not be NULL. - */ - mv t0, a0 /* we need a0 for return value */ - li a0, EINVAL - beqz t0, 8f - beqz a1, 8f - - /* - * We need to be able to get at the func and arg arguments - * in the child. Luckily, we have a convenient place to - * do this: the child's stack. - */ - addi a1, a1, -CALLFRAME_SIZ - REG_S t0, 0(a1) - REG_S a3, SZREG(a1) - - /* - * The system call expects (flags, stack). - */ - mv a0, a2 - SYSTRAP(__clone) - # a1 (rv[1]) == 0, parent, child pid in a0 -8: JUMP_TO_CERROR() /* error */ - bnez a1, 9f /* success */ - ret # parent return - - /* NOTREACHED */ - -9: /* - * Child: Fetch the function and argument from the new stack and create - a frame so that the child can be safely called. - * - * There are already register slots on the stack from above. - * They already include the o32 argument save area. The - * highest is unused. a1 should equal sp now. - */ - - REG_L t0, 0(sp) - REG_L a0, SZREG(sp) - - REG_S zero, CALLFRAME_RA(sp) /* make sure stack frame ends */ - - /* Call the clone's entry point. */ - jalr t0 - - /* Pass the return value to _exit. */ - tail _C_LABEL(_exit) - - /* NOTREACHED */ -END(__clone) diff --git a/lib/libc/arch/riscv/sys/__sigaction14_sigtramp.c b/lib/libc/arch/riscv/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 1929180a0..000000000 --- a/lib/libc/arch/riscv/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.1 2014/09/19 17:36:25 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specified or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/riscv/sys/__sigtramp2.S b/lib/libc/arch/riscv/sys/__sigtramp2.S deleted file mode 100644 index b82df24de..000000000 --- a/lib/libc/arch/riscv/sys/__sigtramp2.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __sigtramp2.S,v 1.2 2015/03/27 06:44:28 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - - -/* - * The MIPS signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * sp -> siginfo_t structure - * sp + SIGINFO_SIZE -> ucontext_t structure - */ -ENTRY_NP(__sigtramp_siginfo_2) - addi a0, sp, SIGINFO_SIZE /* address of ucontext */ - SYSTRAP(setcontext) /* and do setcontext */ - nop - SYSTRAP(exit) /* if sigreturn fails */ -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/riscv/sys/__syscall.S b/lib/libc/arch/riscv/sys/__syscall.S deleted file mode 100644 index bfb1aa108..000000000 --- a/lib/libc/arch/riscv/sys/__syscall.S +++ /dev/null @@ -1,19 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -#include "SYS.h" - -ENTRY(__syscall) - mv t6, a0 - mv a0, a1 - mv a1, a2 - mv a2, a3 - mv a3, a4 - mv a4, a5 - mv a5, a6 - mv a6, a7 - REG_L a7, (sp) - SYSTRAP(__syscall) - JUMP_TO_CERROR() /* error */ - ret /* success */ -END(__syscall) -STRONG_ALIAS(syscall, __syscall) diff --git a/lib/libc/arch/riscv/sys/__vfork14.S b/lib/libc/arch/riscv/sys/__vfork14.S deleted file mode 100644 index b88122ac6..000000000 --- a/lib/libc/arch/riscv/sys/__vfork14.S +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)Ovfork.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: __vfork14.S,v 1.2 2015/03/27 06:44:28 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * pid = vfork(); - * - * a1 == 0 in parent process, a1 == 1 in child process. - * a0 == pid of child in parent, a0 == pid of parent in child. - */ - -ENTRY(__vfork14) - SYSTRAP(__vfork14) - JUMP_TO_CERROR() /* error */ - addi a1, a1, -1 /* success */ - and a0, a0, a1 - ret -END(__vfork14) diff --git a/lib/libc/arch/riscv/sys/brk.S b/lib/libc/arch/riscv/sys/brk.S deleted file mode 100644 index d57dd0327..000000000 --- a/lib/libc/arch/riscv/sys/brk.S +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: brk.S,v 1.4 2015/03/31 11:59:41 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: brk.S,v 1.4 2015/03/31 11:59:41 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - - .hidden _C_LABEL(__minbrk) - .hidden _C_LABEL(__curbrk) - .globl _C_LABEL(__minbrk) - .globl _C_LABEL(__curbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data - .p2align PTR_SCALESHIFT -_C_LABEL(__minbrk): - PTR_WORD _C_LABEL(_end) -_C_LABEL(__curbrk): - PTR_WORD _C_LABEL(_end) - - .text - -ENTRY(_brk) - lla t1, _C_LABEL(__minbrk) - PTR_L t5, 0(t1) - bgeu a0, t5, 1f - move a0, t5 # dont allow break < minbrk -1: - SYSTRAP(break) - JUMP_TO_CERROR() /* error */ - PTR_S a0, __SIZEOF_POINTER__(t1) /* success */ - move a0, zero - ret -END(_brk) diff --git a/lib/libc/arch/riscv/sys/cerror.S b/lib/libc/arch/riscv/sys/cerror.S deleted file mode 100644 index 498588de6..000000000 --- a/lib/libc/arch/riscv/sys/cerror.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: cerror.S,v 1.3 2015/03/27 23:23:14 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: cerror.S,v 1.3 2015/03/27 23:23:14 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - - .protected _C_LABEL(__cerror) - - .globl _C_LABEL(__errno) -ENTRY_NP(__cerror) -#ifdef _REENTRANT - addi sp, sp, -CALLFRAME_SIZ - REG_S ra, CALLFRAME_RA(sp) # save return address - INT_S a0, CALLFRAME_S0(sp) # save errno value - - call PLT(_C_LABEL(__errno)) # locate address of errno - - INT_L t0, CALLFRAME_S0(sp) # retrieve errno value - REG_L ra, CALLFRAME_RA(sp) # retrieve return address - INT_S t0, 0(a0) # update errno value - addi sp, sp, CALLFRAME_SIZ -#else - aiupc a1, %hi(_C_LABEL(errno)) - INT_S a0, %lo(_C_LABEL(errno))(a1) -#endif /* _REENTRANT */ - li a0, -1 - li a1, -1 - ret -END(__cerror) diff --git a/lib/libc/arch/riscv/sys/exect.S b/lib/libc/arch/riscv/sys/exect.S deleted file mode 100644 index 89efc6d49..000000000 --- a/lib/libc/arch/riscv/sys/exect.S +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: exect.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: exect.S,v 1.1 2014/09/19 17:36:25 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -PSEUDO(exect, execve) diff --git a/lib/libc/arch/riscv/sys/fork.S b/lib/libc/arch/riscv/sys/fork.S deleted file mode 100644 index 0ad2e6bd0..000000000 --- a/lib/libc/arch/riscv/sys/fork.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: fork.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: fork.S,v 1.2 2015/03/27 06:44:28 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -ENTRY(__fork) - SYSTRAP(fork) // pid = fork() - JUMP_TO_CERROR() /* error */ - /* success */ - addi a1, a1, -1 // a1 0->0xffffffff in parent, 1->0 in child - and a0, a0, a1 // a0 = child pid in parent, 0 in child - ret -END(__fork) diff --git a/lib/libc/arch/riscv/sys/getcontext.S b/lib/libc/arch/riscv/sys/getcontext.S deleted file mode 100644 index 9dde23247..000000000 --- a/lib/libc/arch/riscv/sys/getcontext.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.1 2014/09/19 17:36:25 matt Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif -ENTRY(_getcontext) - SYSTRAP(getcontext) - JUMP_TO_CERROR() /* error */ - REG_S zero, UC_GREGS_RV(a0) /* success */ - REG_S ra, UC_GREGS_PC(a0) - ret -END(_getcontext) diff --git a/lib/libc/arch/riscv/sys/pipe.S b/lib/libc/arch/riscv/sys/pipe.S deleted file mode 100644 index 34daef12f..000000000 --- a/lib/libc/arch/riscv/sys/pipe.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: pipe.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: pipe.S,v 1.2 2015/03/27 06:44:28 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe) - mv a2, a0 # a0 will be overwritten - SYSTRAP(pipe) # pipe(fildes) int fildes[2]; - JUMP_TO_CERROR() /* error */ - /* success */ - sw a0, 0(a2) # store the two file descriptors - sw a1, __SIZEOF_INT__(a2) - li a0, 0 - ret -END(_pipe) diff --git a/lib/libc/arch/riscv/sys/ptrace.S b/lib/libc/arch/riscv/sys/ptrace.S deleted file mode 100644 index 48cfc19ff..000000000 --- a/lib/libc/arch/riscv/sys/ptrace.S +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.2 2015/03/27 06:44:28 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: ptrace.S,v 1.2 2015/03/27 06:44:28 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -#define XCALLFRAME_SIZ (8*SZREG) -#define XCALLFRAME_RA (0*SZREG) -#define XCALLFRAME_A0 (1*SZREG) -#define XCALLFRAME_A1 (2*SZREG) -#define XCALLFRAME_A2 (3*SZREG) -#define XCALLFRAME_A3 (4*SZREG) - -ENTRY(ptrace) -#ifdef _REENTRANT - addi sp, sp, -XCALLFRAME_SIZ - REG_S ra, XCALLFRAME_RA(sp) - REG_S a0, XCALLFRAME_A0(sp) - REG_S a1, XCALLFRAME_A1(sp) - REG_S a2, XCALLFRAME_A2(sp) - REG_S a3, XCALLFRAME_A3(sp) - - call PLT(_C_LABEL(__errno)) - - INT_S zero, 0(a0) - - REG_L a3, XCALLFRAME_A3(sp) - REG_L a2, XCALLFRAME_A2(sp) - REG_L a1, XCALLFRAME_A1(sp) - REG_L a0, XCALLFRAME_A0(sp) - REG_L ra, XCALLFRAME_RA(sp) - addi sp, sp, XCALLFRAME_SIZ - -#else - auipc t0, %hi(_C_LABEL(errno)) - INT_S zero, %lo(_C_LABEL(errno))(t0) -#endif - - SYSTRAP(ptrace) - JUMP_TO_CERROR() /* error */ - ret /* success */ -END(ptrace) diff --git a/lib/libc/arch/riscv/sys/sbrk.S b/lib/libc/arch/riscv/sys/sbrk.S deleted file mode 100644 index f8b19705c..000000000 --- a/lib/libc/arch/riscv/sys/sbrk.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.4 2015/03/31 11:59:41 matt Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - - .hidden _C_LABEL(__curbrk) - .globl _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - -ENTRY(_sbrk) - lla t1, _C_LABEL(__curbrk) - PTR_L t2, 0(t1) - add a0, a0, t2 // compute current break - SYSTRAP(break) - JUMP_TO_CERROR() /* error */ - PTR_S a0, 0(t1) // save current val of curbrk from above - move a0, t2 // return old val of curbrk from above - ret -1: -END(_sbrk) diff --git a/lib/libc/arch/riscv/sys/shmat.S b/lib/libc/arch/riscv/sys/shmat.S deleted file mode 100644 index c90475d0e..000000000 --- a/lib/libc/arch/riscv/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/riscv/sys/syscall.S b/lib/libc/arch/riscv/sys/syscall.S deleted file mode 100644 index 4a40c7d66..000000000 --- a/lib/libc/arch/riscv/sys/syscall.S +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: syscall.S,v 1.1 2014/09/19 17:36:25 matt Exp $ */ - -/* __syscall does it all */ diff --git a/lib/libc/arch/sh3/Makefile.inc b/lib/libc/arch/sh3/Makefile.inc deleted file mode 100644 index e97ee9792..000000000 --- a/lib/libc/arch/sh3/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 2006/06/17 18:04:23 uwe Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S - -CPPFLAGS+= -DSOFTFLOAT # -DSOFTFLOAT_NEED_FIXUNS -.include diff --git a/lib/libc/arch/sh3/SYS.h b/lib/libc/arch/sh3/SYS.h deleted file mode 100644 index 8bbb29843..000000000 --- a/lib/libc/arch/sh3/SYS.h +++ /dev/null @@ -1,127 +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 - * William Jolitz. - * - * 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. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * $NetBSD: SYS.h,v 1.11 2013/09/12 15:36:15 joerg Exp $ - */ - -#include -#include - -#ifdef __STDC__ -#define IMMEDIATE # -#define SYSTRAP(x) \ - mov.l 903f, r0; \ - trapa IMMEDIATE 0x80; \ - bra 904f; \ - nop; \ - .align 2; \ - 903: .long (SYS_ ## x); \ - 904: -#else -#define SYSTRAP(x) \ - mov.l 903f, r0; \ - trapa #0x80; \ - bra 904f; \ - nop; \ - .align 2; \ - 903: .long (SYS_/**/x); \ - 904: -#endif - -#define _SYSCALL_NOERROR(x,y) \ - ENTRY(x); \ - SYSTRAP(y) - -#ifdef __PIC__ - -#define JUMP_CERROR \ - mov r0, r4; \ - mov.l 912f, r1; \ - mova 912f, r0; \ - mov.l 913f, r2; \ - add r1, r0; \ - mov.l @(r0, r2), r3; \ - jmp @r3; \ - nop; \ - .align 2; \ - 912: .long _GLOBAL_OFFSET_TABLE_; \ - 913: .long PIC_GOT(cerror) - -#else /* !__PIC__ */ - -#define JUMP_CERROR \ - mov.l 912f, r3; \ - jmp @r3; \ - mov r0, r4; \ - .align 2; \ - 912: .long cerror - -#endif /* !__PIC__ */ - -#define _SYSCALL(x,y) \ - .text; \ - 911: JUMP_CERROR; \ - _SYSCALL_NOERROR(x,y); \ - bf 911b - -#define SYSCALL_NOERROR(x) \ - _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ - rts; \ - nop - -#define PSEUDO(x,y) \ - _SYSCALL(x,y); \ - rts; \ - nop - -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) \ - PSEUDO(x,x) - -#ifdef WEAK_ALIAS -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) -#else -#define WSYSCALL(weak,strong) \ - PSEUDO(weak,weak) -#endif - - .globl cerror diff --git a/lib/libc/arch/sh3/gdtoa/Makefile.inc b/lib/libc/arch/sh3/gdtoa/Makefile.inc deleted file mode 100644 index 1d786e010..000000000 --- a/lib/libc/arch/sh3/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/sh3/gdtoa/arith.h b/lib/libc/arch/sh3/gdtoa/arith.h deleted file mode 100644 index 40d3ed1fa..000000000 --- a/lib/libc/arch/sh3/gdtoa/arith.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#include - -#if BYTE_ORDER == BIG_ENDIAN -#define IEEE_BIG_ENDIAN -#else -#define IEEE_LITTLE_ENDIAN -#endif diff --git a/lib/libc/arch/sh3/gdtoa/gd_qnan.h b/lib/libc/arch/sh3/gdtoa/gd_qnan.h deleted file mode 100644 index a7b54a203..000000000 --- a/lib/libc/arch/sh3/gdtoa/gd_qnan.h +++ /dev/null @@ -1,12 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#include - -#define f_QNAN 0x7fa00000 -#if BYTE_ORDER == BIG_ENDIAN -#define d_QNAN0 0x7ff40000 -#define d_QNAN1 0x0 -#else -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff40000 -#endif diff --git a/lib/libc/arch/sh3/gen/Makefile.inc b/lib/libc/arch/sh3/gen/Makefile.inc deleted file mode 100644 index 0afd1d4d9..000000000 --- a/lib/libc/arch/sh3/gen/Makefile.inc +++ /dev/null @@ -1,26 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.26 2014/01/20 17:14:38 joerg Exp $ - -SRCS+= setjmp.S _setjmp.S sigsetjmp.S - -SRCS+= makecontext.c resumecontext.c swapcontext.S - -SRCS+= _lwp.c - -SRCS+= fabs_ieee754.c flt_rounds.c bswap16.c bswap32.c bswap64.c - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c - -LSRCS.sh3.gen= Lint__setjmp.c Lint___setjmp14.c Lint___sigsetjmp14.c \ - Lint_swapcontext.c - -LSRCS+= ${LSRCS.sh3.gen} -DPSRCS+= ${LSRCS.sh3.gen} -CLEANFILES+= ${LSRCS.sh3.gen} diff --git a/lib/libc/arch/sh3/gen/_lwp.c b/lib/libc/arch/sh3/gen/_lwp.c deleted file mode 100644 index 3f40e331d..000000000 --- a/lib/libc/arch/sh3/gen/_lwp.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.6 2012/03/22 09:32:04 he Exp $ */ - -/* - * Copyright (c) 2002 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Jason R. Thorpe for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.6 2012/03/22 09:32:04 he Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - uintptr_t sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - sp = (uintptr_t)stack_base + stack_size; - - u->uc_mcontext.__gregs[_REG_R4] = (__greg_t) arg; - u->uc_mcontext.__gregs[_REG_SP] = ((__greg_t) sp) & ~3; - u->uc_mcontext.__gregs[_REG_PR] = (__greg_t) _lwp_exit; - u->uc_mcontext.__gregs[_REG_PC] = (__greg_t) start; - u->uc_mcontext.__gregs[_REG_GBR] = (__greg_t) private; -} diff --git a/lib/libc/arch/sh3/gen/_setjmp.S b/lib/libc/arch/sh3/gen/_setjmp.S deleted file mode 100644 index 81a022dc1..000000000 --- a/lib/libc/arch/sh3/gen/_setjmp.S +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.7 2006/01/05 02:04:41 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)_setjmp.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: _setjmp.S,v 1.7 2006/01/05 02:04:41 uwe Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - add #((_JB_HAS_MASK + 1) * 4), r4 - mov #0, r0 - mov.l r0, @-r4 /* no saved signal mask */ - mov.l r15, @-r4 - mov.l r14, @-r4 - mov.l r13, @-r4 - mov.l r12, @-r4 - mov.l r11, @-r4 - mov.l r10, @-r4 - mov.l r9, @-r4 - mov.l r8, @-r4 - sts.l pr, @-r4 - rts - xor r0, r0 - SET_ENTRY_SIZE(_setjmp) - -ENTRY(_longjmp) - lds.l @r4+, pr - mov.l @r4+, r8 - mov.l @r4+, r9 - mov.l @r4+, r10 - mov.l @r4+, r11 - mov.l @r4+, r12 - mov.l @r4+, r13 - mov.l @r4+, r14 - mov.l @r4+, r15 - - mov r5, r0 - tst r0, r0 - bf .L0 - add #1, r0 -.L0: - rts - nop - SET_ENTRY_SIZE(_longjmp) diff --git a/lib/libc/arch/sh3/gen/flt_rounds.c b/lib/libc/arch/sh3/gen/flt_rounds.c deleted file mode 100644 index 2fc27294c..000000000 --- a/lib/libc/arch/sh3/gen/flt_rounds.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.6 2015/03/19 21:22:59 joerg Exp $ */ - -/* - * Copyright (c) 1996 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * for the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.6 2015/03/19 21:22:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 2, /* round to positive infinity */ - 3, /* round to negative infinity */ - 0 /* round to zero */ -}; - -/* - * Return the current FP rounding mode - * - * Returns: - * 0 - round to zero - * 1 - round to nearest - * 2 - round to postive infinity - * 3 - round to negative infinity - * - * ok all we need to do is get the current FP rounding mode - * index our map table and return the appropriate value. - * - * HOWEVER: - * The ARM FPA codes the rounding mode into the actual FP instructions - * so there is no such thing as a global rounding mode. - * The default is round to nearest if rounding is not explicitly specified. - * FP instructions generated by GCC will not explicitly specify a rounding - * mode. - * - * So the best we can do it to return the rounding mode FP instructions - * use if rounding is not specified which is round to nearest. - * - * This could change in the future with new floating point emulators or - * soft float FP libraries. - */ - -extern int __flt_rounds __P((void)); - -int -__flt_rounds(void) -{ - return(map[fpgetround()]); -} diff --git a/lib/libc/arch/sh3/gen/makecontext.c b/lib/libc/arch/sh3/gen/makecontext.c deleted file mode 100644 index 1c55e4500..000000000 --- a/lib/libc/arch/sh3/gen/makecontext.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.4 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.4 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - int i; - unsigned int *sp; - va_list ap; - - /* Compute and align stack pointer. */ - sp = (unsigned int *) - (((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~3); - /* Allocate necessary stack space for arguments exceeding r4-7. */ - if (argc > 4) - sp -= argc - 4; - gr[_REG_SP] = (__greg_t)sp; - /* Arrange for return via the trampoline code. */ - gr[_REG_PR] = (__greg_t)_resumecontext; - gr[_REG_PC] = (__greg_t)func; - - va_start(ap, argc); - /* Pass up to four arguments in r4-7. */ - for (i = 0; i < argc && i < 4; i++) - gr[_REG_R4 - i] = va_arg(ap, int); /* sic! see mcontext.h */ - /* Pass any additional arguments on the stack. */ - for (argc -= i; argc > 0; argc--) - *sp++ = va_arg(ap, int); - va_end(ap); -} diff --git a/lib/libc/arch/sh3/gen/nanf.c b/lib/libc/arch/sh3/gen/nanf.c deleted file mode 100644 index 6fbda2885..000000000 --- a/lib/libc/arch/sh3/gen/nanf.c +++ /dev/null @@ -1,19 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = -#if BYTE_ORDER == BIG_ENDIAN - { { 0x7f, 0xa0, 0, 0 } }; -#else - { { 0, 0, 0xa0, 0x7f } }; -#endif - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/sh3/gen/resumecontext.c b/lib/libc/arch/sh3/gen/resumecontext.c deleted file mode 100644 index 57d68fdf8..000000000 --- a/lib/libc/arch/sh3/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/sh3/gen/setjmp.S b/lib/libc/arch/sh3/gen/setjmp.S deleted file mode 100644 index 5ad5da2d5..000000000 --- a/lib/libc/arch/sh3/gen/setjmp.S +++ /dev/null @@ -1,130 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.10 2006/01/05 19:21:37 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: setjmp.S,v 1.10 2006/01/05 19:21:37 uwe Exp $") -#endif - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - PIC_PROLOGUE(.L_got_1) - sts.l pr, @-sp - mov.l r4, @-sp - - mov.l .L___sigprocmask14_1, r0 - mov r4, r6 - mov #1, r4 /* how = SIG_BLOCK */ - mov #0, r5 /* new = NULL */ -1: CALL r0 - add #(_JB_SIGMASK * 4), r6 /* old = &sigmask */ - - mov.l @sp+, r4 - lds.l @sp+, pr - PIC_EPILOGUE - - /* identical to _setjmp except that _JB_HAS_MASK is non-zero */ - add #((_JB_HAS_MASK + 1) * 4), r4 - mov #1, r0 - mov.l r0, @-r4 /* has signal mask */ - mov.l r15, @-r4 - mov.l r14, @-r4 - mov.l r13, @-r4 - mov.l r12, @-r4 - mov.l r11, @-r4 - mov.l r10, @-r4 - mov.l r9, @-r4 - mov.l r8, @-r4 - sts.l pr, @-r4 - rts - xor r0, r0 - - .align 2 -.L_got_1: PIC_GOT_DATUM -.L___sigprocmask14_1: CALL_DATUM(_C_LABEL(__sigprocmask14), 1b) - SET_ENTRY_SIZE(__setjmp14) - - -ENTRY(__longjmp14) - /* we won't return here, so we don't need to save pr and r12 */ - PIC_PROLOGUE_NOSAVE(.L_got_2) - mov.l r5, @-sp - mov.l r4, @-sp - - mov.l .L___sigprocmask14_2, r0 - mov r4, r5 - mov #3, r4 /* how = SIG_SETMASK */ - add #(_JB_SIGMASK * 4), r5 /* new = &sigmask */ -1: CALL r0 - mov #0, r6 /* old = NULL */ - - mov.l @sp+, r4 - mov.l @sp+, r5 - - /* identical to _longjmp */ - lds.l @r4+, pr - mov.l @r4+, r8 - mov.l @r4+, r9 - mov.l @r4+, r10 - mov.l @r4+, r11 - mov.l @r4+, r12 - mov.l @r4+, r13 - mov.l @r4+, r14 - mov.l @r4+, r15 - - mov r5, r0 - tst r0, r0 /* make sure return value is non-zero */ - bf .L0 - add #1, r0 -.L0: - rts - nop - - .align 2 -.L_got_2: PIC_GOT_DATUM -.L___sigprocmask14_2: CALL_DATUM(_C_LABEL(__sigprocmask14), 1b) - SET_ENTRY_SIZE(__longjmp14) diff --git a/lib/libc/arch/sh3/gen/sigsetjmp.S b/lib/libc/arch/sh3/gen/sigsetjmp.S deleted file mode 100644 index 2c7d7b15f..000000000 --- a/lib/libc/arch/sh3/gen/sigsetjmp.S +++ /dev/null @@ -1,130 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.9 2006/01/05 19:21:37 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: sigsetjmp.S,v 1.9 2006/01/05 19:21:37 uwe Exp $") -#endif - -ENTRY(__sigsetjmp14) - tst r5, r5 - bt 2f /* if (savemask == 0) */ - - /* identical to longjmp except that _JB_HAS_MASK is in the argument */ - PIC_PROLOGUE(.L_got_1) - sts.l pr, @-sp - mov.l r4, @-sp - mov.l r5, @-sp - - mov.l .L___sigprocmask14_1, r0 - mov r4, r6 - mov #1, r4 /* how = SIG_BLOCK */ - mov #0, r5 /* new = NULL */ -1: CALL r0 - add #(_JB_SIGMASK * 4), r6 /* old = &sigmask */ - - mov.l @sp+, r5 - mov.l @sp+, r4 - lds.l @sp+, pr - PIC_EPILOGUE - -2: /* identical to _setjmp except that _JB_HAS_MASK is in the argument */ - add #((_JB_HAS_MASK + 1) * 4), r4 - mov.l r5, @-r4 /* has signal mask? */ - mov.l r15, @-r4 - mov.l r14, @-r4 - mov.l r13, @-r4 - mov.l r12, @-r4 - mov.l r11, @-r4 - mov.l r10, @-r4 - mov.l r9, @-r4 - mov.l r8, @-r4 - sts.l pr, @-r4 - rts - xor r0, r0 - - .align 2 -.L_got_1: PIC_GOT_DATUM -.L___sigprocmask14_1: CALL_DATUM(_C_LABEL(__sigprocmask14), 1b) - SET_ENTRY_SIZE(__sigsetjmp14) - - -ENTRY(__siglongjmp14) - mov.l @(_JB_HAS_MASK * 4, r4), r0 - tst r0, r0 - bt 2f /* if no mask */ - - /* identical to longjmp */ - /* we won't return here, so we don't need to save pr and r12 */ - PIC_PROLOGUE_NOSAVE(.L_got_2) - mov.l r5, @-sp - mov.l r4, @-sp - - mov.l .L___sigprocmask14_2, r0 - mov r4, r5 - mov #3, r4 /* how = SIG_SETMASK */ - add #(_JB_SIGMASK * 4), r5 /* new = &sigmask */ -1: CALL r0 - mov #0, r6 /* old = NULL */ - - mov.l @sp+, r4 - mov.l @sp+, r5 - -2: /* identical to _longjmp */ - lds.l @r4+, pr - mov.l @r4+, r8 - mov.l @r4+, r9 - mov.l @r4+, r10 - mov.l @r4+, r11 - mov.l @r4+, r12 - mov.l @r4+, r13 - mov.l @r4+, r14 - mov.l @r4+, r15 - - mov r5, r0 - tst r0, r0 /* make sure return value is non-zero */ - bf .L0 - add #1, r0 -.L0: - rts - nop - - .align 2 -.L_got_2: PIC_GOT_DATUM -.L___sigprocmask14_2: CALL_DATUM(_C_LABEL(__sigprocmask14), 1b) - SET_ENTRY_SIZE(__siglongjmp14) diff --git a/lib/libc/arch/sh3/gen/swapcontext.S b/lib/libc/arch/sh3/gen/swapcontext.S deleted file mode 100644 index 69eb82815..000000000 --- a/lib/libc/arch/sh3/gen/swapcontext.S +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.12 2015/04/06 01:50:46 uwe Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.12 2015/04/06 01:50:46 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * int - * swapcontext(ucontext_t * restrict oucp, ucontext_t * restrict ucp); - */ -ENTRY(swapcontext) - PIC_PROLOGUE(.L_got) - sts.l pr, @-sp - - mov.l .L__getcontext, r0 - mov.l r5, @-sp -1: CALL r0 ! _getcontext(oucp) - mov.l r4, @-sp - !! getcontext captures oucp resuming here with r12 (when PIC), - !! pr, r5 and r4 pushed onto the stack - - tst r0, r0 - bf.s 3f ! return error from getcontext - mov.l @sp, r1 ! saved oucp - - !! adjust oucp to resume after setcontext below - mova 3f, r0 - mov.l r0, @(36 + 1 * 4, r1) ! _UC_MACHINE_SET_PC(oucp, pr) - - mov.l .L_setcontext, r2 -2: CALL r2 ! setcontext(ucp) - mov.l @(4, sp), r4 ! saved ucp - - .align 2 -3: !! we get here on errors and when resuming oucp - add #8, sp ! skip r4 and r5 - lds.l @sp+, pr - rts - PIC_EPILOGUE_SLOT - - .align 2 -.L_got: PIC_GOT_DATUM -.L__getcontext: CALL_DATUM(_C_LABEL(_getcontext), 1b) -.L_setcontext: CALL_DATUM(_C_LABEL(setcontext), 2b) - SET_ENTRY_SIZE(swapcontext) diff --git a/lib/libc/arch/sh3/net/Makefile.inc b/lib/libc/arch/sh3/net/Makefile.inc deleted file mode 100644 index 02c67cff1..000000000 --- a/lib/libc/arch/sh3/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2000/01/05 14:07:36 msaitoh Exp $ - -SRCS+= htonl.c htons.c ntohl.c ntohs.c diff --git a/lib/libc/arch/sh3/net/htonl.c b/lib/libc/arch/sh3/net/htonl.c deleted file mode 100644 index 67356285f..000000000 --- a/lib/libc/arch/sh3/net/htonl.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: htonl.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)htonl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include -#if defined(LIBC_SCCS) - __RCSID("$NetBSD: htonl.c,v 1.3 2005/12/24 23:10:08 perry Exp $"); -#endif - -/* hostorder = htonl(netorder) */ -#if BYTE_ORDER == LITTLE_ENDIAN -u_int32_t -htonl(x) - u_int32_t x; -{ - u_int32_t y = 0; - - __asm("swap.b %1, %0" : "=r" (y) : "r" (x)); - __asm("swap.w %1, %0" : "=r" (y) : "r" (y)); - __asm("swap.b %1, %0" : "=r" (y) : "r" (y)); - return y; -} -#endif diff --git a/lib/libc/arch/sh3/net/htons.c b/lib/libc/arch/sh3/net/htons.c deleted file mode 100644 index 544f9fcff..000000000 --- a/lib/libc/arch/sh3/net/htons.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: htons.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)htonl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include -#if defined(LIBC_SCCS) - __RCSID("$NetBSD: htons.c,v 1.3 2005/12/24 23:10:08 perry Exp $"); -#endif - -/* netorder = htons(hostorder) */ -#if BYTE_ORDER == LITTLE_ENDIAN -u_int16_t -htons(x) - u_int16_t x; -{ - __asm("swap.b %1, %0" : "=r" (x) : "r" (x)); - return x; -} -#endif diff --git a/lib/libc/arch/sh3/net/ntohl.c b/lib/libc/arch/sh3/net/ntohl.c deleted file mode 100644 index 364656b59..000000000 --- a/lib/libc/arch/sh3/net/ntohl.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: ntohl.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include -#if defined(LIBC_SCCS) - __RCSID("$NetBSD: ntohl.c,v 1.3 2005/12/24 23:10:08 perry Exp $"); -#endif - -/* netorder = ntohl(hostorder) */ -#if BYTE_ORDER == LITTLE_ENDIAN -u_int32_t -ntohl(x) - u_int32_t x; -{ - u_int32_t y = 0; - - __asm("swap.b %1, %0" : "=r" (y) : "r" (x)); - __asm("swap.w %1, %0" : "=r" (y) : "r" (y)); - __asm("swap.b %1, %0" : "=r" (y) : "r" (y)); - return y; -} -#endif diff --git a/lib/libc/arch/sh3/net/ntohs.c b/lib/libc/arch/sh3/net/ntohs.c deleted file mode 100644 index 174a64d8c..000000000 --- a/lib/libc/arch/sh3/net/ntohs.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: ntohs.c,v 1.3 2005/12/24 23:10:08 perry Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)ntohl.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#include -#if defined(LIBC_SCCS) - __RCSID("$NetBSD: ntohs.c,v 1.3 2005/12/24 23:10:08 perry Exp $"); -#endif - -/* hostorder = ntohs(netorder) */ -#if BYTE_ORDER == LITTLE_ENDIAN -u_int16_t -ntohs(x) - u_int16_t x; -{ - __asm("swap.b %1, %0" : "=r" (x) : "r" (x)); - return x; -} -#endif diff --git a/lib/libc/arch/sh3/softfloat/milieu.h b/lib/libc/arch/sh3/softfloat/milieu.h deleted file mode 100644 index 64429ca18..000000000 --- a/lib/libc/arch/sh3/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.1 2000/06/06 17:28:42 tsubai Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "sh3-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/sh3/softfloat/sh3-gcc.h b/lib/libc/arch/sh3/softfloat/sh3-gcc.h deleted file mode 100644 index 15c168aa9..000000000 --- a/lib/libc/arch/sh3/softfloat/sh3-gcc.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: sh3-gcc.h,v 1.2 2005/12/24 21:11:16 perry Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#include -#if _BYTE_ORDER == _BIG_ENDIAN -#define BIGENDIAN -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef unsigned char uint8; -typedef signed char int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64(a) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) diff --git a/lib/libc/arch/sh3/softfloat/softfloat.h b/lib/libc/arch/sh3/softfloat/softfloat.h deleted file mode 100644 index b6d3936e4..000000000 --- a/lib/libc/arch/sh3/softfloat/softfloat.h +++ /dev/null @@ -1,316 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.11 2011/07/07 07:14:57 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -/* #define FLOAT128 */ - -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int8 float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __floatdi?f is in libgcc2.c */ -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned int float32_to_uint32_round_to_zero( float32 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -#endif -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -flag float32_eq( float32, float32 ); -flag float32_le( float32, float32 ); -flag float32_lt( float32, float32 ); -flag float32_eq_signaling( float32, float32 ); -flag float32_le_quiet( float32, float32 ); -flag float32_lt_quiet( float32, float32 ); -#ifndef SOFTFLOAT_FOR_GCC -flag float32_is_signaling_nan( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -#if defined(SOFTFLOAT_FOR_GCC) && defined(SOFTFLOAT_NEED_FIXUNS) -unsigned int float64_to_uint32_round_to_zero( float64 ); -#endif -#ifndef SOFTFLOAT_FOR_GCC /* __fix?fdi provided by libgcc2.c */ -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -#endif -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -flag float64_eq( float64, float64 ); -flag float64_le( float64, float64 ); -flag float64_lt( float64, float64 ); -flag float64_eq_signaling( float64, float64 ); -flag float64_le_quiet( float64, float64 ); -flag float64_lt_quiet( float64, float64 ); -#ifndef SOFTFLOAT_FOR_GCC -flag float64_is_signaling_nan( float64 ); -#endif - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -flag floatx80_eq( floatx80, floatx80 ); -flag floatx80_le( floatx80, floatx80 ); -flag floatx80_lt( floatx80, floatx80 ); -flag floatx80_eq_signaling( floatx80, floatx80 ); -flag floatx80_le_quiet( floatx80, floatx80 ); -flag floatx80_lt_quiet( floatx80, floatx80 ); -flag floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -flag float128_eq( float128, float128 ); -flag float128_le( float128, float128 ); -flag float128_lt( float128, float128 ); -flag float128_eq_signaling( float128, float128 ); -flag float128_le_quiet( float128, float128 ); -flag float128_lt_quiet( float128, float128 ); -flag float128_is_signaling_nan( float128 ); - -#endif - diff --git a/lib/libc/arch/sh3/stdlib/Makefile.inc b/lib/libc/arch/sh3/stdlib/Makefile.inc deleted file mode 100644 index 2f91b992a..000000000 --- a/lib/libc/arch/sh3/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/31 20:40:00 dsl Exp $ diff --git a/lib/libc/arch/sh3/string/Makefile.inc b/lib/libc/arch/sh3/string/Makefile.inc deleted file mode 100644 index 2aced0da6..000000000 --- a/lib/libc/arch/sh3/string/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/30 20:57:16 dsl Exp $ - -SRCS+= bcopy.S bzero.S ffs.S memset.S -SRCS+= memcpy.S memmove.S diff --git a/lib/libc/arch/sh3/string/bcopy.S b/lib/libc/arch/sh3/string/bcopy.S deleted file mode 100644 index b32725ad4..000000000 --- a/lib/libc/arch/sh3/string/bcopy.S +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: bcopy.S,v 1.3 2006/04/23 00:08:18 uwe Exp $ */ - -#define BCOPY -#include "memcpy.S" diff --git a/lib/libc/arch/sh3/string/bzero.S b/lib/libc/arch/sh3/string/bzero.S deleted file mode 100644 index 2d5ceca08..000000000 --- a/lib/libc/arch/sh3/string/bzero.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: bzero.S,v 1.1 2002/11/20 14:23:54 itohy Exp $ */ - -#define BZERO -#include "memset.S" - diff --git a/lib/libc/arch/sh3/sys/__clone.S b/lib/libc/arch/sh3/sys/__clone.S deleted file mode 100644 index fed5a1c4a..000000000 --- a/lib/libc/arch/sh3/sys/__clone.S +++ /dev/null @@ -1,88 +0,0 @@ -/* $NetBSD: __clone.S,v 1.7 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 2001 Tsubai Masanari. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone,__clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - /* - * Sanity checks: func and stack may not be NULL. - */ - tst r4, r4 - bt inval - tst r5, r5 - bt inval - - mov r4, r2 /* save entry point for later */ - - mov r6, r4 /* r4 = flags, r5 = stack (already) */ - mov.l .L_SYS___clone, r0 - trapa #0x80 - bf err - - tst r0, r0 - bf 3f /* we're the parent, just return */ - - jsr @r2 /* clone does _exit((*fn)(arg)); */ - mov r7, r4 - - mov.l .L__exit, r1 -#ifdef __PIC__ - mov r0, r4 - mov.l .L_got, r12 /* PIC_PROLOGUE_NOSAVE(.L_got) */ - mova .L_got, r0 /* expanded to fill the delay slot */ -1: JUMP r1 - add r0, r12 -#else - JUMP r1 - mov r0, r4 -#endif - /* NOTREACHED */ - -inval: - mov #EINVAL, r0 -err: - JUMP_CERROR - /* NOTREACHED */ - -3: rts - nop - - .align 2 -.L_SYS___clone: .long SYS___clone - -.L_got: PIC_GOT_DATUM -.L__exit: CALL_DATUM(_C_LABEL(_exit), 1b) - SET_ENTRY_SIZE(__clone) diff --git a/lib/libc/arch/sh3/sys/__sigaction14_sigtramp.c b/lib/libc/arch/sh3/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 73b8fd837..000000000 --- a/lib/libc/arch/sh3/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.8 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.8 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) -#ifdef __LIBC12_SOURCE__ -extern const int __sigtramp_sigcontext_1[] - __weak_reference(__sigtramp_sigcontext_1); -#endif - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern int __sigtramp_siginfo_2[]; - -#ifdef __LIBC12_SOURCE__ - /* - * We select the compatibility SIGCONTEXT trampoline if SA_SIGINFO - * is not set in the sigaction. - */ - if (act && (act->sa_flags & SA_SIGINFO) == 0) { - extern int __sigtramp_sigcontext_1[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - /* - * EINVAL might indicate that trampoline version 1 is - * not supported by the kernel; fall back on native - * SIGINFO trampoline. - */ - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/sh3/sys/__sigtramp2.S b/lib/libc/arch/sh3/sys/__sigtramp2.S deleted file mode 100644 index 930a9996d..000000000 --- a/lib/libc/arch/sh3/sys/__sigtramp2.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The SH signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * siginfo structure - * sp-> ucontext structure - * - * NB: This order is different from what other ports use (siginfo at - * the top of the stack), because we want to avoid wasting two - * instructions to skip to the ucontext. Not that this order really - * matters, but I think this inconsistency deserves an explanation. - */ -NENTRY(__sigtramp_siginfo_2) - mov r15, r4 /* get pointer to ucontext */ - SYSTRAP(setcontext) /* and call setcontext() */ - mov r0, r4 /* exit with errno */ - SYSTRAP(exit) /* if sigreturn fails */ - - SET_ENTRY_SIZE(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/sh3/sys/__syscall.S b/lib/libc/arch/sh3/sys/__syscall.S deleted file mode 100644 index 0da939426..000000000 --- a/lib/libc/arch/sh3/sys/__syscall.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.6 2006/01/06 01:57:38 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __syscall.S,v 1.6 2006/01/06 01:57:38 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -RSYSCALL(__syscall) diff --git a/lib/libc/arch/sh3/sys/__vfork14.S b/lib/libc/arch/sh3/sys/__vfork14.S deleted file mode 100644 index 0d2a29610..000000000 --- a/lib/libc/arch/sh3/sys/__vfork14.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.6 2006/01/06 07:07:34 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __vfork14.S,v 1.6 2006/01/06 07:07:34 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * pid = vfork(); - * - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - * - */ -ENTRY(__vfork14) - mov.l .L_SYS___vfork14, r0 - trapa #0x80 - bf err - - add #0xff, r1 /* from 1 to 0 in child, 0 to -1 in parent */ - rts - and r1, r0 /* 0 in child, child pid in parent */ - -err: - JUMP_CERROR - - .align 2 -.L_SYS___vfork14: - .long SYS___vfork14 - - SET_ENTRY_SIZE(__vfork14) diff --git a/lib/libc/arch/sh3/sys/brk.S b/lib/libc/arch/sh3/sys/brk.S deleted file mode 100644 index 611747d90..000000000 --- a/lib/libc/arch/sh3/sys/brk.S +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: brk.S,v 1.11 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)brk.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: brk.S,v 1.11 2013/09/12 15:36:16 joerg Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk,_brk) -#endif - - .data - .globl _C_LABEL(__minbrk) - .align 2 -_C_LABEL(__minbrk): - .long _end - - .text - -ENTRY(_brk) -#ifdef __PIC__ - mova L_GOT, r0 - mov.l L_GOT, r2 - add r0, r2 - mov.l Lminbrk, r0 - mov.l @(r0, r2), r0 - mov.l @r0, r0 -#else - mov.l Lminbrk, r0 - mov.l @r0, r0 -#endif - cmp/hs r4, r0 - bf 1f - mov r0, r4 -1: - mov.l LSYS_break, r0 - trapa #0x80 - bf err -#ifdef __PIC__ - mov.l Lcurbrk, r0 - mov.l @(r0, r2), r1 - xor r0, r0 -#else - xor r0, r0 - mov.l Lcurbrk, r1 -#endif - rts - mov.l r4, @r1 -err: - JUMP_CERROR - - .align 2 -LSYS_break: .long SYS_break -#ifdef __PIC__ -L_GOT: .long _GLOBAL_OFFSET_TABLE_ -Lminbrk: .long _C_LABEL(__minbrk)@GOT -Lcurbrk: .long curbrk@GOT -#else -Lminbrk: .long _C_LABEL(__minbrk) -Lcurbrk: .long curbrk -#endif - SET_ENTRY_SIZE(_brk) diff --git a/lib/libc/arch/sh3/sys/cerror.S b/lib/libc/arch/sh3/sys/cerror.S deleted file mode 100644 index 0bc5e556a..000000000 --- a/lib/libc/arch/sh3/sys/cerror.S +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: cerror.S,v 1.11 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: cerror.S,v 1.11 2013/09/12 15:36:16 joerg Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef _REENTRANT - - - .globl _C_LABEL(__errno) - - .align 2 -cerror: - mov.l .L___errno, r1 - PIC_PROLOGUE(.L_got) - sts.l pr, @-sp -1: CALL r1 - mov.l r4, @-sp ! save error code - mov.l @sp+, r4 - lds.l @sp+, pr - PIC_EPILOGUE - mov.l r4, @r0 - mov #-1, r1 - rts - mov #-1, r0 - - .align 2 -.L_got: PIC_GOT_DATUM -.L___errno: CALL_DATUM(_C_LABEL(__errno), 1b) - SET_ASENTRY_SIZE(cerror) - -#else /* !_REENTRANT */ - - - .globl _C_LABEL(errno) - - .align 2 -cerror: -#ifdef __PIC__ - mova L_GOT, r0 - mov.l L_GOT, r1 - add r0, r1 - mov.l L_errno, r0 - mov.l @(r0, r1), r1 - mov.l r4, @r1 -#else - mov.l L_errno, r1 - mov.l r4, @r1 -#endif - mov #-1, r0 - rts - mov #-1, r1 - - .align 2 -#ifdef __PIC__ -L_GOT: .long _GLOBAL_OFFSET_TABLE_ -L_errno: .long _C_LABEL(errno)@GOT -#else -L_errno: .long _C_LABEL(errno) -#endif - -#endif /* !_REENTRANT */ diff --git a/lib/libc/arch/sh3/sys/exect.S b/lib/libc/arch/sh3/sys/exect.S deleted file mode 100644 index a4f2a9e96..000000000 --- a/lib/libc/arch/sh3/sys/exect.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: exect.S,v 1.5 2006/01/06 01:53:30 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)exect.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: exect.S,v 1.5 2006/01/06 01:53:30 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -PSEUDO(exect,execve) diff --git a/lib/libc/arch/sh3/sys/fork.S b/lib/libc/arch/sh3/sys/fork.S deleted file mode 100644 index 5448955a5..000000000 --- a/lib/libc/arch/sh3/sys/fork.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: fork.S,v 1.10 2006/01/06 05:11:29 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)fork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: fork.S,v 1.10 2006/01/06 05:11:29 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * pid = fork(); - * - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - * - */ -ENTRY(__fork) - mov #SYS_fork, r0 - trapa #0x80 - bf err - - add #0xff, r1 /* from 1 to 0 in child, 0 to -1 in parent */ - rts - and r1, r0 /* 0 in child, child pid in parent */ - -err: - JUMP_CERROR - - SET_ENTRY_SIZE(__fork) diff --git a/lib/libc/arch/sh3/sys/getcontext.S b/lib/libc/arch/sh3/sys/getcontext.S deleted file mode 100644 index 91ca4a9bc..000000000 --- a/lib/libc/arch/sh3/sys/getcontext.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.3 2008/04/28 20:22:57 martin Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext,_getcontext) -#endif - -_SYSCALL(_getcontext,getcontext) - sts pr, r2 - mov.l r2, @(36 + 1 * 4, r4) /* saved pc <- pr */ - add #36 + 20 * 4, r4 - rts - mov.l r0, @r4 /* arrange for return value 0 */ diff --git a/lib/libc/arch/sh3/sys/pipe.S b/lib/libc/arch/sh3/sys/pipe.S deleted file mode 100644 index 11c6b953b..000000000 --- a/lib/libc/arch/sh3/sys/pipe.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: pipe.S,v 1.7 2006/01/06 05:23:46 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)pipe.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: pipe.S,v 1.7 2006/01/06 05:23:46 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe,_pipe) -#endif - -_SYSCALL(_pipe,pipe) - mov.l r0, @r4 - mov.l r1, @(4, r4) - rts - mov #0, r0 diff --git a/lib/libc/arch/sh3/sys/ptrace.S b/lib/libc/arch/sh3/sys/ptrace.S deleted file mode 100644 index c8a7e652c..000000000 --- a/lib/libc/arch/sh3/sys/ptrace.S +++ /dev/null @@ -1,111 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.9 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)ptrace.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: ptrace.S,v 1.9 2013/09/12 15:36:16 joerg Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * int - * ptrace(int request, pid_t pid, caddr_t addr, int data); - */ -ENTRY(ptrace) -#ifdef _REENTRANT - - mov.l .L___errno, r1 - PIC_PROLOGUE(.L_GOT) - sts.l pr, @-sp - mov.l r7, @-sp - mov.l r6, @-sp - mov.l r5, @-sp -1: CALL r1 - mov.l r4, @-sp - mov.l @sp+, r4 - mov.l @sp+, r5 - mov.l @sp+, r6 - mov.l @sp+, r7 - lds.l @sp+, pr - PIC_EPILOGUE - -#else /* ! _REENTRANT */ - -#ifdef __PIC__ - mova .L_GOT, r0 - mov.l .L_GOT, r1 - add r0, r1 - mov.l .L_errno, r0 - mov.l @(r0, r1), r0 -#else - mov.l .L_errno, r0 -#endif - -#endif /* ! _REENTRANT */ - - mov #0, r1 - mov.l r1, @r0 /* errno = 0; */ - - mov #SYS_ptrace, r0 - trapa #0x80 - bf err - rts - nop -err: - JUMP_CERROR - - .align 2 -.L_GOT: - PIC_GOT_DATUM - -#ifdef _REENTRANT - .global _C_LABEL(__errno) -.L___errno: - CALL_DATUM(_C_LABEL(__errno), 1b) - -#else /* ! _REENTRANT */ - .global _C_LABEL(errno) -.L_errno: -#ifdef __PIC__ - .long PIC_GOT(_C_LABEL(errno)) -#else - .long _C_LABEL(errno) -#endif - -#endif /* ! _REENTRANT */ - - SET_ENTRY_SIZE(ptrace) diff --git a/lib/libc/arch/sh3/sys/sbrk.S b/lib/libc/arch/sh3/sys/sbrk.S deleted file mode 100644 index 6ad26271b..000000000 --- a/lib/libc/arch/sh3/sys/sbrk.S +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.10 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: sbrk.S,v 1.10 2013/09/12 15:36:16 joerg Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl curbrk - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk,_sbrk) -#endif - - .data -curbrk: .long _end - .text - -ENTRY(_sbrk) - mov r4, r2 -#ifdef __PIC__ - mova L_GOT, r0 - mov.l L_GOT, r3 - add r0, r3 - mov.l Lcurbrk, r0 - mov.l @(r0, r3), r0 -#else - mov.l Lcurbrk, r0 -#endif - mov.l @r0, r0 - add r0, r4 - mov.l LSYS_break, r0 - trapa #0x80 - bf err -#ifdef __PIC__ - mov.l Lcurbrk, r0 - mov.l @(r0, r3), r1 -#else - mov.l Lcurbrk, r1 -#endif - mov.l @r1, r0 - add r0, r2 - rts - mov.l r2, @r1 -err: - JUMP_CERROR - - .align 2 -LSYS_break: .long SYS_break -#ifdef __PIC__ -L_GOT: .long _GLOBAL_OFFSET_TABLE_ -Lcurbrk: .long curbrk@GOT -#else -Lcurbrk: .long curbrk -#endif - SET_ENTRY_SIZE(_sbrk) diff --git a/lib/libc/arch/sh3/sys/shmat.S b/lib/libc/arch/sh3/sys/shmat.S deleted file mode 100644 index 7f57fad5f..000000000 --- a/lib/libc/arch/sh3/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:54 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/sh3/sys/syscall.S b/lib/libc/arch/sh3/sys/syscall.S deleted file mode 100644 index 979ef83a8..000000000 --- a/lib/libc/arch/sh3/sys/syscall.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: syscall.S,v 1.6 2006/01/06 01:27:23 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: syscall.S,v 1.6 2006/01/06 01:27:23 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -RSYSCALL(syscall) diff --git a/lib/libc/arch/sparc/Makefile.inc b/lib/libc/arch/sparc/Makefile.inc deleted file mode 100644 index de348c7e6..000000000 --- a/lib/libc/arch/sparc/Makefile.inc +++ /dev/null @@ -1,38 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.15 2014/07/12 19:21:48 nakayama Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S - -.if ${MACHINE} != "sparc64" -# `source' files built from m4 source -# the name `div.o' is taken for the ANSI C `div' function, hence sdiv here -SRCS+= rem.S sdiv.S udiv.S urem.S -CLEANFILES+=rem.S sdiv.S udiv.S urem.S - -sdiv.S: ${LIBCDIR}/arch/sparc/gen/divrem.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @rm -f ${.TARGET} - @(echo "define(NAME,\`.div')define(OP,\`div')define(S,\`true')"; \ - cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET} - @chmod 444 ${.TARGET} - -udiv.S: ${LIBCDIR}/arch/sparc/gen/divrem.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @rm -f ${.TARGET} - @(echo "define(NAME,\`.udiv')define(OP,\`div')define(S,\`false')"; \ - cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET} - @chmod 444 ${.TARGET} - -rem.S: ${LIBCDIR}/arch/sparc/gen/divrem.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @rm -f ${.TARGET} - @(echo "define(NAME,\`.rem')define(OP,\`rem')define(S,\`true')"; \ - cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET} - @chmod 444 ${.TARGET} - -urem.S: ${LIBCDIR}/arch/sparc/gen/divrem.m4 - @echo 'building ${.TARGET} from ${.ALLSRC}' - @rm -f ${.TARGET} - @(echo "define(NAME,\`.urem')define(OP,\`rem')define(S,\`false')"; \ - cat ${.ALLSRC}) | ${TOOL_M4} > ${.TARGET} - @chmod 444 ${.TARGET} -.endif diff --git a/lib/libc/arch/sparc/SYS.h b/lib/libc/arch/sparc/SYS.h deleted file mode 100644 index 8a2fba185..000000000 --- a/lib/libc/arch/sparc/SYS.h +++ /dev/null @@ -1,151 +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. - * 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. - * - * @(#)SYS.h 8.1 (Berkeley) 6/4/93 - * - * from: Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp - * $NetBSD: SYS.h,v 1.19 2013/09/12 15:36:16 joerg Exp $ - */ - -#include -#include -#include - -#ifdef __STDC__ -#define _CAT(x,y) x##y -#else -#define _CAT(x,y) x/**/y -#endif - -#ifdef __ELF__ -#define CERROR _C_LABEL(__cerror) -#define CURBRK _C_LABEL(__curbrk) -#else -#define CERROR _ASM_LABEL(cerror) -#define CURBRK _ASM_LABEL(curbrk) -#endif - -/* - * ERROR branches to cerror. - */ -#ifdef __PIC__ -#define CALL(name) \ - PIC_PROLOGUE(%g1, %g5); \ - set name, %g5; \ - ld [%g1 + %g5], %g5; \ - jmp %g5; \ - nop -#else -#define CALL(name) \ - set name, %g1; \ - jmp %g1; \ - nop -#endif -#define ERROR() CALL(CERROR) - -/* - * SYSCALL is used when further action must be taken before returning. - * Note that it adds a `nop' over what we could do, if we only knew - * what came at label 1.... - */ -#define _SYSCALL(x,y) \ -ENTRY(x); \ - mov _CAT(SYS_,y), %g1; \ - t ST_SYSCALL; \ - bcc 1f; \ - nop; \ - ERROR(); \ -1: /* next insn */ - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -/* - * RSYSCALL is used when the system call should just return. Here we - * use the SYSCALL_G5RFLAG to put the `success' return address in %g5 - * and avoid a branch. - * - * PSEUDO(x,y) is like RSYSCALL(y), except that the name is x. - */ -#define _RSYSCALL(x,y) \ -ENTRY(x); \ - mov (_CAT(SYS_,y)) | SYSCALL_G5RFLAG, %g1; \ - add %o7, 8, %g5; \ - t ST_SYSCALL; \ - ERROR() - -#define RSYSCALL(x) _RSYSCALL(x,x) -#define PSEUDO(x,y) _RSYSCALL(x,y) - -/* - * WSYSCALL(weak,strong) is like RSYSCALL(weak), - * except that weak is a weak internal alias for the strong symbol. - */ -#ifdef WEAK_ALIAS -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) -#else -#define WSYSCALL(weak,strong) \ - RSYSCALL(weak) -#endif - -/* - * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls that - * never fail. - * - * XXX - This should be optimized. - */ -#define SYSCALL_NOERROR(x) \ -ENTRY(x); \ - mov _CAT(SYS_,x), %g1; \ - t ST_SYSCALL - -/* - * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls - * that never fail. - * - * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y), except that the - * name is x. - * - * XXX - This should be optimized. - */ -#define _RSYSCALL_NOERROR(x,y) \ -ENTRY(x); \ - mov (_CAT(SYS_,y)) | SYSCALL_G5RFLAG, %g1; \ - add %o7, 8, %g5; \ - t ST_SYSCALL - -#define RSYSCALL_NOERROR(x) _RSYSCALL_NOERROR(x,x) -#define PSEUDO_NOERROR(x,y) _RSYSCALL_NOERROR(x,y) - - .globl CERROR diff --git a/lib/libc/arch/sparc/gdtoa/Makefile.inc b/lib/libc/arch/sparc/gdtoa/Makefile.inc deleted file mode 100644 index 1d786e010..000000000 --- a/lib/libc/arch/sparc/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c diff --git a/lib/libc/arch/sparc/gdtoa/arith.h b/lib/libc/arch/sparc/gdtoa/arith.h deleted file mode 100644 index 4674f629c..000000000 --- a/lib/libc/arch/sparc/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_BIG_ENDIAN diff --git a/lib/libc/arch/sparc/gdtoa/gd_qnan.h b/lib/libc/arch/sparc/gdtoa/gd_qnan.h deleted file mode 100644 index 75f636b54..000000000 --- a/lib/libc/arch/sparc/gdtoa/gd_qnan.h +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 diff --git a/lib/libc/arch/sparc/gen/Makefile.inc b/lib/libc/arch/sparc/gen/Makefile.inc deleted file mode 100644 index 9fdda48bc..000000000 --- a/lib/libc/arch/sparc/gen/Makefile.inc +++ /dev/null @@ -1,35 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.23 2014/07/12 19:21:48 nakayama Exp $ - -SRCS+= fabs.S modf.S -SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c infinityl_dbl_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c - -SRCS+= setjmp.S longjmp.c -SRCS+= _setjmp.S -SRCS+= sigsetjmp.S - -SRCS+= makecontext.c resumecontext.c _lwp.c swapcontext.S - -.if ${MACHINE} == "sparc64" -.PATH: ${NETBSDSRCDIR}/lib/libarch/sparc/v8 -SRCS+= sparc_v8.S -.else -SRCS+= mul.S umul.S -.endif -SRCS+= fixunsdfsi.S saveregs.S -SRCS+= bswap16.c bswap32.c bswap64.c - -LSRCS.sparc.gen= Lint_swapcontext.c -LSRCS+= ${LSRCS.sparc.gen} -DPSRCS+= ${LSRCS.sparc.gen} -CLEANFILES+= ${LSRCS.sparc.gen} diff --git a/lib/libc/arch/sparc/gen/_lwp.c b/lib/libc/arch/sparc/gen/_lwp.c deleted file mode 100644 index 90450bd0d..000000000 --- a/lib/libc/arch/sparc/gen/_lwp.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.7 2012/03/21 00:34:04 christos Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.7 2012/03/21 00:34:04 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), void *arg, - void *private, caddr_t stack_base, size_t stack_size) -{ - __greg_t *gr; - unsigned long *sp; - - getcontext(u); - gr = u->uc_mcontext.__gregs; - - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - - sp = (void *)(stack_base + stack_size); - sp = (ulong *)((ulong)sp & ~0x07); - - /* Make room for the fake caller stack frame (CCFSZ, only in words) */ - sp -= 8 + 8 + 1 + 6 + 1; - - /* Entering (*start)(arg), return is to _lwp_exit */ - gr[_REG_PC] = (ulong) start; - gr[_REG_nPC] = (ulong) start + 4; - gr[_REG_O0] = (ulong)arg; - gr[_REG_O6] = (ulong)sp; - gr[_REG_O7] = (ulong)_lwp_exit - 8; - gr[_REG_G7] = (ulong)private; - - /* XXX: uwe: why do we need this? */ - /* create loopback in the window save area on the stack? */ - sp[8+6] = (ulong)sp; /* %i6 */ - sp[8+7] = (ulong)_lwp_exit - 8; /* %i7 */ -} diff --git a/lib/libc/arch/sparc/gen/_setjmp.S b/lib/libc/arch/sparc/gen/_setjmp.S deleted file mode 100644 index db8fb5bd2..000000000 --- a/lib/libc/arch/sparc/gen/_setjmp.S +++ /dev/null @@ -1,104 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.10 2014/07/12 19:11:57 nakayama Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: _setjmp.S,v 1.10 2014/07/12 19:11:57 nakayama Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v?v:1)" from - * the last call to - * _setjmp(a) - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - /* store important globals, sigsetjmp compatible */ - st %g3, [%o0 + 16] - st %g2, [%o0 + 24] - st %g4, [%o0 + 48] - st %g7, [%o0 + 52] - - st %sp, [%o0+0] /* store caller's stack pointer */ - st %o7, [%o0+4] /* and the return pc */ - retl - clr %o0 ! return 0 - -ENTRY(_longjmp) -#ifdef __sparc_v9__ - save %sp, -CCFSZ, %sp - flushw - /* - * We restore the saved stack pointer to %fp, then issue - * a `restore' instruction which will reload the register - * window from the stack. - */ - ld [%i0 + 16], %g3 - ld [%i0 + 24], %g2 - ld [%i0 + 48], %g4 - ld [%i0 + 52], %g7 - ld [%i0 + 4], %i7 /* restore return pc */ - ld [%i0 + 0], %fp /* and stack pointer */ - mov 1, %i0 - movrnz %i1, %i1, %i0 ! compute v ? v : 1 - ret - restore -#else - save %sp, -64, %sp ! set up a local stack frame - tst %i1 ! compute v ? v : 1 - be,a 0f - mov 1, %i1 -0: - t ST_FLUSHWIN ! flush register windows out to the stack - - /* restore globals */ - ld [%i0 + 16], %g3 - ld [%i0 + 24], %g2 - ld [%i0 + 48], %g4 - ld [%i0 + 52], %g7 - - /* - * We restore the saved stack pointer to %fp, then issue - * a `restore' instruction which will reload the register - * window from the stack. - */ - ld [%i0+4], %i7 /* restore return pc */ - ld [%i0+0], %fp /* and stack pointer */ - - ret ! success, return %i1 - restore %i1, 0, %o0 -#endif diff --git a/lib/libc/arch/sparc/gen/divrem.m4 b/lib/libc/arch/sparc/gen/divrem.m4 deleted file mode 100644 index 151ca0623..000000000 --- a/lib/libc/arch/sparc/gen/divrem.m4 +++ /dev/null @@ -1,272 +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. - * 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. - * - * from: Header: divrem.m4,v 1.4 92/06/25 13:23:57 torek Exp - * $NetBSD: divrem.m4,v 1.6 2011/03/23 20:54:35 martin Exp $ - */ - -/* - * Division and remainder, from Appendix E of the Sparc Version 8 - * Architecture Manual, with fixes from Gordon Irlam. - */ - -#if defined(LIBC_SCCS) && !defined(lint) - .asciz "@(#)divrem.m4 8.1 (Berkeley) 6/4/93" -#endif /* LIBC_SCCS and not lint */ - -/* - * Input: dividend and divisor in %o0 and %o1 respectively. - * - * m4 parameters: - * NAME name of function to generate - * OP OP=div => %o0 / %o1; OP=rem => %o0 % %o1 - * S S=true => signed; S=false => unsigned - * - * Algorithm parameters: - * N how many bits per iteration we try to get (4) - * WORDSIZE total number of bits (32) - * - * Derived constants: - * TWOSUPN 2^N, for label generation (m4 exponentiation currently broken) - * TOPBITS number of bits in the top `decade' of a number - * - * Important variables: - * Q the partial quotient under development (initially 0) - * R the remainder so far, initially the dividend - * ITER number of main division loop iterations required; - * equal to ceil(log2(quotient) / N). Note that this - * is the log base (2^N) of the quotient. - * V the current comparand, initially divisor*2^(ITER*N-1) - * - * Cost: - * Current estimate for non-large dividend is - * ceil(log2(quotient) / N) * (10 + 7N/2) + C - * A large dividend is one greater than 2^(31-TOPBITS) and takes a - * different path, as the upper bits of the quotient must be developed - * one bit at a time. - */ - -define(N, `4') -define(TWOSUPN, `16') -define(WORDSIZE, `32') -define(TOPBITS, eval(WORDSIZE - N*((WORDSIZE-1)/N))) - -define(dividend, `%o0') -define(divisor, `%o1') -define(Q, `%o2') -define(R, `%o3') -define(ITER, `%o4') -define(V, `%o5') - -/* m4 reminder: ifelse(a,b,c,d) => if a is b, then c, else d */ -define(T, `%g1') -define(SC, `%g5') -ifelse(S, `true', `define(SIGN, `%g6')') - -/* - * This is the recursive definition for developing quotient digits. - * - * Parameters: - * $1 the current depth, 1 <= $1 <= N - * $2 the current accumulation of quotient bits - * N max depth - * - * We add a new bit to $2 and either recurse or insert the bits in - * the quotient. R, Q, and V are inputs and outputs as defined above; - * the condition codes are expected to reflect the input R, and are - * modified to reflect the output R. - */ -define(DEVELOP_QUOTIENT_BITS, -` ! depth $1, accumulated bits $2 - bl L.$1.eval(TWOSUPN+$2) - srl V,1,V - ! remainder is positive - subcc R,V,R - ifelse($1, N, - ` b 9f - add Q, ($2*2+1), Q - ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2+1)')') -L.$1.eval(TWOSUPN+$2): - ! remainder is negative - addcc R,V,R - ifelse($1, N, - ` b 9f - add Q, ($2*2-1), Q - ', ` DEVELOP_QUOTIENT_BITS(incr($1), `eval(2*$2-1)')') - ifelse($1, 1, `9:')') - -#include -#include - -FUNC(NAME) -ifelse(S, `true', -` ! compute sign of result; if neither is negative, no problem - orcc divisor, dividend, %g0 ! either negative? - bge 2f ! no, go do the divide - ifelse(OP, `div', - `xor divisor, dividend, SIGN', - `mov dividend, SIGN') ! compute sign in any case - tst divisor - bge 1f - tst dividend - ! divisor is definitely negative; dividend might also be negative - bge 2f ! if dividend not negative... - neg divisor ! in any case, make divisor nonneg -1: ! dividend is negative, divisor is nonnegative - neg dividend ! make dividend nonnegative -2: -') - ! Ready to divide. Compute size of quotient; scale comparand. - orcc divisor, %g0, V - bnz 1f - mov dividend, R - - ! Divide by zero trap. If it returns, return 0 (about as - ! wrong as possible, but that is what SunOS does...). - t ST_DIV0 - retl - clr %o0 - -1: - cmp R, V ! if divisor exceeds dividend, done - blu Lgot_result ! (and algorithm fails otherwise) - clr Q - sethi %hi(1 << (WORDSIZE - TOPBITS - 1)), T - cmp R, T - blu Lnot_really_big - clr ITER - - ! `Here the dividend is >= 2^(31-N) or so. We must be careful here, - ! as our usual N-at-a-shot divide step will cause overflow and havoc. - ! The number of bits in the result here is N*ITER+SC, where SC <= N. - ! Compute ITER in an unorthodox manner: know we need to shift V into - ! the top decade: so do not even bother to compare to R.' - 1: - cmp V, T - bgeu 3f - mov 1, SC - sll V, N, V - b 1b - inc ITER - - ! Now compute SC. - 2: addcc V, V, V - bcc Lnot_too_big - inc SC - - ! We get here if the divisor overflowed while shifting. - ! This means that R has the high-order bit set. - ! Restore V and subtract from R. - sll T, TOPBITS, T ! high order bit - srl V, 1, V ! rest of V - add V, T, V - b Ldo_single_div - dec SC - - Lnot_too_big: - 3: cmp V, R - blu 2b - nop - be Ldo_single_div - nop - /* NB: these are commented out in the V8-Sparc manual as well */ - /* (I do not understand this) */ - ! V > R: went too far: back up 1 step - ! srl V, 1, V - ! dec SC - ! do single-bit divide steps - ! - ! We have to be careful here. We know that R >= V, so we can do the - ! first divide step without thinking. BUT, the others are conditional, - ! and are only done if R >= 0. Because both R and V may have the high- - ! order bit set in the first step, just falling into the regular - ! division loop will mess up the first time around. - ! So we unroll slightly... - Ldo_single_div: - deccc SC - bl Lend_regular_divide - nop - sub R, V, R - mov 1, Q - b Lend_single_divloop - nop - Lsingle_divloop: - sll Q, 1, Q - bl 1f - srl V, 1, V - ! R >= 0 - sub R, V, R - b 2f - inc Q - 1: ! R < 0 - add R, V, R - dec Q - 2: - Lend_single_divloop: - deccc SC - bge Lsingle_divloop - tst R - b,a Lend_regular_divide - -Lnot_really_big: -1: - sll V, N, V - cmp V, R - bleu 1b - inccc ITER - be Lgot_result - dec ITER - - tst R ! set up for initial iteration -Ldivloop: - sll Q, N, Q - DEVELOP_QUOTIENT_BITS(1, 0) -Lend_regular_divide: - deccc ITER - bge Ldivloop - tst R - bl,a Lgot_result - ! non-restoring fixup here (one instruction only!) -ifelse(OP, `div', -` dec Q -', ` add R, divisor, R -') - -Lgot_result: -ifelse(S, `true', -` ! check to see if answer should be < 0 - tst SIGN - bl,a 1f - ifelse(OP, `div', `neg Q', `neg R') -1:') - retl - ifelse(OP, `div', `mov Q, %o0', `mov R, %o0') diff --git a/lib/libc/arch/sparc/gen/fabs.S b/lib/libc/arch/sparc/gen/fabs.S deleted file mode 100644 index ef7dafa4b..000000000 --- a/lib/libc/arch/sparc/gen/fabs.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: fabs.S,v 1.4 2003/08/07 16:42:23 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: fabs.s,v 1.4 91/10/07 23:59:05 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)fabs.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: fabs.S,v 1.4 2003/08/07 16:42:23 agc Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* fabs - floating absolute value */ - - -ENTRY(fabs) - std %o0, [%sp + 32] ! return value => %f0:f1 - ldd [%sp + 32], %f0 ! (via kernel %o0/%o1 slot) - retl - fabss %f0, %f0 ! return absolute value diff --git a/lib/libc/arch/sparc/gen/fixunsdfsi.S b/lib/libc/arch/sparc/gen/fixunsdfsi.S deleted file mode 100644 index 1d258ba4b..000000000 --- a/lib/libc/arch/sparc/gen/fixunsdfsi.S +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: fixunsdfsi.S,v 1.6 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: fixunsdfsi.s,v 1.3 91/10/08 00:03:15 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)fixunsdfsi.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: fixunsdfsi.S,v 1.6 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * Convert double to unsigned integer (for gcc). - * - * I have made the output for NaN agree with the Sun compiler, not - * that it really matters, by using `fbul,a'. - */ - - - .align 8 -Lbig: - .word 0x41e00000 ! .double 0r2147483648.0e+00 - .word 0 ! (who me, not trust the assembler?) - -ENTRY(__fixunsdfsi) - sub %sp, 8, %sp - std %o0, [%sp + 64] ! get argument into fpu reg - ldd [%sp + 64], %f0 -#ifdef __PIC__ - PICCY_SET(Lbig, %g1, %o0) - ldd [%g1], %f2 -#else - sethi %hi(Lbig), %g1 - ldd [%g1 + %lo(Lbig)], %f2 -#endif - fcmped %f0, %f2 ! d < 2^31, or NaN, or -Inf? - nop ! (fpop2 delay) - fbul,a 1f ! if so, use fdtoi to convert to int - fdtoi %f0, %f0 ! (this includes negatives!) - - ! d does not fit in an int, so subtract 2^31, convert, - ! and add 2^31 again (sigh). Just hope the intermediate - ! fits (if not, the result is undefined anyway). - - fsubd %f0, %f2, %f0 ! d -= 2^31 - fdtoi %f0, %f0 ! convert to int - st %f0, [%sp + 64] ! move into return reg - ld [%sp + 64], %o0 - sethi %hi(0x80000000), %o1 - add %o0, %o1, %o0 ! add 2^31 - retl - add %sp, 8, %sp - -1: - st %f0, [%sp + 64] ! return result - ld [%sp + 64], %o0 - retl - add %sp, 8, %sp diff --git a/lib/libc/arch/sparc/gen/flt_rounds.c b/lib/libc/arch/sparc/gen/flt_rounds.c deleted file mode 100644 index c64b1ff86..000000000 --- a/lib/libc/arch/sparc/gen/flt_rounds.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.7 2012/03/21 00:38:34 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.7 2012/03/21 00:38:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 0, /* round to zero */ - 2, /* round to positive infinity */ - 3 /* round to negative infinity */ -}; - -int -__flt_rounds(void) -{ - unsigned int x; - - __asm("st %%fsr,%0" : "=m" (*&x)); - return map[(x >> 30) & 0x03]; -} diff --git a/lib/libc/arch/sparc/gen/fpgetmask.c b/lib/libc/arch/sparc/gen/fpgetmask.c deleted file mode 100644 index 281e2474b..000000000 --- a/lib/libc/arch/sparc/gen/fpgetmask.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.6 2012/03/21 00:38:34 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.6 2012/03/21 00:38:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -fp_except -fpgetmask(void) -{ - unsigned int x; - - __asm("st %%fsr,%0" : "=m" (*&x)); - return (x >> 23) & 0x1f; -} diff --git a/lib/libc/arch/sparc/gen/fpgetround.c b/lib/libc/arch/sparc/gen/fpgetround.c deleted file mode 100644 index eafd21a24..000000000 --- a/lib/libc/arch/sparc/gen/fpgetround.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.6 2012/03/21 00:38:34 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.6 2012/03/21 00:38:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -fp_rnd -fpgetround(void) -{ - unsigned int x; - - __asm("st %%fsr,%0" : "=m" (*&x)); - return (x >> 30) & 0x03; -} diff --git a/lib/libc/arch/sparc/gen/fpgetsticky.c b/lib/libc/arch/sparc/gen/fpgetsticky.c deleted file mode 100644 index 3184ee1bc..000000000 --- a/lib/libc/arch/sparc/gen/fpgetsticky.c +++ /dev/null @@ -1,28 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.6 2012/03/21 00:38:34 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.6 2012/03/21 00:38:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -fp_except -fpgetsticky(void) -{ - unsigned int x; - - __asm("st %%fsr,%0" : "=m" (*&x)); - return (x >> 5) & 0x1f; -} diff --git a/lib/libc/arch/sparc/gen/fpsetmask.c b/lib/libc/arch/sparc/gen/fpsetmask.c deleted file mode 100644 index 250761e48..000000000 --- a/lib/libc/arch/sparc/gen/fpsetmask.c +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.6 2012/03/21 00:38:34 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.6 2012/03/21 00:38:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -fp_except -fpsetmask(fp_except mask) -{ - fp_except old; - fp_except new; - - __asm("st %%fsr,%0" : "=m" (*&old)); - - new = old; - new &= ~(0x1f << 23); - new |= ((mask & 0x1f) << 23); - - __asm("ld %0,%%fsr" : : "m" (*&new)); - - return (old >> 23) & 0x1f; -} diff --git a/lib/libc/arch/sparc/gen/fpsetround.c b/lib/libc/arch/sparc/gen/fpsetround.c deleted file mode 100644 index 4a0700ffa..000000000 --- a/lib/libc/arch/sparc/gen/fpsetround.c +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.6 2012/03/21 00:38:35 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.6 2012/03/21 00:38:35 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - fp_rnd old; - fp_rnd new; - - __asm("st %%fsr,%0" : "=m" (*&old)); - - new = old; - new &= ~(0x03 << 30); - new |= ((rnd_dir & 0x03) << 30); - - __asm("ld %0,%%fsr" : : "m" (*&new)); - - return ((unsigned int)old >> 30) & 0x03; -} diff --git a/lib/libc/arch/sparc/gen/fpsetsticky.c b/lib/libc/arch/sparc/gen/fpsetsticky.c deleted file mode 100644 index 63d3a9ba0..000000000 --- a/lib/libc/arch/sparc/gen/fpsetsticky.c +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.6 2013/10/18 02:19:12 mrg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.6 2013/10/18 02:19:12 mrg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -fp_except -fpsetsticky(fp_except sticky) -{ - fp_except old; - fp_except new; - - __asm("st %%fsr,%0" : "=m" (*&old)); - - new = old; - new &= ~(0x1f << 5); - new |= ((sticky & 0x1f) << 5); - - __asm("ld %0,%%fsr" : : "m" (*&new)); - - return (old >> 5) & 0x1f; -} diff --git a/lib/libc/arch/sparc/gen/longjmp.c b/lib/libc/arch/sparc/gen/longjmp.c deleted file mode 100644 index fe46e50a8..000000000 --- a/lib/libc/arch/sparc/gen/longjmp.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $NetBSD: longjmp.c,v 1.3 2011/04/30 23:41:12 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christian Limpach. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include - -struct __jmp_buf_regs_t { - __greg_t g4; - __greg_t g7; - __greg_t save_mask; -}; - -/* - * setjmp.S uses hard coded offsets into the jump_buf, - * make sure any changes cause a compile failure here - */ -__CTASSERT(56 == offsetof(struct __jmp_buf_regs_t,save_mask) + - sizeof(struct sigcontext)); -__CTASSERT(sizeof(sigjmp_buf) >= sizeof(struct __jmp_buf_regs_t) + - sizeof(struct sigcontext)); - -/* - * Use setcontext to reload the stack pointer, program counter , and - * set the return value in %o0. The %i and %l registers will be reloaded - * from the place to which %sp points. - */ -void -__longjmp14(jmp_buf env, int val) -{ - struct sigcontext *sc = (void *)env; - struct __jmp_buf_regs_t *r = (void*)&sc[1]; - ucontext_t uc; - - /* Ensure non-zero SP */ - if (sc->sc_sp == 0) - goto err; - - /* Initialise the context */ - memset(&uc, 0, sizeof(uc)); - - /* - * Set _UC_{SET,CLR}STACK according to SS_ONSTACK. - * - * Restore the signal mask with sigprocmask() instead of _UC_SIGMASK, - * since libpthread may want to interpose on signal handling. - */ - uc.uc_flags = _UC_CPU | (sc->sc_onstack ? _UC_SETSTACK : _UC_CLRSTACK); - - sigprocmask(SIG_SETMASK, &sc->sc_mask, NULL); - - /* Extract PSR, PC, NPC and SP from jmp_buf */ - uc.uc_mcontext.__gregs[_REG_PSR] = sc->sc_psr; - uc.uc_mcontext.__gregs[_REG_PC] = sc->sc_pc; - uc.uc_mcontext.__gregs[_REG_nPC] = sc->sc_pc+4; - uc.uc_mcontext.__gregs[_REG_O6] = sc->sc_sp; - uc.uc_mcontext.__gregs[_REG_G2] = sc->sc_g1; - uc.uc_mcontext.__gregs[_REG_G3] = sc->sc_npc; - uc.uc_mcontext.__gregs[_REG_G4] = r->g4; - uc.uc_mcontext.__gregs[_REG_G7] = r->g7; - - /* Set the return value; make sure it's non-zero */ - uc.uc_mcontext.__gregs[_REG_O0] = (val != 0 ? val : 1); - - setcontext(&uc); - -err: - longjmperror(); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/sparc/gen/makecontext.c b/lib/libc/arch/sparc/gen/makecontext.c deleted file mode 100644 index 1742bfb27..000000000 --- a/lib/libc/arch/sparc/gen/makecontext.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.3 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - int i; - unsigned long *sp; - va_list ap; - - sp = (unsigned long *) - ((unsigned long)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - /* Make room for: rwindow, struct return pointer, argd, argx */ - sp -= 8 + 8 + 1 + 6 + 1; /* CCFSZ, only in words */ - /* CCFSZ provides space for up to 7 arguments, add more if necessary */ - if (argc > 7) - sp -= argc - 7; - /* Align on double-word boundary. */ - sp = (unsigned long *)((unsigned long)sp & ~0x7); - - gr[_REG_O6] = (__greg_t)sp; - gr[_REG_PC] = (__greg_t)func; - gr[_REG_nPC] = (__greg_t)func + 4; - gr[_REG_O7] = (__greg_t)_resumecontext - 8; - - va_start(ap, argc); - /* Pass up to 6 arguments in %o0..%o5. */ - for (i = 0; i < argc && i < 6; i++) - gr[_REG_O0 + i] = va_arg(ap, unsigned long); - /* Pass any additional arguments on the stack. */ - for (/* i = 6 */; i < argc; i++) - sp[8 + 8 + 1 + 6 + (i - 6)] = va_arg(ap, unsigned long); - va_end(ap); -} diff --git a/lib/libc/arch/sparc/gen/modf.S b/lib/libc/arch/sparc/gen/modf.S deleted file mode 100644 index 72fd57467..000000000 --- a/lib/libc/arch/sparc/gen/modf.S +++ /dev/null @@ -1,197 +0,0 @@ -/* $NetBSD: modf.S,v 1.7 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: modf.s,v 1.3 92/06/20 00:00:54 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: modf.S,v 1.7 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#include - -/* - * 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 - 4] saved %fsr - * 4@[%fp - 8] new %fsr with rounding set to `towards 0' - * 8@[%fp - 16] space for moving between %i and %f registers - * Register usage: - * %i0%i1 double val; - * %l0 scratch - * %l1 sign bit (0x80000000) - * %i2 double *iptr; - * %f2:f3 `magic number' 2^52, in fpu registers - * %f4:f5 double v, in fpu registers - */ - - .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, -64-16, %sp - - /* - * First, compute v = abs(val) by clearing sign bit, - * and then set up the fpu registers. This would be - * much easier if we could do alu operations on fpu registers! - */ - sethi %hi(0x80000000), %l1 ! sign bit - andn %i0, %l1, %l0 - st %l0, [%fp - 16] -#ifdef __PIC__ - PICCY_SET(Lmagic, %l0, %o7) - ldd [%l0], %f2 -#else - sethi %hi(Lmagic), %l0 - ldd [%l0 + %lo(Lmagic)], %f2 -#endif - st %i1, [%fp - 12] - ldd [%fp - 16], %f4 ! %f4:f5 = v - - /* - * Is %f4:f5 >= %f2:f3 ? If so, it is all integer bits. - * It is probably less, though. - */ - fcmped %f4, %f2 - nop ! fpop2 delay - 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 - 4] ! %l5 = current FSR mode - set FSR_RD, %l3 ! %l3 = rounding direction mask - ld [%fp - 4], %l5 - set FSR_RD_RZ << FSR_RD_SHIFT, %l4 - andn %l5, %l3, %l6 - or %l6, %l4, %l6 ! round towards zero, please - and %l5, %l3, %l5 ! save original rounding mode - st %l6, [%fp - 8] - ld [%fp - 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 - 4] - ld [%fp - 4], %l6 - andn %l6, %l3, %l6 ! %l6 = %fsr & ~FSR_RD; - or %l5, %l6, %l5 ! %l5 |= %l6; - st %l5, [%fp - 4] - ld [%fp - 4], %fsr ! restore %fsr, leaving accrued stuff - - /* - * Now insert the original sign in %f4:f5. - * This is a lot of work, so it is conditional here. - */ - btst %l1, %i0 - be 1f - nop - st %f4, [%fp - 16] - ld [%fp - 16], %g1 - or %l1, %g1, %g1 - st %g1, [%fp - 16] - ld [%fp - 16], %f4 -1: - - /* - * The value in %f4:f5 is now the integer portion of the original - * argument. We need to store this in *ival (%i2), subtract it - * from the original value argument (%i0:i1), and return the result. - */ - std %f4, [%i2] ! *ival = %f4:f5; - std %i0, [%fp - 16] - ldd [%fp - 16], %f0 ! %f0:f1 = val; - 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. - */ -#ifdef __PIC__ - PICCY_SET(L0, %l0, %o7) - std %f0, [%i2] ! *ival = val; - ldd [%l0], %f0 ! return 0.0; -#else - sethi %hi(L0), %l0 - std %f0, [%i2] ! *ival = val; - ldd [%l0 + %lo(L0)], %f0 ! return 0.0; -#endif - ret - restore diff --git a/lib/libc/arch/sparc/gen/nanf.c b/lib/libc/arch/sparc/gen/nanf.c deleted file mode 100644 index 1688d0eae..000000000 --- a/lib/libc/arch/sparc/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xc0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/sparc/gen/resumecontext.c b/lib/libc/arch/sparc/gen/resumecontext.c deleted file mode 100644 index 57d68fdf8..000000000 --- a/lib/libc/arch/sparc/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/sparc/gen/setjmp.S b/lib/libc/arch/sparc/gen/setjmp.S deleted file mode 100644 index 451f3c70f..000000000 --- a/lib/libc/arch/sparc/gen/setjmp.S +++ /dev/null @@ -1,88 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.12 2011/04/30 23:41:13 martin Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: setjmp.s,v 1.2 92/06/25 03:18:43 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: setjmp.S,v 1.12 2011/04/30 23:41:13 martin Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "SYS.h" - -ENTRY(__setjmp14) - save %sp, -CCFSZ, %sp - /* - * local vars on stack: struct sigstack foo @ offset 0x48 - * Note: sc_g1 is not used; sc_o0 is set in longjmp() - */ - mov 1, %o0 /* SIG_BLOCK */ - add %i0, 32, %o2 /* build sigcontext sc.sc_mask */ - call _C_LABEL(__sigprocmask14) - clr %o1 /* sigprocmask(SIG_BLOCK, NULL, &sc.sc_mask) */ - - add %sp, 0x48, %o1 /* (foo being in arg dump area) */ - call _C_LABEL(__sigaltstack14) - clr %o0 /* sigstack(NULL, &foo) */ - - ld [%sp + 0x48 + 8], %o0 /* foo.ss_flags */ - and %o0, 1, %o1 /* onstack = foo.ss_flags & 1; */ - st %o1, [%i0 + 0] /* sc.sc_onstack = current onstack; */ - st %fp, [%i0 + 8] /* sc.sc_sp = (caller's) sp */ - add %i7, 8, %o0 - st %o0, [%i0 + 12] /* sc.sc_pc = return_pc */ - st %g3, [%i0 + 16] /* sc.sc_npc */ - st %g0, [%i0 + 20] /* sc.sc_psr = (clean psr) */ - st %g2, [%i0 + 24] - st %g4, [%i0 + 48] - st %g7, [%i0 + 52] - ret /* return 0 */ - restore %g0, %g0, %o0 - diff --git a/lib/libc/arch/sparc/gen/sigsetjmp.S b/lib/libc/arch/sparc/gen/sigsetjmp.S deleted file mode 100644 index 27281ca3c..000000000 --- a/lib/libc/arch/sparc/gen/sigsetjmp.S +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.7 2013/09/12 15:36:16 joerg Exp $ */ -/* - * Copyright (c) 1995 Paul Kranenburg - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "SYS.h" - -#ifdef __PIC__ - -ENTRY(__sigsetjmp14) - PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE - tst %o1 - bnz 1f - st %o1, [%o0 + 56] ! jmpbuf[JBLEN] = savemask - - !! if (savemask == 0) goto _setjmp - set _C_LABEL(_setjmp), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - - !! if (savemask != 0) goto setjmp -1: set _C_LABEL(__setjmp14), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - - -ENTRY(__siglongjmp14) - PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE - ld [%o0 + 56], %g2 ! restoremask = jmpbuf[JBLEN] - tst %g2 - bnz 1f - nop - - !! if (restoremask == 0) goto _longjmp - set _C_LABEL(_longjmp), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - - !! if (restoremask != 0) goto longjmp -1: set _C_LABEL(__longjmp14), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - -#else /* !__PIC__ */ - -ENTRY(__sigsetjmp14) - cmp %o1,0 - be _C_LABEL(_setjmp) - st %o1,[%o0+56] ! jmpbuf[JBLEN] - nop - ba,a _C_LABEL(__setjmp14) - unimp 0 - -ENTRY(__siglongjmp14) - ld [%o0+56],%g1 - cmp %g1,0 - be _C_LABEL(_longjmp) - nop - ba,a _C_LABEL(__longjmp14) - unimp 0 - -#endif /* !__PIC__ */ diff --git a/lib/libc/arch/sparc/gen/swapcontext.S b/lib/libc/arch/sparc/gen/swapcontext.S deleted file mode 100644 index 21830b44a..000000000 --- a/lib/libc/arch/sparc/gen/swapcontext.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.5 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.5 2013/09/12 15:36:16 joerg Exp $") -#endif /* LIBC_SCCS && !lint */ - -ENTRY(swapcontext) - mov %o0, %o2 ! must save pointer - mov %o1, %o3 ! must save pointer - mov SYS_getcontext, %g1 - t ST_SYSCALL - bcc,a 1f - st %g0, [%o2 + 40 + 11 * 4] ! gr[_REG_O0] = 0 - ERROR() -1: - add %o7, 12, %o1 - st %o1, [%o2 + 40 + 2 * 4] ! gr[_REG_nPC] = retaddr + 4 - add %o7, 8, %o1 - st %o1, [%o2 + 40 + 1 * 4] ! gr[_REG_PC] = retaddr - -#ifdef __PIC__ - PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE - set _C_LABEL(setcontext), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - mov %o3, %o0 -#else - jmp _C_LABEL(setcontext) - mov %o3, %o0 -#endif diff --git a/lib/libc/arch/sparc/net/Makefile.inc b/lib/libc/arch/sparc/net/Makefile.inc deleted file mode 100644 index 0279aaa3b..000000000 --- a/lib/libc/arch/sparc/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 1995/02/25 14:59:11 cgd Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/sparc/stdlib/Makefile.inc b/lib/libc/arch/sparc/stdlib/Makefile.inc deleted file mode 100644 index 102817f9c..000000000 --- a/lib/libc/arch/sparc/stdlib/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/08/11 17:30:43 dsl Exp $ - -SRCS+= llabs.S -NO_SRCS+= imaxabs.S diff --git a/lib/libc/arch/sparc/stdlib/llabs.S b/lib/libc/arch/sparc/stdlib/llabs.S deleted file mode 100644 index ab81609cc..000000000 --- a/lib/libc/arch/sparc/stdlib/llabs.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: llabs.S,v 1.4 2008/08/04 21:29:28 matt Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: abs.s,v 1.1 91/07/06 18:01:57 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "from: @(#)abs.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: llabs.S,v 1.4 2008/08/04 21:29:28 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(llabs, _llabs) -WEAK_ALIAS(imaxabs, _llabs) -#endif - -/* llabs - long long int absolute value */ -/* imaxabs - intmax_t absolute value */ - - -#ifdef WEAK_ALIAS -ENTRY(_llabs) -#else -ENTRY(llabs) -#endif - tst %o0 - bge 1f - nop - subcc %g0, %o1, %o1 - subx %g0, %o0, %o0 -1: retl - nop diff --git a/lib/libc/arch/sparc/string/Makefile.inc b/lib/libc/arch/sparc/string/Makefile.inc deleted file mode 100644 index ed9c5d329..000000000 --- a/lib/libc/arch/sparc/string/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/07/30 20:57:17 dsl Exp $ - -SRCS+= bzero.S ffs.S memset.S strlen.S diff --git a/lib/libc/arch/sparc/sys/__clone.S b/lib/libc/arch/sparc/sys/__clone.S deleted file mode 100644 index c420ded64..000000000 --- a/lib/libc/arch/sparc/sys/__clone.S +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: __clone.S,v 1.6 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - save %sp, -CCFSZ, %sp - - /* - * Sanity checks: func and stack may not be NULL. - */ - tst %i0 - be 8f ! func == NULL, bail - orcc %i1, %g0, %o1 ! setup stack arg for syscall, test - be 8f ! stack == NULL, bail - mov %i2, %o0 ! setup flags arg for syscall - - /* - * Allocate "caller's" frame in the child stack as ABI - * requires. - * - * We pass the function and the argument to the child by - * stashing them at the bottom of the frame. There they are - * safe from window spill would we need to take one as it's - * below the window save area. - */ - sub %o1, CCFSZ, %o1 ! make space on the child's stack - st %i0, [%o1+CCFSZ-8] ! save func - st %i3, [%o1+CCFSZ-4] ! save arg - - /* - * Args are now set up for system call as (flags, stack). - */ - mov SYS___clone, %g1 - t ST_SYSCALL - bcs 9f - tst %o1 ! %o1 (rv[1]) == 0 in parent - -1: bz 2f ! yes, parent - ld [%sp+CCFSZ-8], %l0 ! grab the function... - call %l0 ! Call the clone's entry point. - ld [%sp+CCFSZ-4], %o0 ! ...and the argument from the stack - - CALL(_C_LABEL(_exit)) - /* NOTREACHED */ - -2: ret - restore %g0, %o0, %o0 - -8: restore %g0, EINVAL, %o0 - ERROR() - /* NOTREACHED */ - -9: restore %g0, %o0, %o0 - ERROR() - /* NOTREACHED */ diff --git a/lib/libc/arch/sparc/sys/__sigaction14_sigtramp.c b/lib/libc/arch/sparc/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 263296403..000000000 --- a/lib/libc/arch/sparc/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.7 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.7 2008/04/28 20:22:57 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern void __sigtramp_siginfo_2(void); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the compatibility SIGCONTEXT trampoline if SA_SIGINFO - * is not set in the sigaction. - */ - if (act && (act->sa_flags & SA_SIGINFO) == 0) { - extern void __sigtramp_sigcontext_1(void); - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - /* - * EINVAL might indicate that trampoline version 1 is - * not supported by the kernel; fall back on native - * SIGINFO trampoline. - */ - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/sparc/sys/__sigtramp2.S b/lib/libc/arch/sparc/sys/__sigtramp2.S deleted file mode 100644 index 3cb90dad3..000000000 --- a/lib/libc/arch/sparc/sys/__sigtramp2.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __sigtramp2.S,v 1.2 2008/04/28 20:22:57 martin Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * When this code is run, the stack looks like: - * [%sp] struct frame - * [%sp + 96] siginfo_t - * [%sp + 96 + 128] ucontext_t - * . - * . - */ -ENTRY_NOPROFILE(__sigtramp_siginfo_2) - add %sp, 96 + 128, %o0 /* get pointer to ucontext */ - mov SYS_setcontext, %g1 - t ST_SYSCALL /* call setcontext */ - mov SYS_exit, %g1 /* exit with errno */ - t ST_SYSCALL /* if sigreturn fails */ diff --git a/lib/libc/arch/sparc/sys/__syscall.S b/lib/libc/arch/sparc/sys/__syscall.S deleted file mode 100644 index 1e00e4205..000000000 --- a/lib/libc/arch/sparc/sys/__syscall.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __syscall.S,v 1.2 2008/04/28 20:22:57 martin Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -RSYSCALL(__syscall) diff --git a/lib/libc/arch/sparc/sys/__vfork14.S b/lib/libc/arch/sparc/sys/__vfork14.S deleted file mode 100644 index 74cc932ce..000000000 --- a/lib/libc/arch/sparc/sys/__vfork14.S +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.2 2003/08/07 16:42:25 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: Ovfork.s,v 1.1 91/07/06 13:05:56 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: __vfork14.S,v 1.2 2003/08/07 16:42:25 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * pid = vfork(); - * - * %o1 == 0 in parent process, 1 in child process. - * %o0 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -SYSCALL(__vfork14) - dec %o1 ! from 1 to 0 in child, 0 to -1 in parent - retl - and %o0, %o1, %o0 ! return 0 in child, pid in parent diff --git a/lib/libc/arch/sparc/sys/brk.S b/lib/libc/arch/sparc/sys/brk.S deleted file mode 100644 index 8825956a1..000000000 --- a/lib/libc/arch/sparc/sys/brk.S +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: brk.S,v 1.16 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: brk.s,v 1.3 92/06/25 12:56:05 mccanne Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)brk.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: brk.S,v 1.16 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl CURBRK - .globl _C_LABEL(__minbrk) - .globl _end - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data -_C_LABEL(__minbrk): - .long _end ! lower brk limit; also for gmon code - .text - -ENTRY(_brk) -#ifdef __PIC__ - PIC_PROLOGUE(%o5,%o4) - set _C_LABEL(__minbrk), %o4 - ld [%o5 + %o4], %o4 - ld [%o4], %o1 ! %o1 = minbrk - cmp %o1, %o0 ! if (minbrk > %o0) - bgu,a 0f - mov %o1, %o0 ! %o0 = minbrk -0: - mov %o0, %o2 ! save argument to syscall - mov SYS_break, %g1 - t ST_SYSCALL - set CURBRK, %o3 - bcc,a 1f - ld [%o5 + %o3], %o4 - ERROR() -1: - retl ! success, return 0 & record new break - st %o2, [%o4] -#else - sethi %hi(_C_LABEL(__minbrk)), %o1 ! %o1 = minbrk - ld [%o1 + %lo(_C_LABEL(__minbrk))], %o1 - cmp %o1, %o0 ! if (minbrk > %o0) - bgu,a 0f - mov %o1, %o0 ! %o0 = minbrk -0: - mov %o0, %o2 ! save argument to syscall - mov SYS_break, %g1 - t ST_SYSCALL - bcc,a 1f - sethi %hi(CURBRK), %g1 - ERROR() -1: - retl ! success, return 0 & record new break - st %o2, [%g1 + %lo(CURBRK)] -#endif diff --git a/lib/libc/arch/sparc/sys/cerror.S b/lib/libc/arch/sparc/sys/cerror.S deleted file mode 100644 index 10a71e0fb..000000000 --- a/lib/libc/arch/sparc/sys/cerror.S +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: cerror.S,v 1.11 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: cerror.s,v 1.3 92/07/02 04:17:59 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)cerror.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: cerror.S,v 1.11 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef _REENTRANT -FUNC(CERROR) - save %sp, -CCFSZ, %sp - call _C_LABEL(__errno) - nop - st %i0, [%o0] - mov -1, %i0 - ret - restore %g0, -1, %o1 -#else - .globl _C_LABEL(errno) -#ifdef __PIC__ -FUNC(CERROR) - set _C_LABEL(errno), %g2 - ld [%g1 + %g2], %g1 - st %o0, [%g1] - mov -1, %o0 - retl - mov -1, %o1 -#else -FUNC(CERROR) - sethi %hi(_C_LABEL(errno)), %g1 - st %o0, [%g1 + %lo(_C_LABEL(errno))] - mov -1, %o0 - retl - mov -1, %o1 -#endif -#endif /* _REENTRANT */ diff --git a/lib/libc/arch/sparc/sys/exect.S b/lib/libc/arch/sparc/sys/exect.S deleted file mode 100644 index 208cef90b..000000000 --- a/lib/libc/arch/sparc/sys/exect.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: exect.S,v 1.3 2003/08/07 16:42:25 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: exect.s,v 1.1 91/07/06 13:05:57 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)exect.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: exect.S,v 1.3 2003/08/07 16:42:25 agc Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(exect) - mov SYS_execve, %g1 /* execve(file, argv, env) */ - t ST_SYSCALL - ERROR() diff --git a/lib/libc/arch/sparc/sys/fork.S b/lib/libc/arch/sparc/sys/fork.S deleted file mode 100644 index 1ffb1901b..000000000 --- a/lib/libc/arch/sparc/sys/fork.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: fork.S,v 1.5 2003/08/07 16:42:25 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: fork.s,v 1.1 91/07/06 13:05:58 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)fork.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: fork.S,v 1.5 2003/08/07 16:42:25 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -_SYSCALL(__fork,fork) - dec %o1 ! from 1 to 0 in child, 0 to -1 in parent - retl - and %o0, %o1, %o0 ! return 0 in child, pid in parent diff --git a/lib/libc/arch/sparc/sys/getcontext.S b/lib/libc/arch/sparc/sys/getcontext.S deleted file mode 100644 index d5788bb01..000000000 --- a/lib/libc/arch/sparc/sys/getcontext.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.2 2008/04/28 20:22:57 martin Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -ENTRY(_getcontext) - mov %o0, %o2 ! must save pointer - mov SYS_getcontext, %g1 - t ST_SYSCALL - bcc,a 1f - clr [%o2 + 40 + 11 * 4] ! gr[_REG_O0] = 0 - ERROR() -1: - add %o7, 8, %o1 - st %o1, [%o2 + 40 + 1 * 4] ! gr[_REG_PC] = retaddr - add %o7, 12, %o1 - retl - st %o1, [%o2 + 40 + 2 * 4] ! gr[_REG_nPC] = retaddr + 4 diff --git a/lib/libc/arch/sparc/sys/pipe.S b/lib/libc/arch/sparc/sys/pipe.S deleted file mode 100644 index 457c713f3..000000000 --- a/lib/libc/arch/sparc/sys/pipe.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: pipe.S,v 1.4 2003/08/07 16:42:25 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: pipe.s,v 1.1 91/07/06 13:05:58 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)pipe.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: pipe.S,v 1.4 2003/08/07 16:42:25 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe) - mov %o0, %o2 ! save pointer - mov SYS_pipe, %g1 - t ST_SYSCALL ! pipe() - bcc,a 1f - st %o0, [%o2] ! success, store fds - ERROR() -1: - st %o1, [%o2 + 4] - retl ! and return 0 - clr %o0 diff --git a/lib/libc/arch/sparc/sys/ptrace.S b/lib/libc/arch/sparc/sys/ptrace.S deleted file mode 100644 index b0f3e66b9..000000000 --- a/lib/libc/arch/sparc/sys/ptrace.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.9 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: ptrace.s,v 1.2 91/12/20 01:59:00 leres Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)ptrace.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: ptrace.S,v 1.9 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(ptrace) -#ifdef _REENTRANT - save %sp, -CCFSZ, %sp - call _C_LABEL(__errno) - nop - st %g0, [%o0] - restore -#else -#ifdef __PIC__ - PIC_PROLOGUE(%g1,%g2) - set _C_LABEL(errno), %g2 - ld [%g1 + %g2], %g1 - st %g0, [%g1] -#else - sethi %hi(_C_LABEL(errno)), %g1 - st %g0, [%g1 + %lo(_C_LABEL(errno))] -#endif -#endif /* !_REENTRANT */ - mov SYS_ptrace, %g1 - t ST_SYSCALL - bcc 1f - nop - ERROR() -1: - retl - nop diff --git a/lib/libc/arch/sparc/sys/sbrk.S b/lib/libc/arch/sparc/sys/sbrk.S deleted file mode 100644 index 1a8347bc5..000000000 --- a/lib/libc/arch/sparc/sys/sbrk.S +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.11 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sbrk.s,v 1.3 92/07/02 00:56:49 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: sbrk.S,v 1.11 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl CURBRK - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data -CURBRK: .long _end - .text - -ENTRY(_sbrk) -#ifdef __PIC__ - PIC_PROLOGUE(%o5,%o4) - set CURBRK, %o2 - ld [%o5 + %o2], %o2 - ld [%o2], %o3 ! %o3 = old break - add %o3, %o0, %o4 ! %o4 = new break - mov %o4, %o0 ! copy for syscall - mov SYS_break, %g1 - t ST_SYSCALL ! break(new_break) - bcc,a 1f ! if success, - mov %o3, %o0 ! set return value - ERROR() -1: - retl ! and update curbrk - st %o4, [%o2] -#else - sethi %hi(CURBRK), %o2 - ld [%o2 + %lo(CURBRK)], %o3 ! %o3 = old break - add %o3, %o0, %o4 ! %o4 = new break - mov %o4, %o0 ! copy for syscall - mov SYS_break, %g1 - t ST_SYSCALL ! break(new_break) - bcc,a 1f ! if success, - mov %o3, %o0 ! set return value - ERROR() -1: - retl ! and update curbrk - st %o4, [%o2 + %lo(CURBRK)] -#endif diff --git a/lib/libc/arch/sparc/sys/shmat.S b/lib/libc/arch/sparc/sys/shmat.S deleted file mode 100644 index 7f57fad5f..000000000 --- a/lib/libc/arch/sparc/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:54 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/sparc/sys/syscall.S b/lib/libc/arch/sparc/sys/syscall.S deleted file mode 100644 index b824c4312..000000000 --- a/lib/libc/arch/sparc/sys/syscall.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: syscall.S,v 1.4 2003/08/07 16:42:26 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: syscall.s,v 1.1 91/07/06 13:06:02 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)syscall.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: syscall.S,v 1.4 2003/08/07 16:42:26 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -RSYSCALL(syscall) diff --git a/lib/libc/arch/sparc64/Makefile.inc b/lib/libc/arch/sparc64/Makefile.inc deleted file mode 100644 index 7d1503303..000000000 --- a/lib/libc/arch/sparc64/Makefile.inc +++ /dev/null @@ -1,23 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.20 2015/04/15 19:13:46 mrg Exp $ - -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S - -# Some assembler files use v9a extensions. -AFLAGS+= -Wa,-Av9a - -.PATH: ${ARCHDIR}/softfloat -SRCS+= qp.c -CPPFLAGS+= -DSOFTFLOATSPARC64_FOR_GCC -DEXCEPTIONS_WITH_SOFTFLOAT -CPPFLAGS+= -DSOFTFLOAT_NEED_FIXUNS -.if ${MKSOFTFLOAT} != "no" -.include -.else -# -# Can't directly use softfloat.c due to .PATH issues with the other source -# in softfloat. Just provide a wrapper which pulls it in via a #include -SRCS.softfloat= softfloat-wrapper.c -SRCS+= ${SRCS.softfloat} -CPPFLAGS+= -I${ARCHDIR}/softfloat -I${.CURDIR}/softfloat \ - -I${.CURDIR}/softfloat/bits64 - -.endif diff --git a/lib/libc/arch/sparc64/SYS.h b/lib/libc/arch/sparc64/SYS.h deleted file mode 100644 index be929b38c..000000000 --- a/lib/libc/arch/sparc64/SYS.h +++ /dev/null @@ -1,131 +0,0 @@ -/* $NetBSD: SYS.h,v 1.15 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * 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. - * 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. - * - * @(#)SYS.h 8.1 (Berkeley) 6/4/93 - * - * from: Header: SYS.h,v 1.2 92/07/03 18:57:00 torek Exp - */ - -#include -#include -#include - -#ifdef __STDC__ -#define _CAT(x,y) x##y -#else -#define _CAT(x,y) x/**/y -#endif - -/* - * ERROR branches to cerror. This is done with a macro so that I can - * change it to be position independent later, if need be. - */ -#if __PIC__ - 0 >= 2 -#define JUMP(name) \ - PIC_PROLOGUE(%g1,%g5); \ - sethi %hi(_C_LABEL(name)),%g5; \ - or %g5,%lo(_C_LABEL(name)),%g5; \ - ldx [%g1+%g5],%g5; \ - jmp %g5; \ - nop -#elif __PIC__ - 0 >= 1 -#define JUMP(name) \ - PIC_PROLOGUE(%g1,%g5); \ - ldx [%g1+_C_LABEL(name)],%g5; jmp %g5; nop -#else -#define JUMP(name) set _C_LABEL(name),%g1; jmp %g1; nop -#endif -#define ERROR() JUMP(__cerror) -/* - * SYSCALL is used when further action must be taken before returning. - * Note that it adds a `nop' over what we could do, if we only knew what - * came at label 1.... - */ -#define _SYSCALL(x,y) \ - ENTRY(x); mov _CAT(SYS_,y),%g1; t ST_SYSCALL; bcc 1f; nop; ERROR(); 1: - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -/* - * RSYSCALL is used when the system call should just return. Here - * we use the SYSCALL_G5RFLAG to put the `success' return address in %g5 - * and avoid a branch. - */ -#define RSYSCALL(x) \ - ENTRY(x); mov (_CAT(SYS_,x))|SYSCALL_G5RFLAG,%g1; add %o7,8,%g5; \ - t ST_SYSCALL; ERROR() - -/* - * PSEUDO(x,y) is like RSYSCALL(y) except that the name is x. - */ -#define PSEUDO(x,y) \ - ENTRY(x); mov (_CAT(SYS_,y))|SYSCALL_G5RFLAG,%g1; add %o7,8,%g5; \ - t ST_SYSCALL; ERROR() - -/* - * WSYSCALL(weak,strong) is like RSYSCALL(weak), except that weak is - * a weak internal alias for the strong symbol. - */ -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) - -/* - * SYSCALL_NOERROR is like SYSCALL, except it's used for syscalls - * that never fail. - * - * XXX - This should be optimized. - */ -#define SYSCALL_NOERROR(x) \ - ENTRY(x); mov _CAT(SYS_,x),%g1; t ST_SYSCALL - -/* - * RSYSCALL_NOERROR is like RSYSCALL, except it's used for syscalls - * that never fail. - * - * XXX - This should be optimized. - */ -#define RSYSCALL_NOERROR(x) \ - ENTRY(x); mov (_CAT(SYS_,x))|SYSCALL_G5RFLAG,%g1; add %o7,8,%g5; \ - t ST_SYSCALL - -/* - * PSEUDO_NOERROR(x,y) is like RSYSCALL_NOERROR(y) except that the name is x. - */ -#define PSEUDO_NOERROR(x,y) \ - ENTRY(x); mov (_CAT(SYS_,y))|SYSCALL_G5RFLAG,%g1; add %o7,8,%g5; \ - t ST_SYSCALL - - .globl _C_LABEL(__cerror) diff --git a/lib/libc/arch/sparc64/gdtoa/Makefile.inc b/lib/libc/arch/sparc64/gdtoa/Makefile.inc deleted file mode 100644 index c13f9a737..000000000 --- a/lib/libc/arch/sparc64/gdtoa/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c strtold_pQ.c -SRCS+= strtopQ.c diff --git a/lib/libc/arch/sparc64/gdtoa/arith.h b/lib/libc/arch/sparc64/gdtoa/arith.h deleted file mode 100644 index 4674f629c..000000000 --- a/lib/libc/arch/sparc64/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_BIG_ENDIAN diff --git a/lib/libc/arch/sparc64/gdtoa/gd_qnan.h b/lib/libc/arch/sparc64/gdtoa/gd_qnan.h deleted file mode 100644 index 860e1b064..000000000 --- a/lib/libc/arch/sparc64/gdtoa/gd_qnan.h +++ /dev/null @@ -1,9 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x7ff80000 -#define d_QNAN1 0x0 -#define ld_QNAN0 0x7fff8000 -#define ld_QNAN1 0x0 -#define ld_QNAN2 0x0 -#define ld_QNAN3 0x0 diff --git a/lib/libc/arch/sparc64/gen/Makefile.inc b/lib/libc/arch/sparc64/gen/Makefile.inc deleted file mode 100644 index 3753cba45..000000000 --- a/lib/libc/arch/sparc64/gen/Makefile.inc +++ /dev/null @@ -1,30 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.19 2009/12/06 07:12:17 uebayasi Exp $ - -SRCS+= fabs.S modf.S -SRCS+= flt_rounds.c fpgetmask.c fpgetround.c fpgetsticky.c fpsetmask.c \ - fpsetround.c fpsetsticky.c - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c infinityl.c -SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c signbitl.c - -SRCS+= bswap16.c bswap32.c bswap64.c -SRCS+= setjmp.S -SRCS+= _setjmp.S -SRCS+= sigsetjmp.S longjmp.c - -SRCS+= makecontext.c resumecontext.c _lwp.c swapcontext.S - -SRCS+= fixunsdfsi.S mul.S umul.S saveregs.S - -LSRCS.sparc64.gen=Lint_swapcontext.c -LSRCS+= ${LSRCS.sparc64.gen} -DPSRCS+= ${LSRCS.sparc64.gen} -CLEANFILES+= ${LSRCS.sparc64.gen} diff --git a/lib/libc/arch/sparc64/gen/_lwp.c b/lib/libc/arch/sparc64/gen/_lwp.c deleted file mode 100644 index 622d713db..000000000 --- a/lib/libc/arch/sparc64/gen/_lwp.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.7 2012/03/17 20:48:58 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.7 2012/03/17 20:48:58 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, - caddr_t stack_base, size_t stack_size) -{ - __greg_t *gr; - unsigned long *sp; - - getcontext(u); - gr = u->uc_mcontext.__gregs; - - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - /*LINTED*/ - sp = (ulong *)(stack_base + stack_size); - sp = (ulong *)((ulong)sp & ~0x0f); - - sp -= 8 + 8 + 6; - - sp[8] = (ulong)arg; - sp[14] = (ulong)sp - 2047; - sp[15] = (ulong)_lwp_exit - 8; - - /*LINTED*/ - sp = (ulong *)((caddr_t)sp - 2047); - - gr[_REG_PC] = (ulong) start; - gr[_REG_nPC] = (ulong) start + 4; - - gr[_REG_O0] = (ulong) arg; - gr[_REG_O6] = (ulong) sp; - gr[_REG_O7] = (ulong)_lwp_exit - 8; - gr[_REG_G7] = (ulong)private; -} diff --git a/lib/libc/arch/sparc64/gen/_setjmp.S b/lib/libc/arch/sparc64/gen/_setjmp.S deleted file mode 100644 index 66d1ec40e..000000000 --- a/lib/libc/arch/sparc64/gen/_setjmp.S +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.7 2011/04/30 19:43:17 martin Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: _setjmp.s,v 1.1 91/07/06 16:45:53 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: _setjmp.S,v 1.7 2011/04/30 19:43:17 martin Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - - .register %g2,#ignore - .register %g3,#ignore - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v?v:1)" from - * the last call to - * _setjmp(a) - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - stx %sp, [%o0+0] /* store caller's stack pointer */ - stx %o7, [%o0+8] /* and return pc */ - stx %g0, [%o0+0x18] /* mark as non-sigmask jmpbuf */ - - /* store globals, offsets compatible with siglongjmp */ - stx %g1, [%o0+0x28] - stx %g2, [%o0+0x30] /* adjust asserts in longjmp.c */ - stx %g3, [%o0+0x48] /* if you change any of these */ - stx %g6, [%o0+0x50] /* offsets! */ - stx %g7, [%o0+0x58] - - retl - clr %o0 ! return 0 - -ENTRY(_longjmp) - save %sp, -CC64FSZ, %sp - flushw - /* - * We restore the saved stack pointer to %fp, then issue - * a `restore' instruction which will reload the register - * window from the stack. - */ - ldx [%i0+0x28],%g1 - ldx [%i0+0x30],%g2 - ldx [%i0+0x48],%g3 - ldx [%i0+0x50],%g6 - ldx [%i0+0x58],%g7 - ldx [%i0+8], %i7 - ldx [%i0+0], %fp - mov 1, %i0 - movrnz %i1, %i1, %i0 ! compute v ? v : 1 - ret - restore diff --git a/lib/libc/arch/sparc64/gen/fabs.S b/lib/libc/arch/sparc64/gen/fabs.S deleted file mode 100644 index bb7ac9fce..000000000 --- a/lib/libc/arch/sparc64/gen/fabs.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: fabs.S,v 1.5 2003/08/07 16:42:27 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: fabs.s,v 1.4 91/10/07 23:59:05 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)fabs.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: fabs.S,v 1.5 2003/08/07 16:42:27 agc Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* fabs - floating absolute value */ - -ENTRY(fabs) - retl - fabss %f0, %f0 ! return absolute value - diff --git a/lib/libc/arch/sparc64/gen/fixunsdfsi.S b/lib/libc/arch/sparc64/gen/fixunsdfsi.S deleted file mode 100644 index be95905cc..000000000 --- a/lib/libc/arch/sparc64/gen/fixunsdfsi.S +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: fixunsdfsi.S,v 1.5 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: fixunsdfsi.s,v 1.3 91/10/08 00:03:15 torek Exp - */ - -#include -#define _LOCORE -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)fixunsdfsi.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: fixunsdfsi.S,v 1.5 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * Convert double to unsigned integer (for gcc). - * - * I have made the output for NaN agree with the Sun compiler, not - * that it really matters, by using `fbul,a'. - */ - - - .align 8 -Lbig: - .word 0x43e00000 ! .double 2^63 - .word 0 ! (who me, not trust the assembler?) - -/* - * Same as above but to unsigned long - */ -ENTRY(__dtoul) - sub %sp, 16, %sp - std %f2, [%sp + 64 + BIAS + 8] -#ifdef __PIC__ - PICCY_SET(Lbig, %g1, %o0) - ldd [%g1], %f2 -#else - sethi %hi(Lbig), %g1 - ldd [%g1 + %lo(Lbig)], %f2 -#endif - fcmped %f0, %f2 ! d < 2^63, or NaN, or -Inf? - nop ! (fpop2 delay) - fbul,a 1f ! if so, use fdtoi to convert to int - fdtox %f0, %f0 ! (this includes negatives!) - - ! d does not fit in an int, so subtract 2^63, convert, - ! and add 2^63 again (sigh). Just hope the intermediate - ! fits (if not, the result is undefined anyway). - - fsubd %f0, %f2, %f0 ! d -= 2^63 - fdtox %f0, %f0 ! convert to int - std %f0, [%sp + 64 + BIAS] ! move into return reg - ldx [%sp + 64 + BIAS], %o0 - sethi %hi(0x80000000), %o1 - sllx %o1, 32, %o1 - add %o0, %o1, %o0 ! add 2^63 - ldd [%sp + 64 + BIAS + 8], %f2 - retl - add %sp, 16, %sp - -1: - std %f0, [%sp + 64 + BIAS] ! return result - ldx [%sp + 64 + BIAS], %o0 - ldd [%sp + 64 + BIAS + 8], %f2 - retl - add %sp, 16, %sp diff --git a/lib/libc/arch/sparc64/gen/flt_rounds.c b/lib/libc/arch/sparc64/gen/flt_rounds.c deleted file mode 100644 index 93e3b2cf6..000000000 --- a/lib/libc/arch/sparc64/gen/flt_rounds.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $NetBSD: flt_rounds.c,v 1.6 2012/06/24 15:26:02 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: flt_rounds.c,v 1.6 2012/06/24 15:26:02 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -static const int map[] = { - 1, /* round to nearest */ - 0, /* round to zero */ - 2, /* round to positive infinity */ - 3 /* round to negative infinity */ -}; - -int -__flt_rounds(void) -{ - uint32_t x; - - __asm("st %%fsr,%0" : "=m" (*&x)); - return map[(x >> 30) & 0x03]; -} diff --git a/lib/libc/arch/sparc64/gen/fpclassifyl.c b/lib/libc/arch/sparc64/gen/fpclassifyl.c deleted file mode 100644 index 1a745bb5f..000000000 --- a/lib/libc/arch/sparc64/gen/fpclassifyl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: fpclassifyl.c,v 1.3 2013/11/20 22:22:20 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyl.c,v 1.3 2013/11/20 22:22:20 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__fpclassifyl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - if (u.extu_ext.ext_exp == 0) { - if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0) - return FP_ZERO; - else - return FP_SUBNORMAL; - } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) { - if (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0) - return FP_INFINITE; - else - return FP_NAN; - } - - return FP_NORMAL; -} diff --git a/lib/libc/arch/sparc64/gen/fpgetmask.c b/lib/libc/arch/sparc64/gen/fpgetmask.c deleted file mode 100644 index 095ff73f4..000000000 --- a/lib/libc/arch/sparc64/gen/fpgetmask.c +++ /dev/null @@ -1,29 +0,0 @@ -/* $NetBSD: fpgetmask.c,v 1.6 2012/06/24 15:26:02 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetmask.c,v 1.6 2012/06/24 15:26:02 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetmask,_fpgetmask) -#endif - -fp_except -fpgetmask(void) -{ - uint32_t x; - - __asm("st %%fsr,%0" : "=m" (*&x)); - return (x >> 23) & 0x1f; -} diff --git a/lib/libc/arch/sparc64/gen/fpgetround.c b/lib/libc/arch/sparc64/gen/fpgetround.c deleted file mode 100644 index ef65c131b..000000000 --- a/lib/libc/arch/sparc64/gen/fpgetround.c +++ /dev/null @@ -1,29 +0,0 @@ -/* $NetBSD: fpgetround.c,v 1.6 2012/06/24 15:26:02 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetround.c,v 1.6 2012/06/24 15:26:02 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetround,_fpgetround) -#endif - -fp_rnd -fpgetround(void) -{ - uint32_t x; - - __asm("st %%fsr,%0" : "=m" (*&x)); - return (x >> 30) & 0x03; -} diff --git a/lib/libc/arch/sparc64/gen/fpgetsticky.c b/lib/libc/arch/sparc64/gen/fpgetsticky.c deleted file mode 100644 index 67b3ea652..000000000 --- a/lib/libc/arch/sparc64/gen/fpgetsticky.c +++ /dev/null @@ -1,40 +0,0 @@ -/* $NetBSD: fpgetsticky.c,v 1.7 2012/06/24 15:26:02 christos Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpgetsticky.c,v 1.7 2012/06/24 15:26:02 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpgetsticky,_fpgetsticky) -#endif - -#ifdef EXCEPTIONS_WITH_SOFTFLOAT -extern fp_except _softfloat_float_exception_flags; -#endif - -fp_except -fpgetsticky(void) -{ - uint32_t x; - fp_except res; - - __asm("st %%fsr,%0" : "=m" (*&x)); - res = (x >> 5) & 0x1f; - -#ifdef EXCEPTIONS_WITH_SOFTFLOAT - res |= _softfloat_float_exception_flags; -#endif - - return res; -} diff --git a/lib/libc/arch/sparc64/gen/fpsetmask.c b/lib/libc/arch/sparc64/gen/fpsetmask.c deleted file mode 100644 index 4ac4a4d46..000000000 --- a/lib/libc/arch/sparc64/gen/fpsetmask.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: fpsetmask.c,v 1.7 2013/10/28 01:06:36 mrg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetmask.c,v 1.7 2013/10/28 01:06:36 mrg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetmask,_fpsetmask) -#endif - -#ifdef EXCEPTIONS_WITH_SOFTFLOAT -extern fp_except _softfloat_float_exception_mask; -#endif - -fp_except -fpsetmask(fp_except mask) -{ - fp_except old; - fp_except new; - - __asm("st %%fsr,%0" : "=m" (*&old)); - - new = old; - new &= ~(0x1f << 23); - new |= ((mask & 0x1f) << 23); - - __asm("ld %0,%%fsr" : : "m" (*&new)); - - old = ((uint32_t)old >> 23) & 0x1f; - -#ifdef EXCEPTIONS_WITH_SOFTFLOAT - /* update softfloat mask as well */ - old |= _softfloat_float_exception_mask; - _softfloat_float_exception_mask = mask; -#endif - - return old; -} diff --git a/lib/libc/arch/sparc64/gen/fpsetround.c b/lib/libc/arch/sparc64/gen/fpsetround.c deleted file mode 100644 index 5821b5b43..000000000 --- a/lib/libc/arch/sparc64/gen/fpsetround.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: fpsetround.c,v 1.7 2013/10/28 01:06:36 mrg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetround.c,v 1.7 2013/10/28 01:06:36 mrg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetround,_fpsetround) -#endif - -fp_rnd -fpsetround(fp_rnd rnd_dir) -{ - fp_rnd old; - fp_rnd new; -#ifdef SOFTFLOATSPARC64_FOR_GCC - extern fp_rnd _softfloat_float_rounding_mode; -#endif - - __asm("st %%fsr,%0" : "=m" (*&old)); - -#ifdef SOFTFLOATSPARC64_FOR_GCC - _softfloat_float_rounding_mode = rnd_dir; -#endif - - new = old; - new &= ~(0x03 << 30); - new |= ((rnd_dir & 0x03) << 30); - - __asm("ld %0,%%fsr" : : "m" (*&new)); - - return ((uint32_t)old >> 30) & 0x03; -} diff --git a/lib/libc/arch/sparc64/gen/fpsetsticky.c b/lib/libc/arch/sparc64/gen/fpsetsticky.c deleted file mode 100644 index 47b3ac4d1..000000000 --- a/lib/libc/arch/sparc64/gen/fpsetsticky.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: fpsetsticky.c,v 1.7 2013/10/28 01:06:36 mrg Exp $ */ - -/* - * Written by J.T. Conklin, Apr 10, 1995 - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpsetsticky.c,v 1.7 2013/10/28 01:06:36 mrg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#ifdef __weak_alias -__weak_alias(fpsetsticky,_fpsetsticky) -#endif - -#ifdef EXCEPTIONS_WITH_SOFTFLOAT -extern fp_except _softfloat_float_exception_flags; -#endif - -fp_except -fpsetsticky(fp_except sticky) -{ - fp_except old; - fp_except new; - - __asm("st %%fsr,%0" : "=m" (*&old)); - - new = old; - new &= ~(0x1f << 5); - new |= ((sticky & 0x1f) << 5); - - __asm("ld %0,%%fsr" : : "m" (*&new)); - - old = ((uint32_t)old >> 5) & 0x1f; - -#ifdef EXCEPTIONS_WITH_SOFTFLOAT - old |= _softfloat_float_exception_flags; - _softfloat_float_exception_flags = sticky; -#endif - return old; -} diff --git a/lib/libc/arch/sparc64/gen/infinityl.c b/lib/libc/arch/sparc64/gen/infinityl.c deleted file mode 100644 index ebd8f2daf..000000000 --- a/lib/libc/arch/sparc64/gen/infinityl.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $ */ - -/* - * IEEE-compatible infinityl.c for big-endian 128-bit format -- public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include - -const union __long_double_u __infinityl = - { { 0x7f, 0xff, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 } }; diff --git a/lib/libc/arch/sparc64/gen/isfinitel.c b/lib/libc/arch/sparc64/gen/isfinitel.c deleted file mode 100644 index b56951235..000000000 --- a/lib/libc/arch/sparc64/gen/isfinitel.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: isfinitel.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinitel.c,v 1.2 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__isfinitel(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) - return 0; - - return 1; -} diff --git a/lib/libc/arch/sparc64/gen/isinfl.c b/lib/libc/arch/sparc64/gen/isinfl.c deleted file mode 100644 index 5ce673179..000000000 --- a/lib/libc/arch/sparc64/gen/isinfl.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: isinfl.c,v 1.5 2013/11/20 22:22:20 martin Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinfl.c,v 1.5 2013/11/20 22:22:20 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.3 isinf - test for infinity - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__isinfl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - (u.extu_ext.ext_frach == 0 && u.extu_ext.ext_fracl == 0)); -} diff --git a/lib/libc/arch/sparc64/gen/isnanl.c b/lib/libc/arch/sparc64/gen/isnanl.c deleted file mode 100644 index efa59d531..000000000 --- a/lib/libc/arch/sparc64/gen/isnanl.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: isnanl.c,v 1.5 2013/11/20 22:22:20 martin Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnanl.c,v 1.5 2013/11/20 22:22:20 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.4 isnan - test for a NaN - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__isnanl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - (u.extu_ext.ext_frach != 0 || u.extu_ext.ext_fracl != 0)); -} diff --git a/lib/libc/arch/sparc64/gen/longjmp.c b/lib/libc/arch/sparc64/gen/longjmp.c deleted file mode 100644 index c62d01d60..000000000 --- a/lib/libc/arch/sparc64/gen/longjmp.c +++ /dev/null @@ -1,115 +0,0 @@ -/* $NetBSD: longjmp.c,v 1.7 2012/03/17 21:35:06 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christian Limpach. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include - -typedef struct { - __greg_t g3; - __greg_t g6; - __greg_t g7; - __greg_t dummy; - __greg_t save_mask; -} __jmp_buf_regs_t; - -/* - * setjmp.S uses hard coded offsets into the jump_buf, - * make sure any changes cause a compile failure here - */ -#ifndef lint /* XXX this is too much for lint */ -__CTASSERT(0x68 == offsetof(__jmp_buf_regs_t,save_mask) + - sizeof(struct sigcontext)); -__CTASSERT(sizeof(sigjmp_buf) >= sizeof(__jmp_buf_regs_t) + - sizeof(struct sigcontext)); -#endif - -void -__longjmp14(jmp_buf env, int val) -{ - struct sigcontext *sc = (void *)env; - __jmp_buf_regs_t *r = (void *)&sc[1]; - ucontext_t uc; - - /* Ensure non-zero SP */ - if (sc->sc_sp == 0) - goto err; - - /* - * Set _UC_CPU. No FPU data saved, so we can't restore - * that. Set _UC_{SET,CLR}STACK according to SS_ONSTACK - */ - memset(&uc, 0, sizeof(uc)); - uc.uc_flags = _UC_CPU | (sc->sc_onstack ? _UC_SETSTACK : _UC_CLRSTACK); - - /* - * Set the signal mask - this is a weak symbol, so don't use - * _UC_SIGMASK in the mcontext, libpthread might override sigprocmask. - */ - sigprocmask(SIG_SETMASK, &sc->sc_mask, NULL); - - /* Fill other registers */ - uc.uc_mcontext.__gregs[_REG_CCR] = sc->sc_tstate; - uc.uc_mcontext.__gregs[_REG_PC] = sc->sc_pc; - uc.uc_mcontext.__gregs[_REG_nPC] = sc->sc_pc+4; - uc.uc_mcontext.__gregs[_REG_G1] = sc->sc_g1; - uc.uc_mcontext.__gregs[_REG_G2] = sc->sc_o0; - uc.uc_mcontext.__gregs[_REG_G3] = r->g3; - uc.uc_mcontext.__gregs[_REG_G4] = 0; - uc.uc_mcontext.__gregs[_REG_G5] = 0; - uc.uc_mcontext.__gregs[_REG_G6] = r->g6; - uc.uc_mcontext.__gregs[_REG_G7] = r->g7; - uc.uc_mcontext.__gregs[_REG_O6] = sc->sc_sp; - - - /* Make return value non-zero */ - if (val == 0) - val = 1; - - /* Save return value in context */ - uc.uc_mcontext.__gregs[_REG_O0] = val; - - setcontext(&uc); - - err: - longjmperror(); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/sparc64/gen/makecontext.c b/lib/libc/arch/sparc64/gen/makecontext.c deleted file mode 100644 index 8bdcee63a..000000000 --- a/lib/libc/arch/sparc64/gen/makecontext.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.5 2012/03/17 21:35:06 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.5 2012/03/17 21:35:06 martin Exp $"); -#endif - -#include -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - int i; - ulong *sp; - va_list ap; - - /*LINTED*/ - sp = (ulong *)((caddr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - /* Align on quad-word boundary. */ - sp = (ulong *)((ulong)sp & ~0xf); - - /* Make room for: argx, argd, struct return pointer(?), rwindow. */ - sp -= (argc > 6 ? argc - 6 : 0) + 6 + 8 + 8; - - va_start(ap, argc); - - /* Pass up to 6 arguments in %o0-5. */ - for (i = 0; i < argc && i < 6; i++) - gr[_REG_O0 + i] = sp[i + 16] = va_arg(ap, unsigned long); - - /* Pass any additional arguments on the stack. */ - for (; i < argc; i++) - sp[i + 16] = va_arg(ap, unsigned long); - va_end(ap); - - sp[14] = (ulong)sp - 2047; - sp[15] = (ulong)_resumecontext - 8; - - /*LINTED*/ - sp = (ulong *)((caddr_t)sp - 2047); - - gr[_REG_O6] = (__greg_t)sp; - gr[_REG_PC] = (__greg_t)func; - gr[_REG_nPC] = (__greg_t)func + 4; - gr[_REG_O7] = (__greg_t)_resumecontext - 8; - -} diff --git a/lib/libc/arch/sparc64/gen/modf.S b/lib/libc/arch/sparc64/gen/modf.S deleted file mode 100644 index 97e36e9a1..000000000 --- a/lib/libc/arch/sparc64/gen/modf.S +++ /dev/null @@ -1,189 +0,0 @@ -/* $NetBSD: modf.S,v 1.5 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: modf.s,v 1.3 92/06/20 00:00:54 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: modf.S,v 1.5 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#include - -/* - * 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 + BIAS - 4] saved %fsr - * 4@[%fp + BIAS - 8] new %fsr with rounding set to `towards 0' - * 8@[%fp + BIAS - 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, -CC64FSZ-16, %sp - - /* - * First, compute v = abs(val) - */ - fabsd %f0, %f4 ! %f4:f5 = v - fcmped %fcc1, %f0, %f4 ! %fcc1 = (val == abs(val)) -#ifdef __PIC__ - PICCY_SET(Lmagic, %l0, %o7) - ldd [%l0], %f2 -#else - sethi %hi(Lmagic), %l0 - ldd [%l0 + %lo(Lmagic)], %f2 -#endif - - /* - * 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 + BIAS - 4] ! %l5 = current FSR mode - set FSR_RD, %l3 ! %l3 = rounding direction mask - ld [%fp + BIAS - 4], %l5 - set FSR_RD_RZ << FSR_RD_SHIFT, %l4 - andn %l5, %l3, %l6 - or %l6, %l4, %l6 ! round towards zero, please - and %l5, %l3, %l5 ! save original rounding mode - st %l6, [%fp + BIAS - 8] - ld [%fp + BIAS - 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 + BIAS - 4] - ld [%fp + BIAS - 4], %l6 - andn %l6, %l3, %l6 ! %l6 = %fsr & ~FSR_RD; - or %l5, %l6, %l5 ! %l5 |= %l6; - st %l5, [%fp + BIAS - 4] - ld [%fp + BIAS - 4], %fsr ! restore %fsr, leaving accrued stuff - - /* - * Now insert the original sign in %f4:f5. - * %fcc1 should still have the reults 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. - */ -#ifdef __PIC__ - PICCY_SET(L0, %l0, %o7) - std %f0, [%i1] ! *ival = val; - ldd [%l0], %f0 ! return 0.0; -#else - sethi %hi(L0), %l0 - std %f0, [%i1] ! *ival = val; - ldd [%l0 + %lo(L0)], %f0 ! return 0.0; -#endif - ret - restore - diff --git a/lib/libc/arch/sparc64/gen/nanf.c b/lib/libc/arch/sparc64/gen/nanf.c deleted file mode 100644 index 1688d0eae..000000000 --- a/lib/libc/arch/sparc64/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0x7f, 0xc0, 0, 0 } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/sparc64/gen/resumecontext.c b/lib/libc/arch/sparc64/gen/resumecontext.c deleted file mode 100644 index 57d68fdf8..000000000 --- a/lib/libc/arch/sparc64/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.5 2011/09/19 21:24:58 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/sparc64/gen/setjmp.S b/lib/libc/arch/sparc64/gen/setjmp.S deleted file mode 100644 index aa21e41be..000000000 --- a/lib/libc/arch/sparc64/gen/setjmp.S +++ /dev/null @@ -1,130 +0,0 @@ -/* $NetBSD: setjmp.S,v 1.10 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: setjmp.s,v 1.2 92/06/25 03:18:43 torek Exp - */ - -#define _LOCORE -#include -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: setjmp.S,v 1.10 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp - * - * __longjmp14(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "SYS.h" - - .register %g2,#ignore - .register %g3,#ignore - .register %g6,#ignore - -ENTRY(__setjmp14) - save %sp, -CC64FSZ, %sp - - /* save globals into locals */ - mov %g1, %l1 - mov %g2, %l2 - mov %g3, %l3 - mov %g4, %l4 - mov %g5, %l5 - mov %g6, %l6 - mov %g7, %l7 - -#ifdef __PIC__ - PIC_PROLOGUE(%i1, %o4) -#endif - - /* now get sigmask and onstack flag */ - add %i0, 0x38, %o2 /* build sigcontext in [%o2]->sc.sc_mask */ - mov 1, %o0 /* SIG_BLOCK */ - /* sigprocmask(SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)a) */ -#if __PIC__ - 0 >= 2 - set _C_LABEL(__sigprocmask14), %o4 - ldx [%i1 + %o4], %g2 - call %g2 -#elif __PIC__ - 0 >= 1 - ldx [%i1 + _C_LABEL(__sigprocmask14)], %g2 - call %g2 -#else - call _C_LABEL(__sigprocmask14) -#endif - clr %o1 - - clr %o0 /* sigstack(NULL, &foo) */ -#if __PIC__ - 0 >= 2 - set _C_LABEL(__sigaltstack14), %o4 - ldx [%i1 + %o4], %g2 - call %g2 -#elif __PIC__ - 0 >= 1 - ldx [%i1 + _C_LABEL(__sigaltstack14)], %g2 - call %g2 -#else - call _C_LABEL(__sigaltstack14) -#endif - add %i0, 8, %o1 /* (foo being part of the sigcontext we're overwriting) */ - - lduw [%i0 + 8 + 0x10], %o0 /* foo.ss_flags */ - and %o0, 1, %o1 /* onstack = foo.ss_flags & SS_ONSTACK; */ - st %o1, [%i0 + 0x00] /* sc.sc_onstack = current onstack; */ - - /* store essential state */ - stx %fp, [%i0 + 0x08] /* sc.sc_sp = sp */ - add %i7, 8, %o0 - stx %o0, [%i0 + 0x10] /* sc.sc_pc = return_pc */ - stx %g0, [%i0 + 0x20] /* sc.sc_tstate = (clean ccr) */ - stx %l1, [%i0 + 0x28] /* sc.sc_g1 */ - stx %l2, [%i0 + 0x30] /* sc.sc_o0, set in longjmp, use as %g2 */ - /* 0x38: 4x32bit */ /* sc.sc_mask was already saved above */ - - /* save additional registers needed to fill a complete mcontext */ - stx %l3, [%i0 + 0x48] /* adjust asserts in longjmp.c */ - stx %l6, [%i0 + 0x50] /* if you change any of these */ - stx %l7, [%i0 + 0x58] /* offsets! */ - - ret /* return 0 */ - restore %g0, 0, %o0 diff --git a/lib/libc/arch/sparc64/gen/signbitl.c b/lib/libc/arch/sparc64/gen/signbitl.c deleted file mode 100644 index 0328c9fde..000000000 --- a/lib/libc/arch/sparc64/gen/signbitl.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitl.c,v 1.2 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__signbitl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_sign == 1); -} diff --git a/lib/libc/arch/sparc64/gen/sigsetjmp.S b/lib/libc/arch/sparc64/gen/sigsetjmp.S deleted file mode 100644 index b111209ca..000000000 --- a/lib/libc/arch/sparc64/gen/sigsetjmp.S +++ /dev/null @@ -1,113 +0,0 @@ -/* $NetBSD: sigsetjmp.S,v 1.12 2013/09/14 05:38:00 nakayama Exp $ */ -/* - * Copyright (c) 1995 Paul Kranenburg - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "SYS.h" - -/* - * We use the sc_npc field inside the sigcontext to store the save mask - */ -#define MASK_OFFSET 0x68 - -#if __PIC__ - 0 >= 2 - -ENTRY(__sigsetjmp14) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf - sethi %hi(_C_LABEL(__setjmp14)), %o2 - sethi %hi(_C_LABEL(_setjmp)), %o3 - or %o2, %lo(_C_LABEL(__setjmp14)), %o2 - or %o3, %lo(_C_LABEL(_setjmp)), %o3 - brz %o1, 1f - ldx [%g1+%o3], %o3 ! if (%o1 == 0) goto _setjmp; - ldx [%g1+%o2], %o3 ! else goto __setjmp; -1: - jmp %o3 - nop - -ENTRY(__siglongjmp14) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - ld [%o0+MASK_OFFSET], %o2 ! end of jmpbuf - sethi %hi(_C_LABEL(__longjmp14)), %o3 - sethi %hi(_C_LABEL(_longjmp)), %o4 - or %o3, %lo(_C_LABEL(__longjmp14)), %o3 - or %o4, %lo(_C_LABEL(_longjmp)), %o4 - brz,a %o2, 1f - ldx [%g1+%o4], %o4 ! if (%o2 == 0) goto _longjmp; - ldx [%g1+%o3], %o4 ! else goto __longjmp; -1: - jmp %o4 - nop - unimp 0 - -#elif __PIC__ - 0 >= 1 - -ENTRY(__sigsetjmp14) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - cmp %o1,0 - st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf - bne,a 1f - ldx [%g1+_C_LABEL(__setjmp14)], %g1 ! if (%o1 != 0) goto __setjmp; - ldx [%g1+_C_LABEL(_setjmp)], %g1 ! else goto _setjmp; -1: - jmp %g1 - nop - -ENTRY(__siglongjmp14) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - ld [%o0+MASK_OFFSET],%o2 ! end of jmpbuf - cmp %o2,0 - bne,a 1f - ldx [%g1+_C_LABEL(__longjmp14)], %g1 ! if (%o2 != 0) goto __longjmp; - ldx [%g1+_C_LABEL(_longjmp)], %g1 ! else goto _longjmp; -1: - jmp %g1 - nop - unimp 0 - -#else /* !__PIC__ */ - -ENTRY(__sigsetjmp14) - cmp %o1,0 - be _C_LABEL(_setjmp) - st %o1,[%o0+MASK_OFFSET] ! end of jmpbuf - ba,a _C_LABEL(__setjmp14) - unimp 0 - -ENTRY(__siglongjmp14) - ld [%o0+MASK_OFFSET],%g1 - cmp %g1,0 - be _C_LABEL(_longjmp) - nop - ba,a _C_LABEL(__longjmp14) - unimp 0 - -#endif /* !__PIC__ */ diff --git a/lib/libc/arch/sparc64/gen/swapcontext.S b/lib/libc/arch/sparc64/gen/swapcontext.S deleted file mode 100644 index 4cd081551..000000000 --- a/lib/libc/arch/sparc64/gen/swapcontext.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.8 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.8 2013/09/12 15:36:16 joerg Exp $") -#endif /* LIBC_SCCS && !lint */ - - -ENTRY(swapcontext) - mov %o0, %o2 /* must save pointer */ - mov %o1, %o3 /* must save pointer */ - mov SYS_getcontext, %g1 - t ST_SYSCALL - bcc,a 1f - stx %g0, [%o2 + 64 + 11 * 8] /* gr[_REG_O0] = 0 */ - ERROR() -1: - add %o7, 12, %o1 - stx %o1, [%o2 + 64 + 2 * 8] /* gr[_REG_nPC] = retaddr + 4 */ - add %o7, 8, %o1 - stx %o1, [%o2 + 64 + 1 * 8] /* gr[_REG_PC] = retaddr */ - -#if __PIC__ - 0 >= 2 - PIC_PROLOGUE(%g5,%o4) /* %g5 = _GLOBAL_OFFSET_TABLE */ - set _C_LABEL(setcontext), %o5 - ldx [%g5+%o5], %o4 - jmp %o4 - mov %o3, %o0 -#elif __PIC__ - 0 >= 1 - PIC_PROLOGUE(%g5,%o4) /* %g5 = _GLOBAL_OFFSET_TABLE */ - ldx [%g5+_C_LABEL(setcontext)], %o4 - jmp %o4 - mov %o3, %o0 -#else - ba,a _C_LABEL(setcontext) - mov %o3, %o0 -#endif diff --git a/lib/libc/arch/sparc64/net/Makefile.inc b/lib/libc/arch/sparc64/net/Makefile.inc deleted file mode 100644 index f51553517..000000000 --- a/lib/libc/arch/sparc64/net/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 1998/09/11 04:56:30 eeh Exp $ - -SRCS+= htonl.S htons.S ntohl.S ntohs.S diff --git a/lib/libc/arch/sparc64/softfloat/milieu.h b/lib/libc/arch/sparc64/softfloat/milieu.h deleted file mode 100644 index ef43336cd..000000000 --- a/lib/libc/arch/sparc64/softfloat/milieu.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: milieu.h,v 1.1 2002/02/05 07:53:05 jmc Exp $ */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -Include common integer types and flags. -------------------------------------------------------------------------------- -*/ -#include "sparc64-gcc.h" - -/* -------------------------------------------------------------------------------- -Symbolic Boolean literals. -------------------------------------------------------------------------------- -*/ -enum { - FALSE = 0, - TRUE = 1 -}; diff --git a/lib/libc/arch/sparc64/softfloat/qp.c b/lib/libc/arch/sparc64/softfloat/qp.c deleted file mode 100644 index 365f7a263..000000000 --- a/lib/libc/arch/sparc64/softfloat/qp.c +++ /dev/null @@ -1,289 +0,0 @@ -/* $NetBSD: qp.c,v 1.11 2014/02/02 08:14:39 martin Exp $ */ - -/*- - * Copyright (c) 2002, 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#include "milieu.h" -#include "softfloat.h" - -int printf(const char *, ...); - -void _Qp_add(float128 *c, float128 *a, float128 *b); -int _Qp_cmp(float128 *a, float128 *b); -int _Qp_cmpe(float128 *a, float128 *b); -void _Qp_div(float128 *c, float128 *a, float128 *b); -void _Qp_dtoq(float128 *c, double a); -int _Qp_feq(float128 *a, float128 *b); -int _Qp_fge(float128 *a, float128 *b); -int _Qp_fgt(float128 *a, float128 *b); -int _Qp_fle(float128 *a, float128 *b); -int _Qp_flt(float128 *a, float128 *b); -int _Qp_fne(float128 *a, float128 *b); -void _Qp_itoq(float128 *c, int a); -void _Qp_mul(float128 *c, float128 *a, float128 *b); -void _Qp_neg(float128 *c, float128 *a); -double _Qp_qtod(float128 *a); -int _Qp_qtoi(float128 *a); -float _Qp_qtos(float128 *a); -unsigned int _Qp_qtoui(float128 *a); -unsigned long _Qp_qtoux(float128 *a); -long _Qp_qtox(float128 *a); -void _Qp_sqrt(float128 *c, float128 *a); -void _Qp_stoq(float128 *c, float a); -void _Qp_sub(float128 *c, float128 *a, float128 *b); -void _Qp_uitoq(float128 *c, unsigned int a); -void _Qp_uxtoq(float128 *c, unsigned long a); -void _Qp_xtoq(float128 *c, long a); - - -void -_Qp_add(float128 *c, float128 *a, float128 *b) -{ - *c = float128_add(*a, *b); -} - - -int -_Qp_cmp(float128 *a, float128 *b) -{ - - if (float128_eq(*a, *b)) - return 0; - - if (float128_le(*a, *b)) - return 1; - - return 2; -} - - -/* - * XXX - */ -int -_Qp_cmpe(float128 *a, float128 *b) -{ - return _Qp_cmp(a, b); -} - - -void -_Qp_div(float128 *c, float128 *a, float128 *b) -{ - *c = float128_div(*a, *b); -} - - -void -_Qp_dtoq(float128 *c, double a) -{ - float64 _b; - - memcpy (&_b, &a, sizeof(float64)); - *c = float64_to_float128(_b); -} - - -int -_Qp_feq(float128 *a, float128 *b) -{ - return float128_eq(*a, *b); -} - - -int -_Qp_fge(float128 *a, float128 *b) -{ - return float128_le(*b, *a); -} - - -int -_Qp_fgt(float128 *a, float128 *b) -{ - return float128_lt(*b, *a); -} - - -int -_Qp_fle(float128 *a, float128 *b) -{ - return float128_le(*a, *b); -} - - -int -_Qp_flt(float128 *a, float128 *b) -{ - return float128_lt(*a, *b); -} - - -int -_Qp_fne(float128 *a, float128 *b) -{ - return !float128_eq(*a, *b); -} - - -void -_Qp_itoq(float128 *c, int a) -{ - *c = int32_to_float128(a); -} - - -void -_Qp_mul(float128 *c, float128 *a, float128 *b) -{ - *c = float128_mul(*a, *b); -} - - -/* - * XXX need corresponding softfloat functions - */ -static float128 __sf128_zero = {0x4034000000000000, 0x00000000}; -static float128 __sf128_one = {0x3fff000000000000, 0}; - -void -_Qp_neg(float128 *c, float128 *a) -{ - *c = float128_sub(__sf128_zero, *a); -} - - -double -_Qp_qtod(float128 *a) -{ - float64 _c; - double c; - - _c = float128_to_float64(*a); - - memcpy(&c, &_c, sizeof(double)); - - return c; -} - - -int -_Qp_qtoi(float128 *a) -{ - return float128_to_int32_round_to_zero(*a); -} - - -float - _Qp_qtos(float128 *a) -{ - float c; - float32 _c; - - _c = float128_to_float32(*a); - - memcpy(&c, &_c, sizeof(_c)); - - return c; -} - - -unsigned int -_Qp_qtoui(float128 *a) -{ - return (unsigned int)float128_to_int64_round_to_zero(*a); -} - - -unsigned long -_Qp_qtoux(float128 *a) -{ - return (unsigned long)float128_to_uint64_round_to_zero(*a); -} - - -long -_Qp_qtox(float128 *a) -{ - return (long)float128_to_int64_round_to_zero(*a); -} - - -void -_Qp_sqrt(float128 *c, float128 *a) -{ - *c = float128_sqrt(*a); -} - - -void -_Qp_stoq(float128 *c, float a) -{ - float32 _a; - - memcpy(&_a, &a, sizeof(a)); - - *c = float32_to_float128(_a); -} - - -void -_Qp_sub(float128 *c, float128 *a, float128 *b) -{ - *c = float128_sub(*a, *b); -} - - -void -_Qp_uitoq(float128 *c, unsigned int a) -{ - *c = int64_to_float128(a); -} - - -void -_Qp_uxtoq(float128 *c, unsigned long a) -{ - if (a & 0x8000000000000000ULL) { - /* a would not fit in a signed conversion */ - *c = int64_to_float128((long long)(a>>1)); - *c = float128_add(*c, *c); - if (a & 1) - *c = float128_add(*c, __sf128_one); - } else { - *c = int64_to_float128((long long)a); - } -} - - -void -_Qp_xtoq(float128 *c, long a) -{ - *c = int64_to_float128((long long)a); -} diff --git a/lib/libc/arch/sparc64/softfloat/softfloat-qp.h b/lib/libc/arch/sparc64/softfloat/softfloat-qp.h deleted file mode 100644 index 1fda8802c..000000000 --- a/lib/libc/arch/sparc64/softfloat/softfloat-qp.h +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Get everything SOFTFLOAT_FOR_GCC normally would rename out of the users - * namespace. Much of this isn't used but to avoid dissecting softloat.c - * all of it is pulled in even for just the _Qp* case - */ - -#if defined(SOFTFLOATSPARC64_FOR_GCC) && !defined(SOFTFLOAT_FOR_GCC) -#define float_exception_flags _softfloat_float_exception_flags -#define float_rounding_mode _softfloat_float_rounding_mode -#define float_raise _softfloat_float_raise - -#define float32_eq _softfloat_float32_eq -#define float32_le _softfloat_float32_le -#define float32_lt _softfloat_float32_lt -#define float64_eq _softfloat_float64_eq -#define float64_le _softfloat_float64_le -#define float64_lt _softfloat_float64_lt - -#define float32_add _softfloat_float32_add -#define float64_add _softfloat_float64_add -#define float32_sub _softfloat_float32_sub -#define float64_sub _softfloat_float64_sub -#define float32_mul _softfloat_float32_mul -#define float64_mul _softfloat_float64_mul -#define float32_div _softfloat_float32_div -#define float64_div _softfloat_float64_div -#define int32_to_float32 _softfloat_int32_to_float32 -#define int32_to_float64 _softfloat_int32_to_float64 -#define int64_to_float32 _softfloat_int64_to_float32 -#define int64_to_float64 _softfloat_int64_to_float64 -#define float32_to_int32_round_to_zero _softfloat_float32_to_int32_round_to_zero -#define float64_to_int32_round_to_zero _softfloat_float64_to_int32_round_to_zero -#define float32_to_int64_round_to_zero _softfloat_float32_to_int64_round_to_zero -#define float64_to_int64_round_to_zero _softfloat_float64_to_int64_round_to_zero -#define float32_to_uint32_round_to_zero _softfloat_float32_to_uint32_round_to_zero -#define float64_to_uint32_round_to_zero _softfloat_float64_to_uint32_round_to_zero -#define float32_to_float64 _softfloat_float32_to_float64 -#define float64_to_float32 _softfloat_float64_to_float32 -#define float32_is_signaling_nan _softfloat_float32_is_signaling_nan -#define float64_is_signaling_nan _softfloat_float64_is_signaling_nan - -#endif /* SOFTFLOATSPARC64_FOR_GCC and !SOFTFLOAT_FOR_GCC */ - -/* - * The following will always end up in the namespace if FLOAT128 is - * defined and SOFTFLOAT_FOR_GCC isn't. So rename them out of the user's - * namespace. - */ - -#ifdef SOFTFLOATSPARC64_FOR_GCC -#define float128_add _softfloat_float128_add -#define float128_div _softfloat_float128_div -#define float128_eq _softfloat_float128_eq -#define float128_eq_signaling _softfloat_float128_eq_signaling -#define float128_is_nan _softfloat_float128_is_nan -#define float128_is_signaling_nan _softfloat_float128_is_signaling_nan -#define float128_le _softfloat_float128_le -#define float128_le_quiet _softfloat_float128_le_quiet -#define float128_lt _softfloat_float128_lt -#define float128_lt_quiet _softfloat_float128_lt_quiet -#define float128_mul _softfloat_float128_mul -#define float128_rem _softfloat_float128_rem -#define float128_round_to_int _softfloat_float128_round_to_int -#define float128_sqrt _softfloat_float128_sqrt -#define float128_sub _softfloat_float128_sub -#define float128_to_float32 _softfloat_float128_to_float32 -#define float128_to_float64 _softfloat_float128_to_float64 -#define float128_to_int32 _softfloat_float128_to_int32 -#define float128_to_int32_round_to_zero _softfloat_float128_to_int32_round_to_zero -#define float128_to_int64 _softfloat_float128_to_int64 -#define float128_to_int64_round_to_zero _softfloat_float128_to_int64_round_to_zero -#define float128_to_uint64_round_to_zero _softfloat_float128_to_uint64_round_to_zero -#define float32_to_float128 _softfloat_float32_to_float128 -#define float64_to_float128 _softfloat_float64_to_float128 -#define int32_to_float128 _softfloat_int32_to_float128 -#define int64_to_float128 _softfloat_int64_to_float128 - -/* - * If this isn't defined go ahead and set it now since this is now past - * anywhere define's are happening and this will conditionally compile out - * a lot of extraneous code in softfloat.c - */ - -#ifndef SOFTFLOAT_FOR_GCC -#define SOFTFLOAT_FOR_GCC -#endif - -#endif /* SOFTFLOATSPARC64_FOR_GCC */ diff --git a/lib/libc/arch/sparc64/softfloat/softfloat-wrapper.c b/lib/libc/arch/sparc64/softfloat/softfloat-wrapper.c deleted file mode 100644 index ac5582aff..000000000 --- a/lib/libc/arch/sparc64/softfloat/softfloat-wrapper.c +++ /dev/null @@ -1 +0,0 @@ -#include diff --git a/lib/libc/arch/sparc64/softfloat/softfloat.h b/lib/libc/arch/sparc64/softfloat/softfloat.h deleted file mode 100644 index 881669265..000000000 --- a/lib/libc/arch/sparc64/softfloat/softfloat.h +++ /dev/null @@ -1,305 +0,0 @@ -/* $NetBSD: softfloat.h,v 1.8 2011/07/07 07:14:57 matt Exp $ */ - -/* This is a derivative work. */ - -/* -=============================================================================== - -This C header file is part of the SoftFloat IEC/IEEE Floating-point -Arithmetic Package, Release 2a. - -Written by John R. Hauser. This work was made possible in part by the -International Computer Science Institute, located at Suite 600, 1947 Center -Street, Berkeley, California 94704. Funding was partially provided by the -National Science Foundation under grant MIP-9311980. The original version -of this code was written as part of a project to build a fixed-point vector -processor in collaboration with the University of California at Berkeley, -overseen by Profs. Nelson Morgan and John Wawrzynek. More information -is available through the Web page `http://HTTP.CS.Berkeley.EDU/~jhauser/ -arithmetic/SoftFloat.html'. - -THIS SOFTWARE IS DISTRIBUTED AS IS, FOR FREE. Although reasonable effort -has been made to avoid it, THIS SOFTWARE MAY CONTAIN FAULTS THAT WILL AT -TIMES RESULT IN INCORRECT BEHAVIOR. USE OF THIS SOFTWARE IS RESTRICTED TO -PERSONS AND ORGANIZATIONS WHO CAN AND WILL TAKE FULL RESPONSIBILITY FOR ANY -AND ALL LOSSES, COSTS, OR OTHER PROBLEMS ARISING FROM ITS USE. - -Derivative works are acceptable, even for commercial purposes, so long as -(1) they include prominent notice that the work is derivative, and (2) they -include prominent notice akin to these four paragraphs for those parts of -this code that are retained. - -=============================================================================== -*/ - -/* -------------------------------------------------------------------------------- -The macro `FLOATX80' must be defined to enable the extended double-precision -floating-point format `floatx80'. If this macro is not defined, the -`floatx80' type will not be defined, and none of the functions that either -input or output the `floatx80' type will be defined. The same applies to -the `FLOAT128' macro and the quadruple-precision format `float128'. -------------------------------------------------------------------------------- -*/ -/* #define FLOATX80 */ -#define FLOAT128 - -#include "softfloat-qp.h" - -#include - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point types. -------------------------------------------------------------------------------- -*/ -typedef unsigned int float32; -typedef unsigned long long float64; -#ifdef FLOATX80 -typedef struct { - unsigned short high; - unsigned long long low; -} floatx80; -#endif -#ifdef FLOAT128 -typedef struct { - unsigned long long high, low; -} float128; -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point underflow tininess-detection mode. -------------------------------------------------------------------------------- -*/ -#ifndef SOFTFLOAT_FOR_GCC -extern int8 float_detect_tininess; -#endif -enum { - float_tininess_after_rounding = 0, - float_tininess_before_rounding = 1 -}; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point rounding mode. -------------------------------------------------------------------------------- -*/ -extern fp_rnd float_rounding_mode; -#define float_round_nearest_even FP_RN -#define float_round_to_zero FP_RZ -#define float_round_down FP_RM -#define float_round_up FP_RP - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE floating-point exception flags. -------------------------------------------------------------------------------- -*/ -extern fp_except float_exception_flags; -extern fp_except float_exception_mask; -enum { - float_flag_inexact = FP_X_IMP, - float_flag_underflow = FP_X_UFL, - float_flag_overflow = FP_X_OFL, - float_flag_divbyzero = FP_X_DZ, - float_flag_invalid = FP_X_INV -}; - -/* -------------------------------------------------------------------------------- -Routine to raise any or all of the software IEC/IEEE floating-point -exception flags. -------------------------------------------------------------------------------- -*/ -void float_raise( fp_except ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE integer-to-floating-point conversion routines. -------------------------------------------------------------------------------- -*/ -float32 int32_to_float32( int32 ); -float32 uint32_to_float32( uint32 ); -float64 int32_to_float64( int32 ); -float64 uint32_to_float64( uint32 ); -#ifdef FLOATX80 -floatx80 int32_to_floatx80( int32 ); -floatx80 uint32_to_floatx80( uint32 ); -#endif -#ifdef FLOAT128 -float128 int32_to_float128( int32 ); -float128 uint32_to_float128( uint32 ); -#endif -float32 int64_to_float32( long long ); -float64 int64_to_float64( long long ); -#ifdef FLOATX80 -floatx80 int64_to_floatx80( long long ); -#endif -#ifdef FLOAT128 -float128 int64_to_float128( long long ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float32_to_int32( float32 ); -int float32_to_int32_round_to_zero( float32 ); -unsigned int float32_to_uint32_round_to_zero( float32 ); -long long float32_to_int64( float32 ); -long long float32_to_int64_round_to_zero( float32 ); -float64 float32_to_float64( float32 ); -#ifdef FLOATX80 -floatx80 float32_to_floatx80( float32 ); -#endif -#ifdef FLOAT128 -float128 float32_to_float128( float32 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE single-precision operations. -------------------------------------------------------------------------------- -*/ -float32 float32_round_to_int( float32 ); -float32 float32_add( float32, float32 ); -float32 float32_sub( float32, float32 ); -float32 float32_mul( float32, float32 ); -float32 float32_div( float32, float32 ); -float32 float32_rem( float32, float32 ); -float32 float32_sqrt( float32 ); -flag float32_eq( float32, float32 ); -flag float32_le( float32, float32 ); -flag float32_lt( float32, float32 ); -flag float32_eq_signaling( float32, float32 ); -flag float32_le_quiet( float32, float32 ); -flag float32_lt_quiet( float32, float32 ); -flag float32_is_signaling_nan( float32 ); - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float64_to_int32( float64 ); -int float64_to_int32_round_to_zero( float64 ); -unsigned int float64_to_uint32_round_to_zero( float64 ); -long long float64_to_int64( float64 ); -long long float64_to_int64_round_to_zero( float64 ); -float32 float64_to_float32( float64 ); -#ifdef FLOATX80 -floatx80 float64_to_floatx80( float64 ); -#endif -#ifdef FLOAT128 -float128 float64_to_float128( float64 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE double-precision operations. -------------------------------------------------------------------------------- -*/ -float64 float64_round_to_int( float64 ); -float64 float64_add( float64, float64 ); -float64 float64_sub( float64, float64 ); -float64 float64_mul( float64, float64 ); -float64 float64_div( float64, float64 ); -float64 float64_rem( float64, float64 ); -float64 float64_sqrt( float64 ); -flag float64_eq( float64, float64 ); -flag float64_le( float64, float64 ); -flag float64_lt( float64, float64 ); -flag float64_eq_signaling( float64, float64 ); -flag float64_le_quiet( float64, float64 ); -flag float64_lt_quiet( float64, float64 ); -flag float64_is_signaling_nan( float64 ); - -#ifdef FLOATX80 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int floatx80_to_int32( floatx80 ); -int floatx80_to_int32_round_to_zero( floatx80 ); -long long floatx80_to_int64( floatx80 ); -long long floatx80_to_int64_round_to_zero( floatx80 ); -float32 floatx80_to_float32( floatx80 ); -float64 floatx80_to_float64( floatx80 ); -#ifdef FLOAT128 -float128 floatx80_to_float128( floatx80 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision rounding precision. Valid -values are 32, 64, and 80. -------------------------------------------------------------------------------- -*/ -extern int floatx80_rounding_precision; - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE extended double-precision operations. -------------------------------------------------------------------------------- -*/ -floatx80 floatx80_round_to_int( floatx80 ); -floatx80 floatx80_add( floatx80, floatx80 ); -floatx80 floatx80_sub( floatx80, floatx80 ); -floatx80 floatx80_mul( floatx80, floatx80 ); -floatx80 floatx80_div( floatx80, floatx80 ); -floatx80 floatx80_rem( floatx80, floatx80 ); -floatx80 floatx80_sqrt( floatx80 ); -flag floatx80_eq( floatx80, floatx80 ); -flag floatx80_le( floatx80, floatx80 ); -flag floatx80_lt( floatx80, floatx80 ); -flag floatx80_eq_signaling( floatx80, floatx80 ); -flag floatx80_le_quiet( floatx80, floatx80 ); -flag floatx80_lt_quiet( floatx80, floatx80 ); -flag floatx80_is_signaling_nan( floatx80 ); - -#endif - -#ifdef FLOAT128 - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision conversion routines. -------------------------------------------------------------------------------- -*/ -int float128_to_int32( float128 ); -int float128_to_int32_round_to_zero( float128 ); -long long float128_to_int64( float128 ); -long long float128_to_int64_round_to_zero( float128 ); -unsigned long long float128_to_uint64_round_to_zero( float128 ); -float32 float128_to_float32( float128 ); -float64 float128_to_float64( float128 ); -#ifdef FLOATX80 -floatx80 float128_to_floatx80( float128 ); -#endif - -/* -------------------------------------------------------------------------------- -Software IEC/IEEE quadruple-precision operations. -------------------------------------------------------------------------------- -*/ -float128 float128_round_to_int( float128 ); -float128 float128_add( float128, float128 ); -float128 float128_sub( float128, float128 ); -float128 float128_mul( float128, float128 ); -float128 float128_div( float128, float128 ); -float128 float128_rem( float128, float128 ); -float128 float128_sqrt( float128 ); -flag float128_eq( float128, float128 ); -flag float128_le( float128, float128 ); -flag float128_lt( float128, float128 ); -flag float128_eq_signaling( float128, float128 ); -flag float128_le_quiet( float128, float128 ); -flag float128_lt_quiet( float128, float128 ); -flag float128_is_signaling_nan( float128 ); -flag float128_is_nan( float128 ); - -#endif diff --git a/lib/libc/arch/sparc64/softfloat/sparc64-gcc.h b/lib/libc/arch/sparc64/softfloat/sparc64-gcc.h deleted file mode 100644 index 778e9d0e3..000000000 --- a/lib/libc/arch/sparc64/softfloat/sparc64-gcc.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: sparc64-gcc.h,v 1.2 2005/12/24 21:11:16 perry Exp $ */ - -/* -------------------------------------------------------------------------------- -One of the macros `BIGENDIAN' or `LITTLEENDIAN' must be defined. -------------------------------------------------------------------------------- -*/ -#include -#if _BYTE_ORDER == _BIG_ENDIAN -#define BIGENDIAN -#endif -#if _BYTE_ORDER == _LITTLE_ENDIAN -#define LITTLEENDIAN -#endif - -/* -------------------------------------------------------------------------------- -The macro `BITS64' can be defined to indicate that 64-bit integer types are -supported by the compiler. -------------------------------------------------------------------------------- -*/ -#define BITS64 - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines the most convenient type that holds -integers of at least as many bits as specified. For example, `uint8' should -be the most convenient type that can hold unsigned integers of as many as -8 bits. The `flag' type must be able to hold either a 0 or 1. For most -implementations of C, `flag', `uint8', and `int8' should all be `typedef'ed -to the same as `int'. -------------------------------------------------------------------------------- -*/ -typedef int flag; -typedef int uint8; -typedef int int8; -typedef int uint16; -typedef int int16; -typedef unsigned int uint32; -typedef signed int int32; -#ifdef BITS64 -typedef unsigned long long int uint64; -typedef signed long long int int64; -#endif - -/* -------------------------------------------------------------------------------- -Each of the following `typedef's defines a type that holds integers -of _exactly_ the number of bits specified. For instance, for most -implementation of C, `bits16' and `sbits16' should be `typedef'ed to -`unsigned short int' and `signed short int' (or `short int'), respectively. -------------------------------------------------------------------------------- -*/ -typedef unsigned char bits8; -typedef signed char sbits8; -typedef unsigned short int bits16; -typedef signed short int sbits16; -typedef unsigned int bits32; -typedef signed int sbits32; -#ifdef BITS64 -typedef unsigned long long int bits64; -typedef signed long long int sbits64; -#endif - -#ifdef BITS64 -/* -------------------------------------------------------------------------------- -The `LIT64' macro takes as its argument a textual integer literal and -if necessary ``marks'' the literal as having a 64-bit integer type. -For example, the GNU C Compiler (`gcc') requires that 64-bit literals be -appended with the letters `LL' standing for `long long', which is `gcc's -name for the 64-bit integer type. Some compilers may allow `LIT64' to be -defined as the identity macro: `#define LIT64( a ) a'. -------------------------------------------------------------------------------- -*/ -#define LIT64( a ) a##LL -#endif - -/* -------------------------------------------------------------------------------- -The macro `INLINE' can be used before functions that should be inlined. If -a compiler does not support explicit inlining, this macro should be defined -to be `static'. -------------------------------------------------------------------------------- -*/ -#define INLINE static inline - -#define FLOAT64_DEMANGLE(a) (a) -#define FLOAT64_MANGLE(a) (a) diff --git a/lib/libc/arch/sparc64/stdlib/Makefile.inc b/lib/libc/arch/sparc64/stdlib/Makefile.inc deleted file mode 100644 index 2f91b992a..000000000 --- a/lib/libc/arch/sparc64/stdlib/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/31 20:40:00 dsl Exp $ diff --git a/lib/libc/arch/sparc64/stdlib/abs.S b/lib/libc/arch/sparc64/stdlib/abs.S deleted file mode 100644 index 379b26e95..000000000 --- a/lib/libc/arch/sparc64/stdlib/abs.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: abs.S,v 1.2 2003/08/07 16:42:28 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: abs.s,v 1.1 91/07/06 18:01:57 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)abs.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: abs.S,v 1.2 2003/08/07 16:42:28 agc Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* abs - int absolute value */ - - -ENTRY(abs) - neg %o0, %o1 - retl - movrlz %o0, %o1, %o0 diff --git a/lib/libc/arch/sparc64/string/Makefile.inc b/lib/libc/arch/sparc64/string/Makefile.inc deleted file mode 100644 index 3d197b8bb..000000000 --- a/lib/libc/arch/sparc64/string/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.8 2009/08/11 17:30:43 dsl Exp $ - -SRCS+= ffs.S memcpy.S memset.S strlen.S -NO_SRCS+= bcopy.S bzero.S diff --git a/lib/libc/arch/sparc64/sys/__clone.S b/lib/libc/arch/sparc64/sys/__clone.S deleted file mode 100644 index 3d36d7ded..000000000 --- a/lib/libc/arch/sparc64/sys/__clone.S +++ /dev/null @@ -1,91 +0,0 @@ -/* $NetBSD: __clone.S,v 1.7 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - save %sp, -CC64FSZ, %sp - - /* - * Sanity checks: func and stack may not be NULL. - */ - brz,pn %i0,8f ! func == NULL, bail - orcc %i1, %g0, %o1 ! setup stack arg for syscall, test - bz,pn %xcc, 8f ! stack == NULL, bail - mov %i2, %o0 ! setup flags arg for syscall - - /* - * Allocate "caller's" frame in the child stack as ABI - * requires. Subtract BIAS - it will be 64-bit code. - * - * We pass the function and the argument to the child by - * stashing them at the bottom of the frame. There they are - * safe from window spill would we need to take one as it's - * below the window save area. - */ - sub %o1, CC64FSZ+BIAS, %o1 ! make space - stx %i0, [%o1+CC64FSZ-16+BIAS] ! save func - stx %i3, [%o1+CC64FSZ-8+BIAS] ! save arg - - /* - * Args are now set up for system call as (flags, stack). - */ - mov SYS___clone, %g1 - t ST_SYSCALL - bcs,pn %xcc, 9f - tst %o1 ! %o1 (rv[1]) == 0 in parent - bz %xcc, 2f ! yes, parent - ldx [%sp+CC64FSZ-16+BIAS], %l0 ! grab the function... - call %l0 ! Call the clone's entry point. - ldx [%sp+CC64FSZ-8+BIAS], %o0 ! ...and the argument - - JUMP(_exit) - /* NOTREACHED */ - -2: ret - restore %g0, %o0, %o0 - -8: restore %g0, EINVAL, %o0 - ERROR() - /* NOTREACHED */ - -9: restore %o0, %g0, %o0 - ERROR() - /* NOTREACHED */ diff --git a/lib/libc/arch/sparc64/sys/__sigaction14_sigtramp.c b/lib/libc/arch/sparc64/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 62833a674..000000000 --- a/lib/libc/arch/sparc64/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.9 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.9 2009/01/11 02:46:24 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern void __sigtramp_siginfo_2(void); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the compatibility SIGCONTEXT trampoline if SA_SIGINFO - * is not set in the sigaction. - */ - if (act && (act->sa_flags & SA_SIGINFO) == 0) { - extern void __sigtramp_sigcontext_1(void); - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_1, 1); - /* - * EINVAL might indicate that trampoline version 1 is - * not supported by the kernel; fall back on native - * SIGINFO trampoline. - */ - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/sparc64/sys/__sigtramp2.S b/lib/libc/arch/sparc64/sys/__sigtramp2.S deleted file mode 100644 index 9f9357194..000000000 --- a/lib/libc/arch/sparc64/sys/__sigtramp2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __sigtramp2.S,v 1.3 2008/04/28 20:22:57 martin Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#define _LOCORE -#include /* BIAS, CC64FSZ */ - -/* - * When this code is run, the stack looks like: - * [%sp + BIAS] struct frame - * [%sp + BIAS + CC64FSZ] siginfo_t - * [%sp + BIAS + CC64FSZ + 128] ucontext_t - * . - * . - */ -ENTRY_NOPROFILE(__sigtramp_siginfo_2) - add %sp, BIAS + CC64FSZ + 128, %o0 /* get pointer to ucontext */ - mov SYS_setcontext, %g1 - t ST_SYSCALL /* call setcontext */ - mov SYS_exit, %g1 /* exit with errno */ - t ST_SYSCALL /* if sigreturn fails */ diff --git a/lib/libc/arch/sparc64/sys/__syscall.S b/lib/libc/arch/sparc64/sys/__syscall.S deleted file mode 100644 index 5d55ec75e..000000000 --- a/lib/libc/arch/sparc64/sys/__syscall.S +++ /dev/null @@ -1,6 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.1 2000/12/13 20:25:04 martin Exp $ */ - -#include -#include "SYS.h" - -RSYSCALL(__syscall) diff --git a/lib/libc/arch/sparc64/sys/__vfork14.S b/lib/libc/arch/sparc64/sys/__vfork14.S deleted file mode 100644 index 1ffd4d619..000000000 --- a/lib/libc/arch/sparc64/sys/__vfork14.S +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.3 2003/08/07 16:42:29 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: Ovfork.s,v 1.1 91/07/06 13:05:56 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: __vfork14.S,v 1.3 2003/08/07 16:42:29 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * pid = vfork(); - * - * %o1 == 0 in parent process, 1 in child process. - * %o0 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -SYSCALL(__vfork14) - dec %o1 /* from 1 to 0 in child, 0 to -1 in parent */ - retl - and %o0, %o1, %o0 /* return 0 in child, pid in parent */ diff --git a/lib/libc/arch/sparc64/sys/brk.S b/lib/libc/arch/sparc64/sys/brk.S deleted file mode 100644 index 981f313f3..000000000 --- a/lib/libc/arch/sparc64/sys/brk.S +++ /dev/null @@ -1,118 +0,0 @@ -/* $NetBSD: brk.S,v 1.13 2013/09/12 15:36:16 joerg Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: brk.s,v 1.3 92/06/25 12:56:05 mccanne Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)brk.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: brk.S,v 1.13 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _C_LABEL(__curbrk) - .globl _C_LABEL(__minbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data - .align 8 -_C_LABEL(__minbrk): - .xword _C_LABEL(_end) /* lower brk limit; also for gmon code */ - .text - -#if __PIC__ - 0 >= 2 - -ENTRY(_brk) - PIC_PROLOGUE(%o5,%o4) - set _C_LABEL(__minbrk), %o4 - ldx [%o5 + %o4], %o4 - ldx [%o4], %o1 /* %o1 = minbrk */ - cmp %o1, %o0 /* if (minbrk > %o0) */ - movgu %xcc, %o1, %o0 /* %o0 = minbrk */ - mov %o0, %o2 /* save argument to syscall */ - mov SYS_break, %g1 - t ST_SYSCALL - set _C_LABEL(__curbrk), %o3 - bcc,a,pt %icc, 1f - ldx [%o5 + %o3], %o4 - ERROR() -1: - retl /* success, return 0 & record new break */ - stx %o2, [%o4] - -#elif __PIC__ - 0 >= 1 - -ENTRY(_brk) - PIC_PROLOGUE(%o5,%o4) - ldx [%o5 + _C_LABEL(__minbrk)], %o4 - ldx [%o4], %o1 /* %o1 = minbrk */ - cmp %o1, %o0 /* if (minbrk > %o0) */ - movgu %xcc, %o1, %o0 /* %o0 = minbrk */ - mov %o0, %o2 /* save argument to syscall */ - mov SYS_break, %g1 - t ST_SYSCALL - bcc,a,pt %icc, 1f - ldx [%o5 + _C_LABEL(__curbrk)], %o4 - ERROR() -1: - retl /* success, return 0 & record new break */ - stx %o2, [%o4] - -#else - -ENTRY(_brk) - sethi %hi(_C_LABEL(__minbrk)), %o1 /* %o1 = minbrk */ - ldx [%o1 + %lo(_C_LABEL(__minbrk))], %o1 - cmp %o1, %o0 /* if (minbrk > %o0) */ - movgu %xcc, %o1, %o0 /* %o0 = minbrk */ - mov %o0, %o2 /* save argument to syscall */ - mov SYS_break, %g1 - t ST_SYSCALL - bcc,a,pt %icc,1f - sethi %hi(_C_LABEL(__curbrk)), %g1 - ERROR() -1: - retl /* success, return 0 & record new break */ - stx %o2, [%g1 + %lo(_C_LABEL(__curbrk))] - -#endif diff --git a/lib/libc/arch/sparc64/sys/cerror.S b/lib/libc/arch/sparc64/sys/cerror.S deleted file mode 100644 index af4d39efb..000000000 --- a/lib/libc/arch/sparc64/sys/cerror.S +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: cerror.S,v 1.8 2013/09/14 05:38:00 nakayama Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: cerror.s,v 1.3 92/07/02 04:17:59 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)cerror.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: cerror.S,v 1.8 2013/09/14 05:38:00 nakayama Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef _REENTRANT -FUNC(__cerror) - save %sp, -CC64FSZ, %sp - call _C_LABEL(__errno) - nop - st %i0, [%o0] - mov -1, %i0 - ret - restore %g0, -1, %o1 -#else - .globl _C_LABEL(errno) - -#if __PIC__ - 0 >= 2 - -FUNC(__cerror) - PIC_PROLOGUE(%g1, %o3) - set _C_LABEL(errno),%o1 - ldx [%g1 + %o1], %g1 - st %o0, [%g1] - mov -1, %o0 - retl - mov -1, %o1 - -#elif __PIC__ - 0 >= 1 - -FUNC(__cerror) - PIC_PROLOGUE(%g1, %o3) - ldx [%g1 + _C_LABEL(errno)], %g1 - st %o0, [%g1] - mov -1, %o0 - retl - mov -1, %o1 - -#else - -FUNC(__cerror) - sethi %hi(_C_LABEL(errno)), %g1 - st %o0, [%g1 + %lo(_C_LABEL(errno))] - mov -1, %o0 - retl - mov -1, %o1 - -#endif /* __PIC__ */ - -#endif /* _REENTRANT */ diff --git a/lib/libc/arch/sparc64/sys/exect.S b/lib/libc/arch/sparc64/sys/exect.S deleted file mode 100644 index 5c886989c..000000000 --- a/lib/libc/arch/sparc64/sys/exect.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: exect.S,v 1.2 2003/08/07 16:42:29 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: exect.s,v 1.1 91/07/06 13:05:57 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)exect.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: exect.S,v 1.2 2003/08/07 16:42:29 agc Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(exect) - mov SYS_execve, %g1 /* execve(file, argv, env) */ - t ST_SYSCALL - ERROR() diff --git a/lib/libc/arch/sparc64/sys/fork.S b/lib/libc/arch/sparc64/sys/fork.S deleted file mode 100644 index e83affa83..000000000 --- a/lib/libc/arch/sparc64/sys/fork.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: fork.S,v 1.5 2003/08/07 16:42:30 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: fork.s,v 1.1 91/07/06 13:05:58 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)fork.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: fork.S,v 1.5 2003/08/07 16:42:30 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -_SYSCALL(__fork,fork) - dec %o1 /* from 1 to 0 in child, 0 to -1 in parent */ - retl - and %o0, %o1, %o0 /* return 0 in child, pid in parent */ diff --git a/lib/libc/arch/sparc64/sys/getcontext.S b/lib/libc/arch/sparc64/sys/getcontext.S deleted file mode 100644 index 29f0c840a..000000000 --- a/lib/libc/arch/sparc64/sys/getcontext.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.3 2008/04/28 20:22:57 martin Exp $") -#endif /* SYSLIBC_SCCS && !lint */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -ENTRY(_getcontext) - mov %o0, %o2 /* must save pointer */ - mov SYS_getcontext, %g1 - t ST_SYSCALL - bcc,a 1f - stx %g0, [%o2 + 64 + 11 * 8] /* gr[_REG_O0] = 0 */ - ERROR() -1: - add %o7, 8, %o1 - stx %o1, [%o2 + 64 + 1 * 8] /* gr[_REG_PC] = retaddr */ - add %o7, 12, %o1 - retl - stx %o1, [%o2 + 64 + 2 * 8] /* gr[_REG_nPC] = retaddr + 4 */ diff --git a/lib/libc/arch/sparc64/sys/pipe.S b/lib/libc/arch/sparc64/sys/pipe.S deleted file mode 100644 index c0c6ecfc9..000000000 --- a/lib/libc/arch/sparc64/sys/pipe.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: pipe.S,v 1.4 2003/08/07 16:42:30 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: pipe.s,v 1.1 91/07/06 13:05:58 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)pipe.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: pipe.S,v 1.4 2003/08/07 16:42:30 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -ENTRY(_pipe) - mov %o0, %o2 /* save pointer */ - mov SYS_pipe, %g1 - t ST_SYSCALL /* pipe() */ - bcc,a 1f - st %o0, [%o2] /* success, store fds */ - ERROR() -1: - st %o1, [%o2 + 4] - retl /* and return 0 */ - clr %o0 diff --git a/lib/libc/arch/sparc64/sys/ptrace.S b/lib/libc/arch/sparc64/sys/ptrace.S deleted file mode 100644 index ecf2c9cb3..000000000 --- a/lib/libc/arch/sparc64/sys/ptrace.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.5 2003/08/07 16:42:30 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: ptrace.s,v 1.2 91/12/20 01:59:00 leres Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)ptrace.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: ptrace.S,v 1.5 2003/08/07 16:42:30 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(ptrace) - save %sp, -CC64FSZ, %sp - call _C_LABEL(__errno) - nop - st %g0, [%o0] - restore - mov SYS_ptrace, %g1 - t ST_SYSCALL - bcc 1f - nop - ERROR() -1: - retl - nop diff --git a/lib/libc/arch/sparc64/sys/sbrk.S b/lib/libc/arch/sparc64/sys/sbrk.S deleted file mode 100644 index 29fd9fe6f..000000000 --- a/lib/libc/arch/sparc64/sys/sbrk.S +++ /dev/null @@ -1,113 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.11 2013/09/14 05:38:00 nakayama Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sbrk.s,v 1.3 92/07/02 00:56:49 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: sbrk.S,v 1.11 2013/09/14 05:38:00 nakayama Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _C_LABEL(__curbrk) - .globl _C_LABEL(_end) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data - .align 8 -_C_LABEL(__curbrk): - .xword _C_LABEL(_end) - .text - -#if __PIC__ - 0 >= 2 - -ENTRY(_sbrk) - PIC_PROLOGUE(%o5,%o4) - set _C_LABEL(__curbrk), %o3 - ldx [%o5 + %o3], %o2 - ldx [%o2], %o3 /* %o3 = old break */ - add %o3, %o0, %o4 /* %o4 = new break */ - mov %o4, %o0 /* copy for syscall */ - mov SYS_break, %g1 - t ST_SYSCALL /* break(new_break) */ - bcc,a 1f /* if success, */ - mov %o3, %o0 /* set return value */ - ERROR() -1: - retl /* and update curbrk */ - stx %o4, [%o2] - -#elif __PIC__ - 0 >= 1 - -ENTRY(_sbrk) - PIC_PROLOGUE(%o5,%o4) - ldx [%o5 + _C_LABEL(__curbrk)], %o2 - ldx [%o2], %o3 /* %o3 = old break */ - add %o3, %o0, %o4 /* %o4 = new break */ - mov %o4, %o0 /* copy for syscall */ - mov SYS_break, %g1 - t ST_SYSCALL /* break(new_break) */ - bcc,a 1f /* if success, */ - mov %o3, %o0 /* set return value */ - ERROR() -1: - retl /* and update curbrk */ - stx %o4, [%o2] - -#else - -ENTRY(_sbrk) - sethi %hi(_C_LABEL(__curbrk)), %o2 - ldx [%o2 + %lo(_C_LABEL(__curbrk))], %o3 /* %o3 = old break */ - add %o3, %o0, %o4 /* %o4 = new break */ - mov %o4, %o0 /* copy for syscall */ - mov SYS_break, %g1 - t ST_SYSCALL /* break(new_break) */ - bcc,a 1f /* if success, */ - mov %o3, %o0 /* set return value */ - ERROR() -1: - retl /* and update curbrk */ - stx %o4, [%o2 + %lo(_C_LABEL(__curbrk))] - -#endif /* __PIC__ */ diff --git a/lib/libc/arch/sparc64/sys/shmat.S b/lib/libc/arch/sparc64/sys/shmat.S deleted file mode 100644 index 216dbd807..000000000 --- a/lib/libc/arch/sparc64/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:55 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/sparc64/sys/syscall.S b/lib/libc/arch/sparc64/sys/syscall.S deleted file mode 100644 index f49bf2dbf..000000000 --- a/lib/libc/arch/sparc64/sys/syscall.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: syscall.S,v 1.2 2003/08/07 16:42:30 agc Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: syscall.s,v 1.1 91/07/06 13:06:02 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)syscall.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: syscall.S,v 1.2 2003/08/07 16:42:30 agc Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -RSYSCALL(syscall) diff --git a/lib/libc/arch/vax/DEFS.h b/lib/libc/arch/vax/DEFS.h deleted file mode 100644 index 9e2619748..000000000 --- a/lib/libc/arch/vax/DEFS.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: DEFS.h,v 1.3 1996/01/06 18:34:59 ragge Exp $ */ - -#include - diff --git a/lib/libc/arch/vax/Makefile.inc b/lib/libc/arch/vax/Makefile.inc deleted file mode 100644 index 592be933b..000000000 --- a/lib/libc/arch/vax/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.9 2010/07/06 05:59:52 mrg Exp $ - -SRCS+= __longjmp14.c -SRCS+= __sigaction14_sigtramp.c __sigtramp3.S - -CPPFLAGS+= -I. -CPPFLAGS.assym.h+=-D__LIBC12_SOURCE__ diff --git a/lib/libc/arch/vax/SYS.h b/lib/libc/arch/vax/SYS.h deleted file mode 100644 index 315f31944..000000000 --- a/lib/libc/arch/vax/SYS.h +++ /dev/null @@ -1,89 +0,0 @@ -/* $NetBSD: SYS.h,v 1.12 2012/02/27 12:26:21 joerg Exp $ */ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)SYS.h 8.1 (Berkeley) 6/4/93 - */ - -#include -#include - -#define CERROR _C_LABEL(__cerror) -#define CURBRK _C_LABEL(__curbrk) - -#ifdef __STDC__ -#define SYSTRAP(x) chmk $ SYS_ ## x -#else -#define SYSTRAP(x) chmk $ SYS_/**/x -#endif - -#define _SYSCALL_NOERROR(x,y) \ - ENTRY(x,0); \ - SYSTRAP(y) - -#define _SYSCALL(x,y) \ - .p2align 2; \ - err: nop; nop; jmp CERROR+2; \ - _SYSCALL_NOERROR(x,y); \ - jcs err+2 - -#define SYSCALL_NOERROR(x) \ - _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ - ret; \ - END(x) - -#define PSEUDO(x,y) \ - _SYSCALL(x,y); \ - ret; \ - END(x) - -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) \ - PSEUDO(x,x) - -#ifdef WEAK_ALIAS -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) -#else -#define WSYSCALL(weak,strong) \ - PSEUDO(weak,weak) -#endif - -#define ASMSTR .asciz - - .protected CERROR - .globl CERROR diff --git a/lib/libc/arch/vax/gdtoa/Makefile.inc b/lib/libc/arch/vax/gdtoa/Makefile.inc deleted file mode 100644 index bae804d5d..000000000 --- a/lib/libc/arch/vax/gdtoa/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof_vaxf.c diff --git a/lib/libc/arch/vax/gdtoa/arith.h b/lib/libc/arch/vax/gdtoa/arith.h deleted file mode 100644 index 66e57a0b8..000000000 --- a/lib/libc/arch/vax/gdtoa/arith.h +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define VAX -#define NO_HEX_FP /* XXX */ diff --git a/lib/libc/arch/vax/gdtoa/gd_qnan.h b/lib/libc/arch/vax/gdtoa/gd_qnan.h deleted file mode 100644 index 86a5f8de9..000000000 --- a/lib/libc/arch/vax/gdtoa/gd_qnan.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -/* No NaN in VAX FP. */ diff --git a/lib/libc/arch/vax/gen/Makefile.inc b/lib/libc/arch/vax/gen/Makefile.inc deleted file mode 100644 index 224cb0ff2..000000000 --- a/lib/libc/arch/vax/gen/Makefile.inc +++ /dev/null @@ -1,22 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.17 2010/07/06 05:59:52 mrg Exp $ - -SRCS+= byte_swap_2.S byte_swap_4.S bswap64.S \ - fabs.S frexp.c \ - fpclassifyf.c fpclassifyd.c \ - infinityf.c infinity.c infinityl.c \ - isfinitef.c isfinited.c \ - ldexp.S \ - makecontext.c modf.S \ - resumecontext.c \ - signbitf.c signbitd.c \ - swapcontext.S \ - udiv.S urem.S \ - __setjmp14.S __sigsetjmp14.S _lwp.c _setjmp.S - -# ABI compatibility for libc.so.12 -SRCS+= isinf.c isnan.c - -LSRCS.vax.gen= Lint_bswap16.c Lint_bswap32.c Lint_bswap64.c -LSRCS+= ${LSRCS.vax.gen} -DPSRCS+= ${LSRCS.vax.gen} -CLEANFILES+= ${LSRCS.vax.gen} diff --git a/lib/libc/arch/vax/gen/__longjmp14.c b/lib/libc/arch/vax/gen/__longjmp14.c deleted file mode 100644 index c5d1aafbe..000000000 --- a/lib/libc/arch/vax/gen/__longjmp14.c +++ /dev/null @@ -1,94 +0,0 @@ -/* $NetBSD: __longjmp14.c,v 1.4 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christian Limpach and Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include - -struct _jmp_buf { - struct sigcontext jb_sc; - register_t jb_regs[6]; -}; - -void -__longjmp14(jmp_buf env, int val) -{ - struct _jmp_buf *jb = (void *)env; - ucontext_t uc; - - /* Ensure non-zero SP */ - if (jb->jb_sc.sc_sp == 0) - goto err; - - /* Ensure non-zero return value */ - if (val == 0) - val = -1; - - /* Set _UC_SIGMASK and _UC_CPU */ - uc.uc_flags = _UC_SIGMASK | _UC_CPU; - - /* Clear uc_link */ - uc.uc_link = 0; - - /* Save return value in context */ - uc.uc_mcontext.__gregs[_REG_R0] = val; - - /* Copy saved registers */ - uc.uc_mcontext.__gregs[_REG_AP] = jb->jb_sc.sc_ap; - uc.uc_mcontext.__gregs[_REG_SP] = jb->jb_sc.sc_sp; - uc.uc_mcontext.__gregs[_REG_FP] = jb->jb_sc.sc_fp; - uc.uc_mcontext.__gregs[_REG_PC] = jb->jb_sc.sc_pc; - uc.uc_mcontext.__gregs[_REG_PSL] = jb->jb_sc.sc_ps; - - uc.uc_mcontext.__gregs[_REG_R6] = jb->jb_regs[0]; - uc.uc_mcontext.__gregs[_REG_R7] = jb->jb_regs[1]; - uc.uc_mcontext.__gregs[_REG_R8] = jb->jb_regs[2]; - uc.uc_mcontext.__gregs[_REG_R9] = jb->jb_regs[3]; - uc.uc_mcontext.__gregs[_REG_R10] = jb->jb_regs[4]; - uc.uc_mcontext.__gregs[_REG_R11] = jb->jb_regs[5]; - - /* Copy signal mask */ - uc.uc_sigmask = jb->jb_sc.sc_mask; - - setcontext(&uc); - err: - longjmperror(); - abort(); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/vax/gen/__setjmp14.S b/lib/libc/arch/vax/gen/__setjmp14.S deleted file mode 100644 index 6114aad24..000000000 --- a/lib/libc/arch/vax/gen/__setjmp14.S +++ /dev/null @@ -1,77 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "DEFS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: __setjmp14.S,v 1.11 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -ENTRY(__setjmp14, R6) - movl 4(%ap),%r2 # construct sigcontext - subl2 $12,%sp # space for current struct sigstack - pushl %sp # get current values - pushl $0 # no new values - calls $4,_C_LABEL(__sigaltstack14) # pop args plus signal stack value - movl 4(%ap),%r2 # construct sigcontext - movl (%sp)+,(%r2) # save onsigstack status of caller - pushal 28(%r2) - pushl $0 - pushl $0 - calls $3,_C_LABEL(__sigprocmask14) # get signal mask - addl3 $8,4(%ap),%r2 # point to sp in signal context - clrl %r0 # assume no stack arguments - bbc $13,6(%fp),1f # handle callg - addl3 $1,(%ap),%r0 # get argument count +1 if calls -1: moval 24(%fp)[%r0],(%r2)+ # save sp of caller - movl 12(%fp),(%r2)+ # save frame pointer of caller - movl 8(%fp),(%r2)+ # save argument pointer of caller - movl 16(%fp),(%r2)+ # save pc of caller - movpsl (%r2) # save current psl - movw 4(%fp),(%r2) # save psw of caller - addl3 $SC_LEN,4(%ap),%r2 # point to past signal context - movq %r6,(%r2)+ # save r6/r7 - movq %r8,(%r2)+ # save r8/r9 - movq %r10,(%r2)+ # save r10/r11 - clrl %r0 - ret -END(__setjmp14) diff --git a/lib/libc/arch/vax/gen/__sigsetjmp14.S b/lib/libc/arch/vax/gen/__sigsetjmp14.S deleted file mode 100644 index ed661bfa4..000000000 --- a/lib/libc/arch/vax/gen/__sigsetjmp14.S +++ /dev/null @@ -1,65 +0,0 @@ -/* - * Copyright (c) 1983, 1993, 1995 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" -#include - -#if defined(LIBC_SCCS) && !defined(lint) -RCSID("$NetBSD: __sigsetjmp14.S,v 1.5 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, savemask) - * by restoring registers from the stack, - * and dependent on savemask restores the - * signal mask. - */ - -ENTRY(__sigsetjmp14, R6) - movl 4(%ap),%r0 # get env pointer - movl 8(%ap),(_JBLEN*4)(%r0) # save "savemask" - tstl 8(%ap) # do saving of signal mask? - beql L1 - jmp _C_LABEL(__setjmp14)+2 # yep, do full setjmp -L1: jmp _C_LABEL(_setjmp)+2 # nope, skip to _setjmp -END(__sigsetjmp14) - -ENTRY(__siglongjmp14, 0) - movl 4(%ap),%r0 # get env pointer - tstl (_JBLEN*4)(%r0) # test if "savemask" was set - beql L2 - jmp _C_LABEL(__longjmp14)+2 # yep, do full longjmp -L2: jmp _C_LABEL(_longjmp)+2 # nope, skip to _longjmp -END(__siglongjmp14) - diff --git a/lib/libc/arch/vax/gen/_lwp.c b/lib/libc/arch/vax/gen/_lwp.c deleted file mode 100644 index 94d710bc6..000000000 --- a/lib/libc/arch/vax/gen/_lwp.c +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.3 2012/03/22 17:32:22 christos Exp $ */ - -/*- - * Copyright (c) 2009 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.3 2012/03/22 17:32:22 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - __greg_t *gr = u->uc_mcontext.__gregs; - int *sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - /* Align to a word */ - /* LINTED uintptr_t is safe */ - sp = (int *)((uintptr_t)(stack_base + stack_size) & ~0x3); - - /* - * Allocate necessary stack space for arguments including arg count - * and call frame - */ - sp -= 1 + 1 + 5; - - sp[0] = 0; /* condition handler is null */ - sp[1] = 0x20000000; /* make this a CALLS frame */ - sp[2] = 0; /* saved argument pointer */ - sp[3] = 0; /* saved frame pointer */ - sp[4] = (int)(uintptr_t)_lwp_exit + 2;/* return via _lwp_exit */ - sp[5] = 1; /* argc */ - sp[6] = (int)(uintptr_t)arg; /* argv */ - - gr[_REG_AP] = (__greg_t)(uintptr_t)(sp + 5); - gr[_REG_SP] = (__greg_t)(uintptr_t)sp; - gr[_REG_FP] = (__greg_t)(uintptr_t)sp; - gr[_REG_PC] = (__greg_t)(uintptr_t)start + 2; - - /* - * Push the TLS pointer onto the new stack also. - * The _UC_TLSBASE flag tells the kernel to pop it and use it. - */ - *--sp = (int)(intptr_t)private; - gr[_REG_SP] = (__greg_t)(uintptr_t)sp; - u->uc_flags |= _UC_TLSBASE; -} diff --git a/lib/libc/arch/vax/gen/_setjmp.S b/lib/libc/arch/vax/gen/_setjmp.S deleted file mode 100644 index 932ee1371..000000000 --- a/lib/libc/arch/vax/gen/_setjmp.S +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)_setjmp.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: _setjmp.S,v 1.10 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * _setjmp(a) - * by restoring registers from the stack, - * The previous signal state is NOT restored. - * - * Even though we don't use sigreturn14, we still store things in a sigcontext - * in order to be consistent. - */ - -ENTRY(_setjmp, R6) - movl 4(%ap),%r0 - movl 12(%fp),12(%r0) # save frame pointer of caller - movl 16(%fp),20(%r0) # save pc of caller - movl 8(%fp),16(%r0) # save ap of caller - clrl %r1 # clear arg count - bbc $13,6(%fp),1f # was this a callg? - addl3 $1,(%ap),%r1 # get real arg count+1 for calls -1: moval 24(%fp)[%r1],8(%r0) # save sp of caller - movpsl 24(%r0) # save current psl - movw 4(%fp),24(%r0) # save psw of caller - movq %r6,44(%r0) # save r6/r7 - movq %r8,52(%r0) # save r8/r9 - movq %r10,60(%r0) # save r10/r11 - clrl %r0 - ret -END(_setjmp) - -ENTRY(_longjmp, 0) - movl 8(%ap),%r0 # return(v) - movl 4(%ap),%r1 # fetch buffer - tstl 12(%r1) # is fp null - beql botch - movq 44(%r1),%r6 # restore r6/r7 - movq 52(%r1),%r8 # restore r8/r9 - movq 60(%r1),%r10 # restore r10/r11 - movl 16(%r1),%ap # restore ap - movl 8(%r1),%sp # restore sp - movl 12(%r1),%fp # restore fp - movq 20(%r1),-(%sp) # save pc/psl to new stack - rei # and go back to saved pc/psl - -botch: - calls $0,_C_LABEL(longjmperror) - halt -END(_longjmp) diff --git a/lib/libc/arch/vax/gen/alloca.S b/lib/libc/arch/vax/gen/alloca.S deleted file mode 100644 index d6153040e..000000000 --- a/lib/libc/arch/vax/gen/alloca.S +++ /dev/null @@ -1,47 +0,0 @@ -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)alloca.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: alloca.S,v 1.5 2011/11/21 16:17:48 chs Exp $") -#endif /* LIBC_SCCS and not lint */ - -ENTRY(alloca, 0) - movl 4(%ap),%r0 # get allocation size - movl 16(%fp),%r1 # save return address before we smash it - movab here,16(%fp) - ret -here: - subl2 %r0,%sp # create stack space - bicl2 $3,%sp # align to longword boundary - movl %sp,%r0 - jmp (%r1) -END(alloca) diff --git a/lib/libc/arch/vax/gen/byte_swap_2.S b/lib/libc/arch/vax/gen/byte_swap_2.S deleted file mode 100644 index d3e64a109..000000000 --- a/lib/libc/arch/vax/gen/byte_swap_2.S +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)htons.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: byte_swap_2.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -ALTENTRY(ntohs) -ALTENTRY(htons) -ENTRY(__bswap16, 0) - rotl $8,4(%ap),%r0 - movb 5(%ap),%r0 - movzwl %r0,%r0 - ret -END(__bswap16) diff --git a/lib/libc/arch/vax/gen/byte_swap_4.S b/lib/libc/arch/vax/gen/byte_swap_4.S deleted file mode 100644 index d5272a3ae..000000000 --- a/lib/libc/arch/vax/gen/byte_swap_4.S +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)htonl.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: byte_swap_4.S,v 1.5 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -ALTENTRY(ntohl) -ALTENTRY(htonl) -ENTRY(__bswap32, 0) - rotl $-8,4(%ap),%r0 - insv %r0,$16,$8,%r0 - movb 7(%ap),%r0 - ret -END(__bswap32) diff --git a/lib/libc/arch/vax/gen/fabs.S b/lib/libc/arch/vax/gen/fabs.S deleted file mode 100644 index 1b5c5f501..000000000 --- a/lib/libc/arch/vax/gen/fabs.S +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)fabs.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: fabs.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* fabs - floating absolute value */ - -ENTRY(fabs, 0) - movd 4(%ap),%r0 - bgeq 1f - mnegd %r0,%r0 -1: - ret -END(fabs) diff --git a/lib/libc/arch/vax/gen/fpclassifyd.c b/lib/libc/arch/vax/gen/fpclassifyd.c deleted file mode 100644 index d7814de6f..000000000 --- a/lib/libc/arch/vax/gen/fpclassifyd.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: fpclassifyd.c,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyd.c,v 1.3 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * VAX D_floating version - * - * Implementation notes: - * Reserved operand -> FP_ROP - * True zero -> FP_ZERO - * Dirty zero -> FP_DIRTY_ZERO - * Finite -> FP_NORMAL - */ -int -__fpclassifyd(double x) -{ - union vax_dfloating_u u; - - u.dfltu_d = x; - - if (u.dfltu_dflt.dflt_exp == 0) { - if (u.dfltu_dflt.dflt_sign != 0) - return FP_ROP; - else if (u.dfltu_dflt.dflt_frach != 0 || - u.dfltu_dflt.dflt_fracm != 0 || - u.dfltu_dflt.dflt_fracl != 0) - return FP_DIRTYZERO; - else - return FP_ZERO; - } else { - return FP_NORMAL; - } -} diff --git a/lib/libc/arch/vax/gen/fpclassifyf.c b/lib/libc/arch/vax/gen/fpclassifyf.c deleted file mode 100644 index 20145ade3..000000000 --- a/lib/libc/arch/vax/gen/fpclassifyf.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: fpclassifyf.c,v 1.3 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyf.c,v 1.3 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * VAX F_floating version - * - * Implementation notes: - * Reserved operand -> FP_ROP - * True zero -> FP_ZERO - * Dirty zero -> FP_DIRTY_ZERO - * Finite -> FP_NORMAL - */ -int -__fpclassifyf(float x) -{ - union vax_ffloating_u u; - - u.ffltu_f = x; - - if (u.ffltu_fflt.fflt_exp == 0) { - if (u.ffltu_fflt.fflt_sign != 0) - return FP_ROP; - else if (u.ffltu_fflt.fflt_frach != 0 || - u.ffltu_fflt.fflt_fracl != 0) - return FP_DIRTYZERO; - else - return FP_ZERO; - } else { - return FP_NORMAL; - } -} diff --git a/lib/libc/arch/vax/gen/frexp.c b/lib/libc/arch/vax/gen/frexp.c deleted file mode 100644 index a2edb2bda..000000000 --- a/lib/libc/arch/vax/gen/frexp.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: frexp.c,v 1.5 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)frexp.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: frexp.c,v 1.5 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -double -frexp(double value, int *eptr) -{ - union { - double v; - struct { - u_int u_mant1 : 7; - u_int u_exp : 8; - u_int u_sign : 1; - u_int u_mant2 : 16; - u_int u_mant3 : 32; - } s; - } u; - - if (value) { - u.v = value; - *eptr = u.s.u_exp - 128; - u.s.u_exp = 128; - return (u.v); - } else { - *eptr = 0; - return (0.0); - } -} diff --git a/lib/libc/arch/vax/gen/infinity.c b/lib/libc/arch/vax/gen/infinity.c deleted file mode 100644 index fb0d41fab..000000000 --- a/lib/libc/arch/vax/gen/infinity.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: infinity.c,v 1.8 2002/02/19 21:50:01 thorpej Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinity.c,v 1.8 2002/02/19 21:50:01 thorpej Exp $"); -#endif /* LIBC_SCCS and not lint */ -/* - * XXX - This is not correct, but what can we do about it??? - */ - -/* infinity.c */ - -#include - -/* The highest D float on a vax. */ -const union __double_u __infinity = - { { 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; diff --git a/lib/libc/arch/vax/gen/infinityf.c b/lib/libc/arch/vax/gen/infinityf.c deleted file mode 100644 index 49a2704e4..000000000 --- a/lib/libc/arch/vax/gen/infinityf.c +++ /dev/null @@ -1,11 +0,0 @@ -/* $NetBSD: infinityf.c,v 1.1 2003/10/25 22:31:20 kleink Exp $ */ - -/* - * infinityf.c - max. value representable in VAX F_floating -- public domain. - * This is _not_ infinity. - */ - -#include - -const union __float_u __infinityf = - { { 0xff, 0x7f, 0xff, 0xff } }; diff --git a/lib/libc/arch/vax/gen/infinityl.c b/lib/libc/arch/vax/gen/infinityl.c deleted file mode 100644 index 8c613b94a..000000000 --- a/lib/libc/arch/vax/gen/infinityl.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $ */ - -/* - * infinityl.c - max. value representable in VAX D_floating -- public domain. - * This is _not_ infinity. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinityl.c,v 1.2 2005/06/12 05:21:27 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include - -const union __long_double_u __infinityl = - { { 0xff, 0x7f, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } }; diff --git a/lib/libc/arch/vax/gen/isfinited.c b/lib/libc/arch/vax/gen/isfinited.c deleted file mode 100644 index 778cf81ca..000000000 --- a/lib/libc/arch/vax/gen/isfinited.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: isfinited.c,v 1.5 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinited.c,v 1.5 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * VAX D_floating version - */ -int -__isfinited(double x) -{ - union vax_dfloating_u u; - - u.dfltu_d = x; - - if (u.dfltu_dflt.dflt_exp == 0 && - ((u.dfltu_dflt.dflt_frach != 0 || - u.dfltu_dflt.dflt_fracm != 0 || - u.dfltu_dflt.dflt_fracl != 0) || - (u.dfltu_dflt.dflt_sign != 0))) - return 0; - - return 1; -} diff --git a/lib/libc/arch/vax/gen/isfinitef.c b/lib/libc/arch/vax/gen/isfinitef.c deleted file mode 100644 index 3bdfc2227..000000000 --- a/lib/libc/arch/vax/gen/isfinitef.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: isfinitef.c,v 1.4 2008/04/28 20:22:57 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinitef.c,v 1.4 2008/04/28 20:22:57 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * VAX F_floating version - */ -int -__isfinitef(float x) -{ - union vax_ffloating_u u; - - u.ffltu_f = x; - - if (u.ffltu_fflt.fflt_exp == 0 && - ((u.ffltu_fflt.fflt_frach != 0 || - u.ffltu_fflt.fflt_fracl != 0) || - (u.ffltu_fflt.fflt_sign != 0))) - return 0; - - return 1; -} diff --git a/lib/libc/arch/vax/gen/isinf.c b/lib/libc/arch/vax/gen/isinf.c deleted file mode 100644 index 8478a4cb0..000000000 --- a/lib/libc/arch/vax/gen/isinf.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: isinf.c,v 1.8 2004/03/04 23:42:39 kleink Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinf.c,v 1.8 2004/03/04 23:42:39 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include - -#undef isinf -int isinf __P((double)); - -/* ARGSUSED */ -int -isinf(double d) -{ - return (0); -} diff --git a/lib/libc/arch/vax/gen/isnan.c b/lib/libc/arch/vax/gen/isnan.c deleted file mode 100644 index d46615ef3..000000000 --- a/lib/libc/arch/vax/gen/isnan.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: isnan.c,v 1.3 2004/03/04 23:42:39 kleink Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnan.c,v 1.3 2004/03/04 23:42:39 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#undef isnan -int isnan __P((double)); - -/* ARGSUSED */ -int -isnan(double d) -{ - return (0); -} diff --git a/lib/libc/arch/vax/gen/ldexp.S b/lib/libc/arch/vax/gen/ldexp.S deleted file mode 100644 index 477705e18..000000000 --- a/lib/libc/arch/vax/gen/ldexp.S +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * double ldexp (value, exp) - * double value; - * int exp; - * - * Ldexp returns value*2**exp, if that result is in range. - * If underflow occurs, it returns zero. If overflow occurs, - * it returns a value of appropriate sign and largest - * possible magnitude. In case of either overflow or underflow, - * errno is set to ERANGE. Note that errno is not modified if - * no error occurs. - */ - -#include "DEFS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /*.asciz "@(#)ldexp.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: ldexp.S,v 1.7 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -#ifndef _REENTRANT - .globl _C_LABEL(errno) -#endif - -ENTRY(ldexp, 0) - movd 4(%ap),%r0 /* fetch "value" */ - extzv $7,$8,%r0,%r2 /* %r2 := biased exponent */ - jeql 1f /* if zero, done */ - - addl2 12(%ap),%r2 /* %r2 := new biased exponent */ - jleq 2f /* if <= 0, underflow */ - cmpl %r2,$256 /* otherwise check if too big */ - jgeq 3f /* jump if overflow */ - insv %r2,$7,$8,%r0 /* put exponent back in result */ -1: - ret -2: - clrd %r0 - jbr 1f -3: - /* - * The largest number that can be represented in a long floating - * number. This is given in hex in order to avoid floating - * conversions - */ - movq $0x7fffffffffffffff,%r0 /* largest possible floating magnitude */ - jbc $15,4(%ap),1f /* jump if argument was positive */ - mnegd %r0,%r0 /* if arg < 0, make result negative */ -1: -#ifdef _REENTRANT - pushl %r0 - calls $0,_C_LABEL(__errno) - movl $ ERANGE,(%r0) - movl (%sp)+,%r0 -#else - movl $ ERANGE,_C_LABEL(errno) -#endif - ret -END(ldexp) diff --git a/lib/libc/arch/vax/gen/makecontext.c b/lib/libc/arch/vax/gen/makecontext.c deleted file mode 100644 index 7199f12c1..000000000 --- a/lib/libc/arch/vax/gen/makecontext.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.4 2012/03/22 17:32:22 christos Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.4 2012/03/22 17:32:22 christos Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - va_list ap; - int *sp; - int i; - - /* Compute and align stack pointer. */ - sp = (int *) - (((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size) & ~0x3); - - /* - * Allocate necessary stack space for arguments including arg count - * and call frame - */ - sp -= argc + 1 + 5; - - va_start(ap, argc); - sp[5] = argc; - for (i = 1; argc > 0; argc--, i++) - sp[5 + i] = va_arg(ap, int); - va_end(ap); - - sp[0] = 0; /* condition handler is null */ - sp[1] = 0x20000000; /* make this a CALLS frame */ - sp[2] = 0; /* saved argument pointer */ - sp[3] = 0; /* saved frame pointer */ - sp[4] = (int)(uintptr_t)_resumecontext+2;/* return via trampoline code */ - - gr[_REG_AP] = (__greg_t)(uintptr_t)(sp + 5); - gr[_REG_SP] = (__greg_t)(uintptr_t)sp; - gr[_REG_FP] = (__greg_t)(uintptr_t)sp; - gr[_REG_PC] = (__greg_t)(uintptr_t)func+2; - -} diff --git a/lib/libc/arch/vax/gen/modf.S b/lib/libc/arch/vax/gen/modf.S deleted file mode 100644 index 684875641..000000000 --- a/lib/libc/arch/vax/gen/modf.S +++ /dev/null @@ -1,63 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)modf.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: modf.S,v 1.5 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * double modf (value, iptr) - * double value, *iptr; - * - * Modf returns the fractional part of "value", - * and stores the integer part indirectly through "iptr". - */ - -ENTRY(modf, 0) - emodd 4(%ap),$0,$0f1.0,%r2,%r0 - jvs 1f # integer overflow - cvtld %r2,*12(%ap) - ret -1: - subd3 %r0,4(%ap),*12(%ap) - ret -END(modf) - -ENTRY(modff, 0) - emodf 4(%ap),$0,$0f1.0,%r2,%r0 - jvs 1f # integer overflow - cvtlf %r2,*8(%ap) - ret -1: - subf3 %r0,4(%ap),*8(%ap) - ret -END(modff) diff --git a/lib/libc/arch/vax/gen/resumecontext.c b/lib/libc/arch/vax/gen/resumecontext.c deleted file mode 100644 index f604739da..000000000 --- a/lib/libc/arch/vax/gen/resumecontext.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: resumecontext.c,v 1.4 2011/09/19 21:24:58 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: resumecontext.c,v 1.4 2011/09/19 21:24:58 joerg Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include -#include "extern.h" - -void -_resumecontext(void) -{ - ucontext_t uct; - - (void)getcontext(&uct); - if (uct.uc_link == NULL) - exit(0); - (void)setcontext(uct.uc_link); - _exit(-1); - /* NOTREACHED */ -} diff --git a/lib/libc/arch/vax/gen/signbitd.c b/lib/libc/arch/vax/gen/signbitd.c deleted file mode 100644 index 7f313e1e3..000000000 --- a/lib/libc/arch/vax/gen/signbitd.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitd.c,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: signbitd.c,v 1.2 2008/04/28 20:22:58 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * VAX D_floating version - */ -int -__signbitd(double x) -{ - union vax_dfloating_u u; - - u.dfltu_d = x; - - return (u.dfltu_dflt.dflt_sign == 1); -} diff --git a/lib/libc/arch/vax/gen/signbitf.c b/lib/libc/arch/vax/gen/signbitf.c deleted file mode 100644 index 02cedaab5..000000000 --- a/lib/libc/arch/vax/gen/signbitf.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitf.c,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: signbitf.c,v 1.2 2008/04/28 20:22:58 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * VAX F_floating version - */ -int -__signbitf(float x) -{ - union vax_ffloating_u u; - - u.ffltu_f = x; - - return (u.ffltu_fflt.fflt_sign == 1); -} diff --git a/lib/libc/arch/vax/gen/swapcontext.S b/lib/libc/arch/vax/gen/swapcontext.S deleted file mode 100644 index f80a29bc9..000000000 --- a/lib/libc/arch/vax/gen/swapcontext.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifdef LIBC_SCCS -RCSID("$NetBSD: swapcontext.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - -ENTRY(swapcontext, 0) - clrl %r0 /* assume getcontext succeeds */ - chmk $SYS_getcontext /* getcontext(oucp) */ - jcc 1f - jmp CERROR+2 /* something bad happened */ - -1: movl 4(%ap),%r0 /* get oucp */ - addl3 (%ap),$(5+1),%r1 /* size of callframe + arglist (LW) */ - bbs $13,6(%fp),2f /* was this a CALLG? */ - movl $5,%r1 /* size of callframe (in LW) */ -2: movl 8(%fp),(36+12*4)(%r0) /* restore AP */ - moval (%sp)[%r1],(36+13*4)(%r0) /* restore SP */ - movq 12(%fp),(36+14*4)(%r0) /* restore FP + PC */ - - pushl 8(%ap) - calls $1,_C_LABEL(setcontext) /* setcontext(ucp) */ - ret -END(swapcontext) diff --git a/lib/libc/arch/vax/genassym.cf b/lib/libc/arch/vax/genassym.cf deleted file mode 100644 index cad3361db..000000000 --- a/lib/libc/arch/vax/genassym.cf +++ /dev/null @@ -1,86 +0,0 @@ -# $NetBSD: genassym.cf,v 1.5 2011/01/25 02:38:15 matt Exp $ - -# -# Copyright (c) 2001 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Matt Thomas . -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -include -include -include - -define UC_LEN sizeof(ucontext_t) -define UC_FLAGS offsetof(ucontext_t, uc_flags) -define UC_LINK offsetof(ucontext_t, uc_link) -define UC_STACK offsetof(ucontext_t, uc_stack) -define UC_SIGMASK offsetof(ucontext_t, uc_sigmask) -define UC_GREGS offsetof(ucontext_t, uc_mcontext.__gregs) -define _UC_SIGMASK _UC_SIGMASK -define _UC_STACK _UC_STACK -define _UC_CPU _UC_CPU - -define _REG_R0 4*_REG_R0 -define _REG_R1 4*_REG_R1 -define _REG_R2 4*_REG_R2 -define _REG_R4 4*_REG_R4 -define _REG_R6 4*_REG_R6 -define _REG_R8 4*_REG_R8 -define _REG_R10 4*_REG_R10 -define _REG_AP 4*_REG_AP -define _REG_SP 4*_REG_SP -define _REG_FP 4*_REG_FP -define _REG_PC 4*_REG_PC -define _REG_PSL 4*_REG_PSL - -define SS_SP offsetof(stack_t, ss_sp) -define SS_SIZE offsetof(stack_t, ss_size) -define SS_FLAGS offsetof(stack_t, ss_flags) -define SS_ONSTACK SS_ONSTACK - -define SC13_LEN sizeof(struct sigcontext13) -define SC13_ONSTACK offsetof(struct sigcontext13, sc_onstack) -define SC13_MASK offsetof(struct sigcontext13, sc_mask) -define SC13_SP offsetof(struct sigcontext13, sc_sp) -define SC13_FP offsetof(struct sigcontext13, sc_fp) -define SC13_AP offsetof(struct sigcontext13, sc_ap) -define SC13_PC offsetof(struct sigcontext13, sc_pc) -define SC13_PS offsetof(struct sigcontext13, sc_ps) - -define SC_LEN sizeof(struct sigcontext) -define SC_ONSTACK offsetof(struct sigcontext, sc_onstack) -define SC_MASK13 offsetof(struct sigcontext, __sc_mask13) -define SC_SP offsetof(struct sigcontext, sc_sp) -define SC_FP offsetof(struct sigcontext, sc_fp) -define SC_AP offsetof(struct sigcontext, sc_ap) -define SC_PC offsetof(struct sigcontext, sc_pc) -define SC_PS offsetof(struct sigcontext, sc_ps) -define SC_MASK offsetof(struct sigcontext, sc_mask) - -define SIG_BLOCK SIG_BLOCK -define SS_LEN sizeof(sigset_t) - -define ERANGE ERANGE diff --git a/lib/libc/arch/vax/net/Makefile.inc b/lib/libc/arch/vax/net/Makefile.inc deleted file mode 100644 index db4492c3d..000000000 --- a/lib/libc/arch/vax/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2004/06/06 17:09:48 he Exp $ - -# ntoh* and htn* are in ../gen/byte_swap_* -SRCS+= diff --git a/lib/libc/arch/vax/stdlib/Makefile.inc b/lib/libc/arch/vax/stdlib/Makefile.inc deleted file mode 100644 index 60574235e..000000000 --- a/lib/libc/arch/vax/stdlib/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2009/07/31 20:40:00 dsl Exp $ - -SRCS+= erand48.c -NO_SRCS+= erand48_ieee754.c diff --git a/lib/libc/arch/vax/string/Makefile.inc b/lib/libc/arch/vax/string/Makefile.inc deleted file mode 100644 index 57d25c571..000000000 --- a/lib/libc/arch/vax/string/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2010/03/12 09:12:35 uwe Exp $ - -SRCS+= bcmp.S bcopy.S bzero.S ffs.S memcmp.S -SRCS+= memcpy.S memmove.S memset.S diff --git a/lib/libc/arch/vax/string/bcmp.S b/lib/libc/arch/vax/string/bcmp.S deleted file mode 100644 index 1ea154014..000000000 --- a/lib/libc/arch/vax/string/bcmp.S +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: bcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* bcmp(s1, s2, n) */ - -#include "DEFS.h" - -#ifdef LIBC_SCCS -RCSID("$NetBSD: bcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - -/* Since "cmpc3" is not portable across VAXen, do it the hard way */ -/* still, this is four times faster than the generic C version on a uvax2 */ - -ENTRY(bcmp, 0) - movl 12(%ap),%r0 # %r0 = n - jeql 9f - movq 4(%ap),%r1 # %r1 = s1, %r2 = s2 - ashl $-2,%r0,%r3 # convert len to # of long words - jeql 2f -1: - cmpl (%r1)+,(%r2)+ # no "cmpq" alas, so four bytes at a time - jneq 9f - sobgtr %r3,1b -2: - bicl3 $-4,%r0,%r3 # handle at most 3 extra bytes - jeql 8f -3: - cmpb (%r1)+,(%r2)+ - jneq 9f - sobgtr %r3,3b -8: - clrl %r0 # we have a match! -9: - ret -END(bcmp) diff --git a/lib/libc/arch/vax/string/bcopy.S b/lib/libc/arch/vax/string/bcopy.S deleted file mode 100644 index b2f96a49f..000000000 --- a/lib/libc/arch/vax/string/bcopy.S +++ /dev/null @@ -1,78 +0,0 @@ -/* $NetBSD: bcopy.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* bcopy(from, to, size) */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) - /* .asciz "@(#)bcopy.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: bcopy.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - - -ENTRY(bcopy, R6) - movl 4(%ap),%r1 - movl 8(%ap),%r3 - movl 12(%ap),%r6 - cmpl %r1,%r3 - bgtr 2f # normal forward case - blss 3f # overlapping, must do backwards - ret # equal, nothing to do -1: - subl2 %r0,%r6 - movc3 %r0,(%r1),(%r3) -2: - movzwl $65535,%r0 - cmpl %r6,%r0 - jgtr 1b - movc3 %r6,(%r1),(%r3) - ret -3: - addl2 %r6,%r1 - addl2 %r6,%r3 - movzwl $65535,%r0 - jbr 5f -4: - subl2 %r0,%r6 - subl2 %r0,%r1 - subl2 %r0,%r3 - movc3 %r0,(%r1),(%r3) - movzwl $65535,%r0 - subl2 %r0,%r1 - subl2 %r0,%r3 -5: - cmpl %r6,%r0 - jgtr 4b - subl2 %r6,%r1 - subl2 %r6,%r3 - movc3 %r6,(%r1),(%r3) - ret -END(bcopy) diff --git a/lib/libc/arch/vax/string/bzero.S b/lib/libc/arch/vax/string/bzero.S deleted file mode 100644 index 54b3046f4..000000000 --- a/lib/libc/arch/vax/string/bzero.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: bzero.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) - /* .asciz "@(#)bzero.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: bzero.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - -/* bzero(base, length) */ - -ENTRY(bzero, 0) - movl 4(%ap),%r3 - jbr 2f -1: - subl2 %r0,8(%ap) - movc5 $0,(%r3),$0,%r0,(%r3) -2: - movzwl $65535,%r0 - cmpl 8(%ap),%r0 - jgtr 1b - movc5 $0,(%r3),$0,8(%ap),(%r3) - ret -END(bzero) diff --git a/lib/libc/arch/vax/string/ffs.S b/lib/libc/arch/vax/string/ffs.S deleted file mode 100644 index a87be2adf..000000000 --- a/lib/libc/arch/vax/string/ffs.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: ffs.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "DEFS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - /* .asciz "@(#)ffs.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: ffs.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* bit = ffs(value) */ - -ENTRY(ffs, 0) - ffs $0,$32,4(%ap),%r0 - bneq 1f - mnegl $1,%r0 -1: - incl %r0 - ret -END(ffs) diff --git a/lib/libc/arch/vax/string/index.S b/lib/libc/arch/vax/string/index.S deleted file mode 100644 index 5d0516bd9..000000000 --- a/lib/libc/arch/vax/string/index.S +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: index.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Find the first occurence of c in the string cp. - * Return pointer to match or null pointer. - * - * char * - * index(cp, c) - * char *cp, c; - */ -#include "DEFS.h" - -#ifdef LIBC_SCCS -RCSID("$NetSBD$") -#endif - -/* Alas not quite twice as fast as the generic C version on a uvax2 */ - -ENTRY(index, 0) - movq 4(%ap),%r0 # %r0 = cp; %r1 = c - tstb %r1 # special case, looking for '\0' - jeql 3f -1: - cmpb (%r0),%r1 - jeql 2f - tstb (%r0)+ - jneq 1b - clrl %r0 # return NULL if no match -2: - ret -3: - tstb (%r0)+ - jneq 3b - decl %r0 - jbr 2b -END(index) diff --git a/lib/libc/arch/vax/string/memcmp.S b/lib/libc/arch/vax/string/memcmp.S deleted file mode 100644 index 89e9ac5e3..000000000 --- a/lib/libc/arch/vax/string/memcmp.S +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: memcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - */ - -/* int memcmp(s1, s2, n) */ - -#include "DEFS.h" - -#ifdef LIBC_SCCS -RCSID("$NetBSD: memcmp.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - -ENTRY(memcmp, 0) - movl 12(%ap),%r0 - jeql 9f - movq 4(%ap),%r1 - ashl $-2,%r0,%r3 # convert len to long words - jeql 2f -1: - cmpl (%r1)+,(%r2)+ # no "cmpq" alas - jneq 7f - sobgtr %r3,1b -2: - bicl3 $-4,%r0,%r3 # handle at most 3 extra bytes - jeql 4f -3: - cmpb (%r1)+,(%r2)+ - jneq 8f - sobgtr %r3,3b -4: - clrl %r0 # we had a match - ret -7: # backup, and do a byte compare - tstl -(%r1) - tstl -(%r2) - movl $4,%r3 - jbr 3b -8: - movzbl -(%r1),%r3 - movzbl -(%r2),%r4 - subl3 %r4,%r3,%r0 -9: - ret -END(memcmp) diff --git a/lib/libc/arch/vax/sys/__clone.S b/lib/libc/arch/vax/sys/__clone.S deleted file mode 100644 index 2d7246acd..000000000 --- a/lib/libc/arch/vax/sys/__clone.S +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: __clone.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include "SYS.h" - -#ifdef SYSLIBC_SCCS -RCSID("$NetBSD: __clone.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - -/* - * int __clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone, 0) - - /* - * Sanity checks: func and stack may not be NULL. - */ - movl 4(%ap),%r2 /* check and save function */ - beql 9f - tstl 8(%ap) /* check stack */ - beql 9f - - /* - * The system call expects (flags, stack). - */ - movl 12(%ap),4(%ap) /* XXX this doesn't work for - callg with a RO arglist */ - movl $2,(%ap) - SYSTRAP(__clone) /* only %r0/%r1 munged */ - - blbc %r1,8f /* %r1<0>: 0=parent 1=child */ - - /* Call the clone's entry point. */ - pushl 16(%ap) - calls $1,(%r2) - - /* Pass return value to _exit(). */ - pushl %r0 - calls $1,_C_LABEL(_exit) - - /* NOTREACHED */ - -8: ret - -9: movl $EINVAL,%r0 - jmp CERROR+2 -END(__clone) diff --git a/lib/libc/arch/vax/sys/__sigaction14_sigtramp.c b/lib/libc/arch/vax/sys/__sigaction14_sigtramp.c deleted file mode 100644 index 8c0695566..000000000 --- a/lib/libc/arch/vax/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.10 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.10 2008/04/28 20:22:58 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -extern const int __sigtramp_siginfo_3[]; - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); - -#ifdef __LIBC12_SOURCE__ - /* - * We select the non-SA_SIGINFO trampoline if SA_SIGINFO is not - * set in the sigaction. - */ - if ((act->sa_flags & SA_SIGINFO) == 0) { - extern const int __sigtramp_sigcontext_2[]; - int sav = errno; - int rv = __sigaction_sigtramp(sig, act, oact, - __sigtramp_sigcontext_2, 2); - if (rv >= 0 || errno != EINVAL) - return rv; - errno = sav; - } -#endif - - /* - * If SA_SIGINFO was specificed or the compatibility trampolines - * can't be used, use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_3, 3); -} diff --git a/lib/libc/arch/vax/sys/__sigtramp3.S b/lib/libc/arch/vax/sys/__sigtramp3.S deleted file mode 100644 index 0631cceac..000000000 --- a/lib/libc/arch/vax/sys/__sigtramp3.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: __sigtramp3.S,v 1.2 2011/01/25 02:38:15 matt Exp $ */ - -/* - * Copyright (c) 2003 Matt Thomas - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * 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. - */ - -/* - * Signal trampoline; registers when called: - * pc, psl - obvious - * sp, ap - points to argument list - * 4(ap) -- signo - * 8(ap) -- pointer to siginfo - * 12(ap) -- pointer to ucontext - * fp - address of signal handler - */ - -#include "SYS.h" - -#ifdef SYSLIBC_SCCS -RCSID("$NetBSD: __sigtramp3.S,v 1.2 2011/01/25 02:38:15 matt Exp $") -#endif - - .text - _ALIGN_TEXT - - .globl _C_LABEL(__sigtramp_siginfo_3) -_C_LABEL(__sigtramp_siginfo_3): - nop; nop - callg (%ap),(%fp) # use global arg list - addl2 $8,%ap # arg is pointer to ucontext - SYSTRAP(setcontext) # exit from here - halt # illegal insn diff --git a/lib/libc/arch/vax/sys/__syscall.S b/lib/libc/arch/vax/sys/__syscall.S deleted file mode 100644 index 1efa4a64e..000000000 --- a/lib/libc/arch/vax/sys/__syscall.S +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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 "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)syscall.s 8.2 (Berkeley) 1/21/94" */ -RCSID("$NetBSD: __syscall.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -ENTRY(__syscall, 0) - movl 4(%ap),%r0 # syscall number - addl2 $8,%ap # skip the first argument - subl3 $2,-8(%ap),(%ap) # two fewer arguments - chmk %r0 - jcs 1f - ret -1: - jmp CERROR+2 -END(__syscall) diff --git a/lib/libc/arch/vax/sys/__vfork14.S b/lib/libc/arch/vax/sys/__vfork14.S deleted file mode 100644 index 440ac3f45..000000000 --- a/lib/libc/arch/vax/sys/__vfork14.S +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: __vfork14.S,v 1.7 2011/11/21 16:17:48 chs Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * @(#)vfork.s 4.1 (Berkeley) 12/21/80 - * C library -- vfork - */ - -/* - * pid = vfork(); - * - * %r1 == 0 in parent process, %r1 == 1 in child process. - * %r0 == pid of child in parent, %r0 == pid of parent in child. - * - * trickery here, due to keith sklower, uses ret to clear the stack, - * and then returns with a jump indirect, since only one person can return - * with a ret off this stack... we do the ret before we vfork! - */ - -ENTRY(__vfork14, 0) - movl 16(%fp),%r0 # save return address before we smash it - movab here,16(%fp) - ret -here: - movl %r0,%r2 - chmk $ SYS___vfork14 - bcs err # if failed, set errno and return -1 - /* this next trick is Chris Torek's fault */ - mnegl %r1,%r1 # %r1 = 0xffffffff if child, 0 if parent - bicl2 %r1,%r0 # %r0 &= ~%r1, i.e., 0 if child, else unchanged - jmp (%r2) - -err: -#ifdef _REENTRANT - pushr $0x5 - calls $0,_C_LABEL(__errno) - movl (%sp)+,(%r0) - mnegl $1,%r0 - rsb -#else - movl %r0,_C_LABEL(errno) - mnegl $1,%r0 - jmp (%r2) -#endif -END(__vfork14) diff --git a/lib/libc/arch/vax/sys/brk.S b/lib/libc/arch/vax/sys/brk.S deleted file mode 100644 index 468b523df..000000000 --- a/lib/libc/arch/vax/sys/brk.S +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)brk.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: brk.S,v 1.15 2014/03/18 18:20:37 riastradh Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - - .globl _C_LABEL(__curbrk) - .globl _C_LABEL(__minbrk) - .hidden _C_LABEL(__curbrk) - .hidden _C_LABEL(__minbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - -ENTRY(_brk, 0) - moval _C_LABEL(__minbrk),%r5 # gtr > _end - cmpl (%r5),4(%ap) # gtr > _end - blequ 1f # is fine - movl (%r5),4(%ap) # shrink back to _end -1: chmk $ SYS_break # do it - jcs err - movl 4(%ap),_C_LABEL(__curbrk) - clrl %r0 - ret -err: - jmp CERROR+2 -END(_brk) diff --git a/lib/libc/arch/vax/sys/cerror.S b/lib/libc/arch/vax/sys/cerror.S deleted file mode 100644 index 94f929ac4..000000000 --- a/lib/libc/arch/vax/sys/cerror.S +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)cerror.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: cerror.S,v 1.9 2011/01/25 02:38:15 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - - .globl _C_LABEL(errno) -NENTRY(__cerror, 0) -#ifdef _REENTRANT - pushl %r0 - calls $0,_C_LABEL(__errno) - movl (%sp)+,(%r0) -#else - movl %r0,_C_LABEL(errno) -#endif - mnegl $1,%r0 - movl %r0,%r1 - ret -END(__cerror) diff --git a/lib/libc/arch/vax/sys/execl.S b/lib/libc/arch/vax/sys/execl.S deleted file mode 100644 index c084b8a8c..000000000 --- a/lib/libc/arch/vax/sys/execl.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: execl.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 2001 Ludd, University of Lule}, Sweden. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed at Ludd, University of - * Lule}, Sweden and its contributors. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifdef SYSLIBC_SCCS -RCSID("$NetBSD: execl.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(execl, _execl) -#endif - -ENTRY(_execl, 0) - pushal 8(%ap) # Push pointer to argv vector - pushl 4(%ap) # Push path - calls $2,_C_LABEL(execv) - ret -END(_execl) diff --git a/lib/libc/arch/vax/sys/execle.S b/lib/libc/arch/vax/sys/execle.S deleted file mode 100644 index 3a3a5288c..000000000 --- a/lib/libc/arch/vax/sys/execle.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: execle.S,v 1.5 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 2001 Ludd, University of Lule}, Sweden. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed at Ludd, University of - * Lule}, Sweden and its contributors. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifdef SYSLIBC_SCCS -RCSID("$NetBSD: execle.S,v 1.5 2011/01/25 02:38:15 matt Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(execle, _execle) -#endif - -ENTRY(_execle, 0) - movl (%ap),%r0 # Get number of args - pushl (%ap)[%r0] # Push last arg (envp) - pushal 8(%ap) # Push pointer to argv vector - pushl 4(%ap) # Push path - calls $3,_C_LABEL(execve) - ret -END(_execle) diff --git a/lib/libc/arch/vax/sys/execlp.S b/lib/libc/arch/vax/sys/execlp.S deleted file mode 100644 index 3c866ea39..000000000 --- a/lib/libc/arch/vax/sys/execlp.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: execlp.S,v 1.4 2011/01/25 02:38:15 matt Exp $ */ -/* - * Copyright (c) 2001 Ludd, University of Lule}, Sweden. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed at Ludd, University of - * Lule}, Sweden and its contributors. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifdef SYSLIBC_SCCS -RCSID("$NetBSD: execlp.S,v 1.4 2011/01/25 02:38:15 matt Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(execlp, _execlp) -#endif - -ENTRY(_execlp, 0) - pushal 8(%ap) # Push pointer to argv vector - pushl 4(%ap) # Push path - calls $2,_C_LABEL(execvp) - ret -END(_execlp) diff --git a/lib/libc/arch/vax/sys/exect.S b/lib/libc/arch/vax/sys/exect.S deleted file mode 100644 index 191fb6e99..000000000 --- a/lib/libc/arch/vax/sys/exect.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" -#include - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)exect.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: exect.S,v 1.6 2011/01/25 02:38:15 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -ENTRY(exect, 0) - bispsw $PSL_T - chmk $ SYS_execve - jmp CERROR+2 # exect(file, argv, env) -END(exect) diff --git a/lib/libc/arch/vax/sys/fork.S b/lib/libc/arch/vax/sys/fork.S deleted file mode 100644 index 54d5b7d37..000000000 --- a/lib/libc/arch/vax/sys/fork.S +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)fork.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: fork.S,v 1.6 2011/01/25 02:38:15 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -_SYSCALL(__fork,fork) - jlbc %r1,1f # parent, since %r1 == 0 in parent, 1 in child - clrl %r0 -1: - ret # pid = fork() -END(__fork) diff --git a/lib/libc/arch/vax/sys/getcontext.S b/lib/libc/arch/vax/sys/getcontext.S deleted file mode 100644 index d33419312..000000000 --- a/lib/libc/arch/vax/sys/getcontext.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.6 2011/11/21 16:17:48 chs Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#ifdef SYSLIBC_SCCS -RCSID("$NetBSD: getcontext.S,v 1.6 2011/11/21 16:17:48 chs Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -/* - * Can't use R4 or R5 since those needed by the phread_switch code. - */ -ENTRY(_getcontext, 0) - clrl %r0 /* assume success */ - chmk $SYS_getcontext /* getcontext(oucp) */ - jcc 1f - jmp CERROR+2 /* badness happened */ - -1: movl 4(%ap),%r0 /* ptr to ucontext */ - movl 16(%fp),%r1 /* PC to return to */ - movab 2f,16(%fp) /* let's return early */ - ret - /* - * Now we have the blown away the callframe and argument - * list so it's as if we've return from the function except - * we aren't executing the caller's code (yet). So it's - * the callers state but we still have control. - */ - _ALIGN_TEXT -2: movq %ap,(36+12*4)(%r0) /* adjust AP + SP */ - movl %fp,(36+14*4)(%r0) /* adjust FP */ - movl %r3,(36+15*4)(%r0) /* adjust PC */ - clrl %r0 - jmp (%r1) /* and return */ -END(_getcontext) diff --git a/lib/libc/arch/vax/sys/pipe.S b/lib/libc/arch/vax/sys/pipe.S deleted file mode 100644 index 60ded6aed..000000000 --- a/lib/libc/arch/vax/sys/pipe.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) - /* .asciz "@(#)pipe.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: pipe.S,v 1.5 2011/01/25 02:38:15 matt Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -_SYSCALL(_pipe,pipe) - movl 4(%ap),%r2 - movl %r0,(%r2)+ - movl %r1,(%r2) - clrl %r0 - ret -END(_pipe) diff --git a/lib/libc/arch/vax/sys/ptrace.S b/lib/libc/arch/vax/sys/ptrace.S deleted file mode 100644 index 6e8519c02..000000000 --- a/lib/libc/arch/vax/sys/ptrace.S +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)ptrace.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: ptrace.S,v 1.8 2011/01/25 02:38:15 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -ENTRY(ptrace, 0) -#ifdef _REENTRANT - calls $0,_C_LABEL(__errno) - clrl (%r0) -#else - clrl _C_LABEL(errno) -#endif - chmk $ SYS_ptrace - jcs err - ret -err: - jmp CERROR+2 -END(ptrace) diff --git a/lib/libc/arch/vax/sys/sbrk.S b/lib/libc/arch/vax/sys/sbrk.S deleted file mode 100644 index 922b70d10..000000000 --- a/lib/libc/arch/vax/sys/sbrk.S +++ /dev/null @@ -1,67 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)sbrk.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: sbrk.S,v 1.13 2014/03/18 18:20:37 riastradh Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - - .globl _end - .globl _C_LABEL(__minbrk) - .globl _C_LABEL(__curbrk) - .hidden _C_LABEL(__minbrk) - .hidden _C_LABEL(__curbrk) - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data -_C_LABEL(__minbrk): - .long _end -_C_LABEL(__curbrk): - .long _end - .text - -ENTRY(_sbrk, 0) - moval _C_LABEL(__curbrk),%r5 - addl3 (%r5),4(%ap),-(%sp) - pushl $1 - movl %ap,%r3 - movl %sp,%ap - chmk $ SYS_break - jcs err - movl (%r5),%r0 - addl2 4(%r3),(%r5) - ret -err: - jmp CERROR+2 -END(_sbrk) diff --git a/lib/libc/arch/vax/sys/shmat.S b/lib/libc/arch/vax/sys/shmat.S deleted file mode 100644 index 216dbd807..000000000 --- a/lib/libc/arch/vax/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2000/07/07 08:20:55 itohy Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/vax/sys/syscall.S b/lib/libc/arch/vax/sys/syscall.S deleted file mode 100644 index 9cd8bce53..000000000 --- a/lib/libc/arch/vax/sys/syscall.S +++ /dev/null @@ -1,50 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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 "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)syscall.s 8.2 (Berkeley) 1/21/94" */ -RCSID("$NetBSD: syscall.S,v 1.7 2011/01/25 02:38:15 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -ENTRY(syscall, 0) - movl 4(%ap),%r0 # syscall number - subl3 $1,(%ap)+,(%ap) # one fewer arguments - chmk %r0 - jcs 1f - ret -1: - jmp CERROR+2 -END(syscall) diff --git a/lib/libc/arch/x86_64/Makefile.inc b/lib/libc/arch/x86_64/Makefile.inc deleted file mode 100644 index 7ac3dc0e0..000000000 --- a/lib/libc/arch/x86_64/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 2015/07/15 14:27:49 pooka Exp $ - -.if ${RUMPRUN} != "yes" -SRCS+= __sigaction14_sigtramp.c __sigtramp2.S -.endif diff --git a/lib/libc/arch/x86_64/SYS.h b/lib/libc/arch/x86_64/SYS.h deleted file mode 100644 index d342a166e..000000000 --- a/lib/libc/arch/x86_64/SYS.h +++ /dev/null @@ -1,89 +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 - * William Jolitz. - * - * 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. - * - * from: @(#)SYS.h 5.5 (Berkeley) 5/7/91 - * $NetBSD: SYS.h,v 1.12 2014/05/22 14:38:38 uebayasi Exp $ - */ - -#include -#include - -#ifdef __STDC__ -#define SYSTRAP(x) movl $(SYS_ ## x),%eax; movq %rcx, %r10; syscall -#else -#define SYSTRAP(x) movl $(SYS_/**/x),%eax; movq %rcx, %r10; syscall -#endif - -#define CERROR _C_LABEL(__cerror) -#define CURBRK _C_LABEL(__curbrk) - -#define _SYSCALL_NOERROR(x,y) \ - ENTRY(x); \ - SYSTRAP(y) - -#define _SYSCALL_ERR \ - jmp CERROR - -#define _SYSCALL(x,y) \ - .text; _ALIGN_TEXT; \ - 2: _SYSCALL_ERR; \ - _SYSCALL_NOERROR(x,y); \ - jc 2b - -#define SYSCALL_NOERROR(x) \ - _SYSCALL_NOERROR(x,x) - -#define SYSCALL(x) \ - _SYSCALL(x,x) - -#define PSEUDO_NOERROR(x,y) \ - _SYSCALL_NOERROR(x,y); \ - ret; \ - END(x) - -#define PSEUDO(x,y) \ - _SYSCALL_NOERROR(x,y); \ - jc 2f; \ - ret; \ - 2: _SYSCALL_ERR; \ - END(x) - -#define RSYSCALL_NOERROR(x) \ - PSEUDO_NOERROR(x,x) - -#define RSYSCALL(x) \ - PSEUDO(x,x) - -#define WSYSCALL(weak,strong) \ - WEAK_ALIAS(weak,strong); \ - PSEUDO(strong,weak) - - .globl CERROR diff --git a/lib/libc/arch/x86_64/gdtoa/Makefile.inc b/lib/libc/arch/x86_64/gdtoa/Makefile.inc deleted file mode 100644 index ce2f4854d..000000000 --- a/lib/libc/arch/x86_64/gdtoa/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/03/15 17:35:18 kleink Exp $ - -SRCS+= strtof.c strtold_px.c -SRCS+= strtopx.c diff --git a/lib/libc/arch/x86_64/gdtoa/arith.h b/lib/libc/arch/x86_64/gdtoa/arith.h deleted file mode 100644 index 1513f1fd2..000000000 --- a/lib/libc/arch/x86_64/gdtoa/arith.h +++ /dev/null @@ -1,3 +0,0 @@ -/* $NetBSD: arith.h,v 1.1 2006/01/25 15:33:28 kleink Exp $ */ - -#define IEEE_LITTLE_ENDIAN diff --git a/lib/libc/arch/x86_64/gdtoa/gd_qnan.h b/lib/libc/arch/x86_64/gdtoa/gd_qnan.h deleted file mode 100644 index d702c6792..000000000 --- a/lib/libc/arch/x86_64/gdtoa/gd_qnan.h +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: gd_qnan.h,v 1.3 2011/06/05 14:43:13 christos Exp $ */ - -#define f_QNAN 0x7fc00000 -#define d_QNAN0 0x0 -#define d_QNAN1 0x7ff80000 -#define ld_QNAN0 0x0 -#define ld_QNAN1 0xc0000000 -#define ld_QNAN2 0x7fff -#define ld_QNAN3 0x0 -#define ldus_QNAN0 0x0 -#define ldus_QNAN1 0x0 -#define ldus_QNAN2 0x0 -#define ldus_QNAN3 0xc000 -#define ldus_QNAN4 0x7fff -/* 6 bytes of tail padding follow, per AMD64 ABI */ diff --git a/lib/libc/arch/x86_64/gen/Makefile.inc b/lib/libc/arch/x86_64/gen/Makefile.inc deleted file mode 100644 index 1a1249a49..000000000 --- a/lib/libc/arch/x86_64/gen/Makefile.inc +++ /dev/null @@ -1,37 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.18 2015/07/15 14:27:49 pooka Exp $ - -# objects built from assembler sources (need lint stubs) -SRCS+= alloca.S byte_swap_2.S byte_swap_4.S byte_swap_8.S fabs.S \ - flt_rounds.S fpgetmask.S fpgetround.S fpgetsticky.S \ - fpsetmask.S fpsetround.S fpsetsticky.S fpgetprec.S \ - fpsetprec.S - -SRCS+= __setjmp14.S -SRCS+= _setjmp.S -SRCS+= __sigsetjmp14.S - -.if ${RUMPRUN} != "yes" -SRCS+= resumecontext.S swapcontext.S -SRCS+= _lwp.c makecontext.c -.endif - -# Common ieee754 constants and functions -SRCS+= infinityf_ieee754.c infinity_ieee754.c -SRCS+= fpclassifyf_ieee754.c fpclassifyd_ieee754.c -SRCS+= isfinitef_ieee754.c isfinited_ieee754.c -SRCS+= isinff_ieee754.c isinfd_ieee754.c -SRCS+= isnanf_ieee754.c isnand_ieee754.c -SRCS+= signbitf_ieee754.c signbitd_ieee754.c - -SRCS+= nanf.c infinityl.c -SRCS+= fpclassifyl.c isfinitel.c isinfl.c isnanl.c signbitl.c - -LSRCS.x86_64.gen=\ - Lint__setjmp.c Lint_alloca.c Lint_bswap16.c Lint_bswap32.c \ - Lint_bswap64.c Lint_fabs.c \ - Lint___setjmp14.c Lint___sigsetjmp14.c Lint_flt_rounds.c \ - Lint_fpgetmask.c Lint_fpgetround.c Lint_fpgetsticky.c \ - Lint_fpsetmask.c Lint_fpsetround.c Lint_fpsetsticky.c -LSRCS+= ${LSRCS.x86_64.gen} -DPSRCS+= ${LSRCS.x86_64.gen} -CLEANFILES+= ${LSRCS.x86_64.gen} diff --git a/lib/libc/arch/x86_64/gen/__setjmp14.S b/lib/libc/arch/x86_64/gen/__setjmp14.S deleted file mode 100644 index 5a1f3220a..000000000 --- a/lib/libc/arch/x86_64/gen/__setjmp14.S +++ /dev/null @@ -1,110 +0,0 @@ -/* $NetBSD: __setjmp14.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: __setjmp14.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__setjmp14) - movq (%rsp),%r11 - movq %rbx,(_JB_RBX * 8)(%rdi) - movq %rbp,(_JB_RBP * 8)(%rdi) - movq %r12,(_JB_R12 * 8)(%rdi) - movq %r13,(_JB_R13 * 8)(%rdi) - movq %r14,(_JB_R14 * 8)(%rdi) - movq %r15,(_JB_R15 * 8)(%rdi) - movq %rsp,(_JB_RSP * 8)(%rdi) - movq %r11,(_JB_PC * 8)(%rdi) - - leaq (_JB_SIGMASK * 8)(%rdi),%rdx - xorl %edi,%edi - xorq %rsi,%rsi - -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif -2: xorl %eax,%eax - ret -END(__setjmp14) - -ENTRY(__longjmp14) - movq %rdi,%r12 - movl %esi,%r8d - - leaq (_JB_SIGMASK * 8)(%rdi),%rsi - movl $3,%edi /* SIG_SETMASK */ - xorq %rdx,%rdx - - pushq %r8 -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif - popq %r8 - movq (_JB_RBX * 8)(%r12),%rbx - movq (_JB_RBP * 8)(%r12),%rbp - movq (_JB_R13 * 8)(%r12),%r13 - movq (_JB_R14 * 8)(%r12),%r14 - movq (_JB_R15 * 8)(%r12),%r15 - movq (_JB_RSP * 8)(%r12),%rsp - movq (_JB_PC * 8)(%r12),%r11 - movq (_JB_R12 * 8)(%r12),%r12 - - movl %r8d,%eax - testl %eax,%eax - jnz 1f - incl %eax -1: movq %r11,0(%rsp) - ret -END(__longjmp14) diff --git a/lib/libc/arch/x86_64/gen/__sigsetjmp14.S b/lib/libc/arch/x86_64/gen/__sigsetjmp14.S deleted file mode 100644 index 688bf3f39..000000000 --- a/lib/libc/arch/x86_64/gen/__sigsetjmp14.S +++ /dev/null @@ -1,114 +0,0 @@ -/* $NetBSD: __sigsetjmp14.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: __sigsetjmp14.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(__sigsetjmp14) - movq (%rsp),%r11 - movq %rbx,(_JB_RBX * 8)(%rdi) - movq %rbp,(_JB_RBP * 8)(%rdi) - movq %r12,(_JB_R12 * 8)(%rdi) - movq %r13,(_JB_R13 * 8)(%rdi) - movq %r14,(_JB_R14 * 8)(%rdi) - movq %r15,(_JB_R15 * 8)(%rdi) - movq %rsp,(_JB_RSP * 8)(%rdi) - movq %r11,(_JB_PC * 8)(%rdi) - - movq %rsi,(_JB_SIGFLAG * 8)(%rdi) - testl %esi,%esi - jz 2f - - leaq (_JB_SIGMASK * 8)(%rdi),%rdx - xorl %edi,%edi - xorq %rsi,%rsi - -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif -2: xorl %eax,%eax - ret -END(__sigsetjmp14) - -ENTRY(__siglongjmp14) - movq %rdi,%r12 - pushq %rsi - cmpl $0, (_JB_SIGFLAG * 8)(%rdi) - - jz 2f - leaq (_JB_SIGMASK * 8)(%rdi),%rsi - movl $3,%edi /* SIG_SETMASK */ - xorq %rdx,%rdx - -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__sigprocmask14)) -#else - call _C_LABEL(__sigprocmask14) -#endif -2: popq %rax - movq (_JB_RBX * 8)(%r12),%rbx - movq (_JB_RBP * 8)(%r12),%rbp - movq (_JB_R13 * 8)(%r12),%r13 - movq (_JB_R14 * 8)(%r12),%r14 - movq (_JB_R15 * 8)(%r12),%r15 - movq (_JB_RSP * 8)(%r12),%rsp - movq (_JB_PC * 8)(%r12),%r11 - movq (_JB_R12 * 8)(%r12),%r12 - - testl %eax,%eax - jnz 1f - incl %eax -1: movq %r11,0(%rsp) - ret -END(__siglongjmp14) diff --git a/lib/libc/arch/x86_64/gen/_lwp.c b/lib/libc/arch/x86_64/gen/_lwp.c deleted file mode 100644 index b8c9f9b97..000000000 --- a/lib/libc/arch/x86_64/gen/_lwp.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nathan J. Williams. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _lwp.c,v 1.7 2011/02/24 04:28:43 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -void -_lwp_makecontext(ucontext_t *u, void (*start)(void *), - void *arg, void *private, caddr_t stack_base, size_t stack_size) -{ - __greg_t *gr = u->uc_mcontext.__gregs; - void **sp; - - getcontext(u); - u->uc_link = NULL; - - u->uc_stack.ss_sp = stack_base; - u->uc_stack.ss_size = stack_size; - - /* LINTED uintptr_t is safe */ - gr[_REG_RIP] = (uintptr_t)start; - - sp = (void **) (((uintptr_t)(stack_base + stack_size) & ~15)); - - /* LINTED __greg_t is safe */ - gr[_REG_RDI] = (__greg_t)arg; - *--sp = (void *) _lwp_exit; - - /* LINTED uintptr_t is safe */ - gr[_REG_URSP] = (uintptr_t) sp; - - u->uc_mcontext._mc_tlsbase = (uintptr_t)private; - u->uc_flags |= _UC_TLSBASE; -} diff --git a/lib/libc/arch/x86_64/gen/_setjmp.S b/lib/libc/arch/x86_64/gen/_setjmp.S deleted file mode 100644 index ecf84ee6c..000000000 --- a/lib/libc/arch/x86_64/gen/_setjmp.S +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: _setjmp.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: _setjmp.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from the last call to - * _setjmp(a) - * by restoring registers from the stack. - * The previous signal state is NOT restored. - */ - -ENTRY(_setjmp) - movq (%rsp),%r11 - movq %rbx,(_JB_RBX * 8)(%rdi) - movq %rbp,(_JB_RBP * 8)(%rdi) - movq %r12,(_JB_R12 * 8)(%rdi) - movq %r13,(_JB_R13 * 8)(%rdi) - movq %r14,(_JB_R14 * 8)(%rdi) - movq %r15,(_JB_R15 * 8)(%rdi) - movq %rsp,(_JB_RSP * 8)(%rdi) - movq %r11,(_JB_PC * 8)(%rdi) - - xorl %eax,%eax - ret -END(_setjmp) - -ENTRY(_longjmp) - movq (_JB_RBX * 8)(%rdi),%rbx - movq (_JB_RBP * 8)(%rdi),%rbp - movq (_JB_R12 * 8)(%rdi),%r12 - movq (_JB_R13 * 8)(%rdi),%r13 - movq (_JB_R14 * 8)(%rdi),%r14 - movq (_JB_R15 * 8)(%rdi),%r15 - movq (_JB_RSP * 8)(%rdi),%rsp - movq (_JB_PC * 8)(%rdi),%r11 - - movl %esi,%eax - testl %eax,%eax - jnz 1f - incl %eax -1: movq %r11,0(%rsp) - ret -END(_longjmp) diff --git a/lib/libc/arch/x86_64/gen/alloca.S b/lib/libc/arch/x86_64/gen/alloca.S deleted file mode 100644 index 9c8498d07..000000000 --- a/lib/libc/arch/x86_64/gen/alloca.S +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: alloca.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $ */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: alloca.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -ENTRY(alloca) - popq %rdx - movq %rsp,%rcx - addq $15,%rdi /* round up to 16 bytes */ - andq $~15,%rdi - subq %rdi,%rsp - movq %rsp,%rax - jmp *%rdx -END(alloca) diff --git a/lib/libc/arch/x86_64/gen/fabs.S b/lib/libc/arch/x86_64/gen/fabs.S deleted file mode 100644 index e0d6568ff..000000000 --- a/lib/libc/arch/x86_64/gen/fabs.S +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: fabs.S,v 1.4 2014/05/22 15:01:56 uebayasi Exp $ */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: fabs.S,v 1.4 2014/05/22 15:01:56 uebayasi Exp $") -#endif - - .section .rodata - .align 8 -__signmask: - .long 0xffffffff - .long 0x7fffffff - -ENTRY(fabs) - movsd __signmask(%rip),%xmm1 - andpd %xmm1,%xmm0 - ret -END(fabs) diff --git a/lib/libc/arch/x86_64/gen/flt_rounds.S b/lib/libc/arch/x86_64/gen/flt_rounds.S deleted file mode 100644 index 3a09dd4ce..000000000 --- a/lib/libc/arch/x86_64/gen/flt_rounds.S +++ /dev/null @@ -1,22 +0,0 @@ -/* $NetBSD: flt_rounds.S,v 1.7 2014/05/22 15:01:56 uebayasi Exp $ */ - -#include - -/* - * 00 0 round to zero - * 01 1 round to nearest - * 10 2 round to positive infinity - * 11 3 round to negative infinity - */ - .text - _ALIGN_TEXT -ENTRY(__flt_rounds) - fnstcw -4(%rsp) - movl -4(%rsp), %ecx - shrl $9, %ecx - andl $6, %ecx - movl $0x2d, %eax /* 0x2d = 00.10.11.01 */ - sarl %cl, %eax /* 0,1,2,3 -> 1,3,2,0 */ - andl $3, %eax - ret -END(__flt_rounds) diff --git a/lib/libc/arch/x86_64/gen/fpclassifyl.c b/lib/libc/arch/x86_64/gen/fpclassifyl.c deleted file mode 100644 index edaf28350..000000000 --- a/lib/libc/arch/x86_64/gen/fpclassifyl.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: fpclassifyl.c,v 1.4 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyl.c,v 1.4 2008/04/28 20:22:58 martin Exp $"); -#endif - -#include -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__fpclassifyl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - _DIAGASSERT(u.extu_ext.ext_exp == 0 || - (u.extu_ext.ext_frach & 0x80000000)); - - if (u.extu_ext.ext_exp == 0) { - if ((u.extu_ext.ext_frach & 0x7fffffff) == 0 && - u.extu_ext.ext_fracl == 0) - return FP_ZERO; - else - return FP_SUBNORMAL; - } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) { - if ((u.extu_ext.ext_frach & 0x7fffffff) == 0 && - u.extu_ext.ext_fracl == 0) - return FP_INFINITE; - else - return FP_NAN; - } - - return FP_NORMAL; -} diff --git a/lib/libc/arch/x86_64/gen/fpgetmask.S b/lib/libc/arch/x86_64/gen/fpgetmask.S deleted file mode 100644 index 9d09e684d..000000000 --- a/lib/libc/arch/x86_64/gen/fpgetmask.S +++ /dev/null @@ -1,31 +0,0 @@ -/* $NetBSD: fpgetmask.S,v 1.4 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by J.T. Conklin, Apr 4, 1995 - * Public domain. - */ - -#include - -/* - * XXX only read x87 control word here. If an application only - * uses the fp* interface to manipulate FP bits, it should - * always remain in sync with the SSE mxcsr register. - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetmask, _fpgetmask) -ENTRY(_fpgetmask) -#else -ENTRY(fpgetmask) -#endif - fnstcw -4(%rsp) - movl -4(%rsp),%eax - notl %eax - andl $63,%eax - ret -#ifdef WEAK_ALIAS -END(_fpgetmask) -#else -END(fpgetmask) -#endif diff --git a/lib/libc/arch/x86_64/gen/fpgetprec.S b/lib/libc/arch/x86_64/gen/fpgetprec.S deleted file mode 100644 index e91702029..000000000 --- a/lib/libc/arch/x86_64/gen/fpgetprec.S +++ /dev/null @@ -1,30 +0,0 @@ -/* $NetBSD: fpgetprec.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by J.T. Conklin, Apr 4, 1995 - * Public domain. - */ - -#include - -/* - * XXX store only x87 state. If an application only uses the fp* - * interface, this should be in sync with the SSE mxcsr register. - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetprec, _fpgetprec) -ENTRY(_fpgetprec) -#else -ENTRY(fpgetprec) -#endif - fnstcw -4(%rsp) - movl -4(%rsp),%eax - rorl $8,%eax - andl $3,%eax - ret -#ifdef WEAK_ALIAS -END(_fpgetprec) -#else -END(fpgetprec) -#endif diff --git a/lib/libc/arch/x86_64/gen/fpgetround.S b/lib/libc/arch/x86_64/gen/fpgetround.S deleted file mode 100644 index d01d3390c..000000000 --- a/lib/libc/arch/x86_64/gen/fpgetround.S +++ /dev/null @@ -1,29 +0,0 @@ -/* $NetBSD: fpgetround.S,v 1.5 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by J.T. Conklin, Apr 4, 1995 - * Public domain. - */ - -#include - -/* - * XXX load only x87 state. If an application only uses the fp* - * interface, this should be in sync with the SSE mxcsr register. - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetround, _fpgetround) -ENTRY(_fpgetround) -#else -ENTRY(fpgetround) -#endif - fnstcw -4(%rsp) - movl -4(%rsp), %eax - andl $0x00000c00, %eax - ret -#ifdef WEAK_ALIAS -END(_fpgetround) -#else -END(fpgetround) -#endif diff --git a/lib/libc/arch/x86_64/gen/fpgetsticky.S b/lib/libc/arch/x86_64/gen/fpgetsticky.S deleted file mode 100644 index e3beadd57..000000000 --- a/lib/libc/arch/x86_64/gen/fpgetsticky.S +++ /dev/null @@ -1,32 +0,0 @@ -/* $NetBSD: fpgetsticky.S,v 1.4 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by Frank van der Linden at Wasabi Systems for NetBSD. - * Public domain. - * - */ - -#include - -/* - * XXX read both the x87 and SSE status words here, and OR - * them to get a complete picture of exceptions. - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpgetsticky, _fpgetsticky) -ENTRY(_fpgetsticky) -#else -ENTRY(fpgetsticky) -#endif - fnstsw -4(%rsp) - stmxcsr -8(%rsp) - movl -4(%rsp),%eax - orl -8(%rsp),%eax - andl $63,%eax - ret -#ifdef WEAK_ALIAS -END(_fpgetsticky) -#else -END(fpgetsticky) -#endif diff --git a/lib/libc/arch/x86_64/gen/fpsetmask.S b/lib/libc/arch/x86_64/gen/fpsetmask.S deleted file mode 100644 index 051fd5a40..000000000 --- a/lib/libc/arch/x86_64/gen/fpsetmask.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: fpsetmask.S,v 1.6 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by Frank van der Linden at Wasabi Systems for NetBSD. - * Public domain. - */ - -#include - -/* - * XXX set both the x87 control word and the SSE mxcsr register. - * Applications should only set exception and round flags - * via the fp*() interface, otherwise the status words - * will get our of sync. - */ - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetmask, _fpsetmask) -ENTRY(_fpsetmask) -#else -ENTRY(fpsetmask) -#endif - notl %edi - andl $0x0000003f,%edi - - fnstcw -4(%rsp) - movl -4(%rsp), %edx - movl %edx, %eax - andl $0xffffffc0, %edx - orl %edi, %edx - movl %edx,-4(%rsp) - fldcw -4(%rsp) - - stmxcsr -4(%rsp) - movl -4(%rsp), %edx - andl $0xffffe07f, %edx - sall $7, %edi - orl %edi, %edx - movl %edx,-4(%rsp) - ldmxcsr -4(%rsp) - - notl %eax - andl $0x0000003f, %eax - ret -#ifdef WEAK_ALIAS -END(_fpsetmask) -#else -END(fpsetmask) -#endif diff --git a/lib/libc/arch/x86_64/gen/fpsetprec.S b/lib/libc/arch/x86_64/gen/fpsetprec.S deleted file mode 100644 index 3beb0f99f..000000000 --- a/lib/libc/arch/x86_64/gen/fpsetprec.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: fpsetprec.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by Frank van der Linden at Wasabi Systems for NetBSD. - * Public domain. - */ - -#include - -/* - * XXX set both the x87 control word and the SSE mxcsr register. - * Applications should only set exception and round flags - * via the fp*() interface, otherwise the status words - * will get our of sync. - */ - - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetprec, _fpsetprec) -ENTRY(_fpsetprec) -#else -ENTRY(fpsetprec) -#endif - fnstcw -4(%rsp) - - andl $3,%edi - - movl -4(%rsp),%edx - rorl $8,%edx - movl %edx,%eax - andl $3,%eax - - andl $~3,%edx - orl %edi,%edx - roll $8,%edx - movl %edx,-4(%rsp) - - fldcw -4(%rsp) - ret -#ifdef WEAK_ALIAS -END(_fpsetprec) -#else -END(fpsetprec) -#endif diff --git a/lib/libc/arch/x86_64/gen/fpsetround.S b/lib/libc/arch/x86_64/gen/fpsetround.S deleted file mode 100644 index 16c148598..000000000 --- a/lib/libc/arch/x86_64/gen/fpsetround.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: fpsetround.S,v 1.5 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by Frank van der Linden at Wasabi Systems for NetBSD. - * Public domain. - */ - -#include - -/* - * XXX set both the x87 control word and the SSE mxcsr register. - * Applications should only set exception and round flags - * via the fp*() interface, otherwise the status words - * will get our of sync. - */ - - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetround, _fpsetround) -ENTRY(_fpsetround) -#else -ENTRY(fpsetround) -#endif - - fnstcw -4(%rsp) - movl -4(%rsp), %edx - movl %edx, %eax - andl $0x00000c00, %eax - andl $0xfffff3ff, %edx - orl %edi, %edx - movl %edx, -4(%rsp) - fldcw -4(%rsp) - - stmxcsr -4(%rsp) - movl -4(%rsp), %edx - andl $0xffff9fff, %edx - sall $3, %edi - orl %edi,%edx - movl %edx,-4(%rsp) - ldmxcsr -4(%rsp) - - ret -#ifdef WEAK_ALIAS -END(_fpsetround) -#else -END(fpsetround) -#endif diff --git a/lib/libc/arch/x86_64/gen/fpsetsticky.S b/lib/libc/arch/x86_64/gen/fpsetsticky.S deleted file mode 100644 index 25a73a0e8..000000000 --- a/lib/libc/arch/x86_64/gen/fpsetsticky.S +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: fpsetsticky.S,v 1.6 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by Frank van der Linden at Wasabi Systems for NetBSD - * Public domain. - */ - -#include - -/* - * XXX set both the x87 status word and the SSE mxcsr register. - * Applications should only set exception and round flags - * via the fp*() interface, otherwise the status words - * will get our of sync. - */ - - -#ifdef WEAK_ALIAS -WEAK_ALIAS(fpsetsticky, _fpsetsticky) -ENTRY(_fpsetsticky) -#else -ENTRY(fpsetsticky) -#endif - fnstenv -28(%rsp) - stmxcsr -32(%rsp) - - andl $63,%edi - - movl -24(%rsp),%eax - movl %eax,%edx - andb $0xc0,%dl - - orl %edi,%edx - movl %edx,-24(%rsp) - - movl -32(%rsp),%edx - orl %edx,%eax - andl $63,%eax - andb $0xc0,%dl - orl %edi,%edx - movl %edx,-32(%rsp) - - ldmxcsr -32(%rsp) - fldenv -28(%rsp) - ret -#ifdef WEAK_ALIAS -END(_fpsetsticky) -#else -END(fpsetsticky) -#endif diff --git a/lib/libc/arch/x86_64/gen/infinityl.c b/lib/libc/arch/x86_64/gen/infinityl.c deleted file mode 100644 index 521f10186..000000000 --- a/lib/libc/arch/x86_64/gen/infinityl.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:29 drochner Exp $ */ - -/* - * IEEE-compatible infinityl.c for little-endian 80-bit format -- public domain. - * Note that the representation includes 48 bits of tail padding per amd64 ABI. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinityl.c,v 1.4 2011/06/06 17:02:29 drochner Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include - -const union __long_double_u __infinityl = - { { 0, 0, 0, 0, 0, 0, 0, 0x80, 0xff, 0x7f, 0, 0, 0, 0, 0, 0 } }; diff --git a/lib/libc/arch/x86_64/gen/isfinitel.c b/lib/libc/arch/x86_64/gen/isfinitel.c deleted file mode 100644 index d0f960a0f..000000000 --- a/lib/libc/arch/x86_64/gen/isfinitel.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: isfinitel.c,v 1.3 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinitel.c,v 1.3 2008/04/28 20:22:58 martin Exp $"); -#endif - -#include -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__isfinitel(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - _DIAGASSERT(u.extu_ext.ext_exp == 0 || - (u.extu_ext.ext_frach & 0x80000000)); - - if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) - return 0; - - return 1; -} diff --git a/lib/libc/arch/x86_64/gen/isinfl.c b/lib/libc/arch/x86_64/gen/isinfl.c deleted file mode 100644 index 330451122..000000000 --- a/lib/libc/arch/x86_64/gen/isinfl.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: isinfl.c,v 1.6 2007/02/02 23:19:25 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinfl.c,v 1.6 2007/02/02 23:19:25 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.3 isinf - test for infinity - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__isinfl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - u.extu_ext.ext_frach == 0x80000000 && u.extu_ext.ext_fracl == 0); -} diff --git a/lib/libc/arch/x86_64/gen/isnanl.c b/lib/libc/arch/x86_64/gen/isnanl.c deleted file mode 100644 index 045798c8d..000000000 --- a/lib/libc/arch/x86_64/gen/isnanl.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnanl.c,v 1.8 2011/06/05 14:43:13 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.4 isnan - test for a NaN - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__isnanl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_exp == EXT_EXP_INFNAN && - (u.extu_ext.ext_frach & 0x80000000) != 0 && - (u.extu_ext.ext_frach != 0x80000000 || u.extu_ext.ext_fracl != 0)); -} diff --git a/lib/libc/arch/x86_64/gen/makecontext.c b/lib/libc/arch/x86_64/gen/makecontext.c deleted file mode 100644 index e68976105..000000000 --- a/lib/libc/arch/x86_64/gen/makecontext.c +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: makecontext.c,v 1.4 2009/07/30 20:57:17 dsl Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * Modified from the i386 version for x86_64 by fvdl@wasabisystems.com. - * - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: makecontext.c,v 1.4 2009/07/30 20:57:17 dsl Exp $"); -#endif - -#include -#include -#include -#include "extern.h" - -#include - -void -makecontext(ucontext_t *ucp, void (*func)(void), int argc, ...) -{ - __greg_t *gr = ucp->uc_mcontext.__gregs; - uintptr_t *sp; - va_list ap; - int stackargs, i; - - stackargs = argc - 6; - - /* LINTED __greg_t is safe */ - gr[_REG_RIP] = (__greg_t)func; - - /* LINTED uintptr_t is safe */ - sp = (uintptr_t *) - ((uintptr_t)ucp->uc_stack.ss_sp + ucp->uc_stack.ss_size); - - /* LINTED uintptr_t is safe */ - sp = (uintptr_t *)(((uintptr_t)sp & ~15)); - sp--; - if (stackargs > 0) - sp -= stackargs; - /* LINTED __greg_t is safe */ - gr[_REG_RSP] = (__greg_t)sp; - gr[_REG_RBP] = (__greg_t)0; /* Wipe out frame pointer. */ - - /* Put return address on top of stack. */ - /* LINTED uintptr_t is safe */ - *sp++ = (uintptr_t)_resumecontext; - - /* - * Construct argument list. - * The registers used to pass the first 6 arguments - * (rdi, rsi, rdx, rcx, r8, r9) are the first 6 in gregs, - * in that order, so those arguments can just be copied to - * the gregs array. - */ - va_start(ap, argc); - for (i = 0; i < 6 && argc > 0; i++) { - argc--; - /* LINTED __greg_t is safe */ - gr[i] = va_arg(ap, __greg_t); - } - - while (stackargs-- > 0) { - /* LINTED uintptr_t is safe */ - *sp++ = va_arg(ap, uintptr_t); - } - - va_end(ap); -} diff --git a/lib/libc/arch/x86_64/gen/nanf.c b/lib/libc/arch/x86_64/gen/nanf.c deleted file mode 100644 index ffc388eba..000000000 --- a/lib/libc/arch/x86_64/gen/nanf.c +++ /dev/null @@ -1,15 +0,0 @@ -/* $NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nanf.c,v 1.4 2009/02/22 01:34:02 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* bytes for quiet NaN (IEEE single precision) */ -const union __float_u __nanf = - { { 0, 0, 0xc0, 0x7f } }; - -__warn_references(__nanf, "warning: defines NAN incorrectly for your compiler.") diff --git a/lib/libc/arch/x86_64/gen/resumecontext.S b/lib/libc/arch/x86_64/gen/resumecontext.S deleted file mode 100644 index fe87fcaa5..000000000 --- a/lib/libc/arch/x86_64/gen/resumecontext.S +++ /dev/null @@ -1,80 +0,0 @@ -/* $NetBSD: resumecontext.S,v 1.6 2014/05/22 15:01:56 uebayasi Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - * Modified for x86-64 by fvdl@wasabisystems.com - */ - -#include -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: resumecontext.S,v 1.6 2014/05/22 15:01:56 uebayasi Exp $") -#endif /* LIBC_SCCS && !lint */ - -/* - * This assembly-language implementation differs from the (obvious) - * C-language implementation only in not clobbering the previous - * function's return address (us), which is the point of the exercise. - */ - -NENTRY(_resumecontext) /* profiling prologue would clobber TOS */ - leaq -(8 + 784)(%rsp),%rdi /* retaddr + sizeof (ucontext_t) */ - andq $~15,%rdi /* align on _UC_UCONTEXT_ALIGN */ - movq %rdi,%rsp -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(_getcontext)) -#else - call _C_LABEL(_getcontext) -#endif - movq 8(%rsp),%rdi /* uc_link */ - testq %rdi,%rdi /* link end? */ - jnz 9f - - /* normal exit */ -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(exit)) -#else - call _C_LABEL(exit) -#endif - -9: -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(setcontext)) -#else - call _C_LABEL(setcontext) -#endif - /* NOTREACHED */ - - /* something is wrong, pull the brake */ - movq $-1,%rdi - movq $SYS_exit,%rax - syscall - /* NOTREACHED */ -END(_resumecontext) diff --git a/lib/libc/arch/x86_64/gen/signbitl.c b/lib/libc/arch/x86_64/gen/signbitl.c deleted file mode 100644 index 7f9f2edc1..000000000 --- a/lib/libc/arch/x86_64/gen/signbitl.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitl.c,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: signbitl.c,v 1.2 2008/04/28 20:22:58 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * IEEE 754 compatible 80-bit extended-precision Intel 386 version - */ -int -__signbitl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_sign == 1); -} diff --git a/lib/libc/arch/x86_64/gen/swapcontext.S b/lib/libc/arch/x86_64/gen/swapcontext.S deleted file mode 100644 index b2b87f7ca..000000000 --- a/lib/libc/arch/x86_64/gen/swapcontext.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: swapcontext.S,v 1.6 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Copyright (c) 2003 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: swapcontext.S,v 1.6 2014/05/22 15:01:56 uebayasi Exp $") -#endif /* LIBC_SCCS && !lint */ - -/* - * 56 == offsetof(ucontext_t, uc_mcontext) - * 21 == _REG_RIP - * 24 == _REG_URSP - */ - -ENTRY(swapcontext) - pushq %rdi /* preserve oucp */ - pushq %rsi /* preserve ucp */ -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(_getcontext)) -#else - call _C_LABEL(_getcontext) -#endif - popq %rsi - popq %rdi - testl %eax,%eax - jnz 2f - movq 0(%rsp),%r11 - movq %r11,(56 + 21 * 8)(%rdi) - leaq 8(%rsp),%r11 - movq %r11,(56 + 24 * 8)(%rdi) - movq %rsi,%rdi -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(setcontext)) -#else - call _C_LABEL(setcontext) -#endif -2: - ret -END(swapcontext) diff --git a/lib/libc/arch/x86_64/net/Makefile.inc b/lib/libc/arch/x86_64/net/Makefile.inc deleted file mode 100644 index 6c0eeab3b..000000000 --- a/lib/libc/arch/x86_64/net/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2009/12/06 07:12:18 uebayasi Exp $ - -# objects built from assembler sources (need lint stubs) -# hton* and nto* functions provided by ../gen/byte_swap_*.S -SRCS+= - -LSRCS.x86_64.net=Lint_htonl.c Lint_htons.c Lint_ntohl.c Lint_ntohs.c -LSRCS+= ${LSRCS.x86_64.net} -DPSRCS+= ${LSRCS.x86_64.net} -CLEANFILES+= ${LSRCS.x86_64.net} diff --git a/lib/libc/arch/x86_64/stdlib/Makefile.inc b/lib/libc/arch/x86_64/stdlib/Makefile.inc deleted file mode 100644 index 8737f1b11..000000000 --- a/lib/libc/arch/x86_64/stdlib/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 2009/08/11 17:30:43 dsl Exp $ - -# objects built from assembler sources -SRCS+= abs.S div.S labs.S ldiv.S -NO_SRCS+= llabs.S imaxabs.S imaxdiv.S diff --git a/lib/libc/arch/x86_64/stdlib/abs.S b/lib/libc/arch/x86_64/stdlib/abs.S deleted file mode 100644 index 959a0c741..000000000 --- a/lib/libc/arch/x86_64/stdlib/abs.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: abs.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)abs.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: abs.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -ENTRY(abs) - movl %edi,%eax - testl %eax,%eax - jns 1f - negl %eax -1: ret -END(abs) diff --git a/lib/libc/arch/x86_64/stdlib/div.S b/lib/libc/arch/x86_64/stdlib/div.S deleted file mode 100644 index 3933df53b..000000000 --- a/lib/libc/arch/x86_64/stdlib/div.S +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: div.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $ */ -/* - * Written by Frank van der Linden (fvdl@wasabisystems.com) - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) -RCSID("$NetBSD: div.S,v 1.2 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -ENTRY(div) - movl %edi, %eax - cltd - idivl %esi - salq $32, %rdx - orq %rdx,%rax - ret -END(div) diff --git a/lib/libc/arch/x86_64/stdlib/labs.S b/lib/libc/arch/x86_64/stdlib/labs.S deleted file mode 100644 index 42b23f571..000000000 --- a/lib/libc/arch/x86_64/stdlib/labs.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: labs.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by Frank van der Linden (fvdl@wasabisystems.com) - * Public Domain. - */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: labs.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(imaxabs, _llabs) -WEAK_ALIAS(llabs, _llabs) -WEAK_ALIAS(labs, _labs) -#endif - -#ifdef WEAK_ALIAS -ENTRY(_llabs) -ENTRY(_labs) -#else -ENTRY(llabs) -ENTRY(labs) -#endif - movq %rdi,%rax - testq %rax,%rax - jns 1f - negq %rax -1: ret -#ifdef WEAK_ALIAS -END(_llabs) -END(_labs) -#else -END(llabs) -END(labs) -#endif diff --git a/lib/libc/arch/x86_64/stdlib/ldiv.S b/lib/libc/arch/x86_64/stdlib/ldiv.S deleted file mode 100644 index 4ae6e0f77..000000000 --- a/lib/libc/arch/x86_64/stdlib/ldiv.S +++ /dev/null @@ -1,31 +0,0 @@ -/* $NetBSD: ldiv.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $ */ - -/* - * Written by gcc 3.0. - * Copy/pasted by Frank van der Linden (fvdl@wasabisystems.com) - */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: ldiv.S,v 1.3 2014/05/22 15:01:56 uebayasi Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(ldiv, _ldiv) -#endif - -#ifdef WEAK_ALIAS -ENTRY(_ldiv) -#else -ENTRY(ldiv) -#endif - movq %rdi, %rax - cqto - idivq %rsi - ret -#ifdef WEAK_ALIAS -END(_ldiv) -#else -END(ldiv) -#endif diff --git a/lib/libc/arch/x86_64/string/Makefile.inc b/lib/libc/arch/x86_64/string/Makefile.inc deleted file mode 100644 index 22831f487..000000000 --- a/lib/libc/arch/x86_64/string/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 2013/11/24 03:50:17 christos Exp $ - -# objects built from assembler sources -SRCS+= bcmp.S bcopy.S ffs.S memchr.S memcmp.S \ - memcpy.S memmove.S memset.S strcat.S strchr.S \ - strcmp.S strcpy.S strlen.S strncmp.S strrchr.S swab.S -NO_SRCS+= bzero.c diff --git a/lib/libc/arch/x86_64/string/strncmp.S b/lib/libc/arch/x86_64/string/strncmp.S deleted file mode 100644 index 9156af9a2..000000000 --- a/lib/libc/arch/x86_64/string/strncmp.S +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: strncmp.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $") -#endif - -/* - * NOTE: I've unrolled the loop eight times: large enough to make a - * significant difference, and small enough not to totally trash the - * cache. - */ - -ENTRY(strncmp) - testq %rdx,%rdx - jmp L2 /* Jump into the loop! */ - -L1: incq %rdi - incq %rsi - decq %rdx -L2: jz L4 /* strings are equal */ - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - jne L3 - - incq %rdi - incq %rsi - decq %rdx - jz L4 - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - jne L3 - - incq %rdi - incq %rsi - decq %rdx - jz L4 - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - jne L3 - - incq %rdi - incq %rsi - decq %rdx - jz L4 - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - jne L3 - - incq %rdi - incq %rsi - decq %rdx - jz L4 - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - jne L3 - - incq %rdi - incq %rsi - decq %rdx - jz L4 - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - jne L3 - - incq %rdi - incq %rsi - decq %rdx - jz L4 - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - jne L3 - - incq %rdi - incq %rsi - decq %rdx - jz L4 - movb (%rdi),%al - testb %al,%al - jz L3 - cmpb %al,(%rsi) - je L1 - -L3: movzbl (%rdi),%eax /* unsigned comparison */ - movzbl (%rsi),%ecx - subl %ecx,%eax - ret -L4: xorl %eax,%eax - ret -END(strncmp) diff --git a/lib/libc/arch/x86_64/string/swab.S b/lib/libc/arch/x86_64/string/swab.S deleted file mode 100644 index 636cb4328..000000000 --- a/lib/libc/arch/x86_64/string/swab.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: swab.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $") -#endif - -#define LOAD_SWAP_STORE_WORD \ - lodsw ; \ - xchgb %al,%ah ; \ - stosw - -ENTRY(swab) - xchgq %rdi,%rsi - cld # set direction forward - - shrq $1,%rdx - testq $7,%rdx # copy first group of 1 to 7 words - jz L2 # while swapping alternate bytes. -L1: lodsw - rorw $8,%ax - stosw - decq %rdx - testq $7,%rdx - jnz L1 - -L2: shrq $3,%rdx # copy remainder 8 words at a time - jz L4 # while swapping alternate bytes. -L3: - LOAD_SWAP_STORE_WORD - LOAD_SWAP_STORE_WORD - LOAD_SWAP_STORE_WORD - LOAD_SWAP_STORE_WORD - LOAD_SWAP_STORE_WORD - LOAD_SWAP_STORE_WORD - LOAD_SWAP_STORE_WORD - LOAD_SWAP_STORE_WORD - - decq %rdx - jnz L3 -L4: - ret -END(swab) diff --git a/lib/libc/arch/x86_64/sys/__clone.S b/lib/libc/arch/x86_64/sys/__clone.S deleted file mode 100644 index 459bab5aa..000000000 --- a/lib/libc/arch/x86_64/sys/__clone.S +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: __clone.S,v 1.5 2014/05/22 15:01:57 uebayasi Exp $ */ - -/* - * Copyright (c) 2002 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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 -#include -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(clone, __clone) -#endif - .text - -/* - * int clone(int (*fn)(void *), void *stack, int flags, void *arg); - */ -ENTRY(__clone) - pushq %r12 - pushq %r13 - /* - * Sanity checks: func and stack may not be NULL. - */ - testq %rdi,%rdi - je 3f - testq %rsi,%rsi - je 3f - - - movq %rdi,%r12 - movq %rcx,%r13 - - movq %rdx,%rdi - - pushq $0 /* dummy return address */ - - SYSTRAP(__clone) - jc 4f - cmpl $0,%eax - jne 2f /* we're the parent */ - movq %r13,%rdi /* restore argument */ - call *%r12 /* this is the clone, call the function */ - - movq %rax,%rdi -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(_exit)) -#else - call _C_LABEL(_exit) -#endif - -2: - addq $8,%rsp - popq %r13 - popq %r12 - ret -3: - movl $EINVAL,%eax - jmp 5f -4: - addq $8,%rsp -5: - popq %r13 - popq %r12 - jmp CERROR -END(__clone) diff --git a/lib/libc/arch/x86_64/sys/__sigaction14_sigtramp.c b/lib/libc/arch/x86_64/sys/__sigaction14_sigtramp.c deleted file mode 100644 index e65820c33..000000000 --- a/lib/libc/arch/x86_64/sys/__sigaction14_sigtramp.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: __sigaction14_sigtramp.c,v 1.11 2014/05/14 06:38:09 uebayasi Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __sigaction14_sigtramp.c,v 1.11 2014/05/14 06:38:09 uebayasi Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#include "extern.h" - -__weak_alias(__sigaction14, __libc_sigaction14) - -int -__libc_sigaction14(int sig, const struct sigaction *act, struct sigaction *oact) -{ - extern const int __sigtramp_siginfo_2[]; - -#if 0 - /* - * If no sigaction, use the "default" trampoline since it won't - * be used. - */ - if (act == NULL) - return __sigaction_sigtramp(sig, act, oact, NULL, 0); -#endif - - /* - * Don't provide sigcontext compatibility, - * always use the siginfo trampoline. - */ - return __sigaction_sigtramp(sig, act, oact, __sigtramp_siginfo_2, 2); -} diff --git a/lib/libc/arch/x86_64/sys/__sigtramp2.S b/lib/libc/arch/x86_64/sys/__sigtramp2.S deleted file mode 100644 index a7205dbe2..000000000 --- a/lib/libc/arch/x86_64/sys/__sigtramp2.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: __sigtramp2.S,v 1.6 2014/05/22 15:01:57 uebayasi Exp $ */ - -/* - * Copyright (c) 2001 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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.h" - -/* - * The x86-64 signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - */ -NENTRY(__sigtramp_siginfo_2) - movq %r15,%rdi - movq $SYS_setcontext, %rax - syscall - movq $-1,%rdi /* if we return here, something is wrong */ - movq $SYS_exit, %rax - syscall -END(__sigtramp_siginfo_2) diff --git a/lib/libc/arch/x86_64/sys/__syscall.S b/lib/libc/arch/x86_64/sys/__syscall.S deleted file mode 100644 index 9550377ef..000000000 --- a/lib/libc/arch/x86_64/sys/__syscall.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: __syscall.S,v 1.2 2003/08/07 16:42:37 agc Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __syscall.S,v 1.2 2003/08/07 16:42:37 agc Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -RSYSCALL(__syscall) diff --git a/lib/libc/arch/x86_64/sys/__vfork14.S b/lib/libc/arch/x86_64/sys/__vfork14.S deleted file mode 100644 index f900bb32e..000000000 --- a/lib/libc/arch/x86_64/sys/__vfork14.S +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: __vfork14.S,v 1.5 2014/05/22 15:01:57 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: __vfork14.S,v 1.5 2014/05/22 15:01:57 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ -ENTRY(__vfork14) - popq %r9 /* my rta into r9 */ - SYSTRAP(__vfork14) - jc err - decl %edx - andl %edx,%eax - jmp *%r9 -err: - pushq %r9 - jmp CERROR -END(__vfork14) diff --git a/lib/libc/arch/x86_64/sys/brk.S b/lib/libc/arch/x86_64/sys/brk.S deleted file mode 100644 index 5f3d19c7f..000000000 --- a/lib/libc/arch/x86_64/sys/brk.S +++ /dev/null @@ -1,85 +0,0 @@ -/* $NetBSD: brk.S,v 1.6 2014/05/22 15:01:57 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)brk.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: brk.S,v 1.6 2014/05/22 15:01:57 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl _C_LABEL(__minbrk) - .globl CURBRK - -#ifdef WEAK_ALIAS -WEAK_ALIAS(brk, _brk) -#endif - - .data -_C_LABEL(__minbrk): - .quad _end - .text - -ENTRY(_brk) -#ifdef __PIC__ - movq PIC_GOT(_C_LABEL(__minbrk)),%rdx - cmpq %rdi,(%rdx) - jb 1f - movq (%rdx),%rdi -1: - SYSTRAP(break) - jc err - movq PIC_GOT(CURBRK),%rdx # set up GOT addressing - movq %rdi,(%rdx) - xorl %eax,%eax - ret -err: - jmp CERROR -#else - cmpq %rdi,_C_LABEL(__minbrk)(%rip) - jb 1f - movq _C_LABEL(__minbrk)(%rip),%rdi -1: - SYSTRAP(break) - jc err - movq %rdi,CURBRK(%rip) - xorl %eax,%eax - ret -err: - jmp CERROR -#endif -END(_brk) diff --git a/lib/libc/arch/x86_64/sys/cerror.S b/lib/libc/arch/x86_64/sys/cerror.S deleted file mode 100644 index d338ce700..000000000 --- a/lib/libc/arch/x86_64/sys/cerror.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: cerror.S,v 1.7 2014/05/22 15:01:57 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)cerror.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: cerror.S,v 1.7 2014/05/22 15:01:57 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _C_LABEL(__errno) - .protected CERROR - -_ENTRY(CERROR) - pushq %r12 - movl %eax,%edi - movl %eax,%r12d -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__errno)) -#else - call _C_LABEL(__errno) -#endif /* __PIC__ */ - movl %r12d,(%rax) - movq $-1,%rax - popq %r12 - ret -END(CERROR) diff --git a/lib/libc/arch/x86_64/sys/exect.S b/lib/libc/arch/x86_64/sys/exect.S deleted file mode 100644 index 813c50485..000000000 --- a/lib/libc/arch/x86_64/sys/exect.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: exect.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)exect.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: exect.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" -#include - -ENTRY(exect) - pushfq - orb $(PSL_T>>8),1(%rsp) - popfq - SYSTRAP(execve) - jmp CERROR -END(exect) diff --git a/lib/libc/arch/x86_64/sys/fork.S b/lib/libc/arch/x86_64/sys/fork.S deleted file mode 100644 index 1c00d4e3f..000000000 --- a/lib/libc/arch/x86_64/sys/fork.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: fork.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)fork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: fork.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -_SYSCALL(__fork,fork) - decl %edx /* from 1 to 0 in child, 0 to -1 in parent */ - andl %edx,%eax - ret /* pid = fork(); */ -END(__fork) diff --git a/lib/libc/arch/x86_64/sys/getcontext.S b/lib/libc/arch/x86_64/sys/getcontext.S deleted file mode 100644 index 372e1dfb6..000000000 --- a/lib/libc/arch/x86_64/sys/getcontext.S +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: getcontext.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $ */ - -/* - * Copyright (c) 2003 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Frank van der Linden for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: getcontext.S,v 1.4 2014/05/22 15:01:57 uebayasi Exp $") -#endif - -#ifdef WEAK_ALIAS -WEAK_ALIAS(getcontext, _getcontext) -#endif - -/* - * 56 == offsetof(ucontext_t, uc_mcontext) - * 14 == _REG_RAX - * 21 == _REG_RIP - * 24 == _REG_URSP - */ - -_SYSCALL(_getcontext,getcontext) - movq (%rsp),%r11 - movq %r11,(56 + 21 * 8)(%rdi) - leaq 8(%rsp),%r11 - movq %r11,(56 + 24 * 8)(%rdi) - movq $0,(56 + 14 * 8)(%rdi) - xorl %eax,%eax - ret -END(_getcontext) diff --git a/lib/libc/arch/x86_64/sys/pipe.S b/lib/libc/arch/x86_64/sys/pipe.S deleted file mode 100644 index 023c7800e..000000000 --- a/lib/libc/arch/x86_64/sys/pipe.S +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: pipe.S,v 1.3 2014/05/22 15:01:57 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)pipe.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: pipe.S,v 1.3 2014/05/22 15:01:57 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -#ifdef WEAK_ALIAS -WEAK_ALIAS(pipe, _pipe) -#endif - -_SYSCALL(_pipe,pipe) - movl %eax,(%rdi) - movl %edx,4(%rdi) - xorl %eax,%eax - ret -END(_pipe) diff --git a/lib/libc/arch/x86_64/sys/ptrace.S b/lib/libc/arch/x86_64/sys/ptrace.S deleted file mode 100644 index 715aa0d6c..000000000 --- a/lib/libc/arch/x86_64/sys/ptrace.S +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: ptrace.S,v 1.6 2014/11/24 15:33:18 christos Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)ptrace.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: ptrace.S,v 1.6 2014/11/24 15:33:18 christos Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _C_LABEL(__errno) - -ENTRY(ptrace) - /* - * The following code calls __errno() to set it to 0 before - * calling ptrace(2). The libc version of __errno() does not use - * any registers, but the libpthread version clobbers %rcx - * before we get a chance to store it in %r10. So we save it - * in %r10 and restore it. - */ - movq %rcx, %r10 -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(__errno)) -#else - call _C_LABEL(__errno) -#endif /* __PIC__ */ - movl $0,(%rax) - movq %r10, %rcx - SYSTRAP(ptrace) - jc err - ret -err: - jmp CERROR -END(ptrace) diff --git a/lib/libc/arch/x86_64/sys/sbrk.S b/lib/libc/arch/x86_64/sys/sbrk.S deleted file mode 100644 index 54b0ee4e0..000000000 --- a/lib/libc/arch/x86_64/sys/sbrk.S +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: sbrk.S,v 1.6 2014/05/22 15:01:57 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sbrk.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: sbrk.S,v 1.6 2014/05/22 15:01:57 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - - .globl _end - .globl CURBRK - -#ifdef WEAK_ALIAS -WEAK_ALIAS(sbrk, _sbrk) -#endif - - .data -CURBRK: .quad _end - .text - -ENTRY(_sbrk) -#ifdef __PIC__ - movq PIC_GOT(CURBRK),%rdx - movq (%rdx),%rax - test %rdi,%rdi - jz out - addq %rax,%rdi - SYSTRAP(break) - jc err - movq PIC_GOT(CURBRK),%rdx - movq (%rdx),%rax - movq %rdi,(%rdx) -out: - ret -err: - jmp CERROR -#else - movq CURBRK(%rip),%rax - test %rdi,%rdi - jz out - movq %rdi,%rsi - addq %rax,%rdi - SYSTRAP(break) - jc err - movq CURBRK(%rip),%rax - addq %rsi,CURBRK(%rip) -out: - ret -err: - jmp CERROR -#endif -END(_sbrk) diff --git a/lib/libc/arch/x86_64/sys/shmat.S b/lib/libc/arch/x86_64/sys/shmat.S deleted file mode 100644 index 2c81105e3..000000000 --- a/lib/libc/arch/x86_64/sys/shmat.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: shmat.S,v 1.1 2001/06/19 00:25:06 fvdl Exp $ */ - -#include "SYS.h" - -RSYSCALL(shmat) diff --git a/lib/libc/arch/x86_64/sys/syscall.S b/lib/libc/arch/x86_64/sys/syscall.S deleted file mode 100644 index e802b61fb..000000000 --- a/lib/libc/arch/x86_64/sys/syscall.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: syscall.S,v 1.4 2007/11/05 20:30:07 dsl Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)syscall.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: syscall.S,v 1.4 2007/11/05 20:30:07 dsl Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -RSYSCALL(syscall) diff --git a/lib/libc/atomic/Makefile.inc b/lib/libc/atomic/Makefile.inc deleted file mode 100644 index 80951a7c6..000000000 --- a/lib/libc/atomic/Makefile.inc +++ /dev/null @@ -1,76 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2010/02/12 22:34:38 dyoung Exp $ -# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 - -# gen sources -.PATH: ${.CURDIR}/atomic - -MAN+= atomic_add.3 atomic_and.3 atomic_cas.3 atomic_dec.3 \ - atomic_inc.3 atomic_ops.3 atomic_or.3 atomic_swap.3 \ - membar_ops.3 - -MLINKS+=atomic_add.3 atomic_add_32.3 \ - atomic_add.3 atomic_add_int.3 \ - atomic_add.3 atomic_add_long.3 \ - atomic_add.3 atomic_add_ptr.3 \ - atomic_add.3 atomic_add_64.3 \ - atomic_add.3 atomic_add_32_nv.3 \ - atomic_add.3 atomic_add_int_nv.3 \ - atomic_add.3 atomic_add_long_nv.3 \ - atomic_add.3 atomic_add_ptr_nv.3 \ - atomic_add.3 atomic_add_64_nv.3 \ - atomic_and.3 atomic_and_32.3 \ - atomic_and.3 atomic_and_uint.3 \ - atomic_and.3 atomic_and_ulong.3 \ - atomic_and.3 atomic_and_64.3 \ - atomic_and.3 atomic_and_32_nv.3 \ - atomic_and.3 atomic_and_uint_nv.3 \ - atomic_and.3 atomic_and_ulong_nv.3 \ - atomic_and.3 atomic_and_64_nv.3 \ - atomic_cas.3 atomic_cas_32.3 \ - atomic_cas.3 atomic_cas_uint.3 \ - atomic_cas.3 atomic_cas_ulong.3 \ - atomic_cas.3 atomic_cas_ptr.3 \ - atomic_cas.3 atomic_cas_64.3 \ - atomic_cas.3 atomic_cas_32_ni.3 \ - atomic_cas.3 atomic_cas_uint_ni.3 \ - atomic_cas.3 atomic_cas_ulong_ni.3 \ - atomic_cas.3 atomic_cas_ptr_ni.3 \ - atomic_cas.3 atomic_cas_64_ni.3 \ - atomic_dec.3 atomic_dec_32.3 \ - atomic_dec.3 atomic_dec_uint.3 \ - atomic_dec.3 atomic_dec_ulong.3 \ - atomic_dec.3 atomic_dec_ptr.3 \ - atomic_dec.3 atomic_dec_64.3 \ - atomic_dec.3 atomic_dec_32_nv.3 \ - atomic_dec.3 atomic_dec_uint_nv.3 \ - atomic_dec.3 atomic_dec_ulong_nv.3 \ - atomic_dec.3 atomic_dec_ptr_nv.3 \ - atomic_dec.3 atomic_dec_64_nv.3 \ - atomic_inc.3 atomic_inc_32.3 \ - atomic_inc.3 atomic_inc_uint.3 \ - atomic_inc.3 atomic_inc_ulong.3 \ - atomic_inc.3 atomic_inc_ptr.3 \ - atomic_inc.3 atomic_inc_64.3 \ - atomic_inc.3 atomic_inc_32_nv.3 \ - atomic_inc.3 atomic_inc_uint_nv.3 \ - atomic_inc.3 atomic_inc_ulong_nv.3 \ - atomic_inc.3 atomic_inc_ptr_nv.3 \ - atomic_inc.3 atomic_inc_64_nv.3 \ - atomic_or.3 atomic_or_32.3 \ - atomic_or.3 atomic_or_uint.3 \ - atomic_or.3 atomic_or_ulong.3 \ - atomic_or.3 atomic_or_64.3 \ - atomic_or.3 atomic_or_32_nv.3 \ - atomic_or.3 atomic_or_uint_nv.3 \ - atomic_or.3 atomic_or_ulong_nv.3 \ - atomic_or.3 atomic_or_64_nv.3 \ - atomic_swap.3 atomic_swap_32.3 \ - atomic_swap.3 atomic_swap_uint.3 \ - atomic_swap.3 atomic_swap_ulong.3 \ - atomic_swap.3 atomic_swap_ptr.3 \ - atomic_swap.3 atomic_swap_64.3 \ - membar_ops.3 membar_enter.3 \ - membar_ops.3 membar_exit.3 \ - membar_ops.3 membar_producer.3 \ - membar_ops.3 membar_consumer.3 \ - membar_ops.3 membar_sync.3 diff --git a/lib/libc/atomic/atomic_add.3 b/lib/libc/atomic/atomic_add.3 deleted file mode 100644 index b6f8adbb4..000000000 --- a/lib/libc/atomic/atomic_add.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" $NetBSD: atomic_add.3,v 1.1 2008/06/23 10:22:40 ad Exp $ -.\" -.\" Copyright (c) 2007 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 11, 2007 -.Dt ATOMIC_ADD 3 -.Os -.Sh NAME -.Nm atomic_add , -.Nm atomic_add_32 , -.Nm atomic_add_int , -.Nm atomic_add_long , -.Nm atomic_add_ptr , -.Nm atomic_add_64 , -.Nm atomic_add_32_nv , -.Nm atomic_add_int_nv , -.Nm atomic_add_long_nv , -.Nm atomic_add_ptr_nv , -.Nm atomic_add_64_nv -.Nd atomic add operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Ft void -.Fn atomic_add_32 "volatile uint32_t *ptr" "int32_t delta" -.Ft void -.Fn atomic_add_int "volatile unsigned int *ptr" "int delta" -.Ft void -.Fn atomic_add_long "volatile unsigned long *ptr" "long delta" -.Ft void -.Fn atomic_add_ptr "volatile void *ptr" "ssize_t delta" -.Ft void -.Fn atomic_add_64 "volatile uint64_t *ptr" "int64_t delta" -.Ft uint32_t -.Fn atomic_add_32_nv "volatile uint32_t *ptr" "int32_t delta" -.Ft unsigned int -.Fn atomic_add_int_nv "volatile unsigned int *ptr" "int delta" -.Ft unsigned long -.Fn atomic_add_long_nv "volatile unsigned long *ptr" "long delta" -.Ft void * -.Fn atomic_add_ptr_nv "volatile void *ptr" "ssize_t delta" -.Ft uint64_t -.Fn atomic_add_64_nv "volatile uint64_t *ptr" "int64_t delta" -.Sh DESCRIPTION -The -.Nm atomic_add -family of functions add a signed value -.Fa delta -to the variable referenced by -.Fa ptr -in an atomic fashion. -.Pp -The -.Fn *_nv -variants of these functions return the new value. -.Pp -The 64-bit variants of these functions are available only on platforms -that can support atomic 64-bit memory access. -Applications can check for the availability of 64-bit atomic memory -operations by testing if the pre-processor macro -.Dv __HAVE_ATOMIC64_OPS -is defined. -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm atomic_add -functions first appeared in -.Nx 5.0 . diff --git a/lib/libc/atomic/atomic_and.3 b/lib/libc/atomic/atomic_and.3 deleted file mode 100644 index 7f5ed50d4..000000000 --- a/lib/libc/atomic/atomic_and.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" $NetBSD: atomic_and.3,v 1.1 2008/06/23 10:22:40 ad Exp $ -.\" -.\" Copyright (c) 2007 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 11, 2007 -.Dt ATOMIC_AND 3 -.Os -.Sh NAME -.Nm atomic_and , -.Nm atomic_and_32 , -.Nm atomic_and_uint , -.Nm atomic_and_ulong , -.Nm atomic_and_64 , -.Nm atomic_and_32_nv , -.Nm atomic_and_uint_nv , -.Nm atomic_and_ulong_nv , -.Nm atomic_and_64_nv -.Nd atomic logical -.Sq and -operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Ft void -.Fn atomic_and_32 "volatile uint32_t *ptr" "uint32_t bits" -.Ft void -.Fn atomic_and_uint "volatile unsigned int *ptr" "unsigned int bits" -.Ft void -.Fn atomic_and_ulong "volatile unsigned long *ptr" "unsigned long bits" -.Ft void -.Fn atomic_and_64 "volatile uint64_t *ptr" "uint64_t bits" -.Ft uint32_t -.Fn atomic_and_32_nv "volatile uint32_t *ptr" "uint32_t bits" -.Ft unsigned int -.Fn atomic_and_uint_nv "volatile unsigned int *ptr" "unsigned int bits" -.Ft unsigned long -.Fn atomic_and_ulong_nv "volatile unsigned long *ptr" "unsigned long bits" -.Ft uint64_t -.Fn atomic_and_64_nv "volatile uint64_t *ptr" "uint64_t bits" -.Sh DESCRIPTION -The -.Nm atomic_and -family of functions load the value of the variable referenced by -.Fa ptr , -perform a logical -.Sq and -with the value -.Fa bits , -and store the result back to the variable referenced by -.Fa ptr -in an atomic fashion. -.Pp -The -.Fn *_nv -variants of these functions return the new value. -.Pp -The 64-bit variants of these functions are available only on platforms -that can support atomic 64-bit memory access. -Applications can check for the availability of 64-bit atomic memory -operations by testing if the pre-processor macro -.Dv __HAVE_ATOMIC64_OPS -is defined. -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm atomic_and -functions first appeared in -.Nx 5.0 . diff --git a/lib/libc/atomic/atomic_cas.3 b/lib/libc/atomic/atomic_cas.3 deleted file mode 100644 index 04e4416e7..000000000 --- a/lib/libc/atomic/atomic_cas.3 +++ /dev/null @@ -1,129 +0,0 @@ -.\" $NetBSD: atomic_cas.3,v 1.5 2014/02/02 18:06:33 dholland Exp $ -.\" -.\" Copyright (c) 2007, 2010 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd February 2, 2014 -.Dt ATOMIC_CAS 3 -.Os -.Sh NAME -.Nm atomic_cas , -.Nm atomic_cas_32 , -.Nm atomic_cas_uint , -.Nm atomic_cas_ulong , -.Nm atomic_cas_ptr , -.Nm atomic_cas_64 , -.Nm atomic_cas_32_ni , -.Nm atomic_cas_uint_ni , -.Nm atomic_cas_ulong_ni , -.Nm atomic_cas_ptr_ni , -.Nm atomic_cas_64_ni -.Nd atomic compare-and-swap operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Ft uint32_t -.Fn atomic_cas_32 "volatile uint32_t *ptr" "uint32_t expected" "uint32_t new" -.Ft unsigned int -.Fn atomic_cas_uint "volatile unsigned int *ptr" "unsigned int expected" \ - "unsigned int new" -.Ft unsigned long -.Fn atomic_cas_ulong "volatile unsigned long *ptr" "unsigned long expected" \ - "unsigned long new" -.Ft void * -.Fn atomic_cas_ptr "volatile void *ptr" "void *expected" "void *new" -.Ft uint64_t -.Fn atomic_cas_64 "volatile uint64_t *ptr" "uint64_t expected" "uint64_t new" -.Ft uint32_t -.Fn atomic_cas_32_ni "volatile uint32_t *ptr" "uint32_t expected" \ - "uint32_t new" -.Ft unsigned int -.Fn atomic_cas_uint_ni "volatile unsigned int *ptr" "unsigned int expected" \ - "unsigned int new" -.Ft unsigned long -.Fn atomic_cas_ulong_ni "volatile unsigned long *ptr" \ - "unsigned long expected" "unsigned long new" -.Ft void * -.Fn atomic_cas_ptr_ni "volatile void *ptr" "void *expected" "void *new" -.Ft uint64_t -.Fn atomic_cas_64_ni "volatile uint64_t *ptr" "uint64_t expected" \ - "uint64_t new" -.Sh DESCRIPTION -The -.Nm atomic_cas -family of functions perform an atomic conditional assignment. -The value -.Fa new -is assigned to the variable referenced by -.Fa ptr . -The assignment succeeds -if and only if its current value matches the value -.Fa expected . -If the value is different, the assignment fails and no change is -made. -This operation is sometimes known as -.Dq compare-and-swap . -These functions always return the value found via -.Fa ptr . -Callers test for success by comparing the return value to the value -passed as -.Fa expected ; -if they are equal then the new value was stored; if they are not, the -value was not changed. -.Pp -The non-interlocked variants, -.Fn *_ni , -guarantee atomicity within the same CPU with respect to -interrupts and preemption. -They are not atomic with respect to different CPUs. -These can be used to avoid interprocessor synchronization overhead -in some cases; for example, they are suitable for synchronized -operations on a variable shared by a thread and an interrupt that are -bound to the same CPU. -.Pp -The 64-bit variants of these functions are available only on platforms -that can support atomic 64-bit memory access. -Applications can check for the availability of 64-bit atomic memory -operations by testing if the pre-processor macro -.Dv __HAVE_ATOMIC64_OPS -is defined. -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm atomic_cas -functions first appeared in -.Nx 5.0 . -.Sh NOTES -On some architectures, a -.Fn *_ni -variant is merely an alias for the corresponding standard -compare-and-swap operation. -While the non-interlocked variant behaves correctly on those -architectures, it does not avoid the interprocessor synchronization -overhead. diff --git a/lib/libc/atomic/atomic_dec.3 b/lib/libc/atomic/atomic_dec.3 deleted file mode 100644 index 654ed24a2..000000000 --- a/lib/libc/atomic/atomic_dec.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" $NetBSD: atomic_dec.3,v 1.1 2008/06/23 10:22:40 ad Exp $ -.\" -.\" Copyright (c) 2007 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 11, 2007 -.Dt ATOMIC_DEC 3 -.Os -.Sh NAME -.Nm atomic_dec , -.Nm atomic_dec_32 , -.Nm atomic_dec_uint , -.Nm atomic_dec_ulong , -.Nm atomic_dec_ptr , -.Nm atomic_dec_64 , -.Nm atomic_dec_32_nv , -.Nm atomic_dec_uint_nv , -.Nm atomic_dec_ulong_nv , -.Nm atomic_dec_ptr_nv , -.Nm atomic_dec_64_nv -.Nd atomic decrement operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Ft void -.Fn atomic_dec_32 "volatile uint32_t *ptr" -.Ft void -.Fn atomic_dec_uint "volatile unsigned int *ptr" -.Ft void -.Fn atomic_dec_ulong "volatile unsigned long *ptr" -.Ft void -.Fn atomic_dec_ptr "volatile void *ptr" -.Ft void -.Fn atomic_dec_64 "volatile uint64_t *ptr" -.Ft uint32_t -.Fn atomic_dec_32_nv "volatile uint32_t *ptr" -.Ft unsigned int -.Fn atomic_dec_uint_nv "volatile unsigned int *ptr" -.Ft unsigned long -.Fn atomic_dec_ulong_nv "volatile unsigned long *ptr" -.Ft void * -.Fn atomic_dec_ptr_nv "volatile void *ptr" -.Ft uint64_t -.Fn atomic_dec_64_nv "volatile uint64_t *ptr" -.Sh DESCRIPTION -The -.Nm atomic_dec -family of functions decrement -.Pq by one -the variable referenced by -.Fa ptr -in an atomic fashion. -.Pp -The -.Fn *_nv -variants of these functions return the new value. -.Pp -The 64-bit variants of these functions are available only on platforms -that can support atomic 64-bit memory access. -Applications can check for the availability of 64-bit atomic memory -operations by testing if the pre-processor macro -.Dv __HAVE_ATOMIC64_OPS -is defined. -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm atomic_dec -functions first appeared in -.Nx 5.0 . diff --git a/lib/libc/atomic/atomic_inc.3 b/lib/libc/atomic/atomic_inc.3 deleted file mode 100644 index a03429e99..000000000 --- a/lib/libc/atomic/atomic_inc.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" $NetBSD: atomic_inc.3,v 1.1 2008/06/23 10:22:40 ad Exp $ -.\" -.\" Copyright (c) 2007 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 11, 2007 -.Dt ATOMIC_INC 3 -.Os -.Sh NAME -.Nm atomic_inc , -.Nm atomic_inc_32 , -.Nm atomic_inc_uint , -.Nm atomic_inc_ulong , -.Nm atomic_inc_ptr , -.Nm atomic_inc_64 , -.Nm atomic_inc_32_nv , -.Nm atomic_inc_uint_nv , -.Nm atomic_inc_ulong_nv , -.Nm atomic_inc_ptr_nv , -.Nm atomic_inc_64_nv -.Nd atomic increment operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Ft void -.Fn atomic_inc_32 "volatile uint32_t *ptr" -.Ft void -.Fn atomic_inc_uint "volatile unsigned int *ptr" -.Ft void -.Fn atomic_inc_ulong "volatile unsigned long *ptr" -.Ft void -.Fn atomic_inc_ptr "volatile void *ptr" -.Ft void -.Fn atomic_inc_64 "volatile uint64_t *ptr" -.Ft uint32_t -.Fn atomic_inc_32_nv "volatile uint32_t *ptr" -.Ft unsigned int -.Fn atomic_inc_uint_nv "volatile unsigned int *ptr" -.Ft unsigned long -.Fn atomic_inc_ulong_nv "volatile unsigned long *ptr" -.Ft void * -.Fn atomic_inc_ptr_nv "volatile void *ptr" -.Ft uint64_t -.Fn atomic_inc_64_nv "volatile uint64_t *ptr" -.Sh DESCRIPTION -The -.Nm atomic_inc -family of functions increment -.Pq by one -the variable referenced by -.Fa ptr -in an atomic fashion. -.Pp -The -.Fn *_nv -variants of these functions return the new value. -.Pp -The 64-bit variants of these functions are available only on platforms -that can support atomic 64-bit memory access. -Applications can check for the availability of 64-bit atomic memory -operations by testing if the pre-processor macro -.Dv __HAVE_ATOMIC64_OPS -is defined. -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm atomic_inc -functions first appeared in -.Nx 5.0 . diff --git a/lib/libc/atomic/atomic_ops.3 b/lib/libc/atomic/atomic_ops.3 deleted file mode 100644 index 77f6c72ef..000000000 --- a/lib/libc/atomic/atomic_ops.3 +++ /dev/null @@ -1,129 +0,0 @@ -.\" $NetBSD: atomic_ops.3,v 1.5 2010/04/14 08:49:49 jruoho Exp $ -.\" -.\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 14, 2010 -.Dt ATOMIC_OPS 3 -.Os -.Sh NAME -.Nm atomic_ops -.Nd atomic memory operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Sh DESCRIPTION -The -.Nm atomic_ops -family of functions provide atomic memory operations. -There are 7 classes of atomic memory operations available: -.Pp -.Bl -tag -width "atomic_swap(3)" -offset indent -.It Xr atomic_add 3 -These functions perform atomic addition. -.It Xr atomic_and 3 -These functions perform atomic logical -.Dq and . -.It Xr atomic_cas 3 -These functions perform atomic compare-and-swap. -.It Xr atomic_dec 3 -These functions perform atomic decrement. -.It Xr atomic_inc 3 -These functions perform atomic increment. -.It Xr atomic_or 3 -These functions perform atomic logical -.Dq or . -.It Xr atomic_swap 3 -These functions perform atomic swap. -.El -.Ss Synchronization Mechanisms -Where the architecture does not provide hardware support for atomic compare -and swap (CAS), atomicity is provided by a restartable sequence or by a -spinlock. -The chosen method is not ordinarily distinguishable by or visible to users -of the interface. -The following architectures can be assumed to provide CAS in hardware: -alpha, amd64, i386, powerpc, powerpc64, sparc64. -.Ss Scope and Restrictions -If hardware CAS is available, the atomic operations are globally atomic: -operations within a memory region shared between processes are -guaranteed to be performed atomically. -If hardware CAS is not available, it may only be assumed that the operations -are atomic with respect to threads in the same process. -Additionally, if hardware CAS is not available, the atomic operations must -not be used within a signal handler. -.Pp -Users of atomic memory operations should not make assumptions about how -the memory access is performed -.Pq specifically, the width of the memory access . -For this reason, applications making use of atomic memory operations should -limit their use to regular memory. -The results of using atomic memory operations on anything other than -regular memory are undefined. -.Pp -Users of atomic memory operations should take care to modify any given -memory location either entirely with atomic operations or entirely with -some other synchronization mechanism. -Intermixing of atomic operations with other synchronization mechanisms -for the same memory location results in undefined behavior. -.Ss Visibility and Ordering of Memory Accesses -If hardware CAS is available, stores to the target memory location by an -atomic operation will reach global visibility before the operation -completes. -If hardware CAS is not available, the store may not reach global visibility -until some time after the atomic operation has completed. -However, in all cases a subsequent atomic operation on the same memory cell -will be delayed until the result of any preceeding operation has reached -global visibility. -.Pp -Atomic operations are strongly ordered with respect to each other. -The global visibility of other loads and stores before and after an atomic -operation is undefined. -Applications that require synchronization of loads and stores with respect -to an atomic operation must use memory barriers. -See -.Xr membar_ops 3 . -.Ss Performance -Because atomic memory operations require expensive synchronization at the -hardware level, applications should take care to minimize their use. -In certain cases, it may be more appropriate to use a mutex, especially -if more than one memory location will be modified. -.Sh SEE ALSO -.Xr atomic_add 3 , -.Xr atomic_and 3 , -.Xr atomic_cas 3 , -.Xr atomic_dec 3 , -.Xr atomic_inc 3 , -.Xr atomic_or 3 , -.Xr atomic_swap 3 , -.Xr membar_ops 3 -.Sh HISTORY -The -.Nm atomic_ops -functions first appeared in -.Nx 5.0 . diff --git a/lib/libc/atomic/atomic_or.3 b/lib/libc/atomic/atomic_or.3 deleted file mode 100644 index 903f5b02c..000000000 --- a/lib/libc/atomic/atomic_or.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" $NetBSD: atomic_or.3,v 1.1 2008/06/23 10:22:40 ad Exp $ -.\" -.\" Copyright (c) 2007 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 11, 2007 -.Dt ATOMIC_OR 3 -.Os -.Sh NAME -.Nm atomic_or , -.Nm atomic_or_32 , -.Nm atomic_or_uint , -.Nm atomic_or_ulong , -.Nm atomic_or_64 , -.Nm atomic_or_32_nv , -.Nm atomic_or_uint_nv , -.Nm atomic_or_ulong_nv , -.Nm atomic_or_64_nv -.Nd atomic logical -.Sq or -operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Ft void -.Fn atomic_or_32 "volatile uint32_t *ptr" "uint32_t bits" -.Ft void -.Fn atomic_or_uint "volatile unsigned int *ptr" "unsigned int bits" -.Ft void -.Fn atomic_or_ulong "volatile unsigned long *ptr" "unsigned long bits" -.Ft void -.Fn atomic_or_64 "volatile uint64_t *ptr" "uint64_t bits" -.Ft uint32_t -.Fn atomic_or_32_nv "volatile uint32_t *ptr" "uint32_t bits" -.Ft unsigned int -.Fn atomic_or_uint_nv "volatile unsigned int *ptr" "unsigned int bits" -.Ft unsigned long -.Fn atomic_or_ulong_nv "volatile unsigned long *ptr" "unsigned long bits" -.Ft uint64_t -.Fn atomic_or_64_nv "volatile uint64_t *ptr" "uint64_t bits" -.Sh DESCRIPTION -The -.Nm atomic_or -family of functions load the value of the variable referenced by -.Fa ptr , -perform a logical -.Sq or -with the value -.Fa bits , -and store the result back to the variable referenced by -.Fa ptr -in an atomic fashion. -.Pp -The -.Fn *_nv -variants of these functions return the new value. -.Pp -The 64-bit variants of these functions are available only on platforms -that can support atomic 64-bit memory access. -Applications can check for the availability of 64-bit atomic memory -operations by testing if the pre-processor macro -.Dv __HAVE_ATOMIC64_OPS -is defined. -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm atomic_or -functions first appeared in -.Nx 5.0 . diff --git a/lib/libc/atomic/atomic_swap.3 b/lib/libc/atomic/atomic_swap.3 deleted file mode 100644 index 274365250..000000000 --- a/lib/libc/atomic/atomic_swap.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $NetBSD: atomic_swap.3,v 1.1 2008/06/23 10:22:40 ad Exp $ -.\" -.\" Copyright (c) 2007 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 11, 2007 -.Dt ATOMIC_SWAP 3 -.Os -.Sh NAME -.Nm atomic_swap , -.Nm atomic_swap_32 , -.Nm atomic_swap_uint , -.Nm atomic_swap_ulong , -.Nm atomic_swap_ptr , -.Nm atomic_swap_64 -.Nd atomic swap operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.Ft uint32_t -.Fn atomic_swap_32 "volatile uint32_t *ptr" "uint32_t new" -.Ft unsigned int -.Fn atomic_swap_uint "volatile unsigned int *ptr" "unsigned int new" -.Ft unsigned long -.Fn atomic_swap_ulong "volatile unsigned long *ptr" "unsigned long new" -.Ft void * -.Fn atomic_swap_ptr "volatile void *ptr" "void *new" -.Ft uint64_t -.Fn atomic_swap_64 "volatile uint64_t *ptr" "uint64_t new" -.Sh DESCRIPTION -The -.Nm atomic_swap -family of functions perform a swap operation in an atomic fashion. -The value of the variable referenced by -.Fa ptr -is replaced by -.Fa new -and the old value returned. -.Pp -The 64-bit variants of these functions are available only on platforms -that can support atomic 64-bit memory access. -Applications can check for the availability of 64-bit atomic memory -operations by testing if the pre-processor macro -.Dv __HAVE_ATOMIC64_OPS -is defined. -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm atomic_swap -functions first appeared in -.Nx 5.0 . diff --git a/lib/libc/atomic/membar_ops.3 b/lib/libc/atomic/membar_ops.3 deleted file mode 100644 index 1efecd44a..000000000 --- a/lib/libc/atomic/membar_ops.3 +++ /dev/null @@ -1,137 +0,0 @@ -.\" $NetBSD: membar_ops.3,v 1.4 2015/01/08 22:27:17 riastradh Exp $ -.\" -.\" Copyright (c) 2007, 2008 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd November 20, 2014 -.Dt MEMBAR_OPS 3 -.Os -.Sh NAME -.Nm membar_ops , -.Nm membar_enter , -.Nm membar_exit , -.Nm membar_producer , -.Nm membar_consumer , -.Nm membar_sync -.Nd memory access barrier operations -.\" .Sh LIBRARY -.\" .Lb libc -.Sh SYNOPSIS -.In sys/atomic.h -.\" -.Ft void -.Fn membar_enter "void" -.Ft void -.Fn membar_exit "void" -.Ft void -.Fn membar_producer "void" -.Ft void -.Fn membar_consumer "void" -.Ft void -.Fn membar_datadep_consumer "void" -.Ft void -.Fn membar_sync "void" -.Sh DESCRIPTION -The -.Nm membar_ops -family of functions provide memory access barrier operations necessary -for synchronization in multiprocessor execution environments that have -relaxed load and store order. -.Pp -.Bl -tag -width "mem" -.It Fn membar_enter -Any store preceding -.Fn membar_enter -will reach global visibility before all loads and stores following it. -.Pp -.Fn membar_enter -is typically used in code that implements locking primitives to ensure -that a lock protects its data. -.It Fn membar_exit -All loads and stores preceding -.Fn membar_exit -will reach global visibility before any store that follows it. -.Pp -.Fn membar_exit -is typically used in code that implements locking primitives to ensure -that a lock protects its data. -.It Fn membar_producer -All stores preceding the memory barrier will reach global visibility -before any stores after the memory barrier reach global visibility. -.It Fn membar_consumer -All loads preceding the memory barrier will complete before any loads -after the memory barrier complete. -.It Fn membar_datadep_consumer -Same as -.Fn membar_consumer , -but limited to loads of addresses dependent on prior loads, or -.Sq data-dependent -loads: -.Bd -literal -offset indent -int **pp, *p, v; - -p = *pp; -membar_datadep_consumer(); -v = *p; -consume(v); -.Ed -.Pp -Does not guarantee ordering of loads in branches, or -.Sq control-dependent -loads -- you must use -.Fn membar_consumer -instead: -.Bd -literal -offset indent -int *ok, *p, v; - -if (*ok) { - membar_consumer(); - v = *p; - consume(v); -} -.Ed -.Pp -Most CPUs do not reorder data-dependent loads (i.e., most CPUs -guarantee that cached values are not stale in that case), so -.Fn membar_datadep_consumer -is a no-op on those CPUs. -.It Fn membar_sync -All loads and stores preceding the memory barrier will complete and -reach global visibility before any loads and stores after the memory -barrier complete and reach global visibility. -.El -.Sh SEE ALSO -.Xr atomic_ops 3 -.Sh HISTORY -The -.Nm membar_ops -functions first appeared in -.Nx 5.0 . -The data-dependent load barrier, -.Fn membar_datadep_consumer , -first appeared in -.Nx 7.0 . diff --git a/lib/libc/cdb/Makefile.inc b/lib/libc/cdb/Makefile.inc deleted file mode 100644 index c08c22e00..000000000 --- a/lib/libc/cdb/Makefile.inc +++ /dev/null @@ -1,25 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2013/12/11 01:24:08 joerg Exp $ - -# Constant database reader/writer - -.PATH: ${.CURDIR}/cdb -.PATH: ${NETBSDSRCDIR}/common/lib/libc/cdb - -SRCS+= cdbr.c cdbw.c - -MAN+= cdbr.3 cdbw.3 cdb.5 - -MLINKS+= cdbr.3 cdbr_open.3 -MLINKS+= cdbr.3 cdbr_entries.3 -MLINKS+= cdbr.3 cdbr_get.3 -MLINKS+= cdbr.3 cdbr_find.3 -MLINKS+= cdbr.3 cdbr_close.3 -MLINKS+= cdbw.3 cdbw_open.3 -MLINKS+= cdbw.3 cdbw_put.3 -MLINKS+= cdbw.3 cdbw_put_data.3 -MLINKS+= cdbw.3 cdbw_put_key.3 -MLINKS+= cdbw.3 cdbw_output.3 -MLINKS+= cdbw.3 cdbw_close.3 - -# XXX: Fix the code instead -LINTFLAGS.cdbw.c += -X 132,259,298 diff --git a/lib/libc/cdb/cdb.5 b/lib/libc/cdb/cdb.5 deleted file mode 100644 index 9a0f2f2e2..000000000 --- a/lib/libc/cdb/cdb.5 +++ /dev/null @@ -1,104 +0,0 @@ -.\" $NetBSD: cdb.5,v 1.6 2015/02/08 19:09:56 wiz Exp $ -.\" -.\" Copyright (c) 2010 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Joerg Sonnenberger. -.\" 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 COPYRIGHT HOLDERS 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 -.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, -.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.Dd April 27, 2010 -.Dt CDB 5 -.Os -.Sh NAME -.Nm cdb -.Nd format of the constant database -.Sh DESCRIPTION -The -.Nm -database format provides a space-efficient (key,value) database. -The format doesn't allow updates in any convenient form. -The file overhead is around 5 bytes per key and 5 bytes per entry. -Keys are not stored and it is the responsibility of the caller -to validate matches. -The index structure is based on a minimal perfect hash table, so exactly -one entry has to be checked for a match. -.Ss General Format -The header record of a -.Nm -database consists of the following: -.Bd -literal -offset indent -struct header_cdb { - uint8_t magic[7]; - uint8_t version; - uint8_t description[16]; - uint32_t data_size; - uint32_t entries; - uint32_t entries_index; - uint32_t seed; -}; -.Ed -.Pp -All fields are in Little Endian byte order. -.Pp -This is followed by a description of the hash function of -.Va entries_index -records. -The size of each index entry is the logarithm of -.Va entries -to base 256, rounded up. -.Pp -The index records are followed by the start offsets of the entries, -followed by -.Va data_size . -The offsets are relative to the end of the offset record table and are -monotonically increasing. -The size of each offset record is the logarithm of -.Va data_size -to base 256, rounded up. -.Pp -The offset table is followed by the entries in order. -No separation or padding is added. -.Ss Limitations -The -.Nm -file format is by design intended for a database that can be -mapped into memory. -The hard limit for the number of entries and keys is 3435973836. -The total size of all values must be smaller than 4GiB. -.Sh SEE ALSO -.Xr cdbr 3 , -.Xr cdbw 3 -.Sh HISTORY -Support for the -.Nm cdb -format first appeared in -.Nx 6.0 . -.Sh AUTHORS -The -.Nm cdbr -and -.Nm cdbw -functions have been written by -.An Joerg Sonnenberger Aq Mt joerg@NetBSD.org . diff --git a/lib/libc/cdb/cdbr.3 b/lib/libc/cdb/cdbr.3 deleted file mode 100644 index c28e001e0..000000000 --- a/lib/libc/cdb/cdbr.3 +++ /dev/null @@ -1,146 +0,0 @@ -.\" $NetBSD: cdbr.3,v 1.4 2013/12/05 21:17:23 joerg Exp $ -.\" -.\" Copyright (c) 2010 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Joerg Sonnenberger. -.\" 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 COPYRIGHT HOLDERS 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 -.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, -.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.Dd December 5, 2013 -.Dt CDBR 3 -.Os -.Sh NAME -.Nm cdbr -.Nm cdbr_open , -.Nm cdbr_open_mem , -.Nm cdbr_entries , -.Nm cdbr_get , -.Nm cdbr_find , -.Nm cdbr_close , -.Nm cdbr_write -.Nd constant database access methods -.Sh SYNOPSIS -.Ft "struct cdbr *" -.Fn cdbr_open "const char *path" "int flags" -.Ft "struct cdbr *" -.Fo cdbr_open_mem -.Fa "void *base" -.Fa "size_t size" -.Fa "void (*unmap)(void *, void *, size_t)" -.Fa "void *cookie" -.Fc -.Ft uint32_t -.Fn cdbr_entries "struct cdbr *cdbr" -.Ft int -.Fn cdbr_get "struct cdbr *cdbr" "uint32_t index" "const void **data" "size_t *datalen" -.Ft int -.Fo cdbr_find -.Fa "struct cdbr *cdbr" -.Fa "const void *key" -.Fa "size_t keylen" -.Fa "const void **data" -.Fa "size_t *datalen" -.Fc -.Ft void -.Fn cdbr_close "struct cdbr *cdbr" -.Sh DESCRIPTION -The -.Nm -library provides a space efficient (key,value) database based -on perfect hashing. -.Pp -A cdb database is opened for reading by calling -.Fn cdbr_open . -The only supported value for -.Va flags -is -.Dv CDBR_DEFAULT . -The function returns a handle to pass to the other functions. -The database is closed by invoking -.Fn cdbr_close . -All resources associated with the handle are freed and the memory -returned by -.Fn cdbr_get -and -.Fn cdbr_find -is invalidated. -.Fn cdbr_open_mem -works like -.Fn cdbr_open , -but takes a memory reference to the content of the database file. -If -.Va unmap -is not -.Dv NULL , -it is called by -.Fn cdbr_close -with -.Va cookie , -.Va base -and -.Va size -as arguments. -It is not called by -.Fn cdbr_open_mem -on error. -.Pp -The number of records in the database can be obtained by calling -.Fn cdbr_entries . -Records can be obtained by record number using -.Fn cdbr_get -or by key using -.Fn cdbr_find . -Both functions return 0 on success and update -.Va data -and -.Va datalen -accordingly. -The location -.Va *data -remains valid until -.Fn cdbr_close -is called. -It is the responsibility of the caller of -.Fn cdbr_find -to ensure that the key matches the returned data. -The function returns the only possible match, but the database doesn't store -the keys to minimize overhead. -.Sh SEE ALSO -.Xr nbperf 1 , -.Xr cdbw 3 , -.Xr db 3 , -.Xr cdb 5 -.Sh HISTORY -Support for the -.Nm cdb -format first appeared in -.Nx 6.0 . -.Sh AUTHORS -The -.Nm cdbr -and -.Nm cdbw -functions have been written by -.An Joerg Sonnenberger Aq Mt joerg@NetBSD.org . diff --git a/lib/libc/cdb/cdbw.3 b/lib/libc/cdb/cdbw.3 deleted file mode 100644 index 3d3a09d3f..000000000 --- a/lib/libc/cdb/cdbw.3 +++ /dev/null @@ -1,140 +0,0 @@ -.\" $NetBSD: cdbw.3,v 1.8 2014/02/06 15:50:40 rmind Exp $ -.\" -.\" Copyright (c) 2010 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Joerg Sonnenberger. -.\" 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 COPYRIGHT HOLDERS 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 -.\" COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, -.\" INCIDENTAL, SPECIAL, EXEMPLARY OR CONSEQUENTIAL DAMAGES (INCLUDING, -.\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -.\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED -.\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, -.\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT -.\" OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.Dd February 6, 2014 -.Dt CDBW 3 -.Os -.Sh NAME -.Nm cdbw_open , -.Nm cdbw_put , -.Nm cdbw_put_data , -.Nm cdbw_put_key , -.Nm cdbw_stable_seeder , -.Nm cdbw_output , -.Nm cdbw_close -.Nd create constant databases -.Sh SYNOPSIS -.In cdbw.h -.Ft "struct cdbw *" -.Fn cdbw_open "void" -.Ft int -.Fo cdbw_put -.Fa "struct cdbw *cdbw" -.Fa "const void *key" -.Fa "size_t keylen" -.Fa "const void *data" -.Fa "size_t datalen" -.Fc -.Ft int -.Fo cdbw_put_data -.Fa "struct cdbw *cdbw" -.Fa "const void *data" -.Fa "size_t datalen" -.Fa "uint32_t *index" -.Fc -.Ft int -.Fo cdbw_put_key -.Fa "struct cdbw *cdbw" -.Fa "const void *key" -.Fa "size_t keylen" -.Fa "uint32_t index" -.Fc -.Ft uint32_t -.Fo cdbw_stable_seeder -.Fa "void" -.Fc -.Ft int -.Fo cdbw_output -.Fa "struct cdbw *cdbw" -.Fa "int output" -.Fa "const char descr[16]" -.Fa "uint32_t (*seedgen)(void)" -.Fc -.Ft void -.Fn cdbw_close "struct cdbw *cdbw" -.Sh DESCRIPTION -The -.Nm cdbw -functions are used to create a constant databases for use with -.Xr cdbr 3 . -Details about the file format, including overhead and limitations, -can be found in -.Xr cdb 5 . -.Pp -.Fn cdbw_open -prepares a new -.Nm cdb -writer. -The function returns a handle to pass to the other functions. -.Pp -.Fn cdbw_close -frees all resources associated with the handle. -.Pp -.Fn cdbw_put -adds the given (key,value) pair after checking for a duplicate key. -.Fn cdbw_put_data -adds the given value to the writer without adding a key reference. -The returned index can be used in subsequent calls to -.Fn cdbw_put_key -to add one or more keys pointing to this value. -.Fn cdbw_put_key -checks for duplicate keys and valid index arguments. -On success it adds the given key. -.Pp -.Fn cdbw_output -computes the database file and writes it to the given descriptor. -The function returns an error if the file cannot be written correctly. -The -.Fa descr -parameter provides a human readable description of the database content. -The -.Fa seedgen -parameter can be used to override the default PRNG. -The bitwise layout of the output depends on the chosen seed. -The function should return a different value for each invocation. -The -.Fn cdbw_stable_seeder -can be used to create reproducible output. -It may be slower than the default. -.Sh SEE ALSO -.Xr cdbr 3 , -.Xr cdb 5 -.Sh HISTORY -Support for the -.Nm cdb -format first appeared in -.Nx 6.0 . -.Sh AUTHORS -The -.Nm cdbr -and -.Nm cdbw -functions have been written by -.An Joerg Sonnenberger Aq Mt joerg@NetBSD.org . diff --git a/lib/libc/cdb/cdbw.c b/lib/libc/cdb/cdbw.c deleted file mode 100644 index 379a6d50b..000000000 --- a/lib/libc/cdb/cdbw.c +++ /dev/null @@ -1,623 +0,0 @@ -/* $NetBSD: cdbw.c,v 1.5 2012/07/21 22:49:37 joerg Exp $ */ -/*- - * Copyright (c) 2009, 2010 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Joerg Sonnenberger. - * - * 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 COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: cdbw.c,v 1.5 2012/07/21 22:49:37 joerg Exp $"); - -#include "namespace.h" - -#if !HAVE_NBTOOL_CONFIG_H || HAVE_SYS_ENDIAN_H -#include -#endif -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(cdbw_close,_cdbw_close) -__weak_alias(cdbw_open,_cdbw_open) -__weak_alias(cdbw_output,_cdbw_output) -__weak_alias(cdbw_put,_cdbw_put) -__weak_alias(cdbw_put_data,_cdbw_put_data) -__weak_alias(cdbw_put_key,_cdbw_put_key) -#endif - -struct key_hash { - SLIST_ENTRY(key_hash) link; - uint32_t hashes[3]; - uint32_t idx; - void *key; - size_t keylen; -}; - -SLIST_HEAD(key_hash_head, key_hash); - -struct cdbw { - size_t data_counter; - size_t data_allocated; - size_t data_size; - size_t *data_len; - void **data_ptr; - - size_t hash_size; - struct key_hash_head *hash; - size_t key_counter; -}; - - /* Max. data counter that allows the index size to be 32bit. */ -static const uint32_t max_data_counter = 0xccccccccU; - -struct cdbw * -cdbw_open(void) -{ - struct cdbw *cdbw; - size_t i; - - cdbw = calloc(sizeof(*cdbw), 1); - if (cdbw == NULL) - return NULL; - - cdbw->hash_size = 1024; - cdbw->hash = calloc(cdbw->hash_size, sizeof(*cdbw->hash)); - if (cdbw->hash == NULL) { - free(cdbw); - return NULL; - } - - for (i = 0; i < cdbw->hash_size; ++i) - SLIST_INIT(cdbw->hash + i); - - return cdbw; -} - -int -cdbw_put(struct cdbw *cdbw, const void *key, size_t keylen, - const void *data, size_t datalen) -{ - uint32_t idx; - int rv; - - rv = cdbw_put_data(cdbw, data, datalen, &idx); - if (rv) - return rv; - rv = cdbw_put_key(cdbw, key, keylen, idx); - if (rv) { - --cdbw->data_counter; - free(cdbw->data_ptr[cdbw->data_counter]); - cdbw->data_size -= datalen; - return rv; - } - return 0; -} - -int -cdbw_put_data(struct cdbw *cdbw, const void *data, size_t datalen, - uint32_t *idx) -{ - - if (cdbw->data_counter == max_data_counter) - return -1; - - if (cdbw->data_size + datalen < cdbw->data_size || - cdbw->data_size + datalen > 0xffffffffU) - return -1; /* Overflow */ - - if (cdbw->data_allocated == cdbw->data_counter) { - void **new_data_ptr; - size_t *new_data_len; - size_t new_allocated; - - if (cdbw->data_allocated == 0) - new_allocated = 256; - else - new_allocated = cdbw->data_allocated * 2; - - new_data_ptr = realloc(cdbw->data_ptr, - sizeof(*cdbw->data_ptr) * new_allocated); - if (new_data_ptr == NULL) - return -1; - cdbw->data_ptr = new_data_ptr; - - new_data_len = realloc(cdbw->data_len, - sizeof(*cdbw->data_len) * new_allocated); - if (new_data_len == NULL) - return -1; - cdbw->data_len = new_data_len; - - cdbw->data_allocated = new_allocated; - } - - cdbw->data_ptr[cdbw->data_counter] = malloc(datalen); - if (cdbw->data_ptr[cdbw->data_counter] == NULL) - return -1; - memcpy(cdbw->data_ptr[cdbw->data_counter], data, datalen); - cdbw->data_len[cdbw->data_counter] = datalen; - cdbw->data_size += datalen; - *idx = cdbw->data_counter++; - return 0; -} - -int -cdbw_put_key(struct cdbw *cdbw, const void *key, size_t keylen, uint32_t idx) -{ - uint32_t hashes[3]; - struct key_hash_head *head, *head2, *new_head; - struct key_hash *key_hash; - size_t new_hash_size, i; - - if (idx >= cdbw->data_counter || - cdbw->key_counter == max_data_counter) - return -1; - - mi_vector_hash(key, keylen, 0, hashes); - - head = cdbw->hash + (hashes[0] & (cdbw->hash_size - 1)); - SLIST_FOREACH(key_hash, head, link) { - if (key_hash->keylen != keylen) - continue; - if (key_hash->hashes[0] != hashes[0]) - continue; - if (key_hash->hashes[1] != hashes[1]) - continue; - if (key_hash->hashes[2] != hashes[2]) - continue; - if (memcmp(key, key_hash->key, keylen)) - continue; - return -1; - } - key_hash = malloc(sizeof(*key_hash)); - if (key_hash == NULL) - return -1; - key_hash->key = malloc(keylen); - if (key_hash->key == NULL) { - free(key_hash); - return -1; - } - memcpy(key_hash->key, key, keylen); - key_hash->hashes[0] = hashes[0]; - key_hash->hashes[1] = hashes[1]; - key_hash->hashes[2] = hashes[2]; - key_hash->keylen = keylen; - key_hash->idx = idx; - SLIST_INSERT_HEAD(head, key_hash, link); - ++cdbw->key_counter; - - if (cdbw->key_counter <= cdbw->hash_size) - return 0; - - /* Try to resize the hash table, but ignore errors. */ - new_hash_size = cdbw->hash_size * 2; - new_head = calloc(sizeof(*new_head), new_hash_size); - if (new_head == NULL) - return 0; - - head = &cdbw->hash[hashes[0] & (cdbw->hash_size - 1)]; - for (i = 0; i < new_hash_size; ++i) - SLIST_INIT(new_head + i); - - for (i = 0; i < cdbw->hash_size; ++i) { - head = cdbw->hash + i; - - while ((key_hash = SLIST_FIRST(head)) != NULL) { - SLIST_REMOVE_HEAD(head, link); - head2 = new_head + - (key_hash->hashes[0] & (new_hash_size - 1)); - SLIST_INSERT_HEAD(head2, key_hash, link); - } - } - free(cdbw->hash); - cdbw->hash_size = new_hash_size; - cdbw->hash = new_head; - - return 0; -} - -void -cdbw_close(struct cdbw *cdbw) -{ - struct key_hash_head *head; - struct key_hash *key_hash; - size_t i; - - for (i = 0; i < cdbw->hash_size; ++i) { - head = cdbw->hash + i; - while ((key_hash = SLIST_FIRST(head)) != NULL) { - SLIST_REMOVE_HEAD(head, link); - free(key_hash->key); - free(key_hash); - } - } - - for (i = 0; i < cdbw->data_counter; ++i) - free(cdbw->data_ptr[i]); - free(cdbw->data_ptr); - free(cdbw->data_len); - free(cdbw->hash); - free(cdbw); -} - -uint32_t -cdbw_stable_seeder(void) -{ - return 0; -} - -#define unused 0xffffffffU - -struct vertex { - uint32_t l_edge, m_edge, r_edge; -}; - -struct edge { - uint32_t idx; - - uint32_t left, middle, right; - uint32_t l_prev, m_prev, l_next; - uint32_t r_prev, m_next, r_next; -}; - -struct state { - uint32_t data_entries; - uint32_t entries; - uint32_t keys; - uint32_t seed; - - uint32_t *g; - char *visited; - - struct vertex *verts; - struct edge *edges; - uint32_t output_index; - uint32_t *output_order; -}; - -static void -remove_vertex(struct state *state, struct vertex *v) -{ - struct edge *e; - struct vertex *vl, *vm, *vr; - - if (v->l_edge != unused && v->m_edge != unused) - return; - if (v->l_edge != unused && v->r_edge != unused) - return; - if (v->m_edge != unused && v->r_edge != unused) - return; - if (v->l_edge == unused && v->m_edge == unused && v->r_edge == unused) - return; - - if (v->l_edge != unused) { - e = &state->edges[v->l_edge]; - if (e->l_next != unused) - return; - } else if (v->m_edge != unused) { - e = &state->edges[v->m_edge]; - if (e->m_next != unused) - return; - } else { - if (v->r_edge == unused) - abort(); - e = &state->edges[v->r_edge]; - if (e->r_next != unused) - return; - } - - state->output_order[--state->output_index] = e - state->edges; - - vl = &state->verts[e->left]; - vm = &state->verts[e->middle]; - vr = &state->verts[e->right]; - - if (e->l_prev == unused) - vl->l_edge = e->l_next; - else - state->edges[e->l_prev].l_next = e->l_next; - if (e->l_next != unused) - state->edges[e->l_next].l_prev = e->l_prev; - - if (e->m_prev == unused) - vm->m_edge = e->m_next; - else - state->edges[e->m_prev].m_next = e->m_next; - if (e->m_next != unused) - state->edges[e->m_next].m_prev = e->m_prev; - - if (e->r_prev == unused) - vr->r_edge = e->r_next; - else - state->edges[e->r_prev].r_next = e->r_next; - if (e->r_next != unused) - state->edges[e->r_next].r_prev = e->r_prev; -} - -static int -build_graph(struct cdbw *cdbw, struct state *state) -{ - struct key_hash_head *head; - struct key_hash *key_hash; - struct vertex *v; - struct edge *e; - uint32_t hashes[3]; - size_t i; - - e = state->edges; - for (i = 0; i < cdbw->hash_size; ++i) { - head = &cdbw->hash[i]; - SLIST_FOREACH(key_hash, head, link) { - e->idx = key_hash->idx; - mi_vector_hash(key_hash->key, key_hash->keylen, - state->seed, hashes); - e->left = hashes[0] % state->entries; - e->middle = hashes[1] % state->entries; - e->right = hashes[2] % state->entries; - - if (e->left == e->middle) - return -1; - if (e->left == e->right) - return -1; - if (e->middle == e->right) - return -1; - - ++e; - } - } - - for (i = 0; i < state->entries; ++i) { - v = state->verts + i; - v->l_edge = unused; - v->m_edge = unused; - v->r_edge = unused; - } - - for (i = 0; i < state->keys; ++i) { - e = state->edges + i; - v = state->verts + e->left; - if (v->l_edge != unused) - state->edges[v->l_edge].l_prev = i; - e->l_next = v->l_edge; - e->l_prev = unused; - v->l_edge = i; - - v = &state->verts[e->middle]; - if (v->m_edge != unused) - state->edges[v->m_edge].m_prev = i; - e->m_next = v->m_edge; - e->m_prev = unused; - v->m_edge = i; - - v = &state->verts[e->right]; - if (v->r_edge != unused) - state->edges[v->r_edge].r_prev = i; - e->r_next = v->r_edge; - e->r_prev = unused; - v->r_edge = i; - } - - state->output_index = state->keys; - for (i = 0; i < state->entries; ++i) - remove_vertex(state, state->verts + i); - - i = state->keys; - while (i > 0 && i > state->output_index) { - --i; - e = state->edges + state->output_order[i]; - remove_vertex(state, state->verts + e->left); - remove_vertex(state, state->verts + e->middle); - remove_vertex(state, state->verts + e->right); - } - - return state->output_index == 0 ? 0 : -1; -} - -static void -assign_nodes(struct state *state) -{ - struct edge *e; - size_t i; - - for (i = 0; i < state->keys; ++i) { - e = state->edges + state->output_order[i]; - - if (!state->visited[e->left]) { - state->g[e->left] = - (2 * state->data_entries + e->idx - - state->g[e->middle] - state->g[e->right]) - % state->data_entries; - } else if (!state->visited[e->middle]) { - state->g[e->middle] = - (2 * state->data_entries + e->idx - - state->g[e->left] - state->g[e->right]) - % state->data_entries; - } else { - state->g[e->right] = - (2 * state->data_entries + e->idx - - state->g[e->left] - state->g[e->middle]) - % state->data_entries; - } - state->visited[e->left] = 1; - state->visited[e->middle] = 1; - state->visited[e->right] = 1; - } -} - -static size_t -compute_size(uint32_t size) -{ - if (size < 0x100) - return 1; - else if (size < 0x10000) - return 2; - else - return 4; -} - -#define COND_FLUSH_BUFFER(n) do { \ - if (__predict_false(cur_pos + (n) >= sizeof(buf))) { \ - ret = write(fd, buf, cur_pos); \ - if (ret == -1 || (size_t)ret != cur_pos) \ - return -1; \ - cur_pos = 0; \ - } \ -} while (/* CONSTCOND */ 0) - -static int -print_hash(struct cdbw *cdbw, struct state *state, int fd, const char *descr) -{ - uint32_t data_size; - uint8_t buf[90000]; - size_t i, size, size2, cur_pos; - ssize_t ret; - - memcpy(buf, "NBCDB\n\0", 7); - buf[7] = 1; - strncpy((char *)buf + 8, descr, 16); - le32enc(buf + 24, cdbw->data_size); - le32enc(buf + 28, cdbw->data_counter); - le32enc(buf + 32, state->entries); - le32enc(buf + 36, state->seed); - cur_pos = 40; - - size = compute_size(state->entries); - for (i = 0; i < state->entries; ++i) { - COND_FLUSH_BUFFER(4); - le32enc(buf + cur_pos, state->g[i]); - cur_pos += size; - } - size2 = compute_size(cdbw->data_size); - size = size * state->entries % size2; - if (size != 0) { - size = size2 - size; - COND_FLUSH_BUFFER(4); - le32enc(buf + cur_pos, 0); - cur_pos += size; - } - for (data_size = 0, i = 0; i < cdbw->data_counter; ++i) { - COND_FLUSH_BUFFER(4); - le32enc(buf + cur_pos, data_size); - cur_pos += size2; - data_size += cdbw->data_len[i]; - } - COND_FLUSH_BUFFER(4); - le32enc(buf + cur_pos, data_size); - cur_pos += size2; - - for (i = 0; i < cdbw->data_counter; ++i) { - COND_FLUSH_BUFFER(cdbw->data_len[i]); - if (cdbw->data_len[i] < sizeof(buf)) { - memcpy(buf + cur_pos, cdbw->data_ptr[i], - cdbw->data_len[i]); - cur_pos += cdbw->data_len[i]; - } else { - ret = write(fd, cdbw->data_ptr[i], cdbw->data_len[i]); - if (ret == -1 || (size_t)ret != cdbw->data_len[i]) - return -1; - } - } - if (cur_pos != 0) { - ret = write(fd, buf, cur_pos); - if (ret == -1 || (size_t)ret != cur_pos) - return -1; - } - return 0; -} - -int -cdbw_output(struct cdbw *cdbw, int fd, const char descr[16], - uint32_t (*seedgen)(void)) -{ - struct state state; - int rv; - - if (cdbw->data_counter == 0 || cdbw->key_counter == 0) { - state.entries = 0; - state.seed = 0; - print_hash(cdbw, &state, fd, descr); - return 0; - } - -#if HAVE_NBTOOL_CONFIG_H - if (seedgen == NULL) - seedgen = cdbw_stable_seeder; -#else - if (seedgen == NULL) - seedgen = arc4random; -#endif - - rv = 0; - - state.keys = cdbw->key_counter; - state.data_entries = cdbw->data_counter; - state.entries = state.keys + (state.keys + 3) / 4; - if (state.entries < 10) - state.entries = 10; - -#define NALLOC(var, n) var = calloc(sizeof(*var), n) - NALLOC(state.g, state.entries); - NALLOC(state.visited, state.entries); - NALLOC(state.verts, state.entries); - NALLOC(state.edges, state.entries); - NALLOC(state.output_order, state.keys); -#undef NALLOC - - if (state.g == NULL || state.visited == NULL || state.verts == NULL || - state.edges == NULL || state.output_order == NULL) { - rv = -1; - goto release; - } - - state.seed = 0; - do { - if (seedgen == cdbw_stable_seeder) - ++state.seed; - else - state.seed = (*seedgen)(); - } while (build_graph(cdbw, &state)); - - assign_nodes(&state); - rv = print_hash(cdbw, &state, fd, descr); - -release: - free(state.g); - free(state.visited); - free(state.verts); - free(state.edges); - free(state.output_order); - - return rv; -} diff --git a/lib/libc/citrus/Makefile.inc b/lib/libc/citrus/Makefile.inc deleted file mode 100644 index 39b513a22..000000000 --- a/lib/libc/citrus/Makefile.inc +++ /dev/null @@ -1,29 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.8 2010/05/30 08:28:53 tnozaki Exp $ - -# sources -.PATH: ${ARCHDIR}/citrus ${.CURDIR}/citrus - -.if !defined(__MINIX) -MODULE_SHLIB_MAJOR!= . ${NETBSDSRCDIR}/lib/i18n_module/shlib_version ; echo $$major -.else -MODULE_SHLIB_MAJOR=1 -.endif # !defined(__MINIX) -CPPFLAGS.citrus_module.c+=-DI18NMODULE_MAJOR=${MODULE_SHLIB_MAJOR} -SRCS+= citrus_bcs.c citrus_bcs_strtol.c citrus_bcs_strtoul.c \ - citrus_csmapper.c citrus_ctype.c citrus_ctype_fallback.c \ - citrus_db.c citrus_db_hash.c citrus_esdb.c citrus_hash.c \ - citrus_iconv.c citrus_lookup.c \ - citrus_mapper.c citrus_memstream.c citrus_mmap.c citrus_module.c \ - citrus_none.c citrus_stdenc.c -SRCS+= citrus_lc_ctype.c \ - citrus_lc_monetary.c \ - citrus_lc_numeric.c \ - citrus_lc_time.c \ - citrus_lc_messages.c -CPPFLAGS.citrus_bcs_strtol.c+= -I${LIBCDIR}/../../common/lib/libc/stdlib -CPPFLAGS.citrus_bcs_strtoul.c+= -I${LIBCDIR}/../../common/lib/libc/stdlib -CPPFLAGS.citrus_lc_ctype.c+= -I${LIBCDIR}/locale -CPPFLAGS.citrus_lc_monetary.c+= -I${LIBCDIR}/locale -CPPFLAGS.citrus_lc_numeric.c+= -I${LIBCDIR}/locale -CPPFLAGS.citrus_lc_time.c+= -I${LIBCDIR}/locale -CPPFLAGS.citrus_lc_messages.c+= -I${LIBCDIR}/locale diff --git a/lib/libc/citrus/citrus_aliasname_local.h b/lib/libc/citrus/citrus_aliasname_local.h deleted file mode 100644 index d76cb418b..000000000 --- a/lib/libc/citrus/citrus_aliasname_local.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: citrus_aliasname_local.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ALIASNAME_LOCAL_H_ -#define _CITRUS_ALIASNAME_LOCAL_H_ - -static __inline const char * -__unaliasname(const char *dbname, const char *alias, - void *buf, size_t bufsize) -{ - return _lookup_simple(dbname, alias, - buf, bufsize, _LOOKUP_CASE_SENSITIVE); -} - -static __inline int -__isforcemapping(const char *name) -{ - _DIAGASSERT(name != NULL); - - return _bcs_strcasecmp("/force", name); -} - -#endif /*_CITRUS_ALIASNAME_LOCAL_H_*/ diff --git a/lib/libc/citrus/citrus_bcs.c b/lib/libc/citrus/citrus_bcs.c deleted file mode 100644 index b14186de6..000000000 --- a/lib/libc/citrus/citrus_bcs.c +++ /dev/null @@ -1,171 +0,0 @@ -/* $NetBSD: citrus_bcs.c,v 1.5 2005/05/14 17:55:42 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_bcs.c,v 1.5 2005/05/14 17:55:42 tshiozak Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef HOSTPROG -#include "namespace.h" -#endif -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" - -/* - * case insensitive comparison between two C strings. - */ -int -_citrus_bcs_strcasecmp(const char * __restrict str1, - const char * __restrict str2) -{ - int c1 = 1, c2 = 1; - - while (c1 && c2 && c1 == c2) { - c1 = _bcs_toupper(*str1++); - c2 = _bcs_toupper(*str2++); - } - - return ((c1 == c2) ? 0 : ((c1 > c2) ? 1 : -1)); -} - -/* - * case insensitive comparison between two C strings with limitation of length. - */ -int -_citrus_bcs_strncasecmp(const char * __restrict str1, - const char * __restrict str2, size_t sz) -{ - int c1 = 1, c2 = 1; - - while (c1 && c2 && c1 == c2 && sz != 0) { - c1 = _bcs_toupper(*str1++); - c2 = _bcs_toupper(*str2++); - sz--; - } - - return ((c1 == c2) ? 0 : ((c1 > c2) ? 1 : -1)); -} - -/* - * skip white space characters. - */ -const char * -_citrus_bcs_skip_ws(const char *p) -{ - - while (*p && _bcs_isspace(*p)) - p++; - - return (p); -} - -/* - * skip non white space characters. - */ -const char * -_citrus_bcs_skip_nonws(const char *p) -{ - - while (*p && !_bcs_isspace(*p)) - p++; - - return (p); -} - -/* - * skip white space characters with limitation of length. - */ -const char * -_citrus_bcs_skip_ws_len(const char * __restrict p, size_t * __restrict len) -{ - - while (*p && *len > 0 && _bcs_isspace(*p)) { - p++; - (*len)--; - } - - return (p); -} - -/* - * skip non white space characters with limitation of length. - */ -const char * -_citrus_bcs_skip_nonws_len(const char * __restrict p, size_t * __restrict len) -{ - - while (*p && *len > 0 && !_bcs_isspace(*p)) { - p++; - (*len)--; - } - - return (p); -} - -/* - * truncate trailing white space characters. - */ -void -_citrus_bcs_trunc_rws_len(const char * __restrict p, size_t * __restrict len) -{ - - while (*len > 0 && _bcs_isspace(p[*len - 1])) - (*len)--; -} - -/* - * destructive transliterate to lowercase. - */ -void -_citrus_bcs_convert_to_lower(char *s) -{ - while (*s) { - *s = _bcs_tolower(*s); - s++; - } -} - -/* - * destructive transliterate to uppercase. - */ -void -_citrus_bcs_convert_to_upper(char *s) -{ - while (*s) { - *s = _bcs_toupper(*s); - s++; - } -} diff --git a/lib/libc/citrus/citrus_bcs.h b/lib/libc/citrus/citrus_bcs.h deleted file mode 100644 index 784da76da..000000000 --- a/lib/libc/citrus/citrus_bcs.h +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: citrus_bcs.h,v 1.6 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_BCS_H_ -#define _CITRUS_BCS_H_ - -/* - * predicate/conversion for basic character set. - * - * `Basic character set' is a term defined in the ISO C standard. - * Citrus bcs is, if anything, close to `portable character set' - * defined in the POSIX. - */ - -#define _CITRUS_BCS_PRED(_name_, _cond_) \ -static __inline int _citrus_bcs_##_name_(uint8_t c) { return (_cond_); } - -/* - * predicates. - * Unlike predicates defined in ctype.h, these do not accept EOF. - */ -_CITRUS_BCS_PRED(isblank, c == ' ' || c == '\t') -_CITRUS_BCS_PRED(iseol, c == '\n' || c == '\r') -_CITRUS_BCS_PRED(isspace, - _citrus_bcs_isblank(c) || _citrus_bcs_iseol(c) || - c == '\f' || c == '\v') -_CITRUS_BCS_PRED(isdigit, c >= '0' && c <= '9') -_CITRUS_BCS_PRED(isupper, c >= 'A' && c <= 'Z') -_CITRUS_BCS_PRED(islower, c >= 'a' && c <= 'z') -_CITRUS_BCS_PRED(isalpha, _citrus_bcs_isupper(c) || _citrus_bcs_islower(c)) -_CITRUS_BCS_PRED(isalnum, _citrus_bcs_isdigit(c) || _citrus_bcs_isalpha(c)) -_CITRUS_BCS_PRED(isxdigit, - _citrus_bcs_isdigit(c) || - (c >= 'A' && c <= 'F') || (c >= 'a' && c <= 'f')) - -/* - * transliterate between uppercase and lowercase. - * Unlike transliterator defined in ctype.h, these do not accept EOF. - */ -static __inline uint8_t -_citrus_bcs_toupper(uint8_t c) -{ - return (_citrus_bcs_islower(c) ? (c - 'a' + 'A') : c); -} - -static __inline uint8_t -_citrus_bcs_tolower(uint8_t c) -{ - return (_citrus_bcs_isupper(c) ? (c - 'A' + 'a') : c); -} - -__BEGIN_DECLS -int _citrus_bcs_strcasecmp(const char * __restrict, const char * __restrict); -int _citrus_bcs_strncasecmp(const char * __restrict, const char * __restrict, - size_t); -const char *_citrus_bcs_skip_ws(const char * __restrict); -const char *_citrus_bcs_skip_nonws(const char * __restrict); -const char *_citrus_bcs_skip_ws_len(const char * __restrict, - size_t * __restrict); -const char *_citrus_bcs_skip_nonws_len(const char * __restrict, - size_t * __restrict); -void _citrus_bcs_trunc_rws_len(const char * __restrict, size_t * __restrict); -void _citrus_bcs_convert_to_lower(char *); -void _citrus_bcs_convert_to_upper(char *); - -long int _citrus_bcs_strtol( - const char * __restrict, char ** __restrict, int); -unsigned long int _citrus_bcs_strtoul( - const char * __restrict, char ** __restrict, int); - -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_bcs_strtol.c b/lib/libc/citrus/citrus_bcs_strtol.c deleted file mode 100644 index 618bc19f3..000000000 --- a/lib/libc/citrus/citrus_bcs_strtol.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: citrus_bcs_strtol.c,v 1.4 2013/04/26 21:20:47 joerg Exp $ */ - -/*- - * Copyright (c) 2005 The DragonFly Project. All rights reserved. - * Copyright (c) 2003, 2008 Citrus Project, - * 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 -__RCSID("$NetBSD: citrus_bcs_strtol.c,v 1.4 2013/04/26 21:20:47 joerg Exp $"); - -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" - -#define BCS_ONLY - -#define _FUNCNAME _bcs_strtol -#define __INT long int -#define __INT_MIN LONG_MIN -#define __INT_MAX LONG_MAX - -#undef isspace -#define isspace(c) _bcs_isspace(c) - -#undef isdigit -#define isdigit(c) _bcs_isdigit(c) - -#undef isalpha -#define isalpha(c) _bcs_isalpha(c) - -#undef isupper -#define isupper(c) _bcs_isupper(c) - -#include "_strtol.h" diff --git a/lib/libc/citrus/citrus_bcs_strtoul.c b/lib/libc/citrus/citrus_bcs_strtoul.c deleted file mode 100644 index c9ffe19eb..000000000 --- a/lib/libc/citrus/citrus_bcs_strtoul.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: citrus_bcs_strtoul.c,v 1.5 2013/04/26 21:20:48 joerg Exp $ */ - -/*- - * Copyright (c) 2005 The DragonFly Project. All rights reserved. - * Copyright (c) 2003, 2008 Citrus Project, - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if !defined(lint) -__RCSID("$NetBSD: citrus_bcs_strtoul.c,v 1.5 2013/04/26 21:20:48 joerg Exp $"); -#endif /* not lint */ - -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" - -#define BCS_ONLY - -#define _FUNCNAME _bcs_strtoul -#define __UINT unsigned long int -#define __UINT_MAX ULONG_MAX - -#undef isspace -#define isspace(c) _bcs_isspace(c) - -#undef isdigit -#define isdigit(c) _bcs_isdigit(c) - -#undef isalpha -#define isalpha(c) _bcs_isalpha(c) - -#undef isupper -#define isupper(c) _bcs_isupper(c) - -#include "_strtoul.h" diff --git a/lib/libc/citrus/citrus_csmapper.c b/lib/libc/citrus/citrus_csmapper.c deleted file mode 100644 index 4e8f445c5..000000000 --- a/lib/libc/citrus/citrus_csmapper.c +++ /dev/null @@ -1,388 +0,0 @@ -/* $NetBSD: citrus_csmapper.c,v 1.11 2011/11/20 07:43:52 tnozaki Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_csmapper.c,v 1.11 2011/11/20 07:43:52 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_module.h" -#include "citrus_hash.h" -#include "citrus_mapper.h" -#include "citrus_csmapper.h" -#include "citrus_pivot_file.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" -#include "citrus_lookup.h" - -#ifdef _REENTRANT -static rwlock_t lock = RWLOCK_INITIALIZER; -#endif -static struct _citrus_mapper_area *maparea = NULL; - -#define CS_ALIAS _PATH_CSMAPPER "/charset.alias" -#define CS_PIVOT _PATH_CSMAPPER "/charset.pivot" - - -/* ---------------------------------------------------------------------- */ - -static int -get32(struct _region *r, uint32_t *rval) -{ - if (_region_size(r) != 4) - return EFTYPE; - - memcpy(rval, _region_head(r), (size_t)4); - *rval = be32toh(*rval); - - return 0; -} - -static int -open_subdb(struct _citrus_db **subdb, struct _citrus_db *db, const char *src) -{ - int ret; - struct _region r; - - ret = _db_lookup_by_s(db, src, &r, NULL); - if (ret) - return ret; - ret = _db_open(subdb, &r, _CITRUS_PIVOT_SUB_MAGIC, _db_hash_std, NULL); - if (ret) - return ret; - - return 0; -} - - -#define NO_SUCH_FILE EOPNOTSUPP -static int -find_best_pivot_pvdb(const char *src, const char *dst, char *pivot, - size_t pvlen, unsigned long *rnorm) -{ - int ret, num, i; - struct _region fr, r1, r2; - struct _citrus_db *db1, *db2, *db3; - char buf[LINE_MAX]; - unsigned long norm; - uint32_t val32; - - ret = _map_file(&fr, CS_PIVOT ".pvdb"); - if (ret) { - if (ret == ENOENT) - ret = NO_SUCH_FILE; - return ret; - } - ret = _db_open(&db1, &fr, _CITRUS_PIVOT_MAGIC, _db_hash_std, NULL); - if (ret) - goto quit1; - ret = open_subdb(&db2, db1, src); - if (ret) - goto quit2; - - num = _db_get_num_entries(db2); - *rnorm = ULONG_MAX; - for (i = 0; i < num; i++) { - /* iterate each pivot */ - ret = _db_get_entry(db2, i, &r1, &r2); - if (ret) - goto quit3; - /* r1:pivot name, r2:norm among src and pivot */ - ret = get32(&r2, &val32); - if (ret) - goto quit3; - norm = val32; - snprintf(buf, sizeof(buf), "%.*s", - (int)_region_size(&r1), (char *)_region_head(&r1)); - /* buf: pivot name */ - ret = open_subdb(&db3, db1, buf); - if (ret) - goto quit3; - if (_db_lookup_by_s(db3, dst, &r2, NULL) != 0) - /* don't break the loop, test all src/dst pairs. */ - goto quit4; - /* r2: norm among pivot and dst */ - ret = get32(&r2, &val32); - if (ret) - goto quit4; - norm += val32; - /* judge minimum norm */ - if (norm < *rnorm) { - *rnorm = norm; - strlcpy(pivot, buf, pvlen); - } -quit4: - _db_close(db3); - if (ret) - goto quit3; - } -quit3: - _db_close(db2); -quit2: - _db_close(db1); -quit1: - _unmap_file(&fr); - if (ret) - return ret; - - if (*rnorm == ULONG_MAX) - return ENOENT; - - return 0; -} - -/* ---------------------------------------------------------------------- */ - -struct zone { - const char *begin, *end; -}; - -struct parse_arg { - char dst[PATH_MAX]; - unsigned long norm; -}; - -static int -parse_line(struct parse_arg *pa, struct _region *r) -{ - char buf[20]; - struct zone z1, z2; - size_t len; - - len = _region_size(r); - z1.begin = _bcs_skip_ws_len(_region_head(r), &len); - if (len == 0) - return EFTYPE; - z1.end = _bcs_skip_nonws_len(z1.begin, &len); - if (len == 0) - return EFTYPE; - z2.begin = _bcs_skip_ws_len(z1.end, &len); - if (len == 0) - return EFTYPE; - z2.end = _bcs_skip_nonws_len(z2.begin, &len); - - /* z1 : dst name, z2 : norm */ - snprintf(pa->dst, sizeof(pa->dst), - "%.*s", (int)(z1.end-z1.begin), z1.begin); - snprintf(buf, sizeof(buf), - "%.*s", (int)(z2.end-z2.begin), z2.begin); - pa->norm = _bcs_strtoul(buf, NULL, 0); - - return 0; -} - -static int -find_dst(struct parse_arg *pasrc, const char *dst) -{ - int ret; - struct parse_arg padst; - struct _lookup *cl; - struct _region data; - - ret = _lookup_seq_open(&cl, CS_PIVOT, _LOOKUP_CASE_IGNORE); - if (ret) - return ret; - - ret = _lookup_seq_lookup(cl, pasrc->dst, &data); - while (ret == 0) { - ret = parse_line(&padst, &data); - if (ret) - break; - if (strcmp(dst, padst.dst) == 0) { - pasrc->norm += padst.norm; - break; - } - ret = _lookup_seq_next(cl, NULL, &data); - } - _lookup_seq_close(cl); - - return ret; -} - -static int -find_best_pivot_lookup(const char *src, const char *dst, char *pivot, - size_t pvlen, unsigned long *rnorm) -{ - int ret; - struct _lookup *cl; - struct _region data; - struct parse_arg pa; - unsigned long norm_min; - char pivot_min[PATH_MAX]; - - ret = _lookup_seq_open(&cl, CS_PIVOT, _LOOKUP_CASE_IGNORE); - if (ret) - return ret; - - norm_min = ULONG_MAX; - - /* find pivot code */ - ret = _lookup_seq_lookup(cl, src, &data); - while (ret == 0) { - ret = parse_line(&pa, &data); - if (ret) - break; - ret = find_dst(&pa, dst); - if (ret) - break; - if (pa.norm < norm_min) { - norm_min = pa.norm; - strlcpy(pivot_min, pa.dst, sizeof(pivot_min)); - } - ret = _lookup_seq_next(cl, NULL, &data); - } - _lookup_seq_close(cl); - - if (ret != ENOENT) - return ret; - if (norm_min == ULONG_MAX) - return ENOENT; - strlcpy(pivot, pivot_min, pvlen); - if (rnorm) - *rnorm = norm_min; - - return 0; -} - -static int -find_best_pivot(const char *src, const char *dst, char *pivot, size_t pvlen, - unsigned long *rnorm) -{ - int ret; - - ret = find_best_pivot_pvdb(src, dst, pivot, pvlen, rnorm); - if (ret == NO_SUCH_FILE) - ret = find_best_pivot_lookup(src, dst, pivot, pvlen, rnorm); - - return ret; -} - -static __inline int -open_serial_mapper(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict * __restrict rcm, - const char *src, const char *pivot, const char *dst) -{ - char buf[PATH_MAX]; - - snprintf(buf, sizeof(buf), "%s/%s,%s/%s", src, pivot, pivot, dst); - - return _mapper_open_direct(ma, rcm, "mapper_serial", buf); -} - -static struct _citrus_csmapper *csm_none = NULL; -static int -get_none(struct _citrus_mapper_area *__restrict ma, - struct _citrus_csmapper *__restrict *__restrict rcsm) -{ - int ret; - - rwlock_wrlock(&lock); - if (csm_none) { - *rcsm = csm_none; - ret = 0; - goto quit; - } - - ret = _mapper_open_direct(ma, &csm_none, "mapper_none", ""); - if (ret) - goto quit; - _mapper_set_persistent(csm_none); - - *rcsm = csm_none; - ret = 0; -quit: - rwlock_unlock(&lock); - return ret; -} - -int -_citrus_csmapper_open(struct _citrus_csmapper * __restrict * __restrict rcsm, - const char * __restrict src, const char * __restrict dst, - uint32_t flags, unsigned long *rnorm) -{ - int ret; - char buf1[PATH_MAX], buf2[PATH_MAX], key[PATH_MAX], pivot[PATH_MAX]; - const char *realsrc, *realdst; - unsigned long norm; - - norm = 0; /* XXX gcc */ - - ret = _citrus_mapper_create_area(&maparea, _PATH_CSMAPPER); - if (ret) - return ret; - - realsrc = _lookup_alias(CS_ALIAS, src, buf1, sizeof(buf1), - _LOOKUP_CASE_IGNORE); - realdst = _lookup_alias(CS_ALIAS, dst, buf2, sizeof(buf2), - _LOOKUP_CASE_IGNORE); - if (!strcmp(realsrc, realdst)) { - ret = get_none(maparea, rcsm); - if (ret == 0 && rnorm != NULL) - *rnorm = 0; - return ret; - } - - snprintf(key, sizeof(key), "%s/%s", realsrc, realdst); - - ret = _mapper_open(maparea, rcsm, key); - if (ret == 0) { - if (rnorm != NULL) - *rnorm = 0; - return 0; - } - if (ret != ENOENT || (flags & _CSMAPPER_F_PREVENT_PIVOT)!=0) - return ret; - - ret = find_best_pivot(realsrc, realdst, pivot, sizeof(pivot), &norm); - if (ret) - return ret; - - ret = open_serial_mapper(maparea, rcsm, realsrc, pivot, realdst); - if (ret == 0 && rnorm != NULL) - *rnorm = norm; - - return ret; -} diff --git a/lib/libc/citrus/citrus_csmapper.h b/lib/libc/citrus/citrus_csmapper.h deleted file mode 100644 index 04f8d9b69..000000000 --- a/lib/libc/citrus/citrus_csmapper.h +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: citrus_csmapper.h,v 1.3 2013/06/24 17:28:35 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_CSMAPPER_H_ -#define _CITRUS_CSMAPPER_H_ - -#define _citrus_csmapper _citrus_mapper -#define _citrus_csmapper_close _citrus_mapper_close -#define _citrus_csmapper_convert _citrus_mapper_convert -#define _citrus_csmapper_init_state _citrus_mapper_init_state -#define _citrus_csmapper_get_state_size _citrus_mapper_get_state_size -#define _citrus_csmapper_get_src_max _citrus_mapper_get_src_max -#define _citrus_csmapper_get_dst_max _citrus_mapper_get_dst_max - -#define _CITRUS_CSMAPPER_F_PREVENT_PIVOT 0x00000001 -__BEGIN_DECLS -int _citrus_csmapper_open(struct _citrus_csmapper *__restrict *__restrict, - const char *__restrict, - const char *__restrict, uint32_t, - unsigned long *); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_ctype.c b/lib/libc/citrus/citrus_ctype.c deleted file mode 100644 index 0cac14117..000000000 --- a/lib/libc/citrus/citrus_ctype.c +++ /dev/null @@ -1,216 +0,0 @@ -/* $NetBSD: citrus_ctype.c,v 1.7 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)1999, 2000, 2001, 2002 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_ctype.c,v 1.7 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_ctype_fallback.h" -#include "citrus_none.h" -#include _CITRUS_DEFAULT_CTYPE_HEADER - -_citrus_ctype_rec_t _citrus_ctype_default = { - &_CITRUS_DEFAULT_CTYPE_OPS, /* cc_ops */ - NULL, /* cc_closure */ - NULL /* cc_module */ -}; - -#ifdef _I18N_DYNAMIC - -static int _initctypemodule(_citrus_ctype_t, char const *, _citrus_module_t, - void *, size_t, size_t); - -static int -_initctypemodule(_citrus_ctype_t cc, char const *modname, - _citrus_module_t handle, void *variable, size_t lenvar, - size_t szpriv) -{ - int ret; - _citrus_ctype_getops_t getops; - - _DIAGASSERT(cc != NULL); - - cc->cc_module = handle; - - getops = (_citrus_ctype_getops_t)_citrus_find_getops(cc->cc_module, - modname, - "ctype"); - if (getops == NULL) - return (EINVAL); - - cc->cc_ops = (_citrus_ctype_ops_rec_t *)malloc(sizeof(*cc->cc_ops)); - if (cc->cc_ops == NULL) - return (ENOMEM); - - ret = (*getops)(cc->cc_ops, sizeof(*cc->cc_ops), - _CITRUS_CTYPE_ABI_VERSION); - if (ret) - goto bad; - - /* If return ABI version is not expected, fixup it here*/ - switch (cc->cc_ops->co_abi_version) { - case 0x00000001: - cc->cc_ops->co_btowc = &_citrus_ctype_btowc_fallback; - cc->cc_ops->co_wctob = &_citrus_ctype_wctob_fallback; - /* FALLTHROUGH */ - case 0x00000002: - cc->cc_ops->co_mbsnrtowcs = &_citrus_ctype_mbsnrtowcs_fallback; - cc->cc_ops->co_wcsnrtombs = &_citrus_ctype_wcsnrtombs_fallback; - /* FALLTHROUGH */ - default: - break; - } - - /* validation check */ - if (cc->cc_ops->co_init == NULL || - cc->cc_ops->co_uninit == NULL || - cc->cc_ops->co_get_mb_cur_max == NULL || - cc->cc_ops->co_mblen == NULL || - cc->cc_ops->co_mbrlen == NULL || - cc->cc_ops->co_mbrtowc == NULL || - cc->cc_ops->co_mbsinit == NULL || - cc->cc_ops->co_mbsrtowcs == NULL || - cc->cc_ops->co_mbsnrtowcs == NULL || - cc->cc_ops->co_mbstowcs == NULL || - cc->cc_ops->co_mbtowc == NULL || - cc->cc_ops->co_wcrtomb == NULL || - cc->cc_ops->co_wcsrtombs == NULL || - cc->cc_ops->co_wcsnrtombs == NULL || - cc->cc_ops->co_wcstombs == NULL || - cc->cc_ops->co_wctomb == NULL || - cc->cc_ops->co_btowc == NULL || - cc->cc_ops->co_wctob == NULL) { - ret = EINVAL; - goto bad; - } - - /* init and get closure */ - ret = (*cc->cc_ops->co_init)( - &cc->cc_closure, variable, lenvar, szpriv); - if (ret) - goto bad; - - return (0); - -bad: - if (cc->cc_ops) - free(cc->cc_ops); - cc->cc_ops = NULL; - - return (ret); -} - -int -_citrus_ctype_open(_citrus_ctype_t *rcc, - char const *encname, void *variable, size_t lenvar, - size_t szpriv) -{ - int ret; - _citrus_module_t handle; - _citrus_ctype_t cc; - - _DIAGASSERT(encname != NULL); - _DIAGASSERT(!lenvar || variable!=NULL); - _DIAGASSERT(rcc != NULL); - - if (!strcmp(encname, _CITRUS_DEFAULT_CTYPE_NAME)) { - *rcc = &_citrus_ctype_default; - return (0); - } - ret = _citrus_load_module(&handle, encname); - if (ret) - return (ret); - - cc = calloc(1, sizeof(*cc)); - if (!cc) { - _citrus_unload_module(handle); - return (errno); - } - - ret = _initctypemodule(cc, encname, handle, variable, lenvar, szpriv); - if (ret) { - _citrus_unload_module(cc->cc_module); - free(cc); - return (ret); - } - - *rcc = cc; - - return (0); -} - -void -_citrus_ctype_close(_citrus_ctype_t cc) -{ - - _DIAGASSERT(cc != NULL); - - if (cc == &_citrus_ctype_default) - return; - (*cc->cc_ops->co_uninit)(cc->cc_closure); - free(cc->cc_ops); - _citrus_unload_module(cc->cc_module); - free(cc); -} - -#else -/* !_I18N_DYNAMIC */ - -int -/*ARGSUSED*/ -_citrus_ctype_open(_citrus_ctype_t *rcc, - char const *encname, void *variable, size_t lenvar, - size_t szpriv) -{ - if (!strcmp(encname, _CITRUS_DEFAULT_CTYPE_NAME)) { - *rcc = &_citrus_ctype_default; - return (0); - } - return (EINVAL); -} - -void -/*ARGSUSED*/ -_citrus_ctype_close(_citrus_ctype_t cc) -{ -} - -#endif diff --git a/lib/libc/citrus/citrus_ctype.h b/lib/libc/citrus/citrus_ctype.h deleted file mode 100644 index 3ece36487..000000000 --- a/lib/libc/citrus/citrus_ctype.h +++ /dev/null @@ -1,190 +0,0 @@ -/* $NetBSD: citrus_ctype.h,v 1.3 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_CTYPE_H_ -#define _CITRUS_CTYPE_H_ - -#include "citrus_ctype_local.h" - -typedef struct _citrus_ctype_rec *_citrus_ctype_t; - -__BEGIN_DECLS -int _citrus_ctype_open(_citrus_ctype_t * __restrict, - char const * __restrict, void * __restrict, - size_t, size_t); -void _citrus_ctype_close(_citrus_ctype_t); -__END_DECLS - -static __inline unsigned -_citrus_ctype_get_mb_cur_max(_citrus_ctype_t cc) -{ - - _DIAGASSERT(cc && cc->cc_ops); - return (*cc->cc_ops->co_get_mb_cur_max)(cc->cc_closure); -} - -static __inline int -_citrus_ctype_mblen(_citrus_ctype_t cc, const char *s, size_t n, int *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mblen && nresult); - return (*cc->cc_ops->co_mblen)(cc->cc_closure, s, n, nresult); -} - -static __inline int -_citrus_ctype_mbrlen(_citrus_ctype_t cc, const char *s, size_t n, - void *pspriv, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mbrlen && nresult); - return (*cc->cc_ops->co_mbrlen)(cc->cc_closure, s, n, pspriv, nresult); -} - -static __inline int -_citrus_ctype_mbrtowc(_citrus_ctype_t cc, wchar_t *pwc, const char *s, - size_t n, void *pspriv, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mbrtowc); - return (*cc->cc_ops->co_mbrtowc)(cc->cc_closure, pwc, s, n, pspriv, - nresult); -} - -static __inline int -_citrus_ctype_mbsinit(_citrus_ctype_t cc, void const *pspriv, int *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mbsinit && nresult); - return (*cc->cc_ops->co_mbsinit)(cc->cc_closure, pspriv, nresult); -} - -static __inline int -_citrus_ctype_mbsrtowcs(_citrus_ctype_t cc, wchar_t *pwcs, const char **s, - size_t n, void *pspriv, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mbsrtowcs && nresult); - return (*cc->cc_ops->co_mbsrtowcs)(cc->cc_closure, pwcs, s, n, pspriv, - nresult); -} - -static __inline int -_citrus_ctype_mbsnrtowcs(_citrus_ctype_t cc, wchar_t *pwcs, const char **s, - size_t in, size_t n, void *pspriv, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mbsnrtowcs && nresult); - return (*cc->cc_ops->co_mbsnrtowcs)(cc, pwcs, s, in, n, - pspriv, nresult); -} - -static __inline int -_citrus_ctype_mbstowcs(_citrus_ctype_t cc, wchar_t *pwcs, const char *s, - size_t n, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mbstowcs && nresult); - return (*cc->cc_ops->co_mbstowcs)(cc->cc_closure, pwcs, s, n, nresult); -} - -static __inline int -_citrus_ctype_mbtowc(_citrus_ctype_t cc, wchar_t *pw, const char *s, size_t n, - int *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_mbtowc && nresult); - return (*cc->cc_ops->co_mbtowc)(cc->cc_closure, pw, s, n, nresult); -} - -static __inline int -_citrus_ctype_wcrtomb(_citrus_ctype_t cc, char *s, wchar_t wc, - void *pspriv, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wcrtomb && nresult); - return (*cc->cc_ops->co_wcrtomb)(cc->cc_closure, s, wc, pspriv, - nresult); -} - -static __inline int -_citrus_ctype_wcsrtombs(_citrus_ctype_t cc, char *s, const wchar_t **ppwcs, - size_t n, void *pspriv, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wcsrtombs && nresult); - return (*cc->cc_ops->co_wcsrtombs)(cc->cc_closure, s, ppwcs, n, - pspriv, nresult); -} - -static __inline int -_citrus_ctype_wcsnrtombs(_citrus_ctype_t cc, char *s, const wchar_t **ppwcs, - size_t in, size_t n, void *pspriv, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wcsnrtombs && nresult); - return (*cc->cc_ops->co_wcsnrtombs)(cc, s, ppwcs, in, n, - pspriv, nresult); -} - -static __inline int -_citrus_ctype_wcstombs(_citrus_ctype_t cc, char *s, const wchar_t *wcs, - size_t n, size_t *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wcstombs && nresult); - return (*cc->cc_ops->co_wcstombs)(cc->cc_closure, s, wcs, n, nresult); -} - -static __inline int -_citrus_ctype_wctomb(_citrus_ctype_t cc, char *s, wchar_t wc, int *nresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wctomb && nresult); - return (*cc->cc_ops->co_wctomb)(cc->cc_closure, s, wc, nresult); -} - -static __inline int -_citrus_ctype_btowc(_citrus_ctype_t cc, int c, wint_t *wcresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_btowc && wcresult); - return (*cc->cc_ops->co_btowc)(cc, c, wcresult); -} - -static __inline int -_citrus_ctype_wctob(_citrus_ctype_t cc, wint_t c, int *cresult) -{ - - _DIAGASSERT(cc && cc->cc_ops && cc->cc_ops->co_wctob && cresult); - return (*cc->cc_ops->co_wctob)(cc, c, cresult); -} - -extern _citrus_ctype_rec_t _citrus_ctype_default; - -#endif diff --git a/lib/libc/citrus/citrus_ctype_fallback.c b/lib/libc/citrus/citrus_ctype_fallback.c deleted file mode 100644 index 860fa55d2..000000000 --- a/lib/libc/citrus/citrus_ctype_fallback.c +++ /dev/null @@ -1,229 +0,0 @@ -/* $NetBSD: citrus_ctype_fallback.c,v 1.3 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_ctype_fallback.c,v 1.3 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_ctype_fallback.h" - -/* - * for ABI version >= 0x00000002 - */ - -int -_citrus_ctype_btowc_fallback(_citrus_ctype_rec_t * __restrict cc, - int c, wint_t * __restrict wcresult) -{ - char mb; - /* - * what we need is _PRIVSIZE - * and we know that it's smaller than sizeof(mbstate_t). - */ - char pspriv[sizeof(mbstate_t)]; - wchar_t wc; - size_t nr; - int err; - - _DIAGASSERT(cc != NULL && cc->cc_closure != NULL); - - if (c == EOF) { - *wcresult = WEOF; - return 0; - } - - memset(&pspriv, 0, sizeof(pspriv)); - mb = (char)(unsigned)c; - err = _citrus_ctype_mbrtowc(cc, &wc, &mb, 1, (void *)&pspriv, &nr); - if (!err && (nr == 0 || nr == 1)) - *wcresult = wc; - else - *wcresult = WEOF; - - return 0; -} - -int -_citrus_ctype_wctob_fallback(_citrus_ctype_rec_t * __restrict cc, - wint_t wc, int * __restrict cresult) -{ - /* - * what we need is _PRIVSIZE - * and we know that it's smaller than sizeof(mbstate_t). - */ - char pspriv[sizeof(mbstate_t)]; - char buf[MB_LEN_MAX]; - size_t nr; - int err; - - _DIAGASSERT(cc != NULL && cc->cc_closure != NULL); - - if (wc == WEOF) { - *cresult = EOF; - return 0; - } - memset(&pspriv, 0, sizeof(pspriv)); - err = _citrus_ctype_wcrtomb(cc, buf, (wchar_t)wc, (void *)&pspriv, &nr); - if (!err && nr == 1) - *cresult = buf[0]; - else - *cresult = EOF; - - return 0; -} - -/* - * for ABI version >= 0x00000003 - */ - -int -_citrus_ctype_mbsnrtowcs_fallback(_citrus_ctype_rec_t * __restrict cc, - wchar_t * __restrict pwcs, const char ** __restrict s, size_t in, - size_t n, void * __restrict psenc, size_t * __restrict nresult) -{ - int err; - size_t cnt, siz; - const char *s0, *se; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(*s != NULL); - - /* if pwcs is NULL, ignore n */ - if (pwcs == NULL) - n = 1; /* arbitrary >0 value */ - - err = 0; - cnt = 0; - se = *s + in; - s0 = *s; /* to keep *s unchanged for now, use copy instead. */ - while (s0 < se && n > 0) { - err = _citrus_ctype_mbrtowc(cc, pwcs, s0, (size_t)(se - s0), - psenc, &siz); - if (err) { - cnt = (size_t)-1; - goto bye; - } - if (siz == (size_t)-2) { - s0 = se; - goto bye; - } - switch (siz) { - case 0: - if (pwcs) { - size_t dum; - _citrus_ctype_mbrtowc(cc, NULL, NULL, 0, psenc, - &dum); - } - s0 = 0; - goto bye; - default: - if (pwcs) { - pwcs++; - n--; - } - s0 += siz; - cnt++; - break; - } - } -bye: - if (pwcs) - *s = s0; - - *nresult = cnt; - - return err; -} - -int -_citrus_ctype_wcsnrtombs_fallback(_citrus_ctype_rec_t * __restrict cc, - char * __restrict s, const wchar_t ** __restrict pwcs, size_t in, - size_t n, void * __restrict psenc, size_t * __restrict nresult) -{ - size_t cnt = 0; - int err; - char buf[MB_LEN_MAX]; - size_t siz; - const wchar_t* pwcs0; - mbstate_t state; - - pwcs0 = *pwcs; - - if (!s) - n = 1; - - while (in > 0 && n > 0) { - memcpy(&state, psenc, sizeof(state)); - err = _citrus_ctype_wcrtomb(cc, buf, *pwcs0, psenc, &siz); - if (siz == (size_t)-1) { - *nresult = siz; - return (err); - } - - if (s) { - if (n < siz) { - memcpy(psenc, &state, sizeof(state)); - break; - } - memcpy(s, buf, siz); - s += siz; - n -= siz; - } - cnt += siz; - if (!*pwcs0) { - if (s) { - memset(psenc, 0, sizeof(state)); - } - pwcs0 = 0; - cnt--; /* don't include terminating null */ - break; - } - pwcs0++; - --in; - } - if (s) - *pwcs = pwcs0; - - *nresult = cnt; - return (0); -} diff --git a/lib/libc/citrus/citrus_ctype_fallback.h b/lib/libc/citrus/citrus_ctype_fallback.h deleted file mode 100644 index e760cef3c..000000000 --- a/lib/libc/citrus/citrus_ctype_fallback.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: citrus_ctype_fallback.h,v 1.2 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_CTYPE_FALLBACK_H_ -#define _CITRUS_CTYPE_FALLBACK_H_ - -/* fallback functions for 0x00000002 */ -int _citrus_ctype_btowc_fallback(_citrus_ctype_rec_t * __restrict, - int, wint_t * __restrict); -int _citrus_ctype_wctob_fallback(_citrus_ctype_rec_t * __restrict, - wint_t, int * __restrict); - -/* fallback functions for 0x00000003 */ -int _citrus_ctype_mbsnrtowcs_fallback(_citrus_ctype_rec_t * __restrict, - wchar_t * __restrict, - const char ** __restrict, size_t, - size_t, void * __restrict, - size_t * __restrict); -int _citrus_ctype_wcsnrtombs_fallback(_citrus_ctype_rec_t * __restrict, - char * __restrict, - const wchar_t ** __restrict, size_t, - size_t, void * __restrict, - size_t * __restrict); - -#endif diff --git a/lib/libc/citrus/citrus_ctype_local.h b/lib/libc/citrus/citrus_ctype_local.h deleted file mode 100644 index cd3e76afb..000000000 --- a/lib/libc/citrus/citrus_ctype_local.h +++ /dev/null @@ -1,224 +0,0 @@ -/* $NetBSD: citrus_ctype_local.h,v 1.4 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_CTYPE_LOCAL_H_ -#define _CITRUS_CTYPE_LOCAL_H_ - -#define _CITRUS_CTYPE_GETOPS_FUNC_BASE(_n_) \ -int _n_(_citrus_ctype_ops_rec_t *, size_t, uint32_t) -#define _CITRUS_CTYPE_GETOPS_FUNC(_n_) \ -_CITRUS_CTYPE_GETOPS_FUNC_BASE(_citrus_##_n_##_ctype_getops) - -#define _CITRUS_CTYPE_DECLS(_e_) \ -static int _citrus_##_e_##_ctype_init \ - (void ** __restrict, void * __restrict, size_t, size_t); \ -static void _citrus_##_e_##_ctype_uninit(void *); \ -static unsigned _citrus_##_e_##_ctype_get_mb_cur_max(void *); \ -static int _citrus_##_e_##_ctype_mblen(void * __restrict, \ - const char * __restrict, \ - size_t, int * __restrict); \ -static int _citrus_##_e_##_ctype_mbrlen(void * __restrict, \ - const char * __restrict, \ - size_t, void * __restrict, \ - size_t * __restrict); \ -static int _citrus_##_e_##_ctype_mbrtowc(void * __restrict, \ - wchar_t * __restrict, \ - const char * __restrict, size_t, \ - void * __restrict, \ - size_t * __restrict); \ -static int _citrus_##_e_##_ctype_mbsinit(void * __restrict, \ - void const * __restrict, \ - int * __restrict); \ -static int _citrus_##_e_##_ctype_mbsrtowcs(void * __restrict, \ - wchar_t * __restrict, \ - const char ** __restrict, \ - size_t, void * __restrict, \ - size_t * __restrict); \ -static int _citrus_##_e_##_ctype_mbsnrtowcs(_citrus_ctype_rec_t * __restrict, \ - wchar_t * __restrict, \ - const char ** __restrict, \ - size_t, size_t, void * __restrict, \ - size_t * __restrict); \ -static int _citrus_##_e_##_ctype_mbstowcs(void * __restrict, \ - wchar_t * __restrict, \ - const char * __restrict, \ - size_t, size_t * __restrict); \ -static int _citrus_##_e_##_ctype_mbtowc(void * __restrict, \ - wchar_t * __restrict, \ - const char * __restrict, \ - size_t, int * __restrict); \ -static int _citrus_##_e_##_ctype_wcrtomb(void * __restrict, \ - char * __restrict, wchar_t, \ - void * __restrict, \ - size_t * __restrict); \ -static int _citrus_##_e_##_ctype_wcsrtombs(void * __restrict, \ - char * __restrict, \ - const wchar_t ** __restrict, \ - size_t, void * __restrict, \ - size_t * __restrict); \ -static int _citrus_##_e_##_ctype_wcsnrtombs(_citrus_ctype_rec_t * __restrict, \ - char * __restrict, \ - const wchar_t ** __restrict, \ - size_t, size_t, void * __restrict, \ - size_t * __restrict); \ -static int _citrus_##_e_##_ctype_wcstombs(void * __restrict, \ - char * __restrict, \ - const wchar_t * __restrict, \ - size_t, size_t * __restrict); \ -static int _citrus_##_e_##_ctype_wctomb(void * __restrict, \ - char * __restrict, \ - wchar_t, int * __restrict); \ -static int _citrus_##_e_##_ctype_btowc(_citrus_ctype_rec_t * __restrict, \ - int, wint_t * __restrict); \ -static int _citrus_##_e_##_ctype_wctob(_citrus_ctype_rec_t * __restrict, \ - wint_t, int * __restrict) - -#define _CITRUS_CTYPE_DEF_OPS(_e_) \ -_citrus_ctype_ops_rec_t _citrus_##_e_##_ctype_ops = { \ - /* co_abi_version */ _CITRUS_CTYPE_ABI_VERSION, \ - /* co_init */ &_citrus_##_e_##_ctype_init, \ - /* co_uninit */ &_citrus_##_e_##_ctype_uninit, \ - /* co_get_mb_cur_max */ &_citrus_##_e_##_ctype_get_mb_cur_max, \ - /* co_mblen */ &_citrus_##_e_##_ctype_mblen, \ - /* co_mbrlen */ &_citrus_##_e_##_ctype_mbrlen, \ - /* co_mbrtowc */ &_citrus_##_e_##_ctype_mbrtowc, \ - /* co_mbsinit */ &_citrus_##_e_##_ctype_mbsinit, \ - /* co_mbsrtowcs */ &_citrus_##_e_##_ctype_mbsrtowcs, \ - /* co_mbstowcs */ &_citrus_##_e_##_ctype_mbstowcs, \ - /* co_mbtowc */ &_citrus_##_e_##_ctype_mbtowc, \ - /* co_wcrtomb */ &_citrus_##_e_##_ctype_wcrtomb, \ - /* co_wcsrtombs */ &_citrus_##_e_##_ctype_wcsrtombs, \ - /* co_wcstombs */ &_citrus_##_e_##_ctype_wcstombs, \ - /* co_wctomb */ &_citrus_##_e_##_ctype_wctomb, \ - /* co_btowc */ &_citrus_##_e_##_ctype_btowc, \ - /* co_wctob */ &_citrus_##_e_##_ctype_wctob, \ - /* co_mbsnrtowcs */ &_citrus_##_e_##_ctype_mbsnrtowcs, \ - /* co_wcsnrtombs */ &_citrus_##_e_##_ctype_wcsnrtombs, \ -} - -typedef struct _citrus_ctype_ops_rec _citrus_ctype_ops_rec_t; -typedef struct _citrus_ctype_rec _citrus_ctype_rec_t; - -typedef int (*_citrus_ctype_init_t) - (void ** __restrict, void * __restrict, size_t, size_t); -typedef void (*_citrus_ctype_uninit_t)(void *); -typedef unsigned (*_citrus_ctype_get_mb_cur_max_t)(void *); -typedef int (*_citrus_ctype_mblen_t) - (void * __restrict, const char * __restrict, size_t, int * __restrict); -typedef int (*_citrus_ctype_mbrlen_t) - (void * __restrict, const char * __restrict, size_t, - void * __restrict, size_t * __restrict); -typedef int (*_citrus_ctype_mbrtowc_t) - (void * __restrict, wchar_t * __restrict, const char * __restrict, - size_t, void * __restrict, size_t * __restrict); -typedef int (*_citrus_ctype_mbsinit_t) - (void * __restrict, const void * __restrict, int * __restrict); -typedef int (*_citrus_ctype_mbsrtowcs_t) - (void * __restrict, wchar_t * __restrict, const char ** __restrict, - size_t, void * __restrict, size_t * __restrict); -typedef int (*_citrus_ctype_mbsnrtowcs_t) - (_citrus_ctype_rec_t * __restrict, wchar_t * __restrict, - const char ** __restrict, size_t, size_t, void * __restrict, - size_t * __restrict); -typedef int (*_citrus_ctype_mbstowcs_t) - (void * __restrict, wchar_t * __restrict, const char * __restrict, - size_t, size_t * __restrict); -typedef int (*_citrus_ctype_mbtowc_t) - (void * __restrict, wchar_t * __restrict, const char * __restrict, - size_t, int * __restrict); -typedef int (*_citrus_ctype_wcrtomb_t) - (void * __restrict, char * __restrict, wchar_t, void * __restrict, - size_t * __restrict); -typedef int (*_citrus_ctype_wcsrtombs_t) - (void * __restrict, char * __restrict, const wchar_t ** __restrict, - size_t, void * __restrict, size_t * __restrict); -typedef int (*_citrus_ctype_wcsnrtombs_t) - (_citrus_ctype_rec_t * __restrict, char * __restrict, - const wchar_t ** __restrict, size_t, size_t, void * __restrict, - size_t * __restrict); -typedef int (*_citrus_ctype_wcstombs_t) - (void * __restrict, char * __restrict, const wchar_t * __restrict, - size_t, size_t * __restrict); -typedef int (*_citrus_ctype_wctomb_t) - (void * __restrict, char * __restrict, wchar_t, int * __restrict); -typedef int (*_citrus_ctype_btowc_t) - (_citrus_ctype_rec_t * __restrict, int, wint_t * __restrict); -typedef int (*_citrus_ctype_wctob_t) - (_citrus_ctype_rec_t * __restrict, wint_t, int * __restrict); -#include "citrus_ctype_fallback.h" - -/* - * ABI Version change log: - * 0x00000001 - * initial version - * 0x00000002 - * ops record: btowc and wctob added. - * ctype record: unchanged. - * 0x00000003 - * ops record: mbsnrtowcs and wcsnrtombs added. - * ctype record: unchanged. - */ -#define _CITRUS_CTYPE_ABI_VERSION 0x00000003 -struct _citrus_ctype_ops_rec { - uint32_t co_abi_version; - /* version 0x00000001 */ - _citrus_ctype_init_t co_init; - _citrus_ctype_uninit_t co_uninit; - _citrus_ctype_get_mb_cur_max_t co_get_mb_cur_max; - _citrus_ctype_mblen_t co_mblen; - _citrus_ctype_mbrlen_t co_mbrlen; - _citrus_ctype_mbrtowc_t co_mbrtowc; - _citrus_ctype_mbsinit_t co_mbsinit; - _citrus_ctype_mbsrtowcs_t co_mbsrtowcs; - _citrus_ctype_mbstowcs_t co_mbstowcs; - _citrus_ctype_mbtowc_t co_mbtowc; - _citrus_ctype_wcrtomb_t co_wcrtomb; - _citrus_ctype_wcsrtombs_t co_wcsrtombs; - _citrus_ctype_wcstombs_t co_wcstombs; - _citrus_ctype_wctomb_t co_wctomb; - /* version 0x00000002 */ - _citrus_ctype_btowc_t co_btowc; - _citrus_ctype_wctob_t co_wctob; - /* version 0x00000003 */ - _citrus_ctype_mbsnrtowcs_t co_mbsnrtowcs; - _citrus_ctype_wcsnrtombs_t co_wcsnrtombs; -}; - -#define _CITRUS_DEFAULT_CTYPE_NAME "NONE" -#define _CITRUS_DEFAULT_CTYPE_OPS _citrus_NONE_ctype_ops -#define _CITRUS_DEFAULT_CTYPE_HEADER "citrus_none.h" - -typedef _CITRUS_CTYPE_GETOPS_FUNC_BASE((*_citrus_ctype_getops_t)); -struct _citrus_ctype_rec { - _citrus_ctype_ops_rec_t *cc_ops; - void *cc_closure; - _citrus_module_t cc_module; -}; - -#endif diff --git a/lib/libc/citrus/citrus_ctype_template.h b/lib/libc/citrus/citrus_ctype_template.h deleted file mode 100644 index 1f0c6ecd9..000000000 --- a/lib/libc/citrus/citrus_ctype_template.h +++ /dev/null @@ -1,934 +0,0 @@ -/* $NetBSD: citrus_ctype_template.h,v 1.36 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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. - */ - - -/* - * CAUTION: THIS IS NOT STANDALONE FILE - * - * function templates of ctype encoding handler for each encodings. - * - * you need to define the macros below: - * - * _FUNCNAME(method) : - * It should convine the real function name for the method. - * e.g. _FUNCNAME(mbrtowc) should be expanded to - * _EUC_ctype_mbrtowc - * for EUC locale. - * - * _CEI_TO_STATE(cei, method) : - * It should be expanded to the pointer of the method-internal state - * structures. - * e.g. _CEI_TO_STATE(cei, mbrtowc) might be expanded to - * (cei)->states.s_mbrtowc - * This structure may use if the function is called as - * mbrtowc(&wc, s, n, NULL); - * Such individual structures are needed by: - * mblen - * mbrlen - * mbrtowc - * mbtowc - * mbsrtowcs - * mbsnrtowcs - * wcrtomb - * wcsrtombs - * wcsnrtombs - * wctomb - * These need to be keeped in the ctype encoding information structure, - * pointed by "cei". - * - * _ENCODING_INFO : - * It should be expanded to the name of the encoding information structure. - * e.g. For EUC encoding, this macro is expanded to _EUCInfo. - * Encoding information structure need to contain the common informations - * for the codeset. - * - * _ENCODING_STATE : - * It should be expanded to the name of the encoding state structure. - * e.g. For EUC encoding, this macro is expanded to _EUCState. - * Encoding state structure need to contain the context-dependent states, - * which are "unpacked-form" of mbstate_t type and keeped during sequent - * calls of mb/wc functions, - * - * _ENCODING_IS_STATE_DEPENDENT : - * If the encoding is state dependent, this should be expanded to - * non-zero integral value. Otherwise, 0. - * - * _STATE_NEEDS_EXPLICIT_INIT(ps) : - * some encodings, states needs some explicit initialization. - * (ie. initialization with memset isn't enough.) - * If the encoding state pointed by "ps" needs to be initialized - * explicitly, return non-zero. Otherwize, 0. - * - */ - - -/* prototypes */ - -__BEGIN_DECLS -static void _FUNCNAME(init_state)(_ENCODING_INFO * __restrict, - _ENCODING_STATE * __restrict); -static void _FUNCNAME(pack_state)(_ENCODING_INFO * __restrict, - void * __restrict, - const _ENCODING_STATE * __restrict); -static void _FUNCNAME(unpack_state)(_ENCODING_INFO * __restrict, - _ENCODING_STATE * __restrict, - const void * __restrict); -#if _ENCODING_IS_STATE_DEPENDENT -static int _FUNCNAME(put_state_reset)(_ENCODING_INFO * __restrict, - char * __restrict, size_t, - _ENCODING_STATE * __restrict, - size_t * __restrict); -#endif - -/* - * standard form of mbrtowc_priv. - * - * note (differences from real mbrtowc): - * - 3rd parameter is not "const char *s" but "const char **s". - * after the call of the function, *s will point the first byte of - * the next character. - * - additional 4th parameter is the size of src buffer. - * - 5th parameter is unpacked encoding-dependent state structure. - * - additional 6th parameter is the storage to be stored - * the return value in the real mbrtowc context. - * - return value means "errno" in the real mbrtowc context. - */ - -static int _FUNCNAME(mbrtowc_priv)(_ENCODING_INFO * __restrict, - wchar_t * __restrict, - const char ** __restrict, - size_t, _ENCODING_STATE * __restrict, - size_t * __restrict); - -/* - * standard form of wcrtomb_priv. - * - * note (differences from real wcrtomb): - * - additional 3th parameter is the size of src buffer. - * - 5th parameter is unpacked encoding-dependent state structure. - * - additional 6th parameter is the storage to be stored - * the return value in the real mbrtowc context. - * - return value means "errno" in the real wcrtomb context. - * - caller should ensure that 2nd parameter isn't NULL. - * (XXX inconsist with mbrtowc_priv) - */ - -static int _FUNCNAME(wcrtomb_priv)(_ENCODING_INFO * __restrict, - char * __restrict, size_t, wchar_t, - _ENCODING_STATE * __restrict, - size_t * __restrict); -__END_DECLS - - -/* - * macros - */ - -#define _TO_CEI(_cl_) ((_CTYPE_INFO*)(_cl_)) - - -/* - * templates - */ - -/* internal routines */ - -static __inline int -_FUNCNAME(mbtowc_priv)(_ENCODING_INFO * __restrict ei, - wchar_t * __restrict pwc, const char * __restrict s, - size_t n, _ENCODING_STATE * __restrict psenc, - int * __restrict nresult) -{ - _ENCODING_STATE state; - size_t nr; - int err = 0; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - - if (s == NULL) { - _FUNCNAME(init_state)(ei, psenc); - *nresult = _ENCODING_IS_STATE_DEPENDENT; - return (0); - } - - state = *psenc; - err = _FUNCNAME(mbrtowc_priv)(ei, pwc, (const char **)&s, n, psenc, &nr); - if (nr == (size_t)-2) - err = EILSEQ; - if (err) { - /* In error case, we should restore the state. */ - *psenc = state; - *nresult = -1; - return (err); - } - - *nresult = (int)nr; - - return (0); -} - -static int -_FUNCNAME(mbsrtowcs_priv)(_ENCODING_INFO * __restrict ei, - wchar_t * __restrict pwcs, - const char ** __restrict s, - size_t n, _ENCODING_STATE * __restrict psenc, - size_t * __restrict nresult) -{ - int err, cnt; - size_t siz; - const char *s0; - size_t mbcurmax; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(*s != NULL); - - /* if pwcs is NULL, ignore n */ - if (pwcs == NULL) - n = 1; /* arbitrary >0 value */ - - err = cnt = 0; - s0 = *s; /* to keep *s unchanged for now, use copy instead. */ - mbcurmax = _ENCODING_MB_CUR_MAX(ei); - while (n > 0) { - err = _FUNCNAME(mbrtowc_priv)(ei, pwcs, &s0, mbcurmax, - psenc, &siz); - if (siz == (size_t)-2) - err = EILSEQ; - if (err) { - cnt = -1; - goto bye; - } - switch (siz) { - case 0: - if (pwcs) { - _FUNCNAME(init_state)(ei, psenc); - } - s0 = 0; - goto bye; - default: - if (pwcs) { - pwcs++; - n--; - } - cnt++; - break; - } - } -bye: - if (pwcs) - *s = s0; - - *nresult = (size_t)cnt; - - return err; -} - -static int -_FUNCNAME(mbsnrtowcs_priv)(_ENCODING_INFO * __restrict ei, - wchar_t * __restrict pwcs, - const char ** __restrict s, size_t in, - size_t n, _ENCODING_STATE * __restrict psenc, - size_t * __restrict nresult) -{ - int err; - size_t cnt, siz; - const char *s0, *se; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(*s != NULL); - - /* if pwcs is NULL, ignore n */ - if (pwcs == NULL) - n = 1; /* arbitrary >0 value */ - - err = 0; - cnt = 0; - se = *s + in; - s0 = *s; /* to keep *s unchanged for now, use copy instead. */ - while (s0 < se && n > 0) { - err = _FUNCNAME(mbrtowc_priv)(ei, pwcs, &s0, se - s0, - psenc, &siz); - if (err) { - cnt = (size_t)-1; - goto bye; - } - if (siz == (size_t)-2) { - s0 = se; - goto bye; - } - switch (siz) { - case 0: - if (pwcs) { - _FUNCNAME(init_state)(ei, psenc); - } - s0 = 0; - goto bye; - default: - if (pwcs) { - pwcs++; - n--; - } - cnt++; - break; - } - } -bye: - if (pwcs) - *s = s0; - - *nresult = cnt; - - return err; -} - -static int -_FUNCNAME(wcsrtombs_priv)(_ENCODING_INFO * __restrict ei, char * __restrict s, - const wchar_t ** __restrict pwcs, - size_t n, _ENCODING_STATE * __restrict psenc, - size_t * __restrict nresult) -{ - int err; - char buf[MB_LEN_MAX]; - size_t cnt, siz; - const wchar_t* pwcs0; -#if _ENCODING_IS_STATE_DEPENDENT - _ENCODING_STATE state; -#endif - - pwcs0 = *pwcs; - - cnt = 0; - if (!s) - n = 1; - - while (n > 0) { -#if _ENCODING_IS_STATE_DEPENDENT - state = *psenc; -#endif - err = _FUNCNAME(wcrtomb_priv)(ei, buf, sizeof(buf), - *pwcs0, psenc, &siz); - if (siz == (size_t)-1) { - *nresult = siz; - return (err); - } - - if (s) { - if (n < siz) { -#if _ENCODING_IS_STATE_DEPENDENT - *psenc = state; -#endif - break; - } - memcpy(s, buf, siz); - s += siz; - n -= siz; - } - cnt += siz; - if (!*pwcs0) { - if (s) { - _FUNCNAME(init_state)(ei, psenc); - } - pwcs0 = 0; - cnt--; /* don't include terminating null */ - break; - } - pwcs0++; - } - if (s) - *pwcs = pwcs0; - - *nresult = cnt; - return (0); -} - -static int -_FUNCNAME(wcsnrtombs_priv)(_ENCODING_INFO * __restrict ei, char * __restrict s, - const wchar_t ** __restrict pwcs, size_t in, - size_t n, _ENCODING_STATE * __restrict psenc, - size_t * __restrict nresult) -{ - int cnt = 0, err; - char buf[MB_LEN_MAX]; - size_t siz; - const wchar_t* pwcs0; -#if _ENCODING_IS_STATE_DEPENDENT - _ENCODING_STATE state; -#endif - - pwcs0 = *pwcs; - - if (!s) - n = 1; - - while (in > 0 && n > 0) { -#if _ENCODING_IS_STATE_DEPENDENT - state = *psenc; -#endif - err = _FUNCNAME(wcrtomb_priv)(ei, buf, sizeof(buf), - *pwcs0, psenc, &siz); - if (siz == (size_t)-1) { - *nresult = siz; - return (err); - } - - if (s) { - if (n < siz) { -#if _ENCODING_IS_STATE_DEPENDENT - *psenc = state; -#endif - break; - } - memcpy(s, buf, siz); - s += siz; - n -= siz; - } - cnt += siz; - if (!*pwcs0) { - if (s) { - _FUNCNAME(init_state)(ei, psenc); - } - pwcs0 = 0; - cnt--; /* don't include terminating null */ - break; - } - pwcs0++; - --in; - } - if (s) - *pwcs = pwcs0; - - *nresult = (size_t)cnt; - return (0); -} - - -/* ---------------------------------------------------------------------- - * templates for public functions - */ - -#define _RESTART_BEGIN(_func_, _cei_, _pspriv_, _pse_) \ -do { \ - _ENCODING_STATE _state; \ - do { \ - if (_pspriv_ == NULL) { \ - _pse_ = &_CEI_TO_STATE(_cei_, _func_); \ - if (_STATE_NEEDS_EXPLICIT_INIT(_pse_)) \ - _FUNCNAME(init_state)(_CEI_TO_EI(_cei_), \ - (_pse_)); \ - } else { \ - _pse_ = &_state; \ - _FUNCNAME(unpack_state)(_CEI_TO_EI(_cei_), \ - _pse_, _pspriv_); \ - } \ - } while (/*CONSTCOND*/0) - -#define _RESTART_END(_func_, _cei_, _pspriv_, _pse_) \ - if (_pspriv_ != NULL) { \ - _FUNCNAME(pack_state)(_CEI_TO_EI(_cei_), _pspriv_, \ - _pse_); \ - } \ -} while (/*CONSTCOND*/0) - -int -_FUNCNAME(ctype_getops)(_citrus_ctype_ops_rec_t *ops, size_t lenops, - uint32_t expected_version) -{ - if (expected_version<_CITRUS_CTYPE_ABI_VERSION || lenops lenps) - return (EINVAL); - - cei = calloc(1, sizeof(_CTYPE_INFO)); - if (cei == NULL) - return (ENOMEM); - - *cl = (void *)cei; - - return _FUNCNAME(encoding_module_init)(_CEI_TO_EI(cei), var, lenvar); -} - -static void -_FUNCNAME(ctype_uninit)(void *cl) -{ - if (cl) { - _FUNCNAME(encoding_module_uninit)(_CEI_TO_EI(_TO_CEI(cl))); - free(cl); - } -} - -static unsigned -/*ARGSUSED*/ -_FUNCNAME(ctype_get_mb_cur_max)(void *cl) -{ - return _ENCODING_MB_CUR_MAX(_CEI_TO_EI(_TO_CEI(cl))); -} - -static int -_FUNCNAME(ctype_mblen)(void * __restrict cl, - const char * __restrict s, size_t n, - int * __restrict nresult) -{ - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - - _DIAGASSERT(cl != NULL); - - psenc = &_CEI_TO_STATE(_TO_CEI(cl), mblen); - ei = _CEI_TO_EI(_TO_CEI(cl)); - if (_STATE_NEEDS_EXPLICIT_INIT(psenc)) - _FUNCNAME(init_state)(ei, psenc); - return _FUNCNAME(mbtowc_priv)(ei, NULL, s, n, psenc, nresult); -} - -static int -_FUNCNAME(ctype_mbrlen)(void * __restrict cl, const char * __restrict s, - size_t n, void * __restrict pspriv, - size_t * __restrict nresult) -{ - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - int err = 0; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _RESTART_BEGIN(mbrlen, _TO_CEI(cl), pspriv, psenc); - if (s == NULL) { - _FUNCNAME(init_state)(ei, psenc); - *nresult = 0; - } else { - err = _FUNCNAME(mbrtowc_priv)(ei, NULL, (const char **)&s, n, - (void *)psenc, nresult); - } - _RESTART_END(mbrlen, _TO_CEI(cl), pspriv, psenc); - - return (err); -} - -static int -_FUNCNAME(ctype_mbrtowc)(void * __restrict cl, wchar_t * __restrict pwc, - const char * __restrict s, size_t n, - void * __restrict pspriv, size_t * __restrict nresult) -{ - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - int err = 0; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _RESTART_BEGIN(mbrtowc, _TO_CEI(cl), pspriv, psenc); - if (s == NULL) { - _FUNCNAME(init_state)(ei, psenc); - *nresult = 0; - } else { - err = _FUNCNAME(mbrtowc_priv)(ei, pwc, (const char **)&s, n, - (void *)psenc, nresult); - } - _RESTART_END(mbrtowc, _TO_CEI(cl), pspriv, psenc); - - return (err); -} - -static int -/*ARGSUSED*/ -_FUNCNAME(ctype_mbsinit)(void * __restrict cl, const void * __restrict pspriv, - int * __restrict nresult) -{ - _ENCODING_STATE state; - - if (pspriv == NULL) { - *nresult = 1; - return (0); - } - - _FUNCNAME(unpack_state)(_CEI_TO_EI(_TO_CEI(cl)), &state, pspriv); - - *nresult = (state.chlen == 0); /* XXX: FIXME */ - - return (0); -} - -static int -_FUNCNAME(ctype_mbsrtowcs)(void * __restrict cl, wchar_t * __restrict pwcs, - const char ** __restrict s, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - int err = 0; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _RESTART_BEGIN(mbsrtowcs, _TO_CEI(cl), pspriv, psenc); - err = _FUNCNAME(mbsrtowcs_priv)(ei, pwcs, s, n, psenc, nresult); - _RESTART_END(mbsrtowcs, _TO_CEI(cl), pspriv, psenc); - - return (err); -} - -static int __used -_FUNCNAME(ctype_mbsnrtowcs)(_citrus_ctype_rec_t * __restrict cc, wchar_t * __restrict pwcs, - const char ** __restrict s, size_t in, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - void *cl = cc->cc_closure; - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - int err = 0; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _RESTART_BEGIN(mbsnrtowcs, _TO_CEI(cl), pspriv, psenc); - err = _FUNCNAME(mbsnrtowcs_priv)(ei, pwcs, s, in, n, psenc, nresult); - _RESTART_END(mbsnrtowcs, _TO_CEI(cl), pspriv, psenc); - - return (err); -} - -static int -_FUNCNAME(ctype_mbstowcs)(void * __restrict cl, wchar_t * __restrict pwcs, - const char * __restrict s, size_t n, - size_t * __restrict nresult) -{ - int err; - _ENCODING_STATE state; - _ENCODING_INFO *ei; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _FUNCNAME(init_state)(ei, &state); - err = _FUNCNAME(mbsrtowcs_priv)(ei, pwcs, (const char **)&s, n, - &state, nresult); - if (*nresult == (size_t)-2) { - err = EILSEQ; - *nresult = (size_t)-1; - } - - return (err); -} - -static int -_FUNCNAME(ctype_mbtowc)(void * __restrict cl, wchar_t * __restrict pwc, - const char * __restrict s, size_t n, - int * __restrict nresult) -{ - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - - _DIAGASSERT(cl != NULL); - - psenc = &_CEI_TO_STATE(_TO_CEI(cl), mbtowc); - ei = _CEI_TO_EI(_TO_CEI(cl)); - if (_STATE_NEEDS_EXPLICIT_INIT(psenc)) - _FUNCNAME(init_state)(ei, psenc); - return _FUNCNAME(mbtowc_priv)(ei, pwc, s, n, psenc, nresult); -} - -static int -_FUNCNAME(ctype_wcrtomb)(void * __restrict cl, char * __restrict s, wchar_t wc, - void * __restrict pspriv, size_t * __restrict nresult) -{ - _ENCODING_STATE *psenc; - char buf[MB_LEN_MAX]; - int err = 0; - size_t sz; -#if _ENCODING_IS_STATE_DEPENDENT - size_t rsz = 0; -#endif - - _DIAGASSERT(cl != NULL); - - if (s == NULL) { - /* - * use internal buffer. - */ - s = buf; - wc = L'\0'; /* SUSv3 */ - } - - _RESTART_BEGIN(wcrtomb, _TO_CEI(cl), pspriv, psenc); - sz = _ENCODING_MB_CUR_MAX(_CEI_TO_EI(_TO_CEI(cl))); -#if _ENCODING_IS_STATE_DEPENDENT - if (wc == L'\0') { - /* reset state */ - err = _FUNCNAME(put_state_reset)(_CEI_TO_EI(_TO_CEI(cl)), s, - sz, psenc, &rsz); - if (err) { - *nresult = -1; - goto quit; - } - s += rsz; - sz -= rsz; - } -#endif - err = _FUNCNAME(wcrtomb_priv)(_CEI_TO_EI(_TO_CEI(cl)), s, sz, - wc, psenc, nresult); -#if _ENCODING_IS_STATE_DEPENDENT - if (err == 0) - *nresult += rsz; -quit: -#endif - if (err == E2BIG) - err = EINVAL; - _RESTART_END(wcrtomb, _TO_CEI(cl), pspriv, psenc); - - return err; -} - -static int -/*ARGSUSED*/ -_FUNCNAME(ctype_wcsrtombs)(void * __restrict cl, char * __restrict s, - const wchar_t ** __restrict pwcs, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - int err = 0; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _RESTART_BEGIN(wcsrtombs, _TO_CEI(cl), pspriv, psenc); - err = _FUNCNAME(wcsrtombs_priv)(ei, s, pwcs, n, psenc, nresult); - _RESTART_END(wcsrtombs, _TO_CEI(cl), pspriv, psenc); - - return err; -} - -static int __used -/*ARGSUSED*/ -_FUNCNAME(ctype_wcsnrtombs)(_citrus_ctype_rec_t * __restrict cc, - char * __restrict s, - const wchar_t ** __restrict pwcs, size_t in, - size_t n, void * __restrict pspriv, - size_t * __restrict nresult) -{ - void *cl = cc->cc_closure; - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - int err = 0; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _RESTART_BEGIN(wcsnrtombs, _TO_CEI(cl), pspriv, psenc); - err = _FUNCNAME(wcsnrtombs_priv)(ei, s, pwcs, in, n, psenc, nresult); - _RESTART_END(wcsnrtombs, _TO_CEI(cl), pspriv, psenc); - - return err; -} - -static int -/*ARGSUSED*/ -_FUNCNAME(ctype_wcstombs)(void * __restrict cl, char * __restrict s, - const wchar_t * __restrict pwcs, size_t n, - size_t * __restrict nresult) -{ - _ENCODING_STATE state; - _ENCODING_INFO *ei; - int err; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - _FUNCNAME(init_state)(ei, &state); - err = _FUNCNAME(wcsrtombs_priv)(ei, s, (const wchar_t **)&pwcs, n, - &state, nresult); - - return err; -} - -static int -_FUNCNAME(ctype_wctomb)(void * __restrict cl, char * __restrict s, wchar_t wc, - int * __restrict nresult) -{ - _ENCODING_STATE *psenc; - _ENCODING_INFO *ei; - size_t nr, sz; -#if _ENCODING_IS_STATE_DEPENDENT - size_t rsz = 0; -#endif - int err = 0; - - _DIAGASSERT(cl != NULL); - - ei = _CEI_TO_EI(_TO_CEI(cl)); - psenc = &_CEI_TO_STATE(_TO_CEI(cl), wctomb); - if (_STATE_NEEDS_EXPLICIT_INIT(psenc)) - _FUNCNAME(init_state)(ei, psenc); - if (s == NULL) { - _FUNCNAME(init_state)(ei, psenc); - *nresult = _ENCODING_IS_STATE_DEPENDENT; - return 0; - } - sz = _ENCODING_MB_CUR_MAX(_CEI_TO_EI(_TO_CEI(cl))); -#if _ENCODING_IS_STATE_DEPENDENT - if (wc == L'\0') { - /* reset state */ - err = _FUNCNAME(put_state_reset)(_CEI_TO_EI(_TO_CEI(cl)), s, - sz, psenc, &rsz); - if (err) { - *nresult = -1; /* XXX */ - return 0; - } - s += rsz; - sz -= rsz; - } -#endif - err = _FUNCNAME(wcrtomb_priv)(ei, s, sz, wc, psenc, &nr); -#if _ENCODING_IS_STATE_DEPENDENT - if (err == 0) - *nresult = (int)(nr + rsz); - else -#endif - *nresult = (int)nr; - - return 0; -} - -static int -/*ARGSUSED*/ -_FUNCNAME(ctype_btowc)(_citrus_ctype_rec_t * __restrict cc, - int c, wint_t * __restrict wcresult) -{ - _ENCODING_STATE state; - _ENCODING_INFO *ei; - char mb; - char const *s; - wchar_t wc; - size_t nr; - int err; - - _DIAGASSERT(cc != NULL && cc->cc_closure != NULL); - - if (c == EOF) { - *wcresult = WEOF; - return 0; - } - ei = _CEI_TO_EI(_TO_CEI(cc->cc_closure)); - _FUNCNAME(init_state)(ei, &state); - mb = (char)(unsigned)c; - s = &mb; - err = _FUNCNAME(mbrtowc_priv)(ei, &wc, &s, 1, &state, &nr); - if (!err && (nr == 0 || nr == 1)) - *wcresult = (wint_t)wc; - else - *wcresult = WEOF; - - return 0; -} - -static int -/*ARGSUSED*/ -_FUNCNAME(ctype_wctob)(_citrus_ctype_rec_t * __restrict cc, - wint_t wc, int * __restrict cresult) -{ - _ENCODING_STATE state; - _ENCODING_INFO *ei; - char buf[MB_LEN_MAX]; - size_t nr; - int err; - - _DIAGASSERT(cc != NULL && cc->cc_closure != NULL); - - if (wc == WEOF) { - *cresult = EOF; - return 0; - } - ei = _CEI_TO_EI(_TO_CEI(cc->cc_closure)); - _FUNCNAME(init_state)(ei, &state); - err = _FUNCNAME(wcrtomb_priv)(ei, buf, _ENCODING_MB_CUR_MAX(ei), - (wchar_t)wc, &state, &nr); - if (!err && nr == 1) - *cresult = buf[0]; - else - *cresult = EOF; - - return 0; -} diff --git a/lib/libc/citrus/citrus_db.c b/lib/libc/citrus/citrus_db.c deleted file mode 100644 index fc7e0140f..000000000 --- a/lib/libc/citrus/citrus_db.c +++ /dev/null @@ -1,340 +0,0 @@ -/* $NetBSD: citrus_db.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_db.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_db.h" -#include "citrus_db_file.h" - -struct _citrus_db { - /* private */ - struct _region db_region; - uint32_t (*db_hashfunc)(void *, struct _citrus_region *); - void *db_hashfunc_closure; -}; - -int -_citrus_db_open(struct _citrus_db **rdb, struct _region *r, const char *magic, - uint32_t (*hashfunc)(void *, struct _citrus_region *), - void *hashfunc_closure) -{ - struct _memstream ms; - struct _citrus_db *db; - struct _citrus_db_header_x *dhx; - - _memstream_bind(&ms, r); - - /* sanity check */ - dhx = _memstream_getregion(&ms, NULL, sizeof(*dhx)); - if (dhx == NULL) - return EFTYPE; - if (strncmp(dhx->dhx_magic, magic, _CITRUS_DB_MAGIC_SIZE) != 0) - return EFTYPE; - if (_memstream_seek(&ms, be32toh(dhx->dhx_entry_offset), SEEK_SET)) - return EFTYPE; - - if (be32toh(dhx->dhx_num_entries)*_CITRUS_DB_ENTRY_SIZE > - _memstream_remainder(&ms)) - return EFTYPE; - - db = malloc(sizeof(*db)); - if (db==NULL) - return errno; - db->db_region = *r; - db->db_hashfunc = hashfunc; - db->db_hashfunc_closure = hashfunc_closure; - *rdb = db; - - return 0; -} - -void -_citrus_db_close(struct _citrus_db *db) -{ - free(db); -} - -int -_citrus_db_lookup(struct _citrus_db *db, struct _citrus_region *key, - struct _citrus_region *data, struct _citrus_db_locator *dl) -{ - uint32_t hashval, num_entries; - size_t offset; - struct _memstream ms; - struct _citrus_db_header_x *dhx; - struct _citrus_db_entry_x *dex; - struct _citrus_region r; - - _memstream_bind(&ms, &db->db_region); - - dhx = _memstream_getregion(&ms, NULL, sizeof(*dhx)); - _DIAGASSERT(dhx); - num_entries = be32toh(dhx->dhx_num_entries); - if (num_entries == 0) - return ENOENT; - - if (dl != NULL && dl->dl_offset>0) { - hashval = dl->dl_hashval; - offset = dl->dl_offset; - if (offset >= _region_size(&db->db_region)) - return ENOENT; - } else { - hashval = - db->db_hashfunc(db->db_hashfunc_closure, key)%num_entries; - offset = - be32toh(dhx->dhx_entry_offset) + - hashval * _CITRUS_DB_ENTRY_SIZE; - if (dl) - dl->dl_hashval = hashval; - } - do { - /* seek to the next entry */ - if (_citrus_memory_stream_seek(&ms, offset, SEEK_SET)) - return EFTYPE; - /* get the entry record */ - dex = _memstream_getregion(&ms, NULL, _CITRUS_DB_ENTRY_SIZE); - if (dex == NULL) - return EFTYPE; - - /* jump to next entry having the same hash value. */ - offset = be32toh(dex->dex_next_offset); - - /* save the current position */ - if (dl) { - dl->dl_offset = offset; - if (offset==0) - dl->dl_offset = _region_size(&db->db_region); - } - - /* compare hash value. */ - if (be32toh(dex->dex_hash_value) != hashval) - /* not found */ - break; - /* compare key length */ - if (be32toh(dex->dex_key_size) == _region_size(key)) { - /* seek to the head of the key. */ - if (_memstream_seek(&ms, be32toh(dex->dex_key_offset), - SEEK_SET)) - return EFTYPE; - /* get the region of the key */ - if (_memstream_getregion(&ms, &r, - _region_size(key)) == NULL) - return EFTYPE; - /* compare key byte stream */ - if (memcmp(_region_head(&r), _region_head(key), - _region_size(key)) == 0) { - /* match */ - if (_memstream_seek( - &ms, be32toh(dex->dex_data_offset), - SEEK_SET)) - return EFTYPE; - if (_memstream_getregion( - &ms, data, - be32toh(dex->dex_data_size)) == NULL) - return EFTYPE; - return 0; - } - } - } while (offset != 0); - - return ENOENT; -} - -int -_citrus_db_lookup_by_string(struct _citrus_db *db, const char *key, - struct _citrus_region *data, - struct _citrus_db_locator *dl) -{ - struct _region r; - - _region_init(&r, __UNCONST(key), strlen(key)); - - return _citrus_db_lookup(db, &r, data, dl); -} - -int -_citrus_db_lookup8_by_string(struct _citrus_db *db, const char *key, - uint8_t *rval, struct _citrus_db_locator *dl) -{ - int ret; - struct _region r; - - ret = _citrus_db_lookup_by_string(db, key, &r, dl); - if (ret) - return ret; - - if (_region_size(&r) != 1) - return EFTYPE; - - if (rval) - memcpy(rval, _region_head(&r), 1); - - return 0; -} - -int -_citrus_db_lookup16_by_string(struct _citrus_db *db, const char *key, - uint16_t *rval, struct _citrus_db_locator *dl) -{ - int ret; - struct _region r; - uint16_t val; - - ret = _citrus_db_lookup_by_string(db, key, &r, dl); - if (ret) - return ret; - - if (_region_size(&r) != 2) - return EFTYPE; - - if (rval) { - memcpy(&val, _region_head(&r), 2); - *rval = be16toh(val); - } - - return 0; -} - -int -_citrus_db_lookup32_by_string(struct _citrus_db *db, const char *key, - uint32_t *rval, struct _citrus_db_locator *dl) -{ - int ret; - struct _region r; - uint32_t val; - - ret = _citrus_db_lookup_by_string(db, key, &r, dl); - if (ret) - return ret; - - if (_region_size(&r) != 4) - return EFTYPE; - - if (rval) { - memcpy(&val, _region_head(&r), 4); - *rval = be32toh(val); - } - - return 0; -} - -int -_citrus_db_lookup_string_by_string(struct _citrus_db *db, const char *key, - const char **rdata, - struct _citrus_db_locator *dl) -{ - int ret; - struct _region r; - - ret = _citrus_db_lookup_by_string(db, key, &r, dl); - if (ret) - return ret; - - /* check whether the string is null terminated */ - if (_region_size(&r) == 0) - return EFTYPE; - if (*((const char*)_region_head(&r)+_region_size(&r)-1) != '\0') - return EFTYPE; - - if (rdata) - *rdata = _region_head(&r); - - return 0; -} - -int -_citrus_db_get_number_of_entries(struct _citrus_db *db) -{ - struct _memstream ms; - struct _citrus_db_header_x *dhx; - - _memstream_bind(&ms, &db->db_region); - - dhx = _memstream_getregion(&ms, NULL, sizeof(*dhx)); - _DIAGASSERT(dhx); - return (int)be32toh(dhx->dhx_num_entries); -} - -int -_citrus_db_get_entry(struct _citrus_db *db, int idx, - struct _region *key, struct _region *data) -{ - uint32_t num_entries; - size_t offset; - struct _memstream ms; - struct _citrus_db_header_x *dhx; - struct _citrus_db_entry_x *dex; - - _memstream_bind(&ms, &db->db_region); - - dhx = _memstream_getregion(&ms, NULL, sizeof(*dhx)); - _DIAGASSERT(dhx); - num_entries = be32toh(dhx->dhx_num_entries); - if (idx < 0 || (uint32_t)idx >= num_entries) - return EINVAL; - - /* seek to the next entry */ - offset = be32toh(dhx->dhx_entry_offset) + idx * _CITRUS_DB_ENTRY_SIZE; - if (_citrus_memory_stream_seek(&ms, offset, SEEK_SET)) - return EFTYPE; - /* get the entry record */ - dex = _memstream_getregion(&ms, NULL, _CITRUS_DB_ENTRY_SIZE); - if (dex == NULL) - return EFTYPE; - /* seek to the head of the key. */ - if (_memstream_seek(&ms, be32toh(dex->dex_key_offset), SEEK_SET)) - return EFTYPE; - /* get the region of the key. */ - if (_memstream_getregion(&ms, key, be32toh(dex->dex_key_size))==NULL) - return EFTYPE; - /* seek to the head of the data. */ - if (_memstream_seek(&ms, be32toh(dex->dex_data_offset), SEEK_SET)) - return EFTYPE; - /* get the region of the data. */ - if (_memstream_getregion(&ms, data, be32toh(dex->dex_data_size))==NULL) - return EFTYPE; - - return 0; -} diff --git a/lib/libc/citrus/citrus_db.h b/lib/libc/citrus/citrus_db.h deleted file mode 100644 index 239e1cd98..000000000 --- a/lib/libc/citrus/citrus_db.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: citrus_db.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_DB_H_ -#define _CITRUS_DB_H_ - -struct _citrus_db; -struct _citrus_db_locator { - uint32_t dl_hashval; - size_t dl_offset; -}; - -__BEGIN_DECLS -int _citrus_db_open(struct _citrus_db **, struct _citrus_region *, - const char *, - uint32_t (*)(void *, struct _citrus_region *), - void *); -void _citrus_db_close(struct _citrus_db *); -int _citrus_db_lookup(struct _citrus_db *, struct _citrus_region *, - struct _citrus_region *, - struct _citrus_db_locator *); -int _citrus_db_lookup_by_string(struct _citrus_db *, const char *, - struct _citrus_region *, - struct _citrus_db_locator *); -int _citrus_db_lookup8_by_string(struct _citrus_db *, const char *, - uint8_t *, - struct _citrus_db_locator *); -int _citrus_db_lookup16_by_string(struct _citrus_db *, const char *, - uint16_t *, - struct _citrus_db_locator *); -int _citrus_db_lookup32_by_string(struct _citrus_db *, const char *, - uint32_t *, - struct _citrus_db_locator *); -int _citrus_db_lookup_string_by_string(struct _citrus_db *, const char *, - const char **, - struct _citrus_db_locator *); -int _citrus_db_get_number_of_entries(struct _citrus_db *); -int _citrus_db_get_entry(struct _citrus_db *, int, - struct _citrus_region *, struct _citrus_region *); -__END_DECLS - -static __inline void -_citrus_db_locator_init(struct _citrus_db_locator *dl) -{ - dl->dl_hashval = 0; - dl->dl_offset = 0; -} - -#endif diff --git a/lib/libc/citrus/citrus_db_factory.c b/lib/libc/citrus/citrus_db_factory.c deleted file mode 100644 index a17e5b7f3..000000000 --- a/lib/libc/citrus/citrus_db_factory.c +++ /dev/null @@ -1,345 +0,0 @@ -/* $NetBSD: citrus_db_factory.c,v 1.10 2013/09/14 13:05:51 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_db_factory.c,v 1.10 2013/09/14 13:05:51 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_region.h" -#include "citrus_db_file.h" -#include "citrus_db_factory.h" - -struct _citrus_db_factory_entry { - SIMPLEQ_ENTRY(_citrus_db_factory_entry) de_entry; - struct _citrus_db_factory_entry *de_next; - uint32_t de_hashvalue; - struct _region de_key; - int de_key_free; - struct _region de_data; - int de_data_free; - int de_idx; -}; - -struct _citrus_db_factory { - size_t df_num_entries; - SIMPLEQ_HEAD(, _citrus_db_factory_entry) df_entries; - size_t df_total_key_size; - size_t df_total_data_size; - uint32_t (*df_hashfunc)(void *, struct _citrus_region *); - void *df_hashfunc_closure; -}; - -#define DB_ALIGN 16 - -int -_citrus_db_factory_create(struct _citrus_db_factory **rdf, - _citrus_db_hash_func_t hashfunc, - void *hashfunc_closure) -{ - struct _citrus_db_factory *df; - - df = malloc(sizeof(*df)); - if (df == NULL) - return errno; - df->df_num_entries = 0; - df->df_total_key_size = df->df_total_data_size = 0; - SIMPLEQ_INIT(&df->df_entries); - df->df_hashfunc = hashfunc; - df->df_hashfunc_closure = hashfunc_closure; - - *rdf = df; - - return 0; -} - -void -_citrus_db_factory_free(struct _citrus_db_factory *df) -{ - struct _citrus_db_factory_entry *de; - - while ((de = SIMPLEQ_FIRST(&df->df_entries)) != NULL) { - SIMPLEQ_REMOVE_HEAD(&df->df_entries, de_entry); - if (de->de_key_free) - free(_region_head(&de->de_key)); - if (de->de_data_free) - free(_region_head(&de->de_data)); - free(de); - } - free(df); -} - -static __inline size_t -ceilto(size_t sz) -{ - return (sz+DB_ALIGN-1) & ~(DB_ALIGN-1); -} - -int -_citrus_db_factory_add(struct _citrus_db_factory *df, - struct _region *key, int keyfree, - struct _region *data, int datafree) -{ - struct _citrus_db_factory_entry *de; - - de = malloc(sizeof(*de)); - if (de == NULL) - return -1; - - de->de_hashvalue = df->df_hashfunc(df->df_hashfunc_closure, key); - de->de_key = *key; - de->de_key_free = keyfree; - de->de_data = *data; - de->de_data_free = datafree; - de->de_idx = -1; - - SIMPLEQ_INSERT_TAIL(&df->df_entries, de, de_entry); - df->df_total_key_size += _region_size(key); - df->df_total_data_size += ceilto(_region_size(data)); - df->df_num_entries++; - - return 0; - -} - -int -_citrus_db_factory_add_by_string(struct _citrus_db_factory *df, - const char *key, - struct _citrus_region *data, int datafree) -{ - struct _region r; - char *tmp; - tmp = strdup(key); - if (tmp == NULL) - return errno; - _region_init(&r, tmp, strlen(key)); - return _citrus_db_factory_add(df, &r, 1, data, datafree); -} - -int -_citrus_db_factory_add8_by_string(struct _citrus_db_factory *df, - const char *key, uint8_t val) -{ - struct _region r; - uint8_t *p; - - p = malloc(sizeof(*p)); - if (p == NULL) - return errno; - *p = val; - _region_init(&r, p, 1); - return _citrus_db_factory_add_by_string(df, key, &r, 1); -} - -int -_citrus_db_factory_add16_by_string(struct _citrus_db_factory *df, - const char *key, uint16_t val) -{ - struct _region r; - uint16_t *p; - - p = malloc(sizeof(*p)); - if (p == NULL) - return errno; - *p = htons(val); - _region_init(&r, p, 2); - return _citrus_db_factory_add_by_string(df, key, &r, 1); -} - -int -_citrus_db_factory_add32_by_string(struct _citrus_db_factory *df, - const char *key, uint32_t val) -{ - struct _region r; - uint32_t *p; - - p = malloc(sizeof(*p)); - if (p == NULL) - return errno; - *p = htonl(val); - _region_init(&r, p, 4); - return _citrus_db_factory_add_by_string(df, key, &r, 1); -} - -int -_citrus_db_factory_add_string_by_string(struct _citrus_db_factory *df, - const char *key, const char *data) -{ - char *p; - struct _region r; - - p = strdup(data); - if (p == NULL) - return errno; - _region_init(&r, p, strlen(p)+1); - return _citrus_db_factory_add_by_string(df, key, &r, 1); -} - -size_t -_citrus_db_factory_calc_size(struct _citrus_db_factory *df) -{ - size_t sz; - - sz = ceilto(_CITRUS_DB_HEADER_SIZE); - sz += ceilto(_CITRUS_DB_ENTRY_SIZE * df->df_num_entries); - sz += ceilto(df->df_total_key_size); - sz += df->df_total_data_size; - - return sz; -} - -static __inline void -put8(struct _region *r, size_t *rofs, uint8_t val) -{ - *(uint8_t *)_region_offset(r, *rofs) = val; - *rofs += 1; -} - -static __inline void -put32(struct _region *r, size_t *rofs, uint32_t val) -{ - val = htonl(val); - memcpy(_region_offset(r, *rofs), &val, 4); - *rofs += 4; -} - -static __inline void -putpad(struct _region *r, size_t *rofs) -{ - size_t i; - for (i = ceilto(*rofs) - *rofs; i > 0; i--) - put8(r, rofs, 0); -} - -static __inline void -dump_header(struct _region *r, const char *magic, size_t *rofs, - size_t num_entries) -{ - while (*rofs<_CITRUS_DB_MAGIC_SIZE) - put8(r, rofs, *magic++); - put32(r, rofs, num_entries); - put32(r, rofs, _CITRUS_DB_HEADER_SIZE); -} - -int -_citrus_db_factory_serialize(struct _citrus_db_factory *df, const char *magic, - struct _region *r) -{ - size_t i, ofs, keyofs, dataofs, nextofs; - struct _citrus_db_factory_entry *de, **depp, *det; - - ofs = 0; - /* check whether more than 0 entries exist */ - if (df->df_num_entries == 0) { - dump_header(r, magic, &ofs, 0); - return 0; - } - /* allocate hash table */ - depp = malloc(sizeof(*depp) * df->df_num_entries); - if (depp == NULL) - return -1; - for (i = 0; i < df->df_num_entries; i++) - depp[i] = NULL; - - /* step1: store the entries which are not conflicting */ - SIMPLEQ_FOREACH(de, &df->df_entries, de_entry) { - de->de_hashvalue %= df->df_num_entries; - de->de_idx = -1; - de->de_next = NULL; - if (depp[de->de_hashvalue] == NULL) { - depp[de->de_hashvalue] = de; - de->de_idx = (int)de->de_hashvalue; - } - } - - /* step2: resolve conflicts */ - i = 0; - SIMPLEQ_FOREACH(de, &df->df_entries, de_entry) { - if (de->de_idx == -1) { - det = depp[de->de_hashvalue]; - while (det->de_next != NULL) - det = det->de_next; - det->de_next = de; - while (depp[i] != NULL) - i++; - depp[i] = de; - de->de_idx = (int)i; - } - } - - keyofs = - _CITRUS_DB_HEADER_SIZE + - ceilto(df->df_num_entries*_CITRUS_DB_ENTRY_SIZE); - dataofs = keyofs + ceilto(df->df_total_key_size); - - /* dump header */ - dump_header(r, magic, &ofs, df->df_num_entries); - - /* dump entries */ - for (i = 0; i < df->df_num_entries; i++) { - de = depp[i]; - nextofs = 0; - if (de->de_next) { - nextofs = - _CITRUS_DB_HEADER_SIZE + - de->de_next->de_idx * _CITRUS_DB_ENTRY_SIZE; - } - put32(r, &ofs, de->de_hashvalue); - put32(r, &ofs, nextofs); - put32(r, &ofs, keyofs); - put32(r, &ofs, _region_size(&de->de_key)); - put32(r, &ofs, dataofs); - put32(r, &ofs, _region_size(&de->de_data)); - memcpy(_region_offset(r, keyofs), - _region_head(&de->de_key), _region_size(&de->de_key)); - keyofs += _region_size(&de->de_key); - memcpy(_region_offset(r, dataofs), - _region_head(&de->de_data), _region_size(&de->de_data)); - dataofs += _region_size(&de->de_data); - putpad(r, &dataofs); - } - putpad(r, &ofs); - putpad(r, &keyofs); - free(depp); - - return 0; -} diff --git a/lib/libc/citrus/citrus_db_factory.h b/lib/libc/citrus/citrus_db_factory.h deleted file mode 100644 index 8b2f994a0..000000000 --- a/lib/libc/citrus/citrus_db_factory.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: citrus_db_factory.h,v 1.3 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_DB_FACTORY_H_ -#define _CITRUS_DB_FACTORY_H_ - -struct _citrus_db_factory; -typedef uint32_t (*_citrus_db_hash_func_t)(void *, struct _citrus_region *); - -__BEGIN_DECLS -int _citrus_db_factory_create(struct _citrus_db_factory **, - _citrus_db_hash_func_t, void *); -void _citrus_db_factory_free(struct _citrus_db_factory *); -int _citrus_db_factory_add(struct _citrus_db_factory *, - struct _citrus_region *, int, - struct _citrus_region *, int); -int _citrus_db_factory_add_by_string(struct _citrus_db_factory *, - const char *, - struct _citrus_region *, int); -int _citrus_db_factory_add8_by_string(struct _citrus_db_factory *, - const char *, uint8_t); -int _citrus_db_factory_add16_by_string(struct _citrus_db_factory *, - const char *, uint16_t); -int _citrus_db_factory_add32_by_string(struct _citrus_db_factory *, - const char *, uint32_t); -int _citrus_db_factory_add_string_by_string(struct _citrus_db_factory *, - const char *, const char *); -size_t _citrus_db_factory_calc_size(struct _citrus_db_factory *); -int _citrus_db_factory_serialize(struct _citrus_db_factory *, - const char *, struct _citrus_region *); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_db_file.h b/lib/libc/citrus/citrus_db_file.h deleted file mode 100644 index 4e5295736..000000000 --- a/lib/libc/citrus/citrus_db_file.h +++ /dev/null @@ -1,84 +0,0 @@ -/* $NetBSD: citrus_db_file.h,v 1.4 2008/02/10 05:58:22 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_DB_FILE_H_ -#define _CITRUS_DB_FILE_H_ - -/* - * db format: - * +--- - * | header - * | - magic - * | - num entries - * +--- - * | entry directory - * | +------------ - * | | entry0 - * | | - hash value - * | | - next entry - * | | - key offset - * | | - key len - * | | - data offset - * | | - data size - * | |--- - * | | entry1 - * | | .. - * | | entryN - * | +--- - * +--- - * | key table - * | - key0 - * | ... - * | - keyN - * +--- - * | data table - * | - data0 - * | ... - * | - dataN - * +--- - */ - -#define _CITRUS_DB_MAGIC_SIZE 8 -#define _CITRUS_DB_HEADER_SIZE 16 -struct _citrus_db_header_x { - char dhx_magic[_CITRUS_DB_MAGIC_SIZE]; - uint32_t dhx_num_entries; - uint32_t dhx_entry_offset; -} __packed; - -struct _citrus_db_entry_x { - uint32_t dex_hash_value; - uint32_t dex_next_offset; - uint32_t dex_key_offset; - uint32_t dex_key_size; - uint32_t dex_data_offset; - uint32_t dex_data_size; -} __packed; -#define _CITRUS_DB_ENTRY_SIZE 24 - -#endif diff --git a/lib/libc/citrus/citrus_db_hash.c b/lib/libc/citrus/citrus_db_hash.c deleted file mode 100644 index 9702391a0..000000000 --- a/lib/libc/citrus/citrus_db_hash.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: citrus_db_hash.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_db_hash.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef HOSTPROG -#include "namespace.h" -#endif -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_db_hash.h" - -uint32_t -/*ARGSUSED*/ -_citrus_db_hash_std(void *closure, struct _region *r) -{ - const uint8_t *p = _region_head(r); - uint32_t hash = 0, tmp; - size_t i; - - for (i = _region_size(r); i > 0; i--) { - hash <<= 4; - hash += _bcs_tolower(*p); - tmp = hash & 0xF0000000; - if (tmp != 0) { - hash ^= tmp; - hash ^= tmp >> 24; - } - p++; - } - return hash; -} diff --git a/lib/libc/citrus/citrus_db_hash.h b/lib/libc/citrus/citrus_db_hash.h deleted file mode 100644 index 55ee45e88..000000000 --- a/lib/libc/citrus/citrus_db_hash.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_db_hash.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_DB_HASH_H_ -#define _CITRUS_DB_HASH_H_ - -__BEGIN_DECLS -uint32_t _citrus_db_hash_std(void *, struct _citrus_region *); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_esdb.c b/lib/libc/citrus/citrus_esdb.c deleted file mode 100644 index 493400794..000000000 --- a/lib/libc/citrus/citrus_esdb.c +++ /dev/null @@ -1,355 +0,0 @@ -/* $NetBSD: citrus_esdb.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_esdb.c,v 1.5 2008/02/09 14:56:20 junyoung Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_lookup.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" -#include "citrus_esdb.h" -#include "citrus_esdb_file.h" - -#define ESDB_DIR "esdb.dir" -#define ESDB_ALIAS "esdb.alias" - -/* - * _citrus_esdb_alias: - * resolve encoding scheme name aliases. - */ -const char * -_citrus_esdb_alias(const char *esname, char *buf, size_t bufsize) -{ - return _lookup_alias(_PATH_ESDB "/" ESDB_ALIAS, esname, buf, bufsize, - _LOOKUP_CASE_IGNORE); -} - - -/* - * conv_esdb: - * external representation -> local structure. - */ -static int -conv_esdb(struct _citrus_esdb *esdb, struct _region *fr) -{ - int ret; - struct _citrus_db *db; - uint32_t version, num_charsets, csid, i, tmp; - char buf[100]; - const char *str; - - /* open db */ - ret = _db_open(&db, fr, _CITRUS_ESDB_MAGIC, &_db_hash_std, NULL); - if (ret) - goto err0; - - /* check version */ - ret = _db_lookup32_by_s(db, _CITRUS_ESDB_SYM_VERSION, &version, NULL); - if (ret) - goto err1; - switch (version) { - case 0x00000001: - /* current version */ - /* initial version */ - break; - default: - ret = EFTYPE; - goto err1; - } - - /* get encoding/variable */ - ret = _db_lookupstr_by_s(db, _CITRUS_ESDB_SYM_ENCODING, &str, NULL); - if (ret) - goto err1; - esdb->db_encname = strdup(str); - if (esdb->db_encname == NULL) { - ret = errno; - goto err1; - } - - esdb->db_len_variable = 0; - esdb->db_variable = NULL; - ret = _db_lookupstr_by_s(db, _CITRUS_ESDB_SYM_VARIABLE, &str, NULL); - if (ret == 0) { - esdb->db_len_variable = strlen(str)+1; - esdb->db_variable = strdup(str); - if (esdb->db_variable == NULL) { - ret = errno; - goto err2; - } - } else if (ret != ENOENT) - goto err2; - - /* get number of charsets */ - ret = _db_lookup32_by_s(db, _CITRUS_ESDB_SYM_NUM_CHARSETS, - &num_charsets, NULL); - if (ret) - goto err3; - esdb->db_num_charsets = num_charsets; - - /* get invalid character */ - ret = _db_lookup32_by_s(db, _CITRUS_ESDB_SYM_INVALID, &tmp, NULL); - if (ret == 0) { - esdb->db_use_invalid = 1; - esdb->db_invalid = tmp; - } else if (ret == ENOENT) - esdb->db_use_invalid = 0; - else - goto err3; - - /* get charsets */ - esdb->db_charsets = malloc(num_charsets * sizeof(*esdb->db_charsets)); - if (esdb->db_charsets == NULL) { - ret = errno; - goto err3; - } - for (i = 0; i < num_charsets; i++) { - snprintf(buf, sizeof(buf), - _CITRUS_ESDB_SYM_CSID_PREFIX "%d", i); - ret = _db_lookup32_by_s(db, buf, &csid, NULL); - if (ret) - goto err4; - esdb->db_charsets[i].ec_csid = csid; - - snprintf(buf, sizeof(buf), - _CITRUS_ESDB_SYM_CSNAME_PREFIX "%d", i); - ret = _db_lookupstr_by_s(db, buf, &str, NULL); - if (ret) - goto err4; - esdb->db_charsets[i].ec_csname = strdup(str); - if (esdb->db_charsets[i].ec_csname == NULL) { - ret = errno; - goto err4; - } - } - - _db_close(db); - return 0; - -err4: - for (; i > 0; i--) - free(esdb->db_charsets[i - 1].ec_csname); - free(esdb->db_charsets); -err3: - free(esdb->db_variable); -err2: - free(esdb->db_encname); -err1: - _db_close(db); - if (ret == ENOENT) - ret = EFTYPE; -err0: - return ret; -} - -/* - * _citrus_esdb_open: - * open an ESDB file. - */ -int -_citrus_esdb_open(struct _citrus_esdb *db, const char *esname) -{ - int ret; - const char *realname, *encfile; - char buf1[PATH_MAX], buf2[PATH_MAX], path[PATH_MAX]; - struct _region fr; - - _DIAGASSERT(esname != NULL); - - snprintf(path, sizeof(path), "%s/%s", _PATH_ESDB, ESDB_ALIAS); - realname = _lookup_alias(path, esname, buf1, sizeof(buf1), - _LOOKUP_CASE_IGNORE); - - snprintf(path, sizeof(path), "%s/%s", _PATH_ESDB, ESDB_DIR); - encfile = _lookup_simple(path, realname, buf2, sizeof(buf2), - _LOOKUP_CASE_IGNORE); - if (encfile==NULL) - return ENOENT; - - /* open file */ - snprintf(path, sizeof(path), "%s/%s", _PATH_ESDB, encfile); - ret = _map_file(&fr, path); - if (ret) - return ret; - - ret = conv_esdb(db, &fr); - - _unmap_file(&fr); - - return ret; -} - -/* - * _citrus_esdb_close: - * free an ESDB. - */ -void -_citrus_esdb_close(struct _citrus_esdb *db) -{ - int i; - - _DIAGASSERT(db != NULL); - _DIAGASSERT(db->db_num_charsets == 0 || db->db_charsets != NULL); - - for (i = 0; i < db->db_num_charsets; i++) - free(db->db_charsets[i].ec_csname); - db->db_num_charsets = 0; - free(db->db_charsets); db->db_charsets = NULL; - free(db->db_encname); db->db_encname = NULL; - db->db_len_variable = 0; - free(db->db_variable); db->db_variable = NULL; -} - -/* - * _citrus_esdb_free_list: - * free the list. - */ -void -_citrus_esdb_free_list(char **list, size_t num) -{ - size_t i; - - for (i = 0; i < num; i++) - free(list[i]); - free(list); -} - -/* - * _citrus_esdb_get_list: - * get esdb entries. - */ -int -_citrus_esdb_get_list(char ***rlist, size_t *rnum) -{ - int ret; - struct _region key; - size_t num; - struct _citrus_lookup *cla, *cld; - char **list, **q; - char buf[PATH_MAX]; - - num = 0; - - ret = _lookup_seq_open(&cla, _PATH_ESDB "/" ESDB_ALIAS, - _LOOKUP_CASE_IGNORE); - if (ret) - goto quit0; - - ret = _lookup_seq_open(&cld, _PATH_ESDB "/" ESDB_DIR, - _LOOKUP_CASE_IGNORE); - if (ret) - goto quit1; - - /* count number of entries */ - num = _lookup_get_num_entries(cla) + _lookup_get_num_entries(cld); - - _lookup_seq_rewind(cla); - _lookup_seq_rewind(cld); - - /* allocate list pointer space */ - list = malloc(num * sizeof(char *)); - num = 0; - if (list == NULL) { - ret = errno; - goto quit3; - } - - /* get alias entries */ - while ((ret = _lookup_seq_next(cla, &key, NULL)) == 0) { - snprintf(buf, sizeof(buf), "%.*s", - (int)_region_size(&key), - (const char *)_region_head(&key)); - _bcs_convert_to_lower(buf); - list[num] = strdup(buf); - if (list[num] == NULL) { - ret = errno; - goto quit3; - } - num++; - } - if (ret != ENOENT) - goto quit3; - /* get dir entries */ - while ((ret = _lookup_seq_next(cld, &key, NULL)) == 0) { - /* check duplicated entry */ - snprintf(buf, sizeof(buf), "%.*s", - (int)_region_size(&key), - (const char *)_region_head(&key)); - _bcs_convert_to_lower(buf); - ret = _lookup_seq_lookup(cla, buf, NULL); - if (ret) { - if (ret != ENOENT) - goto quit3; - /* not duplicated */ - list[num] = strdup(buf); - if (list[num] == NULL) { - ret = errno; - goto quit3; - } - num++; - } - } - if (ret != ENOENT) - goto quit3; - - ret = 0; - q = realloc(list, num * sizeof(char *)); - if (!q) { - ret = ENOMEM; - goto quit3; - } - list = q; - *rlist = list; - *rnum = num; -quit3: - if (ret) - _citrus_esdb_free_list(list, num); - _lookup_seq_close(cld); -quit1: - _lookup_seq_close(cla); -quit0: - return ret; -} diff --git a/lib/libc/citrus/citrus_esdb.h b/lib/libc/citrus/citrus_esdb.h deleted file mode 100644 index dce973dad..000000000 --- a/lib/libc/citrus/citrus_esdb.h +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: citrus_esdb.h,v 1.1 2003/06/25 09:51:32 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ESDB_H_ -#define _CITRUS_ESDB_H_ - -struct _citrus_esdb_charset { - _citrus_csid_t ec_csid; - char *ec_csname; -}; - -struct _citrus_esdb { - char *db_encname; - void *db_variable; - size_t db_len_variable; - int db_num_charsets; - struct _citrus_esdb_charset *db_charsets; - int db_use_invalid; - _citrus_wc_t db_invalid; -}; - -__BEGIN_DECLS -const char *_citrus_esdb_alias(const char *, char *, size_t); -int _citrus_esdb_open(struct _citrus_esdb *, const char *); -void _citrus_esdb_close(struct _citrus_esdb *); -void _citrus_esdb_free_list(char **, size_t); -int _citrus_esdb_get_list(char ***, size_t *); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_esdb_file.h b/lib/libc/citrus/citrus_esdb_file.h deleted file mode 100644 index 5bb05a27e..000000000 --- a/lib/libc/citrus/citrus_esdb_file.h +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: citrus_esdb_file.h,v 1.1 2003/06/25 09:51:32 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ESDB_FILE_H_ -#define _CITRUS_ESDB_FILE_H_ - -#define _CITRUS_ESDB_MAGIC "ESDB\0\0\0\0" - -#define _CITRUS_ESDB_SYM_VERSION "version" -#define _CITRUS_ESDB_SYM_ENCODING "encoding" -#define _CITRUS_ESDB_SYM_VARIABLE "variable" -#define _CITRUS_ESDB_SYM_NUM_CHARSETS "num_charsets" -#define _CITRUS_ESDB_SYM_INVALID "invalid" -#define _CITRUS_ESDB_SYM_CSNAME_PREFIX "csname_" -#define _CITRUS_ESDB_SYM_CSID_PREFIX "csid_" - -#define _CITRUS_ESDB_VERSION 0x00000001 - -#endif diff --git a/lib/libc/citrus/citrus_fix_grouping.h b/lib/libc/citrus/citrus_fix_grouping.h deleted file mode 100644 index f4e85e539..000000000 --- a/lib/libc/citrus/citrus_fix_grouping.h +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: citrus_fix_grouping.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_FIX_GROUPING_H_ -#define _CITRUS_FIX_GROUPING_H_ - -#define _CITRUS_LC_GROUPING_VALUE_MIN 0 -#define _CITRUS_LC_GROUPING_VALUE_MAX 126 -#define _CITRUS_LC_GROUPING_VALUE_NO_FUTHER 127 - -#if CHAR_MAX != _CITRUS_LC_GROUPING_VALUE_NO_FUTHER -static __inline void -_citrus_fixup_char_max_md(char *grouping) -{ - char *p; - - _DIAGASSERT(grouping != NULL); - - for (p = grouping; *p != '\0'; ++p) { - if (*p == _CITRUS_LC_GROUPING_VALUE_NO_FUTHER) - *p = (char)CHAR_MAX; - } -} -#define _CITRUS_FIXUP_CHAR_MAX_MD(grouping) \ - _citrus_fixup_char_max_md(__UNCONST(grouping)) -#else -#define _CITRUS_FIXUP_CHAR_MAX_MD(grouping) /* nothing to do */ -#endif - -#endif /*_CITRUS_FIX_GROUPING_H_*/ diff --git a/lib/libc/citrus/citrus_hash.c b/lib/libc/citrus/citrus_hash.c deleted file mode 100644 index 954ce21e8..000000000 --- a/lib/libc/citrus/citrus_hash.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: citrus_hash.c,v 1.3 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_hash.c,v 1.3 2008/02/09 14:56:20 junyoung Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_region.h" -#include "citrus_hash.h" -#include "citrus_db_hash.h" - -int -_citrus_string_hash_func(const char *key, int hashsize) -{ - struct _region r; - - _region_init(&r, __UNCONST(key), strlen(key)); - - return (int)(_db_hash_std(NULL, &r) % (uint32_t)hashsize); -} diff --git a/lib/libc/citrus/citrus_hash.h b/lib/libc/citrus/citrus_hash.h deleted file mode 100644 index 2e677a17f..000000000 --- a/lib/libc/citrus/citrus_hash.h +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: citrus_hash.h,v 1.3 2004/01/02 21:49:35 itojun Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_HASH_H_ -#define _CITRUS_HASH_H_ - -#define _CITRUS_HASH_ENTRY(type) LIST_ENTRY(type) -#define _CITRUS_HASH_HEAD(headname, type, hashsize) \ -struct headname { \ - LIST_HEAD(, type) chh_table[hashsize]; \ -} -#define _CITRUS_HASH_INIT(head, hashsize) \ -do { \ - int _ch_loop; \ - for (_ch_loop = 0; _ch_loop < hashsize; _ch_loop++) \ - LIST_INIT(&(head)->chh_table[_ch_loop]); \ -} while (/*CONSTCOND*/0) -#define _CITRUS_HASH_REMOVE(elm, field) LIST_REMOVE(elm, field) -#define _CITRUS_HASH_INSERT(head, elm, field, hashval) \ -LIST_INSERT_HEAD(&(head)->chh_table[hashval], elm, field) -#define _CITRUS_HASH_SEARCH(head, elm, field, matchfunc, key, hashval) \ -do { \ - LIST_FOREACH((elm), &(head)->chh_table[hashval], field) { \ - if (matchfunc((elm), key)==0) \ - break; \ - } \ -} while (/*CONSTCOND*/0) - -__BEGIN_DECLS -int _citrus_string_hash_func(const char *, int); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_iconv.c b/lib/libc/citrus/citrus_iconv.c deleted file mode 100644 index 3b8f61e53..000000000 --- a/lib/libc/citrus/citrus_iconv.c +++ /dev/null @@ -1,393 +0,0 @@ -/* $NetBSD: citrus_iconv.c,v 1.10 2011/11/19 18:34:21 tnozaki Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_iconv.c,v 1.10 2011/11/19 18:34:21 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_module.h" -#include "citrus_lookup.h" -#include "citrus_hash.h" -#include "citrus_iconv.h" - -#define _CITRUS_ICONV_DIR "iconv.dir" -#define _CITRUS_ICONV_ALIAS "iconv.alias" - -#define CI_HASH_SIZE 101 -#define CI_INITIAL_MAX_REUSE 5 -#define CI_ENV_MAX_REUSE "ICONV_MAX_REUSE" - -#ifdef _REENTRANT -static rwlock_t lock = RWLOCK_INITIALIZER; -#endif - -static bool isinit = false; -static _CITRUS_HASH_HEAD(, _citrus_iconv_shared, CI_HASH_SIZE) shared_pool; -static TAILQ_HEAD(, _citrus_iconv_shared) shared_unused; -static int shared_num_unused, shared_max_reuse; - -static __inline void -init_cache(void) -{ - rwlock_wrlock(&lock); - if (!isinit) { - _CITRUS_HASH_INIT(&shared_pool, CI_HASH_SIZE); - TAILQ_INIT(&shared_unused); - shared_max_reuse = -1; - if (!issetugid() && getenv(CI_ENV_MAX_REUSE)) - shared_max_reuse = atoi(getenv(CI_ENV_MAX_REUSE)); - if (shared_max_reuse < 0) - shared_max_reuse = CI_INITIAL_MAX_REUSE; - isinit = true; - } - rwlock_unlock(&lock); -} - -/* - * lookup_iconv_entry: - * lookup iconv.dir entry in the specified directory. - * - * line format of iconv.dir file: - * key module arg - * key : lookup key. - * module : iconv module name. - * arg : argument for the module (generally, description file name) - * - */ -static __inline int -lookup_iconv_entry(const char *curdir, const char *key, - char *linebuf, size_t linebufsize, - const char **module, const char **variable) -{ - const char *cp, *cq; - char *p, path[PATH_MAX]; - - /* iconv.dir path */ - snprintf(path, (size_t)PATH_MAX, ("%s/" _CITRUS_ICONV_DIR), curdir); - - /* lookup db */ - cp = p = _lookup_simple(path, key, linebuf, linebufsize, - _LOOKUP_CASE_IGNORE); - if (p == NULL) - return ENOENT; - - /* get module name */ - *module = p; - cq = _bcs_skip_nonws(cp); - p[cq-cp] = '\0'; - p += cq-cp+1; - cq++; - - /* get variable */ - cp = _bcs_skip_ws(cq); - *variable = p += cp - cq; - cq = _bcs_skip_nonws(cp); - p[cq-cp] = '\0'; - - return 0; -} - -static __inline void -close_shared(struct _citrus_iconv_shared *ci) -{ - if (ci) { - if (ci->ci_module) { - if (ci->ci_ops) { - if (ci->ci_closure) - (*ci->ci_ops->io_uninit_shared)(ci); - free(ci->ci_ops); - } - _citrus_unload_module(ci->ci_module); - } - free(ci); - } -} - -static __inline int -open_shared(struct _citrus_iconv_shared * __restrict * __restrict rci, - const char * __restrict basedir, const char * __restrict convname, - const char * __restrict src, const char * __restrict dst) -{ - int ret; - struct _citrus_iconv_shared *ci; - _citrus_iconv_getops_t getops; - char linebuf[LINE_MAX]; - const char *module, *variable; - size_t len_convname; - - /* search converter entry */ - ret = lookup_iconv_entry(basedir, convname, linebuf, sizeof(linebuf), - &module, &variable); - if (ret) { - if (ret == ENOENT) - /* fallback */ - ret = lookup_iconv_entry(basedir, "*", - linebuf, sizeof(linebuf), - &module, &variable); - if (ret) - return ret; - } - - /* initialize iconv handle */ - len_convname = strlen(convname); - ci = malloc(sizeof(*ci)+len_convname+1); - if (!ci) { - ret = errno; - goto err; - } - ci->ci_module = NULL; - ci->ci_ops = NULL; - ci->ci_closure = NULL; - ci->ci_convname = (void *)&ci[1]; - memcpy(ci->ci_convname, convname, len_convname+1); - - /* load module */ - ret = _citrus_load_module(&ci->ci_module, module); - if (ret) - goto err; - - /* get operators */ - getops = (_citrus_iconv_getops_t) - _citrus_find_getops(ci->ci_module, module, "iconv"); - if (!getops) { - ret = EOPNOTSUPP; - goto err; - } - ci->ci_ops = malloc(sizeof(*ci->ci_ops)); - if (!ci->ci_ops) { - ret = errno; - goto err; - } - ret = (*getops)(ci->ci_ops, sizeof(*ci->ci_ops), - _CITRUS_ICONV_ABI_VERSION); - if (ret) - goto err; - - /* version check */ - if (ci->ci_ops->io_abi_version == 1) { - /* binary compatibility broken at ver.2 */ - ret = EINVAL; - goto err; - } - - if (ci->ci_ops->io_init_shared == NULL || - ci->ci_ops->io_uninit_shared == NULL || - ci->ci_ops->io_init_context == NULL || - ci->ci_ops->io_uninit_context == NULL || - ci->ci_ops->io_convert == NULL) { - ret = EINVAL; - goto err; - } - - /* initialize the converter */ - ret = (*ci->ci_ops->io_init_shared)(ci, basedir, src, dst, - (const void *)variable, - strlen(variable)+1); - if (ret) - goto err; - - *rci = ci; - - return 0; -err: - close_shared(ci); - return ret; -} - -static __inline int -hash_func(const char *key) -{ - return _string_hash_func(key, CI_HASH_SIZE); -} - -static __inline int -match_func(struct _citrus_iconv_shared * __restrict ci, - const char * __restrict key) -{ - return strcmp(ci->ci_convname, key); -} - -static int -get_shared(struct _citrus_iconv_shared * __restrict * __restrict rci, - const char *basedir, const char *src, const char *dst) -{ - int ret = 0; - int hashval; - struct _citrus_iconv_shared * ci; - char convname[PATH_MAX]; - - snprintf(convname, sizeof(convname), "%s/%s", src, dst); - - rwlock_wrlock(&lock); - - /* lookup alread existing entry */ - hashval = hash_func(convname); - _CITRUS_HASH_SEARCH(&shared_pool, ci, ci_hash_entry, match_func, - convname, hashval); - if (ci != NULL) { - /* found */ - if (ci->ci_used_count == 0) { - TAILQ_REMOVE(&shared_unused, ci, ci_tailq_entry); - shared_num_unused--; - } - ci->ci_used_count++; - *rci = ci; - goto quit; - } - - /* create new entry */ - ret = open_shared(&ci, basedir, convname, src, dst); - if (ret) - goto quit; - - _CITRUS_HASH_INSERT(&shared_pool, ci, ci_hash_entry, hashval); - ci->ci_used_count = 1; - *rci = ci; - -quit: - rwlock_unlock(&lock); - - return ret; -} - -static void -release_shared(struct _citrus_iconv_shared * __restrict ci) -{ - rwlock_wrlock(&lock); - - ci->ci_used_count--; - if (ci->ci_used_count == 0) { - /* put it into unused list */ - shared_num_unused++; - TAILQ_INSERT_TAIL(&shared_unused, ci, ci_tailq_entry); - /* flood out */ - while (shared_num_unused > shared_max_reuse) { - ci = TAILQ_FIRST(&shared_unused); - _DIAGASSERT(ci != NULL); - TAILQ_REMOVE(&shared_unused, ci, ci_tailq_entry); - _CITRUS_HASH_REMOVE(ci, ci_hash_entry); - shared_num_unused--; - close_shared(ci); - } - } - - rwlock_unlock(&lock); -} - -/* - * _citrus_iconv_open: - * open a converter for the specified in/out codes. - */ -int -_citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict rcv, - const char * __restrict basedir, - const char * __restrict src, const char * __restrict dst) -{ - int ret; - struct _citrus_iconv_shared *ci = NULL; - struct _citrus_iconv *cv; - char realsrc[PATH_MAX], realdst[PATH_MAX]; - char buf[PATH_MAX], path[PATH_MAX]; - - init_cache(); - - /* resolve codeset name aliases */ - snprintf(path, sizeof(path), "%s/%s", basedir, _CITRUS_ICONV_ALIAS); - strlcpy(realsrc, - _lookup_alias(path, src, buf, (size_t)PATH_MAX, - _LOOKUP_CASE_IGNORE), - (size_t)PATH_MAX); - strlcpy(realdst, - _lookup_alias(path, dst, buf, (size_t)PATH_MAX, - _LOOKUP_CASE_IGNORE), - (size_t)PATH_MAX); - - /* sanity check */ - if (strchr(realsrc, '/') != NULL || strchr(realdst, '/')) - return EINVAL; - - /* get shared record */ - ret = get_shared(&ci, basedir, realsrc, realdst); - if (ret) - return ret; - - /* create/init context */ - cv = malloc(sizeof(*cv)); - if (cv == NULL) { - ret = errno; - release_shared(ci); - return ret; - } - cv->cv_shared = ci; - ret = (*ci->ci_ops->io_init_context)(cv); - if (ret) { - release_shared(ci); - free(cv); - return ret; - } - *rcv = cv; - - return 0; -} - -/* - * _citrus_iconv_close: - * close the specified converter. - */ -void -_citrus_iconv_close(struct _citrus_iconv *cv) -{ - if (cv) { - (*cv->cv_shared->ci_ops->io_uninit_context)(cv); - release_shared(cv->cv_shared); - free(cv); - } -} diff --git a/lib/libc/citrus/citrus_iconv.h b/lib/libc/citrus/citrus_iconv.h deleted file mode 100644 index 37192600d..000000000 --- a/lib/libc/citrus/citrus_iconv.h +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: citrus_iconv.h,v 1.5 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ICONV_H_ -#define _CITRUS_ICONV_H_ - -struct _citrus_iconv_shared; -struct _citrus_iconv_ops; -struct _citrus_iconv; - -__BEGIN_DECLS -int _citrus_iconv_open(struct _citrus_iconv * __restrict * __restrict, - const char * __restrict, - const char * __restrict, const char * __restrict); -void _citrus_iconv_close(struct _citrus_iconv *); -__END_DECLS - - -#include "citrus_iconv_local.h" - -#define _CITRUS_ICONV_F_HIDE_INVALID 0x0001 - -/* - * _citrus_iconv_convert: - * convert a string. - */ -static __inline int -_citrus_iconv_convert(struct _citrus_iconv * __restrict cv, - const char * __restrict * __restrict in, - size_t * __restrict inbytes, - char * __restrict * __restrict out, - size_t * __restrict outbytes, uint32_t flags, - size_t * __restrict nresults) -{ - - _DIAGASSERT(cv && cv->cv_shared && cv->cv_shared->ci_ops && - cv->cv_shared->ci_ops->io_convert); - _DIAGASSERT(out || outbytes == 0); - - return (*cv->cv_shared->ci_ops->io_convert)(cv, in, inbytes, out, - outbytes, flags, nresults); -} - -#endif diff --git a/lib/libc/citrus/citrus_iconv_local.h b/lib/libc/citrus/citrus_iconv_local.h deleted file mode 100644 index fd42e84d2..000000000 --- a/lib/libc/citrus/citrus_iconv_local.h +++ /dev/null @@ -1,107 +0,0 @@ -/* $NetBSD: citrus_iconv_local.h,v 1.3 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ICONV_LOCAL_H_ -#define _CITRUS_ICONV_LOCAL_H_ - -#define _CITRUS_ICONV_GETOPS_FUNC_BASE(_n_) \ -int _n_(struct _citrus_iconv_ops *, size_t, uint32_t) -#define _CITRUS_ICONV_GETOPS_FUNC(_n_) \ -_CITRUS_ICONV_GETOPS_FUNC_BASE(_citrus_##_n_##_iconv_getops) - -#define _CITRUS_ICONV_DECLS(_m_) \ -static int _citrus_##_m_##_iconv_init_shared \ - (struct _citrus_iconv_shared * __restrict, \ - const char * __restrict, \ - const char * __restrict, const char * __restrict, \ - const void * __restrict, size_t); \ -static void _citrus_##_m_##_iconv_uninit_shared \ - (struct _citrus_iconv_shared *); \ -static int _citrus_##_m_##_iconv_convert \ - (struct _citrus_iconv * __restrict, \ - const char * __restrict * __restrict, size_t * __restrict, \ - char * __restrict * __restrict, size_t * __restrict outbytes, \ - uint32_t, size_t * __restrict); \ -static int _citrus_##_m_##_iconv_init_context \ - (struct _citrus_iconv *); \ -static void _citrus_##_m_##_iconv_uninit_context \ - (struct _citrus_iconv *) - - -#define _CITRUS_ICONV_DEF_OPS(_m_) \ -struct _citrus_iconv_ops _citrus_##_m_##_iconv_ops = { \ - /* io_abi_version */ _CITRUS_ICONV_ABI_VERSION, \ - /* io_init_shared */ &_citrus_##_m_##_iconv_init_shared, \ - /* io_uninit_shared */ &_citrus_##_m_##_iconv_uninit_shared, \ - /* io_init_context */ &_citrus_##_m_##_iconv_init_context, \ - /* io_uninit_context */ &_citrus_##_m_##_iconv_uninit_context, \ - /* io_convert */ &_citrus_##_m_##_iconv_convert \ -} - -typedef _CITRUS_ICONV_GETOPS_FUNC_BASE((*_citrus_iconv_getops_t)); -typedef int (*_citrus_iconv_init_shared_t) - (struct _citrus_iconv_shared * __restrict, - const char * __restrict, const char * __restrict, - const char * __restrict, const void * __restrict, size_t); -typedef void (*_citrus_iconv_uninit_shared_t) - (struct _citrus_iconv_shared *); -typedef int (*_citrus_iconv_convert_t) - (struct _citrus_iconv * __restrict, - const char *__restrict* __restrict, size_t * __restrict, - char * __restrict * __restrict, size_t * __restrict, uint32_t, - size_t * __restrict); -typedef int (*_citrus_iconv_init_context_t)(struct _citrus_iconv *); -typedef void (*_citrus_iconv_uninit_context_t)(struct _citrus_iconv *); - -struct _citrus_iconv_ops { - uint32_t io_abi_version; - _citrus_iconv_init_shared_t io_init_shared; - _citrus_iconv_uninit_shared_t io_uninit_shared; - _citrus_iconv_init_context_t io_init_context; - _citrus_iconv_uninit_context_t io_uninit_context; - _citrus_iconv_convert_t io_convert; -}; -#define _CITRUS_ICONV_ABI_VERSION 2 - -struct _citrus_iconv_shared { - struct _citrus_iconv_ops *ci_ops; - void *ci_closure; - /* private */ - _CITRUS_HASH_ENTRY(_citrus_iconv_shared) ci_hash_entry; - TAILQ_ENTRY(_citrus_iconv_shared) ci_tailq_entry; - _citrus_module_t ci_module; - unsigned int ci_used_count; - char *ci_convname; -}; - -struct _citrus_iconv { - struct _citrus_iconv_shared *cv_shared; - void *cv_closure; -}; - -#endif diff --git a/lib/libc/citrus/citrus_lc_ctype.c b/lib/libc/citrus/citrus_lc_ctype.c deleted file mode 100644 index 3205b09ad..000000000 --- a/lib/libc/citrus/citrus_lc_ctype.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $NetBSD: citrus_lc_ctype.c,v 1.15 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lc_ctype.c,v 1.15 2013/09/13 13:13:32 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "reentrant.h" -#include -#include -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_lookup.h" -#include "citrus_aliasname_local.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_mmap.h" - -#include "runetype_local.h" -#include "multibyte.h" - -/* - * macro required by all template headers - */ -#define _PREFIX(name) __CONCAT(_citrus_LC_CTYPE_, name) - -/* - * macro required by nb_lc_template(_decl).h - */ -#define _CATEGORY_TYPE _RuneLocale - -#include "nb_lc_template_decl.h" - -static int -_citrus_LC_CTYPE_create_impl(const char * __restrict root, - const char * __restrict name, _RuneLocale ** __restrict pdata) -{ - char path[PATH_MAX + 1]; - int ret; - struct _region r; - - _DIAGASSERT(root != NULL); - _DIAGASSERT(name != NULL); - _DIAGASSERT(pdata != NULL); - - snprintf(path, sizeof(path), - "%s/%s/LC_CTYPE", root, name); - ret = _citrus_map_file(&r, path); - if (!ret) { - ret = _rune_load((const char *)r.r_head, r.r_size, pdata); - _citrus_unmap_file(&r); - } - return ret; -} - -static __inline void -_PREFIX(update_global)(_RuneLocale *data) -{ - _DIAGASSERT(data != NULL); - - __mb_cur_max = _citrus_ctype_get_mb_cur_max(data->rl_citrus_ctype); - _ctype_tab_ = data->rl_ctype_tab; - _tolower_tab_ = data->rl_tolower_tab; - _toupper_tab_ = data->rl_toupper_tab; - -#ifdef __BUILD_LEGACY - _ctype_ = data->rl_compat_bsdctype; -#endif -} - -/* - * macro required by nb_lc_template.h - */ -#define _CATEGORY_ID LC_CTYPE -#define _CATEGORY_NAME "LC_CTYPE" - -#include "nb_lc_template.h" diff --git a/lib/libc/citrus/citrus_lc_messages.c b/lib/libc/citrus/citrus_lc_messages.c deleted file mode 100644 index 8f0936042..000000000 --- a/lib/libc/citrus/citrus_lc_messages.c +++ /dev/null @@ -1,162 +0,0 @@ -/* $NetBSD: citrus_lc_messages.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lc_messages.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include -#include -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_lookup.h" -#include "citrus_aliasname_local.h" -#include "citrus_module.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" -#include "citrus_memstream.h" -#include "runetype_local.h" - -/* - * macro required by all template headers - */ -#define _PREFIX(name) __CONCAT(_citrus_LC_MESSAGES_, name) - -#include "nb_lc_messages_misc.h" -#include "citrus_lc_template_decl.h" - -static __inline void -_citrus_LC_MESSAGES_uninit(_MessagesLocale *data) -{ - free(__UNCONST(data->yesexpr)); - free(__UNCONST(data->noexpr)); - free(__UNCONST(data->yesstr)); - free(__UNCONST(data->nostr)); -} - -#include "citrus_lc_messages.h" - -struct _citrus_LC_MESSAGES_key { - const char *name; - size_t offset; -}; - -#define OFFSET(field) (offsetof(_MessagesLocale, field)) -static const struct _citrus_LC_MESSAGES_key keys[] = { - { _CITRUS_LC_MESSAGES_SYM_YESEXPR, OFFSET(yesexpr) }, - { _CITRUS_LC_MESSAGES_SYM_NOEXPR, OFFSET(noexpr ) }, - { _CITRUS_LC_MESSAGES_SYM_YESSTR, OFFSET(yesstr ) }, - { _CITRUS_LC_MESSAGES_SYM_NOSTR, OFFSET(nostr ) }, - { NULL, 0 } -}; - -static __inline int -_citrus_LC_MESSAGES_init_normal(_MessagesLocale * __restrict data, - struct _citrus_db * __restrict db) -{ - const struct _citrus_LC_MESSAGES_key *key; - char **p; - const char *s; - - _DIAGASSERT(data != NULL); - _DIAGASSERT(db != NULL); - - memset(data, 0, sizeof(*data)); - for (key = &keys[0]; key->name != NULL; ++key) { - if (_db_lookupstr_by_s(db, key->name, &s, NULL)) - goto fatal; - p = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p = strdup(s); - if (*p == NULL) - goto fatal; - } - return 0; - -fatal: - _citrus_LC_MESSAGES_uninit(data); - return EFTYPE; -} - -static __inline int -_citrus_LC_MESSAGES_init_fallback(_MessagesLocale * __restrict data, - struct _memstream * __restrict ms) -{ - const struct _citrus_LC_MESSAGES_key *key; - char **p; - const char *s; - size_t n; - - _DIAGASSERT(data != NULL); - _DIAGASSERT(ms != NULL); - - memset(data, 0, sizeof(*data)); - for (key = &keys[0]; key->name != NULL; ++key) { - if ((s = _memstream_getln(ms, &n)) == NULL) - goto fatal; - p = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p = strndup(s, n - 1); - if (*p == NULL) - goto fatal; - } - return 0; - -fatal: - _citrus_LC_MESSAGES_uninit(data); - return EFTYPE; -} - -/* - * macro required by citrus_lc_template.h - */ -#define _CATEGORY_DB "LC_MESSAGES/SYS_LC_MESSAGES" -#define _CATEGORY_MAGIC _CITRUS_LC_MESSAGES_MAGIC_1 - -#include "citrus_lc_template.h" diff --git a/lib/libc/citrus/citrus_lc_messages.h b/lib/libc/citrus/citrus_lc_messages.h deleted file mode 100644 index cdf7d395c..000000000 --- a/lib/libc/citrus/citrus_lc_messages.h +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: citrus_lc_messages.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LC_MESSAGES_H_ -#define _CITRUS_LC_MESSAGES_H_ - -/* - * - */ -#define _CITRUS_LC_MESSAGES_MAGIC_1 "CtrsME10" -#define _CITRUS_LC_MESSAGES_SYM_VERSION "version" -#define _CITRUS_LC_MESSAGES_VERSION 0x00000001 - -/* - * - */ -#define _CITRUS_LC_MESSAGES_SYM_YESEXPR "yesexpr" -#define _CITRUS_LC_MESSAGES_SYM_NOEXPR "noexpr" -#define _CITRUS_LC_MESSAGES_SYM_YESSTR "yesstr" -#define _CITRUS_LC_MESSAGES_SYM_NOSTR "nostr" - -#endif /*_CITRUS_LC_MESSAGES_H_*/ diff --git a/lib/libc/citrus/citrus_lc_monetary.c b/lib/libc/citrus/citrus_lc_monetary.c deleted file mode 100644 index 563dc3e99..000000000 --- a/lib/libc/citrus/citrus_lc_monetary.c +++ /dev/null @@ -1,219 +0,0 @@ -/* $NetBSD: citrus_lc_monetary.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lc_monetary.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include -#include -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_lookup.h" -#include "citrus_aliasname_local.h" -#include "citrus_module.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" -#include "citrus_memstream.h" -#include "runetype_local.h" - -#include "fix_grouping.h" -#include "citrus_fix_grouping.h" - -/* - * macro required by all template headers - */ -#define _PREFIX(name) __CONCAT(_citrus_LC_MONETARY_, name) - -#include "nb_lc_monetary_misc.h" -#include "citrus_lc_template_decl.h" - -static __inline void -_citrus_LC_MONETARY_uninit(_MonetaryLocale *data) -{ - _DIAGASSERT(data != NULL); - - free(__UNCONST(data->int_curr_symbol)); - free(__UNCONST(data->currency_symbol)); - free(__UNCONST(data->mon_decimal_point)); - free(__UNCONST(data->mon_thousands_sep)); - free(__UNCONST(data->mon_grouping)); - free(__UNCONST(data->positive_sign)); - free(__UNCONST(data->negative_sign)); -} - -#include "citrus_lc_monetary.h" - -struct _citrus_LC_MONETARY_key { - const char *name; - size_t offset; -}; - -#define OFFSET(field) (offsetof(_MonetaryLocale, field)) -static const struct _citrus_LC_MONETARY_key keys_string[] = { - { _CITRUS_LC_MONETARY_SYM_INT_CURR_SYMBOL, OFFSET(int_curr_symbol ) }, - { _CITRUS_LC_MONETARY_SYM_CURRENCY_SYMBOL, OFFSET(currency_symbol ) }, - { _CITRUS_LC_MONETARY_SYM_MON_DECIMAL_POINT, OFFSET(mon_decimal_point ) }, - { _CITRUS_LC_MONETARY_SYM_MON_THOUSANDS_SEP, OFFSET(mon_thousands_sep ) }, - { _CITRUS_LC_MONETARY_SYM_MON_GROUPING, OFFSET(mon_grouping ) }, - { _CITRUS_LC_MONETARY_SYM_POSITIVE_SIGN, OFFSET(positive_sign ) }, - { _CITRUS_LC_MONETARY_SYM_NEGATIVE_SIGN, OFFSET(negative_sign ) }, - { NULL, (size_t)0 } -}; -static const struct _citrus_LC_MONETARY_key keys_char[] = { - { _CITRUS_LC_MONETARY_SYM_INT_FRAC_DIGITS, OFFSET(int_frac_digits ) }, - { _CITRUS_LC_MONETARY_SYM_FRAC_DIGITS, OFFSET(frac_digits ) }, - { _CITRUS_LC_MONETARY_SYM_P_CS_PRECEDES, OFFSET(p_cs_precedes ) }, - { _CITRUS_LC_MONETARY_SYM_P_SEP_BY_SPACE, OFFSET(p_sep_by_space ) }, - { _CITRUS_LC_MONETARY_SYM_N_CS_PRECEDES, OFFSET(n_cs_precedes ) }, - { _CITRUS_LC_MONETARY_SYM_N_SEP_BY_SPACE, OFFSET(n_sep_by_space ) }, - { _CITRUS_LC_MONETARY_SYM_P_SIGN_POSN, OFFSET(p_sign_posn ) }, - { _CITRUS_LC_MONETARY_SYM_N_SIGN_POSN, OFFSET(n_sign_posn ) }, - { _CITRUS_LC_MONETARY_SYM_INT_P_CS_PRECEDES, OFFSET(int_p_cs_precedes ) }, - { _CITRUS_LC_MONETARY_SYM_INT_N_CS_PRECEDES, OFFSET(int_n_cs_precedes ) }, - { _CITRUS_LC_MONETARY_SYM_INT_P_SEP_BY_SPACE, OFFSET(int_p_sep_by_space) }, - { _CITRUS_LC_MONETARY_SYM_INT_N_SEP_BY_SPACE, OFFSET(int_n_sep_by_space) }, - { _CITRUS_LC_MONETARY_SYM_INT_P_SIGN_POSN, OFFSET(int_p_sign_posn ) }, - { _CITRUS_LC_MONETARY_SYM_INT_N_SIGN_POSN, OFFSET(int_n_sign_posn ) }, - { NULL, (size_t)0 } -}; - -static __inline int -_citrus_LC_MONETARY_init_normal(_MonetaryLocale * __restrict data, - struct _citrus_db * __restrict db) -{ - const struct _citrus_LC_MONETARY_key *key; - char **p_string, *p_char; - const char *s; - uint8_t u8; - - _DIAGASSERT(data != NULL); - _DIAGASSERT(db != NULL); - - memset(data, 0, sizeof(*data)); - for (key = &keys_string[0]; key->name != NULL; ++key) { - if (_db_lookupstr_by_s(db, key->name, &s, NULL)) - goto fatal; - p_string = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p_string = strdup(s); - if (*p_string == NULL) - goto fatal; - } - for (key = &keys_char[0]; key->name != NULL; ++key) { - if (_db_lookup8_by_s(db, key->name, &u8, NULL)) - goto fatal; - p_char = ((char *)(void *)data) + key->offset; - *p_char = (char)(unsigned char)u8; - } - _CITRUS_FIXUP_CHAR_MAX_MD(data->mon_grouping); - - return 0; - -fatal: - _citrus_LC_MONETARY_uninit(data); - return EFTYPE; -} - -static __inline int -_citrus_LC_MONETARY_init_fallback(_MonetaryLocale * __restrict data, - struct _memstream * __restrict ms) -{ - const struct _citrus_LC_MONETARY_key *key; - char **p_string, *p_char; - const char *s; - size_t n; - char *t; - long int l; - - _DIAGASSERT(data != NULL); - _DIAGASSERT(ms != NULL); - - memset(data, 0, sizeof(*data)); - for (key = &keys_string[0]; key->name != NULL; ++key) { - if ((s = _memstream_getln(ms, &n)) == NULL) - goto fatal; - p_string = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p_string = strndup(s, n - 1); - if (*p_string == NULL) - goto fatal; - } - for (key = &keys_char[0]; key->name != NULL; ++key) { - if ((s = _memstream_getln(ms, &n)) == NULL) - goto fatal; - t = strndup(s, n - 1); - if (t == NULL) - goto fatal; - s = (const char *)t; - l = _bcs_strtol(s, &t, 0); - if (s == t || l < 0 || l > 0x7fL) { - free(t); - goto fatal; - } - free(t); - p_char = ((char *)(void *)data) + key->offset; - *p_char = (char)(l & 0x7fL); - } - data->mon_grouping = - __fix_locale_grouping_str(data->mon_grouping); - return 0; - -fatal: - _citrus_LC_MONETARY_uninit(data); - return EFTYPE; -} - -/* - * macro required by citrus_lc_template.h - */ -#define _CATEGORY_DB "LC_MONETARY" -#define _CATEGORY_MAGIC _CITRUS_LC_MONETARY_MAGIC_1 - -#include "citrus_lc_template.h" diff --git a/lib/libc/citrus/citrus_lc_monetary.h b/lib/libc/citrus/citrus_lc_monetary.h deleted file mode 100644 index 0ef146c88..000000000 --- a/lib/libc/citrus/citrus_lc_monetary.h +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: citrus_lc_monetary.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LC_MONETARY_H_ -#define _CITRUS_LC_MONETARY_H_ - -/* - * - */ -#define _CITRUS_LC_MONETARY_MAGIC_1 "CtrsMO10" -#define _CITRUS_LC_MONETARY_SYM_VERSION "version" -#define _CITRUS_LC_MONETARY_VERSION 0x00000001 - -/* - * - */ -#define _CITRUS_LC_MONETARY_SYM_INT_CURR_SYMBOL "int_curr_symbol" -#define _CITRUS_LC_MONETARY_SYM_CURRENCY_SYMBOL "currency_symbol" -#define _CITRUS_LC_MONETARY_SYM_MON_DECIMAL_POINT "mon_decimal_point" -#define _CITRUS_LC_MONETARY_SYM_MON_THOUSANDS_SEP "mon_thousands_sep" -#define _CITRUS_LC_MONETARY_SYM_MON_GROUPING "mon_grouping" -#define _CITRUS_LC_MONETARY_SYM_POSITIVE_SIGN "positive_sign" -#define _CITRUS_LC_MONETARY_SYM_NEGATIVE_SIGN "negative_sign" -#define _CITRUS_LC_MONETARY_SYM_INT_FRAC_DIGITS "int_frac_digits" -#define _CITRUS_LC_MONETARY_SYM_FRAC_DIGITS "frac_digits" -#define _CITRUS_LC_MONETARY_SYM_P_CS_PRECEDES "p_cs_precedes" -#define _CITRUS_LC_MONETARY_SYM_P_SEP_BY_SPACE "p_sep_by_space" -#define _CITRUS_LC_MONETARY_SYM_N_CS_PRECEDES "n_cs_precedes" -#define _CITRUS_LC_MONETARY_SYM_N_SEP_BY_SPACE "n_sep_by_space" -#define _CITRUS_LC_MONETARY_SYM_P_SIGN_POSN "p_sign_posn" -#define _CITRUS_LC_MONETARY_SYM_N_SIGN_POSN "n_sign_posn" -#define _CITRUS_LC_MONETARY_SYM_INT_P_CS_PRECEDES "int_p_cs_precedes" -#define _CITRUS_LC_MONETARY_SYM_INT_N_CS_PRECEDES "int_n_cs_precedes" -#define _CITRUS_LC_MONETARY_SYM_INT_P_SEP_BY_SPACE "int_p_sep_by_space" -#define _CITRUS_LC_MONETARY_SYM_INT_N_SEP_BY_SPACE "int_n_sep_by_space" -#define _CITRUS_LC_MONETARY_SYM_INT_P_SIGN_POSN "int_p_sign_posn" -#define _CITRUS_LC_MONETARY_SYM_INT_N_SIGN_POSN "int_n_sign_posn" - -#endif /*_CITRUS_LC_MONETARY_H_*/ diff --git a/lib/libc/citrus/citrus_lc_numeric.c b/lib/libc/citrus/citrus_lc_numeric.c deleted file mode 100644 index 7115bf1fe..000000000 --- a/lib/libc/citrus/citrus_lc_numeric.c +++ /dev/null @@ -1,168 +0,0 @@ -/* $NetBSD: citrus_lc_numeric.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lc_numeric.c,v 1.5 2012/03/04 21:14:55 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include -#include -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_lookup.h" -#include "citrus_aliasname_local.h" -#include "citrus_module.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" -#include "citrus_memstream.h" -#include "runetype_local.h" - -#include "fix_grouping.h" -#include "citrus_fix_grouping.h" - -/* - * macro required by all template headers - */ -#define _PREFIX(name) __CONCAT(_citrus_LC_NUMERIC_, name) - -#include "nb_lc_numeric_misc.h" -#include "citrus_lc_template_decl.h" - -static __inline void -_citrus_LC_NUMERIC_uninit(_NumericLocale *data) -{ - free(__UNCONST(data->decimal_point)); - free(__UNCONST(data->thousands_sep)); - free(__UNCONST(data->grouping)); -} - -#include "citrus_lc_numeric.h" - -struct _citrus_LC_NUMERIC_key { - const char *name; - size_t offset; -}; - -#define OFFSET(field) (offsetof(_NumericLocale, field)) -static const struct _citrus_LC_NUMERIC_key keys[] = { - { _CITRUS_LC_NUMERIC_SYM_DECIMAL_POINT, OFFSET(decimal_point) }, - { _CITRUS_LC_NUMERIC_SYM_THOUSANDS_SEP, OFFSET(thousands_sep) }, - { _CITRUS_LC_NUMERIC_SYM_GROUPING, OFFSET(grouping ) }, - { NULL, 0 } -}; - -static __inline int -_citrus_LC_NUMERIC_init_normal(_NumericLocale * __restrict data, - struct _citrus_db * __restrict db) -{ - const struct _citrus_LC_NUMERIC_key *key; - char **p; - const char *s; - - _DIAGASSERT(data != NULL); - _DIAGASSERT(db != NULL); - - memset(data, 0, sizeof(*data)); - for (key = &keys[0]; key->name != NULL; ++key) { - if (_db_lookupstr_by_s(db, key->name, &s, NULL)) - goto fatal; - p = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p = strdup(s); - if (*p == NULL) - goto fatal; - } - _CITRUS_FIXUP_CHAR_MAX_MD(data->grouping); - - return 0; - -fatal: - _citrus_LC_NUMERIC_uninit(data); - return EFTYPE; -} - -static __inline int -_citrus_LC_NUMERIC_init_fallback(_NumericLocale * __restrict data, - struct _memstream * __restrict ms) -{ - const struct _citrus_LC_NUMERIC_key *key; - char **p; - const char *s; - size_t n; - - _DIAGASSERT(data != NULL); - _DIAGASSERT(ms != NULL); - - memset(data, 0, sizeof(*data)); - for (key = &keys[0]; key->name != NULL; ++key) { - if ((s = _memstream_getln(ms, &n)) == NULL) - goto fatal; - p = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p = strndup(s, n - 1); - if (*p == NULL) - goto fatal; - } - data->grouping = - __fix_locale_grouping_str(data->grouping); - - return 0; - -fatal: - _citrus_LC_NUMERIC_uninit(data); - return EFTYPE; -} - -/* - * macro required by citrus_lc_template.h - */ -#define _CATEGORY_DB "LC_NUMERIC" -#define _CATEGORY_MAGIC _CITRUS_LC_NUMERIC_MAGIC_1 - -#include "citrus_lc_template.h" diff --git a/lib/libc/citrus/citrus_lc_numeric.h b/lib/libc/citrus/citrus_lc_numeric.h deleted file mode 100644 index cf9bdd837..000000000 --- a/lib/libc/citrus/citrus_lc_numeric.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: citrus_lc_numeric.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LC_NUMERIC_H_ -#define _CITRUS_LC_NUMERIC_H_ - -/* - * - */ -#define _CITRUS_LC_NUMERIC_MAGIC_1 "CtrsNU10" -#define _CITRUS_LC_NUMERIC_SYM_VERSION "version" -#define _CITRUS_LC_NUMERIC_VERSION 0x00000001 - -/* - * - */ -#define _CITRUS_LC_NUMERIC_SYM_DECIMAL_POINT "decimal_point" -#define _CITRUS_LC_NUMERIC_SYM_THOUSANDS_SEP "thousands_sep" -#define _CITRUS_LC_NUMERIC_SYM_GROUPING "grouping" - -#endif /*_CITRUS_LC_NUMERIC_H_*/ diff --git a/lib/libc/citrus/citrus_lc_template.h b/lib/libc/citrus/citrus_lc_template.h deleted file mode 100644 index 42b2c2299..000000000 --- a/lib/libc/citrus/citrus_lc_template.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: citrus_lc_template.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LC_TEMPLATE_H_ -#define _CITRUS_LC_TEMPLATE_H_ - -static __inline int -_PREFIX(create_impl)(const char * __restrict root, - const char * __restrict name, _CATEGORY_TYPE ** __restrict pdata) -{ - char path[PATH_MAX + 1]; - int ret; - struct _region file; - struct _citrus_db *db; - struct _memstream ms; - _CATEGORY_TYPE *data; - - snprintf(path, sizeof(path), - "%s/%s/" _CATEGORY_DB, root, name); - ret = _map_file(&file, path); - if (ret) { - ret = ENOENT; - } else { - data = malloc(sizeof(*data)); - if (!data) { - ret = ENOMEM; - } else { - ret = _db_open(&db, &file, _CATEGORY_MAGIC, - &_db_hash_std, NULL); - if (!ret) { - ret = _PREFIX(init_normal)(data, db); - _db_close(db); - } else { - _memstream_bind(&ms, &file); - ret = _PREFIX(init_fallback)(data, &ms); - } - if (!ret) - *pdata = data; - else - free(data); - } - _unmap_file(&file); - } - return ret; -} - -#include "nb_lc_template.h" - -#endif /* _CITRUS_LC_TEMPLATE_H_ */ diff --git a/lib/libc/citrus/citrus_lc_template_decl.h b/lib/libc/citrus/citrus_lc_template_decl.h deleted file mode 100644 index e83c691ad..000000000 --- a/lib/libc/citrus/citrus_lc_template_decl.h +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: citrus_lc_template_decl.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LC_TEMPLATE_DECL_H_ -#define _CITRUS_LC_TEMPLATE_DECL_H_ - -#include "nb_lc_template_decl.h" - -static __inline int -_PREFIX(init_normal)(_CATEGORY_TYPE * __restrict, - struct _citrus_db * __restrict db); - -static __inline int -_PREFIX(init_fallback)(_CATEGORY_TYPE * __restrict, - struct _memstream * __restrict); - -#endif /*_CITRUS_LC_TEMPLATE_DECL_H_*/ diff --git a/lib/libc/citrus/citrus_lc_time.c b/lib/libc/citrus/citrus_lc_time.c deleted file mode 100644 index 159a3cedd..000000000 --- a/lib/libc/citrus/citrus_lc_time.c +++ /dev/null @@ -1,213 +0,0 @@ -/* $NetBSD: citrus_lc_time.c,v 1.6 2012/03/04 21:14:55 tnozaki Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lc_time.c,v 1.6 2012/03/04 21:14:55 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include -#include -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_lookup.h" -#include "citrus_aliasname_local.h" -#include "citrus_module.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" -#include "citrus_memstream.h" -#include "runetype_local.h" - -/* - * macro required by all template headers - */ -#define _PREFIX(name) __CONCAT(_citrus_LC_TIME_, name) - -#include "nb_lc_time_misc.h" -#include "citrus_lc_template_decl.h" - -static __inline void -_citrus_LC_TIME_uninit(_TimeLocale *data) -{ - size_t i, j; - - _DIAGASSERT(data != NULL); - - for (i = ABDAY_IDX(ABDAY_1), j = ABDAY_IDX(ABDAY_7); i <= j; ++i) - free(__UNCONST(data->abday[i])); - for (i = DAY_IDX(DAY_1), j = DAY_IDX(DAY_7); i <= j; ++i) - free(__UNCONST(data->day[i])); - for (i = ABMON_IDX(ABMON_1), j = ABMON_IDX(ABMON_12); i <= j; ++i) - free(__UNCONST(data->abmon[i])); - for (i = MON_IDX(MON_1), j = MON_IDX(MON_12); i <= j; ++i) - free(__UNCONST(data->mon[i])); - for (i = AM_PM_IDX(AM_STR), j = AM_PM_IDX(PM_STR); i <= j; ++i) - free(__UNCONST(data->am_pm[i])); - free(__UNCONST(data->d_t_fmt)); - free(__UNCONST(data->d_fmt)); - free(__UNCONST(data->t_fmt)); - free(__UNCONST(data->t_fmt_ampm)); -} - -#include "citrus_lc_time.h" - -struct _citrus_LC_TIME_key { - const char *name; - size_t offset; -}; - -#define OFFSET(field) offsetof(_TimeLocale, field) -static const struct _citrus_LC_TIME_key keys[] = { - { _CITRUS_LC_TIME_SYM_ABDAY_1, OFFSET(abday[ABDAY_IDX(ABDAY_1)] ) }, - { _CITRUS_LC_TIME_SYM_ABDAY_2, OFFSET(abday[ABDAY_IDX(ABDAY_2)] ) }, - { _CITRUS_LC_TIME_SYM_ABDAY_3, OFFSET(abday[ABDAY_IDX(ABDAY_3)] ) }, - { _CITRUS_LC_TIME_SYM_ABDAY_4, OFFSET(abday[ABDAY_IDX(ABDAY_4)] ) }, - { _CITRUS_LC_TIME_SYM_ABDAY_5, OFFSET(abday[ABDAY_IDX(ABDAY_5)] ) }, - { _CITRUS_LC_TIME_SYM_ABDAY_6, OFFSET(abday[ABDAY_IDX(ABDAY_6)] ) }, - { _CITRUS_LC_TIME_SYM_ABDAY_7, OFFSET(abday[ABDAY_IDX(ABDAY_7)] ) }, - { _CITRUS_LC_TIME_SYM_DAY_1, OFFSET(day[DAY_IDX(DAY_1)] ) }, - { _CITRUS_LC_TIME_SYM_DAY_2, OFFSET(day[DAY_IDX(DAY_2)] ) }, - { _CITRUS_LC_TIME_SYM_DAY_3, OFFSET(day[DAY_IDX(DAY_3)] ) }, - { _CITRUS_LC_TIME_SYM_DAY_4, OFFSET(day[DAY_IDX(DAY_4)] ) }, - { _CITRUS_LC_TIME_SYM_DAY_5, OFFSET(day[DAY_IDX(DAY_5)] ) }, - { _CITRUS_LC_TIME_SYM_DAY_6, OFFSET(day[DAY_IDX(DAY_6)] ) }, - { _CITRUS_LC_TIME_SYM_DAY_7, OFFSET(day[DAY_IDX(DAY_7)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_1, OFFSET(abmon[ABMON_IDX(ABMON_1)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_2, OFFSET(abmon[ABMON_IDX(ABMON_2)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_3, OFFSET(abmon[ABMON_IDX(ABMON_3)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_4, OFFSET(abmon[ABMON_IDX(ABMON_4)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_5, OFFSET(abmon[ABMON_IDX(ABMON_5)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_6, OFFSET(abmon[ABMON_IDX(ABMON_6)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_7, OFFSET(abmon[ABMON_IDX(ABMON_7)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_8, OFFSET(abmon[ABMON_IDX(ABMON_8)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_9, OFFSET(abmon[ABMON_IDX(ABMON_9)] ) }, - { _CITRUS_LC_TIME_SYM_ABMON_10, OFFSET(abmon[ABMON_IDX(ABMON_10)]) }, - { _CITRUS_LC_TIME_SYM_ABMON_11, OFFSET(abmon[ABMON_IDX(ABMON_11)]) }, - { _CITRUS_LC_TIME_SYM_ABMON_12, OFFSET(abmon[ABMON_IDX(ABMON_12)]) }, - { _CITRUS_LC_TIME_SYM_MON_1, OFFSET(mon[MON_IDX(MON_1)] ) }, - { _CITRUS_LC_TIME_SYM_MON_2, OFFSET(mon[MON_IDX(MON_2)] ) }, - { _CITRUS_LC_TIME_SYM_MON_3, OFFSET(mon[MON_IDX(MON_3)] ) }, - { _CITRUS_LC_TIME_SYM_MON_4, OFFSET(mon[MON_IDX(MON_4)] ) }, - { _CITRUS_LC_TIME_SYM_MON_5, OFFSET(mon[MON_IDX(MON_5)] ) }, - { _CITRUS_LC_TIME_SYM_MON_6, OFFSET(mon[MON_IDX(MON_6)] ) }, - { _CITRUS_LC_TIME_SYM_MON_7, OFFSET(mon[MON_IDX(MON_7)] ) }, - { _CITRUS_LC_TIME_SYM_MON_8, OFFSET(mon[MON_IDX(MON_8)] ) }, - { _CITRUS_LC_TIME_SYM_MON_9, OFFSET(mon[MON_IDX(MON_9)] ) }, - { _CITRUS_LC_TIME_SYM_MON_10, OFFSET(mon[MON_IDX(MON_10)] ) }, - { _CITRUS_LC_TIME_SYM_MON_11, OFFSET(mon[MON_IDX(MON_11)] ) }, - { _CITRUS_LC_TIME_SYM_MON_12, OFFSET(mon[MON_IDX(MON_12)] ) }, - { _CITRUS_LC_TIME_SYM_AM_STR, OFFSET(am_pm[AM_PM_IDX(AM_STR)] ) }, - { _CITRUS_LC_TIME_SYM_PM_STR, OFFSET(am_pm[AM_PM_IDX(PM_STR)] ) }, - { _CITRUS_LC_TIME_SYM_D_T_FMT, OFFSET(d_t_fmt ) }, - { _CITRUS_LC_TIME_SYM_D_FMT, OFFSET(d_fmt ) }, - { _CITRUS_LC_TIME_SYM_T_FMT, OFFSET(t_fmt ) }, - { _CITRUS_LC_TIME_SYM_T_FMT_AMPM, OFFSET(t_fmt_ampm ) }, - { NULL, 0 } -}; - -static __inline int -_citrus_LC_TIME_init_normal(_TimeLocale * __restrict data, - struct _citrus_db * __restrict db) -{ - const struct _citrus_LC_TIME_key *key; - char **p; - const char *s; - - _DIAGASSERT(data != NULL); - _DIAGASSERT(db != NULL); - - memset(data, 0, sizeof(*data)); - for (key = &keys[0]; key->name != NULL; ++key) { - if (_db_lookupstr_by_s(db, key->name, &s, NULL)) - goto fatal; - p = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p = strdup(s); - if (*p == NULL) - goto fatal; - } - return 0; - -fatal: - _citrus_LC_TIME_uninit(data); - return EFTYPE; -} - -static __inline int -_citrus_LC_TIME_init_fallback(_TimeLocale * __restrict data, - struct _memstream * __restrict ms) -{ - const struct _citrus_LC_TIME_key *key; - char **p; - const char *s; - size_t n; - - memset(data, 0, sizeof(*data)); - for (key = &keys[0]; key->name != NULL; ++key) { - if ((s = _memstream_getln(ms, &n)) == NULL) - goto fatal; - p = (char **)(void *) - (((char *)(void *)data) + key->offset); - *p = strndup(s, n - 1); - if (*p == NULL) - goto fatal; - } - return 0; - -fatal: - _citrus_LC_TIME_uninit(data); - return EFTYPE; -} - -/* - * macro required by citrus_lc_template.h - */ -#define _CATEGORY_DB "LC_TIME" -#define _CATEGORY_MAGIC _CITRUS_LC_TIME_MAGIC_1 - -#include "citrus_lc_template.h" diff --git a/lib/libc/citrus/citrus_lc_time.h b/lib/libc/citrus/citrus_lc_time.h deleted file mode 100644 index 3b9616f3a..000000000 --- a/lib/libc/citrus/citrus_lc_time.h +++ /dev/null @@ -1,87 +0,0 @@ -/* $NetBSD: citrus_lc_time.h,v 1.2 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LC_TIME_H_ -#define _CITRUS_LC_TIME_H_ - -/* - * - */ -#define _CITRUS_LC_TIME_MAGIC_1 "CtrsTI10" -#define _CITRUS_LC_TIME_SYM_VERSION "version" -#define _CITRUS_LC_TIME_VERSION 0x00000001 - -/* - * - */ -#define _CITRUS_LC_TIME_SYM_ABDAY_1 "abday1" -#define _CITRUS_LC_TIME_SYM_ABDAY_2 "abday2" -#define _CITRUS_LC_TIME_SYM_ABDAY_3 "abday3" -#define _CITRUS_LC_TIME_SYM_ABDAY_4 "abday4" -#define _CITRUS_LC_TIME_SYM_ABDAY_5 "abday5" -#define _CITRUS_LC_TIME_SYM_ABDAY_6 "abday6" -#define _CITRUS_LC_TIME_SYM_ABDAY_7 "abday7" -#define _CITRUS_LC_TIME_SYM_DAY_1 "day1" -#define _CITRUS_LC_TIME_SYM_DAY_2 "day2" -#define _CITRUS_LC_TIME_SYM_DAY_3 "day3" -#define _CITRUS_LC_TIME_SYM_DAY_4 "day4" -#define _CITRUS_LC_TIME_SYM_DAY_5 "day5" -#define _CITRUS_LC_TIME_SYM_DAY_6 "day6" -#define _CITRUS_LC_TIME_SYM_DAY_7 "day7" -#define _CITRUS_LC_TIME_SYM_ABMON_1 "abmon_1" -#define _CITRUS_LC_TIME_SYM_ABMON_2 "abmon_2" -#define _CITRUS_LC_TIME_SYM_ABMON_3 "abmon_3" -#define _CITRUS_LC_TIME_SYM_ABMON_4 "abmon_4" -#define _CITRUS_LC_TIME_SYM_ABMON_5 "abmon_5" -#define _CITRUS_LC_TIME_SYM_ABMON_6 "abmon_6" -#define _CITRUS_LC_TIME_SYM_ABMON_7 "abmon_7" -#define _CITRUS_LC_TIME_SYM_ABMON_8 "abmon_8" -#define _CITRUS_LC_TIME_SYM_ABMON_9 "abmon_9" -#define _CITRUS_LC_TIME_SYM_ABMON_10 "abmon_10" -#define _CITRUS_LC_TIME_SYM_ABMON_11 "abmon_11" -#define _CITRUS_LC_TIME_SYM_ABMON_12 "abmon_12" -#define _CITRUS_LC_TIME_SYM_MON_1 "mon_1" -#define _CITRUS_LC_TIME_SYM_MON_2 "mon_2" -#define _CITRUS_LC_TIME_SYM_MON_3 "mon_3" -#define _CITRUS_LC_TIME_SYM_MON_4 "mon_4" -#define _CITRUS_LC_TIME_SYM_MON_5 "mon_5" -#define _CITRUS_LC_TIME_SYM_MON_6 "mon_6" -#define _CITRUS_LC_TIME_SYM_MON_7 "mon_7" -#define _CITRUS_LC_TIME_SYM_MON_8 "mon_8" -#define _CITRUS_LC_TIME_SYM_MON_9 "mon_9" -#define _CITRUS_LC_TIME_SYM_MON_10 "mon_10" -#define _CITRUS_LC_TIME_SYM_MON_11 "mon_11" -#define _CITRUS_LC_TIME_SYM_MON_12 "mon_12" -#define _CITRUS_LC_TIME_SYM_AM_STR "am_str" -#define _CITRUS_LC_TIME_SYM_PM_STR "pm_str" -#define _CITRUS_LC_TIME_SYM_D_T_FMT "d_t_fmt" -#define _CITRUS_LC_TIME_SYM_D_FMT "d_fmt" -#define _CITRUS_LC_TIME_SYM_T_FMT "t_fmt" -#define _CITRUS_LC_TIME_SYM_T_FMT_AMPM "t_fmt_ampm" - -#endif /*_CITRUS_LC_TIME_H_*/ diff --git a/lib/libc/citrus/citrus_lookup.c b/lib/libc/citrus/citrus_lookup.c deleted file mode 100644 index 57af4460b..000000000 --- a/lib/libc/citrus/citrus_lookup.c +++ /dev/null @@ -1,356 +0,0 @@ -/* $NetBSD: citrus_lookup.c,v 1.7 2012/05/04 16:45:05 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lookup.c,v 1.7 2012/05/04 16:45:05 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" -#include "citrus_lookup.h" -#include "citrus_lookup_file.h" - -struct _citrus_lookup { - union { - struct { - struct _citrus_db *db; - struct _citrus_region file; - int num, idx; - struct _db_locator locator; - } db; - struct { - struct _region r; - struct _memstream ms; - } plain; - } u; -#define cl_db u.db.db -#define cl_dbidx u.db.idx -#define cl_dbfile u.db.file -#define cl_dbnum u.db.num -#define cl_dblocator u.db.locator -#define cl_plainr u.plain.r -#define cl_plainms u.plain.ms - int cl_ignore_case; - int cl_rewind; - char *cl_key; - size_t cl_keylen; - int (*cl_next)(struct _citrus_lookup *, struct _region *, - struct _region *); - int (*cl_lookup)(struct _citrus_lookup *, const char *, - struct _region *); - int (*cl_num_entries)(struct _citrus_lookup *); - void (*cl_close)(struct _citrus_lookup *); -}; - -static int -seq_get_num_entries_db(struct _citrus_lookup *cl) -{ - return cl->cl_dbnum; -} - -static int -seq_next_db(struct _citrus_lookup *cl, - struct _region *key, struct _region *data) -{ - - if (cl->cl_key) { - if (key) - _region_init(key, cl->cl_key, cl->cl_keylen); - return _db_lookup_by_s(cl->cl_db, cl->cl_key, data, - &cl->cl_dblocator); - } - - if (cl->cl_rewind) { - cl->cl_dbidx = 0; - } - cl->cl_rewind = 0; - if (cl->cl_dbidx >= cl->cl_dbnum) - return ENOENT; - - return _db_get_entry(cl->cl_db, cl->cl_dbidx++, key, data); -} - -static int -seq_lookup_db(struct _citrus_lookup *cl, const char *key, - struct _region *data) -{ - cl->cl_rewind = 0; - free(cl->cl_key); - cl->cl_key = strdup(key); - if (cl->cl_ignore_case) - _bcs_convert_to_lower(cl->cl_key); - cl->cl_keylen = strlen(cl->cl_key); - _db_locator_init(&cl->cl_dblocator); - return _db_lookup_by_s(cl->cl_db, cl->cl_key, data, &cl->cl_dblocator); -} - -static void -seq_close_db(struct _citrus_lookup *cl) -{ - _db_close(cl->cl_db); - _unmap_file(&cl->cl_dbfile); -} - -static int -seq_open_db(struct _citrus_lookup *cl, const char *name) -{ - int ret; - struct _region r; - char path[PATH_MAX]; - - snprintf(path, sizeof(path), "%s.db", name); - ret = _map_file(&r, path); - if (ret) - return ret; - - ret = _db_open(&cl->cl_db, &r, _CITRUS_LOOKUP_MAGIC, - _db_hash_std, NULL); - if (ret) { - _unmap_file(&r); - return ret; - } - - cl->cl_dbfile = r; - cl->cl_dbnum = _db_get_num_entries(cl->cl_db); - cl->cl_dbidx = 0; - cl->cl_rewind = 1; - cl->cl_lookup = &seq_lookup_db; - cl->cl_next = &seq_next_db; - cl->cl_num_entries = &seq_get_num_entries_db; - cl->cl_close = &seq_close_db; - - return 0; -} - -#define T_COMM '#' -static int -seq_next_plain(struct _citrus_lookup *cl, struct _region *key, - struct _region *data) -{ - const char *p, *q; - size_t len; - - if (cl->cl_rewind) - _memstream_bind(&cl->cl_plainms, &cl->cl_plainr); - cl->cl_rewind = 0; - -retry: - p = _memstream_getln(&cl->cl_plainms, &len); - if (p == NULL) - return ENOENT; - /* ignore comment */ - q = memchr(p, T_COMM, len); - if (q) { - len = q-p; - } - /* ignore trailing spaces */ - _bcs_trunc_rws_len(p, &len); - p = _bcs_skip_ws_len(p, &len); - q = _bcs_skip_nonws_len(p, &len); - if (p==q) - goto retry; - if (cl->cl_key && ((size_t)(q-p) != cl->cl_keylen || - memcmp(p, cl->cl_key, (size_t)(q-p)) != 0)) - goto retry; - - /* found a entry */ - if (key) - _region_init(key, __UNCONST(p), (size_t)(q-p)); - p = _bcs_skip_ws_len(q, &len); - if (data) - _region_init(data, len ? __UNCONST(p) : NULL, len); - - return 0; -} - -static int -seq_get_num_entries_plain(struct _citrus_lookup *cl) -{ - int num; - - num = 0; - while (seq_next_plain(cl, NULL, NULL) == 0) - num++; - - return num; -} - -static int -seq_lookup_plain(struct _citrus_lookup *cl, const char *key, - struct _region *data) -{ - size_t len; - const char *p; - - cl->cl_rewind = 0; - free(cl->cl_key); - cl->cl_key = strdup(key); - if (cl->cl_ignore_case) - _bcs_convert_to_lower(cl->cl_key); - cl->cl_keylen = strlen(cl->cl_key); - _memstream_bind(&cl->cl_plainms, &cl->cl_plainr); - p = _memstream_matchline(&cl->cl_plainms, cl->cl_key, &len, 0); - if (p == NULL) - return ENOENT; - if (data) - _region_init(data, __UNCONST(p), len); - - return 0; -} - -static void -seq_close_plain(struct _citrus_lookup *cl) -{ - _unmap_file(&cl->cl_plainr); -} - -static int -seq_open_plain(struct _citrus_lookup *cl, const char *name) -{ - int ret; - - /* open read stream */ - ret = _map_file(&cl->cl_plainr, name); - if (ret) - return ret; - - cl->cl_rewind = 1; - cl->cl_next = &seq_next_plain; - cl->cl_lookup = &seq_lookup_plain; - cl->cl_num_entries = &seq_get_num_entries_plain; - cl->cl_close = &seq_close_plain; - - return 0; -} - -int -_citrus_lookup_seq_open(struct _citrus_lookup **rcl, const char *name, - int ignore_case) -{ - int ret; - struct _citrus_lookup *cl; - - cl = malloc(sizeof(*cl)); - if (cl == NULL) - return ENOMEM; - - cl->cl_key = NULL; - cl->cl_keylen = 0; - cl->cl_ignore_case = ignore_case; - ret = seq_open_db(cl, name); - if (ret == ENOENT) - ret = seq_open_plain(cl, name); - if (!ret) - *rcl = cl; - else - free(cl); - - return ret; -} - -void -_citrus_lookup_seq_rewind(struct _citrus_lookup *cl) -{ - cl->cl_rewind = 1; - free(cl->cl_key); - cl->cl_key = NULL; - cl->cl_keylen = 0; -} - -int -_citrus_lookup_seq_next(struct _citrus_lookup *cl, - struct _region *key, struct _region *data) -{ - return (*cl->cl_next)(cl, key, data); -} - -int -_citrus_lookup_seq_lookup(struct _citrus_lookup *cl, const char *key, - struct _region *data) -{ - return (*cl->cl_lookup)(cl, key, data); -} - -int -_citrus_lookup_get_number_of_entries(struct _citrus_lookup *cl) -{ - return (*cl->cl_num_entries)(cl); -} - -void -_citrus_lookup_seq_close(struct _citrus_lookup *cl) -{ - free(cl->cl_key); - (*cl->cl_close)(cl); - free(cl); -} - -char * -_citrus_lookup_simple(const char *name, const char *key, - char *linebuf, size_t linebufsize, int ignore_case) -{ - int ret; - struct _citrus_lookup *cl; - struct _region data; - - ret = _citrus_lookup_seq_open(&cl, name, ignore_case); - if (ret) - return NULL; - - ret = _citrus_lookup_seq_lookup(cl, key, &data); - if (ret) { - _citrus_lookup_seq_close(cl); - return NULL; - } - - snprintf(linebuf, linebufsize, "%.*s", - (int)_region_size(&data), (const char *)_region_head(&data)); - - _citrus_lookup_seq_close(cl); - - return linebuf; -} diff --git a/lib/libc/citrus/citrus_lookup.h b/lib/libc/citrus/citrus_lookup.h deleted file mode 100644 index 92b721fb2..000000000 --- a/lib/libc/citrus/citrus_lookup.h +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: citrus_lookup.h,v 1.2 2004/07/21 14:16:34 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LOOKUP_H_ -#define _CITRUS_LOOKUP_H_ - -#define _CITRUS_LOOKUP_CASE_SENSITIVE 0 -#define _CITRUS_LOOKUP_CASE_IGNORE 1 - -struct _citrus_lookup; -__BEGIN_DECLS -char *_citrus_lookup_simple(const char *, const char *, char *, size_t, int); -int _citrus_lookup_seq_open(struct _citrus_lookup **, const char *, int); -void _citrus_lookup_seq_rewind(struct _citrus_lookup *); -int _citrus_lookup_seq_next(struct _citrus_lookup *, - struct _region *, struct _region *); -int _citrus_lookup_seq_lookup(struct _citrus_lookup *, const char *, - struct _region *); -int _citrus_lookup_get_number_of_entries(struct _citrus_lookup *); -void _citrus_lookup_seq_close(struct _citrus_lookup *); -__END_DECLS - -static __inline const char * -_citrus_lookup_alias(const char *path, const char *key, char *buf, size_t n, - int ignore_case) -{ - const char *ret; - - ret = _citrus_lookup_simple(path, key, buf, n, ignore_case); - if (ret == NULL) - ret = key; - - return ret; -} - -#endif diff --git a/lib/libc/citrus/citrus_lookup_factory.c b/lib/libc/citrus/citrus_lookup_factory.c deleted file mode 100644 index 7d14b5151..000000000 --- a/lib/libc/citrus/citrus_lookup_factory.c +++ /dev/null @@ -1,127 +0,0 @@ -/* $NetBSD: citrus_lookup_factory.c,v 1.4 2003/10/27 00:12:42 lukem Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_lookup_factory.c,v 1.4 2003/10/27 00:12:42 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_region.h" -#include "citrus_bcs.h" -#include "citrus_db_factory.h" -#include "citrus_db_hash.h" -#include "citrus_lookup_factory.h" -#include "citrus_lookup_file.h" - -#define T_COMM '#' -static int -convert_line(struct _citrus_db_factory *df, const char *line, size_t len) -{ - const char *p; - char key[LINE_MAX], data[LINE_MAX]; - - /* cut off trailing comment */ - p = memchr(line, T_COMM, len); - if (p) - len = p - line; - - /* key */ - line = _bcs_skip_ws_len(line, &len); - if (len == 0) - return 0; - p = _bcs_skip_nonws_len(line, &len); - if (p==line) - return 0; - snprintf(key, sizeof(key), "%.*s", (int)(p-line), line); - _bcs_convert_to_lower(key); - - /* data */ - line = _bcs_skip_ws_len(p, &len); - _bcs_trunc_rws_len(line, &len); - snprintf(data, sizeof(data), "%.*s", (int)len, line); - - return _db_factory_addstr_by_s(df, key, data); -} - -static int -dump_db(struct _citrus_db_factory *df, struct _region *r) -{ - size_t size; - void *ptr; - - size = _db_factory_calc_size(df); - ptr = malloc(size); - if (ptr == NULL) - return errno; - _region_init(r, ptr, size); - - return _db_factory_serialize(df, _CITRUS_LOOKUP_MAGIC, r); -} - -int -_citrus_lookup_factory_convert(FILE *out, FILE *in) -{ - struct _citrus_db_factory *df; - struct _region r; - char *line; - size_t size; - int ret; - - ret = _db_factory_create(&df, &_db_hash_std, NULL); - if (ret) - return ret; - - while ((line = fgetln(in, &size)) != NULL) - if ((ret = convert_line(df, line, size))) { - _db_factory_free(df); - return ret; - } - - ret = dump_db(df, &r); - _db_factory_free(df); - if (ret) - return ret; - - if (fwrite(_region_head(&r), _region_size(&r), 1, out) != 1) - return errno; - - return 0; -} diff --git a/lib/libc/citrus/citrus_lookup_factory.h b/lib/libc/citrus/citrus_lookup_factory.h deleted file mode 100644 index d50a1e892..000000000 --- a/lib/libc/citrus/citrus_lookup_factory.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_lookup_factory.h,v 1.1 2003/06/25 09:51:35 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LOOKUP_FACTORY_H_ -#define _CITRUS_LOOKUP_FACTORY_H_ - -__BEGIN_DECLS -int _citrus_lookup_factory_convert(FILE *, FILE *); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_lookup_file.h b/lib/libc/citrus/citrus_lookup_file.h deleted file mode 100644 index 0c56b6126..000000000 --- a/lib/libc/citrus/citrus_lookup_file.h +++ /dev/null @@ -1,34 +0,0 @@ -/* $NetBSD: citrus_lookup_file.h,v 1.1 2003/06/25 09:51:36 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_LOOKUP_FILE_H_ -#define _CITRUS_LOOKUP_FILE_H_ - -#define _CITRUS_LOOKUP_MAGIC "LOOKUP\0\0" - -#endif diff --git a/lib/libc/citrus/citrus_mapper.c b/lib/libc/citrus/citrus_mapper.c deleted file mode 100644 index 384990909..000000000 --- a/lib/libc/citrus/citrus_mapper.c +++ /dev/null @@ -1,406 +0,0 @@ -/* $NetBSD: citrus_mapper.c,v 1.10 2012/06/08 07:49:42 martin Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mapper.c,v 1.10 2012/06/08 07:49:42 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_bcs.h" -#include "citrus_mmap.h" -#include "citrus_module.h" -#include "citrus_hash.h" -#include "citrus_mapper.h" - -#define _CITRUS_MAPPER_DIR "mapper.dir" - -#define CM_HASH_SIZE 101 -#define REFCOUNT_PERSISTENT -1 - -#ifdef _REENTRANT -static rwlock_t lock = RWLOCK_INITIALIZER; -#endif - -struct _citrus_mapper_area { - _CITRUS_HASH_HEAD(, _citrus_mapper, CM_HASH_SIZE) ma_cache; - char *ma_dir; -}; - -/* - * _citrus_mapper_create_area: - * create mapper area - */ - -int -_citrus_mapper_create_area( - struct _citrus_mapper_area *__restrict *__restrict rma, - const char *__restrict area) -{ - struct stat st; - int ret; - char path[PATH_MAX]; - struct _citrus_mapper_area *ma; - - rwlock_wrlock(&lock); - - if (*rma != NULL) { - ret = 0; - goto quit; - } - - snprintf(path, (size_t)PATH_MAX, "%s/%s", area, _CITRUS_MAPPER_DIR); - - ret = stat(path, &st); - if (ret) - goto quit; - - ma = malloc(sizeof(*ma)); - if (ma == NULL) { - ret = errno; - goto quit; - } - ma->ma_dir = strdup(area); - if (ma->ma_dir == NULL) { - free(ma); - ret = errno; - goto quit; - } - _CITRUS_HASH_INIT(&ma->ma_cache, CM_HASH_SIZE); - - *rma = ma; - ret = 0; -quit: - rwlock_unlock(&lock); - - return ret; -} - - -/* - * lookup_mapper_entry: - * lookup mapper.dir entry in the specified directory. - * - * line format of iconv.dir file: - * mapper module arg - * mapper : mapper name. - * module : mapper module name. - * arg : argument for the module (generally, description file name) - */ - -static int -lookup_mapper_entry(const char *dir, const char *mapname, - void *linebuf, size_t linebufsize, - const char **module, const char **variable) -{ - struct _region r; - struct _memstream ms; - int ret; - const char *cp, *cq; - char *p; - size_t len; - char path[PATH_MAX]; - - /* create mapper.dir path */ - snprintf(path, (size_t)PATH_MAX, "%s/%s", dir, _CITRUS_MAPPER_DIR); - - /* open read stream */ - ret = _map_file(&r, path); - if (ret) - return ret; - - _memstream_bind(&ms, &r); - - /* search the line matching to the map name */ - cp = _memstream_matchline(&ms, mapname, &len, 0); - if (!cp) { - ret = ENOENT; - goto quit; - } - if (!len || len>linebufsize-1) { - ret = EINVAL; - goto quit; - } - - p = linebuf; - /* get module name */ - *module = p; - cq = _bcs_skip_nonws_len(cp, &len); - strlcpy(p, cp, (size_t)(cq-cp+1)); - p += cq-cp+1; - - /* get variable */ - *variable = p; - cp = _bcs_skip_ws_len(cq, &len); - strlcpy(p, cp, len+1); - - ret = 0; - -quit: - _unmap_file(&r); - return ret; -} - -/* - * mapper_close: - * simply close a mapper. (without handling hash) - */ -static void -mapper_close(struct _citrus_mapper *cm) -{ - if (cm->cm_module) { - if (cm->cm_ops) { - if (cm->cm_closure) - (*cm->cm_ops->mo_uninit)(cm); - free(cm->cm_ops); - } - _citrus_unload_module(cm->cm_module); - } - free(cm->cm_traits); - free(cm); -} - -/* - * mapper_open: - * simply open a mapper. (without handling hash) - */ -static int -mapper_open(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict * __restrict rcm, - const char * __restrict module, - const char * __restrict variable) -{ - int ret; - struct _citrus_mapper *cm; - _citrus_mapper_getops_t getops; - - /* initialize mapper handle */ - cm = malloc(sizeof(*cm)); - if (!cm) - return errno; - - cm->cm_module = NULL; - cm->cm_ops = NULL; - cm->cm_closure = NULL; - cm->cm_traits = NULL; - cm->cm_refcount = 0; - cm->cm_key = NULL; - - /* load module */ - ret = _citrus_load_module(&cm->cm_module, module); - if (ret) - goto err; - - /* get operators */ - getops = (_citrus_mapper_getops_t) - _citrus_find_getops(cm->cm_module, module, "mapper"); - if (!getops) { - ret = EOPNOTSUPP; - goto err; - } - cm->cm_ops = malloc(sizeof(*cm->cm_ops)); - if (!cm->cm_ops) { - ret = errno; - goto err; - } - ret = (*getops)(cm->cm_ops, sizeof(*cm->cm_ops), - _CITRUS_MAPPER_ABI_VERSION); - if (ret) - goto err; - - if (!cm->cm_ops->mo_init || - !cm->cm_ops->mo_uninit || - !cm->cm_ops->mo_convert || - !cm->cm_ops->mo_init_state) { - ret = EINVAL; - goto err; - } - - /* allocate traits structure */ - cm->cm_traits = malloc(sizeof(*cm->cm_traits)); - if (cm->cm_traits == NULL) { - ret = errno; - goto err; - } - /* initialize the mapper */ - ret = (*cm->cm_ops->mo_init)(ma, cm, ma->ma_dir, - (const void *)variable, - strlen(variable)+1, - cm->cm_traits, sizeof(*cm->cm_traits)); - if (ret) - goto err; - - *rcm = cm; - - return 0; - -err: - mapper_close(cm); - return ret; -} - -/* - * _citrus_mapper_open_direct: - * open a mapper. - */ -int -_citrus_mapper_open_direct(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict * __restrict rcm, - const char * __restrict module, - const char * __restrict variable) -{ - return mapper_open(ma, rcm, module, variable); -} - -/* - * hash_func - */ -static __inline int -hash_func(const char *key) -{ - return _string_hash_func(key, CM_HASH_SIZE); -} - -/* - * match_func - */ -static __inline int -match_func(struct _citrus_mapper *cm, const char *key) -{ - return strcmp(cm->cm_key, key); -} - -/* - * _citrus_mapper_open: - * open a mapper with looking up "mapper.dir". - */ -int -_citrus_mapper_open(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict * __restrict rcm, - const char * __restrict mapname) -{ - int ret; - char linebuf[PATH_MAX]; - const char *module, *variable = NULL; - struct _citrus_mapper *cm; - int hashval; - - rwlock_wrlock(&lock); - - /* search in the cache */ - hashval = hash_func(mapname); - _CITRUS_HASH_SEARCH(&ma->ma_cache, cm, cm_entry, match_func, mapname, - hashval); - if (cm) { - /* found */ - cm->cm_refcount++; - *rcm = cm; - ret = 0; - goto quit; - } - - /* search mapper entry */ - ret = lookup_mapper_entry(ma->ma_dir, mapname, linebuf, - (size_t)PATH_MAX, &module, &variable); - if (ret) - goto quit; - - /* open mapper */ - ret = mapper_open(ma, &cm, module, variable); - if (ret) - goto quit; - cm->cm_key = strdup(mapname); - if (cm->cm_key == NULL) { - ret = errno; - rwlock_unlock(&lock); - _mapper_close(cm); - return ret; - } - - /* insert to the cache */ - cm->cm_refcount = 1; - _CITRUS_HASH_INSERT(&ma->ma_cache, cm, cm_entry, hashval); - - *rcm = cm; - ret = 0; -quit: - rwlock_unlock(&lock); - return ret; -} - -/* - * _citrus_mapper_close: - * close the specified mapper. - */ -void -_citrus_mapper_close(struct _citrus_mapper *cm) -{ - if (cm) { - rwlock_wrlock(&lock); - if (cm->cm_refcount == REFCOUNT_PERSISTENT) - goto quit; - if (cm->cm_refcount > 0) { - if (--cm->cm_refcount > 0) - goto quit; - _CITRUS_HASH_REMOVE(cm, cm_entry); - free(cm->cm_key); - } - rwlock_unlock(&lock); - mapper_close(cm); - return; -quit: - rwlock_unlock(&lock); - } -} - -/* - * _citrus_mapper_set_persistent: - * set persistent count. - */ -void -_citrus_mapper_set_persistent(struct _citrus_mapper * __restrict cm) -{ - rwlock_wrlock(&lock); - cm->cm_refcount = REFCOUNT_PERSISTENT; - rwlock_unlock(&lock); -} diff --git a/lib/libc/citrus/citrus_mapper.h b/lib/libc/citrus/citrus_mapper.h deleted file mode 100644 index 2eb1d22ab..000000000 --- a/lib/libc/citrus/citrus_mapper.h +++ /dev/null @@ -1,142 +0,0 @@ -/* $NetBSD: citrus_mapper.h,v 1.3 2003/07/12 15:39:19 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_H_ -#define _CITRUS_MAPPER_H_ - -struct _citrus_mapper_area; -struct _citrus_mapper; -struct _citrus_mapper_ops; -struct _citrus_mapper_traits; - -__BEGIN_DECLS -int _citrus_mapper_create_area( - struct _citrus_mapper_area *__restrict *__restrict, - const char *__restrict); -int _citrus_mapper_open(struct _citrus_mapper_area *__restrict, - struct _citrus_mapper *__restrict *__restrict, - const char *__restrict); -int _citrus_mapper_open_direct( - struct _citrus_mapper_area *__restrict, - struct _citrus_mapper *__restrict *__restrict, - const char *__restrict, const char *__restrict); -void _citrus_mapper_close(struct _citrus_mapper *); -void _citrus_mapper_set_persistent(struct _citrus_mapper * __restrict); -__END_DECLS - -#include "citrus_mapper_local.h" - -/* return values of _citrus_mapper_convert */ -#define _CITRUS_MAPPER_CONVERT_SUCCESS (0) -#define _CITRUS_MAPPER_CONVERT_NONIDENTICAL (1) -#define _CITRUS_MAPPER_CONVERT_SRC_MORE (2) -#define _CITRUS_MAPPER_CONVERT_DST_MORE (3) -#define _CITRUS_MAPPER_CONVERT_ILSEQ (4) -#define _CITRUS_MAPPER_CONVERT_FATAL (5) - -/* - * _citrus_mapper_convert: - * convert an index. - * - if the converter supports M:1 converter, the function may return - * _CITRUS_MAPPER_CONVERT_SRC_MORE and the storage pointed by dst - * may be unchanged in this case, although the internal status of - * the mapper is affected. - * - if the converter supports 1:N converter, the function may return - * _CITRUS_MAPPER_CONVERT_DST_MORE. In this case, the contiguous - * call of this function ignores src and changes the storage pointed - * by dst. - * - if the converter supports M:N converter, the function may behave - * the combination of the above. - * - */ -static __inline int -_citrus_mapper_convert(struct _citrus_mapper * __restrict cm, - _citrus_index_t * __restrict dst, - _citrus_index_t src, - void * __restrict ps) -{ - - _DIAGASSERT(cm && cm->cm_ops && cm->cm_ops->mo_convert && dst); - - return (*cm->cm_ops->mo_convert)(cm, dst, src, ps); -} - -/* - * _citrus_mapper_init_state: - * initialize the state. - */ -static __inline void -_citrus_mapper_init_state(struct _citrus_mapper * __restrict cm, - void * __restrict ps) -{ - - _DIAGASSERT(cm && cm->cm_ops && cm->cm_ops->mo_init_state); - - (*cm->cm_ops->mo_init_state)(cm, ps); -} - -/* - * _citrus_mapper_get_state_size: - * get the size of state storage. - */ -static __inline size_t -_citrus_mapper_get_state_size(struct _citrus_mapper * __restrict cm) -{ - - _DIAGASSERT(cm && cm->cm_traits); - - return cm->cm_traits->mt_state_size; -} - -/* - * _citrus_mapper_get_src_max: - * get the maximum number of suspended sources. - */ -static __inline size_t -_citrus_mapper_get_src_max(struct _citrus_mapper * __restrict cm) -{ - - _DIAGASSERT(cm && cm->cm_traits); - - return cm->cm_traits->mt_src_max; -} - -/* - * _citrus_mapper_get_dst_max: - * get the maximum number of suspended destinations. - */ -static __inline size_t -_citrus_mapper_get_dst_max(struct _citrus_mapper * __restrict cm) -{ - - _DIAGASSERT(cm && cm->cm_traits); - - return cm->cm_traits->mt_dst_max; -} - -#endif diff --git a/lib/libc/citrus/citrus_mapper_local.h b/lib/libc/citrus/citrus_mapper_local.h deleted file mode 100644 index 4861e6655..000000000 --- a/lib/libc/citrus/citrus_mapper_local.h +++ /dev/null @@ -1,105 +0,0 @@ -/* $NetBSD: citrus_mapper_local.h,v 1.2 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_LOCAL_H_ -#define _CITRUS_MAPPER_LOCAL_H_ - -#define _CITRUS_MAPPER_GETOPS_FUNC_BASE(_n_) \ -int _n_(struct _citrus_mapper_ops *, size_t, uint32_t) -#define _CITRUS_MAPPER_GETOPS_FUNC(_n_) \ -_CITRUS_MAPPER_GETOPS_FUNC_BASE(_citrus_##_n_##_mapper_getops) - -#define _CITRUS_MAPPER_DECLS(_m_) \ -static int _citrus_##_m_##_mapper_init \ - (struct _citrus_mapper_area *__restrict, \ - struct _citrus_mapper * __restrict, const char * __restrict, \ - const void * __restrict, size_t, \ - struct _citrus_mapper_traits * __restrict, size_t); \ -static void _citrus_##_m_##_mapper_uninit(struct _citrus_mapper *); \ -static int _citrus_##_m_##_mapper_convert \ - (struct _citrus_mapper * __restrict, \ - _citrus_index_t * __restrict, _citrus_index_t, \ - void * __restrict); \ -static void _citrus_##_m_##_mapper_init_state \ - (struct _citrus_mapper * __restrict, void * __restrict); - -#define _CITRUS_MAPPER_DEF_OPS(_m_) \ -struct _citrus_mapper_ops _citrus_##_m_##_mapper_ops = { \ - /* mo_abi_version */ _CITRUS_MAPPER_ABI_VERSION, \ - /* mo_init */ &_citrus_##_m_##_mapper_init, \ - /* mo_uninit */ &_citrus_##_m_##_mapper_uninit, \ - /* mo_convert */ &_citrus_##_m_##_mapper_convert, \ - /* mo_init_state */ &_citrus_##_m_##_mapper_init_state \ -} - -typedef _CITRUS_MAPPER_GETOPS_FUNC_BASE((*_citrus_mapper_getops_t)); -typedef int (*_citrus_mapper_init_t)( - struct _citrus_mapper_area *__restrict, - struct _citrus_mapper *__restrict, const char *__restrict, - const void *__restrict, size_t, - struct _citrus_mapper_traits * __restrict, size_t); -typedef void (*_citrus_mapper_uninit_t)(struct _citrus_mapper *); -typedef int (*_citrus_mapper_convert_t)(struct _citrus_mapper * __restrict, - _citrus_index_t * __restrict, - _citrus_index_t, - void * __restrict); -typedef void (*_citrus_mapper_init_state_t)( - struct _citrus_mapper * __restrict, void * __restrict); - -/* - * ABI version change log - * 0x00000001 - * initial version - */ -#define _CITRUS_MAPPER_ABI_VERSION 0x00000001 -struct _citrus_mapper_ops { - uint32_t mo_abi_version; - /* version 0x00000001 */ - _citrus_mapper_init_t mo_init; - _citrus_mapper_uninit_t mo_uninit; - _citrus_mapper_convert_t mo_convert; - _citrus_mapper_init_state_t mo_init_state; -}; - -struct _citrus_mapper_traits { - /* version 0x00000001 */ - size_t mt_state_size; - size_t mt_src_max; - size_t mt_dst_max; -}; - -struct _citrus_mapper { - struct _citrus_mapper_ops *cm_ops; - void *cm_closure; - _citrus_module_t cm_module; - struct _citrus_mapper_traits *cm_traits; - _CITRUS_HASH_ENTRY(_citrus_mapper) cm_entry; - int cm_refcount; - char *cm_key; -}; -#endif diff --git a/lib/libc/citrus/citrus_memstream.c b/lib/libc/citrus/citrus_memstream.c deleted file mode 100644 index 17f9ea3ba..000000000 --- a/lib/libc/citrus/citrus_memstream.c +++ /dev/null @@ -1,153 +0,0 @@ -/* $NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_memstream.c,v 1.5 2012/03/13 21:13:31 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_bcs.h" - -const char * -_citrus_memory_stream_getln(struct _citrus_memory_stream * __restrict ms, - size_t * __restrict rlen) -{ - size_t i; - const uint8_t *h, *p; - size_t ret; - - if (ms->ms_pos>=_region_size(&ms->ms_region)) - return (NULL); - - h = p = (uint8_t *)_region_offset(&ms->ms_region, ms->ms_pos); - ret = 0; - for (i = _region_size(&ms->ms_region) - ms->ms_pos; i > 0; i--) { - ret++; - if (_bcs_iseol(*p)) - break; - p++; - } - - ms->ms_pos += ret; - *rlen = ret; - return ((const char *)h); -} - -#define T_COMM '#' - -const char * -_citrus_memory_stream_matchline(struct _citrus_memory_stream * __restrict ms, - const char * __restrict key, - size_t * __restrict rlen, - int iscasesensitive) -{ - const char *p, *q; - size_t len, keylen; - - keylen = strlen(key); - while (/*CONSTCOND*/ 1) { - p = _citrus_memory_stream_getln(ms, &len); - if (p == NULL) - return (NULL); - - /* ignore comment */ - q = memchr(p, T_COMM, len); - if (q) { - len = q-p; - } - /* ignore trailing white space and newline */ - _bcs_trunc_rws_len(p, &len); - if (len == 0) - continue; /* ignore null line */ - - /* skip white spaces at the head of the line */ - p = _bcs_skip_ws_len(p, &len); - q = _bcs_skip_nonws_len(p, &len); - - if ((size_t)(q-p) == keylen) { - if (iscasesensitive) { - if (memcmp(key, p, keylen) == 0) - break; /* match */ - } else { - if (_bcs_strncasecmp(key, p, keylen) == 0) - break; /* match */ - } - } - } - - p = _bcs_skip_ws_len(q, &len); - *rlen = len; - - return (p); -} - -void * -_citrus_memory_stream_chr(struct _citrus_memory_stream *ms, - struct _citrus_region *r, char ch) -{ - void *head, *chr; - size_t sz; - - if (ms->ms_pos >= _region_size(&ms->ms_region)) - return NULL; - - head = _region_offset(&ms->ms_region, ms->ms_pos); - chr = memchr(head, ch, _memstream_remainder(ms)); - if (chr == NULL) { - _region_init(r, head, _memstream_remainder(ms)); - ms->ms_pos = _region_size(&ms->ms_region); - return NULL; - } - sz = (char *)chr - (char *)head; - - _region_init(r, head, sz); - ms->ms_pos += sz+1; - - return chr; -} - -void -_citrus_memory_stream_skip_ws(struct _citrus_memory_stream *ms) -{ - int ch; - - while ((ch = _memstream_peek(ms)) != EOF) { - if (!_bcs_isspace(ch)) - break; - _memstream_getc(ms); - } -} diff --git a/lib/libc/citrus/citrus_memstream.h b/lib/libc/citrus/citrus_memstream.h deleted file mode 100644 index baeb14bc4..000000000 --- a/lib/libc/citrus/citrus_memstream.h +++ /dev/null @@ -1,213 +0,0 @@ -/* $NetBSD: citrus_memstream.h,v 1.3 2005/05/14 17:55:42 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_MEMSTREAM_H_ -#define _CITRUS_MEMSTREAM_H_ - -struct _citrus_memory_stream { - struct _citrus_region ms_region; - size_t ms_pos; -}; - -__BEGIN_DECLS -const char * _citrus_memory_stream_getln( - struct _citrus_memory_stream * __restrict, size_t * __restrict); -const char * _citrus_memory_stream_matchline( - struct _citrus_memory_stream * __restrict, const char * __restrict, - size_t * __restrict, int); -void * _citrus_memory_stream_chr(struct _citrus_memory_stream *, - struct _citrus_region *, char); -void _citrus_memory_stream_skip_ws(struct _citrus_memory_stream *); -__END_DECLS - -static __inline int -_citrus_memory_stream_iseof(struct _citrus_memory_stream *ms) -{ - return ms->ms_pos >= _citrus_region_size(&ms->ms_region); -} - -static __inline void -_citrus_memory_stream_bind(struct _citrus_memory_stream * __restrict ms, - const struct _citrus_region * __restrict r) -{ - ms->ms_region = *r; - ms->ms_pos = 0; -} - -static __inline void -_citrus_memory_stream_bind_ptr(struct _citrus_memory_stream * __restrict ms, - void *ptr, size_t sz) -{ - struct _citrus_region r; - - _citrus_region_init(&r, ptr, sz); - _citrus_memory_stream_bind(ms, &r); -} - -static __inline void -_citrus_memory_stream_rewind(struct _citrus_memory_stream *ms) -{ - ms->ms_pos = 0; -} - -static __inline size_t -_citrus_memory_stream_tell(struct _citrus_memory_stream *ms) -{ - return ms->ms_pos; -} - -static __inline size_t -_citrus_memory_stream_remainder(struct _citrus_memory_stream *ms) -{ - size_t sz; - sz = _citrus_region_size(&ms->ms_region); - if (ms->ms_pos>sz) - return 0; - return sz-ms->ms_pos; -} - -static __inline int -_citrus_memory_stream_seek(struct _citrus_memory_stream *ms, size_t pos, int w) -{ - size_t sz = _citrus_region_size(&ms->ms_region); - switch (w) { - case SEEK_SET: - if (pos>=sz) - return -1; - ms->ms_pos = pos; - break; - case SEEK_CUR: - pos += (ssize_t)ms->ms_pos; - if (pos>=sz) - return -1; - ms->ms_pos = pos; - break; - case SEEK_END: - if (szms_pos = sz - pos; - break; - } - return 0; -} - -static __inline int -_citrus_memory_stream_getc(struct _citrus_memory_stream *ms) -{ - if (_citrus_memory_stream_iseof(ms)) - return (EOF); - return _citrus_region_peek8(&ms->ms_region, ms->ms_pos++); -} - -static __inline void -_citrus_memory_stream_ungetc(struct _citrus_memory_stream *ms, int ch) -{ - if (ch != EOF && ms->ms_pos > 0) - ms->ms_pos--; -} - -static __inline int -_citrus_memory_stream_peek(struct _citrus_memory_stream *ms) -{ - if (_citrus_memory_stream_iseof(ms)) - return (EOF); - return _citrus_region_peek8(&ms->ms_region, ms->ms_pos); -} - -static __inline void * -_citrus_memory_stream_getregion(struct _citrus_memory_stream *ms, - struct _citrus_region *r, size_t sz) -{ - void *ret; - - if (ms->ms_pos + sz > _citrus_region_size(&ms->ms_region)) - return NULL; - - ret = _citrus_region_offset(&ms->ms_region, ms->ms_pos); - ms->ms_pos += sz; - if (r) - _citrus_region_init(r, ret, sz); - - return ret; -} - -static __inline int -_citrus_memory_stream_get8(struct _citrus_memory_stream *ms, uint8_t *rval) -{ - - if (ms->ms_pos + 1 > _citrus_region_size(&ms->ms_region)) - return -1; - - *rval = _citrus_region_peek8(&ms->ms_region, ms->ms_pos); - ms->ms_pos += 2; - - return 0; -} - -static __inline int -_citrus_memory_stream_get16(struct _citrus_memory_stream *ms, uint16_t *rval) -{ - - if (ms->ms_pos + 2 > _citrus_region_size(&ms->ms_region)) - return -1; - - *rval = _citrus_region_peek16(&ms->ms_region, ms->ms_pos); - ms->ms_pos += 2; - - return 0; -} - -static __inline int -_citrus_memory_stream_get32(struct _citrus_memory_stream *ms, uint32_t *rval) -{ - - if (ms->ms_pos + 4 > _citrus_region_size(&ms->ms_region)) - return -1; - - *rval = _citrus_region_peek32(&ms->ms_region, ms->ms_pos); - ms->ms_pos += 4; - - return 0; -} - -static __inline int -_citrus_memory_stream_getln_region(struct _citrus_memory_stream *ms, - struct _citrus_region *r) -{ - const char *ptr; - size_t sz; - - ptr = _citrus_memory_stream_getln(ms, &sz); - if (ptr) - _citrus_region_init(r, __UNCONST(ptr), sz); - - return ptr == NULL; -} - -#endif diff --git a/lib/libc/citrus/citrus_mmap.c b/lib/libc/citrus/citrus_mmap.c deleted file mode 100644 index ffcc8629d..000000000 --- a/lib/libc/citrus/citrus_mmap.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $NetBSD: citrus_mmap.c,v 1.4 2011/10/15 23:00:01 christos Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mmap.c,v 1.4 2011/10/15 23:00:01 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_region.h" -#include "citrus_mmap.h" - -int -_citrus_map_file(struct _citrus_region * __restrict r, - const char * __restrict path) -{ - int fd, ret = 0; - struct stat st; - void *head; - - _DIAGASSERT(r != NULL); - - _region_init(r, NULL, 0); - - if ((fd = open(path, O_RDONLY | O_CLOEXEC)) == -1) - return errno; - - if (fstat(fd, &st) == -1) { - ret = errno; - goto error; - } - if (!S_ISREG(st.st_mode)) { - ret = EOPNOTSUPP; - goto error; - } - - head = mmap(NULL, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_PRIVATE, - fd, (off_t)0); - if (head == MAP_FAILED) { - ret = errno; - goto error; - } - _region_init(r, head, (size_t)st.st_size); - -error: - (void)close(fd); - return ret; -} - -void -_citrus_unmap_file(struct _citrus_region *r) -{ - - _DIAGASSERT(r != NULL); - - if (_region_head(r) != NULL) { - (void)munmap(_region_head(r), _region_size(r)); - _region_init(r, NULL, 0); - } -} diff --git a/lib/libc/citrus/citrus_mmap.h b/lib/libc/citrus/citrus_mmap.h deleted file mode 100644 index 1a968a4ca..000000000 --- a/lib/libc/citrus/citrus_mmap.h +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: citrus_mmap.h,v 1.1 2003/06/25 09:51:38 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_MMAP_H_ -#define _CITRUS_MMAP_H_ - -__BEGIN_DECLS -int _citrus_map_file(struct _citrus_region * __restrict, - const char * __restrict); -void _citrus_unmap_file(struct _citrus_region *); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_module.c b/lib/libc/citrus/citrus_module.c deleted file mode 100644 index 69089ca8c..000000000 --- a/lib/libc/citrus/citrus_module.c +++ /dev/null @@ -1,369 +0,0 @@ -/* $NetBSD: citrus_module.c,v 1.12 2015/08/28 11:45:02 joerg Exp $ */ - -/*- - * Copyright (c)1999, 2000, 2001, 2002 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_module.c,v 1.12 2015/08/28 11:45:02 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_module.h" - -#include -#include -#include - -#ifdef _I18N_DYNAMIC - -static unsigned int _getdewey(int [], char *); -static int _cmpndewey(int [], unsigned int, int [], unsigned int); -static const char *_findshlib(char *, int *, int *); - -static const char *_pathI18nModule = NULL; - -/* from libexec/ld.aout_so/shlib.c */ -#undef major -#undef minor -#define MAXDEWEY 3 /*ELF*/ - -static unsigned int -_getdewey(int dewey[], char *cp) -{ - unsigned int i, n; - - _DIAGASSERT(dewey != NULL); - _DIAGASSERT(cp != NULL); - - for (n = 0, i = 0; i < MAXDEWEY; i++) { - if (*cp == '\0') - break; - - if (*cp == '.') cp++; - if (*cp < '0' || '9' < *cp) - return 0; - - dewey[n++] = (int)_bcs_strtol(cp, &cp, 10); - } - - return n; -} - -/* - * Compare two dewey arrays. - * Return -1 if `d1' represents a smaller value than `d2'. - * Return 1 if `d1' represents a greater value than `d2'. - * Return 0 if equal. - */ -static int -_cmpndewey(int d1[], unsigned int n1, int d2[], unsigned int n2) -{ - register unsigned int i; - - _DIAGASSERT(d1 != NULL); - _DIAGASSERT(d2 != NULL); - - for (i = 0; i < n1 && i < n2; i++) { - if (d1[i] < d2[i]) - return -1; - if (d1[i] > d2[i]) - return 1; - } - - if (n1 == n2) - return 0; - - if (i == n1) - return -1; - - if (i == n2) - return 1; - - /* XXX cannot happen */ - return 0; -} - -static const char * -_findshlib(char *name, int *majorp, int *minorp) -{ - int dewey[MAXDEWEY]; - unsigned int ndewey; - int tmp[MAXDEWEY]; - int i; - int len; - char *lname; - static char path[PATH_MAX]; - int major, minor; - const char *search_dirs[1]; - const int n_search_dirs = 1; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(majorp != NULL); - _DIAGASSERT(minorp != NULL); - - major = *majorp; - minor = *minorp; - path[0] = '\0'; - search_dirs[0] = _pathI18nModule; - len = strlen(name); - lname = name; - - ndewey = 0; - - for (i = 0; i < n_search_dirs; i++) { - DIR *dd = opendir(search_dirs[i]); - struct dirent *dp; - int found_dot_a = 0; - int found_dot_so = 0; - - if (dd == NULL) - continue; - - while ((dp = readdir(dd)) != NULL) { - unsigned int n; - - if (dp->d_namlen < len + 4) - continue; - if (strncmp(dp->d_name, lname, (size_t)len) != 0) - continue; - if (strncmp(dp->d_name+len, ".so.", 4) != 0) - continue; - - if ((n = _getdewey(tmp, dp->d_name+len+4)) == 0) - continue; - - if (major != -1 && found_dot_a) - found_dot_a = 0; - - /* XXX should verify the library is a.out/ELF? */ - - if (major == -1 && minor == -1) { - goto compare_version; - } else if (major != -1 && minor == -1) { - if (tmp[0] == major) - goto compare_version; - } else if (major != -1 && minor != -1) { - if (tmp[0] == major) { - if (n == 1 || tmp[1] >= minor) - goto compare_version; - } - } - - /* else, this file does not qualify */ - continue; - - compare_version: - if (_cmpndewey(tmp, n, dewey, ndewey) <= 0) - continue; - - /* We have a better version */ - found_dot_so = 1; - snprintf(path, sizeof(path), "%s/%s", search_dirs[i], - dp->d_name); - found_dot_a = 0; - bcopy(tmp, dewey, sizeof(dewey)); - ndewey = n; - *majorp = dewey[0]; - *minorp = dewey[1]; - } - closedir(dd); - - if (found_dot_a || found_dot_so) - /* - * There's a lib in this dir; take it. - */ - return path[0] ? path : NULL; - } - - return path[0] ? path : NULL; -} - -void * -_citrus_find_getops(_citrus_module_t handle, const char *modname, - const char *ifname) -{ - char name[PATH_MAX]; - void *p; - - _DIAGASSERT(handle != NULL); - _DIAGASSERT(modname != NULL); - _DIAGASSERT(ifname != NULL); - - snprintf(name, sizeof(name), _C_LABEL_STRING("_citrus_%s_%s_getops"), - modname, ifname); - p = dlsym((void *)handle, name); - return p; -} - -int -_citrus_load_module(_citrus_module_t *rhandle, const char *encname) -{ - const char *p; - char path[PATH_MAX]; - int maj, min; - void *handle; - - _DIAGASSERT(rhandle != NULL); - - if (_pathI18nModule == NULL) { - p = getenv("PATH_I18NMODULE"); - if (p == NULL || issetugid()) { - _pathI18nModule = _PATH_I18NMODULE; -#ifdef MLIBDIR - p = strrchr(_pathI18nModule, '/'); - if (p != NULL) { - snprintf(path, sizeof(path), "%.*s/%s/%s", - (int)(p - _pathI18nModule), - _pathI18nModule, MLIBDIR, p + 1); - p = path; - } else - p = NULL; -#endif - } - if (p != NULL) { - _pathI18nModule = strdup(p); - if (_pathI18nModule == NULL) - return ENOMEM; - } - } - - (void)snprintf(path, sizeof(path), "lib%s", encname); - maj = I18NMODULE_MAJOR; - min = -1; - p = _findshlib(path, &maj, &min); - if (!p) - return (EINVAL); - handle = dlopen(p, RTLD_LAZY); - if (!handle) - return (EINVAL); - - *rhandle = (_citrus_module_t)handle; - - return (0); -} - -void -_citrus_unload_module(_citrus_module_t handle) -{ - if (handle) - dlclose((void *)handle); -} -#else -/* !_I18N_DYNAMIC */ - -void * -/*ARGSUSED*/ -_citrus_find_getops(_citrus_module_t handle, const char *modname, - const char *ifname) -{ - return (NULL); -} - -int -/*ARGSUSED*/ -_citrus_load_module(_citrus_module_t *rhandle, char const *modname) -{ - return (EINVAL); -} - -void -/*ARGSUSED*/ -_citrus_unload_module(_citrus_module_t handle) -{ -} -#endif diff --git a/lib/libc/citrus/citrus_module.h b/lib/libc/citrus/citrus_module.h deleted file mode 100644 index d7e68b837..000000000 --- a/lib/libc/citrus/citrus_module.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD: citrus_module.h,v 1.1 2002/03/17 22:14:20 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_MODULE_H_ -#define _CITRUS_MODULE_H_ - -typedef struct _citrus_module_rec *_citrus_module_t; - -__BEGIN_DECLS -void *_citrus_find_getops(_citrus_module_t __restrict, - const char * __restrict, const char * __restrict); -int _citrus_load_module(_citrus_module_t * __restrict, - const char * __restrict); -void _citrus_unload_module(_citrus_module_t); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_namespace.h b/lib/libc/citrus/citrus_namespace.h deleted file mode 100644 index bb0937d6f..000000000 --- a/lib/libc/citrus/citrus_namespace.h +++ /dev/null @@ -1,238 +0,0 @@ -/* $NetBSD: citrus_namespace.h,v 1.8 2009/01/11 02:46:24 christos Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_NAMESPACE_H_ -#define _CITRUS_NAMESPACE_H_ - -/* citrus_alias */ -#ifndef _CITRUS_ALIAS_NO_NAMESPACE -#define _alias_lookup _citrus_alias_lookup -#endif /* _CITRUS_ALIAS_NO_NAMESPACE */ - -/* citrus_bcs */ -#ifndef _CITRUS_BCS_NO_NAMESPACE -#define _bcs_isalnum _citrus_bcs_isalnum -#define _bcs_isalpha _citrus_bcs_isalpha -#define _bcs_isblank _citrus_bcs_isblank -#define _bcs_isdigit _citrus_bcs_isdigit -#define _bcs_islower _citrus_bcs_islower -#define _bcs_iseol _citrus_bcs_iseol -#define _bcs_isspace _citrus_bcs_isspace -#define _bcs_isupper _citrus_bcs_isupper -#define _bcs_isxdigit _citrus_bcs_isxdigit -#define _bcs_skip_nonws _citrus_bcs_skip_nonws -#define _bcs_skip_nonws_len _citrus_bcs_skip_nonws_len -#define _bcs_skip_ws _citrus_bcs_skip_ws -#define _bcs_skip_ws_len _citrus_bcs_skip_ws_len -#define _bcs_strcasecmp _citrus_bcs_strcasecmp -#define _bcs_strncasecmp _citrus_bcs_strncasecmp -#define _bcs_tolower _citrus_bcs_tolower -#define _bcs_toupper _citrus_bcs_toupper -#define _bcs_trunc_rws_len _citrus_bcs_trunc_rws_len -#define _bcs_convert_to_lower _citrus_bcs_convert_to_lower -#define _bcs_convert_to_upper _citrus_bcs_convert_to_upper -#define _bcs_strtol _citrus_bcs_strtol -#define _bcs_strtoul _citrus_bcs_strtoul -#endif /* _CITRUS_BCS_NO_NAMESPACE */ - -/* citrus_csmapper */ -#ifndef _CITRUS_CSMAPPER_NO_NAMESPACE -#define _csmapper _citrus_csmapper -#define _csmapper_open _citrus_csmapper_open -#define _csmapper_close _citrus_csmapper_close -#define _csmapper_convert _citrus_csmapper_convert -#define _csmapper_init_state _citrus_csmapper_init_state -#define _csmapper_get_state_size _citrus_csmapper_get_state_size -#define _csmapper_get_src_max _citrus_csmapper_get_src_max -#define _csmapper_get_dst_max _citrus_csmapper_get_dst_max -#define _CSMAPPER_F_PREVENT_PIVOT _CITRUS_CSMAPPER_F_PREVENT_PIVOT -#endif /* _CITRUS_CSMAPPER_NO_NAMESPACE */ - -/* citrus_db */ -#ifndef _CITRUS_DB_NO_NAMESPACE -#define _db_open _citrus_db_open -#define _db_close _citrus_db_close -#define _db_lookup _citrus_db_lookup -#define _db_lookup_by_s _citrus_db_lookup_by_string -#define _db_lookup8_by_s _citrus_db_lookup8_by_string -#define _db_lookup16_by_s _citrus_db_lookup16_by_string -#define _db_lookup32_by_s _citrus_db_lookup32_by_string -#define _db_lookupstr_by_s _citrus_db_lookup_string_by_string -#define _db_hash_std _citrus_db_hash_std -#define _db_get_num_entries _citrus_db_get_number_of_entries -#define _db_get_entry _citrus_db_get_entry -#define _db_locator _citrus_db_locator -#define _db_locator_init _citrus_db_locator_init -#endif /* _CITRUS_DB_NO_NAMESPACE */ - -/* citrus_db_factory */ -#ifndef _CITRUS_DB_FACTORY_NO_NAMESPACE -#define _db_factory _citrus_db_factory -#define _db_factory_create _citrus_db_factory_create -#define _db_factory_free _citrus_db_factory_free -#define _db_factory_add _citrus_db_factory_add -#define _db_factory_add_by_s _citrus_db_factory_add_by_string -#define _db_factory_add8_by_s _citrus_db_factory_add8_by_string -#define _db_factory_add16_by_s _citrus_db_factory_add16_by_string -#define _db_factory_add32_by_s _citrus_db_factory_add32_by_string -#define _db_factory_addstr_by_s _citrus_db_factory_add_string_by_string -#define _db_factory_calc_size _citrus_db_factory_calc_size -#define _db_factory_serialize _citrus_db_factory_serialize -#endif /* _CITRUS_DB_FACTORY_NO_NAMESPACE */ - -/* citrus_lookup */ -#ifndef _CITRUS_DB_NO_NAMESPACE -#define _LOOKUP_CASE_SENSITIVE _CITRUS_LOOKUP_CASE_SENSITIVE -#define _LOOKUP_CASE_IGNORE _CITRUS_LOOKUP_CASE_IGNORE -#define _lookup _citrus_lookup -#define _lookup_simple _citrus_lookup_simple -#define _lookup_alias _citrus_lookup_alias -#define _lookup_seq_open _citrus_lookup_seq_open -#define _lookup_seq_rewind _citrus_lookup_seq_rewind -#define _lookup_seq_next _citrus_lookup_seq_next -#define _lookup_seq_lookup _citrus_lookup_seq_lookup -#define _lookup_get_num_entries _citrus_lookup_get_number_of_entries -#define _lookup_seq_close _citrus_lookup_seq_close -#define _lookup_factory_convert _citrus_lookup_factory_convert -#endif /* _CITRUS_DB_NO_NAMESPACE */ - -/* citrus_esdb */ -#ifndef _CITRUS_ESDB_NO_NAMESPACE -#define _esdb _citrus_esdb -#define _esdb_charset _citrus_esdb_charset -#define _esdb_open _citrus_esdb_open -#define _esdb_close _citrus_esdb_close -#define _esdb_get_list _citrus_esdb_get_list -#define _esdb_free_list _citrus_esdb_free_list -#endif /* _CITRUS_ESDB_NO_NAMESPACE */ - -/* citrus_hash */ -#ifndef _CITRUS_HASH_NO_NAMESPACE -#define _citrus_string_hash_func _string_hash_func -#endif /* _CITRUS_HASH_NO_NAMESPACE */ - -/* citrus_mapper */ -#ifndef _CITRUS_MAPPER_NO_NAMESPACE -#define _mapper _citrus_mapper -#define _mapper_ops _citrus_mapper_ops -#define _mapper_traits _citrus_mapper_traits -#define _mapper_open _citrus_mapper_open -#define _mapper_open_direct _citrus_mapper_open_direct -#define _mapper_close _citrus_mapper_close -#define _MAPPER_CONVERT_SUCCESS _CITRUS_MAPPER_CONVERT_SUCCESS -#define _MAPPER_CONVERT_NONIDENTICAL _CITRUS_MAPPER_CONVERT_NONIDENTICAL -#define _MAPPER_CONVERT_SRC_MORE _CITRUS_MAPPER_CONVERT_SRC_MORE -#define _MAPPER_CONVERT_DST_MORE _CITRUS_MAPPER_CONVERT_DST_MORE -#define _MAPPER_CONVERT_ILSEQ _CITRUS_MAPPER_CONVERT_ILSEQ -#define _MAPPER_CONVERT_FATAL _CITRUS_MAPPER_CONVERT_FATAL -#define _mapper_convert _citrus_mapper_convert -#define _mapper_init_state _citrus_mapper_init_state -#define _mapper_get_state_size _citrus_mapper_get_state_size -#define _mapper_get_src_max _citrus_mapper_get_src_max -#define _mapper_get_dst_max _citrus_mapper_get_dst_max -#define _mapper_set_persistent _citrus_mapper_set_persistent -#endif /* _CITRUS_MAPPER_NO_NAMESPACE */ - -/* citrus_memstream */ -#ifndef _CITRUS_MEMSTREAM_NO_NAMESPACE -#define _memstream _citrus_memory_stream -#define _memstream_getln _citrus_memory_stream_getln -#define _memstream_matchline _citrus_memory_stream_matchline -#define _memstream_chr _citrus_memory_stream_chr -#define _memstream_skip_ws _citrus_memory_stream_skip_ws -#define _memstream_iseof _citrus_memory_stream_iseof -#define _memstream_bind _citrus_memory_stream_bind -#define _memstream_bind_ptr _citrus_memory_stream_bind_ptr -#define _memstream_seek _citrus_memory_stream_seek -#define _memstream_rewind _citrus_memory_stream_rewind -#define _memstream_tell _citrus_memory_stream_tell -#define _memstream_remainder _citrus_memory_stream_remainder -#define _memstream_getc _citrus_memory_stream_getc -#define _memstream_ungetc _citrus_memory_stream_ungetc -#define _memstream_peek _citrus_memory_stream_peek -#define _memstream_getregion _citrus_memory_stream_getregion -#define _memstream_getln_region _citrus_memory_stream_getln_region -#endif /* _CITRUS_MEMSTREAM_NO_NAMESPACE */ - -/* citrus_mmap */ -#ifndef _CITRUS_MMAP_NO_NAMESPACE -#define _map_file _citrus_map_file -#define _unmap_file _citrus_unmap_file -#endif /* _CITRUS_MMAP_NO_NAMESPACE */ - -#ifndef _CITRUS_PIVOT_NO_NAMESPACE -#define _pivot_factory_convert _citrus_pivot_factory_convert -#endif /* _CITRUS_PIVOT_NO_NAMESPACE */ - -/* citrus_region.h */ -#ifndef _CITRUS_REGION_NO_NAMESPACE -#define _region _citrus_region -#define _region_init _citrus_region_init -#define _region_head _citrus_region_head -#define _region_size _citrus_region_size -#define _region_check _citrus_region_check -#define _region_offset _citrus_region_offset -#define _region_peek8 _citrus_region_peek8 -#define _region_peek16 _citrus_region_peek16 -#define _region_peek32 _citrus_region_peek32 -#define _region_get_subregion _citrus_region_get_subregion -#endif /* _CITRUS_REGION_NO_NAMESPACE */ - -/* citrus_stdenc.h */ -#ifndef _CITRUS_STDENC_NO_NAMESPACE -#define _stdenc _citrus_stdenc -#define _stdenc_ops _citrus_stdenc_ops -#define _stdenc_traits _citrus_stdenc_traits -#define _stdenc_state_desc _citrus_stdenc_state_desc -#define _stdenc_open _citrus_stdenc_open -#define _stdenc_close _citrus_stdenc_close -#define _stdenc_init_state _citrus_stdenc_init_state -#define _stdenc_mbtocs _citrus_stdenc_mbtocs -#define _stdenc_cstomb _citrus_stdenc_cstomb -#define _stdenc_mbtowc _citrus_stdenc_mbtowc -#define _stdenc_wctomb _citrus_stdenc_wctomb -#define _stdenc_put_state_reset _citrus_stdenc_put_state_reset -#define _stdenc_get_state_size _citrus_stdenc_get_state_size -#define _stdenc_get_mb_cur_max _citrus_stdenc_get_mb_cur_max -#define _stdenc_get_state_desc _citrus_stdenc_get_state_desc -#define _STDENC_SDID_GENERIC _CITRUS_STDENC_SDID_GENERIC -#define _STDENC_SDGEN_UNKNOWN _CITRUS_STDENC_SDGEN_UNKNOWN -#define _STDENC_SDGEN_INITIAL _CITRUS_STDENC_SDGEN_INITIAL -#define _STDENC_SDGEN_STABLE _CITRUS_STDENC_SDGEN_STABLE -#define _STDENC_SDGEN_INCOMPLETE_CHAR _CITRUS_STDENC_SDGEN_INCOMPLETE_CHAR -#define _STDENC_SDGEN_INCOMPLETE_SHIFT _CITRUS_STDENC_SDGEN_INCOMPLETE_SHIFT -#endif /* _CITRUS_STDENC_NO_NAMESPACE */ - -/* citrus_types.h */ -#ifndef _CITRUS_TYPES_NO_NAMESPACE -#define _index_t _citrus_index_t -#define _csid_t _citrus_csid_t -#define _wc_t _citrus_wc_t -#endif /* _CITRUS_TYPES_NO_NAMESPACE */ - -#endif diff --git a/lib/libc/citrus/citrus_none.c b/lib/libc/citrus/citrus_none.c deleted file mode 100644 index 381e74340..000000000 --- a/lib/libc/citrus/citrus_none.c +++ /dev/null @@ -1,586 +0,0 @@ -/* $NetBSD: citrus_none.c,v 1.19 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_none.c,v 1.19 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_none.h" -#include "citrus_stdenc.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_CTYPE_DECLS(NONE); -_CITRUS_CTYPE_DEF_OPS(NONE); - - -/* ---------------------------------------------------------------------- */ - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_init(void ** __restrict cl, void * __restrict var, - size_t lenvar, size_t lenps) -{ - *cl = NULL; - return (0); -} - -static void -/*ARGSUSED*/ -_citrus_NONE_ctype_uninit(void *cl) -{ -} - -static unsigned -/*ARGSUSED*/ -_citrus_NONE_ctype_get_mb_cur_max(void *cl) -{ - return (1); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_mblen(void * __restrict cl, const char * __restrict s, - size_t n, int * __restrict nresult) -{ - if (!s) { - *nresult = 0; /* state independent */ - return (0); - } - if (n==0) { - *nresult = -1; - return (EILSEQ); - } - *nresult = (*s == 0) ? 0 : 1; - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_mbrlen(void * __restrict cl, const char * __restrict s, - size_t n, void * __restrict pspriv, - size_t * __restrict nresult) -{ - if (!s) { - *nresult = 0; - return (0); - } - if (n==0) { - *nresult = (size_t)-2; - return (0); - } - *nresult = (*s == 0) ? 0 : 1; - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_mbrtowc(void * __restrict cl, wchar_t * __restrict pwc, - const char * __restrict s, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - if (s == NULL) { - *nresult = 0; - return (0); - } - if (n == 0) { - *nresult = (size_t)-2; - return (0); - } - - if (pwc != NULL) - *pwc = (wchar_t)(unsigned char) *s; - - *nresult = *s == '\0' ? 0 : 1; - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_mbsinit(void * __restrict cl, - const void * __restrict pspriv, - int * __restrict nresult) -{ - *nresult = 1; /* always initial state */ - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_mbsrtowcs(void * __restrict cl, wchar_t * __restrict pwcs, - const char ** __restrict s, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - int cnt; - const char *s0; - - /* if pwcs is NULL, ignore n */ - if (pwcs == NULL) - n = 1; /* arbitrary >0 value */ - - cnt = 0; - s0 = *s; /* to keep *s unchanged for now, use copy instead. */ - while (n > 0) { - if (pwcs != NULL) { - *pwcs = (wchar_t)(unsigned char)*s0; - } - if (*s0 == '\0') { - s0 = NULL; - break; - } - s0++; - if (pwcs != NULL) { - pwcs++; - n--; - } - cnt++; - } - if (pwcs) - *s = s0; - - *nresult = (size_t)cnt; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_mbsnrtowcs(_citrus_ctype_rec_t * __restrict cc, - wchar_t * __restrict pwcs, - const char ** __restrict s, size_t in, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - int cnt; - const char *s0; - - /* if pwcs is NULL, ignore n */ - if (pwcs == NULL) - n = 1; /* arbitrary >0 value */ - - cnt = 0; - s0 = *s; /* to keep *s unchanged for now, use copy instead. */ - while (in > 0 && n > 0) { - if (pwcs != NULL) { - *pwcs = (wchar_t)(unsigned char)*s0; - } - if (*s0 == '\0') { - s0 = NULL; - break; - } - s0++; - --in; - if (pwcs != NULL) { - pwcs++; - n--; - } - cnt++; - } - if (pwcs) - *s = s0; - - *nresult = (size_t)cnt; - - return (0); -} - -static int -_citrus_NONE_ctype_mbstowcs(void * __restrict cl, wchar_t * __restrict wcs, - const char * __restrict s, size_t n, - size_t * __restrict nresult) -{ - const char *rs = s; - - return (_citrus_NONE_ctype_mbsrtowcs(cl, wcs, &rs, n, NULL, nresult)); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_mbtowc(void * __restrict cl, wchar_t * __restrict pwc, - const char * __restrict s, size_t n, - int * __restrict nresult) -{ - - if (s == NULL) { - *nresult = 0; /* state independent */ - return (0); - } - if (n == 0) { - return (EILSEQ); - } - if (pwc == NULL) { - if (*s == '\0') { - *nresult = 0; - } else { - *nresult = 1; - } - return (0); - } - - *pwc = (wchar_t)(unsigned char)*s; - *nresult = *s == '\0' ? 0 : 1; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_wcrtomb(void * __restrict cl, char * __restrict s, - wchar_t wc, void * __restrict pspriv, - size_t * __restrict nresult) -{ - if ((wc&~0xFFU) != 0) { - *nresult = (size_t)-1; - return (EILSEQ); - } - - *nresult = 1; - if (s!=NULL) - *s = (char)wc; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_wcsrtombs(void * __restrict cl, char * __restrict s, - const wchar_t ** __restrict pwcs, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - size_t count; - const wchar_t *pwcs0; - - pwcs0 = *pwcs; - count = 0; - - if (s == NULL) - n = 1; - - while (n > 0) { - if ((*pwcs0 & ~0xFFU) != 0) { - *nresult = (size_t)-1; - return (EILSEQ); - } - if (s != NULL) { - *s++ = (char)*pwcs0; - n--; - } - if (*pwcs0 == L'\0') { - pwcs0 = NULL; - break; - } - count++; - pwcs0++; - } - if (s != NULL) - *pwcs = pwcs0; - - *nresult = count; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_wcsnrtombs(_citrus_ctype_rec_t * __restrict cc, - char * __restrict s, - const wchar_t ** __restrict pwcs, size_t in, - size_t n, void * __restrict pspriv, - size_t * __restrict nresult) -{ - size_t count; - const wchar_t *pwcs0; - - pwcs0 = *pwcs; - count = 0; - - if (s == NULL) - n = 1; - - while (in > 0 && n > 0) { - if ((*pwcs0 & ~0xFFU) != 0) { - *nresult = (size_t)-1; - return (EILSEQ); - } - if (s != NULL) { - *s++ = (char)*pwcs0; - n--; - } - if (*pwcs0 == L'\0') { - pwcs0 = NULL; - break; - } - count++; - pwcs0++; - --in; - } - if (s != NULL) - *pwcs = pwcs0; - - *nresult = count; - - return (0); -} - -static int -_citrus_NONE_ctype_wcstombs(void * __restrict cl, char * __restrict s, - const wchar_t * __restrict pwcs, size_t n, - size_t * __restrict nresult) -{ - const wchar_t *rpwcs = pwcs; - - return (_citrus_NONE_ctype_wcsrtombs(cl, s, &rpwcs, n, NULL, nresult)); -} - -static int -_citrus_NONE_ctype_wctomb(void * __restrict cl, char * __restrict s, - wchar_t wc, int * __restrict nresult) -{ - int ret; - size_t nr; - - if (s == 0) { - /* - * initialize state here. - * (nothing to do for us.) - */ - *nresult = 0; /* we're state independent */ - return (0); - } - - ret = _citrus_NONE_ctype_wcrtomb(cl, s, wc, NULL, &nr); - *nresult = (int)nr; - - return (ret); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_btowc(_citrus_ctype_rec_t * __restrict cc, - int c, wint_t * __restrict wcresult) -{ - if (c == EOF || c & ~0xFF) - *wcresult = WEOF; - else - *wcresult = (wint_t)c; - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_ctype_wctob(_citrus_ctype_rec_t * __restrict cc, - wint_t wc, int * __restrict cresult) -{ - if (wc == WEOF || wc & ~0xFF) - *cresult = EOF; - else - *cresult = (int)wc; - return (0); -} - -/* ---------------------------------------------------------------------- */ - -_CITRUS_STDENC_DECLS(NONE); -_CITRUS_STDENC_DEF_OPS(NONE); -struct _citrus_stdenc_traits _citrus_NONE_stdenc_traits = { - 0, /* et_state_size */ - 1, /* mb_cur_max */ -}; - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_init(struct _citrus_stdenc * __restrict ce, - const void *var, size_t lenvar, - struct _citrus_stdenc_traits * __restrict et) -{ - - et->et_state_size = 0; - et->et_mb_cur_max = 1; - - ce->ce_closure = NULL; - - return (0); -} - -static void -/*ARGSUSED*/ -_citrus_NONE_stdenc_uninit(struct _citrus_stdenc *ce) -{ -} - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_init_state(struct _citrus_stdenc * __restrict ce, - void * __restrict ps) -{ - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce, - _csid_t *csid, _index_t *idx, - const char **s, size_t n, - void *ps, size_t *nresult) -{ - - _DIAGASSERT(csid != NULL && idx != NULL); - - if (n<1) { - *nresult = (size_t)-2; - return (0); - } - - *csid = 0; - *idx = (_index_t)(unsigned char)*(*s)++; - *nresult = *idx == 0 ? 0 : 1; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_cstomb(struct _citrus_stdenc * __restrict ce, - char *s, size_t n, - _csid_t csid, _index_t idx, - void *ps, size_t *nresult) -{ - - if (csid == _CITRUS_CSID_INVALID) { - *nresult = 0; - return (0); - } - if (n<1) { - *nresult = (size_t)-1; - return (E2BIG); - } - if (csid != 0 || (idx&0xFF) != idx) - return (EILSEQ); - - *s = (char)idx; - *nresult = 1; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_mbtowc(struct _citrus_stdenc * __restrict ce, - _wc_t * __restrict pwc, - const char ** __restrict s, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - if (s == NULL) { - *nresult = 0; - return (0); - } - if (n == 0) { - *nresult = (size_t)-2; - return (0); - } - - if (pwc != NULL) - *pwc = (_wc_t)(unsigned char) **s; - - *nresult = *s == '\0' ? 0 : 1; - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_wctomb(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, - _wc_t wc, void * __restrict pspriv, - size_t * __restrict nresult) -{ - if ((wc&~0xFFU) != 0) { - *nresult = (size_t)-1; - return (EILSEQ); - } - if (n==0) { - *nresult = (size_t)-1; - return (E2BIG); - } - - *nresult = 1; - if (s!=NULL && n>0) - *s = (char)wc; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_put_state_reset(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, - void * __restrict pspriv, - size_t * __restrict nresult) -{ - - *nresult = 0; - - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_NONE_stdenc_get_state_desc(struct _stdenc * __restrict ce, - void * __restrict ps, - int id, - struct _stdenc_state_desc * __restrict d) -{ - int ret = 0; - - switch (id) { - case _STDENC_SDID_GENERIC: - d->u.generic.state = _STDENC_SDGEN_INITIAL; - break; - default: - ret = EOPNOTSUPP; - } - - return ret; -} diff --git a/lib/libc/citrus/citrus_none.h b/lib/libc/citrus/citrus_none.h deleted file mode 100644 index 1a75f2c0f..000000000 --- a/lib/libc/citrus/citrus_none.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_none.h,v 1.3 2003/06/25 09:51:38 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_NONE_H_ -#define _CITRUS_NONE_H_ - -extern struct _citrus_ctype_ops_rec _citrus_NONE_ctype_ops; -extern struct _citrus_stdenc_ops _citrus_NONE_stdenc_ops; -extern struct _citrus_stdenc_traits _citrus_NONE_stdenc_traits; - -#endif diff --git a/lib/libc/citrus/citrus_pivot_factory.c b/lib/libc/citrus/citrus_pivot_factory.c deleted file mode 100644 index 54369caf6..000000000 --- a/lib/libc/citrus/citrus_pivot_factory.c +++ /dev/null @@ -1,231 +0,0 @@ -/* $NetBSD: citrus_pivot_factory.c,v 1.7 2009/04/12 14:20:19 lukem Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_pivot_factory.c,v 1.7 2009/04/12 14:20:19 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_region.h" -#include "citrus_bcs.h" -#include "citrus_db_factory.h" -#include "citrus_db_hash.h" -#include "citrus_pivot_file.h" -#include "citrus_pivot_factory.h" - -struct src_entry { - char *se_name; - struct _citrus_db_factory *se_df; - SIMPLEQ_ENTRY(src_entry) se_entry; -}; -SIMPLEQ_HEAD(src_head, src_entry); - -static int -find_src(struct src_head *sh, struct src_entry **rse, const char *name) -{ - int ret; - struct src_entry *se; - - SIMPLEQ_FOREACH(se, sh, se_entry) { - if (_bcs_strcasecmp(se->se_name, name) == 0) { - *rse = se; - return 0; - } - } - se = malloc(sizeof(*se)); - if (se == NULL) - return errno; - se->se_name = strdup(name); - if (se->se_name == NULL) { - ret = errno; - free(se); - return ret; - } - ret = _db_factory_create(&se->se_df, &_db_hash_std, NULL); - if (ret) { - free(se->se_name); - free(se); - return ret; - } - SIMPLEQ_INSERT_TAIL(sh, se, se_entry); - *rse = se; - - return 0; -} - -static void -free_src(struct src_head *sh) -{ - struct src_entry *se; - - while ((se = SIMPLEQ_FIRST(sh)) != NULL) { - SIMPLEQ_REMOVE_HEAD(sh, se_entry); - _db_factory_free(se->se_df); - free(se->se_name); - free(se); - } -} - - -#define T_COMM '#' -static int -convert_line(struct src_head *sh, const char *line, size_t len) -{ - int ret; - struct src_entry *se; - const char *p; - char key1[LINE_MAX], key2[LINE_MAX], data[LINE_MAX]; - char *ep; - uint32_t val; - - se = NULL; /* XXX gcc */ - - /* cut off trailing comment */ - p = memchr(line, T_COMM, len); - if (p) - len = p - line; - - /* key1 */ - line = _bcs_skip_ws_len(line, &len); - if (len == 0) - return 0; - p = _bcs_skip_nonws_len(line, &len); - if (p==line) - return 0; - snprintf(key1, sizeof(key1), "%.*s", (int)(p-line), line); - - /* key2 */ - line = _bcs_skip_ws_len(p, &len); - if (len == 0) - return 0; - p = _bcs_skip_nonws_len(line, &len); - if (p==line) - return 0; - snprintf(key2, sizeof(key2), "%.*s", (int)(p-line), line); - - /* data */ - line = _bcs_skip_ws_len(p, &len); - _bcs_trunc_rws_len(line, &len); - snprintf(data, sizeof(data), "%.*s", (int)len, line); - val = strtoul(data, &ep, 0); - if (*ep != '\0') - return EFTYPE; - - /* insert to DB */ - ret = find_src(sh, &se, key1); - if (ret) - return ret; - - return _db_factory_add32_by_s(se->se_df, key2, val); -} - -static int -dump_db(struct src_head *sh, struct _region *r) -{ - int ret; - struct _db_factory *df; - struct src_entry *se; - size_t size; - void *ptr; - struct _region subr; - - ret = _db_factory_create(&df, &_db_hash_std, NULL); - if (ret) - return ret; - - SIMPLEQ_FOREACH(se, sh, se_entry) { - size = _db_factory_calc_size(se->se_df); - ptr = malloc(size); - if (ptr == NULL) - goto quit; - _region_init(&subr, ptr, size); - ret = _db_factory_serialize(se->se_df, _CITRUS_PIVOT_SUB_MAGIC, - &subr); - if (ret) - goto quit; - ret = _db_factory_add_by_s(df, se->se_name, &subr, 1); - if (ret) - goto quit; - } - - size = _db_factory_calc_size(df); - ptr = malloc(size); - if (ptr == NULL) - goto quit; - _region_init(r, ptr, size); - - ret = _db_factory_serialize(df, _CITRUS_PIVOT_MAGIC, r); - ptr = NULL; - -quit: - free(ptr); - _db_factory_free(df); - return ret; -} - -int -_citrus_pivot_factory_convert(FILE *out, FILE *in) -{ - struct src_head sh; - struct _region r; - char *line; - size_t size; - int ret; - - SIMPLEQ_INIT(&sh); - - while ((line = fgetln(in, &size)) != NULL) - if ((ret = convert_line(&sh, line, size))) { - free_src(&sh); - return ret; - } - - ret = dump_db(&sh, &r); - free_src(&sh); - if (ret) - return ret; - - if (fwrite(_region_head(&r), _region_size(&r), 1, out) != 1) - return errno; - - return 0; -} diff --git a/lib/libc/citrus/citrus_pivot_factory.h b/lib/libc/citrus/citrus_pivot_factory.h deleted file mode 100644 index dd5d80488..000000000 --- a/lib/libc/citrus/citrus_pivot_factory.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_pivot_factory.h,v 1.1 2003/06/25 09:51:39 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_PIVOT_FACTORY_H_ -#define _CITRUS_PIVOT_FACTORY_H_ - -__BEGIN_DECLS -int _citrus_pivot_factory_convert(FILE *, FILE *); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/citrus_pivot_file.h b/lib/libc/citrus/citrus_pivot_file.h deleted file mode 100644 index eb50645a1..000000000 --- a/lib/libc/citrus/citrus_pivot_file.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: citrus_pivot_file.h,v 1.1 2003/06/25 09:51:39 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_PIVOT_FILE_H_ -#define _CITRUS_PIVOT_FILE_H_ - -#define _CITRUS_PIVOT_MAGIC "CSPIVOT\0" -#define _CITRUS_PIVOT_SUB_MAGIC "CSPIVSUB" - -#endif diff --git a/lib/libc/citrus/citrus_prop.c b/lib/libc/citrus/citrus_prop.c deleted file mode 100644 index 198a9e7c8..000000000 --- a/lib/libc/citrus/citrus_prop.c +++ /dev/null @@ -1,467 +0,0 @@ -/* $NetBSD: citrus_prop.c,v 1.5 2014/06/24 22:24:18 spz Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_prop.c,v 1.5 2014/06/24 22:24:18 spz Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_prop.h" - -typedef struct { - _citrus_prop_type_t type; - union { - const char *str; - int chr; - bool boolean; - uint64_t num; - } u; -} _citrus_prop_object_t; - -static __inline void -_citrus_prop_object_init(_citrus_prop_object_t *obj, _citrus_prop_type_t type) -{ - _DIAGASSERT(obj != NULL); - - obj->type = type; - memset(&obj->u, 0, sizeof(obj->u)); -} - -static __inline void -_citrus_prop_object_uninit(_citrus_prop_object_t *obj) -{ - _DIAGASSERT(obj != NULL); - - if (obj->type == _CITRUS_PROP_STR) - free(__UNCONST(obj->u.str)); -} - -static const char *xdigit = "0123456789ABCDEF"; - -#define _CITRUS_PROP_READ_UINT_COMMON(_func_, _type_, _max_) \ -static int \ -_citrus_prop_read_##_func_##_common(struct _memstream * __restrict ms, \ - _type_ * __restrict result, int base) \ -{ \ - _type_ acc, cutoff; \ - int n, ch, cutlim; \ - char *p; \ - \ - _DIAGASSERT(ms != NULL); \ - _DIAGASSERT(result != NULL); \ - \ - acc = (_type_)0; \ - cutoff = _max_ / base; \ - cutlim = _max_ % base; \ - for (;;) { \ - ch = _memstream_getc(ms); \ - p = strchr(xdigit, _bcs_toupper(ch)); \ - if (p == NULL || (n = (p - xdigit)) >= base) \ - break; \ - if (acc > cutoff || (acc == cutoff && n > cutlim)) \ - break; \ - acc *= base; \ - acc += n; \ - } \ - _memstream_ungetc(ms, ch); \ - *result = acc; \ - return 0; \ -} -_CITRUS_PROP_READ_UINT_COMMON(chr, int, UCHAR_MAX) -_CITRUS_PROP_READ_UINT_COMMON(num, uint64_t, UINT64_MAX) -#undef _CITRUS_PROP_READ_UINT_COMMON - -#define _CITRUS_PROP_READ_INT(_func_, _type_) \ -static int \ -_citrus_prop_read_##_func_(struct _memstream * __restrict ms, \ - _citrus_prop_object_t * __restrict obj) \ -{ \ - int ch, neg, base; \ - \ - _DIAGASSERT(ms != NULL); \ - _DIAGASSERT(obj != NULL); \ - \ - _memstream_skip_ws(ms); \ - ch = _memstream_getc(ms); \ - neg = 0; \ - switch (ch) { \ - case '-': \ - neg = 1; \ - case '+': \ - ch = _memstream_getc(ms); \ - } \ - base = 10; \ - if (ch == '0') { \ - base -= 2; \ - ch = _memstream_getc(ms); \ - if (ch == 'x' || ch == 'X') { \ - ch = _memstream_getc(ms); \ - if (_bcs_isxdigit(ch) == 0) { \ - _memstream_ungetc(ms, ch); \ - obj->u._func_ = 0; \ - return 0; \ - } \ - base += 8; \ - } \ - } else if (_bcs_isdigit(ch) == 0) \ - return EINVAL; \ - _memstream_ungetc(ms, ch); \ - return _citrus_prop_read_##_func_##_common \ - (ms, &obj->u._func_, base); \ -} -_CITRUS_PROP_READ_INT(chr, int) -_CITRUS_PROP_READ_INT(num, uint64_t) -#undef _CITRUS_PROP_READ_INT - -static int -_citrus_prop_read_character_common(struct _memstream * __restrict ms, - int * __restrict result) -{ - int ch, base; - - _DIAGASSERT(ms != NULL); - _DIAGASSERT(result != NULL); - - ch = _memstream_getc(ms); - if (ch != '\\') { - *result = ch; - } else { - ch = _memstream_getc(ms); - base = 16; - switch (ch) { - case 'a': *result = '\a'; break; - case 'b': *result = '\b'; break; - case 'f': *result = '\f'; break; - case 'n': *result = '\n'; break; - case 'r': *result = '\r'; break; - case 't': *result = '\t'; break; - case 'v': *result = '\v'; break; - /*FALLTHROUGH*/ - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - _memstream_ungetc(ms, ch); - base -= 8; - case 'x': - return _citrus_prop_read_chr_common(ms, result, base); - - default: - /* unknown escape */ - *result = ch; - } - } - return 0; -} - -static int -_citrus_prop_read_character(struct _memstream * __restrict ms, - _citrus_prop_object_t * __restrict obj) -{ - int ch, errnum; - - _DIAGASSERT(ms != NULL); - _DIAGASSERT(obj != NULL); - - _memstream_skip_ws(ms); - ch = _memstream_getc(ms); - if (ch != '\'') { - _memstream_ungetc(ms, ch); - return _citrus_prop_read_chr(ms, obj); - } - errnum = _citrus_prop_read_character_common(ms, &ch); - if (errnum != 0) - return errnum; - obj->u.chr = ch; - ch = _memstream_getc(ms); - if (ch != '\'') - return EINVAL; - return 0; -} - -static int -_citrus_prop_read_bool(struct _memstream * __restrict ms, - _citrus_prop_object_t * __restrict obj) -{ - _DIAGASSERT(ms != NULL); - _DIAGASSERT(obj != NULL); - - _memstream_skip_ws(ms); - switch (_bcs_tolower(_memstream_getc(ms))) { - case 't': - if (_bcs_tolower(_memstream_getc(ms)) == 'r' && - _bcs_tolower(_memstream_getc(ms)) == 'u' && - _bcs_tolower(_memstream_getc(ms)) == 'e') { - obj->u.boolean = true; - return 0; - } - break; - case 'f': - if (_bcs_tolower(_memstream_getc(ms)) == 'a' && - _bcs_tolower(_memstream_getc(ms)) == 'l' && - _bcs_tolower(_memstream_getc(ms)) == 's' && - _bcs_tolower(_memstream_getc(ms)) == 'e') { - obj->u.boolean = false; - return 0; - } - } - return EINVAL; -} - -static int -_citrus_prop_read_str(struct _memstream * __restrict ms, - _citrus_prop_object_t * __restrict obj) -{ - int errnum, quot, ch; - char *s, *t; -#define _CITRUS_PROP_STR_BUFSIZ 512 - size_t n, m; - - _DIAGASSERT(ms != NULL); - _DIAGASSERT(obj != NULL); - - m = _CITRUS_PROP_STR_BUFSIZ; - s = malloc(m); - if (s == NULL) - return ENOMEM; - n = 0; - _memstream_skip_ws(ms); - quot = _memstream_getc(ms); - switch (quot) { - case EOF: - goto done; - case '\\': - _memstream_ungetc(ms, quot); - quot = EOF; - /*FALLTHROUGH*/ - case '\"': case '\'': - break; - default: - s[n] = quot; - ++n, --m; - quot = EOF; - } - for (;;) { - if (m < 1) { - m = _CITRUS_PROP_STR_BUFSIZ; - t = realloc(s, n + m); - if (t == NULL) { - free(s); - return ENOMEM; - } - s = t; - } - ch = _memstream_getc(ms); - if (quot == ch || (quot == EOF && - (ch == ';' || _bcs_isspace(ch)))) { -done: - s[n] = '\0'; - obj->u.str = (const char *)s; - return 0; - } - _memstream_ungetc(ms, ch); - errnum = _citrus_prop_read_character_common(ms, &ch); - if (errnum != 0) - return errnum; - s[n] = ch; - ++n, --m; - } - free(s); - return EINVAL; -#undef _CITRUS_PROP_STR_BUFSIZ -} - -typedef int (*_citrus_prop_read_type_t)(struct _memstream * __restrict, - _citrus_prop_object_t * __restrict); - -static const _citrus_prop_read_type_t readers[] = { - _citrus_prop_read_bool, - _citrus_prop_read_str, - _citrus_prop_read_character, - _citrus_prop_read_num, -}; - -static __inline int -_citrus_prop_read_symbol(struct _memstream * __restrict ms, - char * __restrict s, size_t n) -{ - int ch; - size_t m; - - _DIAGASSERT(ms != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(n > 0); - - for (m = 0; m < n; ++m) { - ch = _memstream_getc(ms); - if (ch != '_' && _bcs_isalnum(ch) == 0) - goto name_found; - s[m] = ch; - } - ch = _memstream_getc(ms); - if (ch == '_' || _bcs_isalnum(ch) != 0) - return EINVAL; - -name_found: - _memstream_ungetc(ms, ch); - s[m] = '\0'; - - return 0; -} - -static int -_citrus_prop_parse_element(struct _memstream * __restrict ms, - const _citrus_prop_hint_t * __restrict hints, - void * __restrict context) -{ - int ch, errnum; -#define _CITRUS_PROP_HINT_NAME_LEN_MAX 255 - char name[_CITRUS_PROP_HINT_NAME_LEN_MAX + 1]; - const _citrus_prop_hint_t *hint; - _citrus_prop_object_t ostart, oend; - - _DIAGASSERT(ms != NULL); - _DIAGASSERT(hints != NULL); - - errnum = _citrus_prop_read_symbol(ms, name, sizeof(name)); - if (errnum != 0) - return errnum; - for (hint = hints; hint->name != NULL; ++hint) { - if (_citrus_bcs_strcasecmp(name, hint->name) == 0) - goto hint_found; - } - return EINVAL; - -hint_found: - _memstream_skip_ws(ms); - ch = _memstream_getc(ms); - if (ch != '=' && ch != ':') - _memstream_ungetc(ms, ch); - do { - _citrus_prop_object_init(&ostart, hint->type); - _citrus_prop_object_init(&oend, hint->type); - errnum = (*readers[hint->type])(ms, &ostart); - if (errnum != 0) - return errnum; - _memstream_skip_ws(ms); - ch = _memstream_getc(ms); - switch (hint->type) { - case _CITRUS_PROP_BOOL: - case _CITRUS_PROP_STR: - break; - default: - if (ch != '-') - break; - errnum = (*readers[hint->type])(ms, &oend); - if (errnum != 0) - return errnum; - _memstream_skip_ws(ms); - ch = _memstream_getc(ms); - } -#define CALL0(_func_) \ -do { \ - _DIAGASSERT(hint->cb._func_.func != NULL); \ - errnum = (*hint->cb._func_.func)(context, \ - hint->name, ostart.u._func_); \ -} while (/*CONSTCOND*/0) -#define CALL1(_func_) \ -do { \ - _DIAGASSERT(hint->cb._func_.func != NULL); \ - errnum = (*hint->cb._func_.func)(context, \ - hint->name, ostart.u._func_, oend.u._func_);\ -} while (/*CONSTCOND*/0) - - switch (hint->type) { - - case _CITRUS_PROP_BOOL: - CALL0(boolean); - break; - - case _CITRUS_PROP_STR: - CALL0(str); - break; - - case _CITRUS_PROP_CHR: - CALL1(chr); - break; - - case _CITRUS_PROP_NUM: - CALL1(num); - break; - - default: - abort(); - /*NOTREACHED*/ - } -#undef CALL0 -#undef CALL1 - _citrus_prop_object_uninit(&ostart); - _citrus_prop_object_uninit(&oend); - if (errnum != 0) - return errnum; - } while (ch == ','); - if (ch != ';') - _memstream_ungetc(ms, ch); - return 0; -} - -int -_citrus_prop_parse_variable(const _citrus_prop_hint_t * __restrict hints, - void * __restrict context, const void *var, size_t lenvar) -{ - struct _memstream ms; - int errnum, ch; - - _DIAGASSERT(hints != NULL); - - _memstream_bind_ptr(&ms, __UNCONST(var), lenvar); - for (;;) { - _memstream_skip_ws(&ms); - ch = _memstream_getc(&ms); - if (ch == EOF || ch == '\0') - break; - _memstream_ungetc(&ms, ch); - errnum = _citrus_prop_parse_element(&ms, hints, context); - if (errnum != 0) - return errnum; - } - return 0; -} diff --git a/lib/libc/citrus/citrus_prop.h b/lib/libc/citrus/citrus_prop.h deleted file mode 100644 index 73a1ea88f..000000000 --- a/lib/libc/citrus/citrus_prop.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $NetBSD: citrus_prop.h,v 1.6 2014/06/24 22:24:18 spz Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_PROP_H_ -#define _CITRUS_PROP_H_ - -typedef enum { - _CITRUS_PROP_BOOL = 0, - _CITRUS_PROP_STR = 1, - _CITRUS_PROP_CHR = 2, - _CITRUS_PROP_NUM = 3, -} _citrus_prop_type_t; - -typedef struct _citrus_prop_hint_t _citrus_prop_hint_t; - -#define _CITRUS_PROP_CB0_T(_func_, _type_) \ -typedef int (*_citrus_prop_##_func_##_cb_func_t) \ - (void * __restrict, const char *, _type_); \ -typedef struct { \ - _citrus_prop_##_func_##_cb_func_t func; \ -} _citrus_prop_##_func_##_cb_t; -_CITRUS_PROP_CB0_T(boolean, int) -_CITRUS_PROP_CB0_T(str, const char *) -#undef _CITRUS_PROP_CB0_T - -#define _CITRUS_PROP_CB1_T(_func_, _type_) \ -typedef int (*_citrus_prop_##_func_##_cb_func_t) \ - (void * __restrict, const char *, _type_, _type_); \ -typedef struct { \ - _citrus_prop_##_func_##_cb_func_t func; \ -} _citrus_prop_##_func_##_cb_t; -_CITRUS_PROP_CB1_T(chr, int) -_CITRUS_PROP_CB1_T(num, uint64_t) -#undef _CITRUS_PROP_CB1_T - -struct _citrus_prop_hint_t { - const char *name; - _citrus_prop_type_t type; -#define _CITRUS_PROP_CB_T_OPS(_name_) \ - _citrus_prop_##_name_##_cb_t _name_ - union { - _CITRUS_PROP_CB_T_OPS(boolean); - _CITRUS_PROP_CB_T_OPS(str); - _CITRUS_PROP_CB_T_OPS(chr); - _CITRUS_PROP_CB_T_OPS(num); - } cb; -}; - -#define _CITRUS_PROP_HINT_BOOL(name, cb) \ - { name, _CITRUS_PROP_BOOL, { .boolean = { cb } } } -#define _CITRUS_PROP_HINT_STR(name, cb) \ - { name, _CITRUS_PROP_STR, { .str = { cb } } } -#define _CITRUS_PROP_HINT_CHR(name, cb) \ - { name, _CITRUS_PROP_CHR, { .chr = { cb } } } -#define _CITRUS_PROP_HINT_NUM(name, cb) \ - { name, _CITRUS_PROP_NUM, { .num = { cb } } } -#define _CITRUS_PROP_HINT_END \ - { .name = NULL } - -__BEGIN_DECLS -int _citrus_prop_parse_variable(const _citrus_prop_hint_t * __restrict, - void * __restrict, const void *, size_t); -__END_DECLS - -#endif /* !_CITRUS_PROP_H_ */ diff --git a/lib/libc/citrus/citrus_region.h b/lib/libc/citrus/citrus_region.h deleted file mode 100644 index 18c9db72b..000000000 --- a/lib/libc/citrus/citrus_region.h +++ /dev/null @@ -1,108 +0,0 @@ -/* $NetBSD: citrus_region.h,v 1.7 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_REGION_H_ -#define _CITRUS_REGION_H_ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -struct _citrus_region { -/* private: */ - void *r_head; - size_t r_size; -}; - -static __inline void -_citrus_region_init(struct _citrus_region *r, void *h, size_t sz) -{ - _DIAGASSERT(r); - r->r_head = h; - r->r_size = sz; -} - -static __inline void * -_citrus_region_head(const struct _citrus_region *r) -{ - return r->r_head; -} - -static __inline size_t -_citrus_region_size(const struct _citrus_region *r) -{ - return r->r_size; -} - -static __inline int -_citrus_region_check(const struct _citrus_region *r, size_t ofs, size_t sz) -{ - return r->r_size >= ofs + sz ? 0 : -1; -} - -static __inline void * -_citrus_region_offset(const struct _citrus_region *r, size_t pos) -{ - return (void *)((uint8_t *)r->r_head + pos); -} - -static __inline uint8_t -_citrus_region_peek8(const struct _citrus_region *r, size_t pos) -{ - return *(uint8_t *)_citrus_region_offset(r, pos); -} - -static __inline uint16_t -_citrus_region_peek16(const struct _citrus_region *r, size_t pos) -{ - uint16_t val; - memcpy(&val, _citrus_region_offset(r, pos), (size_t)2); - return val; -} - -static __inline uint32_t -_citrus_region_peek32(const struct _citrus_region *r, size_t pos) -{ - uint32_t val; - memcpy(&val, _citrus_region_offset(r, pos), (size_t)4); - return val; -} - -static __inline int -_citrus_region_get_subregion(struct _citrus_region *subr, - const struct _citrus_region *r, - size_t ofs, size_t sz) -{ - if (_citrus_region_check(r, ofs, sz)) - return -1; - _citrus_region_init(subr, _citrus_region_offset(r, ofs), sz); - return 0; -} - -#endif diff --git a/lib/libc/citrus/citrus_stdenc.c b/lib/libc/citrus/citrus_stdenc.c deleted file mode 100644 index 3dadbfbac..000000000 --- a/lib/libc/citrus/citrus_stdenc.c +++ /dev/null @@ -1,199 +0,0 @@ -/* $NetBSD: citrus_stdenc.c,v 1.4 2011/11/19 18:39:58 tnozaki Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_stdenc.c,v 1.4 2011/11/19 18:39:58 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_stdenc.h" -#include "citrus_none.h" - -struct _citrus_stdenc _citrus_stdenc_default = { - &_citrus_NONE_stdenc_ops, /* ce_ops */ - NULL, /* ce_closure */ - NULL, /* ce_module */ - &_citrus_NONE_stdenc_traits, /* ce_traits */ -}; - -#ifdef _I18N_DYNAMIC - -static int -/*ARGSUSED*/ -get_state_desc_default(struct _citrus_stdenc * __restrict ce, - void * __restrict ps, - int id, - struct _citrus_stdenc_state_desc * __restrict d) -{ - return EOPNOTSUPP; -} - -int -_citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict rce, - char const * __restrict encname, - const void * __restrict variable, size_t lenvar) -{ - int ret; - _citrus_module_t handle; - struct _citrus_stdenc *ce; - _citrus_stdenc_getops_t getops; - - _DIAGASSERT(encname != NULL); - _DIAGASSERT(!lenvar || variable!=NULL); - _DIAGASSERT(rce != NULL); - - if (!strcmp(encname, _CITRUS_DEFAULT_STDENC_NAME)) { - *rce = &_citrus_stdenc_default; - return (0); - } - ce = malloc(sizeof(*ce)); - if (ce==NULL) { - ret = errno; - goto bad; - } - ce->ce_ops = NULL; - ce->ce_closure = NULL; - ce->ce_module = NULL; - ce->ce_traits = NULL; - - ret = _citrus_load_module(&handle, encname); - if (ret) - goto bad; - - ce->ce_module = handle; - - getops = - (_citrus_stdenc_getops_t)_citrus_find_getops(ce->ce_module, - encname, "stdenc"); - if (getops == NULL) { - ret = EINVAL; - goto bad; - } - - ce->ce_ops = (struct _citrus_stdenc_ops *)malloc(sizeof(*ce->ce_ops)); - if (ce->ce_ops == NULL) { - ret = errno; - goto bad; - } - - ret = (*getops)(ce->ce_ops, sizeof(*ce->ce_ops), - _CITRUS_STDENC_ABI_VERSION); - if (ret) - goto bad; - - /* If return ABI version is not expected, should fixup it */ - if (ce->ce_ops->eo_abi_version < 0x00000002) { - ce->ce_ops->eo_get_state_desc = &get_state_desc_default; - } - - /* validation check */ - if (ce->ce_ops->eo_init == NULL || - ce->ce_ops->eo_uninit == NULL || - ce->ce_ops->eo_init_state == NULL || - ce->ce_ops->eo_mbtocs == NULL || - ce->ce_ops->eo_cstomb == NULL || - ce->ce_ops->eo_mbtowc == NULL || - ce->ce_ops->eo_wctomb == NULL || - ce->ce_ops->eo_get_state_desc == NULL) { - ret = EINVAL; - goto bad; - } - - /* allocate traits */ - ce->ce_traits = malloc(sizeof(*ce->ce_traits)); - if (ce->ce_traits == NULL) { - ret = errno; - goto bad; - } - /* init and get closure */ - ret = (*ce->ce_ops->eo_init)(ce, variable, lenvar, ce->ce_traits); - if (ret) - goto bad; - - *rce = ce; - - return (0); - -bad: - _citrus_stdenc_close(ce); - return (ret); -} - -void -_citrus_stdenc_close(struct _citrus_stdenc *ce) -{ - - _DIAGASSERT(ce != NULL); - - if (ce == &_citrus_stdenc_default) - return; - - if (ce->ce_module) { - if (ce->ce_ops) { - if (ce->ce_closure && ce->ce_ops->eo_uninit) - (*ce->ce_ops->eo_uninit)(ce); - free(ce->ce_ops); - } - free(ce->ce_traits); - _citrus_unload_module(ce->ce_module); - } - free(ce); -} - -#else -/* !_I18N_DYNAMIC */ - -int -/*ARGSUSED*/ -_citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict rce, - char const * __restrict encname, - const void * __restrict variable, size_t lenvar) -{ - if (!strcmp(encname, _CITRUS_DEFAULT_STDENC_NAME)) { - *rce = &_citrus_stdenc_default; - return (0); - } - return (EINVAL); -} - -void -/*ARGSUSED*/ -_citrus_stdenc_close(struct _citrus_stdenc *ce) -{ -} - -#endif diff --git a/lib/libc/citrus/citrus_stdenc.h b/lib/libc/citrus/citrus_stdenc.h deleted file mode 100644 index ce198db68..000000000 --- a/lib/libc/citrus/citrus_stdenc.h +++ /dev/null @@ -1,145 +0,0 @@ -/* $NetBSD: citrus_stdenc.h,v 1.4 2005/10/29 18:02:04 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_STDENC_H_ -#define _CITRUS_STDENC_H_ - -struct _citrus_stdenc; -struct _citrus_stdenc_ops; -struct _citrus_stdenc_traits; - -#define _CITRUS_STDENC_SDID_GENERIC 0 -struct _citrus_stdenc_state_desc -{ - union { - struct { - int state; -#define _CITRUS_STDENC_SDGEN_UNKNOWN 0 -#define _CITRUS_STDENC_SDGEN_INITIAL 1 -#define _CITRUS_STDENC_SDGEN_STABLE 2 -#define _CITRUS_STDENC_SDGEN_INCOMPLETE_CHAR 3 -#define _CITRUS_STDENC_SDGEN_INCOMPLETE_SHIFT 4 - } generic; - } u; -}; - -#include "citrus_stdenc_local.h" - -__BEGIN_DECLS -int _citrus_stdenc_open(struct _citrus_stdenc * __restrict * __restrict, - char const * __restrict, - const void * __restrict, size_t); -void _citrus_stdenc_close(struct _citrus_stdenc *); -__END_DECLS - -static __inline int -_citrus_stdenc_init_state(struct _citrus_stdenc * __restrict ce, - void * __restrict ps) -{ - _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_init_state); - return (*ce->ce_ops->eo_init_state)(ce, ps); -} - -static __inline int -_citrus_stdenc_mbtocs(struct _citrus_stdenc * __restrict ce, - _citrus_csid_t * __restrict csid, - _citrus_index_t * __restrict idx, - const char ** __restrict s, size_t n, - void * __restrict ps, size_t * __restrict nresult) -{ - _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_mbtocs); - return (*ce->ce_ops->eo_mbtocs)(ce, csid, idx, s, n, ps, nresult); -} - -static __inline int -_citrus_stdenc_cstomb(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, - _citrus_csid_t csid, _citrus_index_t idx, - void * __restrict ps, size_t * __restrict nresult) -{ - _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_cstomb); - return (*ce->ce_ops->eo_cstomb)(ce, s, n, csid, idx, ps, nresult); -} - -static __inline int -_citrus_stdenc_mbtowc(struct _citrus_stdenc * __restrict ce, - _citrus_wc_t * __restrict wc, - const char ** __restrict s, size_t n, - void * __restrict ps, size_t * __restrict nresult) -{ - _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_mbtocs); - return (*ce->ce_ops->eo_mbtowc)(ce, wc, s, n, ps, nresult); -} - -static __inline int -_citrus_stdenc_wctomb(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, _citrus_wc_t wc, - void * __restrict ps, size_t * __restrict nresult) -{ - _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_cstomb); - return (*ce->ce_ops->eo_wctomb)(ce, s, n, wc, ps, nresult); -} - -static __inline int -_citrus_stdenc_put_state_reset(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, - void * __restrict ps, - size_t * __restrict nresult) -{ - _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_put_state_reset); - return (*ce->ce_ops->eo_put_state_reset)(ce, s, n, ps, nresult); -} - -static __inline size_t -_citrus_stdenc_get_state_size(struct _citrus_stdenc *ce) -{ - _DIAGASSERT(ce && ce->ce_traits); - return ce->ce_traits->et_state_size; -} - -static __inline size_t -_citrus_stdenc_get_mb_cur_max(struct _citrus_stdenc *ce) -{ - _DIAGASSERT(ce && ce->ce_traits); - return ce->ce_traits->et_mb_cur_max; -} - -static __inline int -_citrus_stdenc_get_state_desc(struct _citrus_stdenc * __restrict ce, - void * __restrict ps, - int id, - struct _citrus_stdenc_state_desc * __restrict d) -{ - - _DIAGASSERT(ce && ce->ce_ops && ce->ce_ops->eo_get_state_desc); - - return (*ce->ce_ops->eo_get_state_desc)(ce, ps, id, d); -} - -#endif diff --git a/lib/libc/citrus/citrus_stdenc_local.h b/lib/libc/citrus/citrus_stdenc_local.h deleted file mode 100644 index bac89c624..000000000 --- a/lib/libc/citrus/citrus_stdenc_local.h +++ /dev/null @@ -1,153 +0,0 @@ -/* $NetBSD: citrus_stdenc_local.h,v 1.4 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - * - */ - -#ifndef _CITRUS_STDENC_LOCAL_H_ -#define _CITRUS_STDENC_LOCAL_H_ - -#define _CITRUS_STDENC_GETOPS_FUNC_BASE(n) \ -int n(struct _citrus_stdenc_ops *, size_t, uint32_t) -#define _CITRUS_STDENC_GETOPS_FUNC(_e_) \ -_CITRUS_STDENC_GETOPS_FUNC_BASE(_citrus_##_e_##_stdenc_getops) -typedef _CITRUS_STDENC_GETOPS_FUNC_BASE((*_citrus_stdenc_getops_t)); - - -#define _CITRUS_STDENC_DECLS(_e_) \ -static int _citrus_##_e_##_stdenc_init \ - (struct _citrus_stdenc * __restrict, const void * __restrict, \ - size_t, struct _citrus_stdenc_traits * __restrict); \ -static void _citrus_##_e_##_stdenc_uninit(struct _citrus_stdenc *); \ -static int _citrus_##_e_##_stdenc_init_state \ - (struct _citrus_stdenc * __restrict, void * __restrict); \ -static int _citrus_##_e_##_stdenc_mbtocs \ - (struct _citrus_stdenc * __restrict, \ - _citrus_csid_t * __restrict, _citrus_index_t * __restrict, \ - const char ** __restrict, size_t, \ - void * __restrict, size_t * __restrict); \ -static int _citrus_##_e_##_stdenc_cstomb \ - (struct _citrus_stdenc * __restrict, char * __restrict, \ - size_t, _citrus_csid_t, _citrus_index_t, \ - void * __restrict, size_t * __restrict); \ -static int _citrus_##_e_##_stdenc_mbtowc \ - (struct _citrus_stdenc * __restrict, \ - _citrus_wc_t * __restrict, \ - const char ** __restrict, size_t, \ - void * __restrict, size_t * __restrict); \ -static int _citrus_##_e_##_stdenc_wctomb \ - (struct _citrus_stdenc * __restrict, char * __restrict, size_t, \ - _citrus_wc_t, void * __restrict, size_t * __restrict); \ -static int _citrus_##_e_##_stdenc_put_state_reset \ - (struct _citrus_stdenc * __restrict, char * __restrict, size_t, \ - void * __restrict, size_t * __restrict); \ -static int _citrus_##_e_##_stdenc_get_state_desc \ - (struct _citrus_stdenc * __restrict, void * __restrict, int, \ - struct _citrus_stdenc_state_desc * __restrict) - -#define _CITRUS_STDENC_DEF_OPS(_e_) \ -struct _citrus_stdenc_ops _citrus_##_e_##_stdenc_ops = { \ - /* eo_abi_version */ _CITRUS_STDENC_ABI_VERSION, \ - /* eo_init */ &_citrus_##_e_##_stdenc_init, \ - /* eo_uninit */ &_citrus_##_e_##_stdenc_uninit, \ - /* eo_init_state */ &_citrus_##_e_##_stdenc_init_state, \ - /* eo_mbtocs */ &_citrus_##_e_##_stdenc_mbtocs, \ - /* eo_cstomb */ &_citrus_##_e_##_stdenc_cstomb, \ - /* eo_mbtowc */ &_citrus_##_e_##_stdenc_mbtowc, \ - /* eo_wctomb */ &_citrus_##_e_##_stdenc_wctomb, \ - /* eo_put_state_reset */&_citrus_##_e_##_stdenc_put_state_reset,\ - /* eo_get_state_desc */ &_citrus_##_e_##_stdenc_get_state_desc \ -} - -typedef int (*_citrus_stdenc_init_t) - (struct _citrus_stdenc * __reatrict, const void * __restrict , size_t, - struct _citrus_stdenc_traits * __restrict); -typedef void (*_citrus_stdenc_uninit_t)(struct _citrus_stdenc * __restrict); -typedef int (*_citrus_stdenc_init_state_t) - (struct _citrus_stdenc * __restrict, void * __restrict); -typedef int (*_citrus_stdenc_mbtocs_t) - (struct _citrus_stdenc * __restrict, - _citrus_csid_t * __restrict, _citrus_index_t * __restrict, - const char ** __restrict, size_t, - void * __restrict, size_t * __restrict); -typedef int (*_citrus_stdenc_cstomb_t) - (struct _citrus_stdenc *__restrict, char * __restrict, size_t, - _citrus_csid_t, _citrus_index_t, void * __restrict, - size_t * __restrict); -typedef int (*_citrus_stdenc_mbtowc_t) - (struct _citrus_stdenc * __restrict, - _citrus_wc_t * __restrict, - const char ** __restrict, size_t, - void * __restrict, size_t * __restrict); -typedef int (*_citrus_stdenc_wctomb_t) - (struct _citrus_stdenc *__restrict, char * __restrict, size_t, - _citrus_wc_t, void * __restrict, size_t * __restrict); -typedef int (*_citrus_stdenc_put_state_reset_t) - (struct _citrus_stdenc *__restrict, char * __restrict, size_t, - void * __restrict, size_t * __restrict); -typedef int (*_citrus_stdenc_get_state_desc_t) - (struct _citrus_stdenc * __restrict, void * __restrict, int, - struct _citrus_stdenc_state_desc * __restrict); -/* - * ABI version change log - * 0x00000001 - * initial version - */ -#define _CITRUS_STDENC_ABI_VERSION 0x00000002 -struct _citrus_stdenc_ops { - uint32_t eo_abi_version; - /* version 0x00000001 */ - _citrus_stdenc_init_t eo_init; - _citrus_stdenc_uninit_t eo_uninit; - _citrus_stdenc_init_state_t eo_init_state; - _citrus_stdenc_mbtocs_t eo_mbtocs; - _citrus_stdenc_cstomb_t eo_cstomb; - _citrus_stdenc_mbtowc_t eo_mbtowc; - _citrus_stdenc_wctomb_t eo_wctomb; - _citrus_stdenc_put_state_reset_t eo_put_state_reset; - /* version 0x00000002 */ - _citrus_stdenc_get_state_desc_t eo_get_state_desc; -}; - -struct _citrus_stdenc_traits { - /* version 0x00000001 */ - size_t et_state_size; - size_t et_mb_cur_max; -}; - -struct _citrus_stdenc { - /* public */ - /* version 0x00000001 */ - struct _citrus_stdenc_ops *ce_ops; - void *ce_closure; - /* private */ - _citrus_module_t ce_module; - struct _citrus_stdenc_traits *ce_traits; -}; - -#define _CITRUS_DEFAULT_STDENC_NAME "NONE" - -#endif diff --git a/lib/libc/citrus/citrus_stdenc_template.h b/lib/libc/citrus/citrus_stdenc_template.h deleted file mode 100644 index 54088cd54..000000000 --- a/lib/libc/citrus/citrus_stdenc_template.h +++ /dev/null @@ -1,206 +0,0 @@ -/* $NetBSD: citrus_stdenc_template.h,v 1.4 2008/02/09 14:56:20 junyoung Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -/* - * CAUTION: THIS IS NOT STANDALONE FILE - * - * function templates of iconv standard encoding handler for each encodings. - * - */ - -/* - * macros - */ - -#undef _TO_EI -#undef _CE_TO_EI -#undef _TO_STATE -#define _TO_EI(_cl_) ((_ENCODING_INFO*)(_cl_)) -#define _CE_TO_EI(_ce_) (_TO_EI((_ce_)->ce_closure)) -#define _TO_STATE(_ps_) ((_ENCODING_STATE*)(_ps_)) - -/* ---------------------------------------------------------------------- - * templates for public functions - */ - -int -_FUNCNAME(stdenc_getops)(struct _citrus_stdenc_ops *ops, size_t lenops, - uint32_t expected_version) -{ - if (expected_version<_CITRUS_STDENC_ABI_VERSION || lenops 0) { - ei = calloc(1, sizeof(_ENCODING_INFO)); - if (ei == NULL) { - return errno; - } - } - - ret = _FUNCNAME(encoding_module_init)(ei, var, lenvar); - if (ret) { - free((void *)ei); - return ret; - } - - ce->ce_closure = ei; - et->et_state_size = sizeof(_ENCODING_STATE); - et->et_mb_cur_max = _ENCODING_MB_CUR_MAX(_CE_TO_EI(ce)); - - return 0; -} - -static void -_FUNCNAME(stdenc_uninit)(struct _citrus_stdenc * __restrict ce) -{ - if (ce) { - _FUNCNAME(encoding_module_uninit)(_CE_TO_EI(ce)); - free(ce->ce_closure); - } -} - -static int -_FUNCNAME(stdenc_init_state)(struct _citrus_stdenc * __restrict ce, - void * __restrict ps) -{ - _FUNCNAME(init_state)(_CE_TO_EI(ce), _TO_STATE(ps)); - - return 0; -} - -static int -_FUNCNAME(stdenc_mbtocs)(struct _citrus_stdenc * __restrict ce, - _citrus_csid_t * __restrict csid, - _citrus_index_t * __restrict idx, - const char ** __restrict s, size_t n, - void * __restrict ps, size_t * __restrict nresult) -{ - int ret; - wchar_t wc; - - _DIAGASSERT(nresult != NULL); - - ret = _FUNCNAME(mbrtowc_priv)(_CE_TO_EI(ce), &wc, s, n, - _TO_STATE(ps), nresult); - - if (!ret && *nresult != (size_t)-2) - _FUNCNAME(stdenc_wctocs)(_CE_TO_EI(ce), csid, idx, wc); - - return ret; -} - -static int -_FUNCNAME(stdenc_cstomb)(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, - _citrus_csid_t csid, _citrus_index_t idx, - void * __restrict ps, size_t * __restrict nresult) -{ - int ret; - wchar_t wc; - - _DIAGASSERT(nresult != NULL); - - wc = 0; - - if (csid != _CITRUS_CSID_INVALID) { - ret = _FUNCNAME(stdenc_cstowc)(_CE_TO_EI(ce), &wc, csid, idx); - if (ret) - return ret; - } - - return _FUNCNAME(wcrtomb_priv)(_CE_TO_EI(ce), s, n, wc, _TO_STATE(ps), - nresult); -} - -static int -_FUNCNAME(stdenc_mbtowc)(struct _citrus_stdenc * __restrict ce, - _citrus_wc_t * __restrict wc, - const char ** __restrict s, size_t n, - void * __restrict ps, size_t * __restrict nresult) -{ - return _FUNCNAME(mbrtowc_priv)(_CE_TO_EI(ce), wc, s, n, - _TO_STATE(ps), nresult); -} - -static int -_FUNCNAME(stdenc_wctomb)(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, _citrus_wc_t wc, - void * __restrict ps, size_t * __restrict nresult) -{ - return _FUNCNAME(wcrtomb_priv)(_CE_TO_EI(ce), s, n, wc, _TO_STATE(ps), - nresult); -} - -static int -_FUNCNAME(stdenc_put_state_reset)(struct _citrus_stdenc * __restrict ce, - char * __restrict s, size_t n, - void * __restrict ps, - size_t * __restrict nresult) -{ -#if _ENCODING_IS_STATE_DEPENDENT - return _FUNCNAME(put_state_reset)(_CE_TO_EI(ce), s, n, _TO_STATE(ps), - nresult); -#else - *nresult = 0; - return 0; -#endif -} - -static int -_FUNCNAME(stdenc_get_state_desc)(struct _citrus_stdenc * __restrict ce, - void * __restrict ps, - int id, - struct _citrus_stdenc_state_desc * __restrict d) -{ - int ret; - - switch (id) { - case _STDENC_SDID_GENERIC: - ret = _FUNCNAME(stdenc_get_state_desc_generic)( - _CE_TO_EI(ce), _TO_STATE(ps), &d->u.generic.state); - break; - default: - ret = EOPNOTSUPP; - } - - return ret; -} diff --git a/lib/libc/citrus/citrus_types.h b/lib/libc/citrus/citrus_types.h deleted file mode 100644 index 6692fd3dd..000000000 --- a/lib/libc/citrus/citrus_types.h +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: citrus_types.h,v 1.3 2003/10/27 00:12:42 lukem Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_TYPES_H_ -#define _CITRUS_TYPES_H_ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -typedef uint32_t _citrus_wc_t; -typedef uint32_t _citrus_index_t; -typedef uint32_t _citrus_csid_t; -#define _CITRUS_CSID_INVALID ((_citrus_csid_t)-1) - -#endif diff --git a/lib/libc/citrus/modules/citrus_big5.c b/lib/libc/citrus/modules/citrus_big5.c deleted file mode 100644 index 1f76584ff..000000000 --- a/lib/libc/citrus/modules/citrus_big5.c +++ /dev/null @@ -1,514 +0,0 @@ -/* $NetBSD: citrus_big5.c,v 1.15 2014/06/24 22:24:18 spz Exp $ */ - -/*- - * Copyright (c)2002, 2006 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_big5.c,v 1.15 2014/06/24 22:24:18 spz Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_big5.h" - -#include "citrus_prop.h" - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - char ch[2]; - int chlen; -} _BIG5State; - -typedef struct _BIG5Exclude { - TAILQ_ENTRY(_BIG5Exclude) entry; - wint_t start, end; -} _BIG5Exclude; - -typedef TAILQ_HEAD(_BIG5ExcludeList, _BIG5Exclude) _BIG5ExcludeList; - -typedef struct { - int cell[0x100]; - _BIG5ExcludeList excludes; -} _BIG5EncodingInfo; - -typedef struct { - _BIG5EncodingInfo ei; - struct { - /* for future multi-locale facility */ - _BIG5State s_mblen; - _BIG5State s_mbrlen; - _BIG5State s_mbrtowc; - _BIG5State s_mbtowc; - _BIG5State s_mbsrtowcs; - _BIG5State s_mbsnrtowcs; - _BIG5State s_wcrtomb; - _BIG5State s_wcsrtombs; - _BIG5State s_wcsnrtombs; - _BIG5State s_wctomb; - } states; -} _BIG5CTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_BIG5_##m -#define _ENCODING_INFO _BIG5EncodingInfo -#define _CTYPE_INFO _BIG5CTypeInfo -#define _ENCODING_STATE _BIG5State -#define _ENCODING_MB_CUR_MAX(_ei_) 2 -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - - -static __inline void -/*ARGSUSED*/ -_citrus_BIG5_init_state(_BIG5EncodingInfo * __restrict ei, - _BIG5State * __restrict s) -{ - memset(s, 0, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_BIG5_pack_state(_BIG5EncodingInfo * __restrict ei, - void * __restrict pspriv, - const _BIG5State * __restrict s) -{ - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_BIG5_unpack_state(_BIG5EncodingInfo * __restrict ei, - _BIG5State * __restrict s, - const void * __restrict pspriv) -{ - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static __inline int -_citrus_BIG5_check(_BIG5EncodingInfo *ei, u_int c) -{ - _DIAGASSERT(ei != NULL); - - return (ei->cell[c & 0xFF] & 0x1) ? 2 : 1; -} - -static __inline int -_citrus_BIG5_check2(_BIG5EncodingInfo *ei, u_int c) -{ - _DIAGASSERT(ei != NULL); - - return (ei->cell[c & 0xFF] & 0x2) ? 1 : 0; -} - -static __inline int -_citrus_BIG5_check_excludes(_BIG5EncodingInfo *ei, wint_t c) -{ - _BIG5Exclude *exclude; - - _DIAGASSERT(ei != NULL); - - TAILQ_FOREACH(exclude, &ei->excludes, entry) { - if (c >= exclude->start && c <= exclude->end) - return EILSEQ; - } - return 0; -} - -static int -_citrus_BIG5_fill_rowcol(void * __restrict ctx, const char * __restrict s, - uint64_t start, uint64_t end) -{ - _BIG5EncodingInfo *ei; - int i; - uint64_t n; - - _DIAGASSERT(ctx != NULL); - - if (start > 0xFF || end > 0xFF) - return EINVAL; - ei = (_BIG5EncodingInfo *)ctx; - i = strcmp("row", s) ? 1 : 0; - i = 1 << i; - for (n = start; n <= end; ++n) - ei->cell[n & 0xFF] |= i; - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_BIG5_fill_excludes(void * __restrict ctx, const char * __restrict s, - uint64_t start, uint64_t end) -{ - _BIG5EncodingInfo *ei; - _BIG5Exclude *exclude; - - _DIAGASSERT(ctx != NULL); - - if (start > 0xFFFF || end > 0xFFFF) - return EINVAL; - ei = (_BIG5EncodingInfo *)ctx; - exclude = TAILQ_LAST(&ei->excludes, _BIG5ExcludeList); - if (exclude != NULL && (wint_t)start <= exclude->end) - return EINVAL; - exclude = (void *)malloc(sizeof(*exclude)); - if (exclude == NULL) - return ENOMEM; - exclude->start = (wint_t)start; - exclude->end = (wint_t)end; - TAILQ_INSERT_TAIL(&ei->excludes, exclude, entry); - - return 0; -} - -static const _citrus_prop_hint_t root_hints[] = { - _CITRUS_PROP_HINT_NUM("row", &_citrus_BIG5_fill_rowcol), - _CITRUS_PROP_HINT_NUM("col", &_citrus_BIG5_fill_rowcol), - _CITRUS_PROP_HINT_NUM("excludes", &_citrus_BIG5_fill_excludes), - _CITRUS_PROP_HINT_END -}; - -static void -/*ARGSUSED*/ -_citrus_BIG5_encoding_module_uninit(_BIG5EncodingInfo *ei) -{ - _BIG5Exclude *exclude; - - _DIAGASSERT(ei != NULL); - - while ((exclude = TAILQ_FIRST(&ei->excludes)) != NULL) { - TAILQ_REMOVE(&ei->excludes, exclude, entry); - free(exclude); - } -} - -static int -/*ARGSUSED*/ -_citrus_BIG5_encoding_module_init(_BIG5EncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - int err; - const char *s; - - _DIAGASSERT(ei != NULL); - - memset((void *)ei, 0, sizeof(*ei)); - TAILQ_INIT(&ei->excludes); - - if (lenvar > 0 && var != NULL) { - s = _bcs_skip_ws_len((const char *)var, &lenvar); - if (lenvar > 0 && *s != '\0') { - err = _citrus_prop_parse_variable( - root_hints, (void *)ei, s, lenvar); - if (err == 0) - return 0; - - _citrus_BIG5_encoding_module_uninit(ei); - memset((void *)ei, 0, sizeof(*ei)); - TAILQ_INIT(&ei->excludes); - } - } - - /* fallback Big5-1984, for backward compatibility. */ - _citrus_BIG5_fill_rowcol(ei, "row", 0xA1, 0xFE); - _citrus_BIG5_fill_rowcol(ei, "col", 0x40, 0x7E); - _citrus_BIG5_fill_rowcol(ei, "col", 0xA1, 0xFE); - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_BIG5_mbrtowc_priv(_BIG5EncodingInfo * __restrict ei, - wchar_t * __restrict pwc, - const char ** __restrict s, size_t n, - _BIG5State * __restrict psenc, - size_t * __restrict nresult) -{ - wchar_t wchar; - int c; - int chlenbak; - const char *s0; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL && *s != NULL); - - s0 = *s; - - if (s0 == NULL) { - _citrus_BIG5_init_state(ei, psenc); - *nresult = 0; - return (0); - } - - chlenbak = psenc->chlen; - - /* make sure we have the first byte in the buffer */ - switch (psenc->chlen) { - case 0: - if (n < 1) - goto restart; - psenc->ch[0] = *s0++; - psenc->chlen = 1; - n--; - break; - case 1: - break; - default: - /* illegal state */ - goto ilseq; - } - - c = _citrus_BIG5_check(ei, psenc->ch[0] & 0xff); - if (c == 0) - goto ilseq; - while (psenc->chlen < c) { - if (n < 1) { - goto restart; - } - psenc->ch[psenc->chlen] = *s0++; - psenc->chlen++; - n--; - } - - switch (c) { - case 1: - wchar = psenc->ch[0] & 0xff; - break; - case 2: - if (!_citrus_BIG5_check2(ei, psenc->ch[1] & 0xff)) - goto ilseq; - wchar = ((psenc->ch[0] & 0xff) << 8) | (psenc->ch[1] & 0xff); - break; - default: - /* illegal state */ - goto ilseq; - } - - if (_citrus_BIG5_check_excludes(ei, (wint_t)wchar) != 0) - goto ilseq; - - *s = s0; - psenc->chlen = 0; - if (pwc) - *pwc = wchar; - if (!wchar) - *nresult = 0; - else - *nresult = c - chlenbak; - - return (0); - -ilseq: - psenc->chlen = 0; - *nresult = (size_t)-1; - return (EILSEQ); - -restart: - *s = s0; - *nresult = (size_t)-2; - return (0); -} - -static int -/*ARGSUSED*/ -_citrus_BIG5_wcrtomb_priv(_BIG5EncodingInfo * __restrict ei, - char * __restrict s, - size_t n, wchar_t wc, _BIG5State * __restrict psenc, - size_t * __restrict nresult) -{ - size_t l, ret; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(nresult != 0); - _DIAGASSERT(s != NULL); - - /* check invalid sequence */ - if (wc & ~0xffff || - _citrus_BIG5_check_excludes(ei, (wint_t)wc) != 0) { - ret = EILSEQ; - goto err; - } - - if (wc & 0x8000) { - if (_citrus_BIG5_check(ei, (wc >> 8) & 0xff) != 2 || - !_citrus_BIG5_check2(ei, wc & 0xff)) { - ret = EILSEQ; - goto err; - } - l = 2; - } else { - if (wc & ~0xff || !_citrus_BIG5_check(ei, wc & 0xff)) { - ret = EILSEQ; - goto err; - } - l = 1; - } - - if (n < l) { - /* bound check failure */ - ret = E2BIG; - goto err; - } - - if (l == 2) { - s[0] = (wc >> 8) & 0xff; - s[1] = wc & 0xff; - } else - s[0] = wc & 0xff; - - *nresult = l; - - return 0; - -err: - *nresult = (size_t)-1; - return ret; -} - -static __inline int -/*ARGSUSED*/ -_citrus_BIG5_stdenc_wctocs(_BIG5EncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, wchar_t wc) -{ - - _DIAGASSERT(csid != NULL && idx != NULL); - - *csid = (wc < 0x100) ? 0 : 1; - *idx = (_index_t)wc; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_BIG5_stdenc_cstowc(_BIG5EncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - _DIAGASSERT(wc != NULL); - - switch (csid) { - case 0: - case 1: - *wc = (wchar_t)idx; - break; - default: - return EILSEQ; - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_BIG5_stdenc_get_state_desc_generic(_BIG5EncodingInfo * __restrict ei, - _BIG5State * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(BIG5); -_CITRUS_CTYPE_DEF_OPS(BIG5); - -#include "citrus_ctype_template.h" - - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(BIG5); -_CITRUS_STDENC_DEF_OPS(BIG5); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_big5.h b/lib/libc/citrus/modules/citrus_big5.h deleted file mode 100644 index 60a0f5990..000000000 --- a/lib/libc/citrus/modules/citrus_big5.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_big5.h,v 1.2 2003/06/25 09:51:41 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_BIG5_H_ -#define _CITRUS_BIG5_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(BIG5); -_CITRUS_STDENC_GETOPS_FUNC(BIG5); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_dechanyu.c b/lib/libc/citrus/modules/citrus_dechanyu.c deleted file mode 100644 index 0db33eb45..000000000 --- a/lib/libc/citrus/modules/citrus_dechanyu.c +++ /dev/null @@ -1,443 +0,0 @@ -/* $NetBSD: citrus_dechanyu.c,v 1.5 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2007 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_dechanyu.c,v 1.5 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_dechanyu.h" - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - int chlen; - char ch[4]; -} _DECHanyuState; - -typedef struct { - int dummy; -} _DECHanyuEncodingInfo; - -typedef struct { - _DECHanyuEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _DECHanyuState s_mblen; - _DECHanyuState s_mbrlen; - _DECHanyuState s_mbrtowc; - _DECHanyuState s_mbtowc; - _DECHanyuState s_mbsrtowcs; - _DECHanyuState s_mbsnrtowcs; - _DECHanyuState s_wcrtomb; - _DECHanyuState s_wcsrtombs; - _DECHanyuState s_wcsnrtombs; - _DECHanyuState s_wctomb; - } states; -} _DECHanyuCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.__CONCAT(s_,_func_) - -#define _FUNCNAME(m) __CONCAT(_citrus_DECHanyu_,m) -#define _ENCODING_INFO _DECHanyuEncodingInfo -#define _CTYPE_INFO _DECHanyuCTypeInfo -#define _ENCODING_STATE _DECHanyuState -#define _ENCODING_MB_CUR_MAX(_ei_) 4 -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - -static __inline void -/*ARGSUSED*/ -_citrus_DECHanyu_init_state(_DECHanyuEncodingInfo * __restrict ei, - _DECHanyuState * __restrict psenc) -{ - /* ei may be null */ - _DIAGASSERT(psenc != NULL); - - psenc->chlen = 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_DECHanyu_pack_state(_DECHanyuEncodingInfo * __restrict ei, - void * __restrict pspriv, - const _DECHanyuState * __restrict psenc) -{ - /* ei may be null */ - _DIAGASSERT(pspriv != NULL); - _DIAGASSERT(psenc != NULL); - - memcpy(pspriv, (const void *)psenc, sizeof(*psenc)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_DECHanyu_unpack_state(_DECHanyuEncodingInfo * __restrict ei, - _DECHanyuState * __restrict psenc, - const void * __restrict pspriv) -{ - /* ei may be null */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(pspriv != NULL); - - memcpy((void *)psenc, pspriv, sizeof(*psenc)); -} - -static void -/*ARGSUSED*/ -_citrus_DECHanyu_encoding_module_uninit(_DECHanyuEncodingInfo *ei) -{ - /* ei may be null */ -} - -static int -/*ARGSUSED*/ -_citrus_DECHanyu_encoding_module_init(_DECHanyuEncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - /* ei may be null */ - return 0; -} - -static __inline int -is_singlebyte(int c) -{ - return c <= 0x7F; -} - -static __inline int -is_leadbyte(int c) -{ - return c >= 0xA1 && c <= 0xFE; -} - -static __inline int -is_trailbyte(int c) -{ - c &= ~0x80; - return c >= 0x21 && c <= 0x7E; -} - -static __inline int -is_hanyu1(int c) -{ - return c == 0xC2; -} - -static __inline int -is_hanyu2(int c) -{ - return c == 0xCB; -} - -#define HANYUBIT 0xC2CB0000 - -static __inline int -is_94charset(int c) -{ - return c >= 0x21 && c <= 0x7E; -} - -static int -/*ARGSUSED*/ -_citrus_DECHanyu_mbrtowc_priv(_DECHanyuEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, const char ** __restrict s, size_t n, - _DECHanyuState * __restrict psenc, size_t * __restrict nresult) -{ - const char *s0; - int ch; - wchar_t wc; - - /* ei may be unused */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (*s == NULL) { - _citrus_DECHanyu_init_state(ei, psenc); - *nresult = _ENCODING_IS_STATE_DEPENDENT; - return 0; - } - s0 = *s; - - wc = (wchar_t)0; - switch (psenc->chlen) { - case 0: - if (n-- < 1) - goto restart; - ch = *s0++ & 0xFF; - if (is_singlebyte(ch) != 0) { - if (pwc != NULL) - *pwc = (wchar_t)ch; - *nresult = (size_t)((ch == 0) ? 0 : 1); - *s = s0; - return 0; - } - if (is_leadbyte(ch) == 0) - goto ilseq; - psenc->ch[psenc->chlen++] = ch; - break; - case 1: - ch = psenc->ch[0] & 0xFF; - if (is_leadbyte(ch) == 0) - return EINVAL; - break; - case 2: case 3: - ch = psenc->ch[0] & 0xFF; - if (is_hanyu1(ch) != 0) { - ch = psenc->ch[1] & 0xFF; - if (is_hanyu2(ch) != 0) { - wc |= (wchar_t)HANYUBIT; - break; - } - } - /*FALLTHROUGH*/ - default: - return EINVAL; - } - - switch (psenc->chlen) { - case 1: - if (is_hanyu1(ch) != 0) { - if (n-- < 1) - goto restart; - ch = *s0++ & 0xFF; - if (is_hanyu2(ch) == 0) - goto ilseq; - psenc->ch[psenc->chlen++] = ch; - wc |= (wchar_t)HANYUBIT; - if (n-- < 1) - goto restart; - ch = *s0++ & 0xFF; - if (is_leadbyte(ch) == 0) - goto ilseq; - psenc->ch[psenc->chlen++] = ch; - } - break; - case 2: - if (n-- < 1) - goto restart; - ch = *s0++ & 0xFF; - if (is_leadbyte(ch) == 0) - goto ilseq; - psenc->ch[psenc->chlen++] = ch; - break; - case 3: - ch = psenc->ch[2] & 0xFF; - if (is_leadbyte(ch) == 0) - return EINVAL; - } - if (n-- < 1) - goto restart; - wc |= (wchar_t)(ch << 8); - ch = *s0++ & 0xFF; - if (is_trailbyte(ch) == 0) - goto ilseq; - wc |= (wchar_t)ch; - if (pwc != NULL) - *pwc = wc; - *nresult = (size_t)(s0 - *s); - *s = s0; - psenc->chlen = 0; - - return 0; - -restart: - *nresult = (size_t)-2; - *s = s0; - return 0; - -ilseq: - *nresult = (size_t)-1; - return EILSEQ; -} - -static int -/*ARGSUSED*/ -_citrus_DECHanyu_wcrtomb_priv(_DECHanyuEncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _DECHanyuState * __restrict psenc, size_t * __restrict nresult) -{ - int ch; - - /* ei may be unused */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (psenc->chlen != 0) - return EINVAL; - - /* XXX: assume wchar_t as int */ - if ((uint32_t)wc <= 0x7F) { - ch = wc & 0xFF; - } else { - if ((uint32_t)wc > 0xFFFF) { - if ((wc & ~0xFFFF) != HANYUBIT) - goto ilseq; - psenc->ch[psenc->chlen++] = (wc >> 24) & 0xFF; - psenc->ch[psenc->chlen++] = (wc >> 16) & 0xFF; - wc &= 0xFFFF; - } - ch = (wc >> 8) & 0xFF; - if (!is_leadbyte(ch)) - goto ilseq; - psenc->ch[psenc->chlen++] = ch; - ch = wc & 0xFF; - if (is_trailbyte(ch) == 0) - goto ilseq; - } - psenc->ch[psenc->chlen++] = ch; - if (n < psenc->chlen) { - *nresult = (size_t)-1; - return E2BIG; - } - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - psenc->chlen = 0; - - return 0; - -ilseq: - *nresult = (size_t)-1; - return EILSEQ; -} - -static __inline int -/*ARGSUSED*/ -_citrus_DECHanyu_stdenc_wctocs(_DECHanyuEncodingInfo * __restrict ei, - _csid_t * __restrict csid, _index_t * __restrict idx, wchar_t wc) -{ - int plane; - wchar_t mask; - - /* ei may be unused */ - _DIAGASSERT(csid != NULL); - _DIAGASSERT(idx != NULL); - - plane = 0; - mask = 0x7F; - /* XXX: assume wchar_t as int */ - if ((uint32_t)wc > 0x7F) { - if ((uint32_t)wc > 0xFFFF) { - if ((wc & ~0xFFFF) != HANYUBIT) - return EILSEQ; - plane += 2; - } - if (is_leadbyte((wc >> 8) & 0xFF) == 0 || - is_trailbyte(wc & 0xFF) == 0) - return EILSEQ; - plane += (wc & 0x80) ? 1 : 2; - mask |= 0x7F00; - } - *csid = plane; - *idx = (_index_t)(wc & mask); - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_DECHanyu_stdenc_cstowc(_DECHanyuEncodingInfo * __restrict ei, - wchar_t * __restrict wc, _csid_t csid, _index_t idx) -{ - /* ei may be unused */ - _DIAGASSERT(wc != NULL); - - if (csid == 0) { - if (idx > 0x7F) - return EILSEQ; - } else if (csid <= 4) { - if (is_94charset(idx >> 8) == 0) - return EILSEQ; - if (is_94charset(idx & 0xFF) == 0) - return EILSEQ; - if (csid % 2) - idx |= 0x80; - idx |= 0x8000; - if (csid > 2) - idx |= HANYUBIT; - } else - return EILSEQ; - *wc = (wchar_t)idx; - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_DECHanyu_stdenc_get_state_desc_generic( - _DECHanyuEncodingInfo * __restrict ei, - _DECHanyuState * __restrict psenc, int * __restrict rstate) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(rstate != NULL); - - *rstate = (psenc->chlen == 0) - ? _STDENC_SDGEN_INITIAL - : _STDENC_SDGEN_INCOMPLETE_CHAR; - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(DECHanyu); -_CITRUS_CTYPE_DEF_OPS(DECHanyu); - -#include "citrus_ctype_template.h" - - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(DECHanyu); -_CITRUS_STDENC_DEF_OPS(DECHanyu); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_dechanyu.h b/lib/libc/citrus/modules/citrus_dechanyu.h deleted file mode 100644 index ed774bcab..000000000 --- a/lib/libc/citrus/modules/citrus_dechanyu.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_dechanyu.h,v 1.1 2007/04/01 18:52:32 tnozaki Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_DECHANYU_H_ -#define _CITRUS_DECHANYU_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(DECHanyu); -_CITRUS_STDENC_GETOPS_FUNC(DECHanyu); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_euc.c b/lib/libc/citrus/modules/citrus_euc.c deleted file mode 100644 index acb2bfa68..000000000 --- a/lib/libc/citrus/modules/citrus_euc.c +++ /dev/null @@ -1,437 +0,0 @@ -/* $NetBSD: citrus_euc.c,v 1.17 2014/01/18 15:21:41 christos Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_euc.c,v 1.17 2014/01/18 15:21:41 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_euc.h" - - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - char ch[3]; - int chlen; -} _EUCState; - -typedef struct { - unsigned count[4]; - wchar_t bits[4]; - wchar_t mask; - unsigned mb_cur_max; -} _EUCEncodingInfo; - -typedef struct { - _EUCEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _EUCState s_mblen; - _EUCState s_mbrlen; - _EUCState s_mbrtowc; - _EUCState s_mbtowc; - _EUCState s_mbsrtowcs; - _EUCState s_mbsnrtowcs; - _EUCState s_wcrtomb; - _EUCState s_wcsrtombs; - _EUCState s_wcsnrtombs; - _EUCState s_wctomb; - } states; -} _EUCCTypeInfo; - -#define _SS2 0x008e -#define _SS3 0x008f - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_EUC_##m -#define _ENCODING_INFO _EUCEncodingInfo -#define _CTYPE_INFO _EUCCTypeInfo -#define _ENCODING_STATE _EUCState -#define _ENCODING_MB_CUR_MAX(_ei_) (_ei_)->mb_cur_max -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - - -static __inline int -_citrus_EUC_cs(unsigned int c) -{ - c &= 0xff; - - return ((c & 0x80) ? c == _SS3 ? 3 : c == _SS2 ? 2 : 1 : 0); -} - -static __inline int -_citrus_EUC_parse_variable(_EUCEncodingInfo *ei, - const void *var, size_t lenvar) -{ - const char *v, *e; - int x; - - /* parse variable string */ - if (!var) - return (EFTYPE); - - v = (const char *) var; - - while (*v == ' ' || *v == '\t') - ++v; - - ei->mb_cur_max = 1; - for (x = 0; x < 4; ++x) { - ei->count[x] = (int)_bcs_strtol(v, (char **)&e, 0); - if (v == e || !(v = e) || ei->count[x]<1 || ei->count[x]>4) { - return (EFTYPE); - } - if (ei->mb_cur_max < ei->count[x]) - ei->mb_cur_max = ei->count[x]; - while (*v == ' ' || *v == '\t') - ++v; - ei->bits[x] = (int)_bcs_strtol(v, (char **)&e, 0); - if (v == e || !(v = e)) { - return (EFTYPE); - } - while (*v == ' ' || *v == '\t') - ++v; - } - ei->mask = (int)_bcs_strtol(v, (char **)&e, 0); - if (v == e || !(v = e)) { - return (EFTYPE); - } - - return 0; -} - - -static __inline void -/*ARGSUSED*/ -_citrus_EUC_init_state(_EUCEncodingInfo *ei, _EUCState *s) -{ - memset(s, 0, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_EUC_pack_state(_EUCEncodingInfo *ei, void *pspriv, const _EUCState *s) -{ - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_EUC_unpack_state(_EUCEncodingInfo *ei, _EUCState *s, - const void *pspriv) -{ - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static int -_citrus_EUC_mbrtowc_priv(_EUCEncodingInfo *ei, wchar_t *pwc, const char **s, - size_t n, _EUCState *psenc, size_t *nresult) -{ - wchar_t wchar; - int c, cs, len; - int chlenbak; - const char *s0, *s1 = NULL; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL); - - s0 = *s; - - if (s0 == NULL) { - _citrus_EUC_init_state(ei, psenc); - *nresult = 0; /* state independent */ - return (0); - } - - chlenbak = psenc->chlen; - - /* make sure we have the first byte in the buffer */ - switch (psenc->chlen) { - case 0: - if (n < 1) - goto restart; - psenc->ch[0] = *s0++; - psenc->chlen = 1; - n--; - break; - case 1: - case 2: - break; - default: - /* illgeal state */ - goto encoding_error; - } - - c = ei->count[cs = _citrus_EUC_cs(psenc->ch[0] & 0xff)]; - if (c == 0) - goto encoding_error; - while (psenc->chlen < c) { - if (n < 1) - goto restart; - psenc->ch[psenc->chlen] = *s0++; - psenc->chlen++; - n--; - } - *s = s0; - - switch (cs) { - case 3: - case 2: - /* skip SS2/SS3 */ - len = c - 1; - s1 = &psenc->ch[1]; - break; - case 1: - case 0: - len = c; - s1 = &psenc->ch[0]; - break; - default: - goto encoding_error; - } - wchar = 0; - while (len-- > 0) - wchar = (wchar << 8) | (*s1++ & 0xff); - wchar = (wchar & ~ei->mask) | ei->bits[cs]; - - psenc->chlen = 0; - if (pwc) - *pwc = wchar; - - if (!wchar) { - *nresult = 0; - } else { - *nresult = (size_t)(c - chlenbak); - } - - return 0; - -encoding_error: - psenc->chlen = 0; - *nresult = (size_t)-1; - return (EILSEQ); - -restart: - *nresult = (size_t)-2; - *s = s0; - return (0); -} - -static int -_citrus_EUC_wcrtomb_priv(_EUCEncodingInfo *ei, char *s, size_t n, wchar_t wc, - _EUCState *psenc, size_t *nresult) -{ - wchar_t m, nm; - int cs, i, ret; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(nresult != 0); - _DIAGASSERT(s != NULL); - - m = wc & ei->mask; - nm = wc & ~m; - - for (cs = 0; - cs < sizeof(ei->count)/sizeof(ei->count[0]); - cs++) { - if (m == ei->bits[cs]) - break; - } - /* fallback case - not sure if it is necessary */ - if (cs == sizeof(ei->count)/sizeof(ei->count[0])) - cs = 1; - - i = ei->count[cs]; - if (n < i) { - ret = E2BIG; - goto err; - } - m = (cs) ? 0x80 : 0x00; - switch (cs) { - case 2: - *s++ = _SS2; - i--; - break; - case 3: - *s++ = _SS3; - i--; - break; - } - - while (i-- > 0) - *s++ = ((nm >> (i << 3)) & 0xff) | m; - - *nresult = (size_t)ei->count[cs]; - return 0; - -err: - *nresult = (size_t)-1; - return ret; -} - -static __inline int -/*ARGSUSED*/ -_citrus_EUC_stdenc_wctocs(_EUCEncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, wchar_t wc) -{ - wchar_t m, nm; - - _DIAGASSERT(ei != NULL && csid != NULL && idx != NULL); - - m = wc & ei->mask; - nm = wc & ~m; - - *csid = (_citrus_csid_t)m; - *idx = (_citrus_index_t)nm; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_EUC_stdenc_cstowc(_EUCEncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - - _DIAGASSERT(ei != NULL && wc != NULL); - - if ((csid & ~ei->mask) != 0 || (idx & ei->mask) != 0) - return (EINVAL); - - *wc = (wchar_t)csid | (wchar_t)idx; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_EUC_stdenc_get_state_desc_generic(_EUCEncodingInfo * __restrict ei, - _EUCState * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_EUC_encoding_module_init(_EUCEncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - - _DIAGASSERT(ei != NULL); - - return (_citrus_EUC_parse_variable(ei, var, lenvar)); -} - -static void -/*ARGSUSED*/ -_citrus_EUC_encoding_module_uninit(_EUCEncodingInfo * __restrict ei) -{ -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(EUC); -_CITRUS_CTYPE_DEF_OPS(EUC); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(EUC); -_CITRUS_STDENC_DEF_OPS(EUC); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_euc.h b/lib/libc/citrus/modules/citrus_euc.h deleted file mode 100644 index 9f67756ca..000000000 --- a/lib/libc/citrus/modules/citrus_euc.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_euc.h,v 1.2 2003/06/25 09:51:42 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_EUC_H_ -#define _CITRUS_EUC_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(EUC); -_CITRUS_STDENC_GETOPS_FUNC(EUC); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_euctw.c b/lib/libc/citrus/modules/citrus_euctw.c deleted file mode 100644 index 9d6738f55..000000000 --- a/lib/libc/citrus/modules/citrus_euctw.c +++ /dev/null @@ -1,430 +0,0 @@ -/* $NetBSD: citrus_euctw.c,v 1.12 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -/*- - * Copyright (c)1999 Citrus Project, - * 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. - * - * $Citrus: xpg4dl/FreeBSD/lib/libc/locale/euctw.c,v 1.13 2001/06/21 01:51:44 yamt Exp $ - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_euctw.c,v 1.12 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_euctw.h" - - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - char ch[4]; - int chlen; -} _EUCTWState; - -typedef struct { - int dummy; -} _EUCTWEncodingInfo; -typedef struct { - _EUCTWEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _EUCTWState s_mblen; - _EUCTWState s_mbrlen; - _EUCTWState s_mbrtowc; - _EUCTWState s_mbtowc; - _EUCTWState s_mbsrtowcs; - _EUCTWState s_mbsnrtowcs; - _EUCTWState s_wcrtomb; - _EUCTWState s_wcsrtombs; - _EUCTWState s_wcsnrtombs; - _EUCTWState s_wctomb; - } states; -} _EUCTWCTypeInfo; - -#define _SS2 0x008e -#define _SS3 0x008f - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_EUCTW_##m -#define _ENCODING_INFO _EUCTWEncodingInfo -#define _CTYPE_INFO _EUCTWCTypeInfo -#define _ENCODING_STATE _EUCTWState -#define _ENCODING_MB_CUR_MAX(_ei_) 4 -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - -static __inline int -_citrus_EUCTW_cs(u_int c) -{ - c &= 0xff; - - return ((c & 0x80) ? (c == _SS2 ? 2 : 1) : 0); -} - -static __inline int -_citrus_EUCTW_count(int cs) -{ - switch (cs) { - case 0: - return 1; - case 1: - return 2; - case 2: - return 4; - case 3: - abort(); - /*NOTREACHED*/ - } - return 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_EUCTW_init_state(_EUCTWEncodingInfo * __restrict ei, - _EUCTWState * __restrict s) -{ - memset(s, 0, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_EUCTW_pack_state(_EUCTWEncodingInfo * __restrict ei, - void * __restrict pspriv, - const _EUCTWState * __restrict s) -{ - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_EUCTW_unpack_state(_EUCTWEncodingInfo * __restrict ei, - _EUCTWState * __restrict s, - const void * __restrict pspriv) -{ - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static int -/*ARGSUSED*/ -_citrus_EUCTW_encoding_module_init(_EUCTWEncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - - _DIAGASSERT(ei != NULL); - - memset((void *)ei, 0, sizeof(*ei)); - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_EUCTW_encoding_module_uninit(_EUCTWEncodingInfo *ei) -{ -} - -static int -_citrus_EUCTW_mbrtowc_priv(_EUCTWEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, - const char ** __restrict s, - size_t n, _EUCTWState * __restrict psenc, - size_t * __restrict nresult) -{ - wchar_t wchar; - int c, cs; - int chlenbak; - const char *s0; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL); - - s0 = *s; - - if (s0 == NULL) { - _citrus_EUCTW_init_state(ei, psenc); - *nresult = 0; /* state independent */ - return (0); - } - - chlenbak = psenc->chlen; - - /* make sure we have the first byte in the buffer */ - switch (psenc->chlen) { - case 0: - if (n < 1) - goto restart; - psenc->ch[0] = *s0++; - psenc->chlen = 1; - n--; - break; - case 1: - case 2: - break; - default: - /* illgeal state */ - goto ilseq; - } - - c = _citrus_EUCTW_count(cs = _citrus_EUCTW_cs(psenc->ch[0] & 0xff)); - if (c == 0) - goto ilseq; - while (psenc->chlen < c) { - if (n < 1) - goto ilseq; - psenc->ch[psenc->chlen] = *s0++; - psenc->chlen++; - n--; - } - - wchar = 0; - switch (cs) { - case 0: - if (psenc->ch[0] & 0x80) - goto ilseq; - wchar = psenc->ch[0] & 0xff; - break; - case 1: - if (!(psenc->ch[0] & 0x80) || !(psenc->ch[1] & 0x80)) - goto ilseq; - wchar = ((psenc->ch[0] & 0xff) << 8) | (psenc->ch[1] & 0xff); - wchar |= 'G' << 24; - break; - case 2: - if ((u_char)psenc->ch[1] < 0xa1 || 0xa7 < (u_char)psenc->ch[1]) - goto ilseq; - if (!(psenc->ch[2] & 0x80) || !(psenc->ch[3] & 0x80)) - goto ilseq; - wchar = ((psenc->ch[2] & 0xff) << 8) | (psenc->ch[3] & 0xff); - wchar |= ('G' + psenc->ch[1] - 0xa1) << 24; - break; - default: - goto ilseq; - } - - *s = s0; - psenc->chlen = 0; - - if (pwc) - *pwc = wchar; - - if (!wchar) - *nresult = 0; - else - *nresult = c - chlenbak; - - return (0); - -ilseq: - psenc->chlen = 0; - *nresult = (size_t)-1; - return (EILSEQ); - -restart: - *s = s0; - *nresult = (size_t)-1; - return (0); -} - -static int -_citrus_EUCTW_wcrtomb_priv(_EUCTWEncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _EUCTWState * __restrict psenc, - size_t * __restrict nresult) -{ - wchar_t cs = wc & 0x7f000080; - wchar_t v; - int i, len, clen, ret; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(nresult != 0); - _DIAGASSERT(s != NULL); - - clen = 1; - if (wc & 0x00007f00) - clen = 2; - if ((wc & 0x007f0000) && !(wc & 0x00800000)) - clen = 3; - - if (clen == 1 && cs == 0x00000000) { - /* ASCII */ - len = 1; - if (n < len) { - ret = E2BIG; - goto err; - } - v = wc & 0x0000007f; - } else if (clen == 2 && cs == ('G' << 24)) { - /* CNS-11643-1 */ - len = 2; - if (n < len) { - ret = E2BIG; - goto err; - } - v = wc & 0x00007f7f; - v |= 0x00008080; - } else if (clen == 2 && 'H' <= (cs >> 24) && (cs >> 24) <= 'M') { - /* CNS-11643-[2-7] */ - len = 4; - if (n < len) { - ret = E2BIG; - goto err; - } - *s++ = _SS2; - *s++ = (cs >> 24) - 'H' + 0xa2; - v = wc & 0x00007f7f; - v |= 0x00008080; - } else { - ret = EILSEQ; - goto err; - } - - i = clen; - while (i-- > 0) - *s++ = (v >> (i << 3)) & 0xff; - - *nresult = len; - return 0; - -err: - *nresult = (size_t)-1; - return ret; -} - -static __inline int -/*ARGSUSED*/ -_citrus_EUCTW_stdenc_wctocs(_EUCTWEncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, wchar_t wc) -{ - - _DIAGASSERT(ei != NULL && csid != NULL && idx != NULL); - - *csid = (_csid_t)(wc >> 24) & 0xFF; - *idx = (_index_t)(wc & 0x7F7F); - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_EUCTW_stdenc_cstowc(_EUCTWEncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - - _DIAGASSERT(ei != NULL && wc != NULL); - - if (csid==0) { - if ((idx & ~0x7F) != 0) - return (EINVAL); - *wc = (wchar_t)idx; - } else { - if (csid < 'G' || csid > 'M' || (idx & ~0x7F7F) != 0) - return (EINVAL); - *wc = (wchar_t)idx | ((wchar_t)csid<<24); - } - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_EUCTW_stdenc_get_state_desc_generic(_EUCTWEncodingInfo * __restrict ei, - _EUCTWState * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(EUCTW); -_CITRUS_CTYPE_DEF_OPS(EUCTW); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(EUCTW); -_CITRUS_STDENC_DEF_OPS(EUCTW); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_euctw.h b/lib/libc/citrus/modules/citrus_euctw.h deleted file mode 100644 index dc01412ee..000000000 --- a/lib/libc/citrus/modules/citrus_euctw.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_euctw.h,v 1.2 2003/06/25 09:51:42 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_EUCTW_H_ -#define _CITRUS_EUCTW_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(EUCTW); -_CITRUS_STDENC_GETOPS_FUNC(EUCTW); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_gbk2k.c b/lib/libc/citrus/modules/citrus_gbk2k.c deleted file mode 100644 index 9223e0354..000000000 --- a/lib/libc/citrus/modules/citrus_gbk2k.c +++ /dev/null @@ -1,476 +0,0 @@ -/* $NetBSD: citrus_gbk2k.c,v 1.8 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_gbk2k.c,v 1.8 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_gbk2k.h" - - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct _GBK2KState { - char ch[4]; - int chlen; -} _GBK2KState; - -typedef struct { - int mb_cur_max; -} _GBK2KEncodingInfo; - -typedef struct { - _GBK2KEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _GBK2KState s_mblen; - _GBK2KState s_mbrlen; - _GBK2KState s_mbrtowc; - _GBK2KState s_mbtowc; - _GBK2KState s_mbsrtowcs; - _GBK2KState s_mbsnrtowcs; - _GBK2KState s_wcrtomb; - _GBK2KState s_wcsrtombs; - _GBK2KState s_wcsnrtombs; - _GBK2KState s_wctomb; - } states; -} _GBK2KCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_GBK2K_##m -#define _ENCODING_INFO _GBK2KEncodingInfo -#define _CTYPE_INFO _GBK2KCTypeInfo -#define _ENCODING_STATE _GBK2KState -#define _ENCODING_MB_CUR_MAX(_ei_) (_ei_)->mb_cur_max -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - -static __inline void -/*ARGSUSED*/ -_citrus_GBK2K_init_state(_GBK2KEncodingInfo * __restrict ei, - _GBK2KState * __restrict s) -{ - memset(s, 0, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_GBK2K_pack_state(_GBK2KEncodingInfo * __restrict ei, - void * __restrict pspriv, - const _GBK2KState * __restrict s) -{ - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_GBK2K_unpack_state(_GBK2KEncodingInfo * __restrict ei, - _GBK2KState * __restrict s, - const void * __restrict pspriv) -{ - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static __inline int -_mb_singlebyte(int c) -{ - c &= 0xff; - return (c <= 0x7f); -} - -static __inline int -_mb_leadbyte(int c) -{ - c &= 0xff; - return (0x81 <= c && c <= 0xfe); -} - -static __inline int -_mb_trailbyte(int c) -{ - c &= 0xff; - return ((0x40 <= c && c <= 0x7e) || (0x80 <= c && c <= 0xfe)); -} - -static __inline int -_mb_surrogate(int c) -{ - c &= 0xff; - return (0x30 <= c && c <= 0x39); -} - -static __inline int -_mb_count(wchar_t v) -{ - u_int32_t c; - - c = (u_int32_t)v; /* XXX */ - if (!(c & 0xffffff00)) - return (1); - if (!(c & 0xffff0000)) - return (2); - return (4); -} - -#define _PSENC (psenc->ch[psenc->chlen - 1]) -#define _PUSH_PSENC(c) (psenc->ch[psenc->chlen++] = (c)) - -static int -_citrus_GBK2K_mbrtowc_priv(_GBK2KEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, - const char ** __restrict s, size_t n, - _GBK2KState * __restrict psenc, - size_t * __restrict nresult) -{ - int chlenbak, len; - const char *s0, *s1; - wchar_t wc; - - _DIAGASSERT(ei != NULL); - /* pwc may be NULL */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - - s0 = *s; - - if (s0 == NULL) { - /* _citrus_GBK2K_init_state(ei, psenc); */ - psenc->chlen = 0; - *nresult = 0; - return (0); - } - - chlenbak = psenc->chlen; - - switch (psenc->chlen) { - case 3: - if (!_mb_leadbyte (_PSENC)) - goto invalid; - /* FALLTHROUGH */ - case 2: - if (!_mb_surrogate(_PSENC) || _mb_trailbyte(_PSENC)) - goto invalid; - /* FALLTHROUGH */ - case 1: - if (!_mb_leadbyte (_PSENC)) - goto invalid; - /* FALLTHOROUGH */ - case 0: - break; - default: - goto invalid; - } - - for (;;) { - if (n-- < 1) - goto restart; - - _PUSH_PSENC(*s0++); - - switch (psenc->chlen) { - case 1: - if (_mb_singlebyte(_PSENC)) - goto convert; - if (_mb_leadbyte (_PSENC)) - continue; - goto ilseq; - case 2: - if (_mb_trailbyte (_PSENC)) - goto convert; - if (ei->mb_cur_max == 4 && - _mb_surrogate (_PSENC)) - continue; - goto ilseq; - case 3: - if (_mb_leadbyte (_PSENC)) - continue; - goto ilseq; - case 4: - if (_mb_surrogate (_PSENC)) - goto convert; - goto ilseq; - } - } - -convert: - len = psenc->chlen; - s1 = &psenc->ch[0]; - wc = 0; - while (len-- > 0) - wc = (wc << 8) | (*s1++ & 0xff); - - if (pwc != NULL) - *pwc = wc; - *s = s0; - *nresult = (wc == 0) ? 0 : psenc->chlen - chlenbak; - /* _citrus_GBK2K_init_state(ei, psenc); */ - psenc->chlen = 0; - - return (0); - -restart: - *s = s0; - *nresult = (size_t)-2; - - return (0); - -invalid: - return (EINVAL); - -ilseq: - *nresult = (size_t)-1; - return (EILSEQ); -} - -static int -_citrus_GBK2K_wcrtomb_priv(_GBK2KEncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _GBK2KState * __restrict psenc, - size_t * __restrict nresult) -{ - int len, ret; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - - if (psenc->chlen != 0) { - ret = EINVAL; - goto err; - } - - len = _mb_count(wc); - if (n < len) { - ret = E2BIG; - goto err; - } - - switch (len) { - case 1: - if (!_mb_singlebyte(_PUSH_PSENC(wc ))) { - ret = EILSEQ; - goto err; - } - break; - case 2: - if (!_mb_leadbyte (_PUSH_PSENC(wc >> 8)) || - !_mb_trailbyte (_PUSH_PSENC(wc ))) { - ret = EILSEQ; - goto err; - } - break; - case 4: - if (ei->mb_cur_max != 4 || - !_mb_leadbyte (_PUSH_PSENC(wc >> 24)) || - !_mb_surrogate (_PUSH_PSENC(wc >> 16)) || - !_mb_leadbyte (_PUSH_PSENC(wc >> 8)) || - !_mb_surrogate (_PUSH_PSENC(wc ))) { - ret = EILSEQ; - goto err; - } - break; - } - - _DIAGASSERT(len == psenc->chlen); - - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - /* _citrus_GBK2K_init_state(ei, psenc); */ - psenc->chlen = 0; - - return (0); - -err: - *nresult = (size_t)-1; - return ret; -} - -static __inline int -/*ARGSUSED*/ -_citrus_GBK2K_stdenc_wctocs(_GBK2KEncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, wchar_t wc) -{ - u_int8_t ch, cl; - - _DIAGASSERT(csid != NULL && idx != NULL); - - if ((u_int32_t)wc<0x80) { - /* ISO646 */ - *csid = 0; - *idx = (_index_t)wc; - } else if ((u_int32_t)wc>=0x10000) { - /* GBKUCS : XXX */ - *csid = 3; - *idx = (_index_t)wc; - } else { - ch = (u_int8_t)(wc >> 8); - cl = (u_int8_t)wc; - if (ch>=0xA1 && cl>=0xA1) { - /* EUC G1 */ - *csid = 1; - *idx = (_index_t)wc & 0x7F7FU; - } else { - /* extended area (0x8140-) */ - *csid = 2; - *idx = (_index_t)wc; - } - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_GBK2K_stdenc_cstowc(_GBK2KEncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - - _DIAGASSERT(wc != NULL); - - switch (csid) { - case 0: - /* ISO646 */ - *wc = (wchar_t)idx; - break; - case 1: - /* EUC G1 */ - *wc = (wchar_t)idx | 0x8080U; - break; - case 2: - /* extended area */ - *wc = (wchar_t)idx; - break; - case 3: - /* GBKUCS : XXX */ - if (ei->mb_cur_max != 4) - return EINVAL; - *wc = (wchar_t)idx; - break; - default: - return EILSEQ; - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_GBK2K_stdenc_get_state_desc_generic(_GBK2KEncodingInfo * __restrict ei, - _GBK2KState * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_GBK2K_encoding_module_init(_GBK2KEncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - const char *p; - - _DIAGASSERT(ei != NULL); - - p = var; -#define MATCH(x, act) \ -do { \ - if (lenvar >= (sizeof(#x)-1) && \ - _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) { \ - act; \ - lenvar -= sizeof(#x)-1; \ - p += sizeof(#x)-1; \ - } \ -} while (/*CONSTCOND*/0) - memset((void *)ei, 0, sizeof(*ei)); - ei->mb_cur_max = 4; - while (lenvar>0) { - switch (_bcs_tolower(*p)) { - case '2': - MATCH("2byte", ei->mb_cur_max = 2); - break; - } - p++; - lenvar--; - } - - return (0); -} - -static void -/*ARGSUSED*/ -_citrus_GBK2K_encoding_module_uninit(_GBK2KEncodingInfo *ei) -{ -} - - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(GBK2K); -_CITRUS_CTYPE_DEF_OPS(GBK2K); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(GBK2K); -_CITRUS_STDENC_DEF_OPS(GBK2K); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_gbk2k.h b/lib/libc/citrus/modules/citrus_gbk2k.h deleted file mode 100644 index d0ea49115..000000000 --- a/lib/libc/citrus/modules/citrus_gbk2k.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_gbk2k.h,v 1.2 2003/06/25 09:51:43 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_GBK2K_H_ -#define _CITRUS_GBK2K_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(GBK2K); -_CITRUS_STDENC_GETOPS_FUNC(GBK2K); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_hz.c b/lib/libc/citrus/modules/citrus_hz.c deleted file mode 100644 index 54dca5128..000000000 --- a/lib/libc/citrus/modules/citrus_hz.c +++ /dev/null @@ -1,728 +0,0 @@ -/* $NetBSD: citrus_hz.c,v 1.4 2014/06/24 22:24:18 spz Exp $ */ - -/*- - * Copyright (c)2004, 2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_hz.c,v 1.4 2014/06/24 22:24:18 spz Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" - -#include "citrus_hz.h" -#include "citrus_prop.h" - -/* - * wchar_t mapping: - * - * CTRL/ASCII 00000000 00000000 00000000 gxxxxxxx - * GB2312 00000000 00000000 0xxxxxxx gxxxxxxx - * 94/96*n (~M) 0mmmmmmm 0xxxxxxx 0xxxxxxx gxxxxxxx - */ - -#define ESCAPE_CHAR '~' - -typedef enum { - CTRL = 0, ASCII = 1, GB2312 = 2, CS94 = 3, CS96 = 4 -} charset_t; - -typedef struct { - int start, end, width; -} range_t; - -static const range_t ranges[] = { -#define RANGE(start, end) { start, end, (end - start) + 1 } -/* CTRL */ RANGE(0x00, 0x1F), -/* ASCII */ RANGE(0x20, 0x7F), -/* GB2312 */ RANGE(0x21, 0x7E), -/* CS94 */ RANGE(0x21, 0x7E), -/* CS96 */ RANGE(0x20, 0x7F), -#undef RANGE -}; - -typedef struct escape_t escape_t; -typedef struct { - charset_t charset; - size_t length; -#define ROWCOL_MAX 3 - escape_t *escape; -} graphic_t; - -typedef TAILQ_HEAD(escape_list, escape_t) escape_list; -struct escape_t { - TAILQ_ENTRY(escape_t) entry; - int ch; - graphic_t *left, *right; - escape_list *set; -}; - -#define GL(escape) ((escape)->left) -#define GR(escape) ((escape)->right) -#define SET(escape) ((escape)->set) -#define ESC(escape) ((escape)->ch) -#define INIT(escape) (TAILQ_FIRST(SET(escape))) - -static __inline escape_t * -find_escape(escape_list *set, int ch) -{ - escape_t *escape; - - _DIAGASSERT(set != NULL); - - TAILQ_FOREACH(escape, set, entry) { - if (ESC(escape) == ch) - break; - } - - return escape; -} - -typedef struct { - escape_list e0, e1; - graphic_t *ascii, *gb2312; -} _HZEncodingInfo; - -#define E0SET(ei) (&(ei)->e0) -#define E1SET(ei) (&(ei)->e1) -#define INIT0(ei) (TAILQ_FIRST(E0SET(ei))) -#define INIT1(ei) (TAILQ_FIRST(E1SET(ei))) - -typedef struct { - int chlen; - char ch[ROWCOL_MAX]; - escape_t *inuse; -} _HZState; - -typedef struct { - _HZEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _HZState s_mblen; - _HZState s_mbrlen; - _HZState s_mbrtowc; - _HZState s_mbtowc; - _HZState s_mbsrtowcs; - _HZState s_mbsnrtowcs; - _HZState s_wcrtomb; - _HZState s_wcsrtombs; - _HZState s_wcsnrtombs; - _HZState s_wctomb; - } states; -} _HZCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_HZ_##m -#define _ENCODING_INFO _HZEncodingInfo -#define _CTYPE_INFO _HZCTypeInfo -#define _ENCODING_STATE _HZState -#define _ENCODING_MB_CUR_MAX(_ei_) MB_LEN_MAX -#define _ENCODING_IS_STATE_DEPENDENT 1 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) ((_ps_)->inuse == NULL) - -static __inline void -_citrus_HZ_init_state(_HZEncodingInfo * __restrict ei, - _HZState * __restrict psenc) -{ - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - - psenc->chlen = 0; - psenc->inuse = INIT0(ei); -} - -static __inline void -/*ARGSUSED*/ -_citrus_HZ_pack_state(_HZEncodingInfo * __restrict ei, - void *__restrict pspriv, const _HZState * __restrict psenc) -{ - /* ei may be unused */ - _DIAGASSERT(pspriv != NULL); - _DIAGASSERT(psenc != NULL); - - memcpy(pspriv, (const void *)psenc, sizeof(*psenc)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_HZ_unpack_state(_HZEncodingInfo * __restrict ei, - _HZState * __restrict psenc, const void * __restrict pspriv) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(pspriv != NULL); - - memcpy((void *)psenc, pspriv, sizeof(*psenc)); -} - -static int -_citrus_HZ_mbrtowc_priv(_HZEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, const char ** __restrict s, size_t n, - _HZState * __restrict psenc, size_t * __restrict nresult) -{ - const char *s0; - wchar_t wc; - int bit, head, tail, len, ch; - graphic_t *graphic; - escape_t *candidate, *init; - const range_t *range; - - _DIAGASSERT(ei != NULL); - /* pwc may be null */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (*s == NULL) { - _citrus_HZ_init_state(ei, psenc); - *nresult = 1; - return 0; - } - s0 = *s; - if (psenc->chlen < 0 || psenc->inuse == NULL) - return EINVAL; - - wc = (wchar_t)0; - bit = head = tail = 0; - graphic = NULL; - for (len = 0; len <= MB_LEN_MAX; /**/) { - if (psenc->chlen == tail) { - if (n-- < 1) { - *s = s0; - *nresult = (size_t)-2; - return 0; - } - psenc->ch[psenc->chlen++] = *s0++; - ++len; - } - ch = (unsigned char)psenc->ch[tail++]; - if (tail == 1) { - if ((ch & ~0x80) <= 0x1F) { - if (psenc->inuse != INIT0(ei)) - break; - wc = (wchar_t)ch; - goto done; - } - if (ch & 0x80) { - graphic = GR(psenc->inuse); - bit = 0x80; - ch &= ~0x80; - } else { - graphic = GL(psenc->inuse); - if (ch == ESCAPE_CHAR) - continue; - bit = 0x0; - } - if (graphic == NULL) - break; - } else if (tail == 2 && psenc->ch[0] == ESCAPE_CHAR) { - if (tail < psenc->chlen) - return EINVAL; - if (ch == ESCAPE_CHAR) { - ++head; - } else if (ch == '\n') { - if (psenc->inuse != INIT0(ei)) - break; - tail = psenc->chlen = 0; - continue; - } else { - candidate = NULL; - init = INIT0(ei); - _DIAGASSERT(init != NULL); - if (psenc->inuse == init) { - init = INIT1(ei); - } else if (INIT(psenc->inuse) == init) { - if (ESC(init) != ch) - break; - candidate = init; - } - if (candidate == NULL) { - candidate = find_escape( - SET(psenc->inuse), ch); - if (candidate == NULL) { - if (init == NULL || - ESC(init) != ch) - break; - candidate = init; - } - } - psenc->inuse = candidate; - tail = psenc->chlen = 0; - continue; - } - } else if (ch & 0x80) { - if (graphic != GR(psenc->inuse)) - break; - ch &= ~0x80; - } else { - if (graphic != GL(psenc->inuse)) - break; - } - _DIAGASSERT(graphic != NULL); - range = &ranges[(size_t)graphic->charset]; - if (range->start > ch || range->end < ch) - break; - wc <<= 8; - wc |= ch; - if (graphic->length == (tail - head)) { - if (graphic->charset > GB2312) - bit |= ESC(psenc->inuse) << 24; - wc |= bit; - goto done; - } - } - *nresult = (size_t)-1; - return EILSEQ; -done: - if (tail < psenc->chlen) - return EINVAL; - *s = s0; - if (pwc != NULL) - *pwc = wc; - psenc->chlen = 0; - *nresult = (wc == 0) ? 0 : len; - - return 0; -} - -static int -_citrus_HZ_wcrtomb_priv(_HZEncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _HZState * __restrict psenc, size_t * __restrict nresult) -{ - int bit, ch; - escape_t *candidate, *init; - graphic_t *graphic; - size_t len; - const range_t *range; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (psenc->chlen != 0 || psenc->inuse == NULL) - return EINVAL; - if (wc & 0x80) { - bit = 0x80; - wc &= ~0x80; - } else { - bit = 0x0; - } - if ((uint32_t)wc <= 0x1F) { - candidate = INIT0(ei); - graphic = (bit == 0) - ? candidate->left : candidate->right; - if (graphic == NULL) - goto ilseq; - range = &ranges[(size_t)CTRL]; - len = 1; - } else if ((uint32_t)wc <= 0x7F) { - graphic = ei->ascii; - if (graphic == NULL) - goto ilseq; - candidate = graphic->escape; - range = &ranges[(size_t)graphic->charset]; - len = graphic->length; - } else if ((uint32_t)wc <= 0x7F7F) { - graphic = ei->gb2312; - if (graphic == NULL) - goto ilseq; - candidate = graphic->escape; - range = &ranges[(size_t)graphic->charset]; - len = graphic->length; - } else { - ch = (wc >> 24) & 0xFF; - candidate = find_escape(E0SET(ei), ch); - if (candidate == NULL) { - candidate = find_escape(E1SET(ei), ch); - if (candidate == NULL) - goto ilseq; - } - wc &= ~0xFF000000; - graphic = (bit == 0) - ? candidate->left : candidate->right; - if (graphic == NULL) - goto ilseq; - range = &ranges[(size_t)graphic->charset]; - len = graphic->length; - } - if (psenc->inuse != candidate) { - init = INIT0(ei); - if (SET(psenc->inuse) == SET(candidate)) { - if (INIT(psenc->inuse) != init || - psenc->inuse == init || candidate == init) - init = NULL; - } else if (candidate == (init = INIT(candidate))) { - init = NULL; - } - if (init != NULL) { - if (n < 2) - return E2BIG; - n -= 2; - psenc->ch[psenc->chlen++] = ESCAPE_CHAR; - psenc->ch[psenc->chlen++] = ESC(init); - } - if (n < 2) - return E2BIG; - n -= 2; - psenc->ch[psenc->chlen++] = ESCAPE_CHAR; - psenc->ch[psenc->chlen++] = ESC(candidate); - psenc->inuse = candidate; - } - if (n < len) - return E2BIG; - while (len-- > 0) { - ch = (wc >> (len * 8)) & 0xFF; - if (range->start > ch || range->end < ch) - goto ilseq; - psenc->ch[psenc->chlen++] = ch | bit; - } - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - psenc->chlen = 0; - - return 0; - -ilseq: - *nresult = (size_t)-1; - return EILSEQ; -} - -static __inline int -_citrus_HZ_put_state_reset(_HZEncodingInfo * __restrict ei, - char * __restrict s, size_t n, _HZState * __restrict psenc, - size_t * __restrict nresult) -{ - escape_t *candidate; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (psenc->chlen != 0 || psenc->inuse == NULL) - return EINVAL; - candidate = INIT0(ei); - if (psenc->inuse != candidate) { - if (n < 2) - return E2BIG; - n -= 2; - psenc->ch[psenc->chlen++] = ESCAPE_CHAR; - psenc->ch[psenc->chlen++] = ESC(candidate); - } - if (n < 1) - return E2BIG; - if (psenc->chlen > 0) - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - _citrus_HZ_init_state(ei, psenc); - - return 0; -} - -static __inline int -_citrus_HZ_stdenc_get_state_desc_generic(_HZEncodingInfo * __restrict ei, - _HZState * __restrict psenc, int * __restrict rstate) -{ - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(rstate != NULL); - - if (psenc->chlen < 0 || psenc->inuse == NULL) - return EINVAL; - *rstate = (psenc->chlen == 0) - ? ((psenc->inuse == INIT0(ei)) - ? _STDENC_SDGEN_INITIAL - : _STDENC_SDGEN_STABLE) - : ((psenc->ch[0] == ESCAPE_CHAR) - ? _STDENC_SDGEN_INCOMPLETE_SHIFT - : _STDENC_SDGEN_INCOMPLETE_CHAR); - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_HZ_stdenc_wctocs(_HZEncodingInfo * __restrict ei, - _csid_t * __restrict csid, _index_t * __restrict idx, wchar_t wc) -{ - int bit; - - _DIAGASSERT(csid != NULL); - _DIAGASSERT(idx != NULL); - - if (wc & 0x80) { - bit = 0x80; - wc &= ~0x80; - } else { - bit = 0x0; - } - if ((uint32_t)wc <= 0x7F) { - *csid = (_csid_t)bit; - *idx = (_index_t)wc; - } else if ((uint32_t)wc <= 0x7F7F) { - *csid = (_csid_t)(bit | 0x8000); - *idx = (_index_t)wc; - } else { - *csid = (_index_t)(wc & ~0x00FFFF7F); - *idx = (_csid_t)(wc & 0x00FFFF7F); - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_HZ_stdenc_cstowc(_HZEncodingInfo * __restrict ei, - wchar_t * __restrict wc, _csid_t csid, _index_t idx) -{ - _DIAGASSERT(ei != NULL); - _DIAGASSERT(wc != NULL); - - *wc = (wchar_t)idx; - switch (csid) { - case 0x80: - case 0x8080: - *wc |= (wchar_t)0x80; - /*FALLTHROUGH*/ - case 0x0: - case 0x8000: - break; - default: - *wc |= (wchar_t)csid; - } - - return 0; -} - -static void -_citrus_HZ_encoding_module_uninit(_HZEncodingInfo *ei) -{ - escape_t *escape; - - _DIAGASSERT(ei != NULL); - while ((escape = TAILQ_FIRST(E0SET(ei))) != NULL) { - TAILQ_REMOVE(E0SET(ei), escape, entry); - free(GL(escape)); - free(GR(escape)); - free(escape); - } - while ((escape = TAILQ_FIRST(E1SET(ei))) != NULL) { - TAILQ_REMOVE(E1SET(ei), escape, entry); - free(GL(escape)); - free(GR(escape)); - free(escape); - } -} - -static int -_citrus_HZ_parse_char(void *context, const char *name, const char *s) -{ - void **p; - escape_t *escape; - - _DIAGASSERT(context != NULL && *context != NULL); - _DIAGASSERT(name != NULL); - _DIAGASSERT(s != NULL); - - p = (void **)context; - escape = (escape_t *)p[0]; - if (escape->ch != '\0') - return EINVAL; - escape->ch = *s++; - if (escape->ch == ESCAPE_CHAR || *s != '\0') - return EINVAL; - - return 0; -} - -static int -_citrus_HZ_parse_graphic(void *context, const char *name, const char *s) -{ - void **p; - _HZEncodingInfo *ei; - escape_t *escape; - graphic_t *graphic; - - _DIAGASSERT(context != NULL && *context != NULL); - _DIAGASSERT(name != NULL); - _DIAGASSERT(s != NULL); - - p = (void **)context; - escape = (escape_t *)p[0]; - ei = (_HZEncodingInfo *)p[1]; - graphic = malloc(sizeof(*graphic)); - if (graphic == NULL) - return ENOMEM; - memset(graphic, 0, sizeof(*graphic)); - if (strcmp("GL", name) == 0) { - if (GL(escape) != NULL) - goto release; - GL(escape) = graphic; - } else if (strcmp("GR", name) == 0) { - if (GR(escape) != NULL) - goto release; - GR(escape) = graphic; - } else { -release: - free(graphic); - return EINVAL; - } - graphic->escape = escape; - if (_bcs_strncasecmp("ASCII", s, 5) == 0) { - if (s[5] != '\0') - return EINVAL; - graphic->charset = ASCII; - graphic->length = 1; - ei->ascii = graphic; - return 0; - } else if (_bcs_strncasecmp("GB2312", s, 6) == 0) { - if (s[6] != '\0') - return EINVAL; - graphic->charset = GB2312; - graphic->length = 2; - ei->gb2312 = graphic; - return 0; - } else if (strncmp("94*", s, 3) == 0) { - graphic->charset = CS94; - } else if (strncmp("96*", s, 3) == 0) { - graphic->charset = CS96; - } else { - return EINVAL; - } - s += 3; - switch(*s) { - case '1': case '2': case '3': - graphic->length = (size_t)(*s - '0'); - if (*++s == '\0') - break; - /*FALLTHROUGH*/ - default: - return EINVAL; - } - return 0; -} - -static const _citrus_prop_hint_t escape_hints[] = { -_CITRUS_PROP_HINT_STR("CH", &_citrus_HZ_parse_char), -_CITRUS_PROP_HINT_STR("GL", &_citrus_HZ_parse_graphic), -_CITRUS_PROP_HINT_STR("GR", &_citrus_HZ_parse_graphic), -_CITRUS_PROP_HINT_END -}; - -static int -_citrus_HZ_parse_escape(void *context, const char *name, const char *s) -{ - _HZEncodingInfo *ei; - escape_t *escape; - void *p[2]; - - _DIAGASSERT(context != NULL); - _DIAGASSERT(name != NULL); - _DIAGASSERT(s != NULL); - - ei = (_HZEncodingInfo *)context; - escape = malloc(sizeof(*escape)); - if (escape == NULL) - return EINVAL; - memset(escape, 0, sizeof(*escape)); - if (strcmp("0", name) == 0) { - escape->set = E0SET(ei); - TAILQ_INSERT_TAIL(E0SET(ei), escape, entry); - } else if (strcmp("1", name) == 0) { - escape->set = E1SET(ei); - TAILQ_INSERT_TAIL(E1SET(ei), escape, entry); - } else { - free(escape); - return EINVAL; - } - p[0] = (void *)escape; - p[1] = (void *)ei; - return _citrus_prop_parse_variable( - escape_hints, (void *)&p[0], s, strlen(s)); -} - -static const _citrus_prop_hint_t root_hints[] = { -_CITRUS_PROP_HINT_STR("0", &_citrus_HZ_parse_escape), -_CITRUS_PROP_HINT_STR("1", &_citrus_HZ_parse_escape), -_CITRUS_PROP_HINT_END -}; - -static int -_citrus_HZ_encoding_module_init(_HZEncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - int errnum; - - _DIAGASSERT(ei != NULL); - - memset(ei, 0, sizeof(*ei)); - TAILQ_INIT(E0SET(ei)); - TAILQ_INIT(E1SET(ei)); - errnum = _citrus_prop_parse_variable( - root_hints, (void *)ei, var, lenvar); - if (errnum != 0) - _citrus_HZ_encoding_module_uninit(ei); - return errnum; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(HZ); -_CITRUS_CTYPE_DEF_OPS(HZ); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(HZ); -_CITRUS_STDENC_DEF_OPS(HZ); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_hz.h b/lib/libc/citrus/modules/citrus_hz.h deleted file mode 100644 index 55435210c..000000000 --- a/lib/libc/citrus/modules/citrus_hz.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_hz.h,v 1.1 2006/11/22 23:38:27 tnozaki Exp $ */ - -/*- - * Copyright (c)2004, 2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_HZ_H_ -#define _CITRUS_HZ_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(HZ); -_CITRUS_STDENC_GETOPS_FUNC(HZ); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_iconv_none.c b/lib/libc/citrus/modules/citrus_iconv_none.c deleted file mode 100644 index 83a0ec41a..000000000 --- a/lib/libc/citrus/modules/citrus_iconv_none.c +++ /dev/null @@ -1,128 +0,0 @@ -/* $NetBSD: citrus_iconv_none.c,v 1.3 2011/05/23 14:45:44 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_iconv_none.c,v 1.3 2011/05/23 14:45:44 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_hash.h" -#include "citrus_iconv.h" -#include "citrus_iconv_none.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_ICONV_DECLS(iconv_none); -_CITRUS_ICONV_DEF_OPS(iconv_none); - - -/* ---------------------------------------------------------------------- */ - -int -_citrus_iconv_none_iconv_getops(struct _citrus_iconv_ops *ops, size_t lenops, - uint32_t expected_version) -{ - if (expected_version<_CITRUS_ICONV_ABI_VERSION || lenopsci_closure = NULL; - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_iconv_none_iconv_uninit_shared(struct _citrus_iconv_shared *ci) -{ -} - -static int -/*ARGSUSED*/ -_citrus_iconv_none_iconv_init_context(struct _citrus_iconv *cv) -{ - cv->cv_closure = NULL; - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_iconv_none_iconv_uninit_context(struct _citrus_iconv *cv) -{ -} - -static int -/*ARGSUSED*/ -_citrus_iconv_none_iconv_convert(struct _citrus_iconv * __restrict ci, - const char * __restrict * __restrict in, - size_t * __restrict inbytes, - char * __restrict * __restrict out, - size_t * __restrict outbytes, - u_int32_t flags, size_t * __restrict invalids) -{ - int e2big; - size_t len; - - len = *inbytes; - e2big = 0; - if (*outbytes -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_iconv_std.c,v 1.16 2012/02/12 13:51:29 wiz Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_region.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_iconv.h" -#include "citrus_stdenc.h" -#include "citrus_mapper.h" -#include "citrus_csmapper.h" -#include "citrus_memstream.h" -#include "citrus_iconv_std.h" -#include "citrus_esdb.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_ICONV_DECLS(iconv_std); -_CITRUS_ICONV_DEF_OPS(iconv_std); - - -/* ---------------------------------------------------------------------- */ - -int -_citrus_iconv_std_iconv_getops(struct _citrus_iconv_ops *ops, size_t lenops, - u_int32_t expected_version) -{ - if (expected_version<_CITRUS_ICONV_ABI_VERSION || lenopsse_ps) - memcpy(se->se_pssaved, se->se_ps, - _stdenc_get_state_size(se->se_handle)); -} - -static __inline void -restore_encoding_state(struct _citrus_iconv_std_encoding *se) -{ - if (se->se_ps) - memcpy(se->se_ps, se->se_pssaved, - _stdenc_get_state_size(se->se_handle)); -} - -static __inline void -init_encoding_state(struct _citrus_iconv_std_encoding *se) -{ - if (se->se_ps) - _stdenc_init_state(se->se_handle, se->se_ps); -} - -static __inline int -mbtocsx(struct _citrus_iconv_std_encoding *se, - _csid_t *csid, _index_t *idx, const char **s, size_t n, - size_t *nresult) -{ - return _stdenc_mbtocs(se->se_handle, csid, idx, s, n, se->se_ps, - nresult); -} - -static __inline int -cstombx(struct _citrus_iconv_std_encoding *se, - char *s, size_t n, _csid_t csid, _index_t idx, size_t *nresult) -{ - return _stdenc_cstomb(se->se_handle, s, n, csid, idx, se->se_ps, - nresult); -} - -static __inline int -wctombx(struct _citrus_iconv_std_encoding *se, - char *s, size_t n, _wc_t wc, size_t *nresult) -{ - return _stdenc_wctomb(se->se_handle, s, n, wc, se->se_ps, nresult); -} - -static __inline int -put_state_resetx(struct _citrus_iconv_std_encoding *se, - char *s, size_t n, size_t *nresult) -{ - return _stdenc_put_state_reset(se->se_handle, s, n, se->se_ps, nresult); -} - -static __inline int -get_state_desc_gen(struct _citrus_iconv_std_encoding *se, int *rstate) -{ - int ret; - struct _stdenc_state_desc ssd; - - ret = _stdenc_get_state_desc(se->se_handle, se->se_ps, - _STDENC_SDID_GENERIC, &ssd); - if (!ret) - *rstate = ssd.u.generic.state; - - return ret; -} - -/* - * init encoding context - */ -static int -init_encoding(struct _citrus_iconv_std_encoding *se, struct _stdenc *cs, - void *ps1, void *ps2) -{ - int ret = -1; - - se->se_handle = cs; - se->se_ps = ps1; - se->se_pssaved = ps2; - - if (se->se_ps) - ret = _stdenc_init_state(cs, se->se_ps); - if (!ret && se->se_pssaved) - ret = _stdenc_init_state(cs, se->se_pssaved); - - return ret; -} - -static int -open_csmapper(struct _csmapper **rcm, const char *src, const char *dst, - unsigned long *rnorm) -{ - int ret; - struct _csmapper *cm; - - ret = _csmapper_open(&cm, src, dst, 0, rnorm); - if (ret) - return ret; - if (_csmapper_get_src_max(cm) != 1 || _csmapper_get_dst_max(cm) != 1 || - _csmapper_get_state_size(cm) != 0) { - _csmapper_close(cm); - return EINVAL; - } - - *rcm = cm; - - return 0; -} - -static void -close_dsts(struct _citrus_iconv_std_dst_list *dl) -{ - struct _citrus_iconv_std_dst *sd; - - while ((sd=TAILQ_FIRST(dl)) != NULL) { - TAILQ_REMOVE(dl, sd, sd_entry); - _csmapper_close(sd->sd_mapper); - free(sd); - } -} - -static int -open_dsts(struct _citrus_iconv_std_dst_list *dl, - const struct _esdb_charset *ec, const struct _esdb *dbdst) -{ - int i, ret; - struct _citrus_iconv_std_dst *sd, *sdtmp; - unsigned long norm; - - sd = malloc(sizeof(*sd)); - if (sd == NULL) - return errno; - - for (i=0; idb_num_charsets; i++) { - ret = open_csmapper(&sd->sd_mapper, ec->ec_csname, - dbdst->db_charsets[i].ec_csname, &norm); - if (ret == 0) { - sd->sd_csid = dbdst->db_charsets[i].ec_csid; - sd->sd_norm = norm; - /* insert this mapper by sorted order. */ - TAILQ_FOREACH(sdtmp, dl, sd_entry) { - if (sdtmp->sd_norm > norm) { - TAILQ_INSERT_BEFORE(sdtmp, sd, - sd_entry); - sd = NULL; - break; - } - } - if (sd) - TAILQ_INSERT_TAIL(dl, sd, sd_entry); - sd = malloc(sizeof(*sd)); - if (sd == NULL) { - ret = errno; - close_dsts(dl); - return ret; - } - } else if (ret != ENOENT) { - close_dsts(dl); - free(sd); - return ret; - } - } - free(sd); - return 0; -} - -static void -close_srcs(struct _citrus_iconv_std_src_list *sl) -{ - struct _citrus_iconv_std_src *ss; - - while ((ss=TAILQ_FIRST(sl)) != NULL) { - TAILQ_REMOVE(sl, ss, ss_entry); - close_dsts(&ss->ss_dsts); - free(ss); - } -} - -static int -open_srcs(struct _citrus_iconv_std_src_list *sl, - const struct _esdb *dbsrc, const struct _esdb *dbdst) -{ - int i, ret, count = 0; - struct _citrus_iconv_std_src *ss; - - ss = malloc(sizeof(*ss)); - if (ss == NULL) - return errno; - - TAILQ_INIT(&ss->ss_dsts); - - for (i=0; idb_num_charsets; i++) { - ret = open_dsts(&ss->ss_dsts, &dbsrc->db_charsets[i], dbdst); - if (ret) - goto err; - if (!TAILQ_EMPTY(&ss->ss_dsts)) { - ss->ss_csid = dbsrc->db_charsets[i].ec_csid; - TAILQ_INSERT_TAIL(sl, ss, ss_entry); - ss = malloc(sizeof(*ss)); - if (ss == NULL) { - ret = errno; - goto err; - } - count++; - TAILQ_INIT(&ss->ss_dsts); - } - } - free(ss); - - return count ? 0 : ENOENT; - -err: - free(ss); - close_srcs(sl); - return ret; -} - -/* do convert a character */ -#define E_NO_CORRESPONDING_CHAR ENOENT /* XXX */ -static int -/*ARGSUSED*/ -do_conv(const struct _citrus_iconv_std_shared *is, - struct _citrus_iconv_std_context *sc, _csid_t *csid, _index_t *idx) -{ - _index_t tmpidx; - int ret; - struct _citrus_iconv_std_src *ss; - struct _citrus_iconv_std_dst *sd; - - TAILQ_FOREACH(ss, &is->is_srcs, ss_entry) { - if (ss->ss_csid == *csid) { - TAILQ_FOREACH(sd, &ss->ss_dsts, sd_entry) { - ret = _csmapper_convert(sd->sd_mapper, - &tmpidx, *idx, NULL); - switch (ret) { - case _MAPPER_CONVERT_SUCCESS: - *csid = sd->sd_csid; - *idx = tmpidx; - return 0; - case _MAPPER_CONVERT_NONIDENTICAL: - break; - case _MAPPER_CONVERT_SRC_MORE: - /*FALLTHROUGH*/ - case _MAPPER_CONVERT_DST_MORE: - /*FALLTHROUGH*/ - case _MAPPER_CONVERT_FATAL: - return EINVAL; - case _MAPPER_CONVERT_ILSEQ: - return EILSEQ; - } - } - break; - } - } - - return E_NO_CORRESPONDING_CHAR; -} -/* ---------------------------------------------------------------------- */ - -static int -/*ARGSUSED*/ -_citrus_iconv_std_iconv_init_shared(struct _citrus_iconv_shared *ci, - const char * __restrict curdir, - const char * __restrict src, - const char * __restrict dst, - const void * __restrict var, size_t lenvar) -{ - int ret; - struct _citrus_iconv_std_shared *is; - struct _citrus_esdb esdbsrc, esdbdst; - - is = malloc(sizeof(*is)); - if (is==NULL) { - ret = errno; - goto err0; - } - ret = _citrus_esdb_open(&esdbsrc, src); - if (ret) - goto err1; - ret = _citrus_esdb_open(&esdbdst, dst); - if (ret) - goto err2; - ret = _stdenc_open(&is->is_src_encoding, esdbsrc.db_encname, - esdbsrc.db_variable, esdbsrc.db_len_variable); - if (ret) - goto err3; - ret = _stdenc_open(&is->is_dst_encoding, esdbdst.db_encname, - esdbdst.db_variable, esdbdst.db_len_variable); - if (ret) - goto err4; - is->is_use_invalid = esdbdst.db_use_invalid; - is->is_invalid = esdbdst.db_invalid; - - TAILQ_INIT(&is->is_srcs); - ret = open_srcs(&is->is_srcs, &esdbsrc, &esdbdst); - if (ret) - goto err5; - - _esdb_close(&esdbsrc); - _esdb_close(&esdbdst); - ci->ci_closure = is; - - return 0; - -err5: - _stdenc_close(is->is_dst_encoding); -err4: - _stdenc_close(is->is_src_encoding); -err3: - _esdb_close(&esdbdst); -err2: - _esdb_close(&esdbsrc); -err1: - free(is); -err0: - return ret; -} - -static void -_citrus_iconv_std_iconv_uninit_shared(struct _citrus_iconv_shared *ci) -{ - struct _citrus_iconv_std_shared *is = ci->ci_closure; - - if (is == NULL) - return; - - _stdenc_close(is->is_src_encoding); - _stdenc_close(is->is_dst_encoding); - close_srcs(&is->is_srcs); - free(is); -} - -static int -_citrus_iconv_std_iconv_init_context(struct _citrus_iconv *cv) -{ - const struct _citrus_iconv_std_shared *is = cv->cv_shared->ci_closure; - struct _citrus_iconv_std_context *sc; - size_t szpssrc, szpsdst, sz; - char *ptr; - - szpssrc = _stdenc_get_state_size(is->is_src_encoding); - szpsdst = _stdenc_get_state_size(is->is_dst_encoding); - - sz = (szpssrc + szpsdst)*2 + sizeof(struct _citrus_iconv_std_context); - sc = malloc(sz); - if (sc == NULL) - return errno; - - ptr = (char *)&sc[1]; - if (szpssrc) - init_encoding(&sc->sc_src_encoding, is->is_src_encoding, - ptr, ptr+szpssrc); - else - init_encoding(&sc->sc_src_encoding, is->is_src_encoding, - NULL, NULL); - ptr += szpssrc*2; - if (szpsdst) - init_encoding(&sc->sc_dst_encoding, is->is_dst_encoding, - ptr, ptr+szpsdst); - else - init_encoding(&sc->sc_dst_encoding, is->is_dst_encoding, - NULL, NULL); - - cv->cv_closure = (void *)sc; - - return 0; -} - -static void -_citrus_iconv_std_iconv_uninit_context(struct _citrus_iconv *cv) -{ - free(cv->cv_closure); -} - -static int -_citrus_iconv_std_iconv_convert(struct _citrus_iconv * __restrict cv, - const char * __restrict * __restrict in, - size_t * __restrict inbytes, - char * __restrict * __restrict out, - size_t * __restrict outbytes, u_int32_t flags, - size_t * __restrict invalids) -{ - const struct _citrus_iconv_std_shared *is = cv->cv_shared->ci_closure; - struct _citrus_iconv_std_context *sc = cv->cv_closure; - _index_t idx; - _csid_t csid; - int ret, state; - size_t szrin, szrout; - size_t inval; - const char *tmpin; - - inval = 0; - if (in==NULL || *in==NULL) { - /* special cases */ - if (out!=NULL && *out!=NULL) { - /* init output state and store the shift sequence */ - save_encoding_state(&sc->sc_src_encoding); - save_encoding_state(&sc->sc_dst_encoding); - szrout = 0; - - ret = put_state_resetx(&sc->sc_dst_encoding, - *out, *outbytes, - &szrout); - if (ret) - goto err; - - if (szrout == (size_t)-2) { - /* too small to store the character */ - ret = EINVAL; - goto err; - } - *out += szrout; - *outbytes -= szrout; - } else - /* otherwise, discard the shift sequence */ - init_encoding_state(&sc->sc_dst_encoding); - init_encoding_state(&sc->sc_src_encoding); - *invalids = 0; - return 0; - } - - /* normal case */ - for (;;) { - if (*inbytes==0) { - ret = get_state_desc_gen(&sc->sc_src_encoding, &state); - if (state == _STDENC_SDGEN_INITIAL || - state == _STDENC_SDGEN_STABLE) - break; - } - - /* save the encoding states for the error recovery */ - save_encoding_state(&sc->sc_src_encoding); - save_encoding_state(&sc->sc_dst_encoding); - - /* mb -> csid/index */ - tmpin = *in; - szrin = szrout = 0; - ret = mbtocsx(&sc->sc_src_encoding, &csid, &idx, - &tmpin, *inbytes, &szrin); - if (ret) - goto err; - - if (szrin == (size_t)-2) { - /* incompleted character */ - ret = get_state_desc_gen(&sc->sc_src_encoding, &state); - if (ret) { - ret = EINVAL; - goto err; - } - switch (state) { - case _STDENC_SDGEN_INITIAL: - case _STDENC_SDGEN_STABLE: - /* fetch shift sequences only. */ - goto next; - } - ret = EINVAL; - goto err; - } - /* convert the character */ - ret = do_conv(is, sc, &csid, &idx); - if (ret) { - if (ret == E_NO_CORRESPONDING_CHAR) { - inval++; - szrout = 0; - if ((flags&_CITRUS_ICONV_F_HIDE_INVALID)==0 && - is->is_use_invalid) { - ret = wctombx(&sc->sc_dst_encoding, - *out, *outbytes, - is->is_invalid, - &szrout); - if (ret) - goto err; - } - goto next; - } else { - goto err; - } - } - /* csid/index -> mb */ - ret = cstombx(&sc->sc_dst_encoding, - *out, *outbytes, csid, idx, &szrout); - if (ret) - goto err; -next: - _DIAGASSERT(*inbytes>=szrin && *outbytes>=szrout); - *inbytes -= tmpin-*in; /* szrin is insufficient on \0. */ - *in = tmpin; - *outbytes -= szrout; - *out += szrout; - } - *invalids = inval; - - return 0; - -err: - restore_encoding_state(&sc->sc_src_encoding); - restore_encoding_state(&sc->sc_dst_encoding); -err_norestore: - *invalids = inval; - - return ret; -} diff --git a/lib/libc/citrus/modules/citrus_iconv_std.h b/lib/libc/citrus/modules/citrus_iconv_std.h deleted file mode 100644 index c1d43018a..000000000 --- a/lib/libc/citrus/modules/citrus_iconv_std.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_iconv_std.h,v 1.1 2003/06/25 09:51:44 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ICONV_STD_H_ -#define _CITRUS_ICONV_STD_H_ - -#include "citrus_iconv_std_local.h" - -_CITRUS_ICONV_GETOPS_FUNC(iconv_std); - -#endif diff --git a/lib/libc/citrus/modules/citrus_iconv_std_local.h b/lib/libc/citrus/modules/citrus_iconv_std_local.h deleted file mode 100644 index 4b0f583dd..000000000 --- a/lib/libc/citrus/modules/citrus_iconv_std_local.h +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: citrus_iconv_std_local.h,v 1.2 2003/07/01 09:42:16 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ICONV_STD_LOCAL_H_ -#define _CITRUS_ICONV_STD_LOCAL_H_ - -/* - * encoding - */ -struct _citrus_iconv_std_encoding { - struct _citrus_stdenc *se_handle; - void *se_ps; - void *se_pssaved; -}; - -/* - * dst - */ -struct _citrus_iconv_std_dst { - TAILQ_ENTRY(_citrus_iconv_std_dst) sd_entry; - _citrus_csid_t sd_csid; - unsigned long sd_norm; - struct _citrus_csmapper *sd_mapper; -}; -TAILQ_HEAD(_citrus_iconv_std_dst_list, _citrus_iconv_std_dst); - -/* - * src - */ -struct _citrus_iconv_std_src { - TAILQ_ENTRY(_citrus_iconv_std_src) ss_entry; - _citrus_csid_t ss_csid; - struct _citrus_iconv_std_dst_list ss_dsts; -}; -TAILQ_HEAD(_citrus_iconv_std_src_list, _citrus_iconv_std_src); - -/* - * iconv_std handle - */ -struct _citrus_iconv_std_shared { - struct _citrus_stdenc *is_src_encoding; - struct _citrus_stdenc *is_dst_encoding; - struct _citrus_iconv_std_src_list is_srcs; - int is_use_invalid; - _citrus_wc_t is_invalid; -}; - -/* - * iconv_std context - */ -struct _citrus_iconv_std_context { - struct _citrus_iconv_std_encoding sc_src_encoding; - struct _citrus_iconv_std_encoding sc_dst_encoding; -}; - -#endif diff --git a/lib/libc/citrus/modules/citrus_iso2022.c b/lib/libc/citrus/modules/citrus_iso2022.c deleted file mode 100644 index 0b3a0a801..000000000 --- a/lib/libc/citrus/modules/citrus_iso2022.c +++ /dev/null @@ -1,1349 +0,0 @@ -/* $NetBSD: citrus_iso2022.c,v 1.23 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)1999, 2002 Citrus Project, - * 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. - * - * $Citrus: xpg4dl/FreeBSD/lib/libc/locale/iso2022.c,v 1.23 2001/06/21 01:51:44 yamt Exp $ - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_iso2022.c,v 1.23 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_iso2022.h" - - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - - -/* - * wchar_t mappings: - * ASCII (ESC ( B) 00000000 00000000 00000000 0xxxxxxx - * iso-8859-1 (ESC , A) 00000000 00000000 00000000 1xxxxxxx - * 94 charset (ESC ( F) 0fffffff 00000000 00000000 0xxxxxxx - * 94 charset (ESC ( M F) 0fffffff 1mmmmmmm 00000000 0xxxxxxx - * 96 charset (ESC , F) 0fffffff 00000000 00000000 1xxxxxxx - * 96 charset (ESC , M F) 0fffffff 1mmmmmmm 00000000 1xxxxxxx - * 94x94 charset (ESC $ ( F) 0fffffff 00000000 0xxxxxxx 0xxxxxxx - * 96x96 charset (ESC $ , F) 0fffffff 00000000 0xxxxxxx 1xxxxxxx - * 94x94 charset (ESC & V ESC $ ( F) - * 0fffffff 1vvvvvvv 0xxxxxxx 0xxxxxxx - * 94x94x94 charset (ESC $ ( F) 0fffffff 0xxxxxxx 0xxxxxxx 0xxxxxxx - * 96x96x96 charset (ESC $ , F) 0fffffff 0xxxxxxx 0xxxxxxx 1xxxxxxx - * reserved for UCS4 co-existence (UCS4 is 31bit encoding thanks to mohta bit) - * 1xxxxxxx xxxxxxxx xxxxxxxx xxxxxxxx - */ - -typedef struct { - u_char type; -#define CS94 (0U) -#define CS96 (1U) -#define CS94MULTI (2U) -#define CS96MULTI (3U) - - u_char final; - u_char interm; - u_char vers; -} _ISO2022Charset; - -static const _ISO2022Charset ascii = { CS94, 'B', '\0', '\0' }; -static const _ISO2022Charset iso88591 = { CS96, 'A', '\0', '\0' }; - -typedef struct { - _ISO2022Charset g[4]; - /* need 3 bits to hold -1, 0, ..., 3 */ - int gl:3, - gr:3, - singlegl:3, - singlegr:3; - char ch[7]; /* longest escape sequence (ESC & V ESC $ ( F) */ - int chlen; - int flags; -#define _ISO2022STATE_FLAG_INITIALIZED 1 -} _ISO2022State; - -typedef struct { - _ISO2022Charset *recommend[4]; - size_t recommendsize[4]; - _ISO2022Charset initg[4]; - int maxcharset; - int flags; -#define F_8BIT 0x0001 -#define F_NOOLD 0x0002 -#define F_SI 0x0010 /*0F*/ -#define F_SO 0x0020 /*0E*/ -#define F_LS0 0x0010 /*0F*/ -#define F_LS1 0x0020 /*0E*/ -#define F_LS2 0x0040 /*ESC n*/ -#define F_LS3 0x0080 /*ESC o*/ -#define F_LS1R 0x0100 /*ESC ~*/ -#define F_LS2R 0x0200 /*ESC }*/ -#define F_LS3R 0x0400 /*ESC |*/ -#define F_SS2 0x0800 /*ESC N*/ -#define F_SS3 0x1000 /*ESC O*/ -#define F_SS2R 0x2000 /*8E*/ -#define F_SS3R 0x4000 /*8F*/ -} _ISO2022EncodingInfo; -typedef struct { - _ISO2022EncodingInfo ei; - struct { - /* for future multi-locale facility */ - _ISO2022State s_mblen; - _ISO2022State s_mbrlen; - _ISO2022State s_mbrtowc; - _ISO2022State s_mbtowc; - _ISO2022State s_mbsrtowcs; - _ISO2022State s_mbsnrtowcs; - _ISO2022State s_wcrtomb; - _ISO2022State s_wcsrtombs; - _ISO2022State s_wcsnrtombs; - _ISO2022State s_wctomb; - } states; -} _ISO2022CTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_ISO2022_##m -#define _ENCODING_INFO _ISO2022EncodingInfo -#define _CTYPE_INFO _ISO2022CTypeInfo -#define _ENCODING_STATE _ISO2022State -#define _ENCODING_MB_CUR_MAX(_ei_) MB_LEN_MAX -#define _ENCODING_IS_STATE_DEPENDENT 1 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) \ - (!((_ps_)->flags & _ISO2022STATE_FLAG_INITIALIZED)) - - -#define _ISO2022INVALID (wchar_t)-1 - -static __inline int isc0(__uint8_t x) { return ((x & 0x1f) == x); } -static __inline int isc1(__uint8_t x) { return (0x80 <= x && x <= 0x9f); } -static __inline int iscntl(__uint8_t x) { return (isc0(x) || isc1(x) || x == 0x7f); } -static __inline int is94(__uint8_t x) { return (0x21 <= x && x <= 0x7e); } -static __inline int is96(__uint8_t x) { return (0x20 <= x && x <= 0x7f); } -static __inline int isecma(__uint8_t x) { return (0x30 <= x && x <= 0x7f); } -static __inline int isinterm(__uint8_t x) { return (0x20 <= x && x <= 0x2f); } -static __inline int isthree(__uint8_t x) { return (0x60 <= x && x <= 0x6f); } - -static __inline int -getcs(const char * __restrict p, _ISO2022Charset * __restrict cs) -{ - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - if (!strncmp(p, "94$", 3) && p[3] && !p[4]) { - cs->final = (u_char)(p[3] & 0xff); - cs->interm = '\0'; - cs->vers = '\0'; - cs->type = CS94MULTI; - } else if (!strncmp(p, "96$", 3) && p[3] && !p[4]) { - cs->final = (u_char)(p[3] & 0xff); - cs->interm = '\0'; - cs->vers = '\0'; - cs->type = CS96MULTI; - } else if (!strncmp(p, "94", 2) && p[2] && !p[3]) { - cs->final = (u_char)(p[2] & 0xff); - cs->interm = '\0'; - cs->vers = '\0'; - cs->type = CS94; - } else if (!strncmp(p, "96", 2) && p[2] && !p[3]) { - cs->final = (u_char )(p[2] & 0xff); - cs->interm = '\0'; - cs->vers = '\0'; - cs->type = CS96; - } else { - return 1; - } - - return 0; -} - - -#define _NOTMATCH 0 -#define _MATCH 1 -#define _PARSEFAIL 2 - -static __inline int -get_recommend(_ISO2022EncodingInfo * __restrict ei, - const char * __restrict token) -{ - int i; - _ISO2022Charset cs, *p; - - if (!strchr("0123", token[0]) || token[1] != '=') - return (_NOTMATCH); - - if (getcs(&token[2], &cs) == 0) - ; - else if (!strcmp(&token[2], "94")) { - cs.final = (u_char)(token[4]); - cs.interm = '\0'; - cs.vers = '\0'; - cs.type = CS94; - } else if (!strcmp(&token[2], "96")) { - cs.final = (u_char)(token[4]); - cs.interm = '\0'; - cs.vers = '\0'; - cs.type = CS96; - } else if (!strcmp(&token[2], "94$")) { - cs.final = (u_char)(token[5]); - cs.interm = '\0'; - cs.vers = '\0'; - cs.type = CS94MULTI; - } else if (!strcmp(&token[2], "96$")) { - cs.final = (u_char)(token[5]); - cs.interm = '\0'; - cs.vers = '\0'; - cs.type = CS96MULTI; - } else { - return (_PARSEFAIL); - } - - i = token[0] - '0'; - if (!ei->recommend[i]) { - ei->recommend[i] = malloc(sizeof(_ISO2022Charset)); - } else { - p = realloc(ei->recommend[i], - sizeof(_ISO2022Charset) * (ei->recommendsize[i] + 1)); - if (!p) - return (_PARSEFAIL); - ei->recommend[i] = p; - } - if (!ei->recommend[i]) - return (_PARSEFAIL); - ei->recommendsize[i]++; - - (ei->recommend[i] + (ei->recommendsize[i] - 1))->final = cs.final; - (ei->recommend[i] + (ei->recommendsize[i] - 1))->interm = cs.interm; - (ei->recommend[i] + (ei->recommendsize[i] - 1))->vers = cs.vers; - (ei->recommend[i] + (ei->recommendsize[i] - 1))->type = cs.type; - - return (_MATCH); -} - -static __inline int -get_initg(_ISO2022EncodingInfo * __restrict ei, - const char * __restrict token) -{ - _ISO2022Charset cs; - - if (strncmp("INIT", &token[0], 4) || - !strchr("0123", token[4]) || - token[5] != '=') - return (_NOTMATCH); - - if (getcs(&token[6], &cs) != 0) - return (_PARSEFAIL); - - ei->initg[token[4] - '0'].type = cs.type; - ei->initg[token[4] - '0'].final = cs.final; - ei->initg[token[4] - '0'].interm = cs.interm; - ei->initg[token[4] - '0'].vers = cs.vers; - - return (_MATCH); -} - -static __inline int -get_max(_ISO2022EncodingInfo * __restrict ei, - const char * __restrict token) -{ - if (!strcmp(token, "MAX1")) { - ei->maxcharset = 1; - } else if (!strcmp(token, "MAX2")) { - ei->maxcharset = 2; - } else if (!strcmp(token, "MAX3")) { - ei->maxcharset = 3; - } else - return (_NOTMATCH); - - return (_MATCH); -} - - -static __inline int -get_flags(_ISO2022EncodingInfo * __restrict ei, - const char * __restrict token) -{ - int i; - static struct { - const char *tag; - int flag; - } const tags[] = { - { "DUMMY", 0 }, - { "8BIT", F_8BIT }, - { "NOOLD", F_NOOLD }, - { "SI", F_SI }, - { "SO", F_SO }, - { "LS0", F_LS0 }, - { "LS1", F_LS1 }, - { "LS2", F_LS2 }, - { "LS3", F_LS3 }, - { "LS1R", F_LS1R }, - { "LS2R", F_LS2R }, - { "LS3R", F_LS3R }, - { "SS2", F_SS2 }, - { "SS3", F_SS3 }, - { "SS2R", F_SS2R }, - { "SS3R", F_SS3R }, - { NULL, 0 } - }; - - for (i = 0; tags[i].tag; i++) { - if (!strcmp(token, tags[i].tag)) { - ei->flags |= tags[i].flag; - return (_MATCH); - } - } - - return (_NOTMATCH); -} - - -static __inline int -_citrus_ISO2022_parse_variable(_ISO2022EncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - char const *v, *e; - char buf[20]; - int i, len, ret; - - _DIAGASSERT(ei != NULL); - - - /* - * parse VARIABLE section. - */ - - if (!var) - return (EFTYPE); - - v = (const char *) var; - - /* initialize structure */ - ei->maxcharset = 0; - for (i = 0; i < 4; i++) { - ei->recommend[i] = NULL; - ei->recommendsize[i] = 0; - } - ei->flags = 0; - - while (*v) { - while (*v == ' ' || *v == '\t') - ++v; - - /* find the token */ - e = v; - while (*e && *e != ' ' && *e != '\t') - ++e; - - len = e-v; - if (len == 0) - break; - if (len>=sizeof(buf)) - goto parsefail; - snprintf(buf, sizeof(buf), "%.*s", len, v); - - if ((ret = get_recommend(ei, buf)) != _NOTMATCH) - ; - else if ((ret = get_initg(ei, buf)) != _NOTMATCH) - ; - else if ((ret = get_max(ei, buf)) != _NOTMATCH) - ; - else if ((ret = get_flags(ei, buf)) != _NOTMATCH) - ; - else - ret = _PARSEFAIL; - if (ret==_PARSEFAIL) - goto parsefail; - v = e; - - } - - return (0); - -parsefail: - free(ei->recommend[0]); - free(ei->recommend[1]); - free(ei->recommend[2]); - free(ei->recommend[3]); - - return (EFTYPE); -} - -static __inline void -/*ARGSUSED*/ -_citrus_ISO2022_init_state(_ISO2022EncodingInfo * __restrict ei, - _ISO2022State * __restrict s) -{ - int i; - - memset(s, 0, sizeof(*s)); - s->gl = 0; - s->gr = (ei->flags & F_8BIT) ? 1 : -1; - - for (i = 0; i < 4; i++) { - if (ei->initg[i].final) { - s->g[i].type = ei->initg[i].type; - s->g[i].final = ei->initg[i].final; - s->g[i].interm = ei->initg[i].interm; - } - } - s->singlegl = s->singlegr = -1; - s->flags |= _ISO2022STATE_FLAG_INITIALIZED; -} - -static __inline void -/*ARGSUSED*/ -_citrus_ISO2022_pack_state(_ISO2022EncodingInfo * __restrict ei, - void * __restrict pspriv, - const _ISO2022State * __restrict s) -{ - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_ISO2022_unpack_state(_ISO2022EncodingInfo * __restrict ei, - _ISO2022State * __restrict s, - const void * __restrict pspriv) -{ - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static int -/*ARGSUSED*/ -_citrus_ISO2022_encoding_module_init(_ISO2022EncodingInfo * __restrict ei, - const void * __restrict var, - size_t lenvar) -{ - - _DIAGASSERT(ei != NULL); - - return _citrus_ISO2022_parse_variable(ei, var, lenvar); -} - -static void -/*ARGSUSED*/ -_citrus_ISO2022_encoding_module_uninit(_ISO2022EncodingInfo *ei) -{ -} - -#define ESC '\033' -#define ECMA -1 -#define INTERM -2 -#define OECMA -3 -static const struct seqtable { - int type; - int csoff; - int finaloff; - int intermoff; - int versoff; - int len; - int chars[10]; -} seqtable[] = { - /* G0 94MULTI special */ - { CS94MULTI, -1, 2, -1, -1, 3, { ESC, '$', OECMA }, }, - /* G0 94MULTI special with version identification */ - { CS94MULTI, -1, 5, -1, 2, 6, { ESC, '&', ECMA, ESC, '$', OECMA }, }, - /* G? 94 */ - { CS94, 1, 2, -1, -1, 3, { ESC, CS94, ECMA, }, }, - /* G? 94 with 2nd intermediate char */ - { CS94, 1, 3, 2, -1, 4, { ESC, CS94, INTERM, ECMA, }, }, - /* G? 96 */ - { CS96, 1, 2, -1, -1, 3, { ESC, CS96, ECMA, }, }, - /* G? 96 with 2nd intermediate char */ - { CS96, 1, 3, 2, -1, 4, { ESC, CS96, INTERM, ECMA, }, }, - /* G? 94MULTI */ - { CS94MULTI, 2, 3, -1, -1, 4, { ESC, '$', CS94, ECMA, }, }, - /* G? 96MULTI */ - { CS96MULTI, 2, 3, -1, -1, 4, { ESC, '$', CS96, ECMA, }, }, - /* G? 94MULTI with version specification */ - { CS94MULTI, 5, 6, -1, 2, 7, { ESC, '&', ECMA, ESC, '$', CS94, ECMA, }, }, - /* LS2/3 */ - { -1, -1, -1, -1, -1, 2, { ESC, 'n', }, }, - { -1, -1, -1, -1, -1, 2, { ESC, 'o', }, }, - /* LS1/2/3R */ - { -1, -1, -1, -1, -1, 2, { ESC, '~', }, }, - { -1, -1, -1, -1, -1, 2, { ESC, /*{*/ '}', }, }, - { -1, -1, -1, -1, -1, 2, { ESC, '|', }, }, - /* SS2/3 */ - { -1, -1, -1, -1, -1, 2, { ESC, 'N', }, }, - { -1, -1, -1, -1, -1, 2, { ESC, 'O', }, }, - /* end of records */ - { 0, } -}; - -static int -seqmatch(const char * __restrict s, size_t n, - const struct seqtable * __restrict sp) -{ - const int *p; - - _DIAGASSERT(s != NULL); - _DIAGASSERT(sp != NULL); - - p = sp->chars; - while (p - sp->chars < n && p - sp->chars < sp->len) { - switch (*p) { - case ECMA: - if (!isecma(*s)) - goto terminate; - break; - case OECMA: - if (*s && strchr("@AB", *s)) - break; - else - goto terminate; - case INTERM: - if (!isinterm(*s)) - goto terminate; - break; - case CS94: - if (*s && strchr("()*+", *s)) - break; - else - goto terminate; - case CS96: - if (*s && strchr(",-./", *s)) - break; - else - goto terminate; - default: - if (*s != *p) - goto terminate; - break; - } - - p++; - s++; - } - -terminate: - return p - sp->chars; -} - -static wchar_t -_ISO2022_sgetwchar(_ISO2022EncodingInfo * __restrict ei, - const char * __restrict string, size_t n, - const char ** __restrict result, - _ISO2022State * __restrict psenc) -{ - wchar_t wchar = 0; - int cur; - const struct seqtable *sp; - int nmatch; - int i; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(string != NULL); - /* result may be NULL */ - - while (1) { - /* SI/SO */ - if (1 <= n && string[0] == '\017') { - psenc->gl = 0; - string++; - n--; - continue; - } - if (1 <= n && string[0] == '\016') { - psenc->gl = 1; - string++; - n--; - continue; - } - - /* SS2/3R */ - if (1 <= n && string[0] && strchr("\217\216", string[0])) { - psenc->singlegl = psenc->singlegr = - (string[0] - '\216') + 2; - string++; - n--; - continue; - } - - /* eat the letter if this is not ESC */ - if (1 <= n && string[0] != '\033') - break; - - /* look for a perfect match from escape sequences */ - for (sp = &seqtable[0]; sp->len; sp++) { - nmatch = seqmatch(string, n, sp); - if (sp->len == nmatch && n >= sp->len) - break; - } - - if (!sp->len) - goto notseq; - - if (sp->type != -1) { - if (sp->csoff == -1) - i = 0; - else { - switch (sp->type) { - case CS94: - case CS94MULTI: - i = string[sp->csoff] - '('; - break; - case CS96: - case CS96MULTI: - i = string[sp->csoff] - ','; - break; - default: - return (_ISO2022INVALID); - } - } - psenc->g[i].type = sp->type; - psenc->g[i].final = '\0'; - psenc->g[i].interm = '\0'; - psenc->g[i].vers = '\0'; - /* sp->finaloff must not be -1 */ - if (sp->finaloff != -1) - psenc->g[i].final = string[sp->finaloff]; - if (sp->intermoff != -1) - psenc->g[i].interm = string[sp->intermoff]; - if (sp->versoff != -1) - psenc->g[i].vers = string[sp->versoff]; - - string += sp->len; - n -= sp->len; - continue; - } - - /* LS2/3 */ - if (2 <= n && string[0] == '\033' - && string[1] && strchr("no", string[1])) { - psenc->gl = string[1] - 'n' + 2; - string += 2; - n -= 2; - continue; - } - - /* LS1/2/3R */ - /* XXX: { for vi showmatch */ - if (2 <= n && string[0] == '\033' - && string[1] && strchr("~}|", string[1])) { - psenc->gr = 3 - (string[1] - '|'); - string += 2; - n -= 2; - continue; - } - - /* SS2/3 */ - if (2 <= n && string[0] == '\033' - && string[1] && strchr("NO", string[1])) { - psenc->singlegl = (string[1] - 'N') + 2; - string += 2; - n -= 2; - continue; - } - - notseq: - /* - * if we've got an unknown escape sequence, eat the ESC at the - * head. otherwise, wait till full escape sequence comes. - */ - for (sp = &seqtable[0]; sp->len; sp++) { - nmatch = seqmatch(string, n, sp); - if (!nmatch) - continue; - - /* - * if we are in the middle of escape sequence, - * we still need to wait for more characters to come - */ - if (n < sp->len) { - if (nmatch == n) { - if (result) - *result = string; - return (_ISO2022INVALID); - } - } else { - if (nmatch == sp->len) { - /* this case should not happen */ - goto eat; - } - } - } - - break; - } - -eat: - /* no letter to eat */ - if (n < 1) { - if (result) - *result = string; - return (_ISO2022INVALID); - } - - /* normal chars. always eat C0/C1 as is. */ - if (iscntl(*string & 0xff)) - cur = -1; - else if (*string & 0x80) { - cur = (psenc->singlegr == -1) - ? psenc->gr : psenc->singlegr; - } else { - cur = (psenc->singlegl == -1) - ? psenc->gl : psenc->singlegl; - } - - if (cur == -1) { -asis: - wchar = *string++ & 0xff; - if (result) - *result = string; - /* reset single shift state */ - psenc->singlegr = psenc->singlegl = -1; - return wchar; - } - - /* length error check */ - switch (psenc->g[cur].type) { - case CS94MULTI: - case CS96MULTI: - if (!isthree(psenc->g[cur].final)) { - if (2 <= n - && (string[0] & 0x80) == (string[1] & 0x80)) - break; - } else { - if (3 <= n - && (string[0] & 0x80) == (string[1] & 0x80) - && (string[0] & 0x80) == (string[2] & 0x80)) - break; - } - - /* we still need to wait for more characters to come */ - if (result) - *result = string; - return (_ISO2022INVALID); - - case CS94: - case CS96: - if (1 <= n) - break; - - /* we still need to wait for more characters to come */ - if (result) - *result = string; - return (_ISO2022INVALID); - } - - /* range check */ - switch (psenc->g[cur].type) { - case CS94: - if (!(is94(string[0] & 0x7f))) - goto asis; - case CS96: - if (!(is96(string[0] & 0x7f))) - goto asis; - break; - case CS94MULTI: - if (!(is94(string[0] & 0x7f) && is94(string[1] & 0x7f))) - goto asis; - break; - case CS96MULTI: - if (!(is96(string[0] & 0x7f) && is96(string[1] & 0x7f))) - goto asis; - break; - } - - /* extract the character. */ - switch (psenc->g[cur].type) { - case CS94: - /* special case for ASCII. */ - if (psenc->g[cur].final == 'B' && !psenc->g[cur].interm) { - wchar = *string++; - wchar &= 0x7f; - break; - } - wchar = psenc->g[cur].final; - wchar = (wchar << 8); - wchar |= (psenc->g[cur].interm ? (0x80 | psenc->g[cur].interm) : 0); - wchar = (wchar << 8); - wchar = (wchar << 8) | (*string++ & 0x7f); - break; - case CS96: - /* special case for ISO-8859-1. */ - if (psenc->g[cur].final == 'A' && !psenc->g[cur].interm) { - wchar = *string++; - wchar &= 0x7f; - wchar |= 0x80; - break; - } - wchar = psenc->g[cur].final; - wchar = (wchar << 8); - wchar |= (psenc->g[cur].interm ? (0x80 | psenc->g[cur].interm) : 0); - wchar = (wchar << 8); - wchar = (wchar << 8) | (*string++ & 0x7f); - wchar |= 0x80; - break; - case CS94MULTI: - case CS96MULTI: - wchar = psenc->g[cur].final; - wchar = (wchar << 8); - if (isthree(psenc->g[cur].final)) - wchar |= (*string++ & 0x7f); - wchar = (wchar << 8) | (*string++ & 0x7f); - wchar = (wchar << 8) | (*string++ & 0x7f); - if (psenc->g[cur].type == CS96MULTI) - wchar |= 0x80; - break; - } - - if (result) - *result = string; - /* reset single shift state */ - psenc->singlegr = psenc->singlegl = -1; - return wchar; -} - - - -static int -_citrus_ISO2022_mbrtowc_priv(_ISO2022EncodingInfo * __restrict ei, - wchar_t * __restrict pwc, - const char ** __restrict s, - size_t n, _ISO2022State * __restrict psenc, - size_t * __restrict nresult) -{ - wchar_t wchar; - const char *s0, *p, *result; - int c; - int chlenbak; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL); - - if (*s == NULL) { - _citrus_ISO2022_init_state(ei, psenc); - *nresult = _ENCODING_IS_STATE_DEPENDENT; - return 0; - } - s0 = *s; - c = 0; - chlenbak = psenc->chlen; - - /* - * if we have something in buffer, use that. - * otherwise, skip here - */ - if (psenc->chlen < 0 || psenc->chlen > sizeof(psenc->ch)) { - /* illgeal state */ - _citrus_ISO2022_init_state(ei, psenc); - goto encoding_error; - } - if (psenc->chlen == 0) - goto emptybuf; - - /* buffer is not empty */ - p = psenc->ch; - while (psenc->chlen < sizeof(psenc->ch)) { - if (n > 0) { - psenc->ch[psenc->chlen++] = *s0++; - n--; - } - - wchar = _ISO2022_sgetwchar(ei, p, psenc->chlen - (p-psenc->ch), - &result, psenc); - c += result - p; - if (wchar != _ISO2022INVALID) { - if (psenc->chlen > c) - memmove(psenc->ch, result, psenc->chlen - c); - if (psenc->chlen < c) - psenc->chlen = 0; - else - psenc->chlen -= c; - goto output; - } - - if (n == 0) { - if ((result - p) == psenc->chlen) - /* complete shift sequence. */ - psenc->chlen = 0; - goto restart; - } - - p = result; - } - - /* escape sequence too long? */ - goto encoding_error; - -emptybuf: - wchar = _ISO2022_sgetwchar(ei, s0, n, &result, psenc); - if (wchar != _ISO2022INVALID) { - c += result - s0; - psenc->chlen = 0; - s0 = result; - goto output; - } - if (result > s0) { - c += (result - s0); - n -= (result - s0); - s0 = result; - if (n>0) - goto emptybuf; - /* complete shift sequence. */ - goto restart; - } - n += c; - if (n < sizeof(psenc->ch)) { - memcpy(psenc->ch, s0 - c, n); - psenc->chlen = n; - s0 = result; - goto restart; - } - - /* escape sequence too long? */ - -encoding_error: - psenc->chlen = 0; - *nresult = (size_t)-1; - return (EILSEQ); - -output: - *s = s0; - if (pwc) - *pwc = wchar; - - if (!wchar) - *nresult = 0; - else - *nresult = c - chlenbak; - - return (0); - -restart: - *s = s0; - *nresult = (size_t)-2; - - return (0); -} - -static int -recommendation(_ISO2022EncodingInfo * __restrict ei, - _ISO2022Charset * __restrict cs) -{ - int i, j; - _ISO2022Charset *recommend; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(cs != NULL); - - /* first, try a exact match. */ - for (i = 0; i < 4; i++) { - recommend = ei->recommend[i]; - for (j = 0; j < ei->recommendsize[i]; j++) { - if (cs->type != recommend[j].type) - continue; - if (cs->final != recommend[j].final) - continue; - if (cs->interm != recommend[j].interm) - continue; - - return i; - } - } - - /* then, try a wildcard match over final char. */ - for (i = 0; i < 4; i++) { - recommend = ei->recommend[i]; - for (j = 0; j < ei->recommendsize[i]; j++) { - if (cs->type != recommend[j].type) - continue; - if (cs->final && (cs->final != recommend[j].final)) - continue; - if (cs->interm && (cs->interm != recommend[j].interm)) - continue; - - return i; - } - } - - /* there's no recommendation. make a guess. */ - if (ei->maxcharset == 0) { - return 0; - } else { - switch (cs->type) { - case CS94: - case CS94MULTI: - return 0; - case CS96: - case CS96MULTI: - return 1; - } - } - return 0; -} - -static int -_ISO2022_sputwchar(_ISO2022EncodingInfo * __restrict ei, wchar_t wc, - char * __restrict string, size_t n, - char ** __restrict result, - _ISO2022State * __restrict psenc, - size_t * __restrict nresult) -{ - int i = 0; - size_t len; - _ISO2022Charset cs; - char *p; - char tmp[MB_LEN_MAX]; - int target; - u_char mask; - int bit8; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(string != NULL); - /* result may be NULL */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (isc0(wc & 0xff)) { - /* go back to INIT0 or ASCII on control chars */ - cs = ei->initg[0].final ? ei->initg[0] : ascii; - } else if (isc1(wc & 0xff)) { - /* go back to INIT1 or ISO-8859-1 on control chars */ - cs = ei->initg[1].final ? ei->initg[1] : iso88591; - } else if (!(wc & ~0xff)) { - if (wc & 0x80) { - /* special treatment for ISO-8859-1 */ - cs = iso88591; - } else { - /* special treatment for ASCII */ - cs = ascii; - } - } else { - cs.final = (wc >> 24) & 0x7f; - if ((wc >> 16) & 0x80) - cs.interm = (wc >> 16) & 0x7f; - else - cs.interm = '\0'; - if (wc & 0x80) - cs.type = (wc & 0x00007f00) ? CS96MULTI : CS96; - else - cs.type = (wc & 0x00007f00) ? CS94MULTI : CS94; - } - target = recommendation(ei, &cs); - p = tmp; - bit8 = ei->flags & F_8BIT; - - /* designate the charset onto the target plane(G0/1/2/3). */ - if (psenc->g[target].type == cs.type - && psenc->g[target].final == cs.final - && psenc->g[target].interm == cs.interm) - goto planeok; - - *p++ = '\033'; - if (cs.type == CS94MULTI || cs.type == CS96MULTI) - *p++ = '$'; - if (target == 0 && cs.type == CS94MULTI && strchr("@AB", cs.final) - && !cs.interm && !(ei->flags & F_NOOLD)) - ; - else if (cs.type == CS94 || cs.type == CS94MULTI) - *p++ = "()*+"[target]; - else - *p++ = ",-./"[target]; - if (cs.interm) - *p++ = cs.interm; - *p++ = cs.final; - - psenc->g[target].type = cs.type; - psenc->g[target].final = cs.final; - psenc->g[target].interm = cs.interm; - -planeok: - /* invoke the plane onto GL or GR. */ - if (psenc->gl == target) - goto sideok; - if (bit8 && psenc->gr == target) - goto sideok; - - if (target == 0 && (ei->flags & F_LS0)) { - *p++ = '\017'; - psenc->gl = 0; - } else if (target == 1 && (ei->flags & F_LS1)) { - *p++ = '\016'; - psenc->gl = 1; - } else if (target == 2 && (ei->flags & F_LS2)) { - *p++ = '\033'; - *p++ = 'n'; - psenc->gl = 2; - } else if (target == 3 && (ei->flags & F_LS3)) { - *p++ = '\033'; - *p++ = 'o'; - psenc->gl = 3; - } else if (bit8 && target == 1 && (ei->flags & F_LS1R)) { - *p++ = '\033'; - *p++ = '~'; - psenc->gr = 1; - } else if (bit8 && target == 2 && (ei->flags & F_LS2R)) { - *p++ = '\033'; - /*{*/ - *p++ = '}'; - psenc->gr = 2; - } else if (bit8 && target == 3 && (ei->flags & F_LS3R)) { - *p++ = '\033'; - *p++ = '|'; - psenc->gr = 3; - } else if (target == 2 && (ei->flags & F_SS2)) { - *p++ = '\033'; - *p++ = 'N'; - psenc->singlegl = 2; - } else if (target == 3 && (ei->flags & F_SS3)) { - *p++ = '\033'; - *p++ = 'O'; - psenc->singlegl = 3; - } else if (bit8 && target == 2 && (ei->flags & F_SS2R)) { - *p++ = '\216'; - *p++ = 'N'; - psenc->singlegl = psenc->singlegr = 2; - } else if (bit8 && target == 3 && (ei->flags & F_SS3R)) { - *p++ = '\217'; - *p++ = 'O'; - psenc->singlegl = psenc->singlegr = 3; - } else - goto ilseq; - -sideok: - if (psenc->singlegl == target) - mask = 0x00; - else if (psenc->singlegr == target) - mask = 0x80; - else if (psenc->gl == target) - mask = 0x00; - else if ((ei->flags & F_8BIT) && psenc->gr == target) - mask = 0x80; - else - goto ilseq; - - switch (cs.type) { - case CS94: - case CS96: - i = 1; - break; - case CS94MULTI: - case CS96MULTI: - i = !iscntl(wc & 0xff) ? - (isthree(cs.final) ? 3 : 2) : 1; - break; - } - while (i-- > 0) - *p++ = ((wc >> (i << 3)) & 0x7f) | mask; - - /* reset single shift state */ - psenc->singlegl = psenc->singlegr = -1; - - len = (size_t)(p - tmp); - if (n < len) { - if (result) - *result = (char *)0; - *nresult = (size_t)-1; - return E2BIG; - } - if (result) - *result = string + len; - memcpy(string, tmp, len); - *nresult = len; - - return 0; - -ilseq: - *nresult = (size_t)-1; - return EILSEQ; -} - -static int -_citrus_ISO2022_put_state_reset(_ISO2022EncodingInfo * __restrict ei, - char * __restrict s, size_t n, - _ISO2022State * __restrict psenc, - size_t * __restrict nresult) -{ - char buf[MB_LEN_MAX]; - char *result; - int ret; - size_t len; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(nresult != 0); - _DIAGASSERT(s != NULL); - - /* XXX state will be modified after this operation... */ - ret = _ISO2022_sputwchar(ei, L'\0', buf, sizeof(buf), &result, psenc, - &len); - if (ret) { - *nresult = len; - return ret; - } - - if (sizeof(buf) < len || n < len-1) { - /* XXX should recover state? */ - *nresult = (size_t)-1; - return E2BIG; - } - - memcpy(s, buf, len-1); - *nresult = len-1; - return (0); -} - -static int -_citrus_ISO2022_wcrtomb_priv(_ISO2022EncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _ISO2022State * __restrict psenc, - size_t * __restrict nresult) -{ - char buf[MB_LEN_MAX]; - char *result; - int ret; - size_t len; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != 0); - - /* XXX state will be modified after this operation... */ - ret = _ISO2022_sputwchar(ei, wc, buf, sizeof(buf), &result, psenc, - &len); - if (ret) { - *nresult = len; - return ret; - } - - if (sizeof(buf) < len || n < len) { - /* XXX should recover state? */ - *nresult = (size_t)-1; - return E2BIG; - } - - memcpy(s, buf, len); - *nresult = len; - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_ISO2022_stdenc_wctocs(_ISO2022EncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, wchar_t wc) -{ - wchar_t m, nm; - - _DIAGASSERT(csid != NULL && idx != NULL); - - m = wc & 0x7FFF8080; - nm = wc & 0x007F7F7F; - if (m & 0x00800000) { - nm &= 0x00007F7F; - } else { - m &= 0x7F008080; - } - if (nm & 0x007F0000) { - /* ^3 mark */ - m |= 0x007F0000; - } else if (nm & 0x00007F00) { - /* ^2 mark */ - m |= 0x00007F00; - } - *csid = (_csid_t)m; - *idx = (_index_t)nm; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_ISO2022_stdenc_cstowc(_ISO2022EncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - - _DIAGASSERT(ei != NULL && wc != NULL); - - *wc = (wchar_t)(csid & 0x7F808080) | (wchar_t)idx; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_ISO2022_stdenc_get_state_desc_generic(_ISO2022EncodingInfo * __restrict ei, - _ISO2022State * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) { - /* XXX: it should distinguish initial and stable. */ - *rstate = _STDENC_SDGEN_STABLE; - } else { - if (psenc->ch[0] == '\033') - *rstate = _STDENC_SDGEN_INCOMPLETE_SHIFT; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - } - - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(ISO2022); -_CITRUS_CTYPE_DEF_OPS(ISO2022); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(ISO2022); -_CITRUS_STDENC_DEF_OPS(ISO2022); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_iso2022.h b/lib/libc/citrus/modules/citrus_iso2022.h deleted file mode 100644 index e82e0b3ac..000000000 --- a/lib/libc/citrus/modules/citrus_iso2022.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_iso2022.h,v 1.2 2003/06/25 09:51:44 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ISO2022_H_ -#define _CITRUS_ISO2022_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(ISO2022); -_CITRUS_STDENC_GETOPS_FUNC(ISO2022); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_johab.c b/lib/libc/citrus/modules/citrus_johab.c deleted file mode 100644 index 57761e4fe..000000000 --- a/lib/libc/citrus/modules/citrus_johab.c +++ /dev/null @@ -1,394 +0,0 @@ -/* $NetBSD: citrus_johab.c,v 1.5 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_johab.c,v 1.5 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_johab.h" - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - int chlen; - char ch[2]; -} _JOHABState; - -typedef struct { - int dummy; -} _JOHABEncodingInfo; - -typedef struct { - _JOHABEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _JOHABState s_mblen; - _JOHABState s_mbrlen; - _JOHABState s_mbrtowc; - _JOHABState s_mbtowc; - _JOHABState s_mbsrtowcs; - _JOHABState s_mbsnrtowcs; - _JOHABState s_wcrtomb; - _JOHABState s_wcsrtombs; - _JOHABState s_wcsnrtombs; - _JOHABState s_wctomb; - } states; -} _JOHABCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_JOHAB_##m -#define _ENCODING_INFO _JOHABEncodingInfo -#define _CTYPE_INFO _JOHABCTypeInfo -#define _ENCODING_STATE _JOHABState -#define _ENCODING_MB_CUR_MAX(_ei_) 2 -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - - -static __inline void -/*ARGSUSED*/ -_citrus_JOHAB_init_state(_JOHABEncodingInfo * __restrict ei, - _JOHABState * __restrict psenc) -{ - /* ei may be null */ - _DIAGASSERT(psenc != NULL); - - psenc->chlen = 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_JOHAB_pack_state(_JOHABEncodingInfo * __restrict ei, - void * __restrict pspriv, - const _JOHABState * __restrict psenc) -{ - /* ei may be null */ - _DIAGASSERT(pspriv != NULL); - _DIAGASSERT(psenc != NULL); - - memcpy(pspriv, (const void *)psenc, sizeof(*psenc)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_JOHAB_unpack_state(_JOHABEncodingInfo * __restrict ei, - _JOHABState * __restrict psenc, - const void * __restrict pspriv) -{ - /* ei may be null */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(pspriv != NULL); - - memcpy((void *)psenc, pspriv, sizeof(*psenc)); -} - -static void -/*ARGSUSED*/ -_citrus_JOHAB_encoding_module_uninit(_JOHABEncodingInfo *ei) -{ - /* ei may be null */ -} - -static int -/*ARGSUSED*/ -_citrus_JOHAB_encoding_module_init(_JOHABEncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - /* ei may be null */ - return 0; -} - -static __inline int -ishangul(int l, int t) -{ - - return (l >= 0x84 && l <= 0xD3) && - ((t >= 0x41 && t <= 0x7E) || (t >= 0x81 && t <= 0xFE)); -} - -static __inline int -isuda(int l, int t) -{ - return (l == 0xD8) && - ((t >= 0x31 && t <= 0x7E) || (t >= 0x91 && t <= 0xFE)); -} - -static __inline int -ishanja(int l, int t) -{ - return ((l >= 0xD9 && l <= 0xDE) || (l >= 0xE0 && l <= 0xF9)) && - ((t >= 0x31 && t <= 0x7E) || (t >= 0x91 && t <= 0xFE)); -} - -static int -/*ARGSUSED*/ -_citrus_JOHAB_mbrtowc_priv(_JOHABEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, const char ** __restrict s, size_t n, - _JOHABState * __restrict psenc, size_t * __restrict nresult) -{ - const char *s0; - int l, t; - - /* ei may be unused */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != 0); - - if (*s == NULL) { - _citrus_JOHAB_init_state(ei, psenc); - *nresult = _ENCODING_IS_STATE_DEPENDENT; - return 0; - } - s0 = *s; - - switch (psenc->chlen) { - case 0: - if (n-- < 1) - goto restart; - l = *s0++ & 0xFF; - if (l <= 0x7F) { - if (pwc != NULL) - *pwc = (wchar_t)l; - *nresult = (l == 0) ? 0 : 1; - *s = s0; - return 0; - } - psenc->ch[psenc->chlen++] = l; - break; - case 1: - l = psenc->ch[0] & 0xFF; - break; - default: - return EINVAL; - } - if (n-- < 1) { -restart: - *nresult = (size_t)-2; - *s = s0; - return 0; - } - t = *s0++ & 0xFF; - if (!ishangul(l, t) && !isuda(l, t) && !ishanja(l, t)) { - *nresult = (size_t)-1; - return EILSEQ; - } - if (pwc != NULL) - *pwc = (wchar_t)(l << 8 | t); - *nresult = s0 - *s; - *s = s0; - psenc->chlen = 0; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_JOHAB_wcrtomb_priv(_JOHABEncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _JOHABState * __restrict psenc, size_t * __restrict nresult) -{ - int l, t; - - /* ei may be unused */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (psenc->chlen != 0) - return EINVAL; - - /* XXX assume wchar_t as int */ - if ((uint32_t)wc <= 0x7F) { - if (n < 1) - goto e2big; - *s = wc & 0xFF; - *nresult = 1; - } else if ((uint32_t)wc <= 0xFFFF) { - if (n < 2) { -e2big: - *nresult = (size_t)-1; - return E2BIG; - } - l = (wc >> 8) & 0xFF; - t = wc & 0xFF; - if (!ishangul(l, t) && !isuda(l, t) && !ishanja(l, t)) - goto ilseq; - *s++ = l; - *s = t; - *nresult = 2; - } else { -ilseq: - *nresult = (size_t)-1; - return EILSEQ; - } - return 0; - -} - -static __inline int -/*ARGSUSED*/ -_citrus_JOHAB_stdenc_wctocs(_JOHABEncodingInfo * __restrict ei, - _csid_t * __restrict csid, _index_t * __restrict idx, wchar_t wc) -{ - int m, l, t, linear; - - /* ei may be unused */ - _DIAGASSERT(csid != NULL); - _DIAGASSERT(idx != NULL); - - /* XXX assume wchar_t as int */ - if ((uint32_t)wc <= 0x7F) { - *idx = (_index_t)wc; - *csid = 0; - } else if ((uint32_t)wc <= 0xFFFF) { - l = (wc >> 8) & 0xFF; - t = wc & 0xFF; - if (ishangul(l, t) || isuda(l, t)) { - *idx = (_index_t)wc; - *csid = 1; - } else { - if (l >= 0xD9 && l <= 0xDE) { - linear = l - 0xD9; - m = 0x21; - } else if (l >= 0xE0 && l <= 0xF9) { - linear = l - 0xE0; - m = 0x4A; - } else { - return EILSEQ; - } - linear *= 188; - if (t >= 0x31 && t <= 0x7E) { - linear += t - 0x31; - } else if (t >= 0x91 && t <= 0xFE) { - linear += t - 0x43; - } else { - return EILSEQ; - } - l = (linear / 94) + m; - t = (linear % 94) + 0x21; - *idx = (_index_t)((l << 8) | t); - *csid = 2; - } - } else { - return EILSEQ; - } - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_JOHAB_stdenc_cstowc(_JOHABEncodingInfo * __restrict ei, - wchar_t * __restrict wc, _csid_t csid, _index_t idx) -{ - int m, n, l, t, linear; - - /* ei may be unused */ - _DIAGASSERT(wc != NULL); - - switch (csid) { - case 0: - case 1: - *wc = (wchar_t)idx; - break; - case 2: - if (idx >= 0x2121 && idx <= 0x2C71) { - m = 0xD9; - n = 0x21; - } else if (idx >= 0x4A21 && idx <= 0x7D7E) { - m = 0xE0; - n = 0x4A; - } else { - return EILSEQ; - } - l = ((idx >> 8) & 0xFF) - n; - t = (idx & 0xFF) - 0x21; - linear = (l * 94) + t; - l = (linear / 188) + m; - t = linear % 188; - t += (t <= 0x4D) ? 0x31 : 0x43; - break; - default: - return EILSEQ; - } - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_JOHAB_stdenc_get_state_desc_generic(_JOHABEncodingInfo * __restrict ei, - _JOHABState * __restrict psenc, int * __restrict rstate) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(rstate != NULL); - - *rstate = (psenc->chlen == 0) - ? _STDENC_SDGEN_INITIAL - : _STDENC_SDGEN_INCOMPLETE_CHAR; - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(JOHAB); -_CITRUS_CTYPE_DEF_OPS(JOHAB); - -#include "citrus_ctype_template.h" - - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(JOHAB); -_CITRUS_STDENC_DEF_OPS(JOHAB); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_johab.h b/lib/libc/citrus/modules/citrus_johab.h deleted file mode 100644 index f3878ad6c..000000000 --- a/lib/libc/citrus/modules/citrus_johab.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_johab.h,v 1.1 2006/10/18 17:54:55 tnozaki Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_JOHAB_H_ -#define _CITRUS_JOHAB_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(JOHAB); -_CITRUS_STDENC_GETOPS_FUNC(JOHAB); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_mapper_646.c b/lib/libc/citrus/modules/citrus_mapper_646.c deleted file mode 100644 index 14e6fd2c0..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_646.c +++ /dev/null @@ -1,259 +0,0 @@ -/* $NetBSD: citrus_mapper_646.c,v 1.4 2003/07/14 11:37:49 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mapper_646.c,v 1.4 2003/07/14 11:37:49 tshiozak Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_mapper.h" -#include "citrus_mapper_646.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_MAPPER_DECLS(mapper_646); -_CITRUS_MAPPER_DEF_OPS(mapper_646); - -/* ---------------------------------------------------------------------- */ - -#define ILSEQ 0xFFFFFFFE -#define INVALID 0xFFFFFFFF -#define SPECIALS(x) \ - x(0x23) \ - x(0x24) \ - x(0x40) \ - x(0x5B) \ - x(0x5C) \ - x(0x5D) \ - x(0x5E) \ - x(0x60) \ - x(0x7B) \ - x(0x7C) \ - x(0x7D) \ - x(0x7E) - -#define INDEX(x) INDEX_##x, - -enum { - SPECIALS(INDEX) - NUM_OF_SPECIALS -}; -struct _citrus_mapper_646 { - int m6_forward; - _index_t m6_map[NUM_OF_SPECIALS]; -}; - -int -_citrus_mapper_646_mapper_getops(struct _citrus_mapper_ops *ops, - size_t lenops, uint32_t expected_version) -{ - if (expected_version<_CITRUS_MAPPER_ABI_VERSION || lenopsm6_map[i] = strtoul(buf, (char **)&p, 0); - p = _bcs_skip_ws(buf); - if (*p != T_COMM && !*p) { - ret = EINVAL; - break; - } - } - _unmap_file(&r); - - return ret; -}; - -static int -parse_var(struct _citrus_mapper_646 *m6, struct _memstream *ms, - const char *dir) -{ - struct _region r; - char path[PATH_MAX]; - - m6->m6_forward = 1; - _memstream_skip_ws(ms); - /* whether backward */ - if (_memstream_peek(ms) == '!') { - _memstream_getc(ms); - m6->m6_forward = 0; - } - /* get description file path */ - _memstream_getregion(ms, &r, _memstream_remainder(ms)); - snprintf(path, sizeof(path), "%s/%.*s", - dir, (int)_region_size(&r), (char *)_region_head(&r)); - /* remove trailing white spaces */ - path[_bcs_skip_nonws(path)-path] = '\0'; - return parse_file(m6, path); -} - -static int -/*ARGSUSED*/ -_citrus_mapper_646_mapper_init(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict cm, - const char * __restrict dir, - const void * __restrict var, size_t lenvar, - struct _citrus_mapper_traits * __restrict mt, - size_t lenmt) -{ - struct _citrus_mapper_646 *m6; - struct _memstream ms; - struct _region r; - int ret; - - _DIAGASSERT(cm && dir && mt); - - if (lenmtcm_closure = m6; - mt->mt_src_max = mt->mt_dst_max = 1; /* 1:1 converter */ - mt->mt_state_size = 0; /* stateless */ - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_646_mapper_uninit(struct _citrus_mapper *cm) -{ - if (cm && cm->cm_closure) { - free(cm->cm_closure); - } -} - -static int -/*ARGSUSED*/ -_citrus_mapper_646_mapper_convert(struct _citrus_mapper * __restrict cm, - _index_t * __restrict dst, _index_t src, - void * __restrict ps) -{ - struct _citrus_mapper_646 *m6; - - _DIAGASSERT(cm && cm->cm_closure); - - m6 = cm->cm_closure; - if (m6->m6_forward) { - /* forward */ - if (src>=0x80) - return _MAPPER_CONVERT_ILSEQ; -#define FORWARD(x) \ -if (src==(x)) { \ - if (m6->m6_map[INDEX_##x]==INVALID) \ - return _MAPPER_CONVERT_NONIDENTICAL; \ - *dst = m6->m6_map[INDEX_##x]; \ - return 0; \ -} else - SPECIALS(FORWARD); - *dst = src; - } else { - /* backward */ -#define BACKWARD(x) \ -if (m6->m6_map[INDEX_##x]!=INVALID && src==m6->m6_map[INDEX_##x]) { \ - *dst = (x); \ - return 0; \ -} else if (src==(x)) \ - return _MAPPER_CONVERT_ILSEQ; \ -else - SPECIALS(BACKWARD); - if (src>=0x80) - return _MAPPER_CONVERT_NONIDENTICAL; - *dst = src; - } - - return _MAPPER_CONVERT_SUCCESS; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_646_mapper_init_state(struct _citrus_mapper * __restrict cm, - void * __restrict ps) -{ -} diff --git a/lib/libc/citrus/modules/citrus_mapper_646.h b/lib/libc/citrus/modules/citrus_mapper_646.h deleted file mode 100644 index cdacae0f3..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_646.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_mapper_646.h,v 1.1 2003/06/25 09:51:45 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_646_H_ -#define _CITRUS_MAPPER_646_H_ - -__BEGIN_DECLS -_CITRUS_MAPPER_GETOPS_FUNC(mapper_646); -_CITRUS_MAPPER_GETOPS_FUNC(mapper_646); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_mapper_none.c b/lib/libc/citrus/modules/citrus_mapper_none.c deleted file mode 100644 index 12b31410e..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_none.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $NetBSD: citrus_mapper_none.c,v 1.2 2003/06/27 17:53:31 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mapper_none.c,v 1.2 2003/06/27 17:53:31 tshiozak Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_hash.h" -#include "citrus_mapper.h" -#include "citrus_mapper_none.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_MAPPER_DECLS(mapper_none); -_CITRUS_MAPPER_DEF_OPS(mapper_none); - - -/* ---------------------------------------------------------------------- */ - -int -_citrus_mapper_none_mapper_getops(struct _citrus_mapper_ops *ops, - size_t lenops, uint32_t expected_version) -{ - if (expected_version<_CITRUS_MAPPER_ABI_VERSION || lenopscm_closure = NULL; - mt->mt_src_max = mt->mt_dst_max = 1; /* 1:1 converter */ - mt->mt_state_size = 0; /* stateless */ - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_none_mapper_uninit(struct _citrus_mapper *cm) -{ -} - -static int -/*ARGSUSED*/ -_citrus_mapper_none_mapper_convert(struct _citrus_mapper * __restrict cm, - _citrus_index_t * __restrict dst, - _citrus_index_t src, void * __restrict ps) -{ - *dst = src; - return _CITRUS_MAPPER_CONVERT_SUCCESS; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_none_mapper_init_state(struct _citrus_mapper * __restrict cm, - void * __restrict ps) -{ -} diff --git a/lib/libc/citrus/modules/citrus_mapper_none.h b/lib/libc/citrus/modules/citrus_mapper_none.h deleted file mode 100644 index c0d6a7193..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_none.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_mapper_none.h,v 1.1 2003/06/25 09:51:45 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_NONE_H_ -#define _CITRUS_MAPPER_NONE_H_ - -__BEGIN_DECLS -_CITRUS_MAPPER_GETOPS_FUNC(mapper_none); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_mapper_serial.c b/lib/libc/citrus/modules/citrus_mapper_serial.c deleted file mode 100644 index be006b595..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_serial.c +++ /dev/null @@ -1,263 +0,0 @@ -/* $NetBSD: citrus_mapper_serial.c,v 1.2 2003/07/12 15:39:20 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mapper_serial.c,v 1.2 2003/07/12 15:39:20 tshiozak Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_mapper.h" -#include "citrus_mapper_serial.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_MAPPER_DECLS(mapper_serial); -_CITRUS_MAPPER_DEF_OPS(mapper_serial); - -#define _citrus_mapper_parallel_mapper_init \ - _citrus_mapper_serial_mapper_init -#define _citrus_mapper_parallel_mapper_uninit \ - _citrus_mapper_serial_mapper_uninit -#define _citrus_mapper_parallel_mapper_init_state \ - _citrus_mapper_serial_mapper_init_state -static int _citrus_mapper_parallel_mapper_convert( - struct _citrus_mapper * __restrict, _index_t * __restrict, _index_t, - void * __restrict); -_CITRUS_MAPPER_DEF_OPS(mapper_parallel); -#undef _citrus_mapper_parallel_mapper_init -#undef _citrus_mapper_parallel_mapper_uninit -#undef _citrus_mapper_parallel_mapper_init_state - - -/* ---------------------------------------------------------------------- */ - -struct maplink { - SIMPLEQ_ENTRY(maplink) ml_entry; - struct _mapper *ml_mapper; -}; -SIMPLEQ_HEAD(maplist, maplink); - -struct _citrus_mapper_serial { - struct maplist sr_mappers; -}; - -int -_citrus_mapper_serial_mapper_getops(struct _citrus_mapper_ops *ops, - size_t lenops, uint32_t expected_version) -{ - if (expected_version<_CITRUS_MAPPER_ABI_VERSION || lenopssr_mappers)) != NULL) { - SIMPLEQ_REMOVE_HEAD(&sr->sr_mappers, ml_entry); - _mapper_close(ml->ml_mapper); - free(ml); - } -} - -static int -parse_var(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper_serial *sr, struct _memstream *ms) -{ - int ret; - struct _region r; - char mapname[PATH_MAX]; - struct maplink *ml; - - SIMPLEQ_INIT(&sr->sr_mappers); - while (1) { - /* remove beginning white spaces */ - _memstream_skip_ws(ms); - if (_memstream_iseof(ms)) - break; - /* cut down a mapper name */ - _memstream_chr(ms, &r, ','); - snprintf(mapname, sizeof(mapname), "%.*s", - (int)_region_size(&r), (char *)_region_head(&r)); - /* remove trailing white spaces */ - mapname[_bcs_skip_nonws(mapname)-mapname] = '\0'; - /* create a new mapper record */ - ml = malloc(sizeof(*ml)); - if (ml == NULL) - return errno; - ret = _mapper_open(ma, &ml->ml_mapper, mapname); - if (ret) { - free(ml); - return ret; - } - /* support only 1:1 and stateless converter */ - if (_mapper_get_src_max(ml->ml_mapper) != 1 || - _mapper_get_dst_max(ml->ml_mapper) != 1 || - _mapper_get_state_size(ml->ml_mapper) != 0) { - free(ml); - return EINVAL; - } - SIMPLEQ_INSERT_TAIL(&sr->sr_mappers, ml, ml_entry); - } - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_mapper_serial_mapper_init(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict cm, - const char * __restrict dir, - const void * __restrict var, size_t lenvar, - struct _citrus_mapper_traits * __restrict mt, - size_t lenmt) -{ - struct _citrus_mapper_serial *sr; - struct _memstream ms; - struct _region r; - - _DIAGASSERT(cm && dir && mt); - - if (lenmtcm_closure = sr; - mt->mt_src_max = mt->mt_dst_max = 1; /* 1:1 converter */ - mt->mt_state_size = 0; /* stateless */ - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_serial_mapper_uninit(struct _citrus_mapper *cm) -{ - if (cm && cm->cm_closure) { - uninit(cm->cm_closure); - free(cm->cm_closure); - } -} - -static int -/*ARGSUSED*/ -_citrus_mapper_serial_mapper_convert(struct _citrus_mapper * __restrict cm, - _index_t * __restrict dst, _index_t src, - void * __restrict ps) -{ - int ret; - struct _citrus_mapper_serial *sr; - struct maplink *ml; - - _DIAGASSERT(cm && cm->cm_closure); - - sr = cm->cm_closure; - SIMPLEQ_FOREACH(ml, &sr->sr_mappers, ml_entry) { - ret = _mapper_convert(ml->ml_mapper, &src, src, NULL); - if (ret != _MAPPER_CONVERT_SUCCESS) - return ret; - } - *dst = src; - return _MAPPER_CONVERT_SUCCESS; -} - -static int -/*ARGSUSED*/ -_citrus_mapper_parallel_mapper_convert(struct _citrus_mapper * __restrict cm, - _index_t * __restrict dst, _index_t src, - void * __restrict ps) -{ - int ret; - struct _citrus_mapper_serial *sr; - struct maplink *ml; - _index_t tmp; - - _DIAGASSERT(cm && cm->cm_closure); - - sr = cm->cm_closure; - SIMPLEQ_FOREACH(ml, &sr->sr_mappers, ml_entry) { - ret = _mapper_convert(ml->ml_mapper, &tmp, src, NULL); - if (ret == _MAPPER_CONVERT_SUCCESS) { - *dst = tmp; - return _MAPPER_CONVERT_SUCCESS; - } else if (ret == _MAPPER_CONVERT_ILSEQ) - return _MAPPER_CONVERT_ILSEQ; - } - return _MAPPER_CONVERT_NONIDENTICAL; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_serial_mapper_init_state(struct _citrus_mapper * __restrict cm, - void * __restrict ps) -{ -} diff --git a/lib/libc/citrus/modules/citrus_mapper_serial.h b/lib/libc/citrus/modules/citrus_mapper_serial.h deleted file mode 100644 index 107f0ed6c..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_serial.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_mapper_serial.h,v 1.1 2003/06/25 09:51:46 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_SERIAL_H_ -#define _CITRUS_MAPPER_SERIAL_H_ - -__BEGIN_DECLS -_CITRUS_MAPPER_GETOPS_FUNC(mapper_serial); -_CITRUS_MAPPER_GETOPS_FUNC(mapper_parallel); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_mapper_std.c b/lib/libc/citrus/modules/citrus_mapper_std.c deleted file mode 100644 index 9e7d10cbf..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_std.c +++ /dev/null @@ -1,464 +0,0 @@ -/* $NetBSD: citrus_mapper_std.c,v 1.10 2011/11/19 18:48:39 tnozaki Exp $ */ - -/*- - * Copyright (c)2003, 2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mapper_std.c,v 1.10 2011/11/19 18:48:39 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_mmap.h" -#include "citrus_module.h" -#include "citrus_hash.h" -#include "citrus_mapper.h" -#include "citrus_db.h" -#include "citrus_db_hash.h" - -#include "citrus_mapper_std.h" -#include "citrus_mapper_std_file.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_MAPPER_DECLS(mapper_std); -_CITRUS_MAPPER_DEF_OPS(mapper_std); - - -/* ---------------------------------------------------------------------- */ - -int -_citrus_mapper_std_mapper_getops(struct _citrus_mapper_ops *ops, size_t lenops, - u_int32_t expected_version) -{ - if (expected_version<_CITRUS_MAPPER_ABI_VERSION || lenopsms_rowcol; - - for (i = rc->rc_src_rowcol_len * rc->rc_src_rowcol_bits, - lz = &rc->rc_src_rowcol[0]; i > 0; ++lz) { - i -= rc->rc_src_rowcol_bits; - n = (src >> i) & rc->rc_src_rowcol_mask; - if (n < lz->begin || n > lz->end) { - switch (rc->rc_oob_mode) { - case _CITRUS_MAPPER_STD_OOB_NONIDENTICAL: - *dst = rc->rc_dst_invalid; - return _MAPPER_CONVERT_NONIDENTICAL; - case _CITRUS_MAPPER_STD_OOB_ILSEQ: - return _MAPPER_CONVERT_ILSEQ; - default: - return _MAPPER_CONVERT_FATAL; - } - } - idx = idx * lz->width + n - lz->begin; - } - switch (rc->rc_dst_unit_bits) { - case 8: - conv = _region_peek8(&rc->rc_table, idx); - break; - case 16: - conv = be16toh(_region_peek16(&rc->rc_table, idx*2)); - break; - case 32: - conv = be32toh(_region_peek32(&rc->rc_table, idx*4)); - break; - default: - return _MAPPER_CONVERT_FATAL; - } - - if (conv == rc->rc_dst_invalid) { - *dst = rc->rc_dst_invalid; - return _MAPPER_CONVERT_NONIDENTICAL; - } - if (conv == rc->rc_dst_ilseq) - return _MAPPER_CONVERT_ILSEQ; - - *dst = conv; - - return _MAPPER_CONVERT_SUCCESS; -} - -static __inline int -set_linear_zone(struct _citrus_mapper_std_linear_zone *lz, - u_int32_t begin, u_int32_t end) -{ - _DIAGASSERT(lz != NULL); - - if (begin > end) - return EFTYPE; - - lz->begin = begin; - lz->end = end; - lz->width= end - begin + 1; - - return 0; -} - -static __inline int -rowcol_parse_variable_compat(struct _citrus_mapper_std_rowcol *rc, - struct _region *r) -{ - const struct _citrus_mapper_std_rowcol_info_compat_x *rcx; - struct _citrus_mapper_std_linear_zone *lz; - u_int32_t m, n; - int ret; - - _DIAGASSERT(rc != NULL); - _DIAGASSERT(r != NULL && _region_size(r) == sizeof(*rcx)); - rcx = _region_head(r); - - rc->rc_dst_invalid = be32toh(rcx->rcx_dst_invalid); - rc->rc_dst_unit_bits = be32toh(rcx->rcx_dst_unit_bits); - m = be32toh(rcx->rcx_src_col_bits); - n = 1 << (m - 1); - n |= n - 1; - rc->rc_src_rowcol_bits = m; - rc->rc_src_rowcol_mask = n; - - rc->rc_src_rowcol = malloc(2 * - sizeof(*rc->rc_src_rowcol)); - if (rc->rc_src_rowcol == NULL) - return ENOMEM; - lz = rc->rc_src_rowcol; - rc->rc_src_rowcol_len = 1; - m = be32toh(rcx->rcx_src_row_begin); - n = be32toh(rcx->rcx_src_row_end); - if (m + n > 0) { - ret = set_linear_zone(lz, m, n); - if (ret != 0) { - free(rc->rc_src_rowcol); - rc->rc_src_rowcol = NULL; - return ret; - } - ++rc->rc_src_rowcol_len, ++lz; - } - m = be32toh(rcx->rcx_src_col_begin); - n = be32toh(rcx->rcx_src_col_end); - - return set_linear_zone(lz, m, n); -} - -static __inline int -rowcol_parse_variable(struct _citrus_mapper_std_rowcol *rc, - struct _region *r) -{ - const struct _citrus_mapper_std_rowcol_info_x *rcx; - struct _citrus_mapper_std_linear_zone *lz; - u_int32_t m, n; - size_t i; - int ret; - - _DIAGASSERT(rc != NULL); - _DIAGASSERT(r != NULL && _region_size(r) == sizeof(*rcx)); - rcx = _region_head(r); - - rc->rc_dst_invalid = be32toh(rcx->rcx_dst_invalid); - rc->rc_dst_unit_bits = be32toh(rcx->rcx_dst_unit_bits); - - m = be32toh(rcx->rcx_src_rowcol_bits); - n = 1 << (m - 1); - n |= n - 1; - rc->rc_src_rowcol_bits = m; - rc->rc_src_rowcol_mask = n; - - rc->rc_src_rowcol_len = be32toh(rcx->rcx_src_rowcol_len); - if (rc->rc_src_rowcol_len > _CITRUS_MAPPER_STD_ROWCOL_MAX) - return EFTYPE; - rc->rc_src_rowcol = malloc(rc->rc_src_rowcol_len * - sizeof(*rc->rc_src_rowcol)); - if (rc->rc_src_rowcol == NULL) - return ENOMEM; - for (i = 0, lz = rc->rc_src_rowcol; - i < rc->rc_src_rowcol_len; ++i, ++lz) { - m = be32toh(rcx->rcx_src_rowcol[i].begin), - n = be32toh(rcx->rcx_src_rowcol[i].end); - ret = set_linear_zone(lz, m, n); - if (ret != 0) { - free(rc->rc_src_rowcol); - rc->rc_src_rowcol = NULL; - return ret; - } - } - return 0; -} - -static void -rowcol_uninit(struct _citrus_mapper_std *ms) -{ - struct _citrus_mapper_std_rowcol *rc; - _DIAGASSERT(ms != NULL); - - rc = &ms->ms_rowcol; - free(rc->rc_src_rowcol); -} - -static int -rowcol_init(struct _citrus_mapper_std *ms) -{ - int ret; - struct _citrus_mapper_std_rowcol *rc; - const struct _citrus_mapper_std_rowcol_ext_ilseq_info_x *eix; - struct _region r; - u_int64_t table_size; - size_t i; - struct _citrus_mapper_std_linear_zone *lz; - - _DIAGASSERT(ms != NULL); - ms->ms_convert = &rowcol_convert; - ms->ms_uninit = &rowcol_uninit; - rc = &ms->ms_rowcol; - - /* get table region */ - ret = _db_lookup_by_s(ms->ms_db, _CITRUS_MAPPER_STD_SYM_TABLE, - &rc->rc_table, NULL); - if (ret) { - if (ret==ENOENT) - ret = EFTYPE; - return ret; - } - - /* get table information */ - ret = _db_lookup_by_s(ms->ms_db, _CITRUS_MAPPER_STD_SYM_INFO, &r, NULL); - if (ret) { - if (ret==ENOENT) - ret = EFTYPE; - return ret; - } - switch (_region_size(&r)) { - case _CITRUS_MAPPER_STD_ROWCOL_INFO_COMPAT_SIZE: - ret = rowcol_parse_variable_compat(rc, &r); - break; - case _CITRUS_MAPPER_STD_ROWCOL_INFO_SIZE: - ret = rowcol_parse_variable(rc, &r); - break; - default: - return EFTYPE; - } - if (ret != 0) - return ret; - /* sanity check */ - switch (rc->rc_src_rowcol_bits) { - case 8: case 16: case 32: - if (rc->rc_src_rowcol_len <= 32 / rc->rc_src_rowcol_bits) - break; - /*FALLTHROUGH*/ - default: - return EFTYPE; - } - - /* ilseq extension */ - rc->rc_oob_mode = _CITRUS_MAPPER_STD_OOB_NONIDENTICAL; - rc->rc_dst_ilseq = rc->rc_dst_invalid; - ret = _db_lookup_by_s(ms->ms_db, - _CITRUS_MAPPER_STD_SYM_ROWCOL_EXT_ILSEQ, - &r, NULL); - if (ret && ret != ENOENT) - return ret; - if (_region_size(&r) < sizeof(*eix)) - return EFTYPE; - if (ret == 0) { - eix = _region_head(&r); - rc->rc_oob_mode = be32toh(eix->eix_oob_mode); - rc->rc_dst_ilseq = be32toh(eix->eix_dst_ilseq); - } - - /* calcurate expected table size */ - i = rc->rc_src_rowcol_len; - lz = &rc->rc_src_rowcol[--i]; - table_size = lz->width; - while (i > 0) { - lz = &rc->rc_src_rowcol[--i]; - table_size *= lz->width; - } - table_size *= rc->rc_dst_unit_bits/8; - - if (table_size > UINT32_MAX || - _region_size(&rc->rc_table) < table_size) - return EFTYPE; - - return 0; -} - -typedef int (*initfunc_t)(struct _citrus_mapper_std *); -static const struct { - const char *t_name; - initfunc_t t_init; -} types[] = { - { _CITRUS_MAPPER_STD_TYPE_ROWCOL, &rowcol_init }, -}; -#define NUM_OF_TYPES ((int)(sizeof(types)/sizeof(types[0]))) - -static int -/*ARGSUSED*/ -_citrus_mapper_std_mapper_init(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict cm, - const char * __restrict curdir, - const void * __restrict var, size_t lenvar, - struct _citrus_mapper_traits * __restrict mt, - size_t lenmt) -{ - char path[PATH_MAX]; - const char *type; - int ret, id; - struct _citrus_mapper_std *ms; - - /* set traits */ - if (lenmtmt_src_max = mt->mt_dst_max = 1; /* 1:1 converter */ - mt->mt_state_size = 0; /* stateless */ - - /* alloc mapper std structure */ - ms = malloc(sizeof(*ms)); - if (ms==NULL) { - ret = errno; - goto err0; - } - - /* open mapper file */ - snprintf(path, sizeof(path), - "%s/%.*s", curdir, (int)lenvar, (const char *)var); - ret = _map_file(&ms->ms_file, path); - if (ret) - goto err1; - - ret = _db_open(&ms->ms_db, &ms->ms_file, _CITRUS_MAPPER_STD_MAGIC, - &_db_hash_std, NULL); - if (ret) - goto err2; - - /* get mapper type */ - ret = _db_lookupstr_by_s(ms->ms_db, _CITRUS_MAPPER_STD_SYM_TYPE, - &type, NULL); - if (ret) { - if (ret==ENOENT) - ret = EFTYPE; - goto err3; - } - for (id=0; idcm_closure = ms; - - return 0; - -err3: - _db_close(ms->ms_db); -err2: - _unmap_file(&ms->ms_file); -err1: - free(ms); -err0: - return ret; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_std_mapper_uninit(struct _citrus_mapper *cm) -{ - struct _citrus_mapper_std *ms; - - _DIAGASSERT(cm!=NULL && cm->cm_closure!=NULL); - - ms = cm->cm_closure; - if (ms->ms_uninit) - (*ms->ms_uninit)(ms); - _db_close(ms->ms_db); - _unmap_file(&ms->ms_file); - free(ms); -} - -static void -/*ARGSUSED*/ -_citrus_mapper_std_mapper_init_state(struct _citrus_mapper * __restrict cm, - void * __restrict ps) -{ -} - -static int -/*ARGSUSED*/ -_citrus_mapper_std_mapper_convert(struct _citrus_mapper * __restrict cm, - _index_t * __restrict dst, _index_t src, - void * __restrict ps) -{ - struct _citrus_mapper_std *ms; - - _DIAGASSERT(cm!=NULL && cm->cm_closure!=NULL); - - ms = cm->cm_closure; - - _DIAGASSERT(ms->ms_convert != NULL); - - return (*ms->ms_convert)(ms, dst, src, ps); -} diff --git a/lib/libc/citrus/modules/citrus_mapper_std.h b/lib/libc/citrus/modules/citrus_mapper_std.h deleted file mode 100644 index 83eae8237..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_std.h +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: citrus_mapper_std.h,v 1.1 2003/06/25 09:51:47 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_STD_H_ -#define _CITRUS_MAPPER_STD_H_ - -#include "citrus_mapper_std_local.h" - -__BEGIN_DECLS -_CITRUS_MAPPER_GETOPS_FUNC(mapper_std); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_mapper_std_file.h b/lib/libc/citrus/modules/citrus_mapper_std_file.h deleted file mode 100644 index c9d17cab2..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_std_file.h +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: citrus_mapper_std_file.h,v 1.3 2006/09/09 14:35:17 tnozaki Exp $ */ - -/*- - * Copyright (c)2003, 2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_STD_FILE_H_ -#define _CITRUS_MAPPER_STD_FILE_H_ - -#define _CITRUS_MAPPER_STD_MAGIC "MAPPER\0\0" - -#define _CITRUS_MAPPER_STD_SYM_TYPE "type" -#define _CITRUS_MAPPER_STD_SYM_INFO "info" -#define _CITRUS_MAPPER_STD_SYM_TABLE "table" - -#define _CITRUS_MAPPER_STD_TYPE_ROWCOL "rowcol" -struct _citrus_mapper_std_rowcol_info_x { - u_int32_t rcx_src_rowcol_bits; - u_int32_t rcx_dst_invalid; -#define _CITRUS_MAPPER_STD_ROWCOL_MAX 4 - struct { - u_int32_t begin; - u_int32_t end; - } __packed rcx_src_rowcol[_CITRUS_MAPPER_STD_ROWCOL_MAX]; - u_int32_t rcx_dst_unit_bits; - u_int32_t rcx_src_rowcol_len; -} __packed; -#define _CITRUS_MAPPER_STD_ROWCOL_INFO_SIZE 48 - -/* old file layout */ -struct _citrus_mapper_std_rowcol_info_compat_x { - u_int32_t rcx_src_col_bits; - u_int32_t rcx_dst_invalid; - u_int32_t rcx_src_row_begin; - u_int32_t rcx_src_row_end; - u_int32_t rcx_src_col_begin; - u_int32_t rcx_src_col_end; - u_int32_t rcx_dst_unit_bits; - u_int32_t rcx_pad; -} __packed; -#define _CITRUS_MAPPER_STD_ROWCOL_INFO_COMPAT_SIZE 32 - -/* rowcol oob extension info */ -#define _CITRUS_MAPPER_STD_SYM_ROWCOL_EXT_ILSEQ "rowcol_ext_ilseq" -struct _citrus_mapper_std_rowcol_ext_ilseq_info_x { -#define _CITRUS_MAPPER_STD_OOB_NONIDENTICAL 0 -#define _CITRUS_MAPPER_STD_OOB_ILSEQ 1 - u_int32_t eix_oob_mode; - u_int32_t eix_dst_ilseq; -} __packed; -#define _CITRUS_MAPPER_STD_ROWCOL_EXT_ILSEQ_SIZE 8 - -#endif diff --git a/lib/libc/citrus/modules/citrus_mapper_std_local.h b/lib/libc/citrus/modules/citrus_mapper_std_local.h deleted file mode 100644 index 631a296a3..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_std_local.h +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: citrus_mapper_std_local.h,v 1.3 2006/09/09 14:35:17 tnozaki Exp $ */ - -/*- - * Copyright (c)2003, 2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_STD_LOCAL_H_ -#define _CITRUS_MAPPER_STD_LOCAL_H_ - -typedef u_int32_t (*_citrus_mapper_std_getvalfunc_t)(const void *, u_int32_t); - -struct _citrus_mapper_std_linear_zone { - _citrus_index_t begin; - _citrus_index_t end; - _citrus_index_t width; -}; -struct _citrus_mapper_std_rowcol { - struct _citrus_region rc_table; - size_t rc_src_rowcol_len; - struct _citrus_mapper_std_linear_zone - *rc_src_rowcol; - _citrus_index_t rc_src_rowcol_bits; - _citrus_index_t rc_src_rowcol_mask; - _citrus_index_t rc_dst_invalid; - _citrus_index_t rc_dst_unit_bits; - int rc_oob_mode; - _citrus_index_t rc_dst_ilseq; -}; - -struct _citrus_mapper_std; - -typedef int (*_citrus_mapper_std_convert_t)( - struct _citrus_mapper_std *__restrict, - _index_t *__restrict, _index_t, void *__restrict); -typedef void (*_citrus_mapper_std_uninit_t)(struct _citrus_mapper_std *); - -struct _citrus_mapper_std { - struct _citrus_region ms_file; - struct _citrus_db *ms_db; - _citrus_mapper_std_convert_t ms_convert; - _citrus_mapper_std_uninit_t ms_uninit; - union { - struct _citrus_mapper_std_rowcol rowcol; - } u; -#define ms_rowcol u.rowcol -}; - -#endif diff --git a/lib/libc/citrus/modules/citrus_mapper_zone.c b/lib/libc/citrus/modules/citrus_mapper_zone.c deleted file mode 100644 index 8eddefaf8..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_zone.c +++ /dev/null @@ -1,401 +0,0 @@ -/* $NetBSD: citrus_mapper_zone.c,v 1.4 2003/07/12 15:39:21 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mapper_zone.c,v 1.4 2003/07/12 15:39:21 tshiozak Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_region.h" -#include "citrus_memstream.h" -#include "citrus_mmap.h" -#include "citrus_hash.h" -#include "citrus_mapper.h" -#include "citrus_mapper_zone.h" - -/* ---------------------------------------------------------------------- */ - -_CITRUS_MAPPER_DECLS(mapper_zone); -_CITRUS_MAPPER_DEF_OPS(mapper_zone); - - -/* ---------------------------------------------------------------------- */ - -struct _zone { - u_int32_t z_begin; - u_int32_t z_end; -}; - -struct _citrus_mapper_zone { - struct _zone mz_row; - struct _zone mz_col; - int mz_col_bits; - int32_t mz_row_offset; - int32_t mz_col_offset; -}; - -struct _parse_state { - enum { S_BEGIN, S_OFFSET } ps_state; - union { - u_int32_t u_imm; - int32_t s_imm; - struct _zone zone; - } u; -#define ps_u_imm u.u_imm -#define ps_s_imm u.s_imm -#define ps_zone u.zone - int ps_top; -}; - -int -_citrus_mapper_zone_mapper_getops(struct _citrus_mapper_ops *ops, - size_t lenops, uint32_t expected_version) -{ - if (expected_version<_CITRUS_MAPPER_ABI_VERSION || lenopsps_u_imm = strtoul(buf, &p, 0); - if ((p-buf) != i) - return T_ERR; - if (sign == '-') - ps->ps_u_imm = (unsigned long)-(long)ps->ps_u_imm; - return T_IMM; -} - -static int -get_tok(struct _memstream *ms, struct _parse_state *ps) -{ - int c; - -loop: - c = _memstream_peek(ms); - if (c==0x00) - return EOF; - if (_bcs_isspace(c)) { - _memstream_getc(ms); - goto loop; - } - - switch (ps->ps_state) { - case S_BEGIN: - switch (c) { - case ':': - case '-': - case '/': - _memstream_getc(ms); - return c; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return get_imm(ms, ps); - } - break; - case S_OFFSET: - switch (c) { - case '/': - _memstream_getc(ms); - return c; - case '+': - case '-': - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - case '8': - case '9': - return get_imm(ms, ps); - } - break; - } - return T_ERR; -} - -static int -parse_zone(struct _memstream *ms, struct _parse_state *ps, struct _zone *z) -{ - if (get_tok(ms, ps) != T_IMM) - return -1; - z->z_begin = ps->ps_u_imm; - if (get_tok(ms, ps) != '-') - return -1; - if (get_tok(ms, ps) != T_IMM) - return -1; - z->z_end = ps->ps_u_imm; - - if (z->z_begin > z->z_end) - return -1; - - return 0; -} - -static int -check_rowcol(struct _zone *z, int32_t ofs, uint32_t maxval) -{ - u_int32_t remain; - - if (maxval != 0 && z->z_end >= maxval) - return -1; - - if (ofs > 0) { - if (maxval == 0) { - /* this should 0x100000000 - z->z_end */ - if (z->z_end == 0) { - remain = 0xFFFFFFFF; - } else { - remain = 0xFFFFFFFF - z->z_end + 1; - } - } else - remain = maxval - z->z_end; - if ((u_int32_t)ofs > remain) - return -1; - } else if (ofs < 0) { - if (z->z_begin < (u_int32_t)-ofs) - return -1; - } - - return 0; -} - -static int -parse_var(struct _citrus_mapper_zone *mz, struct _memstream *ms) -{ - struct _parse_state ps; - int ret, isrc; - uint32_t rowmax, colmax; - - ps.ps_state = S_BEGIN; - - if (parse_zone(ms, &ps, &mz->mz_col)) - return -1; - - ret = get_tok(ms, &ps); - if (ret == '/') { - /* rowzone / colzone / bits */ - isrc = 1; - mz->mz_row = mz->mz_col; - - if (parse_zone(ms, &ps, &mz->mz_col)) - return -1; - if (get_tok(ms, &ps) != '/') - return -1; - if (get_tok(ms, &ps) != T_IMM) - return -1; - mz->mz_col_bits = ps.ps_u_imm; - if (mz->mz_col_bits<0 || mz->mz_col_bits>32) - return -1; - ret = get_tok(ms, &ps); - } else { - /* colzone */ - isrc = 0; - mz->mz_col_bits = 32; - mz->mz_row.z_begin = mz->mz_row.z_end = 0; - } - if (ret == ':') { - /* offset */ - ps.ps_state = S_OFFSET; - if (get_tok(ms, &ps) != T_IMM) - return -1; - mz->mz_col_offset = ps.ps_s_imm; - if (isrc) { - /* row/col */ - mz->mz_row_offset = mz->mz_col_offset; - if (get_tok(ms, &ps) != '/') - return -1; - if (get_tok(ms, &ps) != T_IMM) - return -1; - mz->mz_col_offset = ps.ps_s_imm; - } else - mz->mz_row_offset = 0; - ret = get_tok(ms, &ps); - } - if (ret != EOF) - return -1; - - /* sanity check */ - if (mz->mz_col_bits==32) - colmax = 0; - else - colmax = 1 << mz->mz_col_bits; - if (mz->mz_col_bits==0) - rowmax = 0; - else - rowmax = 1 << (32-mz->mz_col_bits); - if (check_rowcol(&mz->mz_col, mz->mz_col_offset, colmax)) - return -1; - if (check_rowcol(&mz->mz_row, mz->mz_row_offset, rowmax)) - return -1; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_mapper_zone_mapper_init(struct _citrus_mapper_area *__restrict ma, - struct _citrus_mapper * __restrict cm, - const char * __restrict dir, - const void * __restrict var, size_t lenvar, - struct _citrus_mapper_traits * __restrict mt, - size_t lenmt) -{ - struct _citrus_mapper_zone *mz; - struct _memstream ms; - struct _region r; - - _DIAGASSERT(cm && dir && mt); - - if (lenmtmz_col.z_begin = mz->mz_col.z_end = 0; - mz->mz_row.z_begin = mz->mz_row.z_end = 0; - mz->mz_col_bits = 0; - mz->mz_row_offset = 0; - mz->mz_col_offset = 0; - - _region_init(&r, (void *)var, lenvar); - _memstream_bind(&ms, &r); - if (parse_var(mz, &ms)) { - free(mz); - return EINVAL; - } - cm->cm_closure = mz; - mt->mt_src_max = mt->mt_dst_max = 1; /* 1:1 converter */ - mt->mt_state_size = 0; /* stateless */ - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_zone_mapper_uninit(struct _citrus_mapper *cm) -{ -} - -static int -/*ARGSUSED*/ -_citrus_mapper_zone_mapper_convert(struct _citrus_mapper * __restrict cm, - _citrus_index_t * __restrict dst, - _citrus_index_t src, void * __restrict ps) -{ - u_int32_t row, col; - struct _citrus_mapper_zone *mz = cm->cm_closure; - - if (mz->mz_col_bits == 32) { - col = src; - row = 0; - if (col < mz->mz_col.z_begin || col > mz->mz_col.z_end) - return _CITRUS_MAPPER_CONVERT_NONIDENTICAL; - if (mz->mz_col_offset>0) - col += (u_int32_t)mz->mz_col_offset; - else - col -= (u_int32_t)-mz->mz_col_offset; - *dst = col; - } else { - col = src & (((u_int32_t)1<mz_col_bits)-1); - row = src >> mz->mz_col_bits; - if (row < mz->mz_row.z_begin || row > mz->mz_row.z_end || - col < mz->mz_col.z_begin || col > mz->mz_col.z_end) - return _CITRUS_MAPPER_CONVERT_NONIDENTICAL; - if (mz->mz_col_offset>0) - col += (u_int32_t)mz->mz_col_offset; - else - col -= (u_int32_t)-mz->mz_col_offset; - if (mz->mz_row_offset>0) - row += (u_int32_t)mz->mz_row_offset; - else - row -= (u_int32_t)-mz->mz_row_offset; - *dst = col | (row << mz->mz_col_bits); - } - return _CITRUS_MAPPER_CONVERT_SUCCESS; -} - -static void -/*ARGSUSED*/ -_citrus_mapper_zone_mapper_init_state(struct _citrus_mapper * __restrict cm, - void * __restrict ps) -{ -} diff --git a/lib/libc/citrus/modules/citrus_mapper_zone.h b/lib/libc/citrus/modules/citrus_mapper_zone.h deleted file mode 100644 index d975dd127..000000000 --- a/lib/libc/citrus/modules/citrus_mapper_zone.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_mapper_zone.h,v 1.1 2003/06/25 09:51:48 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MAPPER_ZONE_H_ -#define _CITRUS_MAPPER_ZONE_H_ - -__BEGIN_DECLS -_CITRUS_MAPPER_GETOPS_FUNC(mapper_zone); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_mskanji.c b/lib/libc/citrus/modules/citrus_mskanji.c deleted file mode 100644 index 808ca35e8..000000000 --- a/lib/libc/citrus/modules/citrus_mskanji.c +++ /dev/null @@ -1,546 +0,0 @@ -/* $NetBSD: citrus_mskanji.c,v 1.14 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -/* - * ja_JP.SJIS locale table for BSD4.4/rune - * version 1.0 - * (C) Sin'ichiro MIYATANI / Phase One, Inc - * May 12, 1995 - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Phase One, Inc. - * 4. The name of Phase One, Inc. 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_mskanji.c,v 1.14 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_mskanji.h" - - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct _MSKanjiState { - char ch[2]; - int chlen; -} _MSKanjiState; - -typedef struct { - int mode; -#define MODE_JIS2004 1 -} _MSKanjiEncodingInfo; - -typedef struct { - _MSKanjiEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _MSKanjiState s_mblen; - _MSKanjiState s_mbrlen; - _MSKanjiState s_mbrtowc; - _MSKanjiState s_mbtowc; - _MSKanjiState s_mbsrtowcs; - _MSKanjiState s_mbsnrtowcs; - _MSKanjiState s_wcrtomb; - _MSKanjiState s_wcsrtombs; - _MSKanjiState s_wcsnrtombs; - _MSKanjiState s_wctomb; - } states; -} _MSKanjiCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_MSKanji_##m -#define _ENCODING_INFO _MSKanjiEncodingInfo -#define _CTYPE_INFO _MSKanjiCTypeInfo -#define _ENCODING_STATE _MSKanjiState -#define _ENCODING_MB_CUR_MAX(_ei_) 2 -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - - -static int -_mskanji1(int c) -{ - - if ((c >= 0x81 && c <= 0x9f) || (c >= 0xe0 && c <= 0xfc)) - return 1; - else - return 0; -} - -static int -_mskanji2(int c) -{ - - if ((c >= 0x40 && c <= 0x7e) || (c >= 0x80 && c <= 0xfc)) - return 1; - else - return 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_MSKanji_init_state(_MSKanjiEncodingInfo * __restrict ei, - _MSKanjiState * __restrict s) -{ - s->chlen = 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_MSKanji_pack_state(_MSKanjiEncodingInfo * __restrict ei, - void * __restrict pspriv, - const _MSKanjiState * __restrict s) -{ - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_MSKanji_unpack_state(_MSKanjiEncodingInfo * __restrict ei, - _MSKanjiState * __restrict s, - const void * __restrict pspriv) -{ - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static int -/*ARGSUSED*/ -_citrus_MSKanji_mbrtowc_priv(_MSKanjiEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, - const char ** __restrict s, size_t n, - _MSKanjiState * __restrict psenc, - size_t * __restrict nresult) -{ - wchar_t wchar; - int len; - int chlenbak; - const char *s0; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - - s0 = *s; - - if (s0 == NULL) { - _citrus_MSKanji_init_state(ei, psenc); - *nresult = 0; /* state independent */ - return (0); - } - - chlenbak = psenc->chlen; - - /* make sure we have the first byte in the buffer */ - switch (psenc->chlen) { - case 0: - if (n < 1) - goto restart; - psenc->ch[0] = *s0++; - psenc->chlen = 1; - n--; - break; - case 1: - break; - default: - /* illegal state */ - goto encoding_error; - } - - len = _mskanji1(psenc->ch[0] & 0xff) ? 2 : 1; - while (psenc->chlen < len) { - if (n < 1) - goto restart; - psenc->ch[psenc->chlen] = *s0++; - psenc->chlen++; - n--; - } - - *s = s0; - - switch (len) { - case 1: - wchar = psenc->ch[0] & 0xff; - break; - case 2: - if (!_mskanji2(psenc->ch[1] & 0xff)) - goto encoding_error; - wchar = ((psenc->ch[0] & 0xff) << 8) | (psenc->ch[1] & 0xff); - break; - default: - /* illegal state */ - goto encoding_error; - } - - psenc->chlen = 0; - - if (pwc) - *pwc = wchar; - - if (!wchar) - *nresult = 0; - else - *nresult = len - chlenbak; - - return (0); - -encoding_error: - psenc->chlen = 0; - *nresult = (size_t)-1; - return (EILSEQ); - -restart: - *nresult = (size_t)-2; - *s = s0; - return (0); -} - - -static int -_citrus_MSKanji_wcrtomb_priv(_MSKanjiEncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _MSKanjiState * __restrict psenc, - size_t * __restrict nresult) -{ - int ret; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(s != NULL); - - /* check invalid sequence */ - if (wc & ~0xffff) { - ret = EILSEQ; - goto err; - } - - if (wc & 0xff00) { - if (n < 2) { - ret = E2BIG; - goto err; - } - - s[0] = (wc >> 8) & 0xff; - s[1] = wc & 0xff; - if (!_mskanji1(s[0] & 0xff) || !_mskanji2(s[1] & 0xff)) { - ret = EILSEQ; - goto err; - } - - *nresult = 2; - return 0; - } else { - if (n < 1) { - ret = E2BIG; - goto err; - } - - s[0] = wc & 0xff; - if (_mskanji1(s[0] & 0xff)) { - ret = EILSEQ; - goto err; - } - - *nresult = 1; - return 0; - } - -err: - *nresult = (size_t)-1; - return ret; -} - - -static __inline int -/*ARGSUSED*/ -_citrus_MSKanji_stdenc_wctocs(_MSKanjiEncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, wchar_t wc) -{ - _index_t row, col; - int offset; - - _DIAGASSERT(csid != NULL && idx != NULL); - - if ((_wc_t)wc < 0x80) { - /* ISO-646 */ - *csid = 0; - *idx = (_index_t)wc; - } else if ((_wc_t)wc < 0x100) { - /* KANA */ - *csid = 1; - *idx = (_index_t)wc & 0x7F; - } else { - /* Kanji (containing Gaiji zone) */ - /* - * 94^2 zone (contains a part of Gaiji (0xED40 - 0xEEFC)): - * 0x8140 - 0x817E -> 0x2121 - 0x215F - * 0x8180 - 0x819E -> 0x2160 - 0x217E - * 0x819F - 0x81FC -> 0x2221 - 0x227E - * - * 0x8240 - 0x827E -> 0x2321 - 0x235F - * ... - * 0x9F9F - 0x9FFc -> 0x5E21 - 0x5E7E - * - * 0xE040 - 0xE07E -> 0x5F21 - 0x5F5F - * ... - * 0xEF9F - 0xEFFC -> 0x7E21 - 0x7E7E - * - * extended Gaiji zone: - * 0xF040 - 0xFCFC - * - * JIS X0213-plane2: - * 0xF040 - 0xF09E -> 0x2121 - 0x217E - * 0xF140 - 0xF19E -> 0x2321 - 0x237E - * ... - * 0xF240 - 0xF29E -> 0x2521 - 0x257E - * - * 0xF09F - 0xF0FC -> 0x2821 - 0x287E - * 0xF29F - 0xF2FC -> 0x2C21 - 0x2C7E - * ... - * 0xF44F - 0xF49E -> 0x2F21 - 0x2F7E - * - * 0xF49F - 0xF4FC -> 0x6E21 - 0x6E7E - * ... - * 0xFC9F - 0xFCFC -> 0x7E21 - 0x7E7E - */ - row = ((_wc_t)wc >> 8) & 0xFF; - col = (_wc_t)wc & 0xFF; - if (!_mskanji1(row) || !_mskanji2(col)) - return EILSEQ; - if ((ei->mode & MODE_JIS2004) == 0 || row < 0xF0) { - *csid = 2; - offset = 0x81; - } else { - *csid = 3; - if ((_wc_t)wc <= 0xF49E) { - offset = (_wc_t)wc >= 0xF29F || - ((_wc_t)wc >= 0xF09F && (_wc_t)wc <= 0xF0FC) - ? 0xED : 0xF0; - } else - offset = 0xCE; - } - row -= offset; - if (row >= 0x5F) - row -= 0x40; - row = row * 2 + 0x21; - col -= 0x1F; - if (col >= 0x61) - col -= 1; - if (col > 0x7E) { - row += 1; - col -= 0x5E; - } - *idx = ((_index_t)row << 8) | col; - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_MSKanji_stdenc_cstowc(_MSKanjiEncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - u_int32_t row, col; - int offset; - - _DIAGASSERT(wc != NULL); - - switch (csid) { - case 0: - /* ISO-646 */ - if (idx >= 0x80) - return EILSEQ; - *wc = (wchar_t)idx; - break; - case 1: - /* kana */ - if (idx >= 0x80) - return EILSEQ; - *wc = (wchar_t)idx + 0x80; - break; - case 3: - if ((ei->mode & MODE_JIS2004) == 0) - return EILSEQ; - /*FALLTHROUGH*/ - case 2: - /* kanji */ - row = (idx >> 8); - if (row < 0x21) - return EILSEQ; - if (csid == 3) { - if (row <= 0x2F) - offset = (row == 0x22 || row >= 0x26) - ? 0xED : 0xF0; - else if (row >= 0x4D && row <= 0x7E) - offset = 0xCE; - else - return EILSEQ; - } else { - if (row > 0x97) - return EILSEQ; - offset = (row < 0x5F) ? 0x81 : 0xC1; - } - col = idx & 0xFF; - if (col < 0x21 || col > 0x7E) - return EILSEQ; - row -= 0x21; col -= 0x21; - if ((row & 1) == 0) { - col += 0x40; - if (col >= 0x7F) - col += 1; - } else - col += 0x9F; - row = row / 2 + offset; - *wc = ((wchar_t)row << 8) | col; - break; - default: - return EILSEQ; - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_MSKanji_stdenc_get_state_desc_generic(_MSKanjiEncodingInfo * __restrict ei, - _MSKanjiState * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_MSKanji_encoding_module_init(_MSKanjiEncodingInfo * __restrict ei, - const void * __restrict var, - size_t lenvar) -{ - const char *p; - - _DIAGASSERT(ei != NULL); - - p = var; -#define MATCH(x, act) \ -do { \ - if (lenvar >= (sizeof(#x)-1) && \ - _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) { \ - act; \ - lenvar -= sizeof(#x)-1; \ - p += sizeof(#x)-1; \ - } \ -} while (/*CONSTCOND*/0) - memset((void *)ei, 0, sizeof(*ei)); - while (lenvar > 0) { - switch (_bcs_toupper(*p)) { - case 'J': - MATCH(JIS2004, ei->mode |= MODE_JIS2004); - break; - } - ++p; - --lenvar; - } - - return 0; -} - -static void -_citrus_MSKanji_encoding_module_uninit(_MSKanjiEncodingInfo *ei) -{ -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(MSKanji); -_CITRUS_CTYPE_DEF_OPS(MSKanji); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(MSKanji); -_CITRUS_STDENC_DEF_OPS(MSKanji); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_mskanji.h b/lib/libc/citrus/modules/citrus_mskanji.h deleted file mode 100644 index 90aebe1b1..000000000 --- a/lib/libc/citrus/modules/citrus_mskanji.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_mskanji.h,v 1.2 2003/06/25 09:51:48 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_MSKANJI_H_ -#define _CITRUS_MSKANJI_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(MSKanji); -_CITRUS_STDENC_GETOPS_FUNC(MSKanji); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_ues.c b/lib/libc/citrus/modules/citrus_ues.c deleted file mode 100644 index fa818e1f5..000000000 --- a/lib/libc/citrus/modules/citrus_ues.c +++ /dev/null @@ -1,474 +0,0 @@ -/* $NetBSD: citrus_ues.c,v 1.4 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_ues.c,v 1.4 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_ues.h" - -typedef struct { - int mode; -#define MODE_C99 1 - size_t mb_cur_max; -} _UESEncodingInfo; - -typedef struct { - int chlen; - char ch[12]; -} _UESState; - -typedef struct { - _UESEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _UESState s_mblen; - _UESState s_mbrlen; - _UESState s_mbrtowc; - _UESState s_mbtowc; - _UESState s_mbsrtowcs; - _UESState s_mbsnrtowcs; - _UESState s_wcrtomb; - _UESState s_wcsrtombs; - _UESState s_wcsnrtombs; - _UESState s_wctomb; - } states; -} _UESCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_UES_##m -#define _ENCODING_INFO _UESEncodingInfo -#define _CTYPE_INFO _UESCTypeInfo -#define _ENCODING_STATE _UESState -#define _ENCODING_MB_CUR_MAX(_ei_) (_ei_)->mb_cur_max -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - -static __inline void -/*ARGSUSED*/ -_citrus_UES_init_state(_UESEncodingInfo * __restrict ei, - _UESState * __restrict psenc) -{ - psenc->chlen = 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_UES_pack_state(_UESEncodingInfo * __restrict ei, - void *__restrict pspriv, const _UESState * __restrict psenc) -{ - /* ei seem to be unused */ - _DIAGASSERT(pspriv != NULL); - _DIAGASSERT(psenc != NULL); - - memcpy(pspriv, (const void *)psenc, sizeof(*psenc)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_UES_unpack_state(_UESEncodingInfo * __restrict ei, - _UESState * __restrict psenc, const void * __restrict pspriv) -{ - /* ei seem to be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(pspriv != NULL); - - memcpy((void *)psenc, pspriv, sizeof(*psenc)); -} - -static __inline int -to_int(int ch) -{ - if (ch >= '0' && ch <= '9') - return ch - '0'; - else if (ch >= 'A' && ch <= 'F') - return (ch - 'A') + 10; - else if (ch >= 'a' && ch <= 'f') - return (ch - 'a') + 10; - return -1; -} - -#define ESCAPE '\\' -#define UCS2_ESC 'u' -#define UCS4_ESC 'U' - -#define UCS2_BIT 16 -#define UCS4_BIT 32 -#define BMP_MAX UINT32_C(0xFFFF) -#define UCS2_MAX UINT32_C(0x10FFFF) -#define UCS4_MAX UINT32_C(0x7FFFFFFF) - -static const char *xdig = "0123456789abcdef"; - -static __inline int -to_str(char *s, wchar_t wc, int bit) -{ - char *p; - - p = s; - *p++ = ESCAPE; - switch (bit) { - case UCS2_BIT: - *p++ = UCS2_ESC; - break; - case UCS4_BIT: - *p++ = UCS4_ESC; - break; - default: - abort(); - } - do { - *p++ = xdig[(wc >> (bit -= 4)) & 0xF]; - } while (bit > 0); - return p - s; -} - -static __inline int -is_hi_surrogate(wchar_t wc) -{ - return wc >= 0xD800 && wc <= 0xDBFF; -} - -static __inline int -is_lo_surrogate(wchar_t wc) -{ - return wc >= 0xDC00 && wc <= 0xDFFF; -} - -static __inline wchar_t -surrogate_to_ucs(wchar_t hi, wchar_t lo) -{ - _DIAGASSERT(is_hi_surrogate(hi)); - _DIAGASSERT(is_lo_surrogate(lo)); - - hi -= 0xD800; - lo -= 0xDC00; - return (hi << 10 | lo) + 0x10000; -} - -static __inline void -ucs_to_surrogate(wchar_t wc, wchar_t * __restrict hi, wchar_t * __restrict lo) -{ - _DIAGASSERT(hi != NULL); - _DIAGASSERT(lo != NULL); - _DIAGASSERT(wc >= 0x10000); - - wc -= 0x10000; - *hi = (wc >> 10) + 0xD800; - *lo = (wc & 0x3FF) + 0xDC00; -} - -static __inline int -is_basic(wchar_t wc) -{ - return (uint32_t)wc <= 0x9F && - wc != 0x24 && wc != 0x40 && wc != 0x60; -} - -static int -_citrus_UES_mbrtowc_priv(_UESEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, const char ** __restrict s, size_t n, - _UESState * __restrict psenc, size_t * __restrict nresult) -{ - const char *s0; - int ch, head, tail, num; - wchar_t hi, wc; - - _DIAGASSERT(ei != NULL); - /* pwc may be null */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (*s == NULL) { - _citrus_UES_init_state(ei, psenc); - *nresult = 0; - return 0; - } - s0 = *s; - - hi = (wchar_t)0; - tail = 0; - -surrogate: - wc = (wchar_t)0; - head = tail; - if (psenc->chlen == head) { - if (n-- < 1) - goto restart; - psenc->ch[psenc->chlen++] = *s0++; - } - ch = (unsigned char)psenc->ch[head++]; - if (ch == ESCAPE) { - if (psenc->chlen == head) { - if (n-- < 1) - goto restart; - psenc->ch[psenc->chlen++] = *s0++; - } - switch (psenc->ch[head]) { - case UCS2_ESC: - tail += 6; - break; - case UCS4_ESC: - if (ei->mode & MODE_C99) { - tail = 10; - break; - } - /*FALLTHROUGH*/ - default: - tail = 0; - } - ++head; - } - for (; head < tail; ++head) { - if (psenc->chlen == head) { - if (n-- < 1) { -restart: - *s = s0; - *nresult = (size_t)-2; - return 0; - } - psenc->ch[psenc->chlen++] = *s0++; - } - num = to_int((int)(unsigned char)psenc->ch[head]); - if (num < 0) { - tail = 0; - break; - } - wc = (wc << 4) | num; - } - head = 0; - switch (tail) { - case 0: - break; - case 6: - if (hi != (wchar_t)0) - break; - if ((ei->mode & MODE_C99) == 0) { - if (is_hi_surrogate(wc) != 0) { - hi = wc; - goto surrogate; - } - if ((uint32_t)wc <= 0x7F /* XXX */ || - is_lo_surrogate(wc) != 0) - break; - goto done; - } - /*FALLTHROUGH*/ - case 10: - if (is_basic(wc) == 0 && (uint32_t)wc <= UCS4_MAX && - is_hi_surrogate(wc) == 0 && is_lo_surrogate(wc) == 0) - goto done; - *nresult = (size_t)-1; - return EILSEQ; - case 12: - if (is_lo_surrogate(wc) == 0) - break; - wc = surrogate_to_ucs(hi, wc); - goto done; - } - ch = (unsigned char)psenc->ch[0]; - head = psenc->chlen; - if (--head > 0) - memmove(&psenc->ch[0], &psenc->ch[1], head); - wc = (wchar_t)ch; -done: - psenc->chlen = head; - if (pwc != NULL) - *pwc = wc; - *nresult = (size_t)((wc == 0) ? 0 : (s0 - *s)); - *s = s0; - - return 0; -} - -static int -_citrus_UES_wcrtomb_priv(_UESEncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _UESState * __restrict psenc, size_t * __restrict nresult) -{ - wchar_t hi, lo; - - if (psenc->chlen != 0) - return EINVAL; - - if ((ei->mode & MODE_C99) ? is_basic(wc) : (uint32_t)wc <= 0x7F) { - if (n-- < 1) - goto e2big; - psenc->ch[psenc->chlen++] = (char)wc; - } else if ((uint32_t)wc <= BMP_MAX) { - if (n < 6) - goto e2big; - psenc->chlen = to_str(&psenc->ch[0], wc, UCS2_BIT); - } else if ((ei->mode & MODE_C99) == 0 && (uint32_t)wc <= UCS2_MAX) { - if (n < 12) - goto e2big; - ucs_to_surrogate(wc, &hi, &lo); - psenc->chlen += to_str(&psenc->ch[0], hi, UCS2_BIT); - psenc->chlen += to_str(&psenc->ch[6], lo, UCS2_BIT); - } else if ((ei->mode & MODE_C99) && (uint32_t)wc <= UCS4_MAX) { - if (n < 10) - goto e2big; - psenc->chlen = to_str(&psenc->ch[0], wc, UCS4_BIT); - } else { - *nresult = (size_t)-1; - return EILSEQ; - } - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - psenc->chlen = 0; - - return 0; - -e2big: - *nresult = (size_t)-1; - return E2BIG; -} - -/*ARGSUSED*/ -static int -_citrus_UES_stdenc_wctocs(_UESEncodingInfo * __restrict ei, - _csid_t * __restrict csid, _index_t * __restrict idx, wchar_t wc) -{ - /* ei seem to be unused */ - _DIAGASSERT(csid != NULL); - _DIAGASSERT(idx != NULL); - - *csid = 0; - *idx = (_index_t)wc; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_UES_stdenc_cstowc(_UESEncodingInfo * __restrict ei, - wchar_t * __restrict wc, _csid_t csid, _index_t idx) -{ - /* ei seem to be unused */ - _DIAGASSERT(wc != NULL); - - if (csid != 0) - return EILSEQ; - *wc = (wchar_t)idx; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_UES_stdenc_get_state_desc_generic(_UESEncodingInfo * __restrict ei, - _UESState * __restrict psenc, int * __restrict rstate) -{ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(rstate != NULL); - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; /* XXX */ - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_UES_encoding_module_uninit(_UESEncodingInfo *ei) -{ - /* ei seems to be unused */ -} - -static int -/*ARGSUSED*/ -_citrus_UES_encoding_module_init(_UESEncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - const char *p; - - _DIAGASSERT(ei != NULL); - - p = var; -#define MATCH(x, act) \ -do { \ - if (lenvar >= (sizeof(#x)-1) && \ - _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) { \ - act; \ - lenvar -= sizeof(#x)-1; \ - p += sizeof(#x)-1; \ - } \ -} while (/*CONSTCOND*/0) - memset((void *)ei, 0, sizeof(*ei)); - while (lenvar > 0) { - switch (_bcs_toupper(*p)) { - case 'C': - MATCH(C99, ei->mode |= MODE_C99); - break; - } - ++p; - --lenvar; - } - ei->mb_cur_max = (ei->mode & MODE_C99) ? 10 : 12; - - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(UES); -_CITRUS_CTYPE_DEF_OPS(UES); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(UES); -_CITRUS_STDENC_DEF_OPS(UES); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_ues.h b/lib/libc/citrus/modules/citrus_ues.h deleted file mode 100644 index 0df7f27a0..000000000 --- a/lib/libc/citrus/modules/citrus_ues.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_ues.h,v 1.1 2006/11/13 15:16:31 tnozaki Exp $ */ - -/*- - * Copyright (c)2004, 2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_UES_H_ -#define _CITRUS_UES_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(UES); -_CITRUS_STDENC_GETOPS_FUNC(UES); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_utf1632.c b/lib/libc/citrus/modules/citrus_utf1632.c deleted file mode 100644 index ce05d2117..000000000 --- a/lib/libc/citrus/modules/citrus_utf1632.c +++ /dev/null @@ -1,485 +0,0 @@ -/* $NetBSD: citrus_utf1632.c,v 1.12 2012/02/12 13:51:29 wiz Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_utf1632.c,v 1.12 2012/02/12 13:51:29 wiz Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_stdenc.h" -#include "citrus_bcs.h" - -#include "citrus_utf1632.h" - - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - u_int8_t ch[4]; - int chlen; - int current_endian; -} _UTF1632State; - -typedef struct { - int preffered_endian; - unsigned int cur_max; -#define _ENDIAN_UNKNOWN 0 -#define _ENDIAN_BIG 1 -#define _ENDIAN_LITTLE 2 - u_int32_t mode; -#define _MODE_UTF32 0x00000001U -#define _MODE_FORCE_ENDIAN 0x00000002U -} _UTF1632EncodingInfo; - -#define _FUNCNAME(m) _citrus_UTF1632_##m -#define _ENCODING_INFO _UTF1632EncodingInfo -#define _ENCODING_STATE _UTF1632State -#define _ENCODING_MB_CUR_MAX(_ei_) ((_ei_)->cur_max) -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - - -static __inline void -/*ARGSUSED*/ -_citrus_UTF1632_init_state(_UTF1632EncodingInfo *ei, _UTF1632State *s) -{ - memset(s, 0, sizeof(*s)); -} - -static int -_citrus_UTF1632_mbrtowc_priv(_UTF1632EncodingInfo *ei, wchar_t *pwc, - const char **s, size_t n, _UTF1632State *psenc, - size_t *nresult) -{ - int chlenbak, endian, needlen; - wchar_t wc; - size_t result; - const char *s0; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - - s0 = *s; - - if (s0 == NULL) { - _citrus_UTF1632_init_state(ei, psenc); - *nresult = 0; /* state independent */ - return (0); - } - - result = 0; - chlenbak = psenc->chlen; - -refetch: - if ((ei->mode & _MODE_UTF32) != 0 || chlenbak>=2) - needlen = 4; - else - needlen = 2; - - while (chlenbak < needlen) { - if (n==0) - goto restart; - psenc->ch[chlenbak++] = *s0++; - n--; - result++; - } - - if (psenc->current_endian == _ENDIAN_UNKNOWN) { - if ((ei->mode & _MODE_FORCE_ENDIAN) == 0) { - /* judge endian marker */ - if ((ei->mode & _MODE_UTF32) == 0) { - /* UTF16 */ - if (psenc->ch[0]==0xFE && psenc->ch[1]==0xFF) { - psenc->current_endian = _ENDIAN_BIG; - chlenbak = 0; - goto refetch; - } else if (psenc->ch[0]==0xFF && psenc->ch[1]==0xFE) { - psenc->current_endian = _ENDIAN_LITTLE; - chlenbak = 0; - goto refetch; - } - } else { - /* UTF32 */ - if (psenc->ch[0]==0x00 && psenc->ch[1]==0x00 && - psenc->ch[2]==0xFE && psenc->ch[3]==0xFF) { - psenc->current_endian = _ENDIAN_BIG; - chlenbak = 0; - goto refetch; - } else if (psenc->ch[0]==0xFF && psenc->ch[1]==0xFE && - psenc->ch[2]==0x00 && psenc->ch[3]==0x00) { - psenc->current_endian = _ENDIAN_LITTLE; - chlenbak = 0; - goto refetch; - } - } - } - psenc->current_endian = ei->preffered_endian; - } - endian = psenc->current_endian; - - /* get wc */ - if ((ei->mode & _MODE_UTF32) == 0) { - /* UTF16 */ - if (needlen==2) { - switch (endian) { - case _ENDIAN_LITTLE: - wc = (psenc->ch[0] | - ((wchar_t)psenc->ch[1] << 8)); - break; - case _ENDIAN_BIG: - wc = (psenc->ch[1] | - ((wchar_t)psenc->ch[0] << 8)); - break; - default: - goto ilseq; - } - if (wc >= 0xD800 && wc <= 0xDBFF) { - /* surrogate high */ - needlen=4; - goto refetch; - } - } else { - /* surrogate low */ - wc -= 0xD800; /* wc : surrogate high (see above) */ - wc <<= 10; - switch (endian) { - case _ENDIAN_LITTLE: - if (psenc->ch[3]<0xDC || psenc->ch[3]>0xDF) - goto ilseq; - wc |= psenc->ch[2]; - wc |= (wchar_t)(psenc->ch[3] & 3) << 8; - break; - case _ENDIAN_BIG: - if (psenc->ch[2]<0xDC || psenc->ch[2]>0xDF) - goto ilseq; - wc |= psenc->ch[3]; - wc |= (wchar_t)(psenc->ch[2] & 3) << 8; - break; - default: - goto ilseq; - } - wc += 0x10000; - } - } else { - /* UTF32 */ - switch (endian) { - case _ENDIAN_LITTLE: - wc = (psenc->ch[0] | - ((wchar_t)psenc->ch[1] << 8) | - ((wchar_t)psenc->ch[2] << 16) | - ((wchar_t)psenc->ch[3] << 24)); - break; - case _ENDIAN_BIG: - wc = (psenc->ch[3] | - ((wchar_t)psenc->ch[2] << 8) | - ((wchar_t)psenc->ch[1] << 16) | - ((wchar_t)psenc->ch[0] << 24)); - break; - default: - goto ilseq; - } - if (wc >= 0xD800 && wc <= 0xDFFF) - goto ilseq; - } - - - *pwc = wc; - psenc->chlen = 0; - *nresult = result; - *s = s0; - - return (0); - -ilseq: - *nresult = (size_t)-1; - psenc->chlen = 0; - return (EILSEQ); - -restart: - *nresult = (size_t)-2; - psenc->chlen = chlenbak; - *s = s0; - return (0); -} - -static int -_citrus_UTF1632_wcrtomb_priv(_UTF1632EncodingInfo *ei, char *s, size_t n, - wchar_t wc, _UTF1632State *psenc, - size_t *nresult) -{ - wchar_t wc2; - static const char _bom[4] = { -#if BYTE_ORDER == BIG_ENDIAN - 0x00, 0x00, 0xFE, 0xFF, -#else - 0xFF, 0xFE, 0x00, 0x00, -#endif - }; - const char *bom = &_bom[0]; - size_t cnt; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(nresult != 0); - _DIAGASSERT(s != NULL); - - cnt = (size_t)0; - if (psenc->current_endian == _ENDIAN_UNKNOWN) { - if ((ei->mode & _MODE_FORCE_ENDIAN) == 0) { - if (ei->mode & _MODE_UTF32) { - cnt = 4; - } else { - cnt = 2; -#if BYTE_ORDER == BIG_ENDIAN - bom += 2; -#endif - } - if (n < cnt) - goto e2big; - memcpy(s, bom, cnt); - s += cnt, n -= cnt; - } - psenc->current_endian = ei->preffered_endian; - } - - wc2 = 0; - if ((ei->mode & _MODE_UTF32)==0) { - /* UTF16 */ - if (wc>0xFFFF) { - /* surrogate */ - if (wc>0x10FFFF) - goto ilseq; - if (n < 4) - goto e2big; - cnt += 4; - wc -= 0x10000; - wc2 = (wc & 0x3FF) | 0xDC00; - wc = (wc>>10) | 0xD800; - } else { - if (n < 2) - goto e2big; - cnt += 2; - } - -surrogate: - switch (psenc->current_endian) { - case _ENDIAN_BIG: - s[1] = wc; - s[0] = (wc >>= 8); - break; - case _ENDIAN_LITTLE: - s[0] = wc; - s[1] = (wc >>= 8); - break; - } - if (wc2!=0) { - wc = wc2; - wc2 = 0; - s += 2; - goto surrogate; - } - } else { - /* UTF32 */ - if (wc >= 0xD800 && wc <= 0xDFFF) - goto ilseq; - if (n < 4) - goto e2big; - cnt += 4; - switch (psenc->current_endian) { - case _ENDIAN_BIG: - s[3] = wc; - s[2] = (wc >>= 8); - s[1] = (wc >>= 8); - s[0] = (wc >>= 8); - break; - case _ENDIAN_LITTLE: - s[0] = wc; - s[1] = (wc >>= 8); - s[2] = (wc >>= 8); - s[3] = (wc >>= 8); - break; - } - } - *nresult = cnt; - - return 0; - -ilseq: - *nresult = (size_t)-1; - return EILSEQ; -e2big: - *nresult = (size_t)-1; - return E2BIG; -} - -static void -parse_variable(_UTF1632EncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ -#define MATCH(x, act) \ -do { \ - if (lenvar >= (sizeof(#x)-1) && \ - _bcs_strncasecmp(p, #x, sizeof(#x)-1) == 0) { \ - act; \ - lenvar -= sizeof(#x)-1; \ - p += sizeof(#x)-1; \ - } \ -} while (/*CONSTCOND*/0) - const char *p; - p = var; - while (lenvar>0) { - switch (*p) { - case 'B': - case 'b': - MATCH(big, ei->preffered_endian = _ENDIAN_BIG); - break; - case 'L': - case 'l': - MATCH(little, ei->preffered_endian = _ENDIAN_LITTLE); - break; - case 'F': - case 'f': - MATCH(force, ei->mode |= _MODE_FORCE_ENDIAN); - break; - case 'U': - case 'u': - MATCH(utf32, ei->mode |= _MODE_UTF32); - break; - } - p++; - lenvar--; - } -} - -static int -/*ARGSUSED*/ -_citrus_UTF1632_encoding_module_init(_UTF1632EncodingInfo * __restrict ei, - const void * __restrict var, - size_t lenvar) -{ - _DIAGASSERT(ei != NULL); - - memset((void *)ei, 0, sizeof(*ei)); - - parse_variable(ei, var, lenvar); - - if ((ei->mode&_MODE_UTF32)==0) - ei->cur_max = 6; /* endian + surrogate */ - else - ei->cur_max = 8; /* endian + normal */ - - if (ei->preffered_endian == _ENDIAN_UNKNOWN) { -#if BYTE_ORDER == BIG_ENDIAN - ei->preffered_endian = _ENDIAN_BIG; -#else - ei->preffered_endian = _ENDIAN_LITTLE; -#endif - } - - return (0); -} - -static void -/*ARGSUSED*/ -_citrus_UTF1632_encoding_module_uninit(_UTF1632EncodingInfo *ei) -{ -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF1632_stdenc_wctocs(_UTF1632EncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, - _wc_t wc) -{ - - _DIAGASSERT(csid != NULL && idx != NULL); - - *csid = 0; - *idx = (_index_t)wc; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF1632_stdenc_cstowc(_UTF1632EncodingInfo * __restrict ei, - _wc_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - - _DIAGASSERT(wc != NULL); - - if (csid != 0) - return (EILSEQ); - - *wc = (_wc_t)idx; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF1632_stdenc_get_state_desc_generic(_UTF1632EncodingInfo * __restrict ei, - _UTF1632State * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(UTF1632); -_CITRUS_STDENC_DEF_OPS(UTF1632); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_utf1632.h b/lib/libc/citrus/modules/citrus_utf1632.h deleted file mode 100644 index 0fac6f312..000000000 --- a/lib/libc/citrus/modules/citrus_utf1632.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: citrus_utf1632.h,v 1.1 2003/06/25 09:51:49 tshiozak Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_UTF1632_H_ -#define _CITRUS_UTF1632_H_ - -__BEGIN_DECLS -_CITRUS_STDENC_GETOPS_FUNC(UTF1632); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_utf7.c b/lib/libc/citrus/modules/citrus_utf7.c deleted file mode 100644 index eae0ee3eb..000000000 --- a/lib/libc/citrus/modules/citrus_utf7.c +++ /dev/null @@ -1,573 +0,0 @@ -/* $NetBSD: citrus_utf7.c,v 1.6 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2004, 2005 Citrus Project, - * 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 -#if defined(LIB_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_utf7.c,v 1.6 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIB_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_utf7.h" - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - uint16_t cell[0x80]; -#define EI_MASK UINT16_C(0xff) -#define EI_DIRECT UINT16_C(0x100) -#define EI_OPTION UINT16_C(0x200) -#define EI_SPACE UINT16_C(0x400) -} _UTF7EncodingInfo; - -typedef struct { - unsigned int - mode: 1, /* whether base64 mode */ - bits: 4, /* need to hold 0 - 15 */ - cache: 22, /* 22 = BASE64_BIT + UTF16_BIT */ - surrogate: 1; /* whether surrogate pair or not */ - int chlen; - char ch[4]; /* BASE64_IN, 3 * 6 = 18, most closed to UTF16_BIT */ -} _UTF7State; - -typedef struct { - _UTF7EncodingInfo ei; - struct { - /* for future multi-locale facility */ - _UTF7State s_mblen; - _UTF7State s_mbrlen; - _UTF7State s_mbrtowc; - _UTF7State s_mbtowc; - _UTF7State s_mbsrtowcs; - _UTF7State s_mbsnrtowcs; - _UTF7State s_wcrtomb; - _UTF7State s_wcsrtombs; - _UTF7State s_wcsnrtombs; - _UTF7State s_wctomb; - } states; -} _UTF7CTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_UTF7_##m -#define _ENCODING_INFO _UTF7EncodingInfo -#define _CTYPE_INFO _UTF7CTypeInfo -#define _ENCODING_STATE _UTF7State -#define _ENCODING_MB_CUR_MAX(_ei_) 4 -#define _ENCODING_IS_STATE_DEPENDENT 1 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - -static __inline void -/*ARGSUSED*/ -_citrus_UTF7_init_state(_UTF7EncodingInfo * __restrict ei, - _UTF7State * __restrict s) -{ - /* ei appears to be unused */ - _DIAGASSERT(s != NULL); - - memset((void *)s, 0, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_UTF7_pack_state(_UTF7EncodingInfo * __restrict ei, - void *__restrict pspriv, const _UTF7State * __restrict s) -{ - /* ei seem to be unused */ - _DIAGASSERT(pspriv != NULL); - _DIAGASSERT(s != NULL); - - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_UTF7_unpack_state(_UTF7EncodingInfo * __restrict ei, - _UTF7State * __restrict s, const void * __restrict pspriv) -{ - /* ei seem to be unused */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(pspriv != NULL); - - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static const char base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789+/"; - -static const char direct[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZ" - "abcdefghijklmnopqrstuvwxyz" - "0123456789(),-./:?"; - -static const char option[] = "!\"#$%&';<=>@[]^_`{|}"; -static const char spaces[] = " \t\r\n"; - -#define BASE64_BIT 6 -#define UTF16_BIT 16 - -#define BASE64_MAX 0x3f -#define UTF16_MAX UINT16_C(0xffff) -#define UTF32_MAX UINT32_C(0x10ffff) - -#define BASE64_IN '+' -#define BASE64_OUT '-' - -#define SHIFT7BIT(c) ((c) >> 7) -#define ISSPECIAL(c) ((c) == '\0' || (c) == BASE64_IN) - -#define FINDLEN(ei, c) \ - (SHIFT7BIT((c)) ? -1 : (((ei)->cell[(c)] & EI_MASK) - 1)) - -#define ISDIRECT(ei, c) (!SHIFT7BIT((c)) && (ISSPECIAL((c)) || \ - ei->cell[(c)] & (EI_DIRECT | EI_OPTION | EI_SPACE))) - -#define ISSAFE(ei, c) (!SHIFT7BIT((c)) && (ISSPECIAL((c)) || \ - (c < 0x80 && ei->cell[(c)] & (EI_DIRECT | EI_SPACE)))) - -/* surrogate pair */ -#define SRG_BASE UINT32_C(0x10000) -#define HISRG_MIN UINT16_C(0xd800) -#define HISRG_MAX UINT16_C(0xdbff) -#define LOSRG_MIN UINT16_C(0xdc00) -#define LOSRG_MAX UINT16_C(0xdfff) - -static int -_citrus_UTF7_mbtoutf16(_UTF7EncodingInfo * __restrict ei, - uint16_t * __restrict u16, const char ** __restrict s, size_t n, - _UTF7State * __restrict psenc, size_t * __restrict nresult) -{ - _UTF7State sv; - const char *s0; - int i, done, len; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL && *s != NULL); - _DIAGASSERT(psenc != NULL); - - s0 = *s; - sv = *psenc; - - for (i = 0, done = 0; done == 0; i++) { - _DIAGASSERT(i <= psenc->chlen); - if (i == psenc->chlen) { - if (n-- < 1) { - *nresult = (size_t)-2; - *s = s0; - sv.chlen = psenc->chlen; - *psenc = sv; - return 0; - } - psenc->ch[psenc->chlen++] = *s0++; - } - if (SHIFT7BIT((int)psenc->ch[i])) - goto ilseq; - if (!psenc->mode) { - if (psenc->bits > 0 || psenc->cache > 0) - return EINVAL; - if (psenc->ch[i] == BASE64_IN) { - psenc->mode = 1; - } else { - if (!ISDIRECT(ei, (int)psenc->ch[i])) - goto ilseq; - *u16 = (uint16_t)psenc->ch[i]; - done = 1; - continue; - } - } else { - if (psenc->ch[i] == BASE64_OUT && psenc->cache == 0) { - psenc->mode = 0; - *u16 = (uint16_t)BASE64_IN; - done = 1; - continue; - } - len = FINDLEN(ei, (int)psenc->ch[i]); - if (len < 0) { - if (psenc->bits >= BASE64_BIT) - return EINVAL; - psenc->mode = 0; - psenc->bits = psenc->cache = 0; - if (psenc->ch[i] != BASE64_OUT) { - if (!ISDIRECT(ei, (int)psenc->ch[i])) - goto ilseq; - *u16 = (uint16_t)psenc->ch[i]; - done = 1; - } - } else { - psenc->cache = - (psenc->cache << BASE64_BIT) | len; - switch (psenc->bits) { - case 0: case 2: case 4: case 6: case 8: - psenc->bits += BASE64_BIT; - break; - case 10: case 12: case 14: - psenc->bits -= (UTF16_BIT - BASE64_BIT); - *u16 = (psenc->cache >> psenc->bits) - & UTF16_MAX; - done = 1; - break; - default: - return EINVAL; - } - } - } - } - - if (psenc->chlen > i) - return EINVAL; - psenc->chlen = 0; - *nresult = (size_t)((*u16 == 0) ? 0 : s0 - *s); - *s = s0; - - return 0; - -ilseq: - *nresult = (size_t)-1; - return EILSEQ; -} - -static int -_citrus_UTF7_mbrtowc_priv(_UTF7EncodingInfo * __restrict ei, - wchar_t * __restrict pwc, const char ** __restrict s, size_t n, - _UTF7State * __restrict psenc, size_t * __restrict nresult) -{ - const char *s0; - uint32_t u32; - uint16_t hi, lo; - size_t siz, nr; - int err; - - _DIAGASSERT(ei != NULL); - /* pwc may be null */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - - if (*s == NULL) { - _citrus_UTF7_init_state(ei, psenc); - *nresult = (size_t)_ENCODING_IS_STATE_DEPENDENT; - return 0; - } - s0 = *s; - if (psenc->surrogate) { - hi = (psenc->cache >> 2) & UTF16_MAX; - if (hi < HISRG_MIN || hi > HISRG_MAX) - return EINVAL; - siz = 0; - } else { - err = _citrus_UTF7_mbtoutf16(ei, &hi, &s0, n, psenc, &nr); - if (nr == (size_t)-1 || nr == (size_t)-2) { - *nresult = nr; - return err; - } - if (err != 0) - return err; - n -= nr; - siz = nr; - if (hi < HISRG_MIN || hi > HISRG_MAX) { - u32 = (uint32_t)hi; - goto done; - } - psenc->surrogate = 1; - } - err = _citrus_UTF7_mbtoutf16(ei, &lo, &s0, n, psenc, &nr); - if (nr == (size_t)-1 || nr == (size_t)-2) { - *nresult = nr; - return err; - } - if (err != 0) - return err; - hi -= HISRG_MIN; - lo -= LOSRG_MIN; - u32 = (hi << 10 | lo) + SRG_BASE; - siz += nr; -done: - *s = s0; - if (pwc != NULL) - *pwc = (wchar_t)u32; - if (u32 == (uint32_t)0) { - *nresult = (size_t)0; - _citrus_UTF7_init_state(ei, psenc); - } else { - *nresult = siz; - psenc->surrogate = 0; - } - return err; -} - -static int -_citrus_UTF7_utf16tomb(_UTF7EncodingInfo * __restrict ei, - char * __restrict s, size_t n, uint16_t u16, - _UTF7State * __restrict psenc, size_t * __restrict nresult) -{ - int bits, i; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(psenc != NULL); - - if (psenc->chlen != 0 || psenc->bits > BASE64_BIT) - return EINVAL; - - if (ISSAFE(ei, u16)) { - if (psenc->mode) { - if (psenc->bits > 0) { - bits = BASE64_BIT - psenc->bits; - i = (psenc->cache << bits) & BASE64_MAX; - psenc->ch[psenc->chlen++] = base64[i]; - psenc->bits = psenc->cache = 0; - } - if (u16 == BASE64_OUT || FINDLEN(ei, u16) >= 0) - psenc->ch[psenc->chlen++] = BASE64_OUT; - psenc->mode = 0; - } - if (psenc->bits != 0) - return EINVAL; - psenc->ch[psenc->chlen++] = (char)u16; - if (u16 == BASE64_IN) - psenc->ch[psenc->chlen++] = BASE64_OUT; - } else { - if (!psenc->mode) { - if (psenc->bits > 0) - return EINVAL; - psenc->ch[psenc->chlen++] = BASE64_IN; - psenc->mode = 1; - } - psenc->cache = (psenc->cache << UTF16_BIT) | u16; - bits = UTF16_BIT + psenc->bits; - psenc->bits = bits % BASE64_BIT; - while ((bits -= BASE64_BIT) >= 0) { - i = (psenc->cache >> bits) & BASE64_MAX; - psenc->ch[psenc->chlen++] = base64[i]; - } - } - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - psenc->chlen = 0; - - return 0; -} - -static int -_citrus_UTF7_wcrtomb_priv(_UTF7EncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wchar, - _UTF7State * __restrict psenc, size_t * __restrict nresult) -{ - uint32_t u32; - uint16_t u16[2]; - int err, len, i; - size_t siz, nr; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - u32 = (uint32_t)wchar; - if (u32 <= UTF16_MAX) { - u16[0] = (uint16_t)u32; - len = 1; - } else if (u32 <= UTF32_MAX) { - u32 -= SRG_BASE; - u16[0] = (u32 >> 10) + HISRG_MIN; - u16[1] = ((uint16_t)(u32 & UINT32_C(0x3ff))) + LOSRG_MIN; - len = 2; - } else { - *nresult = (size_t)-1; - return EILSEQ; - } - siz = 0; - for (i = 0; i < len; ++i) { - err = _citrus_UTF7_utf16tomb(ei, s, n, u16[i], psenc, &nr); - if (err != 0) - return err; /* XXX: state has been modified */ - s += nr; - n -= nr; - siz += nr; - } - *nresult = siz; - - return 0; -} - -static int -/* ARGSUSED */ -_citrus_UTF7_put_state_reset(_UTF7EncodingInfo * __restrict ei, - char * __restrict s, size_t n, _UTF7State * __restrict psenc, - size_t * __restrict nresult) -{ - int bits, pos; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (psenc->chlen != 0 || psenc->bits > BASE64_BIT || psenc->surrogate) - return EINVAL; - - if (psenc->mode) { - if (psenc->bits > 0) { - if (n-- < 1) - return E2BIG; - bits = BASE64_BIT - psenc->bits; - pos = (psenc->cache << bits) & BASE64_MAX; - psenc->ch[psenc->chlen++] = base64[pos]; - psenc->ch[psenc->chlen++] = BASE64_OUT; - psenc->bits = psenc->cache = 0; - } - psenc->mode = 0; - } - if (psenc->bits != 0) - return EINVAL; - if (n-- < 1) - return E2BIG; - - _DIAGASSERT(n >= psenc->chlen); - *nresult = (size_t)psenc->chlen; - if (psenc->chlen > 0) { - memcpy(s, psenc->ch, psenc->chlen); - psenc->chlen = 0; - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF7_stdenc_wctocs(_UTF7EncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, wchar_t wc) -{ - /* ei seem to be unused */ - _DIAGASSERT(csid != NULL); - _DIAGASSERT(idx != NULL); - - *csid = 0; - *idx = (_index_t)wc; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF7_stdenc_cstowc(_UTF7EncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - /* ei seem to be unused */ - _DIAGASSERT(wc != NULL); - - if (csid != 0) - return EILSEQ; - *wc = (wchar_t)idx; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF7_stdenc_get_state_desc_generic(_UTF7EncodingInfo * __restrict ei, - _UTF7State * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_UTF7_encoding_module_uninit(_UTF7EncodingInfo *ei) -{ - /* ei seems to be unused */ -} - -static int -/*ARGSUSED*/ -_citrus_UTF7_encoding_module_init(_UTF7EncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - const char *s; - - _DIAGASSERT(ei != NULL); - /* var may be null */ - - memset(ei, 0, sizeof(*ei)); - -#define FILL(str, flag) \ -do { \ - for (s = str; *s != '\0'; s++) \ - ei->cell[*s & 0x7f] |= flag; \ -} while (/*CONSTCOND*/0) - - FILL(base64, (s - base64) + 1); - FILL(direct, EI_DIRECT); - FILL(option, EI_OPTION); - FILL(spaces, EI_SPACE); - - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(UTF7); -_CITRUS_CTYPE_DEF_OPS(UTF7); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(UTF7); -_CITRUS_STDENC_DEF_OPS(UTF7); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_utf7.h b/lib/libc/citrus/modules/citrus_utf7.h deleted file mode 100644 index 8502acefd..000000000 --- a/lib/libc/citrus/modules/citrus_utf7.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_utf7.h,v 1.1 2005/03/05 18:05:15 tnozaki Exp $ */ - -/*- - * Copyright (c)2004,2005 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_UTF7_H_ -#define _CITRUS_UTF7_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(UTF7); -_CITRUS_STDENC_GETOPS_FUNC(UTF7); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_utf8.c b/lib/libc/citrus/modules/citrus_utf8.c deleted file mode 100644 index 0b7df8865..000000000 --- a/lib/libc/citrus/modules/citrus_utf8.c +++ /dev/null @@ -1,397 +0,0 @@ -/* $NetBSD: citrus_utf8.c,v 1.18 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_utf8.c,v 1.18 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_utf8.h" - - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -static int _UTF8_count_array[256]; -static int const *_UTF8_count = NULL; - -static const u_int32_t _UTF8_range[] = { - 0, /*dummy*/ - 0x00000000, 0x00000080, 0x00000800, 0x00010000, - 0x00200000, 0x04000000, 0x80000000, -}; - -typedef struct { - char ch[6]; - int chlen; -} _UTF8State; - -typedef struct { -} _UTF8EncodingInfo; - -typedef struct { - _UTF8EncodingInfo ei; - struct { - /* for future multi-locale facility */ - _UTF8State s_mblen; - _UTF8State s_mbrlen; - _UTF8State s_mbrtowc; - _UTF8State s_mbtowc; - _UTF8State s_mbsrtowcs; - _UTF8State s_mbsnrtowcs; - _UTF8State s_wcrtomb; - _UTF8State s_wcsrtombs; - _UTF8State s_wcsnrtombs; - _UTF8State s_wctomb; - } states; -} _UTF8CTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_ei_, _func_) (_ei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_UTF8_##m -#define _ENCODING_INFO _UTF8EncodingInfo -#define _CTYPE_INFO _UTF8CTypeInfo -#define _ENCODING_STATE _UTF8State -#define _ENCODING_MB_CUR_MAX(_ei_) 6 -#define _ENCODING_IS_STATE_DEPENDENT 0 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - - -static __inline void -_UTF8_init_count(void) -{ - int i; - if (!_UTF8_count) { - memset(_UTF8_count_array, 0, sizeof(_UTF8_count_array)); - for (i = 0; i <= 0x7f; i++) - _UTF8_count_array[i] = 1; - for (i = 0xc0; i <= 0xdf; i++) - _UTF8_count_array[i] = 2; - for (i = 0xe0; i <= 0xef; i++) - _UTF8_count_array[i] = 3; - for (i = 0xf0; i <= 0xf7; i++) - _UTF8_count_array[i] = 4; - for (i = 0xf8; i <= 0xfb; i++) - _UTF8_count_array[i] = 5; - for (i = 0xfc; i <= 0xfd; i++) - _UTF8_count_array[i] = 6; - _UTF8_count = _UTF8_count_array; - } -} - -static int -_UTF8_findlen(wchar_t v) -{ - int i; - u_int32_t c; - - c = (u_int32_t)v; /*XXX*/ - for (i = 1; i < sizeof(_UTF8_range) / sizeof(_UTF8_range[0]) - 1; i++) - if (c >= _UTF8_range[i] && c < _UTF8_range[i + 1]) - return i; - - return -1; /*out of range*/ -} - -static __inline int -_UTF8_surrogate(wchar_t wc) -{ - return wc >= 0xd800 && wc <= 0xdfff; -} - -static __inline void -/*ARGSUSED*/ -_citrus_UTF8_init_state(_UTF8EncodingInfo *ei, _UTF8State *s) -{ - s->chlen = 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_UTF8_pack_state(_UTF8EncodingInfo *ei, void *pspriv, - const _UTF8State *s) -{ - memcpy(pspriv, (const void *)s, sizeof(*s)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_UTF8_unpack_state(_UTF8EncodingInfo *ei, _UTF8State *s, - const void *pspriv) -{ - memcpy((void *)s, pspriv, sizeof(*s)); -} - -static int -_citrus_UTF8_mbrtowc_priv(_UTF8EncodingInfo *ei, wchar_t *pwc, const char **s, - size_t n, _UTF8State *psenc, size_t *nresult) -{ - wchar_t wchar; - const char *s0; - int c; - int i; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - - s0 = *s; - - if (s0 == NULL) { - _citrus_UTF8_init_state(ei, psenc); - *nresult = 0; /* state independent */ - return 0; - } - - /* make sure we have the first byte in the buffer */ - if (psenc->chlen == 0) { - if (n-- < 1) - goto restart; - psenc->ch[psenc->chlen++] = *s0++; - } - - c = _UTF8_count[psenc->ch[0] & 0xff]; - if (c < 1 || c < psenc->chlen) - goto ilseq; - - if (c == 1) - wchar = psenc->ch[0] & 0xff; - else { - while (psenc->chlen < c) { - if (n-- < 1) - goto restart; - psenc->ch[psenc->chlen++] = *s0++; - } - wchar = psenc->ch[0] & (0x7f >> c); - for (i = 1; i < c; i++) { - if ((psenc->ch[i] & 0xc0) != 0x80) - goto ilseq; - wchar <<= 6; - wchar |= (psenc->ch[i] & 0x3f); - } - if (_UTF8_surrogate(wchar) || _UTF8_findlen(wchar) != c) - goto ilseq; - } - if (pwc != NULL) - *pwc = wchar; - *nresult = (wchar == 0) ? 0 : s0 - *s; - *s = s0; - psenc->chlen = 0; - - return 0; - -ilseq: - *nresult = (size_t)-1; - return EILSEQ; - -restart: - *s = s0; - *nresult = (size_t)-2; - return 0; -} - -static int -_citrus_UTF8_wcrtomb_priv(_UTF8EncodingInfo *ei, char *s, size_t n, wchar_t wc, - _UTF8State *psenc, size_t *nresult) -{ - int cnt, i, ret; - wchar_t c; - - _DIAGASSERT(nresult != 0); - _DIAGASSERT(s != NULL); - - if (_UTF8_surrogate(wc)) { - ret = EILSEQ; - goto err; - } - cnt = _UTF8_findlen(wc); - if (cnt <= 0 || cnt > 6) { - /* invalid UCS4 value */ - ret = EILSEQ; - goto err; - } - if (n < cnt) { - /* bound check failure */ - ret = E2BIG; - goto err; - } - - c = wc; - if (s) { - for (i = cnt - 1; i > 0; i--) { - s[i] = 0x80 | (c & 0x3f); - c >>= 6; - } - s[0] = c; - if (cnt == 1) - s[0] &= 0x7f; - else { - s[0] &= (0x7f >> cnt); - s[0] |= ((0xff00 >> cnt) & 0xff); - } - } - - *nresult = (size_t)cnt; - return 0; - -err: - *nresult = (size_t)-1; - return ret; -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF8_stdenc_wctocs(_UTF8EncodingInfo * __restrict ei, - _csid_t * __restrict csid, - _index_t * __restrict idx, - wchar_t wc) -{ - - _DIAGASSERT(csid != NULL && idx != NULL); - - *csid = 0; - *idx = (_citrus_index_t)wc; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF8_stdenc_cstowc(_UTF8EncodingInfo * __restrict ei, - wchar_t * __restrict wc, - _csid_t csid, _index_t idx) -{ - - _DIAGASSERT(wc != NULL); - - if (csid != 0) - return (EILSEQ); - - *wc = (wchar_t)idx; - - return (0); -} - -static __inline int -/*ARGSUSED*/ -_citrus_UTF8_stdenc_get_state_desc_generic(_UTF8EncodingInfo * __restrict ei, - _UTF8State * __restrict psenc, - int * __restrict rstate) -{ - - if (psenc->chlen == 0) - *rstate = _STDENC_SDGEN_INITIAL; - else - *rstate = _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_UTF8_encoding_module_init(_UTF8EncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - _UTF8_init_count(); - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_UTF8_encoding_module_uninit(_UTF8EncodingInfo *ei) -{ -} - - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(UTF8); -_CITRUS_CTYPE_DEF_OPS(UTF8); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(UTF8); -_CITRUS_STDENC_DEF_OPS(UTF8); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_utf8.h b/lib/libc/citrus/modules/citrus_utf8.h deleted file mode 100644 index 9e57b6b69..000000000 --- a/lib/libc/citrus/modules/citrus_utf8.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_utf8.h,v 1.2 2003/06/25 09:51:49 tshiozak Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_UTF8_H_ -#define _CITRUS_UTF8_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(UTF8); -_CITRUS_STDENC_GETOPS_FUNC(UTF8); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_viqr.c b/lib/libc/citrus/modules/citrus_viqr.c deleted file mode 100644 index 06e744f06..000000000 --- a/lib/libc/citrus/modules/citrus_viqr.c +++ /dev/null @@ -1,574 +0,0 @@ -/* $NetBSD: citrus_viqr.c,v 1.6 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_viqr.c,v 1.6 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_bcs.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_viqr.h" - -#define ESCAPE '\\' - -/* - * this table generated from RFC 1456. - */ -static const char *mnemonic_rfc1456[0x100] = { - NULL , NULL , "A(?", NULL , NULL , "A(~", "A^~", NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , "Y?" , NULL , NULL , NULL , - NULL , "Y~" , NULL , NULL , NULL , NULL , "Y." , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - NULL , NULL , NULL , NULL , NULL , NULL , NULL , NULL , - "A." , "A('", "A(`", "A(.", "A^'", "A^`", "A^?", "A^.", - "E~" , "E." , "E^'", "E^`", "E^?", "E^~", "E^.", "O^'", - "O^`", "O^?", "O^~", "O^.", "O+.", "O+'", "O+`", "O+?", - "I." , "O?" , "O." , "I?" , "U?" , "U~" , "U." , "Y`" , - "O~" , "a('", "a(`", "a(.", "a^'", "a^`", "a^?", "a^.", - "e~" , "e." , "e^'", "e^`", "e^?", "e^~", "e^.", "o^'", - "o^`", "o^?", "o^~", "O+~", "O+" , "o^.", "o+`", "o+?", - "i." , "U+.", "U+'", "U+`", "U+?", "o+" , "o+'", "U+" , - "A`" , "A'" , "A^" , "A~" , "A?" , "A(" , "a(?", "a(~", - "E`" , "E'" , "E^" , "E?" , "I`" , "I'" , "I~" , "y`" , - "DD" , "u+'", "O`" , "O'" , "O^" , "a." , "y?" , "u+`", - "u+?", "U`" , "U'" , "y~" , "y." , "Y'" , "o+~", "u+" , - "a`" , "a'" , "a^" , "a~" , "a?" , "a(" , "u+~", "a^~", - "e`" , "e'" , "e^" , "e?" , "i`" , "i'" , "i~" , "i?" , - "dd" , "u+.", "o`" , "o'" , "o^" , "o~" , "o?" , "o." , - "u." , "u`" , "u'" , "u~" , "u?" , "y'" , "o+.", "U+~", -}; - -typedef struct { - const char *name; - wchar_t value; -} mnemonic_def_t; - -static const mnemonic_def_t mnemonic_ext[] = { -/* add extra mnemonic here (should be sorted by wchar_t order). */ -}; -static const size_t mnemonic_ext_size = - sizeof(mnemonic_ext) / sizeof(mnemonic_def_t); - -static const char * -mnemonic_ext_find(wchar_t wc, const mnemonic_def_t *head, size_t n) -{ - const mnemonic_def_t *mid; - - _DIAGASSERT(head != NULL); - - for (; n > 0; n >>= 1) { - mid = head + (n >> 1); - if (mid->value == wc) { - return mid->name; - } else if (mid->value < wc) { - head = mid + 1; - --n; - } - } - return NULL; -} - -struct mnemonic_t; -typedef TAILQ_HEAD(mnemonic_list_t, mnemonic_t) mnemonic_list_t; -typedef struct mnemonic_t { - TAILQ_ENTRY(mnemonic_t) entry; - int ascii; - struct mnemonic_t *parent; - mnemonic_list_t child; - wchar_t value; -} mnemonic_t; - -static mnemonic_t * -mnemonic_list_find(mnemonic_list_t *ml, int ch) -{ - mnemonic_t *m; - - _DIAGASSERT(ml != NULL); - - TAILQ_FOREACH(m, ml, entry) { - if (m->ascii == ch) - return m; - } - - return NULL; -} - -static mnemonic_t * -mnemonic_create(mnemonic_t *parent, int ascii, wchar_t value) -{ - mnemonic_t *m; - - _DIAGASSERT(parent != NULL); - - m = malloc(sizeof(*m)); - if (m != NULL) { - m->parent = parent; - m->ascii = ascii; - m->value = value; - TAILQ_INIT(&m->child); - } - - return m; -} - -static int -mnemonic_append_child(mnemonic_t *m, const char *s, - wchar_t value, wchar_t invalid) -{ - int ch; - mnemonic_t *m0; - - _DIAGASSERT(m != NULL); - _DIAGASSERT(s != NULL); - - ch = (unsigned char)*s++; - if (ch == '\0') - return EINVAL; - m0 = mnemonic_list_find(&m->child, ch); - if (m0 == NULL) { - m0 = mnemonic_create(m, ch, (wchar_t)ch); - if (m0 == NULL) - return ENOMEM; - TAILQ_INSERT_TAIL(&m->child, m0, entry); - } - m = m0; - for (m0 = NULL; (ch = (unsigned char)*s) != '\0'; ++s) { - m0 = mnemonic_list_find(&m->child, ch); - if (m0 == NULL) { - m0 = mnemonic_create(m, ch, invalid); - if (m0 == NULL) - return ENOMEM; - TAILQ_INSERT_TAIL(&m->child, m0, entry); - } - m = m0; - } - if (m0 == NULL) - return EINVAL; - m0->value = value; - - return 0; -} - -static void -mnemonic_destroy(mnemonic_t *m) -{ - mnemonic_t *m0; - - _DIAGASSERT(m != NULL); - - TAILQ_FOREACH(m0, &m->child, entry) - mnemonic_destroy(m0); - free(m); -} - -typedef struct { - size_t mb_cur_max; - wchar_t invalid; - mnemonic_t *mroot; -} _VIQREncodingInfo; - -typedef struct { - int chlen; - char ch[MB_LEN_MAX]; -} _VIQRState; - -typedef struct { - _VIQREncodingInfo ei; - struct { - /* for future multi-locale facility */ - _VIQRState s_mblen; - _VIQRState s_mbrlen; - _VIQRState s_mbrtowc; - _VIQRState s_mbtowc; - _VIQRState s_mbsrtowcs; - _VIQRState s_mbsnrtowcs; - _VIQRState s_wcrtomb; - _VIQRState s_wcsrtombs; - _VIQRState s_wcsnrtombs; - _VIQRState s_wctomb; - } states; -} _VIQRCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_VIQR_##m -#define _ENCODING_INFO _VIQREncodingInfo -#define _CTYPE_INFO _VIQRCTypeInfo -#define _ENCODING_STATE _VIQRState -#define _ENCODING_MB_CUR_MAX(_ei_) (_ei_)->mb_cur_max -#define _ENCODING_IS_STATE_DEPENDENT 1 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) 0 - -static __inline void -/*ARGSUSED*/ -_citrus_VIQR_init_state(_VIQREncodingInfo * __restrict ei, - _VIQRState * __restrict psenc) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - - psenc->chlen = 0; -} - -static __inline void -/*ARGSUSED*/ -_citrus_VIQR_pack_state(_VIQREncodingInfo * __restrict ei, - void *__restrict pspriv, const _VIQRState * __restrict psenc) -{ - /* ei may be unused */ - _DIAGASSERT(pspriv != NULL); - _DIAGASSERT(psenc != NULL); - - memcpy(pspriv, (const void *)psenc, sizeof(*psenc)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_VIQR_unpack_state(_VIQREncodingInfo * __restrict ei, - _VIQRState * __restrict psenc, const void * __restrict pspriv) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(pspriv != NULL); - - memcpy((void *)psenc, pspriv, sizeof(*psenc)); -} - -static int -_citrus_VIQR_mbrtowc_priv(_VIQREncodingInfo * __restrict ei, - wchar_t * __restrict pwc, const char ** __restrict s, size_t n, - _VIQRState * __restrict psenc, size_t * __restrict nresult) -{ - const char *s0; - wchar_t wc; - mnemonic_t *m, *m0; - size_t i; - int ch, escape; - - _DIAGASSERT(ei != NULL); - /* pwc may be null */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (*s == NULL) { - _citrus_VIQR_init_state(ei, psenc); - *nresult = (size_t)_ENCODING_IS_STATE_DEPENDENT; - return 0; - } - s0 = *s; - - i = 0; - m = ei->mroot; - for (escape = 0;;) { - if (psenc->chlen == i) { - if (n-- < 1) { - *s = s0; - *nresult = (size_t)-2; - return 0; - } - psenc->ch[psenc->chlen++] = *s0++; - } - ch = (unsigned char)psenc->ch[i++]; - if (ch == ESCAPE) { - if (m != ei->mroot) - break; - escape = 1; - continue; - } - if (escape != 0) - break; - m0 = mnemonic_list_find(&m->child, ch); - if (m0 == NULL) - break; - m = m0; - } - while (m != ei->mroot) { - --i; - if (m->value != ei->invalid) - break; - m = m->parent; - } - if (ch == ESCAPE && m != ei->mroot) - ++i; - psenc->chlen -= i; - memmove(&psenc->ch[0], &psenc->ch[i], psenc->chlen); - wc = (m == ei->mroot) ? (wchar_t)ch : m->value; - if (pwc != NULL) - *pwc = wc; - *nresult = (size_t)(wc == 0 ? 0 : s0 - *s); - *s = s0; - - return 0; -} - -static int -_citrus_VIQR_wcrtomb_priv(_VIQREncodingInfo * __restrict ei, - char * __restrict s, size_t n, wchar_t wc, - _VIQRState * __restrict psenc, size_t * __restrict nresult) -{ - mnemonic_t *m; - int ch; - const char *p; - - _DIAGASSERT(ei != NULL); - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - switch (psenc->chlen) { - case 0: case 1: - break; - default: - return EINVAL; - } - m = NULL; - if ((uint32_t)wc <= 0xFF) { - p = mnemonic_rfc1456[wc & 0xFF]; - if (p != NULL) - goto mnemonic_found; - if (n-- < 1) - goto e2big; - ch = (unsigned int)wc; - m = ei->mroot; - if (psenc->chlen > 0) { - m = mnemonic_list_find(&m->child, psenc->ch[0]); - if (m == NULL) - return EINVAL; - psenc->ch[0] = ESCAPE; - } - if (mnemonic_list_find(&m->child, ch) == NULL) { - psenc->chlen = 0; - m = NULL; - } - psenc->ch[psenc->chlen++] = ch; - } else { - p = mnemonic_ext_find(wc, &mnemonic_ext[0], mnemonic_ext_size); - if (p == NULL) { - *nresult = (size_t)-1; - return EILSEQ; - } else { -mnemonic_found: - psenc->chlen = 0; - while (*p != '\0') { - if (n-- < 1) - goto e2big; - psenc->ch[psenc->chlen++] = *p++; - } - } - } - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - if (m == ei->mroot) { - psenc->ch[0] = ch; - psenc->chlen = 1; - } else { - psenc->chlen = 0; - } - - return 0; - -e2big: - *nresult = (size_t)-1; - return E2BIG; -} - -static int -/* ARGSUSED */ -_citrus_VIQR_put_state_reset(_VIQREncodingInfo * __restrict ei, - char * __restrict s, size_t n, _VIQRState * __restrict psenc, - size_t * __restrict nresult) -{ - /* ei may be unused */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - switch (psenc->chlen) { - case 0: case 1: - break; - default: - return EINVAL; - } - *nresult = 0; - psenc->chlen = 0; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_VIQR_stdenc_wctocs(_VIQREncodingInfo * __restrict ei, - _csid_t * __restrict csid, _index_t * __restrict idx, wchar_t wc) -{ - /* ei may be unused */ - _DIAGASSERT(csid != NULL); - _DIAGASSERT(idx != NULL); - - *csid = 0; - *idx = (_index_t)wc; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_VIQR_stdenc_cstowc(_VIQREncodingInfo * __restrict ei, - wchar_t * __restrict pwc, _csid_t csid, _index_t idx) -{ - /* ei may be unused */ - _DIAGASSERT(pwc != NULL); - - if (csid != 0) - return EILSEQ; - *pwc = (wchar_t)idx; - - return 0; -} - -static void -_citrus_VIQR_encoding_module_uninit(_VIQREncodingInfo *ei) -{ - _DIAGASSERT(ei != NULL); - - mnemonic_destroy(ei->mroot); -} - -static int -/*ARGSUSED*/ -_citrus_VIQR_encoding_module_init(_VIQREncodingInfo * __restrict ei, - const void * __restrict var, size_t lenvar) -{ - int errnum; - const char *s; - size_t i, n; - const mnemonic_def_t *p; - - _DIAGASSERT(ei != NULL); - /* var may be unused */ - - ei->mb_cur_max = 1; - ei->invalid = (wchar_t)-1; - ei->mroot = mnemonic_create(NULL, '\0', ei->invalid); - if (ei->mroot == NULL) - return ENOMEM; - for (i = 0; i < sizeof(mnemonic_rfc1456) / sizeof(const char *); ++i) { - s = mnemonic_rfc1456[i]; - if (s == NULL) - continue; - n = strlen(s); - _DIAGASSERT(n <= MB_LEN_MAX); - if (ei->mb_cur_max < n) - ei->mb_cur_max = n; - errnum = mnemonic_append_child(ei->mroot, - s, (wchar_t)i, ei->invalid); - if (errnum != 0) { - _citrus_VIQR_encoding_module_uninit(ei); - return errnum; - } - } - for (i = 0; i < mnemonic_ext_size; ++i) { - p = &mnemonic_ext[i]; - _DIAGASSERT(p != NULL && p->name != NULL); - n = strlen(p->name); - _DIAGASSERT(n <= MB_LEN_MAX); - if (ei->mb_cur_max < n) - ei->mb_cur_max = n; - errnum = mnemonic_append_child(ei->mroot, - p->name, p->value, ei->invalid); - if (errnum != 0) { - _citrus_VIQR_encoding_module_uninit(ei); - return errnum; - } - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_VIQR_stdenc_get_state_desc_generic(_VIQREncodingInfo * __restrict ei, - _VIQRState * __restrict psenc, int * __restrict rstate) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(rstate != NULL); - - *rstate = (psenc->chlen == 0) - ? _STDENC_SDGEN_INITIAL - : _STDENC_SDGEN_INCOMPLETE_CHAR; - - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(VIQR); -_CITRUS_CTYPE_DEF_OPS(VIQR); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(VIQR); -_CITRUS_STDENC_DEF_OPS(VIQR); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_viqr.h b/lib/libc/citrus/modules/citrus_viqr.h deleted file mode 100644 index 93154294a..000000000 --- a/lib/libc/citrus/modules/citrus_viqr.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_viqr.h,v 1.1 2006/11/13 15:16:31 tnozaki Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_VIQR_H_ -#define _CITRUS_VIQR_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(VIQR); -_CITRUS_STDENC_GETOPS_FUNC(VIQR); -__END_DECLS - -#endif diff --git a/lib/libc/citrus/modules/citrus_zw.c b/lib/libc/citrus/modules/citrus_zw.c deleted file mode 100644 index e60f24439..000000000 --- a/lib/libc/citrus/modules/citrus_zw.c +++ /dev/null @@ -1,514 +0,0 @@ -/* $NetBSD: citrus_zw.c,v 1.5 2013/05/28 16:57:56 joerg Exp $ */ - -/*- - * Copyright (c)2004, 2006 Citrus Project, - * 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 -#if defined(LIB_SCCS) && !defined(lint) -__RCSID("$NetBSD: citrus_zw.c,v 1.5 2013/05/28 16:57:56 joerg Exp $"); -#endif /* LIB_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "citrus_stdenc.h" -#include "citrus_zw.h" - -/* ---------------------------------------------------------------------- - * private stuffs used by templates - */ - -typedef struct { - int dummy; -} _ZWEncodingInfo; - -typedef enum { - NONE, AMBIGIOUS, ASCII, GB2312 -} _ZWCharset; - -typedef struct { - int chlen; - char ch[4]; - _ZWCharset charset; -} _ZWState; - -typedef struct { - _ZWEncodingInfo ei; - struct { - /* for future multi-locale facility */ - _ZWState s_mblen; - _ZWState s_mbrlen; - _ZWState s_mbrtowc; - _ZWState s_mbtowc; - _ZWState s_mbsrtowcs; - _ZWState s_mbsnrtowcs; - _ZWState s_wcrtomb; - _ZWState s_wcsrtombs; - _ZWState s_wcsnrtombs; - _ZWState s_wctomb; - } states; -} _ZWCTypeInfo; - -#define _CEI_TO_EI(_cei_) (&(_cei_)->ei) -#define _CEI_TO_STATE(_cei_, _func_) (_cei_)->states.s_##_func_ - -#define _FUNCNAME(m) _citrus_ZW_##m -#define _ENCODING_INFO _ZWEncodingInfo -#define _CTYPE_INFO _ZWCTypeInfo -#define _ENCODING_STATE _ZWState -#define _ENCODING_MB_CUR_MAX(_ei_) MB_LEN_MAX -#define _ENCODING_IS_STATE_DEPENDENT 1 -#define _STATE_NEEDS_EXPLICIT_INIT(_ps_) ((_ps_)->charset != NONE) - -static __inline void -/*ARGSUSED*/ -_citrus_ZW_init_state(_ZWEncodingInfo * __restrict ei, - _ZWState * __restrict psenc) -{ - /* ei my be unused */ - _DIAGASSERT(psenc != NULL); - - psenc->chlen = 0; - psenc->charset = NONE; -} - -static __inline void -/*ARGSUSED*/ -_citrus_ZW_pack_state(_ZWEncodingInfo * __restrict ei, - void *__restrict pspriv, const _ZWState * __restrict psenc) -{ - /* ei may be unused */ - _DIAGASSERT(pspriv != NULL); - _DIAGASSERT(psenc != NULL); - - memcpy(pspriv, (const void *)psenc, sizeof(*psenc)); -} - -static __inline void -/*ARGSUSED*/ -_citrus_ZW_unpack_state(_ZWEncodingInfo * __restrict ei, - _ZWState * __restrict psenc, const void * __restrict pspriv) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(pspriv != NULL); - - memcpy((void *)psenc, pspriv, sizeof(*psenc)); -} - -static int -_citrus_ZW_mbrtowc_priv(_ZWEncodingInfo * __restrict ei, - wchar_t * __restrict pwc, const char **__restrict s, size_t n, - _ZWState * __restrict psenc, size_t * __restrict nresult) -{ - const char *s0; - int ch, len; - wchar_t wc; - - /* ei may be unused */ - /* pwc may be null */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (*s == NULL) { - _citrus_ZW_init_state(ei, psenc); - *nresult = (size_t)_ENCODING_IS_STATE_DEPENDENT; - return 0; - } - s0 = *s; - len = 0; - -#define STORE \ -do { \ - if (n-- < 1) { \ - *nresult = (size_t)-2; \ - *s = s0; \ - return 0; \ - } \ - ch = (unsigned char)*s0++; \ - if (len++ > MB_LEN_MAX || ch > 0x7F)\ - goto ilseq; \ - psenc->ch[psenc->chlen++] = ch; \ -} while (/*CONSTCOND*/0) - -loop: - switch (psenc->charset) { - case ASCII: - switch (psenc->chlen) { - case 0: - STORE; - switch (psenc->ch[0]) { - case '\0': case '\n': - psenc->charset = NONE; - } - /*FALLTHROUGH*/ - case 1: - break; - default: - return EINVAL; - } - ch = (unsigned char)psenc->ch[0]; - if (ch > 0x7F) - goto ilseq; - wc = (wchar_t)ch; - psenc->chlen = 0; - break; - case NONE: - if (psenc->chlen != 0) - return EINVAL; - STORE; - ch = (unsigned char)psenc->ch[0]; - if (ch != 'z') { - if (ch != '\n' && ch != '\0') - psenc->charset = ASCII; - wc = (wchar_t)ch; - psenc->chlen = 0; - break; - } - psenc->charset = AMBIGIOUS; - psenc->chlen = 0; - /* FALLTHROUGH */ - case AMBIGIOUS: - if (psenc->chlen != 0) - return EINVAL; - STORE; - if (psenc->ch[0] != 'W') { - psenc->charset = ASCII; - wc = L'z'; - break; - } - psenc->charset = GB2312; - psenc->chlen = 0; - /* FALLTHROUGH */ - case GB2312: - switch (psenc->chlen) { - case 0: - STORE; - ch = (unsigned char)psenc->ch[0]; - if (ch == '\0') { - psenc->charset = NONE; - wc = (wchar_t)ch; - psenc->chlen = 0; - break; - } else if (ch == '\n') { - psenc->charset = NONE; - psenc->chlen = 0; - goto loop; - } - /*FALLTHROUGH*/ - case 1: - STORE; - if (psenc->ch[0] == ' ') { - ch = (unsigned char)psenc->ch[1]; - wc = (wchar_t)ch; - psenc->chlen = 0; - break; - } else if (psenc->ch[0] == '#') { - ch = (unsigned char)psenc->ch[1]; - if (ch == '\n') { - psenc->charset = NONE; - wc = (wchar_t)ch; - psenc->chlen = 0; - break; - } else if (ch == ' ') { - wc = (wchar_t)ch; - psenc->chlen = 0; - break; - } - } - ch = (unsigned char)psenc->ch[0]; - if (ch < 0x21 || ch > 0x7E) - goto ilseq; - wc = (wchar_t)(ch << 8); - ch = (unsigned char)psenc->ch[1]; - if (ch < 0x21 || ch > 0x7E) { -ilseq: - *nresult = (size_t)-1; - return EILSEQ; - } - wc |= (wchar_t)ch; - psenc->chlen = 0; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - if (pwc != NULL) - *pwc = wc; - - *nresult = (size_t)(wc == 0 ? 0 : len); - *s = s0; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_ZW_wcrtomb_priv(_ZWEncodingInfo * __restrict ei, - char *__restrict s, size_t n, wchar_t wc, - _ZWState * __restrict psenc, size_t * __restrict nresult) -{ - int ch; - - /* ei may be null */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (psenc->chlen != 0) - return EINVAL; - if ((uint32_t)wc <= 0x7F) { - ch = (unsigned char)wc; - switch (psenc->charset) { - case NONE: - if (ch == '\0' || ch == '\n') { - psenc->ch[psenc->chlen++] = ch; - } else { - if (n < 4) - return E2BIG; - n -= 4; - psenc->ch[psenc->chlen++] = 'z'; - psenc->ch[psenc->chlen++] = 'W'; - psenc->ch[psenc->chlen++] = ' '; - psenc->ch[psenc->chlen++] = ch; - psenc->charset = GB2312; - } - break; - case GB2312: - if (n < 2) - return E2BIG; - n -= 2; - if (ch == '\0') { - psenc->ch[psenc->chlen++] = '\n'; - psenc->ch[psenc->chlen++] = '\0'; - psenc->charset = NONE; - } else if (ch == '\n') { - psenc->ch[psenc->chlen++] = '#'; - psenc->ch[psenc->chlen++] = '\n'; - psenc->charset = NONE; - } else { - psenc->ch[psenc->chlen++] = ' '; - psenc->ch[psenc->chlen++] = ch; - } - break; - default: - return EINVAL; - } - } else if ((uint32_t)wc <= 0x7E7E) { - switch (psenc->charset) { - case NONE: - if (n < 2) - return E2BIG; - n -= 2; - psenc->ch[psenc->chlen++] = 'z'; - psenc->ch[psenc->chlen++] = 'W'; - psenc->charset = GB2312; - /* FALLTHROUGH*/ - case GB2312: - if (n < 2) - return E2BIG; - n -= 2; - ch = (wc >> 8) & 0xFF; - if (ch < 0x21 || ch > 0x7E) - goto ilseq; - psenc->ch[psenc->chlen++] = ch; - ch = wc & 0xFF; - if (ch < 0x21 || ch > 0x7E) - goto ilseq; - psenc->ch[psenc->chlen++] = ch; - break; - default: - return EINVAL; - } - } else { -ilseq: - *nresult = (size_t)-1; - return EILSEQ; - } - memcpy(s, psenc->ch, psenc->chlen); - *nresult = psenc->chlen; - psenc->chlen = 0; - - return 0; -} - -static int -/*ARGSUSED*/ -_citrus_ZW_put_state_reset(_ZWEncodingInfo * __restrict ei, - char * __restrict s, size_t n, - _ZWState * __restrict psenc, size_t * __restrict nresult) -{ - /* ei may be unused */ - _DIAGASSERT(s != NULL); - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(nresult != NULL); - - if (psenc->chlen != 0) - return EINVAL; - switch (psenc->charset) { - case GB2312: - if (n-- < 1) - return E2BIG; - psenc->ch[psenc->chlen++] = '\n'; - psenc->charset = NONE; - /*FALLTHROUGH*/ - case NONE: - *nresult = psenc->chlen; - if (psenc->chlen > 0) { - memcpy(s, psenc->ch, psenc->chlen); - psenc->chlen = 0; - } - break; - default: - return EINVAL; - } - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_ZW_stdenc_get_state_desc_generic(_ZWEncodingInfo * __restrict ei, - _ZWState * __restrict psenc, int * __restrict rstate) -{ - /* ei may be unused */ - _DIAGASSERT(psenc != NULL); - _DIAGASSERT(rstate != NULL); - - switch (psenc->charset) { - case NONE: - if (psenc->chlen != 0) - return EINVAL; - *rstate = _STDENC_SDGEN_INITIAL; - break; - case AMBIGIOUS: - if (psenc->chlen != 0) - return EINVAL; - *rstate = _STDENC_SDGEN_INCOMPLETE_SHIFT; - break; - case ASCII: - case GB2312: - switch (psenc->chlen) { - case 0: - *rstate = _STDENC_SDGEN_STABLE; - break; - case 1: - *rstate = (psenc->ch[0] == '#') - ? _STDENC_SDGEN_INCOMPLETE_SHIFT - : _STDENC_SDGEN_INCOMPLETE_CHAR; - break; - default: - return EINVAL; - } - break; - default: - return EINVAL; - } - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_ZW_stdenc_wctocs(_ZWEncodingInfo * __restrict ei, - _csid_t * __restrict csid, _index_t * __restrict idx, wchar_t wc) -{ - /* ei seems to be unused */ - _DIAGASSERT(csid != NULL); - _DIAGASSERT(idx != NULL); - - *csid = (_csid_t)(wc <= 0x7FU) ? 0 : 1; - *idx = (_index_t)wc; - - return 0; -} - -static __inline int -/*ARGSUSED*/ -_citrus_ZW_stdenc_cstowc(_ZWEncodingInfo * __restrict ei, - wchar_t * __restrict wc, _csid_t csid, _index_t idx) -{ - /* ei seems to be unused */ - _DIAGASSERT(wc != NULL); - - switch (csid) { - case 0: case 1: - break; - default: - return EINVAL; - } - *wc = (wchar_t)idx; - - return 0; -} - -static void -/*ARGSUSED*/ -_citrus_ZW_encoding_module_uninit(_ZWEncodingInfo *ei) -{ -} - -static int -/*ARGSUSED*/ -_citrus_ZW_encoding_module_init(_ZWEncodingInfo * __restrict ei, - const void *__restrict var, size_t lenvar) -{ - return 0; -} - -/* ---------------------------------------------------------------------- - * public interface for ctype - */ - -_CITRUS_CTYPE_DECLS(ZW); -_CITRUS_CTYPE_DEF_OPS(ZW); - -#include "citrus_ctype_template.h" - -/* ---------------------------------------------------------------------- - * public interface for stdenc - */ - -_CITRUS_STDENC_DECLS(ZW); -_CITRUS_STDENC_DEF_OPS(ZW); - -#include "citrus_stdenc_template.h" diff --git a/lib/libc/citrus/modules/citrus_zw.h b/lib/libc/citrus/modules/citrus_zw.h deleted file mode 100644 index 9f7a20db9..000000000 --- a/lib/libc/citrus/modules/citrus_zw.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: citrus_zw.h,v 1.1 2006/11/22 23:38:27 tnozaki Exp $ */ - -/*- - * Copyright (c)2004,2006 Citrus Project, - * 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. - */ - -#ifndef _CITRUS_ZW_H_ -#define _CITRUS_ZW_H_ - -__BEGIN_DECLS -_CITRUS_CTYPE_GETOPS_FUNC(ZW); -_CITRUS_STDENC_GETOPS_FUNC(ZW); -__END_DECLS - -#endif diff --git a/lib/libc/compat-43/Makefile.inc b/lib/libc/compat-43/Makefile.inc deleted file mode 100644 index a15cf214b..000000000 --- a/lib/libc/compat-43/Makefile.inc +++ /dev/null @@ -1,25 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.16 2006/04/24 17:15:06 drochner Exp $ -# from: @(#)Makefile.inc 8.1 (Berkeley) 6/2/93 - -# Unsupported by Minix -# setrgid.c setruid.c - -# compat-43 sources -.PATH: ${ARCHDIR}/compat-43 ${.CURDIR}/compat-43 - -SRCS+= creat.c getdtablesize.c gethostid.c \ - killpg.c sethostid.c setpgrp.c \ - sigcompat.c - -.if !defined(AUDIT) -SRCS+= getwd.c -.endif - -# XXX this is to get -CPPFLAGS.sigcompat.c+= -I${NETBSDSRCDIR}/sys - -MAN+= creat.3 getdtablesize.3 gethostid.3 killpg.3 \ - setruid.3 sigblock.3 sigpause.3 sigsetmask.3 sigvec.3 - -MLINKS+=setruid.3 setrgid.3 -MLINKS+=gethostid.3 sethostid.3 diff --git a/lib/libc/compat-43/creat.3 b/lib/libc/compat-43/creat.3 deleted file mode 100644 index a5905b466..000000000 --- a/lib/libc/compat-43/creat.3 +++ /dev/null @@ -1,65 +0,0 @@ -.\" Copyright (c) 1989, 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)creat.2 8.1 (Berkeley) 6/2/93 -.\" $NetBSD: creat.3,v 1.16 2003/08/07 16:42:39 agc Exp $ -.\" -.Dd June 2, 1993 -.Dt CREAT 3 -.Os -.Sh NAME -.Nm creat -.Nd create a new file -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In fcntl.h -.Ft int -.Fn creat "const char *path" "mode_t mode" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Ef -.Xr open 2 . -.Pp -.Fn creat -is the same as: -.Bd -literal -offset indent -open(path, O_CREAT | O_TRUNC | O_WRONLY, mode); -.Ed -.Sh SEE ALSO -.Xr open 2 -.Sh STANDARDS -The -.Fn creat -function call conforms to -.St -p1003.1-90 . -.Sh HISTORY -The -.Fn creat -function call appeared in -.At v6 . diff --git a/lib/libc/compat-43/creat.c b/lib/libc/compat-43/creat.c deleted file mode 100644 index 9560beafb..000000000 --- a/lib/libc/compat-43/creat.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: creat.c,v 1.10 2003/08/07 16:42:39 agc Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)creat.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: creat.c,v 1.10 2003/08/07 16:42:39 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -int -creat(const char *path, mode_t mode) -{ - - _DIAGASSERT(path != NULL); - - return(open(path, O_WRONLY|O_CREAT|O_TRUNC, mode)); -} diff --git a/lib/libc/compat-43/getdtablesize.3 b/lib/libc/compat-43/getdtablesize.3 deleted file mode 100644 index e6ec1fba4..000000000 --- a/lib/libc/compat-43/getdtablesize.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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: @(#)getdtablesize.2 8.1 (Berkeley) 6/4/93 -.\" $NetBSD: getdtablesize.3,v 1.14 2012/01/05 07:05:59 yamt Exp $ -.\" -.Dd January 5, 2012 -.Dt GETDTABLESIZE 3 -.Os -.Sh NAME -.Nm getdtablesize -.Nd get descriptor table size -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn getdtablesize void -.Sh DESCRIPTION -The -.Nm -function is an equivalent of -.Fn sysconf -with -.Dv _SC_OPEN_MAX . -.Sh SEE ALSO -.Xr close 2 , -.Xr dup 2 , -.Xr getrlimit 2 , -.Xr open 2 , -.Xr select 2 , -.Xr sysconf 3 -.Sh HISTORY -The -.Fn getdtablesize -function call appeared in -.Bx 4.2 . -.Pp -Historically, each process had a fixed size descriptor table, -which is guaranteed to have at least 20 slots. -The entries in -the descriptor table are numbered with small integers starting at 0. -The call -.Fn getdtablesize -used to return the size of this table. -It doesn't make much sense these days because the size of the table is dynamic. diff --git a/lib/libc/compat-43/getdtablesize.c b/lib/libc/compat-43/getdtablesize.c deleted file mode 100644 index 058fc8f8a..000000000 --- a/lib/libc/compat-43/getdtablesize.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: getdtablesize.c,v 1.10 2012/06/24 15:26:03 christos Exp $ */ - -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getdtablesize.c,v 1.10 2012/06/24 15:26:03 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -int -getdtablesize(void) -{ - return ((int)sysconf(_SC_OPEN_MAX)); -} diff --git a/lib/libc/compat-43/gethostid.3 b/lib/libc/compat-43/gethostid.3 deleted file mode 100644 index a9f4ab21c..000000000 --- a/lib/libc/compat-43/gethostid.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $NetBSD: gethostid.3,v 1.12 2003/08/07 16:42:39 agc Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)gethostid.3 8.1 (Berkeley) 6/2/93 -.\" -.Dd June 2, 1993 -.Dt GETHOSTID 3 -.Os -.Sh NAME -.Nm gethostid , -.Nm sethostid -.Nd get/set unique identifier of current host -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft long -.Fn gethostid void -.Ft int -.Fn sethostid "long hostid" -.Sh DESCRIPTION -.Fn sethostid -establishes a 32-bit identifier for the current processor that is -intended to be unique among all -.Ux -systems in existence. -This is normally a DARPA Internet address for the local machine. -This call is allowed only to the super-user and is normally performed -at boot time. -.Pp -.Fn gethostid -returns the 32-bit identifier for the current processor. -.Pp -This function has been deprecated. -The hostid should be set or retrieved by use of -.Xr sysctl 3 . -.Sh SEE ALSO -.Xr gethostname 3 , -.Xr sysctl 3 , -.Xr sysctl 8 -.Sh HISTORY -The -.Fn gethostid -and -.Fn sethostid -syscalls appeared in -.Bx 4.2 -and were dropped in -.Bx 4.4 . -.Sh BUGS -32 bits for the identifier is too small. diff --git a/lib/libc/compat-43/gethostid.c b/lib/libc/compat-43/gethostid.c deleted file mode 100644 index b95f5982d..000000000 --- a/lib/libc/compat-43/gethostid.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: gethostid.c,v 1.6 2004/04/19 13:16:42 atatat Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)gethostid.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: gethostid.c,v 1.6 2004/04/19 13:16:42 atatat Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -long -gethostid(void) -{ - int mib[2], value; - size_t size; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTID; - size = sizeof(value); - if (sysctl(mib, 2, &value, &size, NULL, (size_t)0) == -1) - return (-1); - return (value); -} diff --git a/lib/libc/compat-43/getwd.c b/lib/libc/compat-43/getwd.c deleted file mode 100644 index 4e5aa8ec0..000000000 --- a/lib/libc/compat-43/getwd.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: getwd.c,v 1.15 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getwd.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: getwd.c,v 1.15 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include - -__warn_references(getwd, - "warning: getwd() possibly used unsafely, consider using getcwd()") - -char * -getwd(char *buf) -{ - char *p; - - _DIAGASSERT(buf != NULL); - - if ((p = getcwd(buf, MAXPATHLEN)) != NULL) - return(p); - (void)strlcpy(buf, strerror(errno), MAXPATHLEN); - return((char *)NULL); -} diff --git a/lib/libc/compat-43/killpg.3 b/lib/libc/compat-43/killpg.3 deleted file mode 100644 index d3afef034..000000000 --- a/lib/libc/compat-43/killpg.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)killpg.2 8.1 (Berkeley) 6/2/93 -.\" $NetBSD: killpg.3,v 1.16 2003/08/07 16:42:39 agc Exp $ -.\" -.Dd June 2, 1993 -.Dt KILLPG 3 -.Os -.Sh NAME -.Nm killpg -.Nd send signal to a process group -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn killpg "pid_t pgrp" "int sig" -.Sh DESCRIPTION -.Fn killpg -sends the signal -.Fa sig -to the process group -.Fa pgrp . -See -.Xr sigaction 2 -for a list of signals. -If -.Fa pgrp -is 0, -.Fn killpg -sends the signal to the sending process's process group. -.Pp -The sending process and members of the process group must -have the same effective user ID, or -the sender must be the super-user. -As a single special case the continue signal SIGCONT may be sent -to any process that is a descendant of the current process. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, a value of \-1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn killpg -will fail and no signal will be sent if: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa sig -is not a valid signal number. -.It Bq Er ESRCH -No process can be found in the process group specified by -.Fa pgrp . -.It Bq Er ESRCH -The process group was given as 0 -but the sending process does not have a process group. -.It Bq Er EPERM -The sending process is not the super-user and one or more -of the target processes has an effective user ID different from that -of the sending process. -.El -.Sh SEE ALSO -.Xr getpgrp 2 , -.Xr kill 2 , -.Xr sigaction 2 -.Sh HISTORY -The -.Fn killpg -function call appeared in -.Bx 4.0 . diff --git a/lib/libc/compat-43/killpg.c b/lib/libc/compat-43/killpg.c deleted file mode 100644 index ceac3f486..000000000 --- a/lib/libc/compat-43/killpg.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)killpg.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: killpg.c,v 1.8 2003/08/07 16:42:39 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -/* - * Backwards-compatible killpg(). - */ -int -killpg(pid_t pgid, int sig) -{ - if (pgid == 1) { - errno = ESRCH; - return (-1); - } - return (kill(-pgid, sig)); -} diff --git a/lib/libc/compat-43/sethostid.c b/lib/libc/compat-43/sethostid.c deleted file mode 100644 index b38bf8a8c..000000000 --- a/lib/libc/compat-43/sethostid.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: sethostid.c,v 1.7 2004/04/19 13:16:42 atatat Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sethostid.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: sethostid.c,v 1.7 2004/04/19 13:16:42 atatat Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -int -sethostid(long hostid) -{ - int mib[2], value; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTID; - value = (int)hostid; - if (sysctl(mib, 2, NULL, NULL, &value, sizeof(value)) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/compat-43/setpgrp.c b/lib/libc/compat-43/setpgrp.c deleted file mode 100644 index 3c031cce7..000000000 --- a/lib/libc/compat-43/setpgrp.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: setpgrp.c,v 1.8 2003/08/07 16:42:40 agc Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)setpgrp.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: setpgrp.c,v 1.8 2003/08/07 16:42:40 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -setpgrp(pid_t pid, pid_t pgid) -{ - return(setpgid(pid, pgid)); -} diff --git a/lib/libc/compat-43/setrgid.c b/lib/libc/compat-43/setrgid.c deleted file mode 100644 index a0f933486..000000000 --- a/lib/libc/compat-43/setrgid.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: setrgid.c,v 1.12 2003/08/07 16:42:40 agc Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)setrgid.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: setrgid.c,v 1.12 2003/08/07 16:42:40 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -__warn_references(setrgid, "warning: this program uses setrgid(), which is deprecated.") - -int -setrgid(gid_t rgid) -{ - return (setregid(rgid, (gid_t)-1)); -} diff --git a/lib/libc/compat-43/setruid.3 b/lib/libc/compat-43/setruid.3 deleted file mode 100644 index 8a557b1da..000000000 --- a/lib/libc/compat-43/setruid.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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: @(#)setruid.3 8.1 (Berkeley) 6/2/93 -.\" $NetBSD: setruid.3,v 1.10 2003/08/07 16:42:40 agc Exp $ -.\" -.Dd June 2, 1993 -.Dt SETRUID 3 -.Os -.Sh NAME -.Nm setruid , -.Nm setrgid -.Nd set user and group ID -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.Ft int -.Fn setruid "uid_t ruid" -.Ft int -.Fn setrgid "gid_t rgid" -.Sh DESCRIPTION -The -.Fn setruid -function -.Pq Fn setrgid -sets the real user ID (group ID) of the -current process. -.Sh RETURN VALUES -Upon success, these functions return 0; -otherwise \-1 is returned. -.Pp -If the user is not the super user, or the uid -specified is not the real or effective ID, these -functions return \-1. -.Pp -The use of these calls is not portable. -Their use is discouraged; they will be removed in the future. -.Sh SEE ALSO -.Xr getgid 2 , -.Xr getuid 2 , -.Xr setegid 2 , -.Xr seteuid 2 , -.Xr setgid 2 , -.Xr setuid 2 -.Sh HISTORY -The -.Fn setruid -and -.Fn setrgid -syscalls appeared in -.Bx 4.2 -and were dropped in -.Bx 4.4 . diff --git a/lib/libc/compat-43/setruid.c b/lib/libc/compat-43/setruid.c deleted file mode 100644 index 64b843302..000000000 --- a/lib/libc/compat-43/setruid.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: setruid.c,v 1.13 2003/08/07 16:42:40 agc Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)setruid.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: setruid.c,v 1.13 2003/08/07 16:42:40 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -__warn_references(setruid, "warning: this program uses setruid(), which is deprecated.") - -int -setruid(uid_t ruid) -{ - return (setreuid(ruid, (uid_t)-1)); -} diff --git a/lib/libc/compat-43/sigblock.3 b/lib/libc/compat-43/sigblock.3 deleted file mode 100644 index 86c8dff0e..000000000 --- a/lib/libc/compat-43/sigblock.3 +++ /dev/null @@ -1,119 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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: @(#)sigblock.2 8.1 (Berkeley) 6/2/93 -.\" $NetBSD: sigblock.3,v 1.17 2003/08/07 16:42:40 agc Exp $ -.\" -.Dd August 10, 2002 -.Dt SIGBLOCK 3 -.Os -.Sh NAME -.Nm sigblock -.Nd block signals -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn sigblock "int mask" -.Ft int -.Fn sigmask signum -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Xr sigprocmask 2 . -.Ef -.Pp -.Fn sigblock -adds the signals specified in -.Fa mask -to the set of signals currently -being blocked from delivery. -Signals are blocked if the -corresponding bit in -.Fa mask -is a 1; the macro -.Fn sigmask -is provided to construct the mask for a given -.Fa signum . -.Pp -It is not possible to block -.Dv SIGKILL -or -.Dv SIGSTOP ; -this restriction is silently -imposed by the system. -.Sh RETURN VALUES -The previous set of masked signals is returned. -.Sh EXAMPLES -The following example using -.Fn sigblock : -.Bd -literal -offset indent -int omask; - -omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); -.Ed -.Pp -Becomes: -.Bd -literal -offset indent -sigset_t set, oset; - -sigemptyset(&set); -sigaddset(&set, SIGINT); -sigaddset(&set, SIGHUP); -sigprocmask(SIG_BLOCK, &set, &oset); -.Ed -.Pp -Another use of -.Fn sigblock -is to get the current set of masked signals without changing what -is actually blocked. -Instead of: -.Bd -literal -offset indent -int set; - -set = sigblock(0); -.Ed -.Pp -Use the following: -.Bd -literal -offset indent -sigset_t set; - -sigprocmask(SIG_BLOCK, NULL, &set); -.Ed -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigprocmask 2 , -.Xr sigsetmask 3 , -.Xr sigsetops 3 -.Sh HISTORY -The -.Fn sigblock -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigcompat.c b/lib/libc/compat-43/sigcompat.c deleted file mode 100644 index a8ae696ff..000000000 --- a/lib/libc/compat-43/sigcompat.c +++ /dev/null @@ -1,120 +0,0 @@ -/* $NetBSD: sigcompat.c,v 1.13 2005/12/24 21:11:16 perry Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sigcompat.c 8.1 (Berkeley) 6/2/93"; -#else -__RCSID("$NetBSD: sigcompat.c,v 1.13 2005/12/24 21:11:16 perry Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -static inline void sv2sa(struct sigaction *, const struct sigvec *); -static inline void sa2sv(struct sigvec *, const struct sigaction *); - -static inline void -sv2sa(struct sigaction *sa, const struct sigvec *sv) -{ - sigemptyset(&sa->sa_mask); - sa->sa_mask.__bits[0] = sv->sv_mask; - sa->sa_handler = sv->sv_handler; - sa->sa_flags = sv->sv_flags ^ SV_INTERRUPT; /* !SA_INTERRUPT */ -} - -static inline void -sa2sv(struct sigvec *sv, const struct sigaction *sa) -{ - sv->sv_mask = sa->sa_mask.__bits[0]; - sv->sv_handler = sa->sa_handler; - sv->sv_flags = sa->sa_flags ^ SV_INTERRUPT; /* !SA_INTERRUPT */ -} - -int -sigvec(int signo, struct sigvec *nsv, struct sigvec *osv) -{ - int ret; - struct sigaction osa, nsa; - - if (nsv) - sv2sa(&nsa, nsv); - - ret = sigaction(signo, nsv ? &nsa : NULL, osv ? &osa : NULL); - - if (ret == 0 && osv) - sa2sv(osv, &osa); - - return (ret); -} - -int -sigsetmask(int mask) -{ - sigset_t nmask, omask; - int n; - - sigemptyset(&nmask); - nmask.__bits[0] = mask; - - n = sigprocmask(SIG_SETMASK, &nmask, &omask); - if (n) - return (n); - return (omask.__bits[0]); -} - -int -sigblock(int mask) -{ - sigset_t nmask, omask; - int n; - - sigemptyset(&nmask); - nmask.__bits[0] = mask; - - n = sigprocmask(SIG_BLOCK, &nmask, &omask); - if (n) - return (n); - return (omask.__bits[0]); -} - -int -sigpause(int mask) -{ - sigset_t nmask; - - sigemptyset(&nmask); - nmask.__bits[0] = mask; - return (sigsuspend(&nmask)); -} diff --git a/lib/libc/compat-43/sigpause.3 b/lib/libc/compat-43/sigpause.3 deleted file mode 100644 index 431ad501c..000000000 --- a/lib/libc/compat-43/sigpause.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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: @(#)sigpause.2 8.1 (Berkeley) 6/2/93 -.\" $NetBSD: sigpause.3,v 1.15 2003/08/07 16:42:40 agc Exp $ -.\" -.Dd June 2, 1993 -.Dt SIGPAUSE 3 -.Os -.Sh NAME -.Nm sigpause -.Nd atomically release blocked signals and wait for interrupt -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn sigpause "int sigmask" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by -.Xr sigsuspend 2 . -.Ef -.Pp -.Fn sigpause -assigns -.Fa sigmask -to the set of masked signals -and then waits for a signal to arrive; -on return the set of masked signals is restored. -.Fa sigmask -is usually 0 to indicate that no -signals are to be blocked. -.Fn sigpause -always terminates by being interrupted, returning -1 with -.Va errno -set to -.Dv EINTR . -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr sigblock 3 , -.Xr sigvec 3 -.Sh HISTORY -The -.Fn sigpause -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigsetmask.3 b/lib/libc/compat-43/sigsetmask.3 deleted file mode 100644 index 779592816..000000000 --- a/lib/libc/compat-43/sigsetmask.3 +++ /dev/null @@ -1,140 +0,0 @@ -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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: @(#)sigsetmask.2 8.1 (Berkeley) 6/2/93 -.\" $NetBSD: sigsetmask.3,v 1.19 2013/05/06 13:29:12 wiz Exp $ -.\" -.Dd August 10, 2002 -.Dt SIGSETMASK 3 -.Os -.Sh NAME -.Nm sigsetmask -.Nd set current signal mask -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn sigsetmask "int mask" -.Fn sigmask signum -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by: -.Ef -.Xr sigprocmask 2 . -.Pp -.Fn sigsetmask -sets the current signal mask. -Signals are blocked from delivery if the -corresponding bit in -.Fa mask -is a 1; the macro -.Fn sigmask -is provided to construct the mask for a given -.Fa signum . -.Pp -The system -quietly disallows -.Dv SIGKILL -or -.Dv SIGSTOP -to be blocked. -.Sh RETURN VALUES -The previous set of masked signals is returned. -.Sh EXAMPLES -The following example using -.Fn sigsetmask : -.Bd -literal -offset indent -int omask; - -omask = sigblock(sigmask(SIGINT) | sigmask(SIGHUP)); - -\&... - -sigsetmask(omask & ~(sigmask(SIGINT) | sigmask(SIGHUP))); -.Ed -.Pp -Could be converted literally to: -.Bd -literal -offset indent -sigset_t set, oset; - -sigemptyset(&set); -sigaddset(&set, SIGINT); -sigaddset(&set, SIGHUP); -sigprocmask(SIG_BLOCK, &set, &oset); - -\&... - -sigdelset(&oset, SIGINT); -sigdelset(&oset, SIGHUP); -sigprocmask(SIG_SETMASK, &oset, NULL); -.Ed -.Pp -Another, clearer, alternative is: -.Bd -literal -offset indent -sigset_t set; - -sigemptyset(&set); -sigaddset(&set, SIGINT); -sigaddset(&set, SIGHUP); -sigprocmask(SIG_BLOCK, &set, NULL); - -\&... - -sigprocmask(SIG_UNBLOCK, &set, NULL); -.Ed -.Pp -To completely clear the signal mask using -.Fn sigsetmask -one can do: -.Bd -literal -offset indent -(void) sigsetmask(0); -.Ed -.Pp -Which can be expressed via -.Xr sigprocmask 2 -as: -.Bd -literal -offset indent -sigset_t eset; - -sigemptyset(&eset); -(void) sigprocmask(SIG_SETMASK, &eset, NULL); -.Ed -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr sigblock 3 , -.Xr sigsetops 3 , -.Xr sigvec 3 -.Sh HISTORY -The -.Fn sigsetmask -function call appeared in -.Bx 4.2 -and has been deprecated. diff --git a/lib/libc/compat-43/sigvec.3 b/lib/libc/compat-43/sigvec.3 deleted file mode 100644 index 18c2a4c2c..000000000 --- a/lib/libc/compat-43/sigvec.3 +++ /dev/null @@ -1,313 +0,0 @@ -.\" $NetBSD: sigvec.3,v 1.26 2010/03/22 19:30:53 joerg Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" from: @(#)sigvec.2 8.2 (Berkeley) 4/19/94 -.\" -.Dd December 3, 2005 -.Dt SIGVEC 3 -.Os -.Sh NAME -.Nm sigvec -.Nd software signal facilities -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Bd -literal -struct sigvec { - void (*sv_handler)(); - int sv_mask; - int sv_flags; -}; -.Ed -.Ft int -.Fn sigvec "int sig" "struct sigvec *vec" "struct sigvec *ovec" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by -.Xr sigaction 2 . -The structure, flags, and function declaration have been removed from -the header files but the function is kept in the c library for binary -compatibility. -.Ef -.Pp -The system defines a set of signals that may be delivered to a process. -Signal delivery resembles the occurrence of a hardware interrupt: -the signal is blocked from further occurrence, the current process -context is saved, and a new one is built. -A process may specify a -.Em handler -to which a signal is delivered, or specify that a signal is to be -.Em ignored . -A process may also specify that a default action is to be taken -by the system when a signal occurs. -A signal may also be -.Em blocked , -in which case its delivery is postponed until it is -.Em unblocked . -The action to be taken on delivery is determined at the time -of delivery. -Normally, signal handlers execute on the current stack -of the process. -This may be changed, on a per-handler basis, so that signals are -taken on a special -.Em "signal stack" . -.Pp -Signal routines execute with the signal that caused their -invocation -.Em blocked , -but other signals may yet occur. -A global -.Em "signal mask" -defines the set of signals currently blocked from delivery -to a process. -The signal mask for a process is initialized from that of its parent -(normally 0). -It may be changed with a -.Xr sigblock 3 -or -.Xr sigsetmask 3 -call, or when a signal is delivered to the process. -.Pp -When a signal -condition arises for a process, the signal is added to a set of -signals pending for the process. -If the signal is not currently -.Em blocked -by the process then it is delivered to the process. -When a caught signal -is delivered, the current state of the process is saved, -a new signal mask is calculated (as described below), -and the signal handler is invoked. -The call to the handler is arranged so that if the signal handling -routine returns normally the process will resume execution in the -context from before the signal's delivery. -If the process wishes to resume in a different context, then it -must arrange to restore the previous context itself. -.Pp -When a signal is delivered to a process a new signal mask is -installed for the duration of the process' signal handler -(or until a -.Xr sigblock 3 -or -.Xr sigsetmask 3 -call is made). -This mask is formed by taking the union of the current signal mask, -the signal to be delivered, and -the signal mask associated with the handler to be invoked. -.Pp -.Fn sigvec -assigns a handler for a specific signal. -If -.Fa vec -is non-zero, it -specifies an action -.Pf ( Dv SIG_DFL , -.Dv SIG_IGN , -or a handler routine) and mask -to be used when delivering the specified signal. -Further, if the -.Dv SV_ONSTACK -bit is set in -.Fa sv_flags , -the system will deliver the signal to the process on a -.Em "signal stack" , -specified with -.Xr sigaltstack 2 . -If -.Fa ovec -is non-zero, the previous handling information for the signal -is returned to the user. -.Pp -Once a signal handler is installed, it remains installed -until another -.Fn sigvec -call is made, or an -.Xr execve 2 -is performed. -A signal-specific default action may be reset by -setting -.Fa sv_handler -to -.Dv SIG_DFL . -The defaults are process termination, possibly with core dump; -no action; stopping the process; or continuing the process. -See the signal list below for each signal's default action. -If -.Fa sv_handler -is set to -.Dv SIG_DFL , -the default action for the signal is to discard the signal, -and if a signal is pending, -the pending signal is discarded even if the signal is masked. -If -.Fa sv_handler -is set to -.Dv SIG_IGN , -current and pending instances -of the signal are ignored and discarded. -.Pp -Options may be specified by setting -.Em sv_flags . -If the -.Dv SV_ONSTACK -bit is set in -.Fa sv_flags , -the system will deliver the signal to the process on a -.Em "signal stack" , -specified with -.Xr sigstack 2 . -.Pp -If a signal is caught during the system calls listed below, -the call may be restarted, -the call may return with a data transfer shorter than requested, -or the call may be forced to terminate -with the error -.Dv EINTR . -Interrupting of pending calls is requested -by setting the -.Dv SV_INTERRUPT -bit in -.Ar sv_flags . -The affected system calls include -.Xr open 2 , -.Xr read 2 , -.Xr write 2 , -.Xr sendto 2 , -.Xr recvfrom 2 , -.Xr sendmsg 2 -and -.Xr recvmsg 2 -on a communications channel or a slow device (such as a terminal, -but not a regular file) -and during a -.Xr wait 2 -or -.Xr ioctl 2 . -However, calls that have already committed are not restarted, -but instead return a partial success (for example, a short read count). -.Pp -After a -.Xr fork 2 -or -.Xr vfork 2 -all signals, the signal mask, the signal stack, -and the interrupt/restart flags are inherited by the child. -.Pp -The -.Xr execve 2 -system call reinstates the default action for all signals which -were caught and resets all signals to be caught on the user stack. -Ignored signals remain ignored; -the signal mask remains the same; -signals that interrupt pending system calls continue to do so. -.Pp -See -.Xr signal 7 -for comprehensive list of supported signals. -.Sh NOTES -The mask specified in -.Fa vec -is not allowed to block -.Dv SIGKILL -or -.Dv SIGSTOP . -This is enforced silently by the system. -.Pp -The -.Dv SV_INTERRUPT -flag is not available in -.Bx 4.2 , -hence it should not be used if backward compatibility is needed. -.Sh RETURN VALUES -A 0 value indicated that the call succeeded. -A \-1 return value indicates an error occurred and -.Va errno -is set to indicated the reason. -.Sh EXAMPLES -The handler routine can be declared: -.Bd -literal -offset indent -void -handler(sig, code, scp) - int sig, code; - struct sigcontext *scp; -.Ed -.Pp -Here -.Fa sig -is the signal number, into which the hardware faults and traps are -mapped as defined below. -.Fa code -is a parameter that is either a constant -or the code provided by the hardware. -.Fa scp -is a pointer to the -.Fa sigcontext -structure (defined in -.In signal.h ) , -used to restore the context from before the signal. -.Sh ERRORS -.Fn sigvec -will fail and no new signal handler will be installed if one -of the following occurs: -.Bl -tag -width Er -.It Bq Er EFAULT -Either -.Fa vec -or -.Fa ovec -points to memory that is not a valid part of the process -address space. -.It Bq Er EINVAL -.Fa sig -is not a valid signal number. -.It Bq Er EINVAL -An attempt is made to ignore or supply a handler for -.Dv SIGKILL -or -.Dv SIGSTOP . -.El -.Sh SEE ALSO -.Xr kill 1 , -.Xr kill 2 , -.Xr ptrace 2 , -.Xr sigaction 2 , -.Xr sigaltstack 2 , -.Xr sigprocmask 2 , -.Xr sigstack 2 , -.Xr sigsuspend 2 , -.Xr setjmp 3 , -.Xr sigblock 3 , -.Xr siginterrupt 3 , -.Xr signal 3 , -.Xr sigpause 3 , -.Xr sigsetmask 3 , -.Xr sigsetops 3 , -.Xr tty 4 , -.Xr signal 7 diff --git a/lib/libc/compat/Makefile b/lib/libc/compat/Makefile deleted file mode 100644 index 8cb0e46a7..000000000 --- a/lib/libc/compat/Makefile +++ /dev/null @@ -1,29 +0,0 @@ -# $NetBSD: Makefile,v 1.6 2012/01/22 18:36:16 christos Exp $ -# @(#)Makefile 8.2 (Berkeley) 2/3/94 -# - -.include "${.CURDIR}/../Makefile.inc" - -LIB= cold -CPPFLAGS+= -I${.CURDIR}/../include -I${.CURDIR}/.. -CPPFLAGS+= -I${.CURDIR}/../arch/${ARCHSUBDIR} - -COMPATDIR=${.CURDIR} - -.include "${.CURDIR}/Makefile.inc" - -.include "${.CURDIR}/db/Makefile.inc" -.include "${.CURDIR}/gen/Makefile.inc" -.include "${.CURDIR}/locale/Makefile.inc" -.include "${.CURDIR}/net/Makefile.inc" -.if !defined(__MINIX) -.include "${.CURDIR}/rpc/Makefile.inc" -.endif # !defined(__MINIX) -.include "${.CURDIR}/stdio/Makefile.inc" -.include "${.CURDIR}/stdlib/Makefile.inc" -.include "${.CURDIR}/sys/Makefile.inc" - -COMPATARCHDIR=${.CURDIR}/arch/${ARCHSUBDIR} -.PATH: ${COMPATARCHDIR}/gen ${COMPATARCHDIR}/sys - -.include diff --git a/lib/libc/compat/Makefile.inc b/lib/libc/compat/Makefile.inc deleted file mode 100644 index b74a68819..000000000 --- a/lib/libc/compat/Makefile.inc +++ /dev/null @@ -1,21 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.7 2012/01/22 18:36:16 christos Exp $ - -CPPFLAGS+= -I${NETBSDSRCDIR}/sys - -COMPATARCHDIR=${COMPATDIR}/arch/${ARCHSUBDIR} -.PATH: ${COMPATARCHDIR}/gen ${COMPATARCHDIR}/sys - -.include "${COMPATDIR}/db/Makefile.inc" -.include "${COMPATDIR}/locale/Makefile.inc" -.include "${COMPATDIR}/gen/Makefile.inc" -.include "${COMPATDIR}/net/Makefile.inc" -.if !defined(__MINIX) -.include "${COMPATDIR}/rpc/Makefile.inc" -.endif # !defined(__MINIX) -.include "${COMPATDIR}/stdio/Makefile.inc" -.include "${COMPATDIR}/stdlib/Makefile.inc" -.include "${COMPATDIR}/sys/Makefile.inc" -.include "${COMPATDIR}/time/Makefile.inc" -.if !defined(__MINIX) -.include "${COMPATARCHDIR}/Makefile.inc" -.endif # !defined(__MINIX) diff --git a/lib/libc/compat/arch/aarch64/Makefile.inc b/lib/libc/compat/arch/aarch64/Makefile.inc deleted file mode 100644 index 4bcaf502f..000000000 --- a/lib/libc/compat/arch/aarch64/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/08/10 05:47:37 matt Exp $ diff --git a/lib/libc/compat/arch/alpha/Makefile.inc b/lib/libc/compat/arch/alpha/Makefile.inc deleted file mode 100644 index aa2ae6647..000000000 --- a/lib/libc/compat/arch/alpha/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 23:04:03 christos Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/alpha/gen/Makefile.inc b/lib/libc/compat/arch/alpha/gen/Makefile.inc deleted file mode 100644 index 4fc8c9ab5..000000000 --- a/lib/libc/compat/arch/alpha/gen/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/06/28 14:22:15 drochner Exp $ - -# objects built from assembler sources -SRCS+= compat_setjmp.S compat__setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/alpha/gen/compat__setjmp.S b/lib/libc/compat/arch/alpha/gen/compat__setjmp.S deleted file mode 100644 index 3a9550a54..000000000 --- a/lib/libc/compat/arch/alpha/gen/compat__setjmp.S +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: compat__setjmp.S,v 1.4 2014/01/24 10:19:18 skrll 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 - -/* - * C library -- _setjmp, _longjmp - * - * _longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * _setjmp(a) - * by restoring registers from the stack, - * The previous signal state is NOT restored. - */ - - .set noreorder - -LEAF(_setjmp, 1) - LDGP(pv) - stq ra, (2 * 8)(a0) /* sc_pc = return address */ - stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */ - stq s1, ((10 + 4) * 8)(a0) - stq s2, ((11 + 4) * 8)(a0) - stq s3, ((12 + 4) * 8)(a0) - stq s4, ((13 + 4) * 8)(a0) - stq s5, ((14 + 4) * 8)(a0) - stq s6, ((15 + 4) * 8)(a0) - stq ra, ((26 + 4) * 8)(a0) - stq sp, ((30 + 4) * 8)(a0) - ldq t0, magic /* sigcontext magic number */ - stq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */ - /* Too bad we can't check if we actually used FP */ - ldiq t0, 1 - stq t0, (36 * 8)(a0) /* say we've used FP. */ - stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */ - stt fs1, ((3 + 37) * 8)(a0) - stt fs2, ((4 + 37) * 8)(a0) - stt fs3, ((5 + 37) * 8)(a0) - stt fs4, ((6 + 37) * 8)(a0) - stt fs5, ((7 + 37) * 8)(a0) - stt fs6, ((8 + 37) * 8)(a0) - stt fs7, ((9 + 37) * 8)(a0) - mf_fpcr ft0 /* get FP control reg */ - stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */ - stq zero, (70 * 8)(a0) /* FP software control XXX */ - stq zero, (71 * 8)(a0) /* sc_reserved[0] */ - stq zero, (72 * 8)(a0) /* sc_reserved[1] */ - stq zero, (73 * 8)(a0) /* sc_xxx[0] */ - stq zero, (74 * 8)(a0) /* sc_xxx[1] */ - stq zero, (75 * 8)(a0) /* sc_xxx[2] */ - stq zero, (76 * 8)(a0) /* sc_xxx[3] */ - stq zero, (77 * 8)(a0) /* sc_xxx[4] */ - stq zero, (78 * 8)(a0) /* sc_xxx[5] */ - stq zero, (79 * 8)(a0) /* sc_xxx[6] */ - stq zero, (80 * 8)(a0) /* sc_xxx[7] */ - - mov zero, v0 /* return zero */ - RET -magic: - .quad 0xacedbadd -END(_setjmp) - -LEAF(_longjmp, 2) - LDGP(pv) - ldq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */ - ldq t1, magic /* sigcontext magic number */ - cmpeq t0, t1, t0 - beq t0, botch /* If the magic was bad, punt */ - - ldq ra, (2 * 8)(a0) /* sc_pc = return address */ - ldq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */ - ldq s1, ((10 + 4) * 8)(a0) - ldq s2, ((11 + 4) * 8)(a0) - ldq s3, ((12 + 4) * 8)(a0) - ldq s4, ((13 + 4) * 8)(a0) - ldq s5, ((14 + 4) * 8)(a0) - ldq s6, ((15 + 4) * 8)(a0) - /* ldq ra, ((26 + 4) * 8)(a0) set above */ - ldq sp, ((30 + 4) * 8)(a0) - ldt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */ - ldt fs1, ((3 + 37) * 8)(a0) - ldt fs2, ((4 + 37) * 8)(a0) - ldt fs3, ((5 + 37) * 8)(a0) - ldt fs4, ((6 + 37) * 8)(a0) - ldt fs5, ((7 + 37) * 8)(a0) - ldt fs6, ((8 + 37) * 8)(a0) - ldt fs7, ((9 + 37) * 8)(a0) - ldt ft0, (69 * 8)(a0) /* get sc_fpcr */ - mt_fpcr ft0 /* and restore it. */ - - mov a1, v0 /* return second arg */ - RET - -botch: - CALL(longjmperror) - CALL(abort) - RET /* "can't" get here... */ -END(_longjmp) diff --git a/lib/libc/compat/arch/alpha/gen/compat_setjmp.S b/lib/libc/compat/arch/alpha/gen/compat_setjmp.S deleted file mode 100644 index 8daa5e60d..000000000 --- a/lib/libc/compat/arch/alpha/gen/compat_setjmp.S +++ /dev/null @@ -1,126 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.2 2014/01/23 03:08:50 christos 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 - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and the previous signal state. - */ - - .set noreorder - -LEAF(setjmp, 1) - LDGP(pv) - stq ra, (2 * 8)(a0) /* sc_pc = return address */ - stq s0, (( 9 + 4) * 8)(a0) /* saved bits of sc_regs */ - stq s1, ((10 + 4) * 8)(a0) - stq s2, ((11 + 4) * 8)(a0) - stq s3, ((12 + 4) * 8)(a0) - stq s4, ((13 + 4) * 8)(a0) - stq s5, ((14 + 4) * 8)(a0) - stq s6, ((15 + 4) * 8)(a0) - stq ra, ((26 + 4) * 8)(a0) - stq sp, ((30 + 4) * 8)(a0) - - /* - * get signal information - */ - mov a0, s0 /* squirrel away ptr to sc */ - - /* see what's blocked */ - mov zero, a0 - CALL(sigblock) /* see what's blocked */ - stq v0, (1 * 8)(s0) /* and remember it in sc_mask */ - - lda sp, -24(sp) /* sizeof struct sigaltstack */ - mov zero, a0 - mov sp, a1 - CALL(__sigaltstack14) - ldl t0, 16(sp) /* offset of ss_flags */ - lda sp, 24(sp) /* sizeof struct sigaltstack */ - ldq ra, ((26 + 4) * 8)(s0) /* restore return address */ - blt v0, botch /* check for error */ - and t0, 0x1, t0 /* get SA_ONSTACK flag */ - stq t0, (0 * 8)(s0) /* and save it in sc_onstack */ - /* - * Restore old s0 and a0, and continue saving registers - */ - mov s0, a0 - ldq s0, (( 9 + 4) * 8)(a0) - - ldq t0, magic /* sigcontext magic number */ - stq t0, ((31 + 4) * 8)(a0) /* magic in sc_regs[31] */ - /* Too bad we can't check if we actually used FP */ - ldiq t0, 1 - stq t0, (36 * 8)(a0) /* say we've used FP. */ - stt fs0, ((2 + 37) * 8)(a0) /* saved bits of sc_fpregs */ - stt fs1, ((3 + 37) * 8)(a0) - stt fs2, ((4 + 37) * 8)(a0) - stt fs3, ((5 + 37) * 8)(a0) - stt fs4, ((6 + 37) * 8)(a0) - stt fs5, ((7 + 37) * 8)(a0) - stt fs6, ((8 + 37) * 8)(a0) - stt fs7, ((9 + 37) * 8)(a0) - mf_fpcr ft0 /* get FP control reg */ - stt ft0, (69 * 8)(a0) /* and store it in sc_fpcr */ - stq zero, (70 * 8)(a0) /* FP software control XXX */ - stq zero, (71 * 8)(a0) /* sc_reserved[0] */ - stq zero, (72 * 8)(a0) /* sc_reserved[1] */ - stq zero, (73 * 8)(a0) /* sc_xxx[0] */ - stq zero, (74 * 8)(a0) /* sc_xxx[1] */ - stq zero, (75 * 8)(a0) /* sc_xxx[2] */ - stq zero, (76 * 8)(a0) /* sc_xxx[3] */ - stq zero, (77 * 8)(a0) /* sc_xxx[4] */ - stq zero, (78 * 8)(a0) /* sc_xxx[5] */ - stq zero, (79 * 8)(a0) /* sc_xxx[6] */ - stq zero, (80 * 8)(a0) /* sc_xxx[7] */ - - mov zero, v0 /* return zero */ - RET -END(setjmp) - -LEAF(longjmp, 2) - LDGP(pv) - stq a1, (( 0 + 4) * 8)(a0) /* save return value */ - CALL(sigreturn) /* use sigreturn to return */ - -botch: - CALL(longjmperror) - CALL(abort) - RET /* "can't" get here... */ -magic: - .quad 0xacedbade /* sigcontext magic number */ -END(longjmp) diff --git a/lib/libc/compat/arch/alpha/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/alpha/gen/compat_sigsetjmp.S deleted file mode 100644 index dba6f6487..000000000 --- a/lib/libc/compat/arch/alpha/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.1 2005/09/16 18:21:19 drochner 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 - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, mask) - * by restoring registers from the stack. - * If `mask' is non-zero, the previous signal - * state will be restored. - */ - - .set noreorder - -LEAF(sigsetjmp, 2) - LDGP(pv) - stq a1, (81 * 8)(a0) /* save the mask */ - bne a1, Lsavesig /* if !zero, save signals */ - jmp zero, _setjmp /* else don't. */ -Lsavesig: - jmp zero, setjmp -END(sigsetjmp) - -LEAF(siglongjmp, 2) - LDGP(pv) - ldq t0, (81 * 8)(a0) /* get the mask */ - bne t0, Lrestoresig /* if !zero, restore signals */ - jmp zero, _longjmp -Lrestoresig: - jmp zero, longjmp -END(siglongjmp) diff --git a/lib/libc/compat/arch/alpha/sys/Makefile.inc b/lib/libc/compat/arch/alpha/sys/Makefile.inc deleted file mode 100644 index 821e4101e..000000000 --- a/lib/libc/compat/arch/alpha/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:12 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/alpha/sys/compat_Ovfork.S b/lib/libc/compat/arch/alpha/sys/compat_Ovfork.S deleted file mode 100644 index b061d6dc2..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_Ovfork.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.1 2005/09/16 18:21:19 drochner 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.h" - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -SYSCALL(vfork) - cmovne a4, zero, v0 /* a4 (rv[1]) != 0, child */ - RET -END(vfork) diff --git a/lib/libc/compat/arch/alpha/sys/compat___semctl.S b/lib/libc/compat/arch/alpha/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/alpha/sys/compat___sigreturn14.S b/lib/libc/compat/arch/alpha/sys/compat___sigreturn14.S deleted file mode 100644 index 708ef2f6b..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat___sigreturn14.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2005/09/16 18:21:19 drochner 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.h" - -/* - * We must preserve the state of the registers as the user has set them up. - * However, that doesn't involve any special work on the Alpha. - * (XXX PROFILING) - */ - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/alpha/sys/compat___sigtramp1.S b/lib/libc/compat/arch/alpha/sys/compat___sigtramp1.S deleted file mode 100644 index df48f30f8..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat___sigtramp1.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.1 2005/09/16 18:21:19 drochner Exp $ */ - -/* - * Copyright (c) 1994, 1995, 1996 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.h" - -/* - * The Alpha signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, the stack looks like: - * - * sp-> sigcontext structure - */ -NESTED_NOPROFILE(__sigtramp_sigcontext_1,0,0,ra,0,0) - mov sp, a0 /* get pointer to sigcontext */ - CALLSYS_NOERROR(compat_16___sigreturn14) /* and call sigreturn() with it */ - mov v0, a0 /* if that failed, get error code */ - CALLSYS_NOERROR(exit) /* and call exit() with it */ -END(__sigtramp_sigcontext_1) diff --git a/lib/libc/compat/arch/alpha/sys/compat_msgctl.S b/lib/libc/compat/arch/alpha/sys/compat_msgctl.S deleted file mode 100644 index cc08d76ef..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/alpha/sys/compat_quotactl.S b/lib/libc/compat/arch/alpha/sys/compat_quotactl.S deleted file mode 100644 index aa367e039..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:12 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/alpha/sys/compat_shmctl.S b/lib/libc/compat/arch/alpha/sys/compat_shmctl.S deleted file mode 100644 index 10d43f71d..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/alpha/sys/compat_sigaction.S b/lib/libc/compat/arch/alpha/sys/compat_sigaction.S deleted file mode 100644 index a5f8ad810..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/alpha/sys/compat_sigpending.S b/lib/libc/compat/arch/alpha/sys/compat_sigpending.S deleted file mode 100644 index 7ecf6a348..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_sigpending.S +++ /dev/null @@ -1,40 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.1 2005/09/16 18:21:20 drochner 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.h" - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -LEAF(sigpending,0) /* XXX # of args? */ - CALLSYS_ERROR(compat_13_sigpending13) - stl v0, 0(a0) - mov zero, v0 - RET -END(sigpending) diff --git a/lib/libc/compat/arch/alpha/sys/compat_sigprocmask.S b/lib/libc/compat/arch/alpha/sys/compat_sigprocmask.S deleted file mode 100644 index 316a80ad9..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_sigprocmask.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.1 2005/09/16 18:21:20 drochner 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.h" - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -LEAF(sigprocmask, 3) - mov a2, a5 /* safe */ - cmoveq a1, 1, a0 /* if set == NULL, how = SIG_BLOCK */ - beq a1, Ldoit /* and set = 0, and do it. */ - ldl a1, 0(a1) /* load the set from *set */ -Ldoit: CALLSYS_ERROR(compat_13_sigprocmask13) - beq a5, Lret /* if they don't want old mask, done */ - stl v0, 0(a5) /* otherwise, give it to them. */ -Lret: mov zero, v0 - RET - - END(sigprocmask) - diff --git a/lib/libc/compat/arch/alpha/sys/compat_sigreturn.S b/lib/libc/compat/arch/alpha/sys/compat_sigreturn.S deleted file mode 100644 index 76983d0bf..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_sigreturn.S +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.1 2005/09/16 18:21:20 drochner 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.h" - -/* - * We must preserve the state of the registers as the user has set them up. - * However, that doesn't involve any special work on the Alpha. - * (XXX PROFILING) - */ - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -PSEUDO(sigreturn,compat_13_sigreturn13) diff --git a/lib/libc/compat/arch/alpha/sys/compat_sigsuspend.S b/lib/libc/compat/arch/alpha/sys/compat_sigsuspend.S deleted file mode 100644 index b8f3b5743..000000000 --- a/lib/libc/compat/arch/alpha/sys/compat_sigsuspend.S +++ /dev/null @@ -1,40 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.1 2005/09/16 18:21:20 drochner 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.h" - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -LEAF(sigsuspend, 1) - ldl a0, 0(a0) /* pass *mask instead of mask */ - CALLSYS_ERROR(compat_13_sigsuspend13) - mov zero, v0 /* shouldn't need; just in case... */ - RET -END(sigsuspend) diff --git a/lib/libc/compat/arch/arm/Makefile.inc b/lib/libc/compat/arch/arm/Makefile.inc deleted file mode 100644 index 78ab575bb..000000000 --- a/lib/libc/compat/arch/arm/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 23:04:03 christos Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/arm/gen/Makefile.inc b/lib/libc/compat/arch/arm/gen/Makefile.inc deleted file mode 100644 index 81b2b912d..000000000 --- a/lib/libc/compat/arch/arm/gen/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/06/28 14:46:33 drochner Exp $ - -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/arm/gen/compat_setjmp.S b/lib/libc/compat/arch/arm/gen/compat_setjmp.S deleted file mode 100644 index a98d9fbf1..000000000 --- a/lib/libc/compat/arch/arm/gen/compat_setjmp.S +++ /dev/null @@ -1,155 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.4 2013/11/30 20:54:14 joerg Exp $ */ - -/* - * Copyright (c) 1997 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(setjmp) - /* Block all signals and retrieve the old signal mask */ - push {r0, lr} - movs r0, #0x00000000 - - bl PLT_SYM(_C_LABEL(sigblock)) - mov r1, r0 - - /* Store signal mask */ - str r1, [r0, #(_JB_SIGMASK * 4)] - - ldr r1, .Lsetjmp_magic - str r1, [r0] - - /* Store integer registers */ - adds r0, r0, #(_JB_REG_R4 * 4) -#ifdef __thumb__ -#ifdef _ARM_ARCH_7 - stmia r0!, {r4-r12} - str sp, [r0, #0] - str lr, [r0, #4] -#else - stmia r0!, {r4-r7} - mov r2, r8 - mov r3, r9 - stmia r0!, {r2-r3} - mov r1, r10 - mov r2, r11 - mov r3, r12 - stmia r0!, {r1-r3} - mov r2, sp - mov r3, lr - stmia r0!, {r2-r3} -#endif -#else - stmia r0, {r4-lr} -#endif - movs r0, #0 - pop {r3, pc} -END(setjmp) - -ENTRY(longjmp) - ldr r2, .Lsetjmp_magic - ldr r3, [r0] - cmp r2, r3 - bne botch - - /* Fetch signal mask */ - ldr r2, [r0, #(_JB_SIGMASK * 4)] - - /* Set signal mask */ - push {r0, r1} /* don't care about lr */ - - mov r0, r2 - bl PLT_SYM(_C_LABEL(sigsetmask)) - - pop {r0, r1} - - /* Restore integer registers */ - adds r0, r0, #(_JB_REG_R4 * 4) -#if !defined(__thumb__) || defined(_ARM_ARCH_7) - ldmia r0!, {r4-r12} -#else - ldmia r0!, {r4-r7} - ldmia r0!, {r2-r3} - mov r8, r2 - mov r9, r3 - ldmia r0!, {r1-r3} - mov r10, r2 - mov r11, r3 - ldmia r0!, {r2} - mov r12, r2 -#endif - - ldmia r0!, {r2-r3} /* r2 = sp, r3 = lr */ - - /* Validate sp */ - cmp r2, #0 - beq botch - mov sp, r2 - - /* Validate lr */ - cmp r3, #0 - beq botch - mov lr, r3 - - /* Set return value */ - mov r0, r1 - cmp r0, #0 -#ifdef __thumb__ - bne 1f - movs r0, #1 -1: -#else - moveq r0, #1 -#endif - RET - - /* validation failed, die die die. */ -botch: - bl PLT_SYM(_C_LABEL(longjmperror)) - bl PLT_SYM(_C_LABEL(abort)) -2: b 2b /* Cannot get here */ - - .align 0 -.Lsetjmp_magic: - .word _JB_MAGIC_SETJMP -END(longjmp) diff --git a/lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S deleted file mode 100644 index 31ae15276..000000000 --- a/lib/libc/compat/arch/arm/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,91 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.3 2013/11/30 20:54:14 joerg Exp $ */ - -/* - * Copyright (c) 1997 Mark Brinicombe - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Mark Brinicombe - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#include - -/* - * C library -- sigsetjmp, siglongjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a, m) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(sigsetjmp) -#if defined(__thumb__) && defined(_ARM_ARCH_T2) - cbnz r1, 1f - b PLT_SYM(_C_LABEL(_setjmp)) -1: b PLT_SYM(_C_LABEL(setjmp)) -#elif !defined(__thumb__) - cmp r1, #0 - beq PLT_SYM(_C_LABEL(_setjmp)) - b PLT_SYM(_C_LABEL(setjmp)) -#else - push {r3, lr} - beq 1f - bl PLT_SYM(_C_LABEL(setjmp)) - pop {r3, pc} -1: bl PLT_SYM(_C_LABEL(_setjmp)) - pop {r3, pc} -#endif -END(sigsetjmp) - -ENTRY(siglongjmp) - ldr r2, .L_setjmp_magic - ldr r3, [r0] - cmp r2, r3 -#if !defined(__thumb__) || defined(_ARM_ARCH_T2) -#if defined(__thumb__) - it eq -#endif - beq PLT_SYM(_C_LABEL(_longjmp)) - b PLT_SYM(_C_LABEL(longjmp)) -#else - push {lr} - sub sp, sp, #4 - beq 1f - bl PIC_SYM(_C_LABEL(longjmp), PLT) - b 2f -1: bl PIC_SYM(_C_LABEL(_longjmp), PLT) -2: add sp, sp, #4 - pop {pc} -#endif - - .align 0 -.L_setjmp_magic: - .word _JB_MAGIC__SETJMP -END(siglongjmp) diff --git a/lib/libc/compat/arch/arm/sys/Makefile.inc b/lib/libc/compat/arch/arm/sys/Makefile.inc deleted file mode 100644 index 47154b1b6..000000000 --- a/lib/libc/compat/arch/arm/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:13 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/arm/sys/compat_Ovfork.S b/lib/libc/compat/arch/arm/sys/compat_Ovfork.S deleted file mode 100644 index 98e6989a4..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_Ovfork.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.3 2013/08/19 22:11:50 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include "SYS.h" - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -/* - * pid = vfork(); - * - * On return from the SWI: - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - */ -ENTRY(vfork) - mov r2, lr - SYSTRAP(vfork) - _INVOKE_CERROR() - mov lr, r2 - subs r1, r1, #1 /* r1 == 0xffffffff if parent, 0 if child */ - ands r0, r0, r1 /* r0 == 0 if child, else unchanged */ - RET -END(vfork) diff --git a/lib/libc/compat/arch/arm/sys/compat___semctl.S b/lib/libc/compat/arch/arm/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/arm/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/arm/sys/compat___sigreturn14.S b/lib/libc/compat/arch/arm/sys/compat___sigreturn14.S deleted file mode 100644 index 72f0c1d5c..000000000 --- a/lib/libc/compat/arch/arm/sys/compat___sigreturn14.S +++ /dev/null @@ -1,40 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2005/10/16 17:27:50 christos Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/arm/sys/compat___sigtramp1.S b/lib/libc/compat/arch/arm/sys/compat___sigtramp1.S deleted file mode 100644 index 93b21bb85..000000000 --- a/lib/libc/compat/arch/arm/sys/compat___sigtramp1.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.3 2013/08/19 22:11:50 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The ARM signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, the stack looks like: - * - * sp-> sigcontext structure - */ -ENTRY(__sigtramp_sigcontext_1) - mov r0, sp /* get pointer to sigcontext */ - SYSTRAP(compat_16___sigreturn14) /* and call sigreturn */ - - /* If that failed, exit with the error code. */ - SYSTRAP(exit) -END(__sigtramp_sigcontext_1) diff --git a/lib/libc/compat/arch/arm/sys/compat_msgctl.S b/lib/libc/compat/arch/arm/sys/compat_msgctl.S deleted file mode 100644 index cc08d76ef..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/arm/sys/compat_quotactl.S b/lib/libc/compat/arch/arm/sys/compat_quotactl.S deleted file mode 100644 index 8df4a3de5..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:13 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/arm/sys/compat_shmctl.S b/lib/libc/compat/arch/arm/sys/compat_shmctl.S deleted file mode 100644 index 10d43f71d..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/arm/sys/compat_sigaction.S b/lib/libc/compat/arch/arm/sys/compat_sigaction.S deleted file mode 100644 index a5f8ad810..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/arm/sys/compat_sigpending.S b/lib/libc/compat/arch/arm/sys/compat_sigpending.S deleted file mode 100644 index 83f72dd26..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_sigpending.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.3 2013/08/19 22:11:50 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigpending.s 5.1 (Berkeley) 7/1/90 - */ - -#include "SYS.h" - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -ENTRY(sigpending) - mov r2, r0 - SYSTRAP(compat_13_sigpending13) - _INVOKE_CERROR() - str r0, [r2] - movs r0, #0 - RET -END(sigpending) diff --git a/lib/libc/compat/arch/arm/sys/compat_sigprocmask.S b/lib/libc/compat/arch/arm/sys/compat_sigprocmask.S deleted file mode 100644 index df89f64d7..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_sigprocmask.S +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.3 2013/08/19 22:11:50 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigprocmask.s 5.2 (Berkeley) 12/17/90 - */ - -#include "SYS.h" - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -ENTRY(sigprocmask) - cmp r1, #0 -#if defined(_ARM_ARCH_7) || !defined(__thumb__) -#ifdef __thumb__ - itte eq -#endif - moveq r0, #1 - moveq r1, #0 - ldrne r1, [r1] -#else - bne 1f - movs r0, #1 - movs r1, #0 - b 2f -1: ldr r1, [r1] -2: -#endif - SYSTRAP(compat_13_sigprocmask13) - _INVOKE_CERROR() - cmp r2, #0 -#if defined(_ARM_ARCH_7) || !defined(__thumb__) -#ifdef __thumb__ - it ne -#endif - strne r0, [r2] -#else - beq 3f - str r0, [r2] -3: -#endif - movs r0, #0 - RET -END(sigprocmask) diff --git a/lib/libc/compat/arch/arm/sys/compat_sigreturn.S b/lib/libc/compat/arch/arm/sys/compat_sigreturn.S deleted file mode 100644 index 6428869d2..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_sigreturn.S +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.2 2005/10/16 22:16:05 christos Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -PSEUDO(sigreturn,compat_13_sigreturn13) diff --git a/lib/libc/compat/arch/arm/sys/compat_sigsuspend.S b/lib/libc/compat/arch/arm/sys/compat_sigsuspend.S deleted file mode 100644 index 5a6de9c8f..000000000 --- a/lib/libc/compat/arch/arm/sys/compat_sigsuspend.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.3 2013/08/19 22:11:50 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * from: @(#)sigsuspend.s 5.2 (Berkeley) 12/17/90 - */ - -#include "SYS.h" - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend) - ldr r0, [r0] - SYSTRAP(compat_13_sigsuspend13) - _INVOKE_CERROR() - movs r0, #0 - RET -END(sigsuspend) diff --git a/lib/libc/compat/arch/hppa/Makefile.inc b/lib/libc/compat/arch/hppa/Makefile.inc deleted file mode 100644 index e9f6ca5ca..000000000 --- a/lib/libc/compat/arch/hppa/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2006/06/28 14:46:33 drochner Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/hppa/gen/Makefile.inc b/lib/libc/compat/arch/hppa/gen/Makefile.inc deleted file mode 100644 index a9e9667c1..000000000 --- a/lib/libc/compat/arch/hppa/gen/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/06/28 14:46:33 drochner Exp $ - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/hppa/locale/compat_setlocale32.c b/lib/libc/compat/arch/hppa/locale/compat_setlocale32.c deleted file mode 100644 index dc035cd31..000000000 --- a/lib/libc/compat/arch/hppa/locale/compat_setlocale32.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: compat_setlocale32.c,v 1.1 2010/06/07 13:52:29 tnozaki Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * 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. - * - * NetBSD: setlocale32.c,v 1.6 2010/05/22 13:50:02 tnozaki Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_setlocale32.c,v 1.1 2010/06/07 13:52:29 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include "setlocale_local.h" - -__warn_references(__setlocale_mb_len_max_32, - "warning: reference to compatibility __setlocale_mb_len_max_32();" - "include for correct reference") - -char * -__setlocale_mb_len_max_32(int category, const char *locale) -{ - - /* locale may be NULL */ - - __mb_len_max_runtime = 6; - return __setlocale(category, locale); -} diff --git a/lib/libc/compat/arch/hppa/sys/Makefile.inc b/lib/libc/compat/arch/hppa/sys/Makefile.inc deleted file mode 100644 index 7910a4612..000000000 --- a/lib/libc/compat/arch/hppa/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:13 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/hppa/sys/compat_Ovfork.S b/lib/libc/compat/arch/hppa/sys/compat_Ovfork.S deleted file mode 100644 index bf0f9a254..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_Ovfork.S +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.2 2009/11/03 05:07:25 snj Exp $ */ - -/* $OpenBSD: Ovfork.S,v 1.7 2001/06/04 23:14:04 mickey Exp $ */ - -/* - * Copyright (c) 1999,2002 Michael Shalayeff - * 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 ``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 HIS RELATIVES 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 MIND, 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.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_Ovfork.S,v 1.2 2009/11/03 05:07:25 snj Exp $") -#endif /* LIBC_SCCS and not lint */ - -ENTRY(vfork,0) - SYSCALL(vfork) - addi -1, %ret1, %ret1 - bv %r0(%rp) - and %ret1, %ret0, %ret0 -EXIT(vfork) - - .end diff --git a/lib/libc/compat/arch/hppa/sys/compat___semctl.S b/lib/libc/compat/arch/hppa/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/hppa/sys/compat___sigreturn14.S b/lib/libc/compat/arch/hppa/sys/compat___sigreturn14.S deleted file mode 100644 index 515a88801..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat___sigreturn14.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2006/03/11 19:54:56 christos Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat___sigreturn14.S,v 1.1 2006/03/11 19:54:56 christos Exp $") -#endif /* LIBC_SCCS and not lint */ - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/hppa/sys/compat_msgctl.S b/lib/libc/compat/arch/hppa/sys/compat_msgctl.S deleted file mode 100644 index cc08d76ef..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/hppa/sys/compat_quotactl.S b/lib/libc/compat/arch/hppa/sys/compat_quotactl.S deleted file mode 100644 index 8df4a3de5..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:13 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/hppa/sys/compat_shmctl.S b/lib/libc/compat/arch/hppa/sys/compat_shmctl.S deleted file mode 100644 index 10d43f71d..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/hppa/sys/compat_sigaction.S b/lib/libc/compat/arch/hppa/sys/compat_sigaction.S deleted file mode 100644 index a5f8ad810..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/hppa/sys/compat_sigpending.S b/lib/libc/compat/arch/hppa/sys/compat_sigpending.S deleted file mode 100644 index 0ed8d51f4..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_sigpending.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - - .import __cerror, code - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -ENTRY(sigpending, 0) - /* - * AFAICT, since the hppa port came after __sigpending14, - * we shouldn't have to supply the compatability sigpending. - */ - ldi EINVAL, %t1 - b,n __cerror -EXIT(sigpending) diff --git a/lib/libc/compat/arch/hppa/sys/compat_sigprocmask.S b/lib/libc/compat/arch/hppa/sys/compat_sigprocmask.S deleted file mode 100644 index 99c00931f..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_sigprocmask.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - - .import __cerror, code - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -ENTRY(sigprocmask, 0) - /* - * AFAICT, since the hppa port came after __sigprocmask14, - * we shouldn't have to supply the compatability sigprocmask. - */ - ldi EINVAL, %t1 - b,n __cerror -EXIT(sigprocmask) diff --git a/lib/libc/compat/arch/hppa/sys/compat_sigreturn.S b/lib/libc/compat/arch/hppa/sys/compat_sigreturn.S deleted file mode 100644 index d02624bdb..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_sigreturn.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - - .import __cerror, code - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn(); include for correct reference") - -ENTRY(sigreturn, 0) - /* - * AFAICT, since the hppa port came after __sigreturn14, - * we shouldn't have to supply the compatability sigreturn. - */ - ldi EINVAL, %t1 - b,n __cerror -EXIT(sigreturn) diff --git a/lib/libc/compat/arch/hppa/sys/compat_sigsuspend.S b/lib/libc/compat/arch/hppa/sys/compat_sigsuspend.S deleted file mode 100644 index 2cdbb3eff..000000000 --- a/lib/libc/compat/arch/hppa/sys/compat_sigsuspend.S +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Fredette. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include "SYS.h" - - .import __cerror, code - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend, 0) - /* - * AFAICT, since the hppa port came after __sigsuspend14, - * we shouldn't have to supply the compatability sigsuspend. - */ - ldi EINVAL, %t1 - b,n __cerror -EXIT(sigsuspend) diff --git a/lib/libc/compat/arch/i386/Makefile.inc b/lib/libc/compat/arch/i386/Makefile.inc deleted file mode 100644 index 940d4f194..000000000 --- a/lib/libc/compat/arch/i386/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2015/02/09 22:44:34 pooka Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.if ${RUMPRUN} != "yes" -.include "${COMPATARCHDIR}/sys/Makefile.inc" -.endif diff --git a/lib/libc/compat/arch/i386/gen/Makefile.inc b/lib/libc/compat/arch/i386/gen/Makefile.inc deleted file mode 100644 index 81d6059a5..000000000 --- a/lib/libc/compat/arch/i386/gen/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2006/06/27 18:19:57 drochner Exp $ - -# objects built from assembler sources (need lint stubs) -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/i386/gen/compat_setjmp.S b/lib/libc/compat/arch/i386/gen/compat_setjmp.S deleted file mode 100644 index 01c2d6f23..000000000 --- a/lib/libc/compat/arch/i386/gen/compat_setjmp.S +++ /dev/null @@ -1,103 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: compat_setjmp.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(setjmp) - - PIC_PROLOGUE - pushl $0 -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(sigblock)) -#else - call _C_LABEL(sigblock) -#endif - addl $4,%esp - PIC_EPILOGUE - - movl 4(%esp),%ecx - movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - movl %eax,24(%ecx) - xorl %eax,%eax - ret -END(setjmp) - -ENTRY(longjmp) - movl 4(%esp),%edx - - PIC_PROLOGUE - pushl 24(%edx) -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(sigsetmask)) -#else - call _C_LABEL(sigsetmask) -#endif - addl $4,%esp - PIC_EPILOGUE - - movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jnz 1f - incl %eax -1: movl %ecx,0(%esp) - ret -END(longjmp) diff --git a/lib/libc/compat/arch/i386/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/i386/gen/compat_sigsetjmp.S deleted file mode 100644 index db1b22b71..000000000 --- a/lib/libc/compat/arch/i386/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90" - */ - -#include -#if defined(LIBC_SCCS) - RCSID("$NetBSD: compat_sigsetjmp.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $") -#endif - -ENTRY(sigsetjmp) - movl 4(%esp),%ecx - movl 8(%esp),%eax - movl %eax,28(%ecx) - testl %eax,%eax - jz 2f - - PIC_PROLOGUE - pushl $0 -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(sigblock)) -#else - call _C_LABEL(sigblock) -#endif - addl $4,%esp - PIC_EPILOGUE - - movl 4(%esp),%ecx - movl %eax,24(%ecx) -2: movl 0(%esp),%edx - movl %edx, 0(%ecx) - movl %ebx, 4(%ecx) - movl %esp, 8(%ecx) - movl %ebp,12(%ecx) - movl %esi,16(%ecx) - movl %edi,20(%ecx) - xorl %eax,%eax - ret -END(sigsetjmp) - -ENTRY(siglongjmp) - movl 4(%esp),%edx - cmpl $0,28(%edx) - jz 2f - - PIC_PROLOGUE - pushl 24(%edx) -#ifdef __PIC__ - call PIC_PLT(_C_LABEL(sigsetmask)) -#else - call _C_LABEL(sigsetmask) -#endif - addl $4,%esp - PIC_EPILOGUE - -2: movl 4(%esp),%edx - movl 8(%esp),%eax - movl 0(%edx),%ecx - movl 4(%edx),%ebx - movl 8(%edx),%esp - movl 12(%edx),%ebp - movl 16(%edx),%esi - movl 20(%edx),%edi - testl %eax,%eax - jnz 3f - incl %eax -3: movl %ecx,0(%esp) - ret -END(siglongjmp) diff --git a/lib/libc/compat/arch/i386/sys/Makefile.inc b/lib/libc/compat/arch/i386/sys/Makefile.inc deleted file mode 100644 index 47154b1b6..000000000 --- a/lib/libc/compat/arch/i386/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:13 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/i386/sys/compat_Ovfork.S b/lib/libc/compat/arch/i386/sys/compat_Ovfork.S deleted file mode 100644 index 5098c57d3..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_Ovfork.S +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_Ovfork.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ -ENTRY(vfork) - popl %ecx /* my rta into ecx */ - SYSTRAP(vfork) - jc err - decl %edx - andl %edx,%eax - jmp *%ecx -err: - pushl %ecx -#ifdef __PIC__ - PIC_PROLOGUE - mov PIC_GOT(CERROR), %ecx - PIC_EPILOGUE - jmp *%ecx -#else - jmp CERROR -#endif -END(vfork) diff --git a/lib/libc/compat/arch/i386/sys/compat___semctl.S b/lib/libc/compat/arch/i386/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/i386/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/i386/sys/compat___sigreturn14.S b/lib/libc/compat/arch/i386/sys/compat___sigreturn14.S deleted file mode 100644 index c0a66a8bc..000000000 --- a/lib/libc/compat/arch/i386/sys/compat___sigreturn14.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.3 2014/05/23 02:03:41 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat___sigreturn14.S,v 1.3 2014/05/23 02:03:41 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef GPROF -#undef ENTRY -#undef END -#ifdef __ELF__ -#define MCOUNT_SYMBOL __mcount -#else -#define MCOUNT_SYMBOL mcount -#endif -#define ENTRY(x) \ - .globl _ ## x; _ALIGN_TEXT; _ ## x: pusha ; \ - .data; 1:; .long 0; .text; movl $1b,%eax; call MCOUNT_SYMBOL; popa ; nop -#define END(x) \ - .size _ ## x, . - _ ## x -#endif /* GPROF */ - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/i386/sys/compat___sigtramp1.S b/lib/libc/compat/arch/i386/sys/compat___sigtramp1.S deleted file mode 100644 index 8cdbe5940..000000000 --- a/lib/libc/compat/arch/i386/sys/compat___sigtramp1.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The i386 signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * sigcontext structure [12] - * pointer to sigcontext structure [8] - * signal specific code [4] - * sp-> signal number [0] - */ -NENTRY(__sigtramp_sigcontext_1) - leal 12(%esp),%eax /* get pointer to sigcontext */ - movl %eax,4(%esp) /* put it in the argument slot */ - /* fake return address already there */ - SYSTRAP(compat_16___sigreturn14) /* do sigreturn */ - movl %eax,4(%esp) /* error code */ - SYSTRAP(exit) /* exit */ -END(__sigtramp_sigcontext_1) diff --git a/lib/libc/compat/arch/i386/sys/compat_msgctl.S b/lib/libc/compat/arch/i386/sys/compat_msgctl.S deleted file mode 100644 index cc08d76ef..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/i386/sys/compat_quotactl.S b/lib/libc/compat/arch/i386/sys/compat_quotactl.S deleted file mode 100644 index 8df4a3de5..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:13 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/i386/sys/compat_shmctl.S b/lib/libc/compat/arch/i386/sys/compat_shmctl.S deleted file mode 100644 index 10d43f71d..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/i386/sys/compat_sigaction.S b/lib/libc/compat/arch/i386/sys/compat_sigaction.S deleted file mode 100644 index a5f8ad810..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/i386/sys/compat_sigpending.S b/lib/libc/compat/arch/i386/sys/compat_sigpending.S deleted file mode 100644 index 0759c52f0..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_sigpending.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.2 2014/05/23 02:34:33 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigpending.s 5.1 (Berkeley) 7/1/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigpending.S,v 1.2 2014/05/23 02:34:33 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -_SYSCALL(sigpending,compat_13_sigpending13) - movl 4(%esp),%ecx # fetch pointer to... - movl %eax,(%ecx) # store old mask - xorl %eax,%eax - ret -END(sigpending) diff --git a/lib/libc/compat/arch/i386/sys/compat_sigprocmask.S b/lib/libc/compat/arch/i386/sys/compat_sigprocmask.S deleted file mode 100644 index d06aa46c0..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_sigprocmask.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigprocmask.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigprocmask.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -ENTRY(sigprocmask) - movl 8(%esp),%ecx # fetch new sigset pointer - testl %ecx,%ecx # check new sigset pointer - jnz 1f # if not null, indirect -/* movl $0,8(%esp) # null mask pointer: block empty set */ - movl $1,4(%esp) # SIG_BLOCK - jmp 2f -1: movl (%ecx),%ecx # fetch indirect ... - movl %ecx,8(%esp) # to new mask arg -2: SYSTRAP(compat_13_sigprocmask13) - jc err - movl 12(%esp),%ecx # fetch old mask requested - testl %ecx,%ecx # test if old mask requested - jz out - movl %eax,(%ecx) # store old mask -out: - xorl %eax,%eax - ret -err: -#ifdef __PIC__ - PIC_PROLOGUE - mov PIC_GOT(CERROR), %ecx - PIC_EPILOGUE - jmp *%ecx -#else - jmp CERROR -#endif -END(sigprocmask) diff --git a/lib/libc/compat/arch/i386/sys/compat_sigreturn.S b/lib/libc/compat/arch/i386/sys/compat_sigreturn.S deleted file mode 100644 index 3dc2bb9f6..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_sigreturn.S +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.3 2014/05/23 02:03:41 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigreturn.S,v 1.3 2014/05/23 02:03:41 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef GPROF -#undef ENTRY -#undef END -#ifdef __ELF__ -#define MCOUNT_SYMBOL __mcount -#else -#define MCOUNT_SYMBOL mcount -#endif -#define ENTRY(x) \ - .globl _ ## x; _ALIGN_TEXT; _ ## x: pusha ; \ - .data; 1:; .long 0; .text; movl $1b,%eax; call MCOUNT_SYMBOL; popa ; nop -#define END(x) \ - .size _ ## x, . - _ ## x -#endif /* GPROF */ - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -PSEUDO(sigreturn,compat_13_sigreturn13) diff --git a/lib/libc/compat/arch/i386/sys/compat_sigsuspend.S b/lib/libc/compat/arch/i386/sys/compat_sigsuspend.S deleted file mode 100644 index 2bcccd4dd..000000000 --- a/lib/libc/compat/arch/i386/sys/compat_sigsuspend.S +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigsuspend.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigsuspend.S,v 1.3 2014/05/23 02:34:33 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend) - movl 4(%esp),%eax # fetch mask arg - movl (%eax),%eax # indirect to mask arg - movl %eax,4(%esp) - SYSTRAP(compat_13_sigsuspend13) - jc err - xorl %eax,%eax # shouldn t happen - ret -err: -#ifdef __PIC__ - PIC_PROLOGUE - mov PIC_GOT(CERROR), %ecx - PIC_EPILOGUE - jmp *%ecx -#else - jmp CERROR -#endif -END(sigsuspend) diff --git a/lib/libc/compat/arch/ia64/Makefile.inc b/lib/libc/compat/arch/ia64/Makefile.inc deleted file mode 100644 index 81c5297f9..000000000 --- a/lib/libc/compat/arch/ia64/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/09/23 17:38:03 cherry Exp $ - -.include "${COMPATARCHDIR}/sys/Makefile.inc" - diff --git a/lib/libc/compat/arch/ia64/sys/Makefile.inc b/lib/libc/compat/arch/ia64/sys/Makefile.inc deleted file mode 100644 index 83d9c16d5..000000000 --- a/lib/libc/compat/arch/ia64/sys/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:13 bouyer Exp $ - -SRCS+= compat___semctl.S compat_quotactl.S diff --git a/lib/libc/compat/arch/ia64/sys/compat___semctl.S b/lib/libc/compat/arch/ia64/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/ia64/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/ia64/sys/compat_quotactl.S b/lib/libc/compat/arch/ia64/sys/compat_quotactl.S deleted file mode 100644 index 8df4a3de5..000000000 --- a/lib/libc/compat/arch/ia64/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:13 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/m68k/Makefile.inc b/lib/libc/compat/arch/m68k/Makefile.inc deleted file mode 100644 index 78ab575bb..000000000 --- a/lib/libc/compat/arch/m68k/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 23:04:03 christos Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/m68k/gen/Makefile.inc b/lib/libc/compat/arch/m68k/gen/Makefile.inc deleted file mode 100644 index 260fd9ce4..000000000 --- a/lib/libc/compat/arch/m68k/gen/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/07/03 12:54:34 drochner Exp $ - -# objects built from assembler sources (need lint stubs) -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c -#SRCS+= compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/m68k/gen/compat_setjmp.S b/lib/libc/compat/arch/m68k/gen/compat_setjmp.S deleted file mode 100644 index 662228ad5..000000000 --- a/lib/libc/compat/arch/m68k/gen/compat_setjmp.S +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.3 2014/03/04 06:27:00 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)setjmp.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: compat_setjmp.S,v 1.3 2014/03/04 06:27:00 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -ENTRY(setjmp) - lea -12(%sp),%sp /* space for sigstack args/rvals */ - clrl (%sp) /* don't change it... */ - movl %sp,4(%sp) /* ...but return the current val */ - jbsr PIC_PLT(_C_LABEL(__sigaltstack14)) - /* note: flags returned in sp@(8) */ - clrl (%sp) /* don't change mask, just return */ - jbsr PIC_PLT(_C_LABEL(sigblock)) /* old value */ - movl 8(%sp),%d1 /* old flags value */ - andl #1,%d1 /* extract onstack flag */ - lea 12(%sp),%sp - movl 4(%sp),%a0 /* save area pointer */ - movl %d1,(%a0)+ /* save old onstack value */ - movl %d0,(%a0)+ /* save old signal mask */ - lea 4(%sp),%a1 /* adjust saved SP since we won't rts */ - movl %a1,(%a0)+ /* save old SP */ - movl %a6,(%a0)+ /* save old FP */ - clrl (%a0)+ /* no AP */ - movl (%sp),(%a0)+ /* save old PC */ - clrl (%a0)+ /* clean PS */ - moveml #0x3CFC,(%a0) /* save remaining non-scratch regs */ - clrl %d0 /* return 0 */ - rts -END(setjmp) - -ENTRY(longjmp) - movl 4(%sp),%a0 /* save area pointer */ - tstl 8(%a0) /* ensure non-zero SP */ - jeq botch /* oops! */ - movl 8(%sp),%d0 /* grab return value */ - jne ok /* non-zero ok */ - moveq #1,%d0 /* else make non-zero */ -ok: - moveml 28(%a0),#0x3CFC /* restore non-scratch regs */ - movl %a0,-(%sp) /* let sigreturn */ - trap #1 /* finish via compat_13_sigreturn13() */ - -botch: - jbsr PIC_PLT(_C_LABEL(longjmperror)) - stop #0 -END(longjmp) diff --git a/lib/libc/compat/arch/m68k/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/m68k/gen/compat_sigsetjmp.S deleted file mode 100644 index d44d3985e..000000000 --- a/lib/libc/compat/arch/m68k/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)_setjmp.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: compat_sigsetjmp.S,v 1.3 2014/03/18 18:20:37 riastradh Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a,m) - * by restoring registers from the stack, - * The previous signal state is restored if 'm' was non-zero. - */ - -/* grab _JBLEN */ -#include - -ENTRY(sigsetjmp) - movl 8(%sp),%d1 /* grab the mask */ - movl 4(%sp),%a0 /* grab the area pointer */ - movl %d1,(_JBLEN * 4)(%a0) /* save at end of area */ - tstl %d1 - bne dosig - jra PIC_PLT(_C_LABEL(_setjmp)) -dosig: - jra PIC_PLT(_C_LABEL(setjmp)) -END(sigsetjmp) - - -ENTRY(siglongjmp) - movl 4(%sp),%a0 /* save area pointer */ - tstl (_JBLEN * 4)(%a0) /* check mask... */ - bne didsig - jra PIC_PLT(_C_LABEL(_longjmp)) -didsig: - jra PIC_PLT(_C_LABEL(longjmp)) -END(siglongjmp) diff --git a/lib/libc/compat/arch/m68k/sys/Makefile.inc b/lib/libc/compat/arch/m68k/sys/Makefile.inc deleted file mode 100644 index 47154b1b6..000000000 --- a/lib/libc/compat/arch/m68k/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:13 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/m68k/sys/compat_Ovfork.S b/lib/libc/compat/arch/m68k/sys/compat_Ovfork.S deleted file mode 100644 index 39c209e73..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_Ovfork.S +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.3 2013/09/12 15:36:16 joerg Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)Ovfork.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: compat_Ovfork.S,v 1.3 2013/09/12 15:36:16 joerg Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * @(#)vfork.s 4.1 (Berkeley) 12/21/80 - * C library -- vfork - */ - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -/* - * pid = vfork(); - * - * d1 == 0 in parent process, d1 == 1 in child process. - * d0 == pid of child in parent, d0 == pid of parent in child. - * - * trickery here, due to keith sklower, uses ret to clear the stack, - * and then returns with a jump indirect, since only one person can return - * with a ret off this stack... we do the ret before we vfork! - */ - -ENTRY(vfork) - movl (%sp)+,%a1 - SYSTRAP(vfork) - jcs err - subql #1,%d1 /* from 1 to 0 in child, 0 to -1 in parent */ - andl %d1,%d0 - jmp (%a1) -err: -#ifdef _REENTRANT - .globl _C_LABEL(__errno) - movl %a1,-(%sp) - movl %d0,-(%sp) - jbsr PIC_PLT(_C_LABEL(__errno)) -#ifdef __SVR4_ABI__ - movl (%sp)+,(%a0) -#else - movl %d0,%a1 - movl (%sp)+,(%a1) -#endif /* __SVR4_ABI__ */ - movl (%sp)+,%a1 -#else - .globl _C_LABEL(errno) -#ifdef __PIC__ - GOT_SETUP(%a0) - movl _C_LABEL(errno)@GOT:w(%a0),%a0 - movl %d0,(%a0) -#else - movl %d0,_C_LABEL(errno) -#endif /* __PIC__ */ -#endif /* _REENTRANT */ - moveq #-1,%d0 - jmp (%a1) -END(vfork) diff --git a/lib/libc/compat/arch/m68k/sys/compat___semctl.S b/lib/libc/compat/arch/m68k/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/m68k/sys/compat___sigreturn14.S b/lib/libc/compat/arch/m68k/sys/compat___sigreturn14.S deleted file mode 100644 index 39c41b9c0..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat___sigreturn14.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.2 2013/07/16 23:00:15 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigreturn.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: compat___sigreturn14.S,v 1.2 2013/07/16 23:00:15 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef GPROF -#undef _PROF_PROLOG -#define _PROF_PROLOG \ - .data; 1: .long 0; \ - .text; INTERRUPT_SAVEREG; LEA_LCL(1b,%a0); jbsr MCOUNT_ENTRY; \ - INTERRUPT_RESTOREREG -#endif - -ENTRY(__sigreturn14) - trap #3 /* special sigreturn syscall entry point */ - jbra CERROR -END(__sigreturn14) diff --git a/lib/libc/compat/arch/m68k/sys/compat___sigtramp1.S b/lib/libc/compat/arch/m68k/sys/compat___sigtramp1.S deleted file mode 100644 index 09116a0b0..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat___sigtramp1.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.3 2013/07/16 23:00:15 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The m68k signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * sigcontext structure [12] - * pointer to sigcontext structure [8] - * signal specific code [4] - * sp-> signal number [0] - */ -ENTRY_NOPROFILE(__sigtramp_sigcontext_1) - leal 12(%sp),%a0 /* get pointer to sigcontext */ - movl %a0,4(%sp) /* put it in the argument slot */ - /* fake return address already there */ - trap #3 /* special sigreturn trap */ - movl %d0,4(%sp) /* failed, exit with errno */ - SYSTRAP(exit) -END(__sigtramp_sigcontext_1) diff --git a/lib/libc/compat/arch/m68k/sys/compat_msgctl.S b/lib/libc/compat/arch/m68k/sys/compat_msgctl.S deleted file mode 100644 index cc08d76ef..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/m68k/sys/compat_quotactl.S b/lib/libc/compat/arch/m68k/sys/compat_quotactl.S deleted file mode 100644 index 8df4a3de5..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:13 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/m68k/sys/compat_shmctl.S b/lib/libc/compat/arch/m68k/sys/compat_shmctl.S deleted file mode 100644 index 10d43f71d..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/m68k/sys/compat_sigaction.S b/lib/libc/compat/arch/m68k/sys/compat_sigaction.S deleted file mode 100644 index a5f8ad810..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/m68k/sys/compat_sigpending.S b/lib/libc/compat/arch/m68k/sys/compat_sigpending.S deleted file mode 100644 index 4118a2d76..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_sigpending.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.2 2013/07/16 23:00:15 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigpending.s 5.2 (Berkeley) 8/6/90") -#else - RCSID("$NetBSD: compat_sigpending.S,v 1.2 2013/07/16 23:00:15 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -_SYSCALL(sigpending,compat_13_sigpending13) - movl 4(%sp),%a0 - movl %d0,(%a0) - clrl %d0 - rts -END(sigpending) diff --git a/lib/libc/compat/arch/m68k/sys/compat_sigprocmask.S b/lib/libc/compat/arch/m68k/sys/compat_sigprocmask.S deleted file mode 100644 index d24f02083..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_sigprocmask.S +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.4 2013/07/25 22:08:15 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigprocmask.s 5.2 (Berkeley) 6/6/90") -#else - RCSID("$NetBSD: compat_sigprocmask.S,v 1.4 2013/07/25 22:08:15 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -ENTRY(sigprocmask) - tstl 8(%sp) /* check new sigset pointer */ - jne gotptr /* if not null, indirect */ -/* movl #0,8(%sp) /* null mask pointer: block empty set */ - movql #1,%d0 /* SIG_BLOCK */ - movl %d0,4(%sp) - jra doit -gotptr: - movl 8(%sp),%a0 - movl (%a0),8(%sp) /* indirect to new mask arg */ -doit: - SYSTRAP(compat_13_sigprocmask13) - jcs CERROR - tstl 12(%sp) /* test if old mask requested */ - jeq out - movl 12(%sp),%a0 - movl %d0,(%a0) /* store old mask */ -out: - clrl %d0 - rts -END(sigprocmask) diff --git a/lib/libc/compat/arch/m68k/sys/compat_sigreturn.S b/lib/libc/compat/arch/m68k/sys/compat_sigreturn.S deleted file mode 100644 index 0af92c58b..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_sigreturn.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.2 2013/07/16 23:00:15 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigreturn.s 5.1 (Berkeley) 5/12/90") -#else - RCSID("$NetBSD: compat_sigreturn.S,v 1.2 2013/07/16 23:00:15 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef GPROF -#undef _PROF_PROLOG -#define _PROF_PROLOG \ - .data; 1: .long 0; \ - .text; INTERRUPT_SAVEREG; LEA_LCL(1b,%a0); jbsr MCOUNT_ENTRY; \ - INTERRUPT_RESTOREREG -#endif /* GPROF */ - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -/* - * NOTE: Trap #1 is used for compat_13_sigreturn13 on the m68k! - */ -ENTRY(sigreturn) - trap #1 /* signals compat_13_sigreturn13() */ - jbra CERROR -END(sigreturn) diff --git a/lib/libc/compat/arch/m68k/sys/compat_sigsuspend.S b/lib/libc/compat/arch/m68k/sys/compat_sigsuspend.S deleted file mode 100644 index 64497235d..000000000 --- a/lib/libc/compat/arch/m68k/sys/compat_sigsuspend.S +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.3 2013/07/25 22:08:15 matt Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * the Systems Programming Group of the University of Utah Computer - * Science Department. - * - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigsuspend.s 5.2 (Berkeley) 6/6/90") -#else - RCSID("$NetBSD: compat_sigsuspend.S,v 1.3 2013/07/25 22:08:15 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend) - movl 4(%sp),%a0 - movl (%a0),4(%sp) /* indirect to mask arg */ - SYSTRAP(compat_13_sigsuspend13) - jcs CERROR - clrl %d0 /* shouldn't happen */ - rts -END(sigsuspend) diff --git a/lib/libc/compat/arch/mips/Makefile.inc b/lib/libc/compat/arch/mips/Makefile.inc deleted file mode 100644 index 78ab575bb..000000000 --- a/lib/libc/compat/arch/mips/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 23:04:03 christos Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/mips/gen/Makefile.inc b/lib/libc/compat/arch/mips/gen/Makefile.inc deleted file mode 100644 index 3aa7a9002..000000000 --- a/lib/libc/compat/arch/mips/gen/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2006/07/03 12:58:55 drochner Exp $ - -# objects built from assembler sources (need lint stubs) -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c -#SRCS+= compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/mips/gen/compat_setjmp.S b/lib/libc/compat/arch/mips/gen/compat_setjmp.S deleted file mode 100644 index a3028f787..000000000 --- a/lib/libc/compat/arch/mips/gen/compat_setjmp.S +++ /dev/null @@ -1,162 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.2 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 -#include - -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: compat_setjmp.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#define SETJMP_FRAME_SIZE (CALLFRAME_SIZ + STACK_T_SIZE) - -NON_LEAF(setjmp, SETJMP_FRAME_SIZE, ra) - .mask 0x80010000, (CALLFRAME_RA - CALLFRAME_SIZ) - SETUP_GP - PTR_SUBU sp, sp, SETJMP_FRAME_SIZE # allocate stack frame - SAVE_GP(CALLFRAME_GP) - SETUP_GP64(CALLFRAME_GP, setjmp) - - REG_S ra, CALLFRAME_RA(sp) # save RA - REG_S s0, CALLFRAME_S0(sp) # save S0 - move s0, a0 # save sigcontext - - /* Get the signal mask. */ - move a0, zero # get current sigmask - jal _C_LABEL(sigblock) - nop - INT_S v0, _OFFSETOF_SC_MASK13(s0) # save sc_mask13 - - /* Get the signal stack. */ - move a0, zero - PTR_ADDU a1, sp, CALLFRAME_SIZ # pointer to stack_t - jal _C_LABEL(__sigaltstack14) - - move a0, s0 # restore jmpbuf - INT_L v1, CALLFRAME_SIZ+_OFFSETOF_STACK_T_FLAGS(sp) - # get old ss_onstack - and v1, v1, SS_ONSTACK # extract onstack flag - INT_S v1, _OFFSETOF_SC_ONSTACK(a0) # save it in sc_onstack - - REG_L s0, CALLFRAME_S0(sp) # restore S0 - REG_L ra, CALLFRAME_RA(sp) # restore RA - blt v0, zero, botch # check for sigaltstack() error - nop - /* - * We know we won't need this routine's GP anymore. - */ - RESTORE_GP64 - PTR_ADDU sp, sp, SETJMP_FRAME_SIZE # pop stack frame - - REG_PROLOGUE - REG_S ra, _OFFSETOF_SC_PC(a0) # sc_pc = return address - REG_LI v0, 0xACEDBADE # sigcontext magic number - REG_S v0, _OFFSETOF_SC_REGS(a0) # saved in sc_regs[0] - REG_S s0, _OFFSETOF_SC_REGS_S0(a0) - REG_S s1, _OFFSETOF_SC_REGS_S1(a0) - REG_S s2, _OFFSETOF_SC_REGS_S2(a0) - REG_S s3, _OFFSETOF_SC_REGS_S3(a0) - REG_S s4, _OFFSETOF_SC_REGS_S4(a0) - REG_S s5, _OFFSETOF_SC_REGS_S5(a0) - REG_S s6, _OFFSETOF_SC_REGS_S6(a0) - REG_S s7, _OFFSETOF_SC_REGS_S7(a0) - REG_S gp, _OFFSETOF_SC_REGS_GP(a0) - REG_S sp, _OFFSETOF_SC_REGS_SP(a0) - REG_S s8, _OFFSETOF_SC_REGS_S8(a0) - li v0, 1 # be nice if we could tell - INT_S v0, _OFFSETOF_SC_FPUSED(a0) # sc_fpused = 1 - cfc1 v0, $31 - INT_S v0, _OFFSETOF_SC_FPREGS_FCSR(a0) -#if defined(__mips_o32) || defined(__mips_o64) || defined(__mips_n32) - FP_S $f20, _OFFSETOF_SC_FPREGS_F20(a0) - FP_S $f22, _OFFSETOF_SC_FPREGS_F22(a0) -#endif -#if defined(__mips_o32) || defined(__mips_o64) - FP_S $f21, _OFFSETOF_SC_FPREGS_F21(a0) - FP_S $f23, _OFFSETOF_SC_FPREGS_F23(a0) -#endif -#if defined(__mips_n32) || defined(__mips_n64) - FP_S $f24, _OFFSETOF_SC_FPREGS_F24(a0) - FP_S $f26, _OFFSETOF_SC_FPREGS_F26(a0) - FP_S $f28, _OFFSETOF_SC_FPREGS_F28(a0) - FP_S $f30, _OFFSETOF_SC_FPREGS_F30(a0) -#endif -#if defined(__mips_n64) - FP_S $f25, _OFFSETOF_SC_FPREGS_F25(a0) - FP_S $f27, _OFFSETOF_SC_FPREGS_F27(a0) - FP_S $f29, _OFFSETOF_SC_FPREGS_F29(a0) - FP_S $f31, _OFFSETOF_SC_FPREGS_F31(a0) -#endif - REG_EPILOGUE - j ra - move v0, zero - -botch: - jal _C_LABEL(abort) -END(setjmp) - -LEAF(longjmp) - SETUP_GP - PTR_SUBU sp, sp, CALLFRAME_SIZ - SAVE_GP(CALLFRAME_S0) - SETUP_GP64(s0, longjmp) - - REG_PROLOGUE - /* save return value in sc_regs[_R_V0] */ - REG_S a1, _OFFSETOF_SC_REGS_V0(a0) - REG_EPILOGUE - - li v0, SYS_compat_13_sigreturn13 - syscall - - jal _C_LABEL(longjmperror) - jal _C_LABEL(abort) -END(longjmp) diff --git a/lib/libc/compat/arch/mips/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/mips/gen/compat_sigsetjmp.S deleted file mode 100644 index e7c8b968c..000000000 --- a/lib/libc/compat/arch/mips/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.2 2009/12/14 03:04:33 matt 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 - * Havard Eidnes. - * - * 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 -#include -#include - -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - ASMSTR("from: @(#)setjmp.s 8.1 (Berkeley) 6/4/93") -#else - ASMSTR("$NetBSD: compat_sigsetjmp.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- sigsetjmp, siglongjmp - * - * siglongjmp(a,v) - * will generate a "return(v)" from - * the last call to - * sigsetjmp(a, savemask) - * by restoring registers from the stack, - * and dependent on savemask restores the - * signal mask. - */ - -LEAF(sigsetjmp) - SETUP_GP - SETUP_GP64(t0, sigsetjmp) - INT_S a1, _OFFSETOF_SC_MASK13(a0) # save "savemask" - bne a1, 0x0, 1f # do saving of signal mask? - PTR_LA t9, _C_LABEL(_setjmp) - jr t9 - -1: PTR_LA t9, _C_LABEL(setjmp) - jr t9 -END(sigsetjmp) - -LEAF(siglongjmp) - SETUP_GP - SETUP_GP64(t0, siglongjmp) - INT_L t1, _OFFSETOF_SC_MASK13(a0) # get "savemask" - bne t1, 0x0, 1f # restore signal mask? - PTR_LA t9, _C_LABEL(_longjmp) - jr t9 - -1: PTR_LA t9, _C_LABEL(longjmp) - jr t9 -END(siglongjmp) diff --git a/lib/libc/compat/arch/mips/sys/Makefile.inc b/lib/libc/compat/arch/mips/sys/Makefile.inc deleted file mode 100644 index 07241b413..000000000 --- a/lib/libc/compat/arch/mips/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:14 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/mips/sys/compat_Ovfork.S b/lib/libc/compat/arch/mips/sys/compat_Ovfork.S deleted file mode 100644 index 758f9ace4..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_Ovfork.S +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.2 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)Ovfork.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: compat_Ovfork.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -/* - * pid = vfork(); - * - * v1 == 0 in parent process, v1 == 1 in child process. - * v0 == pid of child in parent, v0 == pid of parent in child. - */ - -LEAF(vfork) - PIC_PROLOGUE(vfork) - - SYSTRAP(vfork) # system call number for vfork - beq a3, zero, 1f # jump if no errors - - PIC_TAILCALL(__cerror) - -1: - beq v1, zero, 2f # parent process ? - move v0, zero # return zero in child -2: - PIC_RETURN() -END(vfork) diff --git a/lib/libc/compat/arch/mips/sys/compat___semctl.S b/lib/libc/compat/arch/mips/sys/compat___semctl.S deleted file mode 100644 index 53f21ef57..000000000 --- a/lib/libc/compat/arch/mips/sys/compat___semctl.S +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.4 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat___semctl.S,v 1.4 2009/12/14 03:04:33 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/mips/sys/compat___sigreturn14.S b/lib/libc/compat/arch/mips/sys/compat___sigreturn14.S deleted file mode 100644 index b2536af10..000000000 --- a/lib/libc/compat/arch/mips/sys/compat___sigreturn14.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.2 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigreturn.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: compat___sigreturn14.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/mips/sys/compat___sigtramp1.S b/lib/libc/compat/arch/mips/sys/compat___sigtramp1.S deleted file mode 100644 index 71680d006..000000000 --- a/lib/libc/compat/arch/mips/sys/compat___sigtramp1.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.4 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat___sigtramp1.S,v 1.4 2009/12/14 03:04:33 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -/* - * The MIPS signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * sp-> sigcontext structure - */ -LEAF_NOPROFILE(__sigtramp_sigcontext_1) - move a0, sp /* address of sigcontext */ - SYSTRAP(compat_16___sigreturn14) /* and do sigreturn */ - move a0, v0 /* exit with errno */ - SYSTRAP(exit) /* if sigreturn fails */ -END(__sigtramp_sigcontext_1) diff --git a/lib/libc/compat/arch/mips/sys/compat_msgctl.S b/lib/libc/compat/arch/mips/sys/compat_msgctl.S deleted file mode 100644 index 5457c6c4c..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_msgctl.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.3 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_msgctl.S,v 1.3 2009/12/14 01:07:42 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/mips/sys/compat_quotactl.S b/lib/libc/compat/arch/mips/sys/compat_quotactl.S deleted file mode 100644 index 94630b816..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:14 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/mips/sys/compat_shmctl.S b/lib/libc/compat/arch/mips/sys/compat_shmctl.S deleted file mode 100644 index 57c842155..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_shmctl.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.3 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_shmctl.S,v 1.3 2009/12/14 01:07:42 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/mips/sys/compat_sigaction.S b/lib/libc/compat/arch/mips/sys/compat_sigaction.S deleted file mode 100644 index b2506acd5..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_sigaction.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.3 2009/12/14 01:07:42 matt Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigaction.S,v 1.3 2009/12/14 01:07:42 matt Exp $") -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/mips/sys/compat_sigpending.S b/lib/libc/compat/arch/mips/sys/compat_sigpending.S deleted file mode 100644 index 93c99e824..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_sigpending.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.2 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigpending.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: compat_sigpending.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -LEAF(sigpending) - PIC_PROLOGUE(sigpending) - - SYSTRAP(compat_13_sigpending13) - bne a3, zero, 1f - INT_S v0, _OFFSETOF_SC_ONSTACK(a0) - move v0, zero - PIC_RETURN() - -1: - PIC_TAILCALL(__cerror) -END(sigpending) diff --git a/lib/libc/compat/arch/mips/sys/compat_sigprocmask.S b/lib/libc/compat/arch/mips/sys/compat_sigprocmask.S deleted file mode 100644 index 913a139d1..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_sigprocmask.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.2 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigprocmask.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: compat_sigprocmask.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -LEAF(sigprocmask) # sigprocmask(how, new, old) sigset_t *new, *old; - PIC_PROLOGUE(sigprocmask) - bne a1, zero, gotptr # if new sigset pointer not null - li a0, 1 # how = SIG_BLOCK - b doit # mask = zero -gotptr: - INT_L a1, 0(a1) # indirect to new mask arg -doit: - SYSTRAP(compat_13_sigprocmask13) - - bne a3, zero, err - beq a2, zero, out # test if old mask requested - INT_S v0, 0(a2) # store old mask -out: - move v0, zero - PIC_RETURN() -err: - PIC_TAILCALL(__cerror) -END(sigprocmask) diff --git a/lib/libc/compat/arch/mips/sys/compat_sigreturn.S b/lib/libc/compat/arch/mips/sys/compat_sigreturn.S deleted file mode 100644 index ac5df9dfc..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_sigreturn.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.2 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigreturn.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: compat_sigreturn.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -PSEUDO(sigreturn,compat_13_sigreturn13) diff --git a/lib/libc/compat/arch/mips/sys/compat_sigsuspend.S b/lib/libc/compat/arch/mips/sys/compat_sigsuspend.S deleted file mode 100644 index 8c7b7c519..000000000 --- a/lib/libc/compat/arch/mips/sys/compat_sigsuspend.S +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.2 2009/12/14 03:04:33 matt Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * 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 "SYS.h" - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - RCSID("from: @(#)sigsuspend.s 8.1 (Berkeley) 6/4/93") -#else - RCSID("$NetBSD: compat_sigsuspend.S,v 1.2 2009/12/14 03:04:33 matt Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -LEAF(sigsuspend) - PIC_PROLOGUE(sigsuspend) - - INT_L a0, 0(a0) # indirect to mask arg - SYSTRAP(compat_13_sigsuspend13) - bne a3, zero, 1f - move v0, zero # should not happen - PIC_RETURN() -1: - PIC_TAILCALL(__cerror) -END(sigsuspend) diff --git a/lib/libc/compat/arch/or1k/Makefile.inc b/lib/libc/compat/arch/or1k/Makefile.inc deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/libc/compat/arch/powerpc/Makefile.inc b/lib/libc/compat/arch/powerpc/Makefile.inc deleted file mode 100644 index 2f234ec4d..000000000 --- a/lib/libc/compat/arch/powerpc/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2011/01/15 07:31:13 matt Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" - -CPPFLAGS+= -I. diff --git a/lib/libc/compat/arch/powerpc/gen/Makefile.inc b/lib/libc/compat/arch/powerpc/gen/Makefile.inc deleted file mode 100644 index 0018c2bee..000000000 --- a/lib/libc/compat/arch/powerpc/gen/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2006/06/28 14:46:33 drochner Exp $ - -# objects built from assembler sources (need lint stubs) -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/powerpc/gen/compat_setjmp.S b/lib/libc/compat/arch/powerpc/gen/compat_setjmp.S deleted file mode 100644 index 49d928326..000000000 --- a/lib/libc/compat/arch/powerpc/gen/compat_setjmp.S +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.2 2011/01/15 07:31:13 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: compat_setjmp.S,v 1.2 2011/01/15 07:31:13 matt Exp $") -#endif - -/* - * C library -- _setjmp, _longjmp - * - * longjmp(a,v) - * will generate a "return(v?v:1)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(setjmp) - mr %r6,%r3 - li %r3,SIG_BLOCK - li %r4,0 - _DOSYSCALL(compat_13_sigprocmask13) # assume no error XXX - mflr %r11 - mfcr %r12 - mr %r10,%r1 - mr %r9,%r2 - mr %r8,%r3 - stmw %r8,4(%r6) - li %r3,0 - blr -END(setjmp) - -ENTRY(longjmp) - lmw %r8,4(%r3) - mr %r6,%r4 - mtlr %r11 - mtcr %r12 - mr %r2,%r9 - mr %r1,%r10 - mr %r4,%r8 - li %r3,SIG_SETMASK - _DOSYSCALL(compat_13_sigprocmask13) # assume no error XXX - or. %r3,%r6,%r6 - bnelr - li %r3,1 - blr -END(longjmp) diff --git a/lib/libc/compat/arch/powerpc/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/powerpc/gen/compat_sigsetjmp.S deleted file mode 100644 index 9ebe269b2..000000000 --- a/lib/libc/compat/arch/powerpc/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.2 2011/01/15 07:31:13 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: compat_sigsetjmp.S,v 1.2 2011/01/15 07:31:13 matt Exp $") -#endif - -ENTRY(sigsetjmp) - mr %r6,%r3 - or. %r7,%r4,%r4 - beq 1f - li %r3,SIG_BLOCK - li %r4,0 - _DOSYSCALL(compat_13_sigprocmask13) # assume no error XXX -1: - mflr %r11 - mfcr %r12 - mr %r10,%r1 - mr %r9,%r2 - mr %r8,%r3 - stmw %r7,0(%r6) - li %r3,0 - blr -END(sigsetjmp) - -ENTRY(siglongjmp) - lmw %r7,0(%r3) - mr %r6,%r4 - mtlr %r11 - mtcr %r12 - mr %r2,%r9 - mr %r1,%r10 - or. %r7,%r7,%r7 - beq 1f - mr %r4,%r8 - li %r3,SIG_SETMASK - _DOSYSCALL(compat_13_sigprocmask13) # assume no error XXX -1: - or. %r3,%r6,%r6 - bnelr - li %r3,1 - blr -END(siglongjmp) diff --git a/lib/libc/compat/arch/powerpc/sys/Makefile.inc b/lib/libc/compat/arch/powerpc/sys/Makefile.inc deleted file mode 100644 index 13b76ee08..000000000 --- a/lib/libc/compat/arch/powerpc/sys/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:14 bouyer Exp $ - -SRCS+= compat_Ovfork.S \ - compat___sigreturn14.S compat___sigtramp1.S \ - compat_msgctl.S compat___semctl.S compat_shmctl.S \ - compat_sigaction13.S compat_sigpending13.S compat_sigprocmask13.S \ - compat_sigreturn13.S compat_sigsuspend13.S compat_quotactl.S diff --git a/lib/libc/compat/arch/powerpc/sys/compat_Ovfork.S b/lib/libc/compat/arch/powerpc/sys/compat_Ovfork.S deleted file mode 100644 index 4c39ceba9..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_Ovfork.S +++ /dev/null @@ -1,23 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.2 2011/01/15 07:31:13 matt Exp $ */ - -/* - * pid = vfork(); - * - * r4 == 0 in parent process, 1 in child process. - * r3 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: compat_Ovfork.S,v 1.2 2011/01/15 07:31:13 matt Exp $") -#endif - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -SYSCALL(vfork) - addi %r4,%r4,-1 # from 1 to 0 in child, 0 to -1 in parent - and %r3,%r3,%r4 # return 0 in child, pid in parent - blr -END(vfork) diff --git a/lib/libc/compat/arch/powerpc/sys/compat___semctl.S b/lib/libc/compat/arch/powerpc/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/powerpc/sys/compat___sigreturn14.S b/lib/libc/compat/arch/powerpc/sys/compat___sigreturn14.S deleted file mode 100644 index b075c3135..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat___sigreturn14.S +++ /dev/null @@ -1,5 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2006/02/18 00:21:28 matt Exp $ */ - -#include "SYS.h" - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/powerpc/sys/compat___sigtramp1.S b/lib/libc/compat/arch/powerpc/sys/compat___sigtramp1.S deleted file mode 100644 index ff6e30ac9..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat___sigtramp1.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.3 2011/01/15 07:31:13 matt Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: compat___sigtramp1.S,v 1.3 2011/01/15 07:31:13 matt Exp $") -#endif - -/* - * On entry, stack and registers look like: - * - * r3 signal number - * r4 signal specific code - * r5 pointer to sigcontext structure - * lr address of handler - * - * sp-> sigcontext structure - */ -ENTRY_NOPROFILE(__sigtramp_sigcontext_1) - addi %r1,%r1,-CALLFRAMELEN /* space for callee */ - blrl /* call handler */ - addi %r3,%r1,CALLFRAMELEN /* compute address of sigcontext */ - _DOSYSCALL(compat_16___sigreturn14) /* and call sigreturn */ - _DOSYSCALL(exit) /* or exit with errno if failed */ -END(__sigtramp_sigcontext_1) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_msgctl.S b/lib/libc/compat/arch/powerpc/sys/compat_msgctl.S deleted file mode 100644 index 26ccc3ced..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_msgctl.S +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.1 2006/02/18 00:21:28 matt Exp $ */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_quotactl.S b/lib/libc/compat/arch/powerpc/sys/compat_quotactl.S deleted file mode 100644 index 94630b816..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:14 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_shmctl.S b/lib/libc/compat/arch/powerpc/sys/compat_shmctl.S deleted file mode 100644 index 10d43f71d..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_sigaction13.S b/lib/libc/compat/arch/powerpc/sys/compat_sigaction13.S deleted file mode 100644 index 42c5ed6b4..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_sigaction13.S +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: compat_sigaction13.S,v 1.1 2006/02/18 00:21:28 matt Exp $ */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_sigpending13.S b/lib/libc/compat/arch/powerpc/sys/compat_sigpending13.S deleted file mode 100644 index 27867cc30..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_sigpending13.S +++ /dev/null @@ -1,21 +0,0 @@ -/* $NetBSD: compat_sigpending13.S,v 1.3 2011/01/16 02:45:48 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: compat_sigpending13.S,v 1.3 2011/01/16 02:45:48 matt Exp $") -#endif - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -ENTRY(sigpending) - mr %r5,%r3 # save pointer - _DOSYSCALL(compat_13_sigpending13) # sigpending() - bso 1f - stw %r3,0(%r5) # store return value - li %r3,0 # and return 0 - blr -1: - b _C_LABEL(__cerror) -END(sigpending) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_sigprocmask13.S b/lib/libc/compat/arch/powerpc/sys/compat_sigprocmask13.S deleted file mode 100644 index 08ee8bfcc..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_sigprocmask13.S +++ /dev/null @@ -1,34 +0,0 @@ -/* $NetBSD: compat_sigprocmask13.S,v 1.2 2011/01/15 07:31:13 matt Exp $ */ - -#include "SYS.h" -#include "assym.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: compat_sigprocmask13.S,v 1.2 2011/01/15 07:31:13 matt Exp $") -#endif - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -/* - * sigprocmask(int how, sigset_t *set, sigset_t *oset) - */ -ENTRY(sigprocmask) - or. %r4,%r4,%r4 # set == NULL? - li %r6,SIG_BLOCK - beq 1f - lwz %r4,0(%r4) # if not, replace it in r4 with *set - mr %r6,%r3 -1: - mr %r3,%r6 # ... using sigprocmask(SIG_BLOCK) - _DOSYSCALL(compat_13_sigprocmask13) - bso 3f - or. %r5,%r5,%r5 # check to see of oset requested - beq 2f # if oset != NULL, - stw %r3,0(%r5) # *oset = oldmask -2: - li %r3,0 - blr # in any case, return 0 -3: - b _C_LABEL(__cerror) -END(sigprocmask) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_sigreturn13.S b/lib/libc/compat/arch/powerpc/sys/compat_sigreturn13.S deleted file mode 100644 index 0c5020943..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_sigreturn13.S +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: compat_sigreturn13.S,v 1.1 2006/02/18 00:21:28 matt Exp $ */ - -#include "SYS.h" - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -PSEUDO(sigreturn,compat_13_sigreturn13) diff --git a/lib/libc/compat/arch/powerpc/sys/compat_sigsuspend13.S b/lib/libc/compat/arch/powerpc/sys/compat_sigsuspend13.S deleted file mode 100644 index fa0374a01..000000000 --- a/lib/libc/compat/arch/powerpc/sys/compat_sigsuspend13.S +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: compat_sigsuspend13.S,v 1.2 2011/01/15 07:31:13 matt Exp $ */ - -#include "SYS.h" - -#if defined(LIBC_SCCS) -__RCSID("$NetBSD: compat_sigsuspend13.S,v 1.2 2011/01/15 07:31:13 matt Exp $") -#endif - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend) - lwz %r3,0(%r3) # indirect to mask arg - _DOSYSCALL(compat_13_sigsuspend13) - b _C_LABEL(__cerror) # always terminates with EINTR -END(sigsuspend) diff --git a/lib/libc/compat/arch/powerpc64/Makefile.inc b/lib/libc/compat/arch/powerpc64/Makefile.inc deleted file mode 100644 index edf1a86ed..000000000 --- a/lib/libc/compat/arch/powerpc64/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/07/01 19:14:49 ross Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/powerpc64/gen/Makefile.inc b/lib/libc/compat/arch/powerpc64/gen/Makefile.inc deleted file mode 100644 index 91d77fbeb..000000000 --- a/lib/libc/compat/arch/powerpc64/gen/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/07/01 19:17:32 ross Exp $ - -# objects built from assembler sources (need lint stubs) -SRCS+= - -# objects built from C sources in compat/gen -SRCS+= diff --git a/lib/libc/compat/arch/powerpc64/sys/Makefile.inc b/lib/libc/compat/arch/powerpc64/sys/Makefile.inc deleted file mode 100644 index a814c1bda..000000000 --- a/lib/libc/compat/arch/powerpc64/sys/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2011/03/06 17:08:14 bouyer Exp $ - -SRCS+= compat_msgctl.S compat___semctl.S compat_shmctl.S compat_quotactl.S diff --git a/lib/libc/compat/arch/powerpc64/sys/compat___semctl.S b/lib/libc/compat/arch/powerpc64/sys/compat___semctl.S deleted file mode 100644 index 80503100d..000000000 --- a/lib/libc/compat/arch/powerpc64/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/powerpc64/sys/compat_msgctl.S b/lib/libc/compat/arch/powerpc64/sys/compat_msgctl.S deleted file mode 100644 index 1e3309aa0..000000000 --- a/lib/libc/compat/arch/powerpc64/sys/compat_msgctl.S +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.1 2006/07/07 06:59:04 ross Exp $ */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/powerpc64/sys/compat_quotactl.S b/lib/libc/compat/arch/powerpc64/sys/compat_quotactl.S deleted file mode 100644 index 94630b816..000000000 --- a/lib/libc/compat/arch/powerpc64/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:14 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/powerpc64/sys/compat_shmctl.S b/lib/libc/compat/arch/powerpc64/sys/compat_shmctl.S deleted file mode 100644 index 10d43f71d..000000000 --- a/lib/libc/compat/arch/powerpc64/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:58 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/riscv/Makefile.inc b/lib/libc/compat/arch/riscv/Makefile.inc deleted file mode 100644 index 3cb7a1a1c..000000000 --- a/lib/libc/compat/arch/riscv/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2014/09/19 17:36:25 matt Exp $ diff --git a/lib/libc/compat/arch/sh3/Makefile.inc b/lib/libc/compat/arch/sh3/Makefile.inc deleted file mode 100644 index 30de512ae..000000000 --- a/lib/libc/compat/arch/sh3/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2006/03/11 23:04:04 christos Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/sh3/gen/Makefile.inc b/lib/libc/compat/arch/sh3/gen/Makefile.inc deleted file mode 100644 index 4faa8a2b2..000000000 --- a/lib/libc/compat/arch/sh3/gen/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2006/06/28 14:46:33 drochner Exp $ - -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/sh3/gen/compat_setjmp.S b/lib/libc/compat/arch/sh3/gen/compat_setjmp.S deleted file mode 100644 index ce296fd7c..000000000 --- a/lib/libc/compat/arch/sh3/gen/compat_setjmp.S +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.3 2006/01/05 19:21:37 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: compat_setjmp.S,v 1.3 2006/01/05 19:21:37 uwe Exp $") -#endif - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from the last call to - * setjmp(a) - * by restoring registers from the stack. - * The previous signal state is restored. - */ - -ENTRY(setjmp) - PIC_PROLOGUE(.L_got_1) - sts.l pr, @-sp - mov.l r4, @-sp - - mov.l .L_sigblock, r0 -1: CALL r0 /* int mask = sigblock(0); */ - mov #0, r4 - - mov.l @sp+, r4 - lds.l @sp+, pr - PIC_EPILOGUE - - /* identical to _setjmp except that mask is present */ - add #((_JB_SIGMASK + 1) * 4), r4 - mov.l r0, @-r4 /* current mask returned by sigblock */ - mov #1, r0 - mov.l r0, @-r4 /* has signal mask */ - mov.l r15, @-r4 - mov.l r14, @-r4 - mov.l r13, @-r4 - mov.l r12, @-r4 - mov.l r11, @-r4 - mov.l r10, @-r4 - mov.l r9, @-r4 - mov.l r8, @-r4 - sts.l pr, @-r4 - rts - xor r0, r0 - - .align 2 -.L_got_1: PIC_GOT_DATUM -.L_sigblock: CALL_DATUM(_C_LABEL(sigblock), 1b) - SET_ENTRY_SIZE(setjmp) - - -ENTRY(longjmp) - /* we won't return here, so we don't need to save pr and r12 */ - PIC_PROLOGUE_NOSAVE(.L_got_2) - mov.l r5, @-sp - mov.l r4, @-sp - - mov.l .L_sigsetmask, r0 -1: CALL r0 /* sigsetmask(saved mask) */ - mov.l @(_JB_SIGMASK * 4, r4), r4 - - mov.l @sp+, r4 - mov.l @sp+, r5 - - /* identical to _longjmp */ - lds.l @r4+, pr - mov.l @r4+, r8 - mov.l @r4+, r9 - mov.l @r4+, r10 - mov.l @r4+, r11 - mov.l @r4+, r12 - mov.l @r4+, r13 - mov.l @r4+, r14 - mov.l @r4+, r15 - - mov r5, r0 - tst r0, r0 /* make sure return value is non-zero */ - bf .L0 - add #1, r0 -.L0: - rts - nop - - .align 2 -.L_got_2: PIC_GOT_DATUM -.L_sigsetmask: CALL_DATUM(_C_LABEL(sigsetmask), 1b) - SET_ENTRY_SIZE(longjmp) diff --git a/lib/libc/compat/arch/sh3/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/sh3/gen/compat_sigsetjmp.S deleted file mode 100644 index 5260f7b66..000000000 --- a/lib/libc/compat/arch/sh3/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,122 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.5 2006/01/05 19:21:37 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)setjmp.s 5.1 (Berkeley) 4/23/90" - */ - -#include -#include - -#if defined(LIBC_SCCS) - RCSID("$NetBSD: compat_sigsetjmp.S,v 1.5 2006/01/05 19:21:37 uwe Exp $") -#endif - -ENTRY(sigsetjmp) - tst r5, r5 - mov.l r5, @(_JB_HAS_MASK * 4, r4) - bt 2f /* if (savemask == 0) */ - - PIC_PROLOGUE(.L_got_1) - sts.l pr, @-sp - mov.l r4, @-sp - - mov.l .L_sigblock, r0 -1: CALL r0 /* int mask = sigblock(0); */ - mov #0, r4 - - mov.l @sp+, r4 - lds.l @sp+, pr - PIC_EPILOGUE - - mov.l r0, @(_JB_SIGMASK * 4, r4) - -2: /* identical to _setjmp sans mask */ - add #((_JB_REG_R15 + 1) * 4), r4 - mov.l r15, @-r4 - mov.l r14, @-r4 - mov.l r13, @-r4 - mov.l r12, @-r4 - mov.l r11, @-r4 - mov.l r10, @-r4 - mov.l r9, @-r4 - mov.l r8, @-r4 - sts.l pr, @-r4 - rts - xor r0, r0 - - .align 2 -.L_got_1: PIC_GOT_DATUM -.L_sigblock: CALL_DATUM(_C_LABEL(sigblock), 1b) - SET_ENTRY_SIZE(sigsetjmp) - - -ENTRY(siglongjmp) - mov.l @(_JB_HAS_MASK * 4, r4), r0 - tst r0, r0 - bt 2f /* if no mask */ - - /* we won't return here, so we don't need to save pr and r12 */ - PIC_PROLOGUE_NOSAVE(.L_got_2) - mov.l r5, @-sp - mov.l r4, @-sp - - mov.l .L_sigsetmask, r0 -1: CALL r0 /* sigsetmask(saved mask) */ - mov.l @(_JB_SIGMASK * 4, r4), r4 - - mov.l @sp+, r4 - mov.l @sp+, r5 - -2: /* identical to _longjmp */ - lds.l @r4+, pr - mov.l @r4+, r8 - mov.l @r4+, r9 - mov.l @r4+, r10 - mov.l @r4+, r11 - mov.l @r4+, r12 - mov.l @r4+, r13 - mov.l @r4+, r14 - mov.l @r4+, r15 - - mov r5, r0 - tst r0, r0 /* make sure return value is non-zero */ - bf .L0 - add #1, r0 -.L0: - rts - nop - - .align 2 -.L_got_2: PIC_GOT_DATUM -.L_sigsetmask: CALL_DATUM(_C_LABEL(sigsetmask), 1b) - SET_ENTRY_SIZE(siglongjmp) diff --git a/lib/libc/compat/arch/sh3/sys/Makefile.inc b/lib/libc/compat/arch/sh3/sys/Makefile.inc deleted file mode 100644 index 07241b413..000000000 --- a/lib/libc/compat/arch/sh3/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:14 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/sh3/sys/compat_Ovfork.S b/lib/libc/compat/arch/sh3/sys/compat_Ovfork.S deleted file mode 100644 index 7ed4d04a8..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_Ovfork.S +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.2 2006/01/06 04:30:33 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_Ovfork.S,v 1.2 2006/01/06 04:30:33 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -/* - * pid = vfork(); - * - * r1 == 0 in parent process, r1 == 1 in child process. - * r0 == pid of child in parent, r0 == pid of parent in child. - * - */ -ENTRY(vfork) - mov #SYS_vfork, r0 - trapa #0x80 - bf err - - add #0xff, r1 /* from 1 to 0 in child, 0 to -1 in parent */ - rts - and r1, r0 /* 0 in child, child pid in parent */ - -err: - JUMP_CERROR - - SET_ENTRY_SIZE(vfork) diff --git a/lib/libc/compat/arch/sh3/sys/compat___semctl.S b/lib/libc/compat/arch/sh3/sys/compat___semctl.S deleted file mode 100644 index c64b6d3bb..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/sh3/sys/compat___sigreturn14.S b/lib/libc/compat/arch/sh3/sys/compat___sigreturn14.S deleted file mode 100644 index b151804e8..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat___sigreturn14.S +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2005/09/15 21:39:16 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat___sigreturn14.S,v 1.1 2005/09/15 21:39:16 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/sh3/sys/compat___sigtramp1.S b/lib/libc/compat/arch/sh3/sys/compat___sigtramp1.S deleted file mode 100644 index 671b5cc0d..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat___sigtramp1.S +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -/* - * The SH signal trampoline is invoked only to return from - * the signal; the kernel calls the signal handler directly. - * - * On entry, stack looks like: - * - * sp-> sigcontext structure - */ -NENTRY(__sigtramp_sigcontext_1) - mov r15, r4 /* get pointer to sigcontext */ - SYSTRAP(compat_16___sigreturn14) /* and call sigreturn() */ - mov r0, r4 /* exit with errno */ - SYSTRAP(exit) /* if sigreturn fails */ diff --git a/lib/libc/compat/arch/sh3/sys/compat_msgctl.S b/lib/libc/compat/arch/sh3/sys/compat_msgctl.S deleted file mode 100644 index a5598b0b1..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/sh3/sys/compat_quotactl.S b/lib/libc/compat/arch/sh3/sys/compat_quotactl.S deleted file mode 100644 index 94630b816..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:14 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/sh3/sys/compat_shmctl.S b/lib/libc/compat/arch/sh3/sys/compat_shmctl.S deleted file mode 100644 index a9f938c68..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/sh3/sys/compat_sigaction.S b/lib/libc/compat/arch/sh3/sys/compat_sigaction.S deleted file mode 100644 index 7d778432c..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/sh3/sys/compat_sigpending.S b/lib/libc/compat/arch/sh3/sys/compat_sigpending.S deleted file mode 100644 index 39f2e62b6..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_sigpending.S +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.2 2006/01/06 04:14:35 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigpending.s 5.1 (Berkeley) 7/1/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigpending.S,v 1.2 2006/01/06 04:14:35 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -/* - * int - * sigpending(sigset_t *set); - */ -_SYSCALL(sigpending,compat_13_sigpending13) - mov.l r0, @r4 /* store returned mask */ - rts - mov #0, r0 diff --git a/lib/libc/compat/arch/sh3/sys/compat_sigprocmask.S b/lib/libc/compat/arch/sh3/sys/compat_sigprocmask.S deleted file mode 100644 index f67a41446..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_sigprocmask.S +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.3 2006/01/06 04:08:47 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigprocmask.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigprocmask.S,v 1.3 2006/01/06 04:08:47 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -/* - * int - * sigprocmask(int how, const sigset_t * restrict set, - * sigset_t * restrict oset); - */ -ENTRY(sigprocmask) - tst r5, r5 /* set == NULL? */ - bf 1f - - bra 2f /* r5 (new mask) is already zero */ - mov #1, r4 /* how = SIG_BLOCK */ - -1: mov.l @r5, r5 /* fetch new mask */ - -2: mov #SYS_compat_13_sigprocmask13, r0 - trapa #0x80 - bf err - - tst r6, r6 /* oset == NULL? */ - bt 3f - mov.l r0, @r6 /* store old mask */ -3: rts - mov #0, r0 - -err: - JUMP_CERROR - - SET_ENTRY_SIZE(sigprocmask) diff --git a/lib/libc/compat/arch/sh3/sys/compat_sigreturn.S b/lib/libc/compat/arch/sh3/sys/compat_sigreturn.S deleted file mode 100644 index 9376a7aa1..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_sigreturn.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.1 2005/09/15 21:39:16 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigreturn.S,v 1.1 2005/09/15 21:39:16 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -/* - * We must preserve the state of the registers as the user has set them up. - */ - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -PSEUDO(sigreturn,compat_13_sigreturn13) diff --git a/lib/libc/compat/arch/sh3/sys/compat_sigsuspend.S b/lib/libc/compat/arch/sh3/sys/compat_sigsuspend.S deleted file mode 100644 index 3f6fdf225..000000000 --- a/lib/libc/compat/arch/sh3/sys/compat_sigsuspend.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.3 2006/01/06 04:05:55 uwe Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigsuspend.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigsuspend.S,v 1.3 2006/01/06 04:05:55 uwe Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -/* - * int sigsuspend(const sigset_t *sigmask); - */ -ENTRY(sigsuspend) - mov.l @r4, r4 /* syscall expects mask as the argument */ - mov #SYS_compat_13_sigsuspend13, r0 - trapa #0x80 - bf err - rts /* shouldn t happen */ - mov #0, r0 -err: - JUMP_CERROR - - SET_ENTRY_SIZE(sigsuspend) diff --git a/lib/libc/compat/arch/sparc/Makefile.inc b/lib/libc/compat/arch/sparc/Makefile.inc deleted file mode 100644 index fc44d319a..000000000 --- a/lib/libc/compat/arch/sparc/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 23:04:04 christos Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/sparc/gen/Makefile.inc b/lib/libc/compat/arch/sparc/gen/Makefile.inc deleted file mode 100644 index ec25fc1bb..000000000 --- a/lib/libc/compat/arch/sparc/gen/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/07/03 13:06:12 drochner Exp $ - -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c -#SRCS+= compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/sparc/gen/compat_setjmp.S b/lib/libc/compat/arch/sparc/gen/compat_setjmp.S deleted file mode 100644 index dc56cef13..000000000 --- a/lib/libc/compat/arch/sparc/gen/compat_setjmp.S +++ /dev/null @@ -1,116 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: setjmp.s,v 1.2 92/06/25 03:18:43 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_setjmp.S,v 1.1 2005/10/15 22:11:22 uwe Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "SYS.h" - -ENTRY(setjmp) - /* - * We use the caller's `arg dump' area (%sp+0x44; there are 6 ints - * reserved there for us) to avoid having to allocate stack space - * here. - */ - mov %o0, %o2 /* build sigcontext in [%o2] */ - mov 1, %o0 /* SIG_BLOCK */ - mov SYS_compat_13_sigprocmask13, %g1 - clr %o1 /* sigprocmask(SIG_BLOCK, (sigset_t *)NULL) */ - t ST_SYSCALL - st %o0, [%o2 + 4] /* sc.sc_mask = current mask; */ - mov SYS___sigaltstack14, %g1 - clr %o0 /* sigaltstack(NULL, &foo) */ - add %sp, 0x48, %o1 /* (foo being in arg dump area) */ - t ST_SYSCALL - ld [%sp + 0x50], %o0 /* foo.ss_flags */ - and %o0, 1, %o1 /* onstack = foo.ss_flags & 1; */ - st %o0, [%o2 + 0] /* sc.sc_onstack = current onstack; */ - st %sp, [%o2 + 8] /* sc.sc_sp = sp (both ours and caller's) */ - add %o7, 8, %o0 - st %o0, [%o2 + 12] /* sc.sc_pc = return_pc */ - add %o7, 12, %o0 - st %o0, [%o2 + 16] /* sc.sc_npc = return_pc + 4 */ - st %g0, [%o2 + 20] /* sc.sc_psr = (clean psr) */ - st %fp, [%o2 + 24] /* sc.sc_g1 = %fp (misuse, but what the heck) */ - /* sc.sc_o0 = random(), set in longjmp */ - retl /* return 0 */ - clr %o0 - -/* - * All we need to do here is force sigreturn to load a new stack pointer, - * new , and appropriate %o0 return value from the sigcontext built - * in setjmp. The %i and %l registers will be reloaded from the place to - * which %sp points, due to sigreturn() semantics (sigreturn does not modify - * the window pointer in the psr, hence it must force all windows to reload). - */ -ENTRY(longjmp) - save %sp, -96, %sp - ld [%i0 + 8], %o2 /* make sure sc->sc_sp, sc->sc_fp nonzero */ - ld [%i0 + 24], %o3 - orcc %o2, %o3, %g0 - bz Lbotch - tst %i1 /* if (v == 0) v = 1; */ - bz,a 1f - mov 1, %i1 -1: - st %i1, [%i0 + 28] /* sc.sc_o0 = v; */ - mov SYS_compat_13_sigreturn13, %g1 - mov %i0, %o0 - t ST_SYSCALL /* sigreturn(scp); */ - -Lbotch: - /* oops, caller botched it */ - call _C_LABEL(longjmperror) - nop - unimp 0 diff --git a/lib/libc/compat/arch/sparc/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/sparc/gen/compat_sigsetjmp.S deleted file mode 100644 index f6b327aee..000000000 --- a/lib/libc/compat/arch/sparc/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.3 2013/09/12 15:36:16 joerg Exp $ */ -/* - * Copyright (c) 1995 Paul Kranenburg - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "SYS.h" - -#ifdef __PIC__ - -ENTRY(sigsetjmp) - PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE - tst %o1 - bnz 1f - st %o1, [%o0 + 56] ! jmpbuf[JBLEN] = savemask - - !! if (savemask == 0) goto _setjmp - set _C_LABEL(_setjmp), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - - !! if (savemask != 0) goto setjmp -1: set _C_LABEL(setjmp), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - - -ENTRY(siglongjmp) - PIC_PROLOGUE(%g1, %g2) ! %g1 = _GLOBAL_OFFSET_TABLE - ld [%o0 + 56], %g2 ! restoremask = jmpbuf[JBLEN] - tst %g2 - bnz 1f - nop - - !! if (restoremask == 0) goto _longjmp - set _C_LABEL(_longjmp), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - - !! if (restoremask != 0) goto longjmp -1: set _C_LABEL(longjmp), %g2 - ld [%g1 + %g2], %g1 - jmp %g1 - nop - -#else /* !__PIC__ */ - -ENTRY(sigsetjmp) - cmp %o1,0 - be _C_LABEL(_setjmp) - st %o1,[%o0+40] ! jmpbuf[JBLEN] - nop - ba,a _C_LABEL(setjmp) - unimp 0 - -ENTRY(siglongjmp) - ld [%o0+40],%g1 - cmp %g1,0 - be _C_LABEL(_longjmp) - nop - ba,a _C_LABEL(longjmp) - unimp 0 - -#endif /* !__PIC__ */ diff --git a/lib/libc/compat/arch/sparc/sys/Makefile.inc b/lib/libc/compat/arch/sparc/sys/Makefile.inc deleted file mode 100644 index 191a9903a..000000000 --- a/lib/libc/compat/arch/sparc/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:15 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/sparc/sys/compat_Ovfork.S b/lib/libc/compat/arch/sparc/sys/compat_Ovfork.S deleted file mode 100644 index e56f145d4..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_Ovfork.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: Ovfork.s,v 1.1 91/07/06 13:05:56 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_Ovfork.S,v 1.1 2005/10/15 22:11:22 uwe Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * pid = vfork(); - * - * %o1 == 0 in parent process, 1 in child process. - * %o0 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -SYSCALL(vfork) - dec %o1 ! from 1 to 0 in child, 0 to -1 in parent - retl - and %o0, %o1, %o0 ! return 0 in child, pid in parent diff --git a/lib/libc/compat/arch/sparc/sys/compat___semctl.S b/lib/libc/compat/arch/sparc/sys/compat___semctl.S deleted file mode 100644 index c64b6d3bb..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/sparc/sys/compat___sigreturn14.S b/lib/libc/compat/arch/sparc/sys/compat___sigreturn14.S deleted file mode 100644 index d6620e763..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat___sigreturn14.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sigreturn.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat___sigreturn14.S,v 1.1 2005/10/15 22:11:22 uwe Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(__sigreturn14) - mov SYS_compat_16___sigreturn14, %g1 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/compat/arch/sparc/sys/compat___sigtramp1.S b/lib/libc/compat/arch/sparc/sys/compat___sigtramp1.S deleted file mode 100644 index 12385b159..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat___sigtramp1.S +++ /dev/null @@ -1,170 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ - -/* - * Copyright (c) 1996 Paul Kranenburg - * Copyright (c) 1996 - * The President and Fellows of Harvard College. All rights reserved. - * 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. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * This product includes software developed by Harvard University. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Harvard University. - * This product includes software developed by Paul Kranenburg. - * 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. - */ - -#include "SYS.h" - -#define _LOCORE -#include -#include -#include - -/* - * When this code is run, the stack looks like: - * [%sp] 64 bytes to which registers can be dumped - * [%sp + 64] signal number (goes in %o0) - * [%sp + 64 + 4] signal code (goes in %o1) - * [%sp + 64 + 8] placeholder - * [%sp + 64 + 12] argument for %o3, currently unsupported (always 0) - * [%sp + 64 + 16] first word of saved state (sigcontext) - * . - * . - * . - * [%sp + NNN] last word of saved state - * (followed by previous stack contents or top of signal stack). - * The address of the function to call is in %g1; the old %g1 and %o0 - * have already been saved in the sigcontext. We are running in a clean - * window, all previous windows now being saved to the stack. - * - * Note that [%sp + 64 + 8] == %sp + 64 + 16. The copy at %sp+64+8 - * will eventually be removed, with a hole left in its place, if things - * work out. - */ -#define SAVE_STATE \ - /* \ - * XXX the `save' and `restore' below are unnecessary: should \ - * replace with simple arithmetic on %sp \ - * \ - * Make room on the stack for 32 %f registers + %fsr. This comes \ - * out to 33*4 or 132 bytes, but this must be aligned to a multiple \ - * of 8, or 136 bytes. \ - */ \ - save %sp, -CCFSZ - 136, %sp; \ - mov %g2, %l2; /* save globals in %l registers */ \ - mov %g3, %l3; \ - mov %g4, %l4; \ - mov %g5, %l5; \ - mov %g6, %l6; \ - mov %g7, %l7; \ - /* \ - * Saving the fpu registers is expensive, so do it iff the fsr \ - * stored in the sigcontext shows that the fpu is enabled. \ - */ \ - ld [%fp + 64 + 16 + SC_PSR_OFFSET], %l0; \ - sethi %hi(PSR_EF), %l1; /* FPU enable is too high for andcc */ \ - andcc %l0, %l1, %l0; /* %l0 = fpu enable bit */ \ - be 1f; /* if not set, skip the saves */ \ - rd %y, %l1; /* in any case, save %y */ \ - /* fpu is enabled, oh well */ \ - st %fsr, [%sp + CCFSZ + 0]; \ - std %f0, [%sp + CCFSZ + 8]; \ - std %f2, [%sp + CCFSZ + 16]; \ - std %f4, [%sp + CCFSZ + 24]; \ - std %f6, [%sp + CCFSZ + 32]; \ - std %f8, [%sp + CCFSZ + 40]; \ - std %f10, [%sp + CCFSZ + 48]; \ - std %f12, [%sp + CCFSZ + 56]; \ - std %f14, [%sp + CCFSZ + 64]; \ - std %f16, [%sp + CCFSZ + 72]; \ - std %f18, [%sp + CCFSZ + 80]; \ - std %f20, [%sp + CCFSZ + 88]; \ - std %f22, [%sp + CCFSZ + 96]; \ - std %f24, [%sp + CCFSZ + 104]; \ - std %f26, [%sp + CCFSZ + 112]; \ - std %f28, [%sp + CCFSZ + 120]; \ - std %f30, [%sp + CCFSZ + 128]; \ -1: - -#define RESTORE_STATE \ - /* \ - * Now that the handler has returned, re-establish all the state \ - * we just saved above, then do a sigreturn. \ - */ \ - tst %l0; /* reload fpu registers? */ \ - be 1f; /* if not, skip the loads */ \ - wr %l1, %g0, %y; /* in any case, restore %y */ \ - ld [%sp + CCFSZ + 0], %fsr; \ - ldd [%sp + CCFSZ + 8], %f0; \ - ldd [%sp + CCFSZ + 16], %f2; \ - ldd [%sp + CCFSZ + 24], %f4; \ - ldd [%sp + CCFSZ + 32], %f6; \ - ldd [%sp + CCFSZ + 40], %f8; \ - ldd [%sp + CCFSZ + 48], %f10; \ - ldd [%sp + CCFSZ + 56], %f12; \ - ldd [%sp + CCFSZ + 64], %f14; \ - ldd [%sp + CCFSZ + 72], %f16; \ - ldd [%sp + CCFSZ + 80], %f18; \ - ldd [%sp + CCFSZ + 88], %f20; \ - ldd [%sp + CCFSZ + 96], %f22; \ - ldd [%sp + CCFSZ + 104], %f24; \ - ldd [%sp + CCFSZ + 112], %f26; \ - ldd [%sp + CCFSZ + 120], %f28; \ - ldd [%sp + CCFSZ + 128], %f30; \ -1: \ - mov %l2, %g2; \ - mov %l3, %g3; \ - mov %l4, %g4; \ - mov %l5, %g5; \ - mov %l6, %g6; \ - mov %l7, %g7 - -ENTRY_NOPROFILE(__sigtramp_sigcontext_1) - SAVE_STATE - - ldd [%fp + 64], %o0 /* sig, code */ - ld [%fp + 76], %o3 /* arg3 */ - call %g1 /* call handler */ - add %fp, 64 + 16, %o2 /* pointer to sigcontext */ - - RESTORE_STATE - - /* Get registers back and set syscall # */ - restore %g0, SYS_compat_16___sigreturn14, %g1 - add %sp, 64 + 16, %o0 /* compute scp */ - t ST_SYSCALL /* call sigreturn */ - mov SYS_exit, %g1 /* exit with errno */ - t ST_SYSCALL /* if sigreturn fails */ diff --git a/lib/libc/compat/arch/sparc/sys/compat_msgctl.S b/lib/libc/compat/arch/sparc/sys/compat_msgctl.S deleted file mode 100644 index a5598b0b1..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/sparc/sys/compat_quotactl.S b/lib/libc/compat/arch/sparc/sys/compat_quotactl.S deleted file mode 100644 index efb80312a..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:15 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/sparc/sys/compat_shmctl.S b/lib/libc/compat/arch/sparc/sys/compat_shmctl.S deleted file mode 100644 index a9f938c68..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/sparc/sys/compat_sigaction.S b/lib/libc/compat/arch/sparc/sys/compat_sigaction.S deleted file mode 100644 index 7d778432c..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/sparc/sys/compat_sigpending.S b/lib/libc/compat/arch/sparc/sys/compat_sigpending.S deleted file mode 100644 index c5891599c..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_sigpending.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ -/* - * 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. - * 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. - * - * from: Header: sigpending.s,v 1.1 91/07/06 13:06:00 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigpending.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigpending.S,v 1.1 2005/10/15 22:11:22 uwe Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -ENTRY(sigpending) - mov %o0, %o2 ! save pointer - mov SYS_compat_13_sigpending13, %g1 - t ST_SYSCALL ! sigpending() - bcc,a 1f ! if success, - st %o0, [%o2] ! store return value - ERROR() -1: - retl ! and return 0 - clr %o0 diff --git a/lib/libc/compat/arch/sparc/sys/compat_sigprocmask.S b/lib/libc/compat/arch/sparc/sys/compat_sigprocmask.S deleted file mode 100644 index d38d7874f..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_sigprocmask.S +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sigprocmask.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigprocmask.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigprocmask.S,v 1.1 2005/10/15 22:11:22 uwe Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -/* - * sigprocmask(int how, sigset_t *set, sigset_t *oset) - */ -ENTRY(sigprocmask) - tst %o1 ! set == NULL? - bne,a 1f ! if not, - ld [%o1], %o1 ! replace it in %o1 with *set -! clr %o1 ! else block no signals ... - mov 1, %o0 ! ... using sigprocmask(SIG_BLOCK) -1: - mov SYS_compat_13_sigprocmask13, %g1 - t ST_SYSCALL - bcc 2f ! if success, - tst %o2 ! check to see if oset requested - ERROR() -2: - bne,a 3f ! if oset != NULL, - st %o0, [%o2] ! *oset = oldmask -3: - retl ! in any case, return 0 - clr %o0 diff --git a/lib/libc/compat/arch/sparc/sys/compat_sigreturn.S b/lib/libc/compat/arch/sparc/sys/compat_sigreturn.S deleted file mode 100644 index 041392b0b..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_sigreturn.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sigreturn.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigreturn.S,v 1.1 2005/10/15 22:11:22 uwe Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -ENTRY(sigreturn) - mov SYS_compat_13_sigreturn13, %g1 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/compat/arch/sparc/sys/compat_sigsuspend.S b/lib/libc/compat/arch/sparc/sys/compat_sigsuspend.S deleted file mode 100644 index a50ff7126..000000000 --- a/lib/libc/compat/arch/sparc/sys/compat_sigsuspend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.1 2005/10/15 22:11:22 uwe Exp $ */ -/* - * 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. - * 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. - * - * from: Header: sigsuspend.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigsuspend.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigsuspend.S,v 1.1 2005/10/15 22:11:22 uwe Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend) - ld [%o0], %o0 ! indirect to mask argument - mov SYS_compat_13_sigsuspend13, %g1 - t ST_SYSCALL - ERROR() ! always terminates with EINTR diff --git a/lib/libc/compat/arch/sparc64/Makefile.inc b/lib/libc/compat/arch/sparc64/Makefile.inc deleted file mode 100644 index fc44d319a..000000000 --- a/lib/libc/compat/arch/sparc64/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 23:04:04 christos Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/sparc64/gen/Makefile.inc b/lib/libc/compat/arch/sparc64/gen/Makefile.inc deleted file mode 100644 index ec25fc1bb..000000000 --- a/lib/libc/compat/arch/sparc64/gen/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/07/03 13:06:12 drochner Exp $ - -SRCS+= compat_setjmp.S compat_sigsetjmp.S - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c -#SRCS+= compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/sparc64/gen/compat_setjmp.S b/lib/libc/compat/arch/sparc64/gen/compat_setjmp.S deleted file mode 100644 index 628a5e08f..000000000 --- a/lib/libc/compat/arch/sparc64/gen/compat_setjmp.S +++ /dev/null @@ -1,119 +0,0 @@ -/* $NetBSD: compat_setjmp.S,v 1.1 2005/10/16 04:41:34 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: setjmp.s,v 1.2 92/06/25 03:18:43 torek Exp - */ - -#define _LOCORE -#include -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)setjmp.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_setjmp.S,v 1.1 2005/10/16 04:41:34 christos Exp $") -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * C library -- setjmp, longjmp - * - * longjmp(a,v) - * will generate a "return(v)" from - * the last call to - * setjmp(a) - * by restoring registers from the stack, - * and a struct sigcontext, see - */ - -#include "SYS.h" - -#define STACK_T_SZ -ENTRY(setjmp) - /* - * We use the part of the sigcontext structure, the sp, pc, and npc fields, - * for the sigstack call so we don't need to get our own stackframe. It - * won't be filled out till later anyway. - */ - mov %o0, %o3 /* Save our jmp_buf in %o3 */ - mov %o0, %o2 /* build sigcontext in [%o2] */ - mov 1, %o0 /* SIG_BLOCK */ - mov SYS_compat_13_sigprocmask13, %g1 - clr %o1 /* sigprocmask(SIG_BLOCK, (sigset_t *)NULL, (sigset_t *)a) */ - t ST_SYSCALL - - st %o0, [%o3 + 0x04] /* sc.sc_mask = current mask; */ - mov SYS___sigaltstack14, %g1 - clr %o0 /* sigstack(NULL, &foo) */ - add %o3, 0x38, %o1 /* (foo being the sigcontext14 sc_mask) */ - t ST_SYSCALL - - lduw [%o3 + 0x38+0x10], %o0 /* foo.ss_flags */ - and %o0, 1, %o1 /* onstack = foo.ss_flags & 1; */ - st %o0, [%o3 + 0x00] /* sc.sc_onstack = current onstack; */ - stx %sp, [%o3 + 0x08] /* sc.sc_sp = sp (both ours and caller's) */ - add %o7, 8, %o0 - stx %o0, [%o3 + 0x10] /* sc.sc_pc = return_pc */ - add %o7, 12, %o0 - stx %o0, [%o3 + 0x18] /* sc.sc_npc = return_pc + 4 */ - stx %g0, [%o3 + 0x20] /* sc.sc_psr = (clean psr) */ - stx %fp, [%o3 + 0x28] /* sc.sc_g1 = %fp (misuse, but what the heck) */ - /* sc.sc_o0 = random(), set in longjmp */ - retl /* return 0 */ - clr %o0 - -/* - * All we need to do here is force sigreturn to load a new stack pointer, - * new , and appropriate %o0 return value from the sigcontext built - * in setjmp. The %i and %l registers will be reloaded from the place to - * which %sp points, due to sigreturn() semantics (sigreturn does not modify - * the window pointer in the psr, hence it must force all windows to reload). - */ -ENTRY(longjmp) - save %sp, -CC64FSZ, %sp - ldx [%i0 + 0x08], %o2 /* make sure sc->sc_sp, sc->sc_fp nonzero */ - ldx [%i0 + 0x28], %o3 - orcc %o2, %o3, %g0 - bz,pn %xcc, Lbotch - movrz %i1, 1, %i1 /* if (v == 0) v = 1; */ - st %i1, [%i0 + 0x30] /* sc.sc_o0 = v; */ - mov SYS_compat_13_sigreturn13, %g1 - mov %i0, %o0 - t ST_SYSCALL /* sigreturn(scp); */ - -Lbotch: - /* oops, caller botched it */ - call _C_LABEL(longjmperror) - nop - unimp 0 diff --git a/lib/libc/compat/arch/sparc64/gen/compat_sigsetjmp.S b/lib/libc/compat/arch/sparc64/gen/compat_sigsetjmp.S deleted file mode 100644 index 2dde308f5..000000000 --- a/lib/libc/compat/arch/sparc64/gen/compat_sigsetjmp.S +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: compat_sigsetjmp.S,v 1.2 2013/09/12 15:36:16 joerg Exp $ */ -/* - * Copyright (c) 1995 Paul Kranenburg - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Paul Kranenburg. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "SYS.h" - -#if __PIC__ - 0 >= 2 - -ENTRY(sigsetjmp) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - set _C_LABEL(setjmp), %o2 ! if (%o1 != 0) goto _setjmp; - set _C_LABEL(_setjmp), %o3 ! else goto __setjmp; - movrnz %o1, %o2, %o3 - ldx [%g1+%o3], %g1 - jmp %g1 - st %o1,[%o0+0x48] ! jmpbuf[JBLEN] - - -ENTRY(siglongjmp) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - ld [%o0 + 0x48],%o2 ! jmpbuf[JBLEN] - set _C_LABEL(longjmp), %o3 ! if (%o2 != 0) goto _longjmp; - set _C_LABEL(_longjmp), %o4 ! else goto __longjmp; - movrnz %o2, %o3, %o4 - ldx [%g1 + %o4], %g1 - jmp %g1 - nop - unimp 0 - -#elif __PIC__ - 0 >= 1 - -ENTRY(sigsetjmp) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - cmp %o1, 0 - bne,a 1f - ldx [%g1 + _C_LABEL(setjmp)], %g1 ! if (%o1 != 0) goto _setjmp; - ldx [%g1 + _C_LABEL(_setjmp)], %g1 ! else goto __setjmp; -1: - jmp %g1 - st %o1,[%o0+0x48] ! jmpbuf[JBLEN] - - -ENTRY(siglongjmp) - PIC_PROLOGUE(%g1,%o2) ! %g1 = _GLOBAL_OFFSET_TABLE - cmp %o2, 0 - ld [%o0 + 0x48],%o2 ! jmpbuf[JBLEN] - bne,a 1f - ldx [%g1 + _C_LABEL(longjmp)], %g1 ! if (%o2 != 0) goto _longjmp; - ldx [%g1 + _C_LABEL(_longjmp)], %g1 ! else goto __longjmp; -1: - jmp %g1 - nop - unimp 0 - -#else /* !__PIC__ */ - -ENTRY(sigsetjmp) - brz,pt %o1,_C_LABEL(_setjmp) - st %o1,[%o0+0x48] ! jmpbuf[JBLEN] - ba,a,pt %icc,_C_LABEL(setjmp) - nop ! spitfire bug - unimp 0 - -ENTRY(siglongjmp) - ld [%o0 + 0x48], %g1 - brz,pt %g1, _C_LABEL(_longjmp) - nop - ba,a,pt %icc, _C_LABEL(longjmp) - unimp 0 - -#endif /* !__PIC__ */ diff --git a/lib/libc/compat/arch/sparc64/sys/Makefile.inc b/lib/libc/compat/arch/sparc64/sys/Makefile.inc deleted file mode 100644 index 191a9903a..000000000 --- a/lib/libc/compat/arch/sparc64/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:15 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat___sigtramp1.S compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/sparc64/sys/compat_Ovfork.S b/lib/libc/compat/arch/sparc64/sys/compat_Ovfork.S deleted file mode 100644 index e11a6aa4e..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_Ovfork.S +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.1 2005/10/16 04:41:34 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: Ovfork.s,v 1.1 91/07/06 13:05:56 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_Ovfork.S,v 1.1 2005/10/16 04:41:34 christos Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * pid = vfork(); - * - * %o1 == 0 in parent process, 1 in child process. - * %o0 == pid of child in parent, pid of parent in child. - */ - -#include "SYS.h" - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -SYSCALL(vfork) - dec %o1 /* from 1 to 0 in child, 0 to -1 in parent */ - retl - and %o0, %o1, %o0 /* return 0 in child, pid in parent */ diff --git a/lib/libc/compat/arch/sparc64/sys/compat___semctl.S b/lib/libc/compat/arch/sparc64/sys/compat___semctl.S deleted file mode 100644 index c64b6d3bb..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/sparc64/sys/compat___sigreturn14.S b/lib/libc/compat/arch/sparc64/sys/compat___sigreturn14.S deleted file mode 100644 index b65b83946..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat___sigreturn14.S +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2005/10/16 04:41:34 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sigreturn.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat___sigreturn14.S,v 1.1 2005/10/16 04:41:34 christos Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -ENTRY(__sigreturn14) - mov SYS_compat_16___sigreturn14, %g1 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/compat/arch/sparc64/sys/compat___sigtramp1.S b/lib/libc/compat/arch/sparc64/sys/compat___sigtramp1.S deleted file mode 100644 index 3fbf49aa1..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat___sigtramp1.S +++ /dev/null @@ -1,172 +0,0 @@ -/* $NetBSD: compat___sigtramp1.S,v 1.2 2011/07/12 07:51:33 mrg Exp $ */ - -/* - * Copyright (c) 1996-2002 Eduardo Horvath - * Copyright (c) 1996 Paul Kranenburg - * Copyright (c) 1996 - * The President and Fellows of Harvard College. All rights reserved. - * 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. - * - * All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Lawrence Berkeley Laboratory. - * This product includes software developed by Harvard University. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Harvard University. - * This product includes software developed by Paul Kranenburg. - * 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. - */ - -#include "SYS.h" - -#define _LOCORE -#include -#include -#include -#include - - .register %g2,#ignore - .register %g3,#ignore - -#define BLOCK_SIZE SPARC64_BLOCK_SIZE -#define BLOCK_ALIGN SPARC64_BLOCK_ALIGN - -/* - * When this code is run, the stack looks like: - * [%sp] 128 bytes to which registers can be dumped - * [%sp + 128] signal number (goes in %o0) - * [%sp + 128 + 4] signal code (goes in %o1) - * [%sp + 128 + 8] first word of saved state (sigcontext) - * . - * . - * . - * [%sp + NNN] last word of saved state - * (followed by previous stack contents or top of signal stack). - * The address of the function to call is in %g1; the old %g1 and %o0 - * have already been saved in the sigcontext. We are running in a clean - * window, all previous windows now being saved to the stack. - * - * Note that [%sp + 128 + 8] == %sp + 128 + 16. The copy at %sp+128+8 - * will eventually be removed, with a hole left in its place, if things - * work out. - */ -ENTRY_NOPROFILE(__sigtramp_sigcontext_1) - /* - * XXX the `save' and `restore' below are unnecessary: should - * replace with simple arithmetic on %sp - * - * Make room on the stack for 64 %f registers + %fsr. This comes - * out to 64*4+8 or 264 bytes, but this must be aligned to a multiple - * of 64, or 320 bytes. - */ - save %sp, -CC64FSZ - 320, %sp - mov %g2, %l2 /* save globals in %l registers */ - mov %g3, %l3 - mov %g4, %l4 - mov %g5, %l5 - mov %g6, %l6 - mov %g7, %l7 - /* - * Saving the fpu registers is expensive, so do it iff it is - * enabled and dirty. - */ - rd %fprs, %l0 - btst FPRS_DL|FPRS_DU, %l0 /* All clean? */ - bz,pt %icc, 2f - btst FPRS_DL, %l0 /* test dl */ - bz,pt %icc, 1f - btst FPRS_DU, %l0 /* test du */ - - /* fpu is enabled, oh well */ - stx %fsr, [%sp + CC64FSZ + BIAS + 0] - add %sp, BIAS+CC64FSZ+BLOCK_SIZE, %l0 /* Generate a pointer so */ - andn %l0, BLOCK_ALIGN, %l0 /* we can do a block store */ - stda %f0, [%l0] ASI_BLK_P - inc BLOCK_SIZE, %l0 - stda %f16, [%l0] ASI_BLK_P -1: - bz,pt %icc, 2f - add %sp, BIAS+CC64FSZ+BLOCK_SIZE, %l0 /* Generate a pointer so */ - andn %l0, BLOCK_ALIGN, %l0 /* we can do a block store */ - add %l0, 2*BLOCK_SIZE, %l0 /* and skip what we already stored */ - stda %f32, [%l0] ASI_BLK_P - inc BLOCK_SIZE, %l0 - stda %f48, [%l0] ASI_BLK_P -2: - membar #Sync - rd %y, %l1 /* in any case, save %y */ - lduw [%fp + BIAS + 128], %o0 /* sig */ - lduw [%fp + BIAS + 128 + 4], %o1 /* code */ - call %g1 /* call handler */ - add %fp, BIAS + 128 + 8, %o2 /* scp */ - - /* - * Now that the handler has returned, re-establish all the state - * we just saved above, then do a sigreturn. - */ - btst 3, %l0 /* All clean? */ - bz,pt %icc, 2f - btst 1, %l0 /* test dl */ - bz,pt %icc, 1f - btst 2, %l0 /* test du */ - - ldx [%sp + CC64FSZ + BIAS + 0], %fsr - add %sp, BIAS+CC64FSZ+BLOCK_SIZE, %l0 /* Generate a pointer so */ - andn %l0, BLOCK_ALIGN, %l0 /* we can do a block load */ - ldda [%l0] ASI_BLK_P, %f0 - inc BLOCK_SIZE, %l0 - ldda [%l0] ASI_BLK_P, %f16 -1: - bz,pt %icc, 2f - wr %l1, %g0, %y /* in any case, restore %y */ - add %sp, BIAS+CC64FSZ+BLOCK_SIZE, %l0 /* Generate a pointer so */ - andn %l0, BLOCK_ALIGN, %l0 /* we can do a block load */ - inc 2*BLOCK_SIZE, %l0 /* and skip what we already loaded */ - ldda [%l0] ASI_BLK_P, %f32 - inc BLOCK_SIZE, %l0 - ldda [%l0] ASI_BLK_P, %f48 -2: - mov %l2, %g2 - mov %l3, %g3 - mov %l4, %g4 - mov %l5, %g5 - mov %l6, %g6 - mov %l7, %g7 - membar #Sync - - /* get registers back and set syscall # */ - restore %g0, SYS_compat_16___sigreturn14, %g1 - add %sp, BIAS + 128 + 8, %o0 /* compute scp */ - t ST_SYSCALL /* call sigreturn */ - mov SYS_exit, %g1 /* exit with errno */ - t ST_SYSCALL /* if sigreturn fails */ diff --git a/lib/libc/compat/arch/sparc64/sys/compat_msgctl.S b/lib/libc/compat/arch/sparc64/sys/compat_msgctl.S deleted file mode 100644 index a5598b0b1..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/sparc64/sys/compat_quotactl.S b/lib/libc/compat/arch/sparc64/sys/compat_quotactl.S deleted file mode 100644 index efb80312a..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:15 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/sparc64/sys/compat_shmctl.S b/lib/libc/compat/arch/sparc64/sys/compat_shmctl.S deleted file mode 100644 index a9f938c68..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/sparc64/sys/compat_sigaction.S b/lib/libc/compat/arch/sparc64/sys/compat_sigaction.S deleted file mode 100644 index 7d778432c..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/sparc64/sys/compat_sigpending.S b/lib/libc/compat/arch/sparc64/sys/compat_sigpending.S deleted file mode 100644 index 21d62906a..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_sigpending.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.1 2005/10/16 04:41:34 christos Exp $ */ -/* - * 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. - * 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. - * - * from: Header: sigpending.s,v 1.1 91/07/06 13:06:00 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigpending.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigpending.S,v 1.1 2005/10/16 04:41:34 christos Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -ENTRY(sigpending) - mov %o0, %o2 /* save pointer */ - mov SYS_compat_13_sigpending13, %g1 - t ST_SYSCALL /* sigpending() */ - bcc,a 1f /* if success, */ - st %o0, [%o2] /* store return value */ - ERROR() -1: - retl /* and return 0 */ - clr %o0 diff --git a/lib/libc/compat/arch/sparc64/sys/compat_sigprocmask.S b/lib/libc/compat/arch/sparc64/sys/compat_sigprocmask.S deleted file mode 100644 index bbdd339bb..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_sigprocmask.S +++ /dev/null @@ -1,73 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.1 2005/10/16 04:41:34 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sigprocmask.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigprocmask.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigprocmask.S,v 1.1 2005/10/16 04:41:34 christos Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -/* - * sigprocmask(int how, sigset_t *set, sigset_t *oset) - */ -ENTRY(sigprocmask) - brnz,a %o1, 1f /* if (set != NULL) */ - ld [%o1], %o1 /* replace it in %o1 with *set */ -#if 0 - clr %o1 /* else block no signals ... */ -#endif - mov 1, %o0 /* ... using sigprocmask(SIG_BLOCK) */ -1: - mov SYS_compat_13_sigprocmask13, %g1 - t ST_SYSCALL - bcc 2f /* if success, */ - tst %o2 /* check to see if oset requested */ - ERROR() -2: - bne,a 3f /* if oset != NULL, */ - st %o0, [%o2] /* *oset = oldmask */ -3: - retl /* in any case, return 0 */ - clr %o0 diff --git a/lib/libc/compat/arch/sparc64/sys/compat_sigreturn.S b/lib/libc/compat/arch/sparc64/sys/compat_sigreturn.S deleted file mode 100644 index 2bb980e24..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_sigreturn.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.1 2005/10/16 04:41:34 christos Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: sigreturn.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigreturn.S,v 1.1 2005/10/16 04:41:34 christos Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -ENTRY(sigreturn) - mov SYS_compat_13_sigreturn13, %g1 - t ST_SYSCALL - ERROR() diff --git a/lib/libc/compat/arch/sparc64/sys/compat_sigsuspend.S b/lib/libc/compat/arch/sparc64/sys/compat_sigsuspend.S deleted file mode 100644 index 0fefb342d..000000000 --- a/lib/libc/compat/arch/sparc64/sys/compat_sigsuspend.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.1 2005/10/16 04:41:34 christos Exp $ */ -/* - * 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. - * 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. - * - * from: Header: sigsuspend.s,v 1.1 91/07/06 13:06:01 torek Exp - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) -#if 0 - .asciz "@(#)sigsuspend.s 8.1 (Berkeley) 6/4/93" -#else - RCSID("$NetBSD: compat_sigsuspend.S,v 1.1 2005/10/16 04:41:34 christos Exp $") -#endif -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend) - ld [%o0], %o0 /* indirect to mask argument */ - mov SYS_compat_13_sigsuspend13, %g1 - t ST_SYSCALL - ERROR() /* always terminates with EINTR */ diff --git a/lib/libc/compat/arch/vax/Makefile.inc b/lib/libc/compat/arch/vax/Makefile.inc deleted file mode 100644 index 04c44bf66..000000000 --- a/lib/libc/compat/arch/vax/Makefile.inc +++ /dev/null @@ -1,3 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2010/07/06 05:59:52 mrg Exp $ - -.include "${COMPATARCHDIR}/sys/Makefile.inc" diff --git a/lib/libc/compat/arch/vax/sys/Makefile.inc b/lib/libc/compat/arch/vax/sys/Makefile.inc deleted file mode 100644 index 0ef016907..000000000 --- a/lib/libc/compat/arch/vax/sys/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:15 bouyer Exp $ - -SRCS+= compat_Ovfork.S \ - compat___sigreturn14.S compat___sigtramp2.S \ - compat_msgctl.S compat___semctl.S compat_shmctl.S \ - compat_sigaction13.S compat_sigpending13.S compat_sigprocmask13.S \ - compat_sigreturn13.S compat_sigsuspend13.S compat_quotactl.S diff --git a/lib/libc/compat/arch/vax/sys/compat_Ovfork.S b/lib/libc/compat/arch/vax/sys/compat_Ovfork.S deleted file mode 100644 index b425c5f5b..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_Ovfork.S +++ /dev/null @@ -1,80 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)Ovfork.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: compat_Ovfork.S,v 1.2 2011/01/25 02:38:16 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * @(#)vfork.s 4.1 (Berkeley) 12/21/80 - * C library -- vfork - */ - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -/* - * pid = vfork(); - * - * %r1 == 0 in parent process, %r1 == 1 in child process. - * %r0 == pid of child in parent, %r0 == pid of parent in child. - * - * trickery here, due to keith sklower, uses ret to clear the stack, - * and then returns with a jump indirect, since only one person can return - * with a ret off this stack... we do the ret before we vfork! - */ - -ENTRY(vfork, 0) - movl 16(%fp),%r2 # save return address before we smash it - movab here,16(%fp) - ret -here: - chmk $ SYS_vfork - bcs err # if failed, set errno and return -1 - /* this next trick is Chris Torek's fault */ - mnegl %r1,%r1 # %r1 = 0xffffffff if child, 0 if parent - bicl2 %r1,%r0 # %r0 &= ~%r1, i.e., 0 if child, else unchanged - jmp (%r2) - -err: -#ifdef _REENTRANT - pushr $0x5 - calls $0,_C_LABEL(__errno) - movl (%sp)+,(%r0) - mnegl $1,%r0 - rsb -#else - movl %r0,_C_LABEL(errno) - mnegl $1,%r0 - jmp (%r2) -#endif -END(vfork) diff --git a/lib/libc/compat/arch/vax/sys/compat___semctl.S b/lib/libc/compat/arch/vax/sys/compat___semctl.S deleted file mode 100644 index c64b6d3bb..000000000 --- a/lib/libc/compat/arch/vax/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/vax/sys/compat___sigreturn14.S b/lib/libc/compat/arch/vax/sys/compat___sigreturn14.S deleted file mode 100644 index 006aa6e7e..000000000 --- a/lib/libc/compat/arch/vax/sys/compat___sigreturn14.S +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: compat___sigreturn14.S,v 1.2 2011/01/25 02:38:16 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef GPROF -#undef ENTRY -#define ENTRY(x, y) _ENTRY(x, y); pushr $0x3f; _PROF_PROLOGUE; popr $0x3f -#endif /* GPROF */ - -PSEUDO(__sigreturn14,compat_16___sigreturn14) diff --git a/lib/libc/compat/arch/vax/sys/compat___sigtramp2.S b/lib/libc/compat/arch/vax/sys/compat___sigtramp2.S deleted file mode 100644 index 72693ac37..000000000 --- a/lib/libc/compat/arch/vax/sys/compat___sigtramp2.S +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: compat___sigtramp2.S,v 1.3 2011/01/29 22:58:47 matt Exp $ */ - -/* - * Copyright (c) 2002 Anders Magnusson, (ragge@NetBSD.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. - * 3. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * 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. - */ - -/* - * Signal trampoline; registers when called: - * sp, pc, psl - obvious - * ap - points to argument list, see machdep.c:sendsig() - * fp - address of signal handler - */ - -#include "SYS.h" - -#ifdef SYSLIBC_SCCS -RCSID("$NetBSD: compat___sigtramp2.S,v 1.3 2011/01/29 22:58:47 matt Exp $") -#endif - - .text - _ALIGN_TEXT - - .globl _C_LABEL(__sigtramp_sigcontext_2) -_C_LABEL(__sigtramp_sigcontext_2): - nop; nop; - pushr $(R0|R1|R2|R3|R4|R5) # save scratch registers - callg (%ap),(%fp) # use global arg list - popr $(R0|R1|R2|R3|R4|R5) # restore regs - movab 8(%ap),%ap # arg is pointer to sigctx - SYSTRAP(compat_16___sigreturn14) # exit from here - halt # illegal insn -END(__sigtramp_sigcontext_2) diff --git a/lib/libc/compat/arch/vax/sys/compat_msgctl.S b/lib/libc/compat/arch/vax/sys/compat_msgctl.S deleted file mode 100644 index a5598b0b1..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/vax/sys/compat_quotactl.S b/lib/libc/compat/arch/vax/sys/compat_quotactl.S deleted file mode 100644 index efb80312a..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:15 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/vax/sys/compat_shmctl.S b/lib/libc/compat/arch/vax/sys/compat_shmctl.S deleted file mode 100644 index a9f938c68..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/vax/sys/compat_sigaction13.S b/lib/libc/compat/arch/vax/sys/compat_sigaction13.S deleted file mode 100644 index 19d986075..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_sigaction13.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction13.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/vax/sys/compat_sigpending13.S b/lib/libc/compat/arch/vax/sys/compat_sigpending13.S deleted file mode 100644 index 04fddc121..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_sigpending13.S +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)sigpending.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: compat_sigpending13.S,v 1.2 2011/01/25 02:38:16 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -_SYSCALL(sigpending,compat_13_sigpending13) - movl %r0,*4(%ap) # store old mask - clrl %r0 - ret -END(sigpending) diff --git a/lib/libc/compat/arch/vax/sys/compat_sigprocmask13.S b/lib/libc/compat/arch/vax/sys/compat_sigprocmask13.S deleted file mode 100644 index 0c3129fa5..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_sigprocmask13.S +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)sigprocmask.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: compat_sigprocmask13.S,v 1.2 2011/01/25 02:38:16 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -ENTRY(sigprocmask, 0) - tstl 8(%ap) # check new sigset pointer - bneq 1f # if not null, indirect -/* movl $0,8(%ap) # null mask pointer: block empty set */ - movl $1,4(%ap) # SIG_BLOCK - jbr 2f -1: movl *8(%ap),8(%ap) # indirect to new mask arg -2: chmk $ SYS_compat_13_sigprocmask13 - jcc 3f - jmp CERROR+2 - -3: tstl 12(%ap) # test if old mask requested - beql out - movl %r0,*12(%ap) # store old mask -out: - clrl %r0 - ret -END(sigprocmask) diff --git a/lib/libc/compat/arch/vax/sys/compat_sigreturn13.S b/lib/libc/compat/arch/vax/sys/compat_sigreturn13.S deleted file mode 100644 index 31686c57d..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_sigreturn13.S +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)sigreturn.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: compat_sigreturn13.S,v 1.2 2011/01/25 02:38:16 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -/* - * We must preserve the state of the registers as the user has set them up. - */ -#ifdef GPROF -#undef ENTRY -#define ENTRY(x, y) \ - _ENTRY(x, y); pushr $0x3f; _PROF_PROLOGUE; popr $0x3f; -#endif /* GPROF */ - -WARN_REFERENCES(sigreturn, \ - "warning: reference to compatibility sigreturn()") - -PSEUDO(sigreturn,compat_13_sigreturn13) diff --git a/lib/libc/compat/arch/vax/sys/compat_sigsuspend13.S b/lib/libc/compat/arch/vax/sys/compat_sigsuspend13.S deleted file mode 100644 index cb468b069..000000000 --- a/lib/libc/compat/arch/vax/sys/compat_sigsuspend13.S +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include "SYS.h" - -#if defined(SYSLIBC_SCCS) && !defined(lint) - /* .asciz "@(#)sigsuspend.s 8.1 (Berkeley) 6/4/93" */ -RCSID("$NetBSD: compat_sigsuspend13.S,v 1.2 2011/01/25 02:38:16 matt Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend, 0) - movl *4(%ap),4(%ap) # indirect to mask arg - SYSTRAP(compat_13_sigsuspend13) - jcc 1f - jmp CERROR+2 -1: clrl %r0 # shouldnt happen - ret -END(sigsuspend) diff --git a/lib/libc/compat/arch/x86_64/Makefile.inc b/lib/libc/compat/arch/x86_64/Makefile.inc deleted file mode 100644 index 9ca65d490..000000000 --- a/lib/libc/compat/arch/x86_64/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2015/02/09 22:44:34 pooka Exp $ - -.include "${COMPATARCHDIR}/gen/Makefile.inc" -.if ${RUMPRUN} != "yes" -.include "${COMPATARCHDIR}/sys/Makefile.inc" -.endif diff --git a/lib/libc/compat/arch/x86_64/gen/Makefile.inc b/lib/libc/compat/arch/x86_64/gen/Makefile.inc deleted file mode 100644 index e06093eab..000000000 --- a/lib/libc/compat/arch/x86_64/gen/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2006/07/03 13:13:53 drochner Exp $ - -# objects built from C sources in compat/gen -SRCS+= compat_frexp_ieee754.c compat_ldexp_ieee754.c compat_modf_ieee754.c diff --git a/lib/libc/compat/arch/x86_64/sys/Makefile.inc b/lib/libc/compat/arch/x86_64/sys/Makefile.inc deleted file mode 100644 index f17a650ef..000000000 --- a/lib/libc/compat/arch/x86_64/sys/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2011/03/06 17:08:15 bouyer Exp $ - -SRCS+=compat_Ovfork.S compat___semctl.S compat___sigreturn14.S \ - compat_msgctl.S compat_shmctl.S compat_sigaction.S \ - compat_sigpending.S compat_sigprocmask.S compat_sigreturn.S \ - compat_sigsuspend.S compat_quotactl.S diff --git a/lib/libc/compat/arch/x86_64/sys/compat_Ovfork.S b/lib/libc/compat/arch/x86_64/sys/compat_Ovfork.S deleted file mode 100644 index e368f30c1..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_Ovfork.S +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: compat_Ovfork.S,v 1.3 2014/05/22 15:21:13 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)Ovfork.s 5.1 (Berkeley) 4/23/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_Ovfork.S,v 1.3 2014/05/22 15:21:13 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(vfork, \ - "warning: reference to compatibility vfork(); include for correct reference") - -/* - * pid = vfork(); - * - * %edx == 0 in parent process, %edx == 1 in child process. - * %eax == pid of child in parent, %eax == pid of parent in child. - * - */ -ENTRY(vfork) - popq %r9 /* my rta into r9 */ - SYSTRAP(vfork) - jc err - decl %edx - andl %edx,%eax - jmp *%r9 -err: - pushq %r9 -#ifdef __PIC__ - movq PIC_GOT(CERROR), %rcx - jmp *%rcx -#else - jmp CERROR -#endif -END(vfork) diff --git a/lib/libc/compat/arch/x86_64/sys/compat___semctl.S b/lib/libc/compat/arch/x86_64/sys/compat___semctl.S deleted file mode 100644 index c64b6d3bb..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat___semctl.S +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat___semctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -PSEUDO(__semctl,compat_14___semctl) diff --git a/lib/libc/compat/arch/x86_64/sys/compat___sigreturn14.S b/lib/libc/compat/arch/x86_64/sys/compat___sigreturn14.S deleted file mode 100644 index 4704ae88f..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat___sigreturn14.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: compat___sigreturn14.S,v 1.1 2006/03/11 18:59:21 christos Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat___sigreturn14.S,v 1.1 2006/03/11 18:59:21 christos Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -/* Nothing here. We don't need NetBSD-1.6 binary compatibility. */ diff --git a/lib/libc/compat/arch/x86_64/sys/compat_msgctl.S b/lib/libc/compat/arch/x86_64/sys/compat_msgctl.S deleted file mode 100644 index a5598b0b1..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_msgctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_msgctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(msgctl, \ - "warning: reference to compatibility msgctl(); include for correct reference") - -PSEUDO(msgctl,compat_14_msgctl) diff --git a/lib/libc/compat/arch/x86_64/sys/compat_quotactl.S b/lib/libc/compat/arch/x86_64/sys/compat_quotactl.S deleted file mode 100644 index efb80312a..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_quotactl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_quotactl.S,v 1.2 2011/03/06 17:08:15 bouyer Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(quotactl, \ - "warning: reference to compatibility quotactl(); include for correct reference") - -PSEUDO(quotactl,compat_50_quotactl) diff --git a/lib/libc/compat/arch/x86_64/sys/compat_shmctl.S b/lib/libc/compat/arch/x86_64/sys/compat_shmctl.S deleted file mode 100644 index a9f938c68..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_shmctl.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_shmctl.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(shmctl, \ - "warning: reference to compatibility shmctl(); include for correct reference") - -PSEUDO(shmctl,compat_14_shmctl) diff --git a/lib/libc/compat/arch/x86_64/sys/compat_sigaction.S b/lib/libc/compat/arch/x86_64/sys/compat_sigaction.S deleted file mode 100644 index 7d778432c..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_sigaction.S +++ /dev/null @@ -1,38 +0,0 @@ -/* $NetBSD: compat_sigaction.S,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "SYS.h" - -WARN_REFERENCES(sigaction, \ - "warning: reference to compatibility sigaction(); include for correct reference") - -PSEUDO(sigaction,compat_13_sigaction13) diff --git a/lib/libc/compat/arch/x86_64/sys/compat_sigpending.S b/lib/libc/compat/arch/x86_64/sys/compat_sigpending.S deleted file mode 100644 index 353264971..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_sigpending.S +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: compat_sigpending.S,v 1.2 2014/05/22 15:21:13 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigpending.s 5.1 (Berkeley) 7/1/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigpending.S,v 1.2 2014/05/22 15:21:13 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigpending, \ - "warning: reference to compatibility sigpending(); include for correct reference") - -_SYSCALL(sigpending,compat_13_sigpending13) - movl %eax,(%rdi) # store old mask - xorl %eax,%eax - ret -END(sigpending) diff --git a/lib/libc/compat/arch/x86_64/sys/compat_sigprocmask.S b/lib/libc/compat/arch/x86_64/sys/compat_sigprocmask.S deleted file mode 100644 index 9d08e6047..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_sigprocmask.S +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: compat_sigprocmask.S,v 1.3 2014/05/22 15:21:13 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigprocmask.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigprocmask.S,v 1.3 2014/05/22 15:21:13 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigprocmask, \ - "warning: reference to compatibility sigprocmask(); include for correct reference") - -ENTRY(sigprocmask) - testq %rsi,%rsi # check new sigset pointer - jnz 1f # if not null, indirect - movl $1,%edi # SIG_BLOCK - jmp 2f -1: movl (%rsi),%esi # fetch indirect ... -2: SYSTRAP(compat_13_sigprocmask13) - jc err - testq %rdx,%rdx # test if old mask requested - jz out - movq %rax,(%rdx) # store old mask -out: - xorl %eax,%eax - ret -err: -#ifdef __PIC__ - movq PIC_GOT(CERROR), %rcx - jmp *%rcx -#else - jmp CERROR -#endif -END(sigprocmask) diff --git a/lib/libc/compat/arch/x86_64/sys/compat_sigreturn.S b/lib/libc/compat/arch/x86_64/sys/compat_sigreturn.S deleted file mode 100644 index bdfb76bab..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_sigreturn.S +++ /dev/null @@ -1,42 +0,0 @@ -/* $NetBSD: compat_sigreturn.S,v 1.1 2006/03/11 18:59:21 christos Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigreturn.s 5.2 (Berkeley) 12/17/90" - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigreturn.S,v 1.1 2006/03/11 18:59:21 christos Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -/* Nothing here. We don't need NetBSD-1.3 binary compatibility. */ diff --git a/lib/libc/compat/arch/x86_64/sys/compat_sigsuspend.S b/lib/libc/compat/arch/x86_64/sys/compat_sigsuspend.S deleted file mode 100644 index 50b466913..000000000 --- a/lib/libc/compat/arch/x86_64/sys/compat_sigsuspend.S +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: compat_sigsuspend.S,v 1.3 2014/05/22 15:21:13 uebayasi Exp $ */ - -/*- - * Copyright (c) 1990 The Regents of the University of California. - * All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * William Jolitz. - * - * 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. - * - * from: @(#)sigsuspend.s 5.2 (Berkeley) 12/17/90 - */ - -#include -#if defined(SYSLIBC_SCCS) && !defined(lint) - RCSID("$NetBSD: compat_sigsuspend.S,v 1.3 2014/05/22 15:21:13 uebayasi Exp $") -#endif /* SYSLIBC_SCCS and not lint */ - -#include "SYS.h" - -WARN_REFERENCES(sigsuspend, \ - "warning: reference to compatibility sigsuspend(); include for correct reference") - -ENTRY(sigsuspend) - movl (%rdi),%edi # indirect to mask arg - SYSTRAP(compat_13_sigsuspend13) - jc err - xorl %eax,%eax # shouldn t happen - ret -err: -#ifdef __PIC__ - movq PIC_GOT(CERROR), %rcx - jmp *%rcx -#else - jmp CERROR -#endif -END(sigsuspend) diff --git a/lib/libc/compat/db/Makefile.inc b/lib/libc/compat/db/Makefile.inc deleted file mode 100644 index 91236ce43..000000000 --- a/lib/libc/compat/db/Makefile.inc +++ /dev/null @@ -1,2 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 21:07:18 christos Exp $ -.include "${COMPATDIR}/db/hash/Makefile.inc" diff --git a/lib/libc/compat/db/hash/Makefile.inc b/lib/libc/compat/db/hash/Makefile.inc deleted file mode 100644 index b801df5e6..000000000 --- a/lib/libc/compat/db/hash/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/03/11 21:07:18 christos Exp $ - -.PATH: ${COMPATDIR}/db/hash -SRCS+=compat_ndbmdatum.c diff --git a/lib/libc/compat/db/hash/compat_ndbmdatum.c b/lib/libc/compat/db/hash/compat_ndbmdatum.c deleted file mode 100644 index a238834fe..000000000 --- a/lib/libc/compat/db/hash/compat_ndbmdatum.c +++ /dev/null @@ -1,33 +0,0 @@ -/* $NetBSD: compat_ndbmdatum.c,v 1.2 2012/03/13 21:13:31 christos Exp $ */ - -/* - * Written by Klaus Klein , April 28, 2004. - * Public domain. - */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" -#include -#include -#include - -__warn_references(dbm_delete, - "warning: reference to compatibility dbm_delete();" - " include for correct reference") -__warn_references(dbm_fetch, - "warning: reference to compatibility dbm_fetch();" - " include for correct reference") -__warn_references(dbm_firstkey, - "warning: reference to compatibility dbm_firstkey();" - " include for correct reference") -__warn_references(dbm_nextkey, - "warning: reference to compatibility dbm_nextkey();" - " include for correct reference") -__warn_references(dbm_store, - "warning: reference to compatibility dbm_store();" - " include for correct reference") - -#define datum datum12 -#define datum_truncate(a) ((a) > INT_MAX ? INT_MAX : (int)(a)) - -#include "db/hash/ndbmdatum.c" diff --git a/lib/libc/compat/gen/Makefile.inc b/lib/libc/compat/gen/Makefile.inc deleted file mode 100644 index aaa3cdb72..000000000 --- a/lib/libc/compat/gen/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.17 2014/01/16 20:31:42 christos Exp $ - -#__MINIX: Not all supported yet -.PATH: ${COMPATDIR}/gen -SRCS+=compat_errlist.c compat_fts.c \ - compat_glob.c compat___glob13.c \ - compat_opendir.c compat_readdir.c compat__readdir_unlocked30.c \ - compat_scandir.c compat_siglist.c compat_signame.c compat_sigsetops.c \ - compat_times.c compat_timezone.c compat_unvis.c compat_utmpx.c \ - compat_time.c compat_utime.c compat_devname.c compat_alphasort.c \ - compat_getpwent.c compat_utmp.c compat___fts50.c \ - compat___unvis13.c compat_syslog.c compat_alloca.c diff --git a/lib/libc/compat/gen/compat___fts13.c b/lib/libc/compat/gen/compat___fts13.c deleted file mode 100644 index 44378ea29..000000000 --- a/lib/libc/compat/gen/compat___fts13.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: compat___fts13.c,v 1.11 2013/10/04 21:07:37 christos Exp $ */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ - -__warn_references(__fts_children13, - "warning: reference to compatibility __fts_children13();" - " include for correct reference") -__warn_references(__fts_close13, - "warning: reference to compatibility __fts_close13();" - " include for correct reference") -__warn_references(__fts_open13, - "warning: reference to compatibility __fts_open13();" - " include for correct reference") -__warn_references(__fts_read13, - "warning: reference to compatibility __fts_read13();" - " include for correct reference") -__warn_references(__fts_set13, - "warning: reference to compatibility __fts_set13();" - " include for correct reference") - -#include -#include -#include - -#define __fts_stat_t struct stat13 -#define __fts_ino_t u_int32_t -#define __fts_length_t u_short -#define __fts_number_t long -#define __fts_dev_t uint32_t -#define __fts_level_t short - -#ifndef ftsent_namelen_truncate -#define ftsent_namelen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif -#ifndef ftsent_pathlen_truncate -#define ftsent_pathlen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif - -#define stat __compat___stat13 -#define lstat __compat___lstat13 -#define fstat __compat___fstat13 - -#undef fts_children -#define fts_children __fts_children13 -#undef fts_close -#define fts_close __fts_close13 -#undef fts_open -#define fts_open __fts_open13 -#undef fts_read -#define fts_read __fts_read13 -#undef fts_set -#define fts_set __fts_set13 - -#include -#include - -#define __FTS_COMPAT_TAILINGSLASH -#define __FTS_COMPAT_LENGTH -#define __FTS_COMPAT_LEVEL - -#include "gen/fts.c" diff --git a/lib/libc/compat/gen/compat___fts30.c b/lib/libc/compat/gen/compat___fts30.c deleted file mode 100644 index 54607585b..000000000 --- a/lib/libc/compat/gen/compat___fts30.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: compat___fts30.c,v 1.8 2013/10/04 21:07:37 christos Exp $ */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ - -__warn_references(__fts_children30, - "warning: reference to compatibility __fts_children30();" - " include for correct reference") -__warn_references(__fts_close30, - "warning: reference to compatibility __fts_close30();" - " include for correct reference") -__warn_references(__fts_open30, - "warning: reference to compatibility __fts_open30();" - " include for correct reference") -__warn_references(__fts_read30, - "warning: reference to compatibility __fts_read30();" - " include for correct reference") -__warn_references(__fts_set30, - "warning: reference to compatibility __fts_set30();" - " include for correct reference") - -#include -#include -#include - -#define __fts_stat_t struct stat30 -#define __fts_length_t u_short -#define __fts_number_t long -#define __fts_dev_t uint32_t -#define __fts_level_t short - -#define stat __compat___stat30 -#define lstat __compat___lstat30 -#define fstat __compat___fstat30 - -#ifndef ftsent_namelen_truncate -#define ftsent_namelen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif -#ifndef ftsent_pathlen_truncate -#define ftsent_pathlen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif - -#undef fts_children -#define fts_children __fts_children30 -#undef fts_close -#define fts_close __fts_close30 -#undef fts_open -#define fts_open __fts_open30 -#undef fts_read -#define fts_read __fts_read30 -#undef fts_set -#define fts_set __fts_set30 - -#include -#include - -#define __FTS_COMPAT_LENGTH -#define __FTS_COMPAT_LEVEL - -#include "gen/fts.c" diff --git a/lib/libc/compat/gen/compat___fts31.c b/lib/libc/compat/gen/compat___fts31.c deleted file mode 100644 index cfef1e312..000000000 --- a/lib/libc/compat/gen/compat___fts31.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: compat___fts31.c,v 1.6 2013/10/04 21:07:37 christos Exp $ */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ - -__warn_references(__fts_children31, - "warning: reference to compatibility __fts_children31();" - " include for correct reference") -__warn_references(__fts_close31, - "warning: reference to compatibility __fts_close31();" - " include for correct reference") -__warn_references(__fts_open31, - "warning: reference to compatibility __fts_open31();" - " include for correct reference") -__warn_references(__fts_read31, - "warning: reference to compatibility __fts_read31();" - " include for correct reference") -__warn_references(__fts_set31, - "warning: reference to compatibility __fts_set31();" - " include for correct reference") - -#include -#include -#include - -#define __fts_stat_t struct stat30 -#define __fts_number_t long -#define __fts_dev_t uint32_t -#define __fts_level_t short - -#ifndef ftsent_namelen_truncate -#define ftsent_namelen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif -#ifndef ftsent_pathlen_truncate -#define ftsent_pathlen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif - -#define stat __compat___stat30 -#define lstat __compat___lstat30 -#define fstat __compat___fstat30 - -#undef fts_children -#define fts_children __fts_children31 -#undef fts_close -#define fts_close __fts_close31 -#undef fts_open -#define fts_open __fts_open31 -#undef fts_read -#define fts_read __fts_read31 -#undef fts_set -#define fts_set __fts_set31 - -#include -#include - -#define __FTS_COMPAT_LEVEL - -#include "gen/fts.c" diff --git a/lib/libc/compat/gen/compat___fts32.c b/lib/libc/compat/gen/compat___fts32.c deleted file mode 100644 index 2c6b10942..000000000 --- a/lib/libc/compat/gen/compat___fts32.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: compat___fts32.c,v 1.5 2013/10/04 21:07:37 christos Exp $ */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ -__warn_references(__fts_children32, - "warning: reference to compatibility __fts_children32();" - " include for correct reference") -__warn_references(__fts_close32, - "warning: reference to compatibility __fts_close32();" - " include for correct reference") -__warn_references(__fts_open32, - "warning: reference to compatibility __fts_open32();" - " include for correct reference") -__warn_references(__fts_read32, - "warning: reference to compatibility __fts_read32();" - " include for correct reference") -__warn_references(__fts_set32, - "warning: reference to compatibility __fts_set32();" - " include for correct reference") - -#define __fts_stat_t struct stat30 -#define __fts_dev_t uint32_t -#define __fts_level_t short - -#undef fts_children -#define fts_children __fts_children32 -#undef fts_close -#define fts_close __fts_close32 -#undef fts_open -#define fts_open __fts_open32 -#undef fts_read -#define fts_read __fts_read32 -#undef fts_set -#define fts_set __fts_set32 - -#include -#include -#include -#include - -#include -#include - -#define __FTS_COMPAT_LEVEL - -#define stat __compat___stat30 -#define lstat __compat___lstat30 -#define fstat __compat___fstat30 - -#include "gen/fts.c" diff --git a/lib/libc/compat/gen/compat___fts50.c b/lib/libc/compat/gen/compat___fts50.c deleted file mode 100644 index dbf913b36..000000000 --- a/lib/libc/compat/gen/compat___fts50.c +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD: compat___fts50.c,v 1.2 2009/10/19 17:52:05 christos Exp $ */ - -#include "namespace.h" -#include -#include -#include -#include - -#define __LIBC12_SOURCE__ -__warn_references(__fts_children50, - "warning: reference to compatibility __fts_children50();" - " include for correct reference") -__warn_references(__fts_close50, - "warning: reference to compatibility __fts_close50();" - " include for correct reference") -__warn_references(__fts_open50, - "warning: reference to compatibility __fts_open50();" - " include for correct reference") -__warn_references(__fts_read50, - "warning: reference to compatibility __fts_read50();" - " include for correct reference") -__warn_references(__fts_set50, - "warning: reference to compatibility __fts_set50();" - " include for correct reference") - -#define __fts_level_t short -#undef fts_children -#define fts_children __fts_children50 -#undef fts_close -#define fts_close __fts_close50 -#undef fts_open -#define fts_open __fts_open50 -#undef fts_read -#define fts_read __fts_read50 -#undef fts_set -#define fts_set __fts_set50 - -#include -#include - -#define __FTS_COMPAT_LEVEL - -#include "gen/fts.c" diff --git a/lib/libc/compat/gen/compat___glob13.c b/lib/libc/compat/gen/compat___glob13.c deleted file mode 100644 index f3ea45bae..000000000 --- a/lib/libc/compat/gen/compat___glob13.c +++ /dev/null @@ -1,27 +0,0 @@ -/* $NetBSD: compat___glob13.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/* - * Written by Jason R. Thorpe , October 21, 1997. - * Public domain. - */ -#include "namespace.h" -#include -#include -#include -#define __gl_size_t int - -#define __LIBC12_SOURCE__ -__warn_references(__glob13, - "warning: reference to compatibility __glob13(); include for correct reference") -__warn_references(__globfree13, - "warning: reference to compatibility __globfree13(); include for correct reference") - -#undef glob -#undef globfree -#define glob __glob13 -#define globfree __globfree13 - -#include -#include - -#include "gen/glob.c" diff --git a/lib/libc/compat/gen/compat___unvis13.c b/lib/libc/compat/gen/compat___unvis13.c deleted file mode 100644 index df938ba31..000000000 --- a/lib/libc/compat/gen/compat___unvis13.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: compat___unvis13.c,v 1.1 2011/03/12 19:52:47 christos Exp $ */ - -/*- - * Copyright (c) 2011 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___unvis13.c,v 1.1 2011/03/12 19:52:47 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#ifdef __warn_references -__warn_references(__unvis13, - "warning: reference to compatibility __unvis13(); include for correct reference") -#endif - -int -__unvis13(char *cp, int c, int *astate, int flag) -{ - flag = (flag & ~1) | ((flag & 1) ? UNVIS_END : 0); - return __unvis50(cp, c, astate, flag); -} diff --git a/lib/libc/compat/gen/compat__readdir_unlocked30.c b/lib/libc/compat/gen/compat__readdir_unlocked30.c deleted file mode 100644 index df6fe22ee..000000000 --- a/lib/libc/compat/gen/compat__readdir_unlocked30.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: compat__readdir_unlocked30.c,v 1.1 2008/05/04 18:53:26 tonnerre Exp $ */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" -#include -#include - -#ifdef __warn_references -__warn_references(___readdir_unlocked30, - "warning: reference to compatibility _readdir_unlocked(); include for correct reference") -#endif - -/** - * Compat version of _readdir_unlocked which always skips directories - */ -struct dirent * -___readdir_unlocked30(DIR *dirp) -{ - return ___readdir_unlocked50(dirp, 1); -} diff --git a/lib/libc/compat/gen/compat_alloca.c b/lib/libc/compat/gen/compat_alloca.c deleted file mode 100644 index fff067f47..000000000 --- a/lib/libc/compat/gen/compat_alloca.c +++ /dev/null @@ -1,6 +0,0 @@ -#include - -__warn_references(alloca, - "Warning: reference to the libc supplied alloca(3); this most likely will " - "not work. Please use the compiler provided version of alloca(3), by " - "supplying the appropriate compiler flags (e.g. not -std=c89).") diff --git a/lib/libc/compat/gen/compat_alphasort.c b/lib/libc/compat/gen/compat_alphasort.c deleted file mode 100644 index 25201718f..000000000 --- a/lib/libc/compat/gen/compat_alphasort.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: compat_alphasort.c,v 1.1 2009/02/24 18:42:36 christos Exp $ */ - -#include -#define __LIBC12_SOURCE__ -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(alphasort,_alphasort) -#endif - -#ifdef __warn_references -__warn_references(alphasort, - "warning: reference to compatibility alphasort(); include for correct reference") -#endif - -#define dirent dirent12 - -#include "gen/alphasort.c" diff --git a/lib/libc/compat/gen/compat_devname.c b/lib/libc/compat/gen/compat_devname.c deleted file mode 100644 index 399c002d2..000000000 --- a/lib/libc/compat/gen/compat_devname.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_devname.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_devname.c,v 1.2 2009/01/11 02:46:25 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include - -__warn_references(devname, - "warning: reference to compatibility devname(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(devname, _devname) -#endif - -__aconst char * -devname(int32_t dev, mode_t mode) -{ - return __devname50(dev, mode); -} diff --git a/lib/libc/compat/gen/compat_errlist.c b/lib/libc/compat/gen/compat_errlist.c deleted file mode 100644 index 7c8c8cb3b..000000000 --- a/lib/libc/compat/gen/compat_errlist.c +++ /dev/null @@ -1,153 +0,0 @@ -/* $NetBSD: compat_errlist.c,v 1.2 2006/10/31 00:38:07 cbiere Exp $ */ - -/* - * Copyright (c) 1982, 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)errlst.c 8.2 (Berkeley) 11/16/93"; -#else -__RCSID("$NetBSD: compat_errlist.c,v 1.2 2006/10/31 00:38:07 cbiere Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#define __LIBC12_SOURCE__ -#include -#ifdef __weak_alias -__weak_alias(sys_errlist, _sys_errlist) -__weak_alias(__sys_errlist, _sys_errlist) -__weak_alias(sys_nerr, _sys_nerr) -__weak_alias(__sys_nerr, _sys_nerr) -#endif - -const char *const sys_errlist[] = { - "Undefined error: 0", /* 0 - ENOERROR */ - "Operation not permitted", /* 1 - EPERM */ - "No such file or directory", /* 2 - ENOENT */ - "No such process", /* 3 - ESRCH */ - "Interrupted system call", /* 4 - EINTR */ - "Input/output error", /* 5 - EIO */ - "Device not configured", /* 6 - ENXIO */ - "Argument list too long", /* 7 - E2BIG */ - "Exec format error", /* 8 - ENOEXEC */ - "Bad file descriptor", /* 9 - EBADF */ - "No child processes", /* 10 - ECHILD */ - "Resource deadlock avoided", /* 11 - EDEADLK */ - "Cannot allocate memory", /* 12 - ENOMEM */ - "Permission denied", /* 13 - EACCES */ - "Bad address", /* 14 - EFAULT */ - "Block device required", /* 15 - ENOTBLK */ - "Device busy", /* 16 - EBUSY */ - "File exists", /* 17 - EEXIST */ - "Cross-device link", /* 18 - EXDEV */ - "Operation not supported by device", /* 19 - ENODEV */ - "Not a directory", /* 20 - ENOTDIR */ - "Is a directory", /* 21 - EISDIR */ - "Invalid argument", /* 22 - EINVAL */ - "Too many open files in system", /* 23 - ENFILE */ - "Too many open files", /* 24 - EMFILE */ - "Inappropriate ioctl for device", /* 25 - ENOTTY */ - "Text file busy", /* 26 - ETXTBSY */ - "File too large", /* 27 - EFBIG */ - "No space left on device", /* 28 - ENOSPC */ - "Illegal seek", /* 29 - ESPIPE */ - "Read-only file system", /* 30 - EROFS */ - "Too many links", /* 31 - EMLINK */ - "Broken pipe", /* 32 - EPIPE */ - -/* math software */ - "Numerical argument out of domain", /* 33 - EDOM */ - "Result too large or too small", /* 34 - ERANGE */ - -/* non-blocking and interrupt i/o */ - "Resource temporarily unavailable", /* 35 - EAGAIN */ - /* 35 - EWOULDBLOCK */ - "Operation now in progress", /* 36 - EINPROGRESS */ - "Operation already in progress", /* 37 - EALREADY */ - -/* ipc/network software -- argument errors */ - "Socket operation on non-socket", /* 38 - ENOTSOCK */ - "Destination address required", /* 39 - EDESTADDRREQ */ - "Message too long", /* 40 - EMSGSIZE */ - "Protocol wrong type for socket", /* 41 - EPROTOTYPE */ - "Protocol option not available", /* 42 - ENOPROTOOPT */ - "Protocol not supported", /* 43 - EPROTONOSUPPORT */ - "Socket type not supported", /* 44 - ESOCKTNOSUPPORT */ - "Operation not supported", /* 45 - EOPNOTSUPP */ - "Protocol family not supported", /* 46 - EPFNOSUPPORT */ - /* 47 - EAFNOSUPPORT */ - "Address family not supported by protocol family", - "Address already in use", /* 48 - EADDRINUSE */ - "Can't assign requested address", /* 49 - EADDRNOTAVAIL */ - -/* ipc/network software -- operational errors */ - "Network is down", /* 50 - ENETDOWN */ - "Network is unreachable", /* 51 - ENETUNREACH */ - "Network dropped connection on reset", /* 52 - ENETRESET */ - "Software caused connection abort", /* 53 - ECONNABORTED */ - "Connection reset by peer", /* 54 - ECONNRESET */ - "No buffer space available", /* 55 - ENOBUFS */ - "Socket is already connected", /* 56 - EISCONN */ - "Socket is not connected", /* 57 - ENOTCONN */ - "Can't send after socket shutdown", /* 58 - ESHUTDOWN */ - "Too many references: can't splice", /* 59 - ETOOMANYREFS */ - "Operation timed out", /* 60 - ETIMEDOUT */ - "Connection refused", /* 61 - ECONNREFUSED */ - - "Too many levels of symbolic links", /* 62 - ELOOP */ - "File name too long", /* 63 - ENAMETOOLONG */ - -/* should be rearranged */ - "Host is down", /* 64 - EHOSTDOWN */ - "No route to host", /* 65 - EHOSTUNREACH */ - "Directory not empty", /* 66 - ENOTEMPTY */ - -/* quotas & mush */ - "Too many processes", /* 67 - EPROCLIM */ - "Too many users", /* 68 - EUSERS */ - "Disc quota exceeded", /* 69 - EDQUOT */ - -/* Network File System */ - "Stale NFS file handle", /* 70 - ESTALE */ - "Too many levels of remote in path", /* 71 - EREMOTE */ - "RPC struct is bad", /* 72 - EBADRPC */ - "RPC version wrong", /* 73 - ERPCMISMATCH */ - "RPC prog. not avail", /* 74 - EPROGUNAVAIL */ - "Program version wrong", /* 75 - EPROGMISMATCH */ - "Bad procedure for program", /* 76 - EPROCUNAVAIL */ - - "No locks available", /* 77 - ENOLCK */ - "Function not implemented", /* 78 - ENOSYS */ - - "Inappropriate file type or format", /* 79 - EFTYPE */ -}; -const int sys_nerr = { sizeof(sys_errlist) / sizeof(sys_errlist[0]) }; diff --git a/lib/libc/compat/gen/compat_frexp_ieee754.c b/lib/libc/compat/gen/compat_frexp_ieee754.c deleted file mode 100644 index 947039bfc..000000000 --- a/lib/libc/compat/gen/compat_frexp_ieee754.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: compat_frexp_ieee754.c,v 1.5 2010/04/23 19:04:54 drochner Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: frexp.c,v 1.1 91/07/07 04:45:01 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)frexp.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_frexp_ieee754.c,v 1.5 2010/04/23 19:04:54 drochner Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -double frexp(double, int *); - -/* - * Split the given value into a fraction in the range [0.5, 1.0) and - * an exponent, such that frac * (2^exp) == value. If value is 0, - * return 0. - */ -double -frexp(double value, int *eptr) -{ - union ieee_double_u u; - - if (value) { - /* - * Fractions in [0.5..1.0) have an exponent of 2^-1. - * Leave Inf and NaN alone, however. - */ - u.dblu_d = value; - if (u.dblu_dbl.dbl_exp != DBL_EXP_INFNAN) { - *eptr = 0; - if (u.dblu_dbl.dbl_exp == 0) { - /* denormal, scale out of mantissa */ - *eptr = -DBL_FRACBITS; - u.dblu_d *= 4.50359962737049600000e+15; - } - *eptr += u.dblu_dbl.dbl_exp - (DBL_EXP_BIAS - 1); - u.dblu_dbl.dbl_exp = DBL_EXP_BIAS - 1; - } - return (u.dblu_d); - } else { - *eptr = 0; - return (value); - } -} diff --git a/lib/libc/compat/gen/compat_fts.c b/lib/libc/compat/gen/compat_fts.c deleted file mode 100644 index 5cd131436..000000000 --- a/lib/libc/compat/gen/compat_fts.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: compat_fts.c,v 1.8 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Written by Jason R. Thorpe , October 21, 1997. - * Public domain. - */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include -#include - -#define __fts_stat_t struct stat12 -#define __fts_nlink_t u_int16_t -#define __fts_ino_t u_int32_t -#define __fts_length_t unsigned short -#define __fts_number_t long -#define __fts_dev_t uint32_t -#define __fts_level_t short - -#ifndef ftsent_namelen -#define ftsent_namelen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif -#ifndef fts_pathlen_truncate -#define ftsent_pathlen_truncate(a) \ - ((a) > USHRT_MAX ? USHRT_MAX : (unsigned short)(a)) -#endif - -#include -#include - -#ifdef __weak_alias -__weak_alias(fts_children,_fts_children) -__weak_alias(fts_close,_fts_close) -__weak_alias(fts_open,_fts_open) -__weak_alias(fts_read,_fts_read) -__weak_alias(fts_set,_fts_set) -#endif /* __weak_alias */ - -__warn_references(fts_children, - "warning: reference to compatibility fts_children();" - " include for correct reference") -__warn_references(fts_close, - "warning: reference to compatibility fts_close();" - " include for correct reference") -__warn_references(fts_open, - "warning: reference to compatibility fts_open();" - " include for correct reference") -__warn_references(fts_read, - "warning: reference to compatibility fts_read();" - " include for correct reference") -__warn_references(fts_set, - "warning: reference to compatibility fts_set();" - " include for correct reference") - -#define __FTS_COMPAT_TAILINGSLASH -#define __FTS_COMPAT_LENGTH -#define __FTS_COMPAT_LEVEL - -#define stat __compat_stat -#define lstat __compat_lstat -#define fstat __compat_fstat - -#include "gen/fts.c" diff --git a/lib/libc/compat/gen/compat_getmntinfo.c b/lib/libc/compat/gen/compat_getmntinfo.c deleted file mode 100644 index a23566f3c..000000000 --- a/lib/libc/compat/gen/compat_getmntinfo.c +++ /dev/null @@ -1,85 +0,0 @@ -/* $NetBSD: compat_getmntinfo.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_getmntinfo.c,v 1.4 2013/10/04 21:07:37 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include - -__strong_alias(getmntinfo, __compat_getmntinfo) - -/* - * Return information about mounted filesystems. - */ -int -__compat_getmntinfo(struct statfs12 **mntbufp, int flags) -{ - static struct statfs12 *mntbuf; - static int mntsize; - static size_t bufsize; - - _DIAGASSERT(mntbufp != NULL); - - if (mntsize <= 0 && - (mntsize = __compat_getfsstat(NULL, 0L, MNT_NOWAIT)) == -1) - return (0); - if (bufsize > 0 && - (mntsize = __compat_getfsstat(mntbuf, (long)bufsize, flags)) == -1) - return (0); - while (bufsize <= mntsize * sizeof(struct statfs12)) { - if (mntbuf) - free(mntbuf); - bufsize = (mntsize + 1) * sizeof(struct statfs12); - if ((mntbuf = malloc(bufsize)) == NULL) - return (0); - if ((mntsize = __compat_getfsstat(mntbuf, (long)bufsize, - flags)) == -1) - return (0); - } - *mntbufp = mntbuf; - return (mntsize); -} diff --git a/lib/libc/compat/gen/compat_getpwent.c b/lib/libc/compat/gen/compat_getpwent.c deleted file mode 100644 index 886f49545..000000000 --- a/lib/libc/compat/gen/compat_getpwent.c +++ /dev/null @@ -1,187 +0,0 @@ -/* $NetBSD: compat_getpwent.c,v 1.3 2009/06/01 06:04:37 yamt Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_getpwent.c,v 1.3 2009/06/01 06:04:37 yamt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include - -__warn_references(getpwuid, - "warning: reference to compatibility getpwuid(); include to generate correct reference") -__warn_references(getpwnam, - "warning: reference to compatibility getpwnam(); include to generate correct reference") -__warn_references(getpwnam_r, - "warning: reference to compatibility getpwnam_r(); include to generate correct reference") -__warn_references(getpwuid_r, - "warning: reference to compatibility getpwuid_r(); include to generate correct reference") -__warn_references(getpwent, - "warning: reference to compatibility getpwent(); include to generate correct reference") -#ifdef notdef /* for libutil */ -__warn_references(pw_scan, - "warning: reference to compatibility pw_scan(); include to generate correct reference") -#endif -__warn_references(getpwent_r, - "warning: reference to compatibility getpwent_r(); include to generate correct reference") -__warn_references(pwcache_userdb, - "warning: reference to compatibility pwcache_userdb(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(getpwent, _getpwent) -__weak_alias(getpwent_r, _getpwent_r) -__weak_alias(getpwuid, _getpwuid) -__weak_alias(getpwuid_r, _getpwuid_r) -__weak_alias(getpwnam, _getpwnam) -__weak_alias(getpwnam_r, _getpwnam_r) -__weak_alias(pwcache_userdb, _pwcache_userdb) -#endif - -static struct passwd50 * -cvt(struct passwd *p) -{ - struct passwd50 *q = (void *)p; - - if (q == NULL) { - return NULL; - } - q->pw_change = (int32_t)p->pw_change; - q->pw_class = p->pw_class; - q->pw_gecos = p->pw_gecos; - q->pw_dir = p->pw_dir; - q->pw_shell = p->pw_shell; - q->pw_expire = (int32_t)p->pw_expire; - return q; -} - -struct passwd50 * -getpwuid(uid_t uid) -{ - return cvt(__getpwuid50(uid)); - -} - -struct passwd50 * -getpwnam(const char *name) -{ - return cvt(__getpwnam50(name)); -} - -int -getpwnam_r(const char *name , struct passwd50 *p, char *buf, size_t len, - struct passwd50 **q) -{ - struct passwd px, *qx; - int rv = __getpwnam_r50(name, &px, buf, len, &qx); - *q = p; - passwd_to_passwd50(&px, p); - return rv; -} - -int -getpwuid_r(uid_t uid, struct passwd50 *p, char *buf, size_t len, - struct passwd50 **q) -{ - struct passwd px, *qx; - int rv = __getpwuid_r50(uid, &px, buf, len, &qx); - *q = p; - passwd_to_passwd50(&px, p); - return rv; -} - -struct passwd50 * -getpwent(void) -{ - return cvt(__getpwent50()); -} - -#ifdef notdef /* for libutil */ -int -pw_scan(char *buf, struct passwd50 *p, int *flags) -{ - struct passwd px; - int rv = __pw_scan50(buf, &px, flags); - passwd_to_passwd50(&px, p); - return rv; -} -#endif - -int -getpwent_r(struct passwd50 *p, char *buf, size_t len, struct passwd50 **q) -{ - struct passwd px, *qx; - int rv = __getpwent_r50(&px, buf, len, &qx); - *q = p; - passwd_to_passwd50(&px, p); - return rv; -} - -static struct passwd50 * (*__getpwnamf)(const char *); -static struct passwd50 * (*__getpwuidf)(uid_t); -static struct passwd pw; - -static struct passwd * -internal_getpwnam(const char *name) -{ - struct passwd50 *p = (*__getpwnamf)(name); - passwd50_to_passwd(p, &pw); - return &pw; -} - -static struct passwd * -internal_getpwuid(uid_t uid) -{ - struct passwd50 *p = (*__getpwuidf)(uid); - passwd50_to_passwd(p, &pw); - return &pw; -} - -int pwcache_userdb(int (*setpassentf)(int), void (*endpwentf)(void), - struct passwd50 * (*getpwnamf)(const char *), - struct passwd50 * (*getpwuidf)(uid_t)) -{ - __getpwnamf = getpwnamf; - __getpwuidf = getpwuidf; - return __pwcache_userdb50(setpassentf, endpwentf, internal_getpwnam, - internal_getpwuid); -} diff --git a/lib/libc/compat/gen/compat_glob.c b/lib/libc/compat/gen/compat_glob.c deleted file mode 100644 index 629e40044..000000000 --- a/lib/libc/compat/gen/compat_glob.c +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: compat_glob.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Written by Jason R. Thorpe , October 21, 1997. - * Public domain. - */ -#include "namespace.h" -#include -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include -#include -#define __gl_stat_t struct stat12 - -#include -#include - -#ifdef __weak_alias -__weak_alias(glob,_glob) -__weak_alias(globfree,_globfree) -#endif /* __weak_alias */ - -__warn_references(glob, - "warning: reference to compatibility glob(); include for correct reference") -__warn_references(globfree, - "warning: reference to compatibility globfree(); include for correct reference") - -#define stat __compat_stat -#define lstat __compat_lstat -#define fstat __compat_fstat - -#include "gen/glob.c" diff --git a/lib/libc/compat/gen/compat_lastlogx.c b/lib/libc/compat/gen/compat_lastlogx.c deleted file mode 100644 index 8d1af36c2..000000000 --- a/lib/libc/compat/gen/compat_lastlogx.c +++ /dev/null @@ -1,91 +0,0 @@ -/* $NetBSD: compat_lastlogx.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_lastlogx.c,v 1.2 2009/01/11 02:46:25 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -/* don't define earlier, has side effects in fcntl.h */ -#define __LIBC12_SOURCE__ -#include -#include - -__warn_references(getlastlogx, - "warning: reference to compatibility getlastlogx(); include for correct reference") -__warn_references(lastlogxname, - "warning: reference to deprecated lastlogxname()") - -static char llfile[MAXPATHLEN] = _PATH_LASTLOGX; - -int -lastlogxname(const char *fname) -{ - size_t len; - - _DIAGASSERT(fname != NULL); - - len = strlen(fname); - - if (len >= sizeof(llfile)) - return 0; - - /* must end in x! */ - if (fname[len - 1] != 'x') - return 0; - - (void)strlcpy(llfile, fname, sizeof(llfile)); - return 1; -} - -struct lastlogx * -getlastlogx(uid_t uid, struct lastlogx *ll) -{ - - return __getlastlogx13(llfile, uid, ll); -} diff --git a/lib/libc/compat/gen/compat_ldexp_ieee754.c b/lib/libc/compat/gen/compat_ldexp_ieee754.c deleted file mode 100644 index a21d385e2..000000000 --- a/lib/libc/compat/gen/compat_ldexp_ieee754.c +++ /dev/null @@ -1,143 +0,0 @@ -/* $NetBSD: compat_ldexp_ieee754.c,v 1.5 2010/04/23 19:04:54 drochner Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_ldexp_ieee754.c,v 1.5 2010/04/23 19:04:54 drochner Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -double ldexp(double, int); - -/* - * Multiply the given value by 2^expon. - */ -double -ldexp(double val, int expon) -{ - int oldexp, newexp; - union ieee_double_u u, mul; - - u.dblu_d = val; - oldexp = u.dblu_dbl.dbl_exp; - - /* - * If input is zero, Inf or NaN, just return it. - */ - if (u.dblu_d == 0.0 || oldexp == DBL_EXP_INFNAN) - return (val); - - if (oldexp == 0) { - /* - * u.v is denormal. We must adjust it so that the exponent - * arithmetic below will work. - */ - if (expon <= DBL_EXP_BIAS) { - /* - * Optimization: if the scaling can be done in a single - * multiply, or underflows, just do it now. - */ - if (expon <= -DBL_FRACBITS) { - errno = ERANGE; - return (val < 0.0 ? -0.0 : 0.0); - } - mul.dblu_d = 0.0; - mul.dblu_dbl.dbl_exp = expon + DBL_EXP_BIAS; - u.dblu_d *= mul.dblu_d; - if (u.dblu_d == 0.0) { - errno = ERANGE; - return (val < 0.0 ? -0.0 : 0.0); - } - return (u.dblu_d); - } else { - /* - * We know that expon is very large, and therefore the - * result cannot be denormal (though it may be Inf). - * Shift u.v by just enough to make it normal. - */ - mul.dblu_d = 0.0; - mul.dblu_dbl.dbl_exp = DBL_FRACBITS + DBL_EXP_BIAS; - u.dblu_d *= mul.dblu_d; - expon -= DBL_FRACBITS; - oldexp = u.dblu_dbl.dbl_exp; - } - } - - /* - * u.v is now normalized and oldexp has been adjusted if necessary. - * Calculate the new exponent and check for underflow and overflow. - */ - newexp = oldexp + expon; - - if (newexp <= 0) { - /* - * The output number is either denormal or underflows (see - * comments in machine/ieee.h). - */ - if (newexp <= -DBL_FRACBITS) { - errno = ERANGE; - return (val < 0.0 ? -0.0 : 0.0); - } - /* - * Denormalize the result. We do this with a multiply. If - * expon is very large, it won't fit in a double, so we have - * to adjust the exponent first. This is safe because we know - * that u.v is normal at this point. - */ - if (expon <= -DBL_EXP_BIAS) { - u.dblu_dbl.dbl_exp = 1; - expon += oldexp - 1; - } - mul.dblu_d = 0.0; - mul.dblu_dbl.dbl_exp = expon + DBL_EXP_BIAS; - u.dblu_d *= mul.dblu_d; - return (u.dblu_d); - } else if (newexp >= DBL_EXP_INFNAN) { - /* - * The result overflowed; return +/-Inf. - */ - u.dblu_dbl.dbl_exp = DBL_EXP_INFNAN; - u.dblu_dbl.dbl_frach = 0; - u.dblu_dbl.dbl_fracl = 0; - errno = ERANGE; - return (u.dblu_d); - } else { - /* - * The result is normal; just replace the old exponent with the - * new one. - */ - u.dblu_dbl.dbl_exp = newexp; - return (u.dblu_d); - } -} diff --git a/lib/libc/compat/gen/compat_modf_ieee754.c b/lib/libc/compat/gen/compat_modf_ieee754.c deleted file mode 100644 index 660697d6f..000000000 --- a/lib/libc/compat/gen/compat_modf_ieee754.c +++ /dev/null @@ -1,103 +0,0 @@ -/* $NetBSD: compat_modf_ieee754.c,v 1.4 2010/04/23 19:04:54 drochner 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 -#include -#include - -double modf(double, double *); - -/* - * 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(double val, double *iptr) -{ - union ieee_double_u u, v; - u_int64_t frac; - - /* - * If input is +/-Inf or NaN, return +/-0 or NaN. - */ - u.dblu_d = val; - if (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN) { - *iptr = u.dblu_d; - return (0.0 / u.dblu_d); - } - - /* - * If input can't have a fractional part, return - * (appropriately signed) zero, and make i be the input. - */ - if ((int)u.dblu_dbl.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) { - *iptr = u.dblu_d; - v.dblu_d = 0.0; - v.dblu_dbl.dbl_sign = u.dblu_dbl.dbl_sign; - return (v.dblu_d); - } - - /* - * If |input| < 1.0, return it, and set i to the appropriately - * signed zero. - */ - if (u.dblu_dbl.dbl_exp < DBL_EXP_BIAS) { - v.dblu_d = 0.0; - v.dblu_dbl.dbl_sign = u.dblu_dbl.dbl_sign; - *iptr = v.dblu_d; - return (u.dblu_d); - } - - /* - * 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.dblu_d = u.dblu_d; - /* Zero the low bits of the fraction, the sleazy way. */ - frac = ((u_int64_t)v.dblu_dbl.dbl_frach << 32) + v.dblu_dbl.dbl_fracl; - frac >>= DBL_FRACBITS - (u.dblu_dbl.dbl_exp - DBL_EXP_BIAS); - frac <<= DBL_FRACBITS - (u.dblu_dbl.dbl_exp - DBL_EXP_BIAS); - v.dblu_dbl.dbl_fracl = (unsigned int)frac & 0xffffffff; - v.dblu_dbl.dbl_frach = (unsigned int)(frac >> 32); - *iptr = v.dblu_d; - - u.dblu_d -= v.dblu_d; - u.dblu_dbl.dbl_sign = v.dblu_dbl.dbl_sign; - return (u.dblu_d); -} diff --git a/lib/libc/compat/gen/compat_opendir.c b/lib/libc/compat/gen/compat_opendir.c deleted file mode 100644 index 24eaef0b8..000000000 --- a/lib/libc/compat/gen/compat_opendir.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: compat_opendir.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include - -#ifdef __weak_alias -__weak_alias(opendir,_opendir) -#endif - -#ifdef __warn_references -__warn_references(opendir, - "warning: reference to compatibility opendir(); include for correct reference") -__warn_references(__opendir2, - "warning: reference to compatibility __opendir2(); include for correct reference") -#endif - -#define dirent dirent12 - -#include "gen/opendir.c" diff --git a/lib/libc/compat/gen/compat_readdir.c b/lib/libc/compat/gen/compat_readdir.c deleted file mode 100644 index 72d524377..000000000 --- a/lib/libc/compat/gen/compat_readdir.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_readdir.c,v 1.3 2012/02/08 12:10:17 mbalmer Exp $ */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(readdir,_readdir) -__weak_alias(readdir_r,_readdir_r) -#endif - -#ifdef __warn_references -__warn_references(readdir, - "warning: reference to compatibility readdir(); include for correct reference") -__warn_references(readdir_r, - "warning: reference to compatibility readdir_r(); include for correct reference") -#endif - -static struct dirent12 * -direnttodirent12(struct dirent12 *d12, const struct dirent *d) -{ - if (d == NULL) - return NULL; - - if (d->d_fileno > UINT_MAX || d->d_namlen >= sizeof(d12->d_name)) { - errno = ERANGE; - return NULL; - } - d12->d_fileno = (uint32_t)d->d_fileno; - d12->d_reclen = (uint16_t)d->d_reclen; - d12->d_namlen = (uint8_t)MIN(d->d_namlen, sizeof(d->d_name) - 1); - d12->d_type = (uint8_t)d->d_type; - memcpy(d12->d_name, d->d_name, (size_t)d12->d_namlen); - d12->d_name[d12->d_namlen] = '\0'; - return d12; -} - -struct dirent12 * -readdir(DIR *dirp) -{ - static struct dirent12 d12; - return direnttodirent12(&d12, __readdir30(dirp)); -} - -int -readdir_r(DIR *dirp, struct dirent12 *entry, struct dirent12 **result) -{ - int error; - struct dirent e, *ep; - - if ((error = __readdir_r30(dirp, &e, &ep)) != 0) - return error; - - *result = entry; - (void)direnttodirent12(entry, &e); - return 0; -} diff --git a/lib/libc/compat/gen/compat_scandir.c b/lib/libc/compat/gen/compat_scandir.c deleted file mode 100644 index 7aac0f257..000000000 --- a/lib/libc/compat/gen/compat_scandir.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: compat_scandir.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */ - -#include -#define __LIBC12_SOURCE__ -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(scandir,_scandir) -#endif - -#ifdef __warn_references -__warn_references(scandir, - "warning: reference to compatibility scandir(); include for correct reference") -#endif - -#define dirent dirent12 - -#include "gen/scandir.c" diff --git a/lib/libc/compat/gen/compat_siglist.c b/lib/libc/compat/gen/compat_siglist.c deleted file mode 100644 index 0627f4486..000000000 --- a/lib/libc/compat/gen/compat_siglist.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: compat_siglist.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)siglist.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_siglist.c,v 1.1 2005/09/13 01:44:09 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef __weak_alias -__weak_alias(sys_siglist, _sys_siglist) -__weak_alias(__sys_siglist, _sys_siglist) -#endif - -const char *const _sys_siglist[] = { - "Signal 0", - "Hangup", /* SIGHUP */ - "Interrupt", /* SIGINT */ - "Quit", /* SIGQUIT */ - "Illegal instruction", /* SIGILL */ - "Trace/BPT trap", /* SIGTRAP */ - "Abort trap", /* SIGABRT */ - "EMT trap", /* SIGEMT */ - "Floating point exception", /* SIGFPE */ - "Killed", /* SIGKILL */ - "Bus error", /* SIGBUS */ - "Segmentation fault", /* SIGSEGV */ - "Bad system call", /* SIGSYS */ - "Broken pipe", /* SIGPIPE */ - "Alarm clock", /* SIGALRM */ - "Terminated", /* SIGTERM */ - "Urgent I/O condition", /* SIGURG */ - "Suspended (signal)", /* SIGSTOP */ - "Suspended", /* SIGTSTP */ - "Continued", /* SIGCONT */ - "Child exited", /* SIGCHLD */ - "Stopped (tty input)", /* SIGTTIN */ - "Stopped (tty output)", /* SIGTTOU */ - "I/O possible", /* SIGIO */ - "Cputime limit exceeded", /* SIGXCPU */ - "Filesize limit exceeded", /* SIGXFSZ */ - "Virtual timer expired", /* SIGVTALRM */ - "Profiling timer expired", /* SIGPROF */ - "Window size changes", /* SIGWINCH */ - "Information request", /* SIGINFO */ - "User defined signal 1", /* SIGUSR1 */ - "User defined signal 2" /* SIGUSR2 */ -}; diff --git a/lib/libc/compat/gen/compat_signame.c b/lib/libc/compat/gen/compat_signame.c deleted file mode 100644 index b2dcddc67..000000000 --- a/lib/libc/compat/gen/compat_signame.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: compat_signame.c,v 1.1 2005/09/13 01:44:09 christos Exp $ */ - -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "from: @(#)siglist.c 5.6 (Berkeley) 2/23/91";*/ -#else -__RCSID("$NetBSD: compat_signame.c,v 1.1 2005/09/13 01:44:09 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -__warn_references(sys_signame, - "warning: reference to compatibility sys_signame[]; include for correct reference") - -const char *const sys_signame[] = { - "Signal 0", /* 0 */ - "HUP", /* 1 SIGHUP */ - "INT", /* 2 SIGINT */ - "QUIT", /* 3 SIGQUIT */ - "ILL", /* 4 SIGILL */ - "TRAP", /* 5 SIGTRAP */ - "ABRT", /* 6 SIGABRT */ - "EMT", /* 7 SIGEMT */ - "FPE", /* 8 SIGFPE */ - "KILL", /* 9 SIGKILL */ - "BUS", /* 10 SIGBUS */ - "SEGV", /* 11 SIGSEGV */ - "SYS", /* 12 SIGSYS */ - "PIPE", /* 13 SIGPIPE */ - "ALRM", /* 14 SIGALRM */ - "TERM", /* 15 SIGTERM */ - "URG", /* 16 SIGURG */ - "STOP", /* 17 SIGSTOP */ - "TSTP", /* 18 SIGTSTP */ - "CONT", /* 19 SIGCONT */ - "CHLD", /* 20 SIGCHLD */ - "TTIN", /* 21 SIGTTIN */ - "TTOU", /* 22 SIGTTOU */ - "IO", /* 23 SIGIO */ - "XCPU", /* 24 SIGXCPU */ - "XFSZ", /* 25 SIGXFSZ */ - "VTALRM", /* 26 SIGVTALRM */ - "PROF", /* 27 SIGPROF */ - "WINCH", /* 28 SIGWINCH */ - "INFO", /* 29 SIGINFO */ - "USR1", /* 30 SIGUSR1 */ - "USR2", /* 31 SIGUSR2 */ -}; diff --git a/lib/libc/compat/gen/compat_sigsetops.c b/lib/libc/compat/gen/compat_sigsetops.c deleted file mode 100644 index f7911b11e..000000000 --- a/lib/libc/compat/gen/compat_sigsetops.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: compat_sigsetops.c,v 1.3 2012/03/20 17:05:59 matt Exp $ */ - -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sigsetops.c 8.1 (Berkeley) 6/4/93 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sigsetops.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_sigsetops.c,v 1.3 2012/03/20 17:05:59 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include -#include - -#undef sigemptyset -#undef sigfillset -#undef sigaddset -#undef sigdelset -#undef sigismember - -__warn_references(sigaddset, - "warning: reference to compatibility sigaddset(); include for correct reference") -__warn_references(sigdelset, - "warning: reference to compatibility sigdelset(); include for correct reference") -__warn_references(sigemptyset, - "warning: reference to compatibility sigemptyset(); include for correct reference") -__warn_references(sigfillset, - "warning: reference to compatibility sigfillset(); include for correct reference") -__warn_references(sigismember, - "warning: reference to compatibility sigismember(); include for correct reference") - -int -sigemptyset(sigset13_t *set) -{ - *set = 0; - return (0); -} - -int -sigfillset(sigset13_t *set) -{ - *set = ~(sigset13_t)0; - return (0); -} - -int -sigaddset(sigset13_t *set, int signo) -{ - if (signo <= 0 || signo >= NSIG13) { - errno = EINVAL; - return -1; - } - *set |= __sigmask13(signo); - return (0); -} - -int -sigdelset(sigset13_t *set, int signo) -{ - if (signo <= 0 || signo >= NSIG13) { - errno = EINVAL; - return -1; - } - *set &= ~__sigmask13(signo); - return (0); -} - -int -sigismember(const sigset13_t *set, int signo) -{ - if (signo <= 0 || signo >= NSIG13) { - errno = EINVAL; - return -1; - } - return ((*set & __sigmask13(signo)) != 0); -} diff --git a/lib/libc/compat/gen/compat_syslog.c b/lib/libc/compat/gen/compat_syslog.c deleted file mode 100644 index e653463d4..000000000 --- a/lib/libc/compat/gen/compat_syslog.c +++ /dev/null @@ -1,205 +0,0 @@ -/* $NetBSD: compat_syslog.c,v 1.2 2012/10/11 17:09:55 christos Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include "namespace.h" -#include - -#define __LIBC12_SOURCE__ -#include - -#include -#include -#include - -void syslog_ss(int, struct syslog_data60 *, const char *, ...) - __printflike(3, 4); -void vsyslog_ss(int, struct syslog_data60 *, const char *, va_list) - __printflike(3, 0); -void syslogp_ss(int, struct syslog_data60 *, const char *, const char *, - const char *, ...) __printflike(5, 0); -void vsyslogp_ss(int, struct syslog_data60 *, const char *, const char *, - const char *, va_list) __printflike(5, 0); - -#ifdef __weak_alias -__weak_alias(closelog_r,_closelog_r) -__weak_alias(openlog_r,_openlog_r) -__weak_alias(setlogmask_r,_setlogmask_r) -__weak_alias(syslog_r,_syslog_r) -__weak_alias(vsyslog_r,_vsyslog_r) -__weak_alias(syslogp_r,_syslogp_r) -__weak_alias(vsyslogp_r,_vsyslogp_r) - -__weak_alias(syslog_ss,_syslog_ss) -__weak_alias(vsyslog_ss,_vsyslog_ss) -__weak_alias(syslogp_ss,_syslogp_ss) -__weak_alias(vsyslogp_ss,_vsyslogp_ss) -#endif /* __weak_alias */ - -__warn_references(closelog_r, - "warning: reference to compatibility closelog_r();" - " include for correct reference") -__warn_references(openlog_r, - "warning: reference to compatibility openlog_r();" - " include for correct reference") -__warn_references(setlogmask_r, - "warning: reference to compatibility setlogmask_r();" - " include for correct reference") -__warn_references(syslog_r, - "warning: reference to compatibility syslog_r();" - " include for correct reference") -__warn_references(vsyslog_r, - "warning: reference to compatibility vsyslog_r();" - " include for correct reference") -__warn_references(syslogp_r, - "warning: reference to compatibility syslogp_r();" - " include for correct reference") -__warn_references(vsyslogp_r, - "warning: reference to compatibility vsyslogp_r();" - " include for correct reference") - -static void -syslog_data_convert(struct syslog_data *d, const struct syslog_data60 *s) -{ - d->log_file = s->log_file; - d->log_connected = s->connected; - d->log_opened = s->opened; - d->log_stat = s->log_stat; - d->log_tag = s->log_tag; - d->log_fac = s->log_fac; - d->log_mask = s->log_mask; -} - -void -closelog_r(struct syslog_data60 *data60) -{ - struct syslog_data data = SYSLOG_DATA_INIT; - syslog_data_convert(&data, data60); - __closelog_r60(&data); -} - -void -openlog_r(const char *ident, int logstat, int logfac, - struct syslog_data60 *data60) -{ - struct syslog_data data = SYSLOG_DATA_INIT; - syslog_data_convert(&data, data60); - __openlog_r60(ident, logstat, logfac, &data); -} - -int -setlogmask_r(int pmask, struct syslog_data60 *data60) -{ - struct syslog_data data = SYSLOG_DATA_INIT; - syslog_data_convert(&data, data60); - return __setlogmask_r60(pmask, &data); -} - -void -syslog_r(int pri, struct syslog_data60 *data60, const char *fmt, ...) -{ - va_list ap; - struct syslog_data data = SYSLOG_DATA_INIT; - syslog_data_convert(&data, data60); - - va_start(ap, fmt); - __vsyslog_r60(pri, &data, fmt, ap); - va_end(ap); -} - -void -vsyslog_r(int pri, struct syslog_data60 *data60, const char *fmt, __va_list ap) -{ - struct syslog_data data = SYSLOG_DATA_INIT; - syslog_data_convert(&data, data60); - __vsyslog_r60(pri, &data, fmt, ap); -} - -void -syslogp_r(int pri, struct syslog_data60 *data60, const char *msgid, - const char *sdfmt, const char *msgfmt, ...) -{ - va_list ap; - struct syslog_data data = SYSLOG_DATA_INIT; - syslog_data_convert(&data, data60); - - va_start(ap, msgfmt); - __vsyslogp_r60(pri, &data, msgid, sdfmt, msgfmt, ap); - va_end(ap); -} - -void -vsyslogp_r(int pri, struct syslog_data60 *data60, const char *msgid, - const char *sdfmt, const char *msgfmt, __va_list ap) -{ - struct syslog_data data = SYSLOG_DATA_INIT; - syslog_data_convert(&data, data60); - - __vsyslogp_r60(pri, &data, msgid, sdfmt, msgfmt, ap); -} - -/* - * These are semi-private - */ -#define LOG_SIGNAL_SAFE (int)0x80000000 - -void -syslog_ss(int pri, struct syslog_data60 *data, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsyslog_r(pri | LOG_SIGNAL_SAFE, data, fmt, ap); - va_end(ap); -} - -void -syslogp_ss(int pri, struct syslog_data60 *data, const char *msgid, - const char *sdfmt, const char *msgfmt, ...) -{ - va_list ap; - - va_start(ap, msgfmt); - vsyslogp_r(pri | LOG_SIGNAL_SAFE, data, msgid, sdfmt, msgfmt, ap); - va_end(ap); -} - -void -vsyslog_ss(int pri, struct syslog_data60 *data, const char *fmt, va_list ap) -{ - vsyslog_r(pri | LOG_SIGNAL_SAFE, data, fmt, ap); -} - -void -vsyslogp_ss(int pri, struct syslog_data60 *data, const char *msgid, - const char *sdfmt, const char *msgfmt, va_list ap) -{ - vsyslogp_r(pri | LOG_SIGNAL_SAFE, data, msgid, sdfmt, msgfmt, ap); -} diff --git a/lib/libc/compat/gen/compat_time.c b/lib/libc/compat/gen/compat_time.c deleted file mode 100644 index 7bb93e57c..000000000 --- a/lib/libc/compat/gen/compat_time.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $NetBSD: compat_time.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Written by Jason R. Thorpe , October 21, 1997. - * Public domain. - */ - -#include "namespace.h" -#include - -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(time,_time) -#endif - -__warn_references(time, - "warning: reference to compatibility time();" - " include for correct reference") - -#define timeval timeval50 -#define time_t int32_t - -#define gettimeofday __compat_gettimeofday - -#include "gen/time.c" diff --git a/lib/libc/compat/gen/compat_times.c b/lib/libc/compat/gen/compat_times.c deleted file mode 100644 index 6d11b55de..000000000 --- a/lib/libc/compat/gen/compat_times.c +++ /dev/null @@ -1,31 +0,0 @@ -/* $NetBSD: compat_times.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Ben Harris, 2002. - * This file is in the Public Domain. - */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(times,_times) -#endif - -__warn_references(times, - "warning: reference to compatibility times(); include for correct reference") - -#define __times_rusage struct rusage50 -#define __times_timeval struct timeval50 - -#define getrusage __compat_getrusage -#define gettimeofday __compat_gettimeofday - -#include "gen/times.c" diff --git a/lib/libc/compat/gen/compat_timezone.c b/lib/libc/compat/gen/compat_timezone.c deleted file mode 100644 index 5c6165211..000000000 --- a/lib/libc/compat/gen/compat_timezone.c +++ /dev/null @@ -1,141 +0,0 @@ -/* $NetBSD: compat_timezone.c,v 1.4 2012/03/20 17:05:59 matt Exp $ */ - -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)timezone.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_timezone.c,v 1.4 2012/03/20 17:05:59 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -__warn_references(timezone, - "warning: reference to compatibility timezone; include to generate correct reference") - -/* - * timezone -- - * The arguments are the number of minutes of time you are westward - * from Greenwich and whether DST is in effect. It returns a string - * giving the name of the local timezone. Should be replaced, in the - * application code, by a call to localtime. - */ - -char *_tztab(int, int); - -static char czone[TZ_MAX_CHARS]; /* space for zone name */ - -char *timezone(int, int); -char * -timezone(int zone, int dst) -{ - char *beg, - *end; - - if ((beg = getenv("TZNAME")) != NULL) { /* set in environment */ - if ((end = strchr(beg, ',')) != NULL) { /* "PST,PDT" */ - if (dst) - return(++end); - *end = '\0'; - (void)strlcpy(czone, beg, sizeof(czone)); - *end = ','; - return(czone); - } - return(beg); - } - return(_tztab(zone,dst)); /* default: table or created zone */ -} - -static const struct zone { - int offset; - const char *stdzone; - const char *dlzone; -} zonetab[] = { - { -1*60, "MET", "MET DST" }, /* Middle European */ - { -2*60, "EET", "EET DST" }, /* Eastern European */ - { 4*60, "AST", "ADT" }, /* Atlantic */ - { 5*60, "EST", "EDT" }, /* Eastern */ - { 6*60, "CST", "CDT" }, /* Central */ - { 7*60, "MST", "MDT" }, /* Mountain */ - { 8*60, "PST", "PDT" }, /* Pacific */ -#ifdef notdef - /* there's no way to distinguish this from WET */ - { 0, "GMT", 0 }, /* Greenwich */ -#endif - { 0*60, "WET", "WET DST" }, /* Western European */ - { -10*60, "EST", "EST" }, /* Aust: Eastern */ - { -10*60+30, "CST", "CST" }, /* Aust: Central */ - { -8*60, "WST", 0 }, /* Aust: Western */ - { -1, NULL, NULL } -}; - -/* - * _tztab -- - * check static tables or create a new zone name; broken out so that - * we can make a guess as to what the zone is if the standard tables - * aren't in place in /etc. DO NOT USE THIS ROUTINE OUTSIDE OF THE - * STANDARD LIBRARY. - */ -char * -_tztab(int zone, int dst) -{ - const struct zone *zp; - char sign; - - for (zp = zonetab; zp->offset != -1;++zp) /* static tables */ - if (zp->offset == zone) { - if (dst && zp->dlzone) - return __UNCONST(zp->dlzone); - if (!dst && zp->stdzone) - return __UNCONST(zp->stdzone); - } - - if (zone < 0) { /* create one */ - zone = -zone; - sign = '+'; - } - else - sign = '-'; - (void)snprintf(czone, TZ_MAX_CHARS, "GMT%c%d:%02d", sign, zone / 60, - zone % 60); - return(czone); -} diff --git a/lib/libc/compat/gen/compat_unvis.c b/lib/libc/compat/gen/compat_unvis.c deleted file mode 100644 index fb529a59f..000000000 --- a/lib/libc/compat/gen/compat_unvis.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: compat_unvis.c,v 1.3 2011/03/12 19:52:47 christos Exp $ */ - -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_unvis.c,v 1.3 2011/03/12 19:52:47 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#ifdef __warn_references -__warn_references(unvis, - "warning: reference to compatibility unvis(); include for correct reference") -#endif - -int -unvis(char *cp, int c, int *astate, int flag) -{ - flag = (flag & ~1) | ((flag & 1) ? UNVIS_END : 0); - return __unvis50(cp, c, astate, flag); -} diff --git a/lib/libc/compat/gen/compat_utime.c b/lib/libc/compat/gen/compat_utime.c deleted file mode 100644 index 1c9c0e3e9..000000000 --- a/lib/libc/compat/gen/compat_utime.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: compat_utime.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)utime.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_utime.c,v 1.2 2009/01/11 02:46:25 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include - -__warn_references(utime, - "warning: reference to compatibility utime(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(utime, _utime) -#endif - -int -utime(const char *path, const struct utimbuf50 *times50) -{ - struct timeval tv[2], *tvp; - - _DIAGASSERT(path != NULL); - - if (times50 == NULL) - tvp = NULL; - else { - tv[0].tv_sec = times50->actime; - tv[1].tv_sec = times50->modtime; - tv[0].tv_usec = tv[1].tv_usec = 0; - tvp = tv; - } - return __utimes50(path, tvp); -} diff --git a/lib/libc/compat/gen/compat_utmp.c b/lib/libc/compat/gen/compat_utmp.c deleted file mode 100644 index be986822e..000000000 --- a/lib/libc/compat/gen/compat_utmp.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: compat_utmp.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_utmp.c,v 1.2 2009/01/11 02:46:25 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include -#include -#include -#include -#include - -__warn_references(getutent, - "warning: reference to compatibility getutent(); include for correct reference") - -static struct utmp50 * -cvt(struct utmp *ut) -{ - struct utmp50 *ut50 = (void *)ut; - if (ut == NULL) - return NULL; - ut50->ut_time = (int32_t)ut->ut_time; - return ut50; -} - -struct utmp50 * -getutent(void) -{ - return cvt(__getutent50()); -} diff --git a/lib/libc/compat/gen/compat_utmpx.c b/lib/libc/compat/gen/compat_utmpx.c deleted file mode 100644 index ad3beb67f..000000000 --- a/lib/libc/compat/gen/compat_utmpx.c +++ /dev/null @@ -1,194 +0,0 @@ -/* $NetBSD: compat_utmpx.c,v 1.4 2011/07/01 01:08:59 joerg Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_utmpx.c,v 1.4 2011/07/01 01:08:59 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#define __LIBC12_SOURCE__ -#include -#include -#include -#include -#include -#include - -__warn_references(getutxent, - "warning: reference to compatibility getutxent(); include for correct reference") -__warn_references(getutxid, - "warning: reference to compatibility getutxid(); include for correct reference") -__warn_references(getutxline, - "warning: reference to compatibility getutxline(); include for correct reference") -__warn_references(pututxline, - "warning: reference to compatibility pututxline(); include for correct reference") -__warn_references(updwtmpx, - "warning: reference to compatibility updwtmpx(); include for correct reference") -__warn_references(getlastlogx, - "warning: reference to compatibility getlastlogx(); include for correct reference") -__warn_references(updlastlogx, - "warning: reference to compatibility updlastlogx(); include for correct reference") -__warn_references(getutmp, - "warning: reference to compatibility getutmp(); include for correct reference") -__warn_references(getutmpx, - "warning: reference to compatibility getutmpx(); include for correct reference") - -static struct utmpx50 * -cvt(struct utmpx *ut) -{ - if (ut == NULL) - return NULL; - timeval_to_timeval50(&ut->ut_tv, (void *)&ut->ut_tv); - return (void *)ut; -} - -static void -lastlogx50_to_lastlogx(const struct lastlogx50 *ll50, struct lastlogx *ll) -{ - (void)memcpy(ll->ll_line, ll50->ll_line, sizeof(ll->ll_line)); - (void)memcpy(ll->ll_host, ll50->ll_host, sizeof(ll->ll_host)); - (void)memcpy(&ll->ll_ss, &ll50->ll_ss, sizeof(ll->ll_ss)); - timeval50_to_timeval(&ll50->ll_tv, &ll->ll_tv); -} - -static void -lastlogx_to_lastlogx50(const struct lastlogx *ll, struct lastlogx50 *ll50) -{ - (void)memcpy(ll50->ll_line, ll->ll_line, sizeof(ll50->ll_line)); - (void)memcpy(ll50->ll_host, ll->ll_host, sizeof(ll50->ll_host)); - (void)memcpy(&ll50->ll_ss, &ll->ll_ss, sizeof(ll50->ll_ss)); - timeval_to_timeval50(&ll->ll_tv, &ll50->ll_tv); -} - -struct utmpx50 * -getutxent(void) -{ - return cvt(__getutxent50()); -} - -struct utmpx50 * -getutxid(const struct utmpx50 *ut50) -{ - struct utmpx ut; - utmpx50_to_utmpx(ut50, &ut); - return cvt(__getutxid50(&ut)); -} - -struct utmpx50 * -getutxline(const struct utmpx50 *ut50) -{ - struct utmpx ut; - utmpx50_to_utmpx(ut50, &ut); - return cvt(__getutxline50(&ut)); -} - -struct utmpx50 * -pututxline(const struct utmpx50 *ut50) -{ - struct utmpx ut; - utmpx50_to_utmpx(ut50, &ut); - return cvt(__pututxline50(&ut)); -} - -int -updwtmpx(const char *fname, const struct utmpx50 *ut50) -{ - struct utmpx ut; - utmpx50_to_utmpx(ut50, &ut); - return __updwtmpx50(fname, &ut); -} - -struct lastlogx50 * -__getlastlogx13(const char *fname, uid_t uid, struct lastlogx50 *ll50) -{ - struct lastlogx ll; - if (__getlastlogx50(fname, uid, &ll) == NULL) - return NULL; - lastlogx_to_lastlogx50(&ll, ll50); - return ll50; -} - -static char llfile[MAXPATHLEN] = _PATH_LASTLOGX; - -int -lastlogxname(const char *fname) -{ - size_t len; - - _DIAGASSERT(fname != NULL); - - len = strlen(fname); - - if (len >= sizeof(llfile)) - return 0; - - /* must end in x! */ - if (fname[len - 1] != 'x') - return 0; - - (void)strlcpy(llfile, fname, sizeof(llfile)); - return 1; -} - -struct lastlogx50 * -getlastlogx(uid_t uid, struct lastlogx50 *ll) -{ - - return __getlastlogx13(llfile, uid, ll); -} - -int -updlastlogx(const char *fname, uid_t uid, struct lastlogx50 *ll50) -{ - struct lastlogx ll; - lastlogx50_to_lastlogx(ll50, &ll); - return __updlastlogx50(fname, uid, &ll); -} - -void -getutmp(const struct utmpx50 *utx50, struct utmp *ut) -{ - struct utmpx utx; - utmpx50_to_utmpx(utx50, &utx); - __getutmp50(&utx, ut); -} - -void -getutmpx(const struct utmp *ut, struct utmpx50 *utx50) -{ - struct utmpx utx; - __getutmpx50(ut, &utx); - utmpx_to_utmpx50(&utx, utx50); -} diff --git a/lib/libc/compat/include/aio.h b/lib/libc/compat/include/aio.h deleted file mode 100644 index 60d80ee20..000000000 --- a/lib/libc/compat/include/aio.h +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: aio.h,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _COMPAT_AIO_H_ -#define _COMPAT_AIO_H_ - -__BEGIN_DECLS -struct aiocb; -struct timespec50; -struct timespec; -int aio_suspend(const struct aiocb * const [], int, - const struct timespec50 *); -int __aio_suspend50(const struct aiocb * const [], int, - const struct timespec *); -__END_DECLS - -#endif /* _COMPAT_AIO_H_ */ diff --git a/lib/libc/compat/include/dirent.h b/lib/libc/compat/include/dirent.h deleted file mode 100644 index f41fc32f9..000000000 --- a/lib/libc/compat/include/dirent.h +++ /dev/null @@ -1,78 +0,0 @@ -/* $NetBSD: dirent.h,v 1.7 2009/02/24 18:42:36 christos Exp $ */ - -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)dirent.h 8.2 (Berkeley) 7/28/94 - */ - -#ifndef _COMPAT_DIRENT_H_ -#define _COMPAT_DIRENT_H_ - -#include - -__BEGIN_DECLS - -DIR *opendir(const char *); -DIR *__opendir30(const char *); - -int readdir_r(DIR *, struct dirent12 * __restrict, - struct dirent12 ** __restrict); -int __readdir_r30(DIR * __restrict, struct dirent * __restrict, - struct dirent ** __restrict); - -struct dirent12 *readdir(DIR *); -struct dirent *__readdir30(DIR *); - -#if defined(_NETBSD_SOURCE) - -struct dirent12 *_readdir_unlocked(DIR *, int); -struct dirent *___readdir_unlocked50(DIR *, int); -struct dirent *___readdir_unlocked30(DIR *); - -DIR *__opendir2(const char *, int); -DIR *__opendir230(const char *, int); - -int scandir(const char *, struct dirent12 ***, - int (*)(const struct dirent12 *), int (*)(const void *, const void *)); -int __scandir30(const char *, struct dirent ***, - int (*)(const struct dirent *), int (*)(const void *, const void *)); - -int getdents(int, char *, size_t); -int __getdents30(int, char *, size_t); - -int alphasort(const void *, const void *); -int __alphasort30(const void *, const void *); - -int getdirentries(int, char *, int, long *); - -#endif /* defined(_NETBSD_SOURCE) */ - -__END_DECLS - -#endif /* !_COMPAT_DIRENT_H_ */ diff --git a/lib/libc/compat/include/fstypes.h b/lib/libc/compat/include/fstypes.h deleted file mode 100644 index 06868b768..000000000 --- a/lib/libc/compat/include/fstypes.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: fstypes.h,v 1.4 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _COMPAT_FSTYPES_H_ -#define _COMPAT_FSTYPES_H_ - -#include - -/* Old, fixed size filehandle structures (used upto (including) 3.x) */ -struct compat_30_fid { - unsigned short fid30_len; - unsigned short fid30_reserved; - char fid30_data[16]; -}; -struct compat_30_fhandle { - fsid_t fh_fsid; - struct compat_30_fid fh_fid; -}; - -#define FHANDLE30_SIZE sizeof(struct compat_30_fhandle) /* 28 */ - -#endif /* _COMPAT_FSTYPES_H_ */ diff --git a/lib/libc/compat/include/fts.h b/lib/libc/compat/include/fts.h deleted file mode 100644 index de95bcfd6..000000000 --- a/lib/libc/compat/include/fts.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: fts.h,v 1.1 2005/09/13 01:44:09 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)fts.h 8.3 (Berkeley) 8/14/94 - */ - -#ifndef _COMPAT_FTS_H_ -#define _COMPAT_FTS_H_ - -__BEGIN_DECLS -FTSENT *fts_children(FTS *, int); -int fts_close(FTS *); -FTS *fts_open(char * const *, int, - int (*)(const FTSENT **, const FTSENT **)); -FTSENT *fts_read(FTS *); -int fts_set(FTS *, FTSENT *, int); -__END_DECLS - -#endif /* !_COMPAT_FTS_H_ */ diff --git a/lib/libc/compat/include/glob.h b/lib/libc/compat/include/glob.h deleted file mode 100644 index cd6860724..000000000 --- a/lib/libc/compat/include/glob.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: glob.h,v 1.1 2005/09/13 01:44:09 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * 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. - * - * @(#)glob.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _COMPAT_GLOB_H_ -#define _COMPAT_GLOB_H_ - -__BEGIN_DECLS -int glob(const char * __restrict, int, - int (*)(const char *, int), glob_t * __restrict); -void globfree(glob_t *); -__END_DECLS - -#endif /* !_COMPAT_GLOB_H_ */ diff --git a/lib/libc/compat/include/locale.h b/lib/libc/compat/include/locale.h deleted file mode 100644 index 455be3079..000000000 --- a/lib/libc/compat/include/locale.h +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: locale.h,v 1.1 2010/06/07 13:52:30 tnozaki Exp $ */ - -/* - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)locale.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _COMPAT_LOCALE_H_ -#define _COMPAT_LOCALE_H_ - -#define _LC_LAST 7 /* marks end */ - -__BEGIN_DECLS -char *setlocale(int, const char *); -char *__setlocale_mb_len_max_32(int, const char *); -__END_DECLS - -#endif /* _COMPAT_LOCALE_H_ */ diff --git a/lib/libc/compat/include/lwp.h b/lib/libc/compat/include/lwp.h deleted file mode 100644 index 3d67d76d5..000000000 --- a/lib/libc/compat/include/lwp.h +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: lwp.h,v 1.4 2014/01/31 20:45:49 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _COMPAT_LWP_H_ -#define _COMPAT_LWP_H_ - -__BEGIN_DECLS -struct timespec50; -int _lwp_park(const struct timespec50 *, lwpid_t, const void *, const void *); -int ___lwp_park50(const struct timespec *, lwpid_t, const void *, const void *); -int ___lwp_park60(clockid_t, int, const struct timespec *, lwpid_t, - const void *, const void *); -__END_DECLS - -#endif /* !_COMPAT_LWP_H_ */ diff --git a/lib/libc/compat/include/mqueue.h b/lib/libc/compat/include/mqueue.h deleted file mode 100644 index dd0cf61d8..000000000 --- a/lib/libc/compat/include/mqueue.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: mqueue.h,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _COMPAT_MQUEUE_H_ -#define _COMPAT_MQUEUE_H_ - -__BEGIN_DECLS -ssize_t mq_timedreceive(mqd_t, char * __restrict, size_t, - unsigned * __restrict, const struct timespec50 * __restrict); -int mq_timedsend(mqd_t, const char *, size_t, unsigned, - const struct timespec50 *); -ssize_t __mq_timedreceive50(mqd_t, char * __restrict, size_t, - unsigned * __restrict, const struct timespec * __restrict); -int __mq_timedsend50(mqd_t, const char *, size_t, unsigned, - const struct timespec *); -__END_DECLS - -#endif /* _COMPAT_MQUEUE_H_ */ diff --git a/lib/libc/compat/include/ndbm.h b/lib/libc/compat/include/ndbm.h deleted file mode 100644 index 99a0a9b22..000000000 --- a/lib/libc/compat/include/ndbm.h +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: ndbm.h,v 1.1 2005/09/13 01:44:09 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - * - * @(#)ndbm.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _COMPAT_NDBM_H_ -#define _COMPAT_NDBM_H_ - -typedef struct { - void *dptr; - int dsize; -} datum12; - -__BEGIN_DECLS -int dbm_delete(DBM *, datum12); -datum12 dbm_fetch(DBM *, datum12); -datum12 dbm_firstkey(DBM *); -datum12 dbm_nextkey(DBM *); -int dbm_store(DBM *, datum12, datum12, int); -__END_DECLS - -#endif /* !_COMPAT_NDBM_H_ */ diff --git a/lib/libc/compat/include/ns.h b/lib/libc/compat/include/ns.h deleted file mode 100644 index 97d9cd473..000000000 --- a/lib/libc/compat/include/ns.h +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: ns.h,v 1.1 2006/08/26 16:07:01 matt Exp $ */ - -/* - * Copyright (c) 1984, 1985, 1986, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)ns.h 8.1 (Berkeley) 6/10/93 - */ - -#ifndef _NETNS_NS_H_ -#define _NETNS_NS_H_ - -/* - * NS addressing - */ -union ns_host { - u_int8_t c_host[6]; - u_int16_t s_host[3]; -}; - -union ns_net { - u_int8_t c_net[4]; - u_int16_t s_net[2]; -}; - -union ns_net_u { - union ns_net net_e; - u_int32_t long_e; -}; - -struct ns_addr { - union ns_net x_net; - union ns_host x_host; - u_int16_t x_port; -}; - -__BEGIN_DECLS -extern struct ns_addr ns_addr __P((const char *)); -extern char *ns_ntoa __P((struct ns_addr)); -__END_DECLS - -#endif /* !_NETNS_NS_H_ */ diff --git a/lib/libc/compat/include/pwd.h b/lib/libc/compat/include/pwd.h deleted file mode 100644 index b9a805aaa..000000000 --- a/lib/libc/compat/include/pwd.h +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: pwd.h,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -#ifndef _COMPAT_PWD_H_ -#define _COMPAT_PWD_H_ - -#include -#include -#include - -struct passwd; -struct passwd50 { - __aconst char *pw_name; /* user name */ - __aconst char *pw_passwd; /* encrypted password */ - uid_t pw_uid; /* user uid */ - gid_t pw_gid; /* user gid */ - int32_t pw_change; /* password change time */ - __aconst char *pw_class; /* user login class */ - __aconst char *pw_gecos; /* general information */ - __aconst char *pw_dir; /* home directory */ - __aconst char *pw_shell; /* default shell */ - int32_t pw_expire; /* account expiration */ -}; - -__BEGIN_DECLS -static __inline void -passwd_to_passwd50(const struct passwd *p, struct passwd50 *q) -{ - q->pw_name = p->pw_name; - q->pw_passwd = p->pw_passwd; - q->pw_uid = p->pw_uid; - q->pw_gid = p->pw_gid; - q->pw_change = (int32_t)p->pw_change; - q->pw_class = p->pw_class; - q->pw_gecos = p->pw_gecos; - q->pw_dir = p->pw_dir; - q->pw_shell = p->pw_shell; - q->pw_expire = (int32_t)p->pw_expire; -} - -static __inline void -passwd50_to_passwd(const struct passwd50 *p, struct passwd *q) -{ - q->pw_name = p->pw_name; - q->pw_passwd = p->pw_passwd; - q->pw_uid = p->pw_uid; - q->pw_gid = p->pw_gid; - q->pw_change = p->pw_change; - q->pw_class = p->pw_class; - q->pw_gecos = p->pw_gecos; - q->pw_dir = p->pw_dir; - q->pw_shell = p->pw_shell; - q->pw_expire = p->pw_expire; -} - -struct passwd50 *getpwuid(uid_t); -struct passwd50 *getpwnam(const char *); -#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ - defined(_REENTRANT) || defined(_NETBSD_SOURCE) -int getpwnam_r(const char *, struct passwd50 *, char *, size_t, - struct passwd50 **); -int getpwuid_r(uid_t, struct passwd50 *, char *, size_t, - struct passwd50 **); -#endif -#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) -struct passwd50 *getpwent(void); -#endif -#if defined(_NETBSD_SOURCE) -int pw_scan(char *, struct passwd50 *, int *); -int getpwent_r(struct passwd50 *, char *, size_t, struct passwd50 **); -#endif -#if defined(_NETBSD_SOURCE) -int pwcache_userdb(int (*)(int), void (*)(void), - struct passwd50 * (*)(const char *), struct passwd50 * (*)(uid_t)); -#endif - -struct passwd *__getpwuid50(uid_t); -struct passwd *__getpwnam50(const char *); -#if (_POSIX_C_SOURCE - 0) >= 199506L || (_XOPEN_SOURCE - 0) >= 500 || \ - defined(_REENTRANT) || defined(_NETBSD_SOURCE) -int __getpwnam_r50(const char *, struct passwd *, char *, size_t, - struct passwd **); -int __getpwuid_r50(uid_t, struct passwd *, char *, size_t, - struct passwd **); -#endif -#if defined(_XOPEN_SOURCE) || defined(_NETBSD_SOURCE) -struct passwd *__getpwent50(void); -#endif -#if defined(_NETBSD_SOURCE) -int __pw_scan50(char *, struct passwd *, int *); -int __getpwent_r50(struct passwd *, char *, size_t, struct passwd **); -#endif -int setpassent(int); -#if defined(_NETBSD_SOURCE) -int __pwcache_userdb50(int (*)(int), void (*)(void), - struct passwd * (*)(const char *), struct passwd * (*)(uid_t)); -#endif -__END_DECLS - -#endif /* !_COMPAT_PWD_H_ */ diff --git a/lib/libc/compat/include/rpc/pmap_clnt.h b/lib/libc/compat/include/rpc/pmap_clnt.h deleted file mode 100644 index 5e075c2c5..000000000 --- a/lib/libc/compat/include/rpc/pmap_clnt.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: pmap_clnt.h,v 1.2 2009/01/11 03:56:22 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _COMPAT_RPC_PMAP_CLNT_H_ -#define _COMPAT_RPC_PMAP_CLNT_H_ -#include - -__BEGIN_DECLS -extern enum clnt_stat pmap_rmtcall(struct sockaddr_in *, - u_long, u_long, u_long, xdrproc_t, caddr_t, xdrproc_t, caddr_t, - struct timeval50, u_long *); -extern enum clnt_stat __pmap_rmtcall50(struct sockaddr_in *, - u_long, u_long, u_long, xdrproc_t, caddr_t, xdrproc_t, caddr_t, - struct timeval, u_long *); -__END_DECLS - -#endif /* !_RPC_PMAP_CLNT_H_ */ diff --git a/lib/libc/compat/include/rpc/rpcb_clnt.h b/lib/libc/compat/include/rpc/rpcb_clnt.h deleted file mode 100644 index e751b659b..000000000 --- a/lib/libc/compat/include/rpc/rpcb_clnt.h +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: rpcb_clnt.h,v 1.2 2009/01/11 03:56:22 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _COMPAT_RPC_RPCB_CLNT_H -#define _COMPAT_RPC_RPCB_CLNT_H - -__BEGIN_DECLS - -extern enum clnt_stat rpcb_rmtcall(const struct netconfig *, - const char *, const rpcprog_t, const rpcvers_t, const rpcproc_t, - const xdrproc_t, const char *, const xdrproc_t, caddr_t, - const struct timeval50, const struct netbuf *); -extern bool_t rpcb_gettime(const char *, int32_t *); -extern enum clnt_stat __rpcb_rmtcall50(const struct netconfig *, - const char *, const rpcprog_t, const rpcvers_t, const rpcproc_t, - const xdrproc_t, const char *, const xdrproc_t, caddr_t, - const struct timeval, const struct netbuf *); -extern bool_t __rpcb_gettime50(const char *, time_t *); - -__END_DECLS - -#endif /* !_COMPAT_RPC_RPCB_CLNT_H */ diff --git a/lib/libc/compat/include/setjmp.h b/lib/libc/compat/include/setjmp.h deleted file mode 100644 index 9998e185a..000000000 --- a/lib/libc/compat/include/setjmp.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: setjmp.h,v 1.2 2011/11/05 09:27:06 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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. - * - * @(#)setjmp.h 8.2 (Berkeley) 1/21/94 - */ - -#ifndef _COMPAT_SETJMP_H_ -#define _COMPAT_SETJMP_H_ - -__BEGIN_DECLS -int __setjmp14(jmp_buf) __returns_twice; -void __longjmp14(jmp_buf, int) __dead; - -int __sigsetjmp14(sigjmp_buf, int) __returns_twice; -void __siglongjmp14(sigjmp_buf, int) __dead; -__END_DECLS - -#endif /* !_COMPAT_SETJMP_H_ */ diff --git a/lib/libc/compat/include/signal.h b/lib/libc/compat/include/signal.h deleted file mode 100644 index e78a2a906..000000000 --- a/lib/libc/compat/include/signal.h +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: signal.h,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)signal.h 8.3 (Berkeley) 3/30/94 - */ - -#ifndef _COMPAT_SIGNAL_H_ -#define _COMPAT_SIGNAL_H_ - -#include - -__BEGIN_DECLS -int sigaction(int, const struct sigaction13 * __restrict, - struct sigaction13 * __restrict); -int __sigaction14(int, const struct sigaction * __restrict, - struct sigaction * __restrict); -int sigaddset(sigset13_t *, int); -int __sigaddset14(sigset_t *, int); -int sigdelset(sigset13_t *, int); -int __sigdelset14(sigset_t *, int); -int sigemptyset(sigset13_t *); -int __sigemptyset14(sigset_t *); -int sigfillset(sigset13_t *); -int __sigfillset14(sigset_t *); -int sigismember(const sigset13_t *, int); -int __sigismember14(const sigset_t *, int); -int sigpending(sigset13_t *); -int __sigpending14(sigset_t *); -int sigprocmask(int, const sigset13_t * __restrict, - sigset13_t * __restrict); -int __sigprocmask14(int, const sigset_t * __restrict, - sigset_t * __restrict); -int sigsuspend(const sigset13_t *); -int __sigsuspend14(const sigset_t *); - -int sigtimedwait(const sigset_t * __restrict, - siginfo_t * __restrict, const struct timespec50 * __restrict); -int __sigtimedwait(const sigset_t * __restrict, - siginfo_t * __restrict, struct timespec50 * __restrict); -int __sigtimedwait50(const sigset_t * __restrict, - siginfo_t * __restrict, const struct timespec * __restrict); -int ____sigtimedwait50(const sigset_t * __restrict, - siginfo_t * __restrict, struct timespec * __restrict); -/* - * X/Open CAE Specification Issue 4 Version 2 - */ -#if (defined(_XOPEN_SOURCE) && defined(_XOPEN_SOURCE_EXTENDED)) || \ - (_XOPEN_SOURCE - 0) >= 500 || defined(_NETBSD_SOURCE) -int sigaltstack(const struct sigaltstack13 * __restrict, - struct sigaltstack13 * __restrict); -int __sigaltstack14(const stack_t * __restrict, stack_t * __restrict); -#endif /* _XOPEN_SOURCE_EXTENDED || _XOPEN_SOURCE >= 500 || _NETBSD_SOURCE */ - -__END_DECLS - -#endif /* !_COMPAT_SIGNAL_H_ */ diff --git a/lib/libc/compat/include/stdio.h b/lib/libc/compat/include/stdio.h deleted file mode 100644 index b58852f8f..000000000 --- a/lib/libc/compat/include/stdio.h +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: stdio.h,v 1.1 2012/01/22 18:36:14 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * 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. - * - * @(#)stdio.h 8.5 (Berkeley) 4/29/95 - * - */ - -#ifndef _COMPAT_STDIO_H_ -#define _COMPAT_STDIO_H_ - -__BEGIN_DECLS -int fgetpos(FILE * __restrict, off_t * __restrict); -int fsetpos(FILE *, const off_t *); -__END_DECLS - -#endif /* _COMPAT_STDIO_H_ */ diff --git a/lib/libc/compat/include/stdlib.h b/lib/libc/compat/include/stdlib.h deleted file mode 100644 index 4b9961075..000000000 --- a/lib/libc/compat/include/stdlib.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: stdlib.h,v 1.7 2014/06/12 18:50:12 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)stdlib.h 8.5 (Berkeley) 5/19/95 - */ - -#ifndef _COMPAT_STDLIB_H_ -#define _COMPAT_STDLIB_H_ - -__BEGIN_DECLS - -void unsetenv(const char *); -int __unsetenv13(const char *); -int putenv(char *); -int __putenv50(char *); -__aconst char *devname(int32_t, mode_t); -__aconst char *__devname50(dev_t, mode_t); -char *initstate(unsigned long, char *, size_t); -char *__initstate60(unsigned int, char *, size_t); -void srandom(unsigned long); -void __srandom60(unsigned int); - -__END_DECLS - -#endif /* !_COMPAT_STDLIB_H_ */ diff --git a/lib/libc/compat/include/time.h b/lib/libc/compat/include/time.h deleted file mode 100644 index c0842f585..000000000 --- a/lib/libc/compat/include/time.h +++ /dev/null @@ -1,106 +0,0 @@ -/* $NetBSD: time.h,v 1.3 2010/12/16 18:38:06 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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. - * - * @(#)time.h 8.3 (Berkeley) 1/21/94 - */ - -#ifndef _COMPAT_TIME_H_ -#define _COMPAT_TIME_H_ - -#include -#if defined(_POSIX_C_SOURCE) || defined(_XOPEN_SOURCE) || \ - defined(_NETBSD_SOURCE) -#define CLK_TCK 100 -#endif - -__BEGIN_DECLS -#if (_XOPEN_SOURCE - 0) >= 4 || defined(_NETBSD_SOURCE) -char *strptime(const char * __restrict, const char * __restrict, - struct tm * __restrict); -#if 0 -#if defined(_NETBSD_SOURCE) -char *timezone(int, int); -#endif /* _NETBSD_SOURCE */ -#endif - -#endif /* !_ANSI_SOURCE */ -char *ctime(const int32_t *); -double difftime(int32_t, int32_t); -struct tm *gmtime(const int32_t *); -struct tm *localtime(const int32_t *); -int32_t time(int32_t *); -int32_t mktime(struct tm *); -void tzset(void); -void tzsetwall(void); -void __tzset50(void); -void __tzsetwall50(void); - -int clock_getres(clockid_t, struct timespec50 *); -int clock_gettime(clockid_t, struct timespec50 *); -int clock_settime(clockid_t, const struct timespec50 *); -int __clock_getres50(clockid_t, struct timespec *); -int __clock_gettime50(clockid_t, struct timespec *); -int __clock_settime50(clockid_t, const struct timespec *); -int nanosleep(const struct timespec50 *, struct timespec50 *); -int __nanosleep50(const struct timespec *, struct timespec *); -int timer_gettime(timer_t, struct itimerspec50 *); -int timer_settime(timer_t, int, const struct itimerspec50 * __restrict, - struct itimerspec50 * __restrict); -int __timer_gettime50(timer_t, struct itimerspec *); -int __timer_settime50(timer_t, int, const struct itimerspec * __restrict, - struct itimerspec * __restrict); -int __timer_getres50(timer_t, struct itimerspec *); -char *ctime_r(const int32_t *, char *); -struct tm *gmtime_r(const int32_t * __restrict, struct tm * __restrict); -struct tm *localtime_r(const int32_t * __restrict, struct tm * __restrict); -struct tm *offtime(const int32_t *, long); -struct tm *offtime_r(const int32_t *, long, struct tm *); -int32_t timelocal(struct tm *); -int32_t timegm(struct tm *); -int32_t timeoff(struct tm *, long); -int32_t time2posix(int32_t); -int32_t posix2time(int32_t); -struct tm *localtime_rz(const timezone_t, const int32_t * __restrict, - struct tm * __restrict); -char *ctime_rz(const timezone_t, const int32_t *, char *); -int32_t mktime_z(const timezone_t, struct tm *); -int32_t timelocal_z(const timezone_t, struct tm *); -int32_t time2posix_z(const timezone_t, int32_t); -int32_t posix2time_z(const timezone_t, int32_t); -timezone_t tzalloc(const char *); -void tzfree(const timezone_t); -const char *tzgetname(const timezone_t, int); - -#endif /* !_COMPAT_TIME_H_ */ diff --git a/lib/libc/compat/include/unistd.h b/lib/libc/compat/include/unistd.h deleted file mode 100644 index d607a01b2..000000000 --- a/lib/libc/compat/include/unistd.h +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: unistd.h,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1998, 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)unistd.h 8.12 (Berkeley) 4/27/95 - */ - -#ifndef _COMPAT_UNISTD_H_ -#define _COMPAT_UNISTD_H_ - -__BEGIN_DECLS -pid_t vfork(void); -pid_t __vfork14(void); -__END_DECLS - -#endif /* !_COMPAT_UNISTD_H_ */ diff --git a/lib/libc/compat/include/utime.h b/lib/libc/compat/include/utime.h deleted file mode 100644 index 33be9e926..000000000 --- a/lib/libc/compat/include/utime.h +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: utime.h,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)utime.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _COMPAT_UTIME_H_ -#define _COMPAT_UTIME_H_ - -#include - -struct utimbuf50 { - int32_t actime; /* Access time */ - int32_t modtime; /* Modification time */ -}; - -#include - -__BEGIN_DECLS -int utime(const char *, const struct utimbuf50 *); -int __utime50(const char *, const struct utimbuf *); -__END_DECLS - -#endif /* !_COMPAT_UTIME_H_ */ diff --git a/lib/libc/compat/include/utmp.h b/lib/libc/compat/include/utmp.h deleted file mode 100644 index f6b7f13d4..000000000 --- a/lib/libc/compat/include/utmp.h +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: utmp.h,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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. - * - * @(#)utmp.h 8.2 (Berkeley) 1/21/94 - */ - -#ifndef _COMPAT_UTMP_H_ -#define _COMPAT_UTMP_H_ - -struct utmp50 { - char ut_line[UT_LINESIZE]; - char ut_name[UT_NAMESIZE]; - char ut_host[UT_HOSTSIZE]; - int32_t ut_time; -}; - -__BEGIN_DECLS -static __inline void -utmp_to_utmp50(const struct utmp *ut, struct utmp50 *ut50) -{ - (void)memcpy(ut50, ut, sizeof(*ut50)); - ut50->ut_time = (int32_t)ut->ut_time; -} - -static __inline void -utmp50_to_utmp(const struct utmp50 *ut50, struct utmp *ut) -{ - (void)memcpy(ut, ut50, sizeof(*ut50)); - ut->ut_time = ut50->ut_time; -} - -struct utmp50 *getutent(void); -struct utmp *__getutent50(void); -__END_DECLS - -#endif /* !_COMPAT_UTMP_H_ */ diff --git a/lib/libc/compat/include/utmpx.h b/lib/libc/compat/include/utmpx.h deleted file mode 100644 index ee201964c..000000000 --- a/lib/libc/compat/include/utmpx.h +++ /dev/null @@ -1,101 +0,0 @@ -/* $NetBSD: utmpx.h,v 1.3 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#ifndef _COMPAT_UTMPX_H_ -#define _COMPAT_UTMPX_H_ - -#include - -struct utmpx50 { - char ut_name[_UTX_USERSIZE]; /* login name */ - char ut_id[_UTX_IDSIZE]; /* inittab id */ - char ut_line[_UTX_LINESIZE]; /* tty name */ - char ut_host[_UTX_HOSTSIZE]; /* host name */ - uint16_t ut_session; /* session id used for windowing */ - uint16_t ut_type; /* type of this entry */ - pid_t ut_pid; /* process id creating the entry */ - struct { - uint16_t e_termination; /* process termination signal */ - uint16_t e_exit; /* process exit status */ - } ut_exit; - struct sockaddr_storage ut_ss; /* address where entry was made from */ - struct timeval50 ut_tv; /* time entry was created */ - uint32_t ut_pad[10]; /* reserved for future use */ -}; - -struct lastlogx50 { - struct timeval50 ll_tv; /* time entry was created */ - char ll_line[_UTX_LINESIZE]; /* tty name */ - char ll_host[_UTX_HOSTSIZE]; /* host name */ - struct sockaddr_storage ll_ss; /* address where entry was made from */ -}; - -__BEGIN_DECLS - -static __inline void -utmpx50_to_utmpx(const struct utmpx50 *ut50, struct utmpx *ut) -{ - (void)memcpy(ut, ut50, sizeof(*ut)); - timeval50_to_timeval(&ut50->ut_tv, &ut->ut_tv); -} - -static __inline void -utmpx_to_utmpx50(const struct utmpx *ut, struct utmpx50 *ut50) -{ - (void)memcpy(ut50, ut, sizeof(*ut50)); - timeval_to_timeval50(&ut->ut_tv, &ut50->ut_tv); -} - -struct utmpx50 *getutxent(void); -struct utmpx *__getutxent50(void); -struct utmpx50 *getutxid(const struct utmpx50 *); -struct utmpx *__getutxid50(const struct utmpx *); -struct utmpx50 *getutxline(const struct utmpx50 *); -struct utmpx *__getutxline50(const struct utmpx *); -struct utmpx50 *pututxline(const struct utmpx50 *); -struct utmpx *__pututxline50(const struct utmpx *); -int updwtmpx(const char *, const struct utmpx50 *); -int __updwtmpx50(const char *, const struct utmpx *); -int updlastlogx(const char *, uid_t, struct lastlogx50 *); -int __updlastlogx50(const char *, uid_t, struct lastlogx *); -struct utmp; -void getutmp(const struct utmpx50 *, struct utmp *); -void __getutmp50(const struct utmpx *, struct utmp *); -void getutmpx(const struct utmp *, struct utmpx50 *); -void __getutmpx50(const struct utmp *, struct utmpx *); - -int lastlogxname(const char *); -struct lastlogx50 *getlastlogx(uid_t, struct lastlogx50 *); -struct lastlogx50 *__getlastlogx13(const char *, uid_t, struct lastlogx50 *); -struct lastlogx *__getlastlogx50(const char *, uid_t, struct lastlogx *); - -__END_DECLS - -#endif /* !_COMPAT_UTMPX_H_ */ diff --git a/lib/libc/compat/include/vis.h b/lib/libc/compat/include/vis.h deleted file mode 100644 index 084386e50..000000000 --- a/lib/libc/compat/include/vis.h +++ /dev/null @@ -1,43 +0,0 @@ -/* $NetBSD: vis.h,v 1.2 2011/03/12 19:52:47 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * @(#)vis.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _COMPAT_VIS_H_ -#define _COMPAT_VIS_H_ - -__BEGIN_DECLS -int unvis(char *, int, int *, int); -int __unvis13(char *, int, int *, int); -int __unvis50(char *, int, int *, int); -__END_DECLS - -#endif /* !_COMPAT_VIS_H_ */ diff --git a/lib/libc/compat/locale/Makefile.inc b/lib/libc/compat/locale/Makefile.inc deleted file mode 100644 index b714fccf9..000000000 --- a/lib/libc/compat/locale/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2010/06/07 13:52:30 tnozaki Exp $ - -.PATH: ${COMPATDIR}/arch/${MACHINE_ARCH}/locale ${COMPATDIR}/locale - -CPPFLAGS+= -I${COMPATDIR}/../locale -SRCS+= compat_setlocale1.c compat_setlocale32.c diff --git a/lib/libc/compat/locale/compat_setlocale1.c b/lib/libc/compat/locale/compat_setlocale1.c deleted file mode 100644 index f8b98b581..000000000 --- a/lib/libc/compat/locale/compat_setlocale1.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_setlocale1.c,v 1.2 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * 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. - * - * NetBSD: setlocale1.c,v 1.4 2010/05/22 13:50:02 tnozaki Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_setlocale1.c,v 1.2 2013/09/13 13:13:32 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include "setlocale_local.h" - -#undef setlocale - -__warn_references(setlocale, - "warning: reference to compatibility setlocale();" - "include for correct reference") - -/* - * Preparation for the future import of multibyte locale. - * This function will ensure binary compatibility for old executables. - */ -char * -compat_setlocale(int category, const char *locale) __RENAME(setlocale); - -char * -compat_setlocale(int category, const char *locale) -{ - - /* locale may be NULL */ - - __mb_len_max_runtime = 1; - return __setlocale(category, locale); -} diff --git a/lib/libc/compat/locale/compat_setlocale32.c b/lib/libc/compat/locale/compat_setlocale32.c deleted file mode 100644 index d06b5c412..000000000 --- a/lib/libc/compat/locale/compat_setlocale32.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: compat_setlocale32.c,v 1.2 2013/03/06 11:29:01 yamt Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * 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. - * - * NetBSD: setlocale32.c,v 1.6 2010/05/22 13:50:02 tnozaki Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_setlocale32.c,v 1.2 2013/03/06 11:29:01 yamt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include "setlocale_local.h" - -__warn_references(__setlocale_mb_len_max_32, - "warning: reference to compatibility __setlocale_mb_len_max_32();" - "include for correct reference") - -/* - * MB_LEN_MAX used to be a MD macro. it was 32 for most ports but 6 for hppa. - * hppa uses arch/hppa/locale/compat_setlocale32.c instead of this file. - */ -#if defined(__hppa__) -#error using wrong variant of compat_setlocale32.c -#endif /* defined(__hppa__) */ - -char * -__setlocale_mb_len_max_32(int category, const char *locale) -{ - - /* locale may be NULL */ - - __mb_len_max_runtime = 32; - return __setlocale(category, locale); -} diff --git a/lib/libc/compat/net/Makefile.inc b/lib/libc/compat/net/Makefile.inc deleted file mode 100644 index aa8f2513c..000000000 --- a/lib/libc/compat/net/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2012/01/20 14:08:05 joerg Exp $ - -.PATH: ${COMPATDIR}/net -SRCS+= __cmsg_alignbytes.c compat_ns_addr.c compat_ns_ntoa.c diff --git a/lib/libc/compat/net/__cmsg_alignbytes.c b/lib/libc/compat/net/__cmsg_alignbytes.c deleted file mode 100644 index dbf21f86f..000000000 --- a/lib/libc/compat/net/__cmsg_alignbytes.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: __cmsg_alignbytes.c,v 1.1 2012/01/20 14:08:05 joerg Exp $ */ - -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jun-ichiro Hagino. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__RCSID("$NetBSD: __cmsg_alignbytes.c,v 1.1 2012/01/20 14:08:05 joerg Exp $"); - -#include "namespace.h" -#include -#include -#include -#include - -int __cmsg_alignbytes(void); - -int -__cmsg_alignbytes(void) -{ - static int alignbytes = -1; -#ifdef HW_ALIGNBYTES - int mib[2]; - size_t len; - int ret; -#endif - - if (alignbytes > 0) - return alignbytes; - -#ifdef HW_ALIGNBYTES - mib[0] = CTL_HW; - mib[1] = HW_ALIGNBYTES; - len = sizeof(alignbytes); - ret = sysctl(mib, (u_int) (sizeof(mib) / sizeof(mib[0])), - (void *)&alignbytes, &len, NULL, (size_t)0); - if (ret >= 0 && alignbytes >= 0) - return alignbytes; -#endif - /* last resort */ - alignbytes = ALIGNBYTES; - return alignbytes; -} diff --git a/lib/libc/compat/net/compat_ns_addr.c b/lib/libc/compat/net/compat_ns_addr.c deleted file mode 100644 index a3667fca3..000000000 --- a/lib/libc/compat/net/compat_ns_addr.c +++ /dev/null @@ -1,243 +0,0 @@ -/* $NetBSD: compat_ns_addr.c,v 1.3 2012/10/15 22:22:01 msaitoh Exp $ */ - -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * J.Q. Johnson. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ns_addr.c 8.1 (Berkeley) 6/7/93"; -#else -__RCSID("$NetBSD: compat_ns_addr.c,v 1.3 2012/10/15 22:22:01 msaitoh Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include - -static void Field(char *, uint8_t *, int); -static void cvtbase(long, int, int[], int, uint8_t [], int); - -struct ns_addr -ns_addr(const char *name) -{ - char separator; - char *hostname, *socketname, *cp; - char buf[50]; - static struct ns_addr addr; - - _DIAGASSERT(name != NULL); - - (void)strlcpy(buf, name, sizeof(buf)); - - /* - * First, figure out what he intends as a field separtor. - * Despite the way this routine is written, the prefered - * form 2-272.AA001234H.01777, i.e. XDE standard. - * Great efforts are made to insure backward compatibility. - */ - if ((hostname = strchr(buf, '#')) != NULL) - separator = '#'; - else { - hostname = strchr(buf, '.'); - if ((cp = strchr(buf, ':')) && - ((hostname && cp < hostname) || (hostname == 0))) { - hostname = cp; - separator = ':'; - } else - separator = '.'; - } - if (hostname) - *hostname++ = 0; - - memset(&addr, '\0', sizeof(addr)); - Field(buf, addr.x_net.c_net, 4); - if (hostname == 0) - return (addr); /* No separator means net only */ - - socketname = strchr(hostname, separator); - if (socketname) { - *socketname++ = 0; - Field(socketname, (uint8_t *)(void *)&addr.x_port, 2); - } - - Field(hostname, addr.x_host.c_host, 6); - - return (addr); -} - -static void -Field(char *buf, uint8_t *out, int len) -{ - register char *bp = buf; - int i, ibase, base16 = 0, base10 = 0; - unsigned int clen = 0; - int hb[6], *hp; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(out != NULL); - - /* - * first try 2-273#2-852-151-014#socket - */ - if ((*buf != '-') && - (1 < (i = sscanf(buf, "%d-%d-%d-%d-%d", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4])))) { - cvtbase(1000L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0.0.AA.0.5E.E6#socket - */ - if (1 < (i = sscanf(buf,"%x.%x.%x.%x.%x.%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * try form 8E1#0:0:AA:0:5E:E6#socket - */ - if (1 < (i = sscanf(buf,"%x:%x:%x:%x:%x:%x", - &hb[0], &hb[1], &hb[2], &hb[3], &hb[4], &hb[5]))) { - cvtbase(256L, 256, hb, i, out, len); - return; - } - /* - * This is REALLY stretching it but there was a - * comma notation separting shorts -- definitely non standard - */ - if (1 < (i = sscanf(buf,"%x,%x,%x", - &hb[0], &hb[1], &hb[2]))) { - hb[0] = htons(hb[0]); hb[1] = htons(hb[1]); - hb[2] = htons(hb[2]); - cvtbase(65536L, 256, hb, i, out, len); - return; - } - - /* Need to decide if base 10, 16 or 8 */ - while (*bp) switch (*bp++) { - - case '0': case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '-': - break; - - case '8': case '9': - base10 = 1; - break; - - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - base16 = 1; - break; - - case 'x': case 'X': - *--bp = '0'; - base16 = 1; - break; - - case 'h': case 'H': - base16 = 1; - /* FALLTHROUGH */ - - default: - *--bp = 0; /* Ends Loop */ - } - if (base16) { - ibase = 4096; - } else if (base10 == 0 && *buf == '0') { - ibase = 512; - } else { - base10 = 1; - ibase = 1000; - } - - for (bp = buf; *bp++; ) clen++; - if (clen == 0) clen++; - if (clen > 18) clen = 18; - i = ((clen - 1) / 3) + 1; - bp = clen + buf - 3; - hp = hb + i - 1; - - while (hp > hb) { - if (base16) - (void)sscanf(bp, "%3x", hp); - else if (base10) - (void)sscanf(bp, "%3d", hp); - else - (void)sscanf(bp, "%3o", hp); - - bp[0] = 0; - hp--; - bp -= 3; - } - if (base16) - (void)sscanf(buf, "%3x", hp); - else if (base10) - (void)sscanf(buf, "%3d", hp); - else - (void)sscanf(buf, "%3o", hp); - - cvtbase((long)ibase, 256, hb, i, out, len); -} - -static void -cvtbase(long oldbase, int newbase, int input[], int inlen, - uint8_t result[], int reslen) -{ - int d, e; - long sum; - - _DIAGASSERT(input != NULL); - _DIAGASSERT(result != NULL); - _DIAGASSERT(inlen > 0); - - e = 1; - while (e > 0 && reslen > 0) { - d = 0; e = 0; sum = 0; - /* long division: input=input/newbase */ - while (d < inlen) { - sum = sum*oldbase + (long) input[d]; - e += (sum > 0); - input[d++] = (int) (sum / newbase); - sum %= newbase; - } - /* accumulate remainder */ - result[--reslen] = (unsigned char)sum; - } - for (d=0; d < reslen; d++) - result[d] = 0; -} diff --git a/lib/libc/compat/net/compat_ns_ntoa.c b/lib/libc/compat/net/compat_ns_ntoa.c deleted file mode 100644 index 3aaa5d9f7..000000000 --- a/lib/libc/compat/net/compat_ns_ntoa.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $NetBSD: compat_ns_ntoa.c,v 1.2 2012/03/20 17:05:59 matt Exp $ */ - -/* - * Copyright (c) 1986, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ns_ntoa.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_ns_ntoa.c,v 1.2 2012/03/20 17:05:59 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include -#include - -static char *spectHex(char *); - -char * -ns_ntoa(struct ns_addr addr) -{ - static char obuf[40]; - union { union ns_net net_e; uint32_t long_e; } net; - uint16_t port = htons(addr.x_port); - char *cp; - char *cp2; - uint8_t *up = addr.x_host.c_host; - uint8_t *uplim = up + 6; - - net.net_e = addr.x_net; - sprintf(obuf, "%x", ntohl(net.long_e)); - cp = spectHex(obuf); - cp2 = cp + 1; - while (up < uplim && *up==0) - up++; - if (up == uplim) { - if (port) { - sprintf(cp, ".0"); - cp += 2; - } - } else { - sprintf(cp, ".%x", *up++); - while (up < uplim) { - while (*cp) cp++; - sprintf(cp, "%02x", *up++); - } - cp = spectHex(cp2); - } - if (port) { - sprintf(cp, ".%x", port); - spectHex(cp + 1); - } - return (obuf); -} - -static char * -spectHex(char *p0) -{ - int ok = 0; - int nonzero = 0; - char *p = p0; - - _DIAGASSERT(p0 != NULL); - - for (; *p; p++) - switch (*p) { - case 'a': case 'b': case 'c': case 'd': case 'e': case 'f': - *p += ('A' - 'a'); - /* FALLTHROUGH */ - case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': - ok = 1; - /* FALLTHROUGH */ - case '1': case '2': case '3': case '4': case '5': - case '6': case '7': case '8': case '9': - nonzero = 1; - } - if (nonzero && !ok) { *p++ = 'H'; *p = 0; } - return (p); -} diff --git a/lib/libc/compat/rpc/Makefile.inc b/lib/libc/compat/rpc/Makefile.inc deleted file mode 100644 index 32de61fe2..000000000 --- a/lib/libc/compat/rpc/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2009/01/11 03:41:28 christos Exp $ - -.PATH: ${COMPATDIR}/rpc - -SRCS+=compat_pmap_rmtcall.c compat_rpcb.c diff --git a/lib/libc/compat/rpc/compat_pmap_rmtcall.c b/lib/libc/compat/rpc/compat_pmap_rmtcall.c deleted file mode 100644 index fb82c7a7a..000000000 --- a/lib/libc/compat/rpc/compat_pmap_rmtcall.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: compat_pmap_rmtcall.c,v 1.2 2009/01/11 03:41:28 christos Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_pmap_rmtcall.c,v 1.2 2009/01/11 03:41:28 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include - -__warn_references(pmap_rmtcall, - "warning: reference to compatibility pmap_rmtcall(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(pmap_rmtcall, _pmap_rmtcall) -#endif - -enum clnt_stat -pmap_rmtcall(struct sockaddr_in *addr, u_long prognum, u_long versnum, - u_long procnum, xdrproc_t inproc, char *in, xdrproc_t outproc, - char *out, struct timeval50 tout50, u_long *portp) -{ - struct timeval tout; - timeval50_to_timeval(&tout50, &tout); - return __pmap_rmtcall50(addr, prognum, versnum, procnum, inproc, in, - outproc, out, tout, portp); -} diff --git a/lib/libc/compat/rpc/compat_rpcb.c b/lib/libc/compat/rpc/compat_rpcb.c deleted file mode 100644 index b547d5348..000000000 --- a/lib/libc/compat/rpc/compat_rpcb.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: compat_rpcb.c,v 1.2 2009/01/11 03:41:28 christos Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_rpcb.c,v 1.2 2009/01/11 03:41:28 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include - -__warn_references(rpcb_rmtcall, - "warning: reference to compatibility rpcb_rmtcall(); include to generate correct reference") -__warn_references(rpcb_gettime, - "warning: reference to compatibility rpcb_gettime(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(rpcb_rmtcall, _rpcb_rmtcall) -__weak_alias(rpcb_gettime, _rpcb_gettime) -#endif - -enum clnt_stat -rpcb_rmtcall(const struct netconfig *nc, - const char *name, const rpcprog_t prog, const rpcvers_t vers, - const rpcproc_t proc, const xdrproc_t inproc, const char *inbuf, - const xdrproc_t outproc, caddr_t outbuf, - const struct timeval50 tout50, const struct netbuf *nb) -{ - struct timeval tout; - timeval50_to_timeval(&tout50, &tout); - return __rpcb_rmtcall50(nc, name, prog, vers, proc, inproc, inbuf, - outproc, outbuf, tout, nb); -} - -bool_t -rpcb_gettime(const char *name, int32_t *t50) -{ - time_t t; - bool_t rv = __rpcb_gettime50(name, &t); - *t50 = (int32_t)t; - return rv; -} diff --git a/lib/libc/compat/shlib_version b/lib/libc/compat/shlib_version deleted file mode 100644 index 5b1659f3c..000000000 --- a/lib/libc/compat/shlib_version +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: shlib_version,v 1.1 2006/03/11 21:07:18 christos Exp $ -# Remember to update distrib/sets/lists/base/shl.* when changing -# -major=0 -minor=0 diff --git a/lib/libc/compat/stdio/Makefile.inc b/lib/libc/compat/stdio/Makefile.inc deleted file mode 100644 index 0a02e2680..000000000 --- a/lib/libc/compat/stdio/Makefile.inc +++ /dev/null @@ -1,23 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2012/01/22 18:36:18 christos Exp $ - -.PATH: ${COMPATDIR}/arch/${MACHINE_ARCH}/stdio ${COMPATDIR}/stdio - -SRCS+= compat_fgetpos.c compat_fsetpos.c -CPPFLAGS.compat_fgetpos.c+= -I${COMPATDIR}/../stdio -CPPFLAGS.compat_fsetpos.c+= -I${COMPATDIR}/../stdio -# $NetBSD: Makefile.inc,v 1.1 2012/01/22 18:36:18 christos Exp $ - -.ifndef ABSTOP -ABSTOP!= cd ${.PARSEDIR}; pwd - -.if (${.PARSEDIR} == ${.CURDIR}) -RELTOP:= . -.else -RELTOP:= ${.PARSEDIR:S,^${.CURDIR},,} -.endif - -# you can set BSD{SRC,OBJ}DIR in Makefile.local.inc -.if exists(${ABSTOP}/Makefile.local.inc) -.include "${ABSTOP}/Makefile.local.inc" -.endif -.endif diff --git a/lib/libc/compat/stdio/compat_fgetpos.c b/lib/libc/compat/stdio/compat_fgetpos.c deleted file mode 100644 index c2b129826..000000000 --- a/lib/libc/compat/stdio/compat_fgetpos.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: compat_fgetpos.c,v 1.1 2012/01/22 18:36:18 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * 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. - * - * Original version ID: - * NetBSD: fgetpos.c,v 1.11 2003/08/07 16:43:23 agc Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fgetpos.c,v 1.1 2012/01/22 18:36:18 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include - -#include -#include -#include - -#ifdef __warn_references -__warn_references(fgetpos, - "warning: reference to compatibility fgetpos(); include for correct reference") -#endif - -int -fgetpos(FILE * __restrict fp, off_t * __restrict pos) -{ - _DIAGASSERT(fp != NULL); - _DIAGASSERT(pos != NULL); - - return (*pos = ftello(fp)) == (off_t)-1; -} diff --git a/lib/libc/compat/stdio/compat_fsetpos.c b/lib/libc/compat/stdio/compat_fsetpos.c deleted file mode 100644 index 74250f639..000000000 --- a/lib/libc/compat/stdio/compat_fsetpos.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: compat_fsetpos.c,v 1.2 2012/10/17 16:09:03 drochner Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Chris Torek. - * - * 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. - * - * Original version ID: - * NetBSD: fsetpos.c,v 1.10 2003/08/07 16:43:25 agc Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fsetpos.c,v 1.2 2012/10/17 16:09:03 drochner Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include - -#include -#include -#include - -#ifdef __warn_references -__warn_references(fsetpos, - "warning: reference to compatibility fsetpos(); include for correct reference") -#endif - - -/* - * fsetpos: like fseek. - */ -int -fsetpos(FILE * __restrict iop, const off_t * __restrict pos) -{ - _DIAGASSERT(iop != NULL); - _DIAGASSERT(pos != NULL); - - return fseeko(iop, *pos, SEEK_SET) == (off_t)-1; -} diff --git a/lib/libc/compat/stdlib/Makefile.inc b/lib/libc/compat/stdlib/Makefile.inc deleted file mode 100644 index 71853720c..000000000 --- a/lib/libc/compat/stdlib/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2014/06/12 18:44:36 christos Exp $ - -.PATH: ${COMPATDIR}/stdlib -CPPFLAGS+=-I${COMPATDIR}/stdlib -I${COMPATDIR}/../stdlib -SRCS+=compat_putenv.c compat_random.c compat_unsetenv.c diff --git a/lib/libc/compat/stdlib/compat_putenv.c b/lib/libc/compat/stdlib/compat_putenv.c deleted file mode 100644 index 8c8a128bd..000000000 --- a/lib/libc/compat/stdlib/compat_putenv.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: compat_putenv.c,v 1.3 2015/01/20 18:31:24 christos Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_putenv.c,v 1.3 2015/01/20 18:31:24 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" - -#include -#include -#include -#include -#include - -#include "env.h" -#include "local.h" - -#ifdef __weak_alias -__weak_alias(putenv,_putenv) -#endif - -__warn_references(putenv, - "warning: reference to compatibility putenv();" - " include for correct reference") - -/* - * putenv(name) -- - * This version implicitly copies the string for compatibility. - */ -int -putenv(char *name) -{ - size_t l_name; - char *copy; - int rv; - - _DIAGASSERT(name != NULL); - - l_name = __envvarnamelen(name, true); - if (l_name == 0) { - errno = EINVAL; - return -1; - } - - if ((copy = strdup(name)) == NULL) - return -1; - copy[l_name++] = '\0'; - - rv = setenv(copy, copy + l_name, 1); - - free(copy); - return rv; -} diff --git a/lib/libc/compat/stdlib/compat_random.c b/lib/libc/compat/stdlib/compat_random.c deleted file mode 100644 index b831d25ee..000000000 --- a/lib/libc/compat/stdlib/compat_random.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: compat_random.c,v 1.3 2015/01/20 18:31:24 christos Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_random.c,v 1.3 2015/01/20 18:31:24 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" - -#include -#include -#include - -#include "env.h" -#include "local.h" - -#ifdef __weak_alias -__weak_alias(initstate,_initstate) -__weak_alias(srandom,_srandom) -#endif - -__warn_references(initstate, - "warning: reference to compatibility initstate();" - " include for correct reference") -__warn_references(srandom, - "warning: reference to compatibility srandom();" - " include for correct reference") - -char * -initstate(unsigned long seed, char * buf, size_t len) { - return __initstate60((unsigned int)seed, buf, len); -} - -void -srandom(unsigned long seed) { - __srandom60((unsigned int)seed); -} diff --git a/lib/libc/compat/stdlib/compat_unsetenv.c b/lib/libc/compat/stdlib/compat_unsetenv.c deleted file mode 100644 index 6043d6fc1..000000000 --- a/lib/libc/compat/stdlib/compat_unsetenv.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: compat_unsetenv.c,v 1.4 2015/01/20 18:31:24 christos Exp $ */ - -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "from: @(#)setenv.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: compat_unsetenv.c,v 1.4 2015/01/20 18:31:24 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include "local.h" - -#ifdef __weak_alias -__weak_alias(unsetenv,_unsetenv) -#endif - -#include "env.h" - -__warn_references(unsetenv, - "warning: reference to compatibility unsetenv();" - " include for correct reference") - -/* - * unsetenv(name) -- - * Delete environmental variable "name". - */ -void -unsetenv(const char *name) -{ - size_t l_name; - - _DIAGASSERT(name != NULL); - - l_name = strlen(name); - if (__writelockenv()) { - ssize_t offset; - - while ((offset = __getenvslot(name, l_name, false)) != -1) { - char **p; - for (p = &environ[offset]; ; ++p) { - if ((*p = *(p + 1)) == NULL) - break; - } - } - (void)__unlockenv(); - } -} diff --git a/lib/libc/compat/sys/Lint_Ovfork.c b/lib/libc/compat/sys/Lint_Ovfork.c deleted file mode 100644 index 33cd226ac..000000000 --- a/lib/libc/compat/sys/Lint_Ovfork.c +++ /dev/null @@ -1,21 +0,0 @@ -/* $NetBSD: Lint_Ovfork.c,v 1.1 2006/03/11 21:07:18 christos Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#if 0 -#include -#else -#include -#include -pid_t vfork __P((void)); -#endif - -/*ARGSUSED*/ -pid_t -vfork() -{ - return (0); -} diff --git a/lib/libc/compat/sys/Makefile.inc b/lib/libc/compat/sys/Makefile.inc deleted file mode 100644 index ddc208b53..000000000 --- a/lib/libc/compat/sys/Makefile.inc +++ /dev/null @@ -1,21 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.9 2013/03/29 02:09:58 christos Exp $ - -#__MINIX: Not everything is imported yet. -.PATH: ${COMPATDIR}/sys -SRCS+= compat_getdents.c compat_getdirentries.c \ - compat_sched.c \ - compat_stat.c \ - compat_socket.c \ - \ - compat_getrusage.c compat_gettimeofday.c compat_utimes.c \ - compat_wait4.c compat_settimeofday.c \ - compat_clock.c compat_itimer.c compat_nanosleep.c \ - compat_adjtime.c compat_mknod.c \ - \ - compat___shmctl13.c \ - -MAN+= getdirentries.3 - -.if ${MKLINT} != "no" -LSRCS+= Lint_Ovfork.c -.endif diff --git a/lib/libc/compat/sys/compat___fhstat30.c b/lib/libc/compat/sys/compat___fhstat30.c deleted file mode 100644 index 8bb5e8813..000000000 --- a/lib/libc/compat/sys/compat___fhstat30.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: compat___fhstat30.c,v 1.6 2013/10/04 21:07:37 christos Exp $ */ - -/*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___fhstat30.c,v 1.6 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include - -__warn_references(fhstat, - "warning: reference to compatibility __fhstat30(); include to generate correct reference") - -__strong_alias(__fhstat30, __compat___fhstat30) - -/* - * Convert old fhstat() call to new calling convention - */ -int -__compat___fhstat30(const struct compat_30_fhandle *fhp, struct stat30 *sb) -{ - return __compat___fhstat40(fhp, FHANDLE30_SIZE, sb); -} diff --git a/lib/libc/compat/sys/compat___lwp_park50.c b/lib/libc/compat/sys/compat___lwp_park50.c deleted file mode 100644 index e13a80f4c..000000000 --- a/lib/libc/compat/sys/compat___lwp_park50.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: compat___lwp_park50.c,v 1.2 2014/01/31 20:45:49 christos Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___lwp_park50.c,v 1.2 2014/01/31 20:45:49 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include -#include - -__warn_references(fhstat, - "warning: reference to compatibility ___lwp_park50(); include to generate correct reference") - -/* - * Convert old __lwp_park() call to new - */ -int -___lwp_park50(const struct timespec *ts, lwpid_t unpark, const void *hint, - const void *unparkhint) -{ - return ___lwp_park60(CLOCK_REALTIME, TIMER_ABSTIME, ts, unpark, - hint, unparkhint); -} diff --git a/lib/libc/compat/sys/compat___msgctl13.c b/lib/libc/compat/sys/compat___msgctl13.c deleted file mode 100644 index a69b4adc9..000000000 --- a/lib/libc/compat/sys/compat___msgctl13.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: compat___msgctl13.c,v 1.2 2009/01/11 02:46:25 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___msgctl13.c,v 1.2 2009/01/11 02:46:25 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -__warn_references(__msgctl13, - "warning: reference to compatibility __msgctl13(); include to generate correct reference") - -int -__msgctl13(int msqid, int cmd, struct msqid_ds13 *ds13) -{ - struct msqid_ds ds; - int error; - - if (cmd == IPC_SET) - __msqid_ds13_to_native(ds13, &ds); - - error = __msgctl50(msqid, cmd, &ds); - if (error) - return error; - if (cmd == IPC_STAT) - __native_to_msqid_ds13(&ds, ds13); - return 0; -} diff --git a/lib/libc/compat/sys/compat___ntp_gettime30.c b/lib/libc/compat/sys/compat___ntp_gettime30.c deleted file mode 100644 index 8511ec401..000000000 --- a/lib/libc/compat/sys/compat___ntp_gettime30.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $NetBSD: compat___ntp_gettime30.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___ntp_gettime30.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include - -__warn_references(__ntp_gettime30, - "warning: reference to compatibility __ntp_gettime30(); include for correct reference") - -int -__ntp_gettime30(struct ntptimeval50 *ontvp) -{ - struct ntptimeval ntv; - int res; - - res = __ntp_gettime50(&ntv); - ontvp->time.tv_sec = (int32_t)ntv.time.tv_sec; - ontvp->time.tv_nsec = ntv.time.tv_nsec; - ontvp->maxerror = ntv.maxerror; - ontvp->esterror = ntv.esterror; - - return (res); -} diff --git a/lib/libc/compat/sys/compat___semctl13.c b/lib/libc/compat/sys/compat___semctl13.c deleted file mode 100644 index 4a0b0060a..000000000 --- a/lib/libc/compat/sys/compat___semctl13.c +++ /dev/null @@ -1,108 +0,0 @@ -/* $NetBSD: compat___semctl13.c,v 1.6 2015/01/29 20:44:38 joerg Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___semctl13.c,v 1.6 2015/01/29 20:44:38 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include -#include -#ifdef __lint__ -#include -#endif - -__warn_references(__semctl13, - "warning: reference to compatibility __semctl13(); include to generate correct reference") - -/* - * Copy timeout to local variable and call the syscall. - */ -int -__semctl13(int semid, int semnum, int cmd, ...) -{ - va_list ap; - union __semun semun; - struct semid_ds13 *ds13; - struct semid_ds ds; - int error; - - va_start(ap, cmd); - switch (cmd) { - case IPC_SET: - case IPC_STAT: - case GETALL: - case SETVAL: - case SETALL: -#ifdef __lint__ - memcpy(&semun, &ap, sizeof(semun)); -#else - semun = va_arg(ap, union __semun); -#endif - break; - default: - break; - } - va_end(ap); - - switch (cmd) { - case IPC_SET: - case IPC_STAT: - ds13 = (void *)semun.buf; - semun.buf = &ds; - if (cmd == IPC_SET) - __semid_ds13_to_native(ds13, &ds); - break; - default: - ds13 = NULL; - break; - } - - - error = ____semctl50(semid, semnum, cmd, &semun); - if (error) - return error; - - if (cmd == IPC_STAT) - __native_to_semid_ds13(&ds, ds13); - return 0; -} diff --git a/lib/libc/compat/sys/compat___shmctl13.c b/lib/libc/compat/sys/compat___shmctl13.c deleted file mode 100644 index 00c399917..000000000 --- a/lib/libc/compat/sys/compat___shmctl13.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: compat___shmctl13.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___shmctl13.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -__warn_references(__shmctl13, - "warning: reference to compatibility __shmctl13(); include to generate correct reference") - -int -__shmctl13(int shmid, int cmd, struct shmid_ds13 *ds13) -{ - struct shmid_ds ds; - int error; - - if (cmd == IPC_SET) - __shmid_ds13_to_native(ds13, &ds); - - error = __shmctl50(shmid, cmd, &ds); - if (error) - return error; - if (cmd == IPC_STAT) - __native_to_shmid_ds13(&ds, ds13); - return 0; -} diff --git a/lib/libc/compat/sys/compat___stat13.c b/lib/libc/compat/sys/compat___stat13.c deleted file mode 100644 index ea02d1fe1..000000000 --- a/lib/libc/compat/sys/compat___stat13.c +++ /dev/null @@ -1,144 +0,0 @@ -/* $NetBSD: compat___stat13.c,v 1.6 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Copyright (c) 1997 Frank van der Linden - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Frank van der Linden - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___stat13.c,v 1.6 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include -#include -#include -#include - -__warn_references(__stat13, - "warning: reference to compatibility __stat13(); include to generate correct reference") - -__warn_references(__fstat13, - "warning: reference to compatibility __fstat13(); include to generate correct reference") - -__warn_references(__lstat13, - "warning: reference to compatibility __lstat13(); include to generate correct reference") - -__warn_references(fhstat, - "warning: reference to compatibility fhstat(); include to generate correct reference") - -__strong_alias(__stat13, __compat___stat13) -__strong_alias(__fstat13, __compat___fstat13) -__strong_alias(__lstat13, __compat___lstat13) -__strong_alias(fhstat, __compat_fhstat) - -/* - * Convert from a new to an old stat structure. - */ - -static void cvtstat(struct stat13 *, const struct stat *); - -static void -cvtstat(struct stat13 *ost, const struct stat *st) -{ - - ost->st_dev = (uint32_t)st->st_dev; - ost->st_ino = (uint32_t)st->st_ino; - ost->st_mode = st->st_mode; - ost->st_nlink = st->st_nlink; - ost->st_uid = st->st_uid; - ost->st_gid = st->st_gid; - ost->st_rdev = (uint32_t)st->st_rdev; - ost->st_atimespec.tv_sec = (int32_t)st->st_atimespec.tv_sec; - ost->st_atimespec.tv_nsec = st->st_atimespec.tv_nsec; - ost->st_mtimespec.tv_sec = (int32_t)st->st_mtimespec.tv_sec; - ost->st_mtimespec.tv_nsec = st->st_mtimespec.tv_nsec; - ost->st_ctimespec.tv_sec = (int32_t)st->st_ctimespec.tv_sec; - ost->st_ctimespec.tv_nsec = st->st_ctimespec.tv_nsec; - ost->st_birthtimespec.tv_sec = (int32_t)st->st_birthtimespec.tv_sec; - ost->st_birthtimespec.tv_nsec = st->st_birthtimespec.tv_nsec; - ost->st_size = st->st_size; - ost->st_blocks = st->st_blocks; - ost->st_blksize = st->st_blksize; - ost->st_flags = st->st_flags; - ost->st_gen = st->st_gen; -} - -int -__compat___stat13(const char *file, struct stat13 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __stat50(file, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} - -int -__compat___fstat13(int f, struct stat13 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __fstat50(f, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} - -int -__compat___lstat13(const char *file, struct stat13 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __lstat50(file, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} - -int -__compat_fhstat(const struct compat_30_fhandle *fh, struct stat13 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __fhstat50((const void *)fh, /* FHANDLE_SIZE_COMPAT */28, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} diff --git a/lib/libc/compat/sys/compat___stat30.c b/lib/libc/compat/sys/compat___stat30.c deleted file mode 100644 index e859453a7..000000000 --- a/lib/libc/compat/sys/compat___stat30.c +++ /dev/null @@ -1,141 +0,0 @@ -/* $NetBSD: compat___stat30.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Copyright (c) 1997 Frank van der Linden - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Frank van der Linden - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat___stat30.c,v 1.4 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include -#include -#include -#include - -__warn_references(__stat30, - "warning: reference to compatibility __stat30(); include to generate correct reference") - -__warn_references(__fstat30, - "warning: reference to compatibility __fstat30(); include to generate correct reference") - -__warn_references(__lstat30, - "warning: reference to compatibility __lstat30(); include to generate correct reference") - -__warn_references(__fhstat40, - "warning: reference to compatibility __fhstat40(); include to generate correct reference") - - -__strong_alias(__stat30, __compat___stat30) -__strong_alias(__fstat30, __compat___fstat30) -__strong_alias(__lstat30, __compat___lstat30) -__strong_alias(__fhstat40, __compat___fhstat40) - -/* - * Convert from a new to an old stat structure. - */ - -static void cvtstat(struct stat30 *, const struct stat *); - -static void -cvtstat(struct stat30 *ost, const struct stat *st) -{ - - ost->st_dev = (uint32_t)st->st_dev; - ost->st_ino = st->st_ino; - ost->st_mode = st->st_mode; - ost->st_nlink = st->st_nlink; - ost->st_uid = st->st_uid; - ost->st_gid = st->st_gid; - ost->st_rdev = (uint32_t)st->st_rdev; - timespec_to_timespec50(&st->st_atimespec, &ost->st_atimespec); - timespec_to_timespec50(&st->st_mtimespec, &ost->st_mtimespec); - timespec_to_timespec50(&st->st_ctimespec, &ost->st_ctimespec); - timespec_to_timespec50(&st->st_birthtimespec, &ost->st_birthtimespec); - ost->st_size = st->st_size; - ost->st_blocks = st->st_blocks; - ost->st_blksize = st->st_blksize; - ost->st_flags = st->st_flags; - ost->st_gen = st->st_gen; -} - -int -__compat___stat30(const char *file, struct stat30 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __stat50(file, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} - -int -__compat___fstat30(int f, struct stat30 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __fstat50(f, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} - -int -__compat___lstat30(const char *file, struct stat30 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __lstat50(file, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} - -int -__compat___fhstat40(const void *fh, size_t fh_size, struct stat30 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __fhstat50(fh, fh_size, &nst)) == -1) - return ret; - cvtstat(ost, &nst); - return ret; -} diff --git a/lib/libc/compat/sys/compat__lwp_park.c b/lib/libc/compat/sys/compat__lwp_park.c deleted file mode 100644 index f4f9b1902..000000000 --- a/lib/libc/compat/sys/compat__lwp_park.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: compat__lwp_park.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat__lwp_park.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -__warn_references(_lwp_park, - "warning: reference to compatibility _lwp_park(); include to generate correct reference") - -/* - * Copy timeout to local variable and call the syscall. - */ -int -_lwp_park(const struct timespec50 *ts50, lwpid_t unpark, - const void *hint, const void *unparkhint) -{ - struct timespec ts, *tsp; - - if (ts50) - timespec50_to_timespec(ts50, tsp = &ts); - else - tsp = NULL; - return ___lwp_park50(tsp, unpark, hint, unparkhint); -} diff --git a/lib/libc/compat/sys/compat_adjtime.c b/lib/libc/compat/sys/compat_adjtime.c deleted file mode 100644 index b6a242f53..000000000 --- a/lib/libc/compat/sys/compat_adjtime.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: compat_adjtime.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without valific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_adjtime.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include - -__warn_references(adjtime, - "warning: reference to compatibility adjtime(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(adjtime, _adjtime) -__weak_alias(__adjtime, _adjtime) -#endif - -/* - * Copy timeout to local variable and call the syscall. - */ -int -adjtime(const struct timeval50 *ts50, struct timeval50 *rts50) -{ - struct timeval ts, *tsp; - struct timeval rts, *rtsp; - int error; - - rtsp = rts50 ? &rts : NULL; - if (ts50) - timeval50_to_timeval(ts50, tsp = &ts); - else - tsp = NULL; - error = __adjtime50(tsp, rtsp); - if (error) - return error; - if (rts50) - timeval_to_timeval50(rtsp, rts50); - return 0; -} diff --git a/lib/libc/compat/sys/compat_aio_suspend.c b/lib/libc/compat/sys/compat_aio_suspend.c deleted file mode 100644 index 3639f5ba9..000000000 --- a/lib/libc/compat/sys/compat_aio_suspend.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: compat_aio_suspend.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_aio_suspend.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include - -__warn_references(aio_suspend, - "warning: reference to compatibility aio_suspend(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(aio_suspend, _aio_suspend) -__weak_alias(_sys_aio_suspend, _aio_suspend) -#endif -/* - * Copy timeout to local variable and call the syscall. - */ -int -aio_suspend(const struct aiocb * const list[], int nent, - const struct timespec50 * ts50) -{ - struct timespec ts, *tsp; - - if (ts50) - timespec50_to_timespec(ts50, tsp = &ts); - else - tsp = NULL; - return __aio_suspend50(list, nent, tsp); -} diff --git a/lib/libc/compat/sys/compat_clock.c b/lib/libc/compat/sys/compat_clock.c deleted file mode 100644 index c3f56451a..000000000 --- a/lib/libc/compat/sys/compat_clock.c +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: compat_clock.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_clock.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include - -__warn_references(clock_gettime, - "warning: reference to compatibility clock_gettime(); include to generate correct reference") -__warn_references(clock_settime, - "warning: reference to compatibility clock_settime(); include to generate correct reference") -__warn_references(clock_getres, - "warning: reference to compatibility clock_getres(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(clock_settime, _clock_settime) -__weak_alias(__clock_settime, _clock_settime) -__weak_alias(clock_gettime, _clock_gettime) -__weak_alias(clock_getres, _clock_getres) -#endif - -int -clock_settime(clockid_t clockid, const struct timespec50 * tim50) -{ - struct timespec tim, *timp; - int error; - - if (tim50) - timespec50_to_timespec(tim50, timp = &tim); - else - timp = NULL; - error = __clock_settime50(clockid, timp); - if (error) - return error; - return 0; -} - -int -clock_gettime(clockid_t clockid, struct timespec50 *tim50) -{ - struct timespec tim, *timp = tim50 ? &tim : NULL; - int error = __clock_gettime50(clockid, timp); - if (error) - return error; - if (tim50) - timespec_to_timespec50(timp, tim50); - return 0; -} - -int -clock_getres(clockid_t clockid, struct timespec50 *tim50) -{ - struct timespec tim, *timp = tim50 ? &tim : NULL; - int error = __clock_getres50(clockid, timp); - if (error) - return error; - if (tim50) - timespec_to_timespec50(timp, tim50); - return 0; -} diff --git a/lib/libc/compat/sys/compat_fhopen.c b/lib/libc/compat/sys/compat_fhopen.c deleted file mode 100644 index 438231655..000000000 --- a/lib/libc/compat/sys/compat_fhopen.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: compat_fhopen.c,v 1.4 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fhopen.c,v 1.4 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include - -__warn_references(fhopen, - "warning: reference to compatibility fhopen(); include to generate correct reference") - - -int __fhopen40(const void *, size_t, int); -int fhopen(const struct compat_30_fhandle *, int); - -/* - * Convert old fhopen() call to new calling convention - */ -int -fhopen(const struct compat_30_fhandle *fhp, int flags) -{ - return __fhopen40(fhp, FHANDLE30_SIZE, flags); -} diff --git a/lib/libc/compat/sys/compat_fhstatvfs.c b/lib/libc/compat/sys/compat_fhstatvfs.c deleted file mode 100644 index 1e2207cfc..000000000 --- a/lib/libc/compat/sys/compat_fhstatvfs.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_fhstatvfs.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fhstatvfs.c,v 1.3 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include - -__warn_references(fhstatvfs, - "warning: reference to compatibility fhstatvfs(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(fhstatvfs, _fhstatvfs) -#endif - -int _fhstatvfs(const struct compat_30_fhandle *fhp, struct statvfs *buf); -int __fhstatvfs140(const void *fhp, size_t fh_size, struct statvfs *buf, - int flags); - -/* - * Convert old fhstatvs() call to new calling convention - */ -int -_fhstatvfs(const struct compat_30_fhandle *fhp, struct statvfs *buf) -{ - return __fhstatvfs140(fhp, FHANDLE30_SIZE, buf, ST_WAIT); -} diff --git a/lib/libc/compat/sys/compat_fhstatvfs1.c b/lib/libc/compat/sys/compat_fhstatvfs1.c deleted file mode 100644 index 6eb7db3b0..000000000 --- a/lib/libc/compat/sys/compat_fhstatvfs1.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: compat_fhstatvfs1.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_fhstatvfs1.c,v 1.3 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include - -__warn_references(fhstatvfs1, - "warning: reference to compatibility fhstatvfs1(); include to generate correct reference") - -int fhstatvfs1(const struct compat_30_fhandle *fhp, struct statvfs *buf, - int flags); -int __fhstatvfs140(const void *fhp, size_t fh_size, struct statvfs *buf, - int flags); - -/* - * Convert old fhstatvs1() call to new calling convention - */ -int -fhstatvfs1(const struct compat_30_fhandle *fhp, struct statvfs *buf, int flags) -{ - return __fhstatvfs140(fhp, FHANDLE30_SIZE, buf, flags); -} diff --git a/lib/libc/compat/sys/compat_getdents.c b/lib/libc/compat/sys/compat_getdents.c deleted file mode 100644 index c0c372338..000000000 --- a/lib/libc/compat/sys/compat_getdents.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: compat_getdents.c,v 1.6 2012/03/13 22:24:48 joerg Exp $ */ - -/*- - * Copyright (c) 2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_getdents.c,v 1.6 2012/03/13 22:24:48 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -/* - * libc12 compatible getdents routine. - */ -int -getdents(int fd, char *buf, size_t nbytes) -{ - struct dirent *ndp, *nndp, *endp; - struct dirent12 *odp; - ino_t ino; - int rv; - size_t len; - - if ((rv = __getdents30(fd, buf, nbytes)) == -1) - return rv; - - odp = (struct dirent12 *)(void *)buf; - ndp = (struct dirent *)(void *)buf; - endp = (struct dirent *)(void *)&buf[rv]; - - /* - * In-place conversion. This works because odp - * is smaller than ndp, but it has to be done - * in the right sequence. - */ - for (; ndp < endp; ndp = nndp) { - nndp = _DIRENT_NEXT(ndp); - /* XXX: avoid unaligned 64-bit access on sparc64 */ - /* XXX: does this work? */ - memcpy(&ino, &ndp->d_ino, sizeof(ino_t)); - odp->d_ino = (uint32_t)ino; - if (ndp->d_namlen >= sizeof(odp->d_name)) - odp->d_namlen = sizeof(odp->d_name) - 1; - else - odp->d_namlen = (u_int8_t)ndp->d_namlen; - odp->d_type = ndp->d_type; - (void)memcpy(odp->d_name, ndp->d_name, (size_t)odp->d_namlen); - odp->d_name[odp->d_namlen] = '\0'; - len = _DIRENT_SIZE(odp); - _DIAGASSERT(__type_fit(uint16_t, len)); - odp->d_reclen = (uint16_t)len; - odp = _DIRENT_NEXT(odp); - } - ptrdiff_t td = (((char *)(void *)odp) - buf); - _DIAGASSERT(__type_fit(int, td)); - return (int)td; -} diff --git a/lib/libc/compat/sys/compat_getdirentries.c b/lib/libc/compat/sys/compat_getdirentries.c deleted file mode 100644 index a77de9ea2..000000000 --- a/lib/libc/compat/sys/compat_getdirentries.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: compat_getdirentries.c,v 1.3 2012/03/20 17:06:00 matt Exp $ */ - -/* - * Copyright (c) 1997 Frank van der Linden - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by Frank van der Linden for - * the NetBSD Project. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_getdirentries.c,v 1.3 2012/03/20 17:06:00 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ -#include "namespace.h" -#include -#include -#include -#include - -__warn_references(getdirentries, - "reference to compatibility-only getdirentries(); this will break; use getdents() or readdir() instead") - -int -getdirentries(int fd, char *buf, int nbytes, long *basep) -{ - *basep = (long)lseek(fd, (off_t)0, SEEK_CUR); - return getdents(fd, buf, (size_t)nbytes); -} diff --git a/lib/libc/compat/sys/compat_getfh.c b/lib/libc/compat/sys/compat_getfh.c deleted file mode 100644 index 5c7695004..000000000 --- a/lib/libc/compat/sys/compat_getfh.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: compat_getfh.c,v 1.6 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_getfh.c,v 1.6 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include - -#include - -__warn_references(getfh, - "warning: reference to compatibility getfh(); include to generate correct reference") - - -int __getfh30(const char *, void*, size_t *); -int getfh(const char *path, struct compat_30_fhandle *fhp); - -/* - * Convert old getfh() call to new calling convention - */ -int -getfh(const char *path, struct compat_30_fhandle *fhp) -{ - size_t fh_size = sizeof(*fhp); - int ret; - - ret = __getfh30(path, (void*)fhp, &fh_size); - if (ret != 0) { - return ret; - } - if (fh_size != FHANDLE30_SIZE) { - errno = EINVAL; - return -1; - } - return 0; -} diff --git a/lib/libc/compat/sys/compat_getrusage.c b/lib/libc/compat/sys/compat_getrusage.c deleted file mode 100644 index 314ab5a3a..000000000 --- a/lib/libc/compat/sys/compat_getrusage.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: compat_getrusage.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_getrusage.c,v 1.4 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include - -__warn_references(getrusage, - "warning: reference to compatibility getrusage(); include to generate correct reference") - -__strong_alias(getrusage, __compat_getrusage) - -void __rusage_to_rusage50(const struct rusage *, struct rusage50 *); - -void -__rusage_to_rusage50(const struct rusage *ru, struct rusage50 *ru50) -{ - (void)memcpy(&ru50->ru_first, &ru->ru_first, - (size_t)((char *)(void *)&ru50->ru_last - - (char *)(void *)&ru50->ru_first)); - ru50->ru_maxrss = ru->ru_maxrss; - timeval_to_timeval50(&ru->ru_utime, &ru50->ru_utime); - timeval_to_timeval50(&ru->ru_stime, &ru50->ru_stime); -} - -/* - * libc12 compatible getrusage routine. - */ -int -__compat_getrusage(int who, struct rusage50 *ru50) -{ - struct rusage ru; - int rv; - - if ((rv = __getrusage50(who, &ru)) == -1) - return rv; - __rusage_to_rusage50(&ru, ru50); - return rv; -} diff --git a/lib/libc/compat/sys/compat_gettimeofday.c b/lib/libc/compat/sys/compat_gettimeofday.c deleted file mode 100644 index 838ffdf78..000000000 --- a/lib/libc/compat/sys/compat_gettimeofday.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: compat_gettimeofday.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_gettimeofday.c,v 1.4 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include - -__warn_references(gettimeofday, - "warning: reference to compatibility gettimeofday(); include to generate correct reference") - -__strong_alias(gettimeofday, __compat_gettimeofday) - -/* - * libc12 compatible gettimeofday routine. - */ -int -__compat_gettimeofday(struct timeval50 *tv50, void *tzp) -{ - struct timeval tv; - int rv; - - if ((rv = __gettimeofday50(&tv, tzp)) == -1) - return rv; - timeval_to_timeval50(&tv, tv50); - return rv; -} diff --git a/lib/libc/compat/sys/compat_itimer.c b/lib/libc/compat/sys/compat_itimer.c deleted file mode 100644 index e31dec76a..000000000 --- a/lib/libc/compat/sys/compat_itimer.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: compat_itimer.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_itimer.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include - -__warn_references(getitimer, - "warning: reference to compatibility getitimer(); include to generate correct reference") -__warn_references(setitimer, - "warning: reference to compatibility setitimer(); include to generate correct reference") - -int -setitimer(int timerid, const struct itimerval50 * __restrict tim50, - struct itimerval50 * __restrict otim50) -{ - struct itimerval tim, *timp; - struct itimerval otim, *otimp; - int error; - - otimp = otim50 ? &otim : NULL; - if (tim50) - itimerval50_to_itimerval(tim50, timp = &tim); - else - timp = NULL; - error = __setitimer50(timerid, timp, otimp); - if (error) - return error; - if (otim50) - itimerval_to_itimerval50(otimp, otim50); - return 0; -} - -int -getitimer(int timerid, struct itimerval50 *tim50) -{ - struct itimerval tim, *timp = tim50 ? &tim : NULL; - int error = __getitimer50(timerid, timp); - if (error) - return error; - if (tim50) - itimerval_to_itimerval50(timp, tim50); - return 0; -} diff --git a/lib/libc/compat/sys/compat_kevent.c b/lib/libc/compat/sys/compat_kevent.c deleted file mode 100644 index c613f0735..000000000 --- a/lib/libc/compat/sys/compat_kevent.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: compat_kevent.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_kevent.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -__warn_references(kevent, - "warning: reference to compatibility kevent(); include to generate correct reference") - -int -kevent(int kq, const struct kevent *changelist, size_t nchanges, - struct kevent *eventlist, size_t nevents, const struct timespec50 *ts50) -{ - struct timespec ts, *tsp; - - if (ts50) - timespec50_to_timespec(ts50, tsp = &ts); - else - tsp = NULL; - return __kevent50(kq, changelist, nchanges, eventlist, nevents, tsp); -} diff --git a/lib/libc/compat/sys/compat_lfs_segwait.c b/lib/libc/compat/sys/compat_lfs_segwait.c deleted file mode 100644 index 5a4cead1c..000000000 --- a/lib/libc/compat/sys/compat_lfs_segwait.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: compat_lfs_segwait.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without valific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_lfs_segwait.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -__warn_references(lfs_segwait, - "warning: reference to compatibility lfs_segwait(); include to generate correct reference") - -int lfs_segwait(fsid_t *, struct timeval50 *); -int __lfs_segwait50(fsid_t *, struct timeval *); -int -lfs_segwait(fsid_t *fsid, struct timeval50 *ts50) -{ - struct timeval ts, *tsp; - - if (ts50) - timeval50_to_timeval(ts50, tsp = &ts); - else - tsp = NULL; - return __lfs_segwait50(fsid, tsp); -} diff --git a/lib/libc/compat/sys/compat_mknod.c b/lib/libc/compat/sys/compat_mknod.c deleted file mode 100644 index dc354555e..000000000 --- a/lib/libc/compat/sys/compat_mknod.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: compat_mknod.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_mknod.c,v 1.4 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -__warn_references(mknod, - "warning: reference to compatibility mknod(); include to generate correct reference") - -__strong_alias(mknod, __compat_mknod) - -int -__compat_mknod(const char *path, mode_t mode, uint32_t dev) -{ - return __mknod50(path, mode, dev); -} diff --git a/lib/libc/compat/sys/compat_mount.c b/lib/libc/compat/sys/compat_mount.c deleted file mode 100644 index 83f8f3c3f..000000000 --- a/lib/libc/compat/sys/compat_mount.c +++ /dev/null @@ -1,29 +0,0 @@ -/* $NetBSD: compat_mount.c,v 1.2 2007/07/18 20:10:47 dsl Exp $ */ - - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_mount.c,v 1.2 2007/07/18 20:10:47 dsl Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include - -__warn_references(mount, - "warning: reference to compatibility mount(); include to generate correct reference") - -int mount(const char *, const char *, int, void *); -int __mount50(const char *, const char *, int, void *, size_t); - -/* - * Convert old mount() call to new calling convention - * The kernel will treat length 0 as 'default for the fs'. - * We need to throw away the +ve response for MNT_GETARGS. - */ -int -mount(const char *type, const char *dir, int flags, void *data) -{ - return __mount50(type, dir, flags, data, 0) == -1 ? -1 : 0; -} diff --git a/lib/libc/compat/sys/compat_mqueue.c b/lib/libc/compat/sys/compat_mqueue.c deleted file mode 100644 index 41244f81a..000000000 --- a/lib/libc/compat/sys/compat_mqueue.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: compat_mqueue.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_mqueue.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -__warn_references(mq_timedreceive, - "warning: reference to compatibility mq_timedreceive(); include to generate correct reference") -__warn_references(mq_timedsend, - "warning: reference to compatibility mq_timedsend(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(mq_timedreceive, _mq_timedreceive) -__weak_alias(mq_timedsend, _mq_timedsend) -__weak_alias(_sys_mq_timedreceive, _mq_timedreceive) -__weak_alias(_sys_mq_timedsend, _mq_timedsend) -#endif - -ssize_t -mq_timedreceive(mqd_t mq, char * __restrict name, size_t len, - unsigned * __restrict buf, const struct timespec50 * __restrict ts50) -{ - struct timespec ts, *tsp; - - if (ts50) - timespec50_to_timespec(ts50, tsp = &ts); - else - tsp = NULL; - return __mq_timedreceive50(mq, name, len, buf, tsp); -} - -int -mq_timedsend(mqd_t mq, const char *name, size_t len, - unsigned buf, const struct timespec50 *ts50) -{ - struct timespec ts, *tsp; - - if (ts50) - timespec50_to_timespec(ts50, tsp = &ts); - else - tsp = NULL; - return __mq_timedsend50(mq, name, len, buf, tsp); -} diff --git a/lib/libc/compat/sys/compat_msync.c b/lib/libc/compat/sys/compat_msync.c deleted file mode 100644 index b0c2822fe..000000000 --- a/lib/libc/compat/sys/compat_msync.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: compat_msync.c,v 1.2 2012/03/20 17:06:00 matt Exp $ */ - -/* - * Copyright (c) 1997 Frank van der Linden - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Frank van der Linden - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_msync.c,v 1.2 2012/03/20 17:06:00 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include - -__warn_references(msync, - "warning: reference to compatibility msync(); include for correct reference") - -int -msync(void *addr, size_t size) -{ - return __msync13(addr, size, MS_SYNC|MS_INVALIDATE); -} diff --git a/lib/libc/compat/sys/compat_nanosleep.c b/lib/libc/compat/sys/compat_nanosleep.c deleted file mode 100644 index 5d76722e0..000000000 --- a/lib/libc/compat/sys/compat_nanosleep.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: compat_nanosleep.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_nanosleep.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include - -__warn_references(nanosleep, - "warning: reference to compatibility nanosleep(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(nanosleep, _nanosleep) -__weak_alias(_sys_nanosleep, _nanosleep) -#endif - -/* - * Copy timeout to local variable and call the syscall. - */ -int -nanosleep(const struct timespec50 *ts50, struct timespec50 *rts50) -{ - struct timespec ts, *tsp; - struct timespec rts, *rtsp; - int error; - - rtsp = rts50 ? &rts : NULL; - if (ts50) - timespec50_to_timespec(ts50, tsp = &ts); - else - tsp = NULL; - error = __nanosleep50(tsp, rtsp); - if (error) - return error; - if (rts50) - timespec_to_timespec50(rtsp, rts50); - return 0; -} diff --git a/lib/libc/compat/sys/compat_ntp_gettime.c b/lib/libc/compat/sys/compat_ntp_gettime.c deleted file mode 100644 index 6fbbbbcbe..000000000 --- a/lib/libc/compat/sys/compat_ntp_gettime.c +++ /dev/null @@ -1,30 +0,0 @@ -/* $NetBSD: compat_ntp_gettime.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_ntp_gettime.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include - -__warn_references(ntp_gettime, - "warning: reference to compatibility ntp_gettime(); include for correct reference") - -int -ntp_gettime(struct ntptimeval30 *ontvp) -{ - struct ntptimeval ntv; - int res; - - res = __ntp_gettime50(&ntv); - ontvp->time.tv_sec = (int32_t)ntv.time.tv_sec; - ontvp->time.tv_usec = ntv.time.tv_nsec / 1000; - ontvp->maxerror = ntv.maxerror; - ontvp->esterror = ntv.esterror; - - return (res); -} diff --git a/lib/libc/compat/sys/compat_sched.c b/lib/libc/compat/sys/compat_sched.c deleted file mode 100644 index ceeb099fb..000000000 --- a/lib/libc/compat/sys/compat_sched.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: compat_sched.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_sched.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include - -__warn_references(sched_rr_get_interval, - "warning: reference to compatibility sched_rr_get_interval(); include to generate correct reference") - -int sched_rr_get_interval(pid_t, struct timespec50 *); - -int -/*ARGSUSED*/ -sched_rr_get_interval(pid_t pid, struct timespec50 *interval) -{ - interval->tv_sec = 0; - interval->tv_nsec = sysconf(_SC_SCHED_RT_TS) * 1000; - return 0; -} diff --git a/lib/libc/compat/sys/compat_select.c b/lib/libc/compat/sys/compat_select.c deleted file mode 100644 index c81de97a9..000000000 --- a/lib/libc/compat/sys/compat_select.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $NetBSD: compat_select.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_select.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -__warn_references(pollts, - "warning: reference to compatibility pollts(); include to generate correct reference") -__warn_references(select, - "warning: reference to compatibility select(); include to generate correct reference") -__warn_references(pselect, - "warning: reference to compatibility pselect(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(select, _select) -__weak_alias(_sys_select, _select) -__weak_alias(pselect, _pselect) -__weak_alias(_sys_pselect, _pselect) -__weak_alias(pollts, _pollts) -__weak_alias(_sys_pollts, _pollts) -#endif -int -pollts(struct pollfd * __restrict fds, nfds_t nfds, - const struct timespec50 * __restrict tim50, - const sigset_t * __restrict sigmask) -{ - struct timespec tim, *timp; - - if (tim50) - timespec50_to_timespec(tim50, timp = &tim); - else - timp = NULL; - return __pollts50(fds, nfds, timp, sigmask); -} - -int -select(int nfds, fd_set * __restrict readfds, fd_set * __restrict writefds, - fd_set * __restrict exceptfds, struct timeval50 * __restrict tim50) -{ - struct timeval tim, *timp; - - if (tim50) - timeval50_to_timeval(tim50, timp = &tim); - else - timp = NULL; - return __select50(nfds, readfds, writefds, exceptfds, timp); -} - -int -pselect(int nfds, fd_set * __restrict readfds, fd_set * __restrict writefds, - fd_set * __restrict exceptfds, const struct timespec50 *__restrict tim50, - const sigset_t * __restrict sigmask) -{ - struct timespec tim, *timp; - - if (tim50) - timespec50_to_timespec(tim50, timp = &tim); - else - timp = NULL; - return __pselect50(nfds, readfds, writefds, exceptfds, timp, sigmask); -} diff --git a/lib/libc/compat/sys/compat_semctl.c b/lib/libc/compat/sys/compat_semctl.c deleted file mode 100644 index 1bc0233c2..000000000 --- a/lib/libc/compat/sys/compat_semctl.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: compat_semctl.c,v 1.6 2015/01/29 20:44:38 joerg Exp $ */ - -/* - * Copyright (c) 1994, 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_semctl.c,v 1.6 2015/01/29 20:44:38 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ -#include -#include -#include -#include -#include -#include -#ifdef __lint__ -#include -#endif - -int -semctl(int semid, int semnum, int cmd, ...) -{ - va_list ap; - union __semun semun; - struct semid_ds ds; - struct semid_ds14 *ds14; - int error; - - va_start(ap, cmd); - switch (cmd) { - case IPC_SET: - case IPC_STAT: - case GETALL: - case SETVAL: - case SETALL: -#ifdef __lint__ - memcpy(&semun, &ap, sizeof(semun)); -#else - semun = va_arg(ap, union __semun); -#endif - break; - default: - break; - } - va_end(ap); - - switch (cmd) { - case IPC_SET: - case IPC_STAT: - ds14 = (void *)semun.buf; - if (cmd == IPC_SET) - __semid_ds14_to_native(ds14, &ds); - semun.buf = &ds; - break; - default: - ds14 = NULL; - break; - } - - error = __semctl50(semid, semnum, cmd, &semun); - if (error) - return error; - - if (cmd == IPC_STAT) - __native_to_semid_ds14(&ds, ds14); - return 0; -} diff --git a/lib/libc/compat/sys/compat_settimeofday.c b/lib/libc/compat/sys/compat_settimeofday.c deleted file mode 100644 index cafbc3fe6..000000000 --- a/lib/libc/compat/sys/compat_settimeofday.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: compat_settimeofday.c,v 1.2 2009/01/11 02:46:26 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_settimeofday.c,v 1.2 2009/01/11 02:46:26 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include - -__warn_references(settimeofday, - "warning: reference to compatibility settimeofday(); include to generate correct reference") - -#ifdef __weak_alias -__weak_alias(settimeofday, _settimeofday) -__weak_alias(__settimeofday, _settimeofday) -#endif -/* - * Copy timeout to local variable and call the syscall. - */ -int -settimeofday(const struct timeval50 * __restrict tv50, - const void * __restrict tvp) -{ - struct timeval tv; - timeval50_to_timeval(tv50, &tv); - return __settimeofday50(&tv, tvp); -} diff --git a/lib/libc/compat/sys/compat_sigaltstack.c b/lib/libc/compat/sys/compat_sigaltstack.c deleted file mode 100644 index dfa6d46ef..000000000 --- a/lib/libc/compat/sys/compat_sigaltstack.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: compat_sigaltstack.c,v 1.5 2012/03/20 17:06:00 matt Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_sigaltstack.c,v 1.5 2012/03/20 17:06:00 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include -#include -#include - -int -sigaltstack(const struct sigaltstack13 *onss, struct sigaltstack13 *ooss) -{ - stack_t nss, oss; - int error; - - nss.ss_sp = onss->ss_sp; - nss.ss_size = onss->ss_size; - nss.ss_flags = onss->ss_flags; - - error = __sigaltstack14(&nss, &oss); - - if (error == 0 && ooss != NULL) { - ooss->ss_sp = oss.ss_sp; - if (oss.ss_size > INT_MAX) - ooss->ss_size = INT_MAX; - else - ooss->ss_size = (int)oss.ss_size; - ooss->ss_flags = oss.ss_flags; - } - - return (error); -} diff --git a/lib/libc/compat/sys/compat_sigtimedwait.c b/lib/libc/compat/sys/compat_sigtimedwait.c deleted file mode 100644 index 1d7349536..000000000 --- a/lib/libc/compat/sys/compat_sigtimedwait.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: compat_sigtimedwait.c,v 1.2 2009/01/11 02:46:27 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_sigtimedwait.c,v 1.2 2009/01/11 02:46:27 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(sigtimedwait, _sigtimedwait) -#endif -/* - * Copy timeout to local variable and call the syscall. - */ -int -sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info, - const struct timespec50 * __restrict timeout) -{ - struct timespec ts; - - if (timeout) { - timespec50_to_timespec(timeout, &ts); - return ____sigtimedwait50(set, info, &ts); - } else - return ____sigtimedwait50(set, info, NULL); -} - -int -__sigtimedwait(const sigset_t * __restrict set, siginfo_t * __restrict info, - struct timespec50 * __restrict timeout) -{ - return sigtimedwait(set, info, timeout); -} diff --git a/lib/libc/compat/sys/compat_socket.c b/lib/libc/compat/sys/compat_socket.c deleted file mode 100644 index 31a6dc7a5..000000000 --- a/lib/libc/compat/sys/compat_socket.c +++ /dev/null @@ -1,27 +0,0 @@ -/* $NetBSD: compat_socket.c,v 1.1 2006/06/26 21:23:56 mrg Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_socket.c,v 1.1 2006/06/26 21:23:56 mrg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include - -__warn_references(socket, - "warning: reference to compatibility socket(); include for correct reference") - -int -socket(int domain, int type, int protocol) -{ - int res; - - res = __socket30(domain, type, protocol); - if (errno == EAFNOSUPPORT) - errno = EPROTONOSUPPORT; - return res; -} diff --git a/lib/libc/compat/sys/compat_stat.c b/lib/libc/compat/sys/compat_stat.c deleted file mode 100644 index d9cb4c50f..000000000 --- a/lib/libc/compat/sys/compat_stat.c +++ /dev/null @@ -1,126 +0,0 @@ -/* $NetBSD: compat_stat.c,v 1.4 2013/10/04 21:07:37 christos Exp $ */ - -/* - * Copyright (c) 1997 Frank van der Linden - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project - * by Frank van der Linden - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_stat.c,v 1.4 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include -#include -#include -#include - -__warn_references(stat, - "warning: reference to compatibility stat(); include to generate correct reference") - -__warn_references(fstat, - "warning: reference to compatibility fstat(); include to generate correct reference") - -__warn_references(lstat, - "warning: reference to compatibility lstat(); include to generate correct reference") - -/* - * Convert from a new to an old stat structure. - */ - -static void cvtstat(const struct stat *, struct stat12 *); - -__strong_alias(stat, __compat_stat) -__strong_alias(lstat, __compat_lstat) -__strong_alias(fstat, __compat_fstat) - -static void -cvtstat(const struct stat *st, struct stat12 *ost) -{ - - ost->st_dev = (uint32_t)st->st_dev; - ost->st_ino = (uint32_t)st->st_ino; - ost->st_mode = st->st_mode; - if (st->st_nlink >= (1 << 15)) - ost->st_nlink = (1 << 15) - 1; - else - ost->st_nlink = st->st_nlink; - ost->st_uid = st->st_uid; - ost->st_gid = st->st_gid; - ost->st_rdev = (uint32_t)st->st_rdev; - ost->st_atimespec.tv_sec = (int32_t)st->st_atimespec.tv_sec; - ost->st_atimespec.tv_nsec = st->st_atimespec.tv_nsec; - ost->st_mtimespec.tv_sec = (int32_t)st->st_mtimespec.tv_sec; - ost->st_mtimespec.tv_nsec = st->st_mtimespec.tv_nsec; - ost->st_ctimespec.tv_sec = (int32_t)st->st_ctimespec.tv_sec; - ost->st_ctimespec.tv_nsec = st->st_ctimespec.tv_nsec; - ost->st_size = st->st_size; - ost->st_blocks = st->st_blocks; - ost->st_blksize = st->st_blksize; - ost->st_flags = st->st_flags; - ost->st_gen = st->st_gen; -} - -int -__compat_stat(const char *file, struct stat12 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __stat50(file, &nst)) < 0) - return ret; - cvtstat(&nst, ost); - return ret; -} - -int -__compat_fstat(int f, struct stat12 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __fstat50(f, &nst)) < 0) - return ret; - cvtstat(&nst, ost); - return ret; -} - -int -__compat_lstat(const char *file, struct stat12 *ost) -{ - struct stat nst; - int ret; - - if ((ret = __lstat50(file, &nst)) < 0) - return ret; - cvtstat(&nst, ost); - return ret; -} diff --git a/lib/libc/compat/sys/compat_statfs.c b/lib/libc/compat/sys/compat_statfs.c deleted file mode 100644 index ca18276e5..000000000 --- a/lib/libc/compat/sys/compat_statfs.c +++ /dev/null @@ -1,193 +0,0 @@ -/* $NetBSD: compat_statfs.c,v 1.7 2013/10/04 21:07:37 christos Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_statfs.c,v 1.7 2013/10/04 21:07:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -__warn_references(statfs, - "warning: reference to obsolete statfs(); use statvfs()") - -__warn_references(fstatfs, - "warning: reference to obsolete fstatfs(); use fstatvfs()") - -__warn_references(fhstatfs, - "warning: reference to obsolete fhstatfs(); use fhstatvfs()") - -__warn_references(getfsstat, - "warning: reference to obsolete getfsstat(); use getvfsstat()") - -__strong_alias(statfs, __compat_statfs) -__strong_alias(fstatfs, __compat_fstatfs) -__strong_alias(fhstatfs, __compat_fhstatfs) -__strong_alias(getfsstat, __compat_getfsstat) - -/* - * Convert from a new statvfs to an old statfs structure. - */ - -static void vfs2fs(struct statfs12 *, const struct statvfs *); - -#define MOUNTNO_NONE 0 -#define MOUNTNO_UFS 1 /* UNIX "Fast" Filesystem */ -#define MOUNTNO_NFS 2 /* Network Filesystem */ -#define MOUNTNO_MFS 3 /* Memory Filesystem */ -#define MOUNTNO_MSDOS 4 /* MSDOS Filesystem */ -#define MOUNTNO_CD9660 5 /* iso9660 cdrom */ -#define MOUNTNO_FDESC 6 /* /dev/fd filesystem */ -#define MOUNTNO_KERNFS 7 /* kernel variable filesystem */ -#define MOUNTNO_DEVFS 8 /* device node filesystem */ -#define MOUNTNO_AFS 9 /* AFS 3.x */ -static const struct { - const char *name; - const int value; -} nv[] = { - { MOUNT_UFS, MOUNTNO_UFS }, - { MOUNT_NFS, MOUNTNO_NFS }, - { MOUNT_MFS, MOUNTNO_MFS }, - { MOUNT_MSDOS, MOUNTNO_MSDOS }, - { MOUNT_CD9660, MOUNTNO_CD9660 }, - { MOUNT_FDESC, MOUNTNO_FDESC }, - { MOUNT_KERNFS, MOUNTNO_KERNFS }, - { MOUNT_AFS, MOUNTNO_AFS }, -}; - -static void -vfs2fs(struct statfs12 *bfs, const struct statvfs *fs) -{ - size_t i = 0; - bfs->f_type = 0; - bfs->f_oflags = (short)fs->f_flag; - - for (i = 0; i < sizeof(nv) / sizeof(nv[0]); i++) { - if (strcmp(nv[i].name, fs->f_fstypename) == 0) { - bfs->f_type = nv[i].value; - break; - } - } -#define CLAMP(a) (long)(((a) & ~LONG_MAX) ? LONG_MAX : (a)) - bfs->f_bsize = CLAMP(fs->f_frsize); - bfs->f_iosize = CLAMP(fs->f_iosize); - bfs->f_blocks = CLAMP(fs->f_blocks); - bfs->f_bfree = CLAMP(fs->f_bfree); - if (fs->f_bfree > fs->f_bresvd) - bfs->f_bavail = CLAMP(fs->f_bfree - fs->f_bresvd); - else - bfs->f_bavail = -CLAMP(fs->f_bresvd - fs->f_bfree); - bfs->f_files = CLAMP(fs->f_files); - bfs->f_ffree = CLAMP(fs->f_ffree); - bfs->f_fsid = fs->f_fsidx; - bfs->f_owner = fs->f_owner; - bfs->f_flags = (long)fs->f_flag; - bfs->f_syncwrites = CLAMP(fs->f_syncwrites); - bfs->f_asyncwrites = CLAMP(fs->f_asyncwrites); - (void)strncpy(bfs->f_fstypename, fs->f_fstypename, - sizeof(bfs->f_fstypename)); - (void)strncpy(bfs->f_mntonname, fs->f_mntonname, - sizeof(bfs->f_mntonname)); - (void)strncpy(bfs->f_mntfromname, fs->f_mntfromname, - sizeof(bfs->f_mntfromname)); -} - -int -__compat_statfs(const char *file, struct statfs12 *ost) -{ - struct statvfs nst; - int ret; - - if ((ret = statvfs(file, &nst)) == -1) - return ret; - vfs2fs(ost, &nst); - return ret; -} - -int -__compat_fstatfs(int f, struct statfs12 *ost) -{ - struct statvfs nst; - int ret; - - if ((ret = fstatvfs(f, &nst)) == -1) - return ret; - vfs2fs(ost, &nst); - return ret; -} - -int __fhstatvfs140(const void *fhp, size_t fh_size, struct statvfs *buf, - int flags); - -int -__compat_fhstatfs(const struct compat_30_fhandle *fh, struct statfs12 *ost) -{ - struct statvfs nst; - int ret; - - if ((ret = __fhstatvfs140(fh, FHANDLE30_SIZE, &nst, ST_WAIT)) == -1) - return ret; - vfs2fs(ost, &nst); - return ret; -} - -int -__compat_getfsstat(struct statfs12 *ost, long size, int flags) -{ - struct statvfs *nst; - int ret, i; - size_t bsize = (size_t)(size / sizeof(*ost)) * sizeof(*nst); - - if (ost != NULL) { - if ((nst = malloc(bsize)) == NULL) - return -1; - } else - nst = NULL; - - if ((ret = getvfsstat(nst, bsize, flags)) == -1) - goto done; - if (nst) - for (i = 0; i < ret; i++) - vfs2fs(&ost[i], &nst[i]); -done: - if (nst) - free(nst); - return ret; -} diff --git a/lib/libc/compat/sys/compat_timer.c b/lib/libc/compat/sys/compat_timer.c deleted file mode 100644 index 8c09a393a..000000000 --- a/lib/libc/compat/sys/compat_timer.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: compat_timer.c,v 1.2 2009/01/11 02:46:27 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_timer.c,v 1.2 2009/01/11 02:46:27 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include - -__warn_references(timer_gettime, - "warning: reference to compatibility timer_gettime(); include to generate correct reference") -__warn_references(timer_settime, - "warning: reference to compatibility timer_settime(); include to generate correct reference") - -int -timer_settime(timer_t timerid, int flags, - const struct itimerspec50 * __restrict tim50, - struct itimerspec50 * __restrict otim50) -{ - struct itimerspec tim, *timp; - struct itimerspec otim, *otimp; - int error; - - otimp = otim50 ? &otim : NULL; - if (tim50) - itimerspec50_to_itimerspec(tim50, timp = &tim); - else - timp = NULL; - error = __timer_settime50(timerid, flags, timp, otimp); - if (error) - return error; - if (otim50) - itimerspec_to_itimerspec50(otimp, otim50); - return 0; -} - -int -timer_gettime(timer_t timerid, struct itimerspec50 *tim50) -{ - struct itimerspec tim, *timp = tim50 ? &tim : NULL; - int error = __timer_gettime50(timerid, timp); - if (error) - return error; - if (tim50) - itimerspec_to_itimerspec50(timp, tim50); - return 0; -} diff --git a/lib/libc/compat/sys/compat_utimes.c b/lib/libc/compat/sys/compat_utimes.c deleted file mode 100644 index a5664341e..000000000 --- a/lib/libc/compat/sys/compat_utimes.c +++ /dev/null @@ -1,88 +0,0 @@ -/* $NetBSD: compat_utimes.c,v 1.2 2009/01/11 02:46:27 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_utimes.c,v 1.2 2009/01/11 02:46:27 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include - -__warn_references(utimes, - "warning: reference to compatibility utimes(); include to generate correct reference") -__warn_references(lutimes, - "warning: reference to compatibility lutimes(); include to generate correct reference") -__warn_references(futimes, - "warning: reference to compatibility futimes(); include to generate correct reference") - -/* - * libc12 compatible f,l,utimes routine. - */ -int -utimes(const char *path, const struct timeval50 *tv50) -{ - struct timeval tv[2]; - - if (tv50) { - timeval50_to_timeval(&tv50[0], &tv[0]); - timeval50_to_timeval(&tv50[1], &tv[1]); - } - return __utimes50(path, tv50 ? tv : NULL); -} - -int -lutimes(const char *path, const struct timeval50 *tv50) -{ - struct timeval tv[2]; - - if (tv50) { - timeval50_to_timeval(&tv50[0], &tv[0]); - timeval50_to_timeval(&tv50[1], &tv[1]); - } - return __lutimes50(path, tv50 ? tv : NULL); -} - -int -futimes(int fd, const struct timeval50 *tv50) -{ - struct timeval tv[2]; - - if (tv50) { - timeval50_to_timeval(&tv50[0], &tv[0]); - timeval50_to_timeval(&tv50[1], &tv[1]); - } - return __futimes50(fd, tv50 ? tv : NULL); -} diff --git a/lib/libc/compat/sys/compat_wait4.c b/lib/libc/compat/sys/compat_wait4.c deleted file mode 100644 index 1b3e8f17a..000000000 --- a/lib/libc/compat/sys/compat_wait4.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: compat_wait4.c,v 1.3 2015/03/26 11:17:08 justin Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: compat_wait4.c,v 1.3 2015/03/26 11:17:08 justin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define __LIBC12_SOURCE__ - -#include "namespace.h" -#include -#include -#include -#include -#include - -__warn_references(wait3, - "warning: reference to compatibility wait3(); include to generate correct reference") -__warn_references(wait4, - "warning: reference to compatibility wait4(); include to generate correct reference") - -extern void __rusage_to_rusage50(const struct rusage *, struct rusage50 *); - -#ifdef __weak_alias -__weak_alias(wait4, _wait4) -__weak_alias(_sys_wait4, _wait4) -__weak_alias(wait3, _wait3) -#endif - -/* - * libc12 compatible wait4 routine. - */ -pid_t -wait3(int *status, int options, struct rusage50 *ru50) -{ - struct rusage ru; - pid_t rv; - - if ((rv = __wait350(status, options, ru50 ? &ru : NULL)) == -1) - return rv; - if (ru50) - __rusage_to_rusage50(&ru, ru50); - return rv; -} - -pid_t -wait4(pid_t wpid, int *status, int options, struct rusage50 *ru50) -{ - struct rusage ru; - pid_t rv; - - if ((rv = __wait450(wpid, status, options, ru50 ? &ru : NULL)) == -1) - return rv; - if (ru50) - __rusage_to_rusage50(&ru, ru50); - return rv; -} diff --git a/lib/libc/compat/sys/getdirentries.3 b/lib/libc/compat/sys/getdirentries.3 deleted file mode 100644 index b1f4b6e5f..000000000 --- a/lib/libc/compat/sys/getdirentries.3 +++ /dev/null @@ -1,164 +0,0 @@ -.\" $NetBSD: getdirentries.3,v 1.1 2005/09/13 01:44:09 christos Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getdirentries.2 8.1 (Berkeley) 6/9/93 -.\" -.Dd June 9, 1993 -.Dt GETDIRENTRIES 3 -.Os -.Sh NAME -.Nm getdirentries -.Nd "get directory entries in a filesystem independent format" -.Sh SYNOPSIS -.In dirent.h -.Ft int -.Fn getdirentries "int fd" "char *buf" "int nbytes" "long *basep" -.Sh DESCRIPTION -.Bf -symbolic -.\" This interface is available from the compatibility library, libcompat and -This interface is provided for compatibility only and -has been obsoleted by -.Xr getdents 2 . -.Ef -.Pp -.Fn getdirentries -reads directory entries from the directory -referenced by the file descriptor -.Fa fd -into the buffer pointed to by -.Fa buf , -in a filesystem independent format. -Up to -.Fa nbytes -of data will be transferred. -.Fa nbytes -must be greater than or equal to the -block size associated with the file, -see -.Xr stat 2 . -Some filesystems may not support -.Fn getdirentries -with buffers smaller than this size. -.Pp -The data in the buffer is a series of -.Em dirent -structures each containing the following entries: -.Bd -literal -offset indent -unsigned long d_fileno; -unsigned short d_reclen; -unsigned short d_namlen; -char d_name[MAXNAMELEN + 1]; /* see below */ -.Ed -.Pp -The -.Fa d_fileno -entry is a number which is unique for each -distinct file in the filesystem. -Files that are linked by hard links (see -.Xr link 2 ) -have the same -.Fa d_fileno . -If -.Fa d_fileno -is zero, the entry refers to a deleted file. -.Pp -The -.Fa d_reclen -entry is the length, in bytes, of the directory record. -.Pp -The -.Fa d_namlen -entry specifies the length of the file name excluding the null byte. -Thus the actual size of -.Fa d_name -may vary from 1 to -.Dv MAXNAMELEN -\&+ 1. -.Pp -The -.Fa d_name -entry contains a null terminated file name. -.Pp -Entries may be separated by extra space. -The -.Fa d_reclen -entry may be used as an offset from the start of a -.Fa dirent -structure to the next structure, if any. -.Pp -The actual number of bytes transferred is returned. -The current position pointer associated with -.Fa fd -is set to point to the next block of entries. -The pointer may not advance by the number of bytes returned by -.Fn getdirentries . -A value of zero is returned when -the end of the directory has been reached. -.Pp -.Fn getdirentries -writes the position of the block read into the location pointed to by -.Fa basep . -Alternatively, the current position pointer may be set and retrieved by -.Xr lseek 2 . -The current position pointer should only be set to a value returned by -.Xr lseek 2 , -a value returned in the location pointed to by -.Fa basep , -or zero. -.Sh RETURN VALUES -If successful, the number of bytes actually transferred is returned. -Otherwise, \-1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn getdirentries -will fail if: -.Bl -tag -width Er -.It Bq Er EBADF -.Fa fd -is not a valid file descriptor open for reading. -.It Bq Er EFAULT -Either -.Fa buf -or -.Fa basep -point outside the allocated address space. -.It Bq Er EIO -An -.Tn I/O -error occurred while reading from or writing to the file system. -.El -.Sh SEE ALSO -.Xr lseek 2 , -.Xr open 2 -.Sh HISTORY -The -.Fn getdirentries -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/compat/time/Makefile.inc b/lib/libc/compat/time/Makefile.inc deleted file mode 100644 index 9728ed1c3..000000000 --- a/lib/libc/compat/time/Makefile.inc +++ /dev/null @@ -1,4 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2009/01/11 03:46:25 christos Exp $ - -.PATH: ${COMPATDIR}/time -SRCS+= compat_localtime.c compat_difftime.c diff --git a/lib/libc/compat/time/compat_difftime.c b/lib/libc/compat/time/compat_difftime.c deleted file mode 100644 index 30f08ff01..000000000 --- a/lib/libc/compat/time/compat_difftime.c +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: compat_difftime.c,v 1.2 2009/01/11 03:46:25 christos Exp $ */ -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include "namespace.h" -#include - -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(difftime,_difftime) -#endif - -#define timeval timeval50 -#define timespec timespec50 -#define time_t int32_t - -#include "time/difftime.c" diff --git a/lib/libc/compat/time/compat_localtime.c b/lib/libc/compat/time/compat_localtime.c deleted file mode 100644 index 03a63e1a0..000000000 --- a/lib/libc/compat/time/compat_localtime.c +++ /dev/null @@ -1,85 +0,0 @@ -/* $NetBSD: compat_localtime.c,v 1.3 2011/02/21 22:07:44 christos Exp $ */ - -/* - * Written by Jason R. Thorpe , October 21, 1997. - * Public domain. - */ - -#include "namespace.h" -#include - -#define __LIBC12_SOURCE__ -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(ctime_r,_ctime_r) -__weak_alias(ctime_rz,_ctime_rz) -__weak_alias(gmtime_r,_gmtime_r) -__weak_alias(localtime_r,_localtime_r) -__weak_alias(localtime_rz,_localtime_rz) -__weak_alias(mktime_z,_mktime_z) -__weak_alias(offtime,_offtime) -__weak_alias(posix2time,_posix2time) -__weak_alias(posix2time_z,_posix2time_z) -__weak_alias(time2posix,_time2posix) -__weak_alias(timegm,_timegm) -__weak_alias(timelocal,_timelocal) -__weak_alias(timeoff,_timeoff) -__weak_alias(tzset,_tzset) -__weak_alias(tzsetwall,_tzsetwall) -#endif - -__warn_references(ctime_r, - "warning: reference to compatibility ctime_r();" - " include for correct reference") -__warn_references(ctime_rz, - "warning: reference to compatibility ctime_rz();" - " include for correct reference") -__warn_references(gmtime_r, - "warning: reference to compatibility gmtime_r();" - " include for correct reference") -__warn_references(localtime_r, - "warning: reference to compatibility localtime_r();" - " include for correct reference") -__warn_references(localtime_rz, - "warning: reference to compatibility localtime_rz();" - " include for correct reference") -__warn_references(mktime_z, - "warning: reference to compatibility mktime_z();" - " include for correct reference") -__warn_references(offtime, - "warning: reference to compatibility offtime();" - " include for correct reference") -__warn_references(posix2time, - "warning: reference to compatibility posix2time();" - " include for correct reference") -__warn_references(posix2time_z, - "warning: reference to compatibility posix2time_z();" - " include for correct reference") -__warn_references(time2posix, - "warning: reference to compatibility time2posix();" - " include for correct reference") -__warn_references(timegm, - "warning: reference to compatibility timegm();" - " include for correct reference") -__warn_references(timelocal, - "warning: reference to compatibility timelocal();" - " include for correct reference") -__warn_references(timeoff, - "warning: reference to compatibility timeoff();" - " include for correct reference") -__warn_references(tzset, - "warning: reference to compatibility tzset();" - " include for correct reference") -__warn_references(tzsetwall, - "warning: reference to compatibility tzsetwall();" - " include for correct reference") - -#define timeval timeval50 -#define timespec timespec50 -#define time_t int32_t - -#include "time/localtime.c" diff --git a/lib/libc/compiler_rt/Makefile.inc b/lib/libc/compiler_rt/Makefile.inc deleted file mode 100644 index 2185c3657..000000000 --- a/lib/libc/compiler_rt/Makefile.inc +++ /dev/null @@ -1,270 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.27 2014/09/03 19:29:14 matt Exp $ - -COMPILER_RT_SRCDIR= ${NETBSDSRCDIR}/sys/external/bsd/compiler_rt/dist - -.if ${LIBC_MACHINE_ARCH} == "powerpc" || ${LIBC_MACHINE_ARCH} == "powerpc64" -COMPILER_RT_CPU_DIR= ${COMPILER_RT_SRCDIR}/lib/builtins/ppc -COMPILER_RT_ARCH_DIR= ${COMPILER_RT_SRCDIR}/lib/builtins/ppc -.else -COMPILER_RT_CPU_DIR= ${COMPILER_RT_SRCDIR}/lib/builtins/${LIBC_MACHINE_CPU} -COMPILER_RT_ARCH_DIR= ${COMPILER_RT_SRCDIR}/lib/builtins/${LIBC_MACHINE_ARCH} -.endif - -.if defined(__MINIX) -LIBC_MACHINE_CPU?= ${MACHINE_CPU} -.endif # defined(__MINIX) - -.PATH: ${COMPILER_RT_CPU_DIR} -.PATH: ${COMPILER_RT_ARCH_DIR} -.PATH: ${COMPILER_RT_SRCDIR}/lib/builtins -.PATH: ${COMPILER_RT_SRCDIR}/lib/profile - -# Complex support needs parts of libm -#GENERIC_SRCS+= -# mulxc3.c \ -# mulsc3.c \ -# divxc3.c \ -# divdc3.c \ -# divsc3.c - -# Implemented on top of our atomic interface. -#GENERIC_SRCS+= atomic.c - -.if ${HAVE_LIBGCC_EH} == "no" -GENERIC_SRCS+= \ - gcc_personality_v0.c -.endif - -.if 0 -# Conflicts with soft-float -GENERIC_SRCS+= \ - comparedf2.c \ - comparesf2.c \ - adddf3.c \ - addsf3.c \ - addtf3.c \ - divdf3.c \ - divsf3.c \ - divtf3.c \ - extendsfdf2.c \ - extendsftf2.c \ - extenddftf2.c \ - fixdfsi.c \ - fixdfti.c \ - fixsfsi.c \ - fixsfti.c \ - floatsidf.c \ - floatsisf.c \ - floatunsidf.c \ - floatunsisf.c \ - muldf3.c \ - mulsf3.c \ - multf3.c \ - subdf3.c \ - subsf3.c \ - subtf3.c \ - truncdfsf2.c \ - trunctfdf2.c \ - trunctfsf2.c -.endif - -GENERIC_SRCS+= \ - absvsi2.c \ - absvti2.c \ - addvsi3.c \ - addvti3.c \ - ashlti3.c \ - ashrti3.c \ - clzti2.c \ - cmpti2.c \ - ctzti2.c \ - divti3.c \ - ffsti2.c \ - fixsfdi.c \ - fixdfdi.c \ - fixunsdfdi.c \ - fixunsdfsi.c \ - fixunssfdi.c \ - fixunssfsi.c \ - fixunsxfdi.c \ - fixunsxfsi.c \ - fixxfdi.c \ - floatdidf.c \ - floatdisf.c \ - floatdixf.c \ - floatundidf.c \ - floatundisf.c \ - floatundixf.c \ - int_util.c \ - lshrti3.c \ - modti3.c \ - muldc3.c \ - mulosi4.c \ - muloti4.c \ - multi3.c \ - mulvsi3.c \ - mulvti3.c \ - negdf2.c \ - negsf2.c \ - negti2.c \ - negvsi2.c \ - negvti2.c \ - paritysi2.c \ - parityti2.c \ - popcountsi2.c \ - popcountti2.c \ - powidf2.c \ - powisf2.c \ - powitf2.c \ - powixf2.c \ - subvsi3.c \ - subvti3.c \ - ucmpti2.c \ - udivmodti4.c \ - udivti3.c \ - umodti3.c - -.if ${MACHINE_ARCH} != "aarch64" -GENERIC_SRCS+= \ - fixunsdfti.c \ - fixunssfti.c \ - fixunsxfti.c \ - fixxfti.c \ - floattidf.c \ - floattisf.c \ - floattixf.c \ - floatuntidf.c \ - floatuntisf.c \ - floatuntixf.c -.endif - -# These have h/w instructions which are always used. -.if ${LIBC_MACHINE_ARCH} != "alpha" && ${LIBC_MACHINE_CPU} != "aarch64" \ - && ${LIBC_MACHINE_CPU} != "powerpc" && ${LIBC_MACHINE_CPU} != "or1k" -GENERIC_SRCS+= \ - clzsi2.c -.endif - -# These have h/w instructions which are always used. -.if ${LIBC_MACHINE_ARCH} != "alpha" && ${LIBC_MACHINE_ARCH} != "vax" \ - && ${LIBC_MACHINE_CPU} != "aarch64" && ${LIBC_MACHINE_CPU} != "powerpc" \ - && ${LIBC_MACHINE_CPU} != "or1k" -GENERIC_SRCS+= \ - ctzsi2.c -.endif - -# These have h/w instructions which are always used. -.if ${LIBC_MACHINE_ARCH} != "alpha" && ${LIBC_MACHINE_CPU} != "powerpc" \ - && ${LIBC_MACHINE_CPU} != "aarch64" && ${LIBC_MACHINE_ARCH} != "vax" -GENERIC_SRCS+= \ - divmodsi4.c \ - divsi3.c \ - modsi3.c \ - udivmodsi4.c \ - umodsi3.c - -. if ${LIBC_MACHINE_CPU} != "sh3" -# On sh3 __udivsi3 is gcc "millicode" with special calling convention -# (less registers clobbered than usual). Each DSO that needs it gets -# its own hidden copy from libgcc.a. -GENERIC_SRCS+= \ - udivsi3.c -. endif -.endif - - -GENERIC_SRCS+= \ - absvdi2.c \ - addvdi3.c \ - mulodi4.c \ - mulvdi3.c \ - negvdi2.c \ - paritydi2.c \ - popcountdi2.c \ - subvdi3.c - -# These have h/w instructions which are always used. -.if ${LIBC_MACHINE_ARCH} != "alpha" && ${LIBC_MACHINE_CPU} != "powerpc64" \ - && ${LIBC_MACHINE_ARCH} != "aarch64" && ${LIBC_MACHINE_CPU} != "or1k" -GENERIC_SRCS+= \ - clzdi2.c \ - ctzdi2.c \ - ffsdi2.c -.endif - -# Don't need these on 64-bit machines. -.if empty(LIBC_MACHINE_ARCH:M*64*) && ${LIBC_MACHINE_ARCH} != "alpha" -GENERIC_SRCS+= \ - cmpdi2.c \ - ashldi3.c \ - ashrdi3.c \ - divdi3.c \ - divmoddi4.c \ - lshrdi3.c \ - moddi3.c \ - muldi3.c \ - negdi2.c \ - ucmpdi2.c \ - udivdi3.c \ - udivmoddi4.c \ - umoddi3.c -.endif - -GENERIC_SRCS+= \ - GCDAProfiling.c \ - InstrProfiling.c \ - InstrProfilingBuffer.c \ - InstrProfilingFile.c \ - InstrProfilingPlatformOther.c - -.if ${LIBC_MACHINE_ARCH} == "powerpc" || ${LIBC_MACHINE_ARCH} == "powerpc64" -GENERIC_SRCS+= \ - fixtfdi.c \ - fixunstfdi.c \ - floatditf.c \ - floatunditf.c \ - gcc_qadd.c \ - gcc_qdiv.c \ - gcc_qmul.c \ - gcc_qsub.c -.endif - -.if ${LIBC_MACHINE_CPU} == "aarch64" -GENERIC_SRCS+= \ - clear_cache.c -.endif - -.if ${LIBC_MACHINE_CPU} == "arm" -.if !empty(LIBC_MACHINE_ARCH:Mearm*) -GENERIC_SRCS+= \ - aeabi_idivmod.S \ - aeabi_ldivmod.S \ - aeabi_uidivmod.S \ - aeabi_uldivmod.S -.endif -GENERIC_SRCS+= \ - clear_cache.c -# Not yet, overlaps with softfloat -# aeabi_dcmp.S \ -# aeabi_fcmp.S -# Not yet, requires ARMv6 -#GENERIC_SRCS+= \ -# bswapdi2.S \ -# bswapsi2.S -.endif - -.for src in ${GENERIC_SRCS} -. if exists(${COMPILER_RT_CPU_DIR}/${src:R}.S) || \ - exists(${COMPILER_RT_ARCH_DIR}/${src:R}.S) -SRCS+= ${src:R}.S -. else -SRCS+= ${src} -. if ${src:E} != "cc" -COPTS.${src}+= -Wno-missing-prototypes \ - -Wno-old-style-definition \ - -Wno-strict-prototypes \ - -Wno-uninitialized \ - -Wno-cast-qual -. endif -. endif -.endfor diff --git a/lib/libc/db/Makefile.inc b/lib/libc/db/Makefile.inc deleted file mode 100644 index 0763f5553..000000000 --- a/lib/libc/db/Makefile.inc +++ /dev/null @@ -1,11 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.8 2011/08/09 13:03:36 joerg Exp $ -# @(#)Makefile.inc 8.2 (Berkeley) 2/21/94 -# -CPPFLAGS+=-D__DBINTERFACE_PRIVATE - -.include "${.CURDIR}/db/btree/Makefile.inc" -.include "${.CURDIR}/db/db/Makefile.inc" -.include "${.CURDIR}/db/hash/Makefile.inc" -.include "${.CURDIR}/db/man/Makefile.inc" -.include "${.CURDIR}/db/mpool/Makefile.inc" -.include "${.CURDIR}/db/recno/Makefile.inc" diff --git a/lib/libc/db/btree/Makefile.inc b/lib/libc/db/btree/Makefile.inc deleted file mode 100644 index 46fbb029e..000000000 --- a/lib/libc/db/btree/Makefile.inc +++ /dev/null @@ -1,8 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.6 1996/05/03 21:50:36 cgd Exp $ -# @(#)Makefile.inc 8.2 (Berkeley) 7/14/94 - -.PATH: ${.CURDIR}/db/btree - -SRCS+= bt_close.c bt_conv.c bt_debug.c bt_delete.c bt_get.c bt_open.c \ - bt_overflow.c bt_page.c bt_put.c bt_search.c bt_seq.c bt_split.c \ - bt_utils.c diff --git a/lib/libc/db/btree/bt_close.c b/lib/libc/db/btree/bt_close.c deleted file mode 100644 index a085952e0..000000000 --- a/lib/libc/db/btree/bt_close.c +++ /dev/null @@ -1,180 +0,0 @@ -/* $NetBSD: bt_close.c,v 1.14 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_close.c,v 1.14 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_meta(BTREE *); - -/* - * BT_CLOSE -- Close a btree. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_close(DB *dbp) -{ - BTREE *t; - int fd; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Sync the tree. */ - if (__bt_sync(dbp, 0) == RET_ERROR) - return (RET_ERROR); - - /* Close the memory pool. */ - if (mpool_close(t->bt_mp) == RET_ERROR) - return (RET_ERROR); - - /* Free random memory. */ - if (t->bt_cursor.key.data != NULL) { - free(t->bt_cursor.key.data); - t->bt_cursor.key.size = 0; - t->bt_cursor.key.data = NULL; - } - if (t->bt_rkey.data) { - free(t->bt_rkey.data); - t->bt_rkey.size = 0; - t->bt_rkey.data = NULL; - } - if (t->bt_rdata.data) { - free(t->bt_rdata.data); - t->bt_rdata.size = 0; - t->bt_rdata.data = NULL; - } - - fd = t->bt_fd; - free(t); - free(dbp); - return (close(fd) ? RET_ERROR : RET_SUCCESS); -} - -/* - * BT_SYNC -- sync the btree to disk. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_sync(const DB *dbp, u_int flags) -{ - BTREE *t; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Sync doesn't currently take any flags. */ - if (flags != 0) { - errno = EINVAL; - return (RET_ERROR); - } - - if (F_ISSET(t, B_INMEM | B_RDONLY) || !F_ISSET(t, B_MODIFIED)) - return (RET_SUCCESS); - - if (F_ISSET(t, B_METADIRTY) && bt_meta(t) == RET_ERROR) - return (RET_ERROR); - - if ((status = mpool_sync(t->bt_mp)) == RET_SUCCESS) - F_CLR(t, B_MODIFIED); - - return (status); -} - -/* - * BT_META -- write the tree meta data to disk. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_meta(BTREE *t) -{ - BTMETA m; - void *p; - - if ((p = mpool_get(t->bt_mp, P_META, 0)) == NULL) - return (RET_ERROR); - - /* Fill in metadata. */ - m.magic = BTREEMAGIC; - m.version = BTREEVERSION; - m.psize = t->bt_psize; - m.free = t->bt_free; - m.nrecs = t->bt_nrecs; - m.flags = F_ISSET(t, SAVEMETA); - - memmove(p, &m, sizeof(BTMETA)); - mpool_put(t->bt_mp, p, MPOOL_DIRTY); - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/bt_conv.c b/lib/libc/db/btree/bt_conv.c deleted file mode 100644 index 2c5217a39..000000000 --- a/lib/libc/db/btree/bt_conv.c +++ /dev/null @@ -1,214 +0,0 @@ -/* $NetBSD: bt_conv.c,v 1.14 2008/09/10 17:52:35 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_conv.c,v 1.14 2008/09/10 17:52:35 joerg Exp $"); - -#include -#include - -#include -#include "btree.h" - -static void mswap(PAGE *); - -/* - * __BT_BPGIN, __BT_BPGOUT -- - * Convert host-specific number layout to/from the host-independent - * format stored on disk. - * - * Parameters: - * t: tree - * pg: page number - * h: page to convert - */ -void -__bt_pgin(void *t, pgno_t pg, void *pp) -{ - PAGE *h; - indx_t i, top; - uint8_t flags; - char *p; - - if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - M_32_SWAP(h->pgno); - M_32_SWAP(h->prevpg); - M_32_SWAP(h->nextpg); - M_32_SWAP(h->flags); - M_16_SWAP(h->lower); - M_16_SWAP(h->upper); - - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - M_16_SWAP(h->linp[i]); - p = (char *)(void *)GETBINTERNAL(h, i); - P_32_SWAP(p); - p += sizeof(uint32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - if (*(uint8_t *)p & P_BIGKEY) { - p += sizeof(uint8_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - M_16_SWAP(h->linp[i]); - p = (char *)(void *)GETBLEAF(h, i); - P_32_SWAP(p); - p += sizeof(uint32_t); - P_32_SWAP(p); - p += sizeof(uint32_t); - flags = *(uint8_t *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(uint8_t); - if (flags & P_BIGKEY) { - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(uint32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - } -} - -void -__bt_pgout(void *t, pgno_t pg, void *pp) -{ - PAGE *h; - indx_t i, top; - uint8_t flags; - char *p; - - if (!F_ISSET(((BTREE *)t), B_NEEDSWAP)) - return; - if (pg == P_META) { - mswap(pp); - return; - } - - h = pp; - top = NEXTINDEX(h); - if ((h->flags & P_TYPE) == P_BINTERNAL) - for (i = 0; i < top; i++) { - p = (char *)(void *)GETBINTERNAL(h, i); - P_32_SWAP(p); - p += sizeof(uint32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - if (*(uint8_t *)p & P_BIGKEY) { - p += sizeof(uint8_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - M_16_SWAP(h->linp[i]); - } - else if ((h->flags & P_TYPE) == P_BLEAF) - for (i = 0; i < top; i++) { - p = (char *)(void *)GETBLEAF(h, i); - P_32_SWAP(p); - p += sizeof(uint32_t); - P_32_SWAP(p); - p += sizeof(uint32_t); - flags = *(uint8_t *)p; - if (flags & (P_BIGKEY | P_BIGDATA)) { - p += sizeof(uint8_t); - if (flags & P_BIGKEY) { - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - if (flags & P_BIGDATA) { - p += sizeof(uint32_t); - P_32_SWAP(p); - p += sizeof(pgno_t); - P_32_SWAP(p); - } - } - M_16_SWAP(h->linp[i]); - } - - M_32_SWAP(h->pgno); - M_32_SWAP(h->prevpg); - M_32_SWAP(h->nextpg); - M_32_SWAP(h->flags); - M_16_SWAP(h->lower); - M_16_SWAP(h->upper); -} - -/* - * MSWAP -- Actually swap the bytes on the meta page. - * - * Parameters: - * p: page to convert - */ -static void -mswap(PAGE *pg) -{ - char *p; - - p = (char *)(void *)pg; - P_32_SWAP(p); /* magic */ - p += sizeof(uint32_t); - P_32_SWAP(p); /* version */ - p += sizeof(uint32_t); - P_32_SWAP(p); /* psize */ - p += sizeof(uint32_t); - P_32_SWAP(p); /* free */ - p += sizeof(uint32_t); - P_32_SWAP(p); /* nrecs */ - p += sizeof(uint32_t); - P_32_SWAP(p); /* flags */ - p += sizeof(uint32_t); -} diff --git a/lib/libc/db/btree/bt_debug.c b/lib/libc/db/btree/bt_debug.c deleted file mode 100644 index 5b5f2cd81..000000000 --- a/lib/libc/db/btree/bt_debug.c +++ /dev/null @@ -1,341 +0,0 @@ -/* $NetBSD: bt_debug.c,v 1.16 2011/07/17 20:47:39 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_debug.c,v 1.16 2011/07/17 20:47:39 christos Exp $"); - -#include -#include -#include -#include - -#include -#include "btree.h" - -#ifdef DEBUG -/* - * BT_DUMP -- Dump the tree - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_dump(DB *dbp) -{ - BTREE *t; - PAGE *h; - pgno_t i; - const char *sep; - - t = dbp->internal; - (void)fprintf(stderr, "%s: pgsz %d", - F_ISSET(t, B_INMEM) ? "memory" : "disk", t->bt_psize); - if (F_ISSET(t, R_RECNO)) - (void)fprintf(stderr, " keys %lu", (unsigned long) t->bt_nrecs); -#undef X -#define X(flag, name) \ - if (F_ISSET(t, flag)) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (t->flags != 0) { - sep = " flags ("; - X(R_FIXLEN, "FIXLEN"); - X(B_INMEM, "INMEM"); - X(B_NODUPS, "NODUPS"); - X(B_RDONLY, "RDONLY"); - X(R_RECNO, "RECNO"); - X(B_METADIRTY,"METADIRTY"); - (void)fprintf(stderr, ")\n"); - } -#undef X - - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DMPAGE -- Dump the meta page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dmpage(PAGE *h) -{ - BTMETA *m; - const char *sep; - - m = (BTMETA *)(void *)h; - (void)fprintf(stderr, "magic %lx\n", (unsigned long) m->magic); - (void)fprintf(stderr, "version %lu\n", (unsigned long) m->version); - (void)fprintf(stderr, "psize %lu\n", (unsigned long) m->psize); - (void)fprintf(stderr, "free %lu\n", (unsigned long) m->free); - (void)fprintf(stderr, "nrecs %lu\n", (unsigned long) m->nrecs); - (void)fprintf(stderr, "flags %lu", (unsigned long) m->flags); -#undef X -#define X(flag, name) \ - if (m->flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - if (m->flags) { - sep = " ("; - X(B_NODUPS, "NODUPS"); - X(R_RECNO, "RECNO"); - (void)fprintf(stderr, ")"); - } -} - -static pgno_t -__bt_pgno_t(const void *m) -{ - pgno_t r; - memcpy(&r, m, sizeof(r)); - return r; -} - -static uint32_t -__bt_uint32_t(const void *m) -{ - uint32_t r; - memcpy(&r, m, sizeof(r)); - return r; -} - -/* - * BT_DNPAGE -- Dump the page - * - * Parameters: - * n: page number to dump. - */ -void -__bt_dnpage(DB *dbp, pgno_t pgno) -{ - BTREE *t; - PAGE *h; - - t = dbp->internal; - if ((h = mpool_get(t->bt_mp, pgno, 0)) != NULL) { - __bt_dpage(h); - (void)mpool_put(t->bt_mp, h, 0); - } -} - -/* - * BT_DPAGE -- Dump the page - * - * Parameters: - * h: pointer to the PAGE - */ -void -__bt_dpage(PAGE *h) -{ - BINTERNAL *bi; - BLEAF *bl; - RINTERNAL *ri; - RLEAF *rl; - indx_t cur, top; - const char *sep; - - (void)fprintf(stderr, " page %d: (", h->pgno); -#undef X -#define X(flag, name) \ - if (h->flags & flag) { \ - (void)fprintf(stderr, "%s%s", sep, name); \ - sep = ", "; \ - } - sep = ""; - X(P_BINTERNAL, "BINTERNAL") /* types */ - X(P_BLEAF, "BLEAF") - X(P_RINTERNAL, "RINTERNAL") /* types */ - X(P_RLEAF, "RLEAF") - X(P_OVERFLOW, "OVERFLOW") - X(P_PRESERVE, "PRESERVE"); - (void)fprintf(stderr, ")\n"); -#undef X - - (void)fprintf(stderr, "\tprev %2d next %2d", h->prevpg, h->nextpg); - if (h->flags & P_OVERFLOW) - return; - - top = NEXTINDEX(h); - (void)fprintf(stderr, " lower %3d upper %3d nextind %d\n", - h->lower, h->upper, top); - for (cur = 0; cur < top; cur++) { - (void)fprintf(stderr, "\t[%03d] %4d ", cur, h->linp[cur]); - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(h, cur); - (void)fprintf(stderr, - "size %03d pgno %03d", bi->ksize, bi->pgno); - if (bi->flags & P_BIGKEY) - (void)fprintf(stderr, " (indirect)"); - else if (bi->ksize) - (void)fprintf(stderr, - " {%.*s}", (int)bi->ksize, bi->bytes); - break; - case P_RINTERNAL: - ri = GETRINTERNAL(h, cur); - (void)fprintf(stderr, "entries %03d pgno %03d", - ri->nrecs, ri->pgno); - break; - case P_BLEAF: - bl = GETBLEAF(h, cur); - if (bl->flags & P_BIGKEY) - (void)fprintf(stderr, - "big key page %lu size %u/", - (unsigned long) __bt_pgno_t(bl->bytes), - __bt_uint32_t(bl->bytes + sizeof(pgno_t))); - else if (bl->ksize) - (void)fprintf(stderr, "%s/", bl->bytes); - if (bl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %u", - (unsigned long) - __bt_pgno_t(bl->bytes + bl->ksize), - __bt_uint32_t(bl->bytes + bl->ksize + - sizeof(pgno_t))); - else if (bl->dsize) - (void)fprintf(stderr, "%.*s", - (int)bl->dsize, bl->bytes + bl->ksize); - break; - case P_RLEAF: - rl = GETRLEAF(h, cur); - if (rl->flags & P_BIGDATA) - (void)fprintf(stderr, - "big data page %lu size %u", - (unsigned long) __bt_pgno_t(rl->bytes), - __bt_uint32_t(rl->bytes + sizeof(pgno_t))); - else if (rl->dsize) - (void)fprintf(stderr, - "%.*s", (int)rl->dsize, rl->bytes); - break; - } - (void)fprintf(stderr, "\n"); - } -} -#endif - -#ifdef STATISTICS -/* - * BT_STAT -- Gather/print the tree statistics - * - * Parameters: - * dbp: pointer to the DB - */ -void -__bt_stat(DB *dbp) -{ - extern unsigned long bt_cache_hit, bt_cache_miss, bt_pfxsaved, bt_rootsplit; - extern unsigned long bt_sortsplit, bt_split; - BTREE *t; - PAGE *h; - pgno_t i, pcont, pinternal, pleaf; - unsigned long ifree, lfree, nkeys; - int levels; - - t = dbp->internal; - pcont = pinternal = pleaf = 0; - nkeys = ifree = lfree = 0; - for (i = P_ROOT; (h = mpool_get(t->bt_mp, i, 0)) != NULL; ++i) { - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - case P_RINTERNAL: - ++pinternal; - ifree += h->upper - h->lower; - break; - case P_BLEAF: - case P_RLEAF: - ++pleaf; - lfree += h->upper - h->lower; - nkeys += NEXTINDEX(h); - break; - case P_OVERFLOW: - ++pcont; - break; - } - (void)mpool_put(t->bt_mp, h, 0); - } - - /* Count the levels of the tree. */ - for (i = P_ROOT, levels = 0 ;; ++levels) { - h = mpool_get(t->bt_mp, i, 0); - if (h->flags & (P_BLEAF|P_RLEAF)) { - if (levels == 0) - levels = 1; - (void)mpool_put(t->bt_mp, h, 0); - break; - } - i = F_ISSET(t, R_RECNO) ? - GETRINTERNAL(h, 0)->pgno : - GETBINTERNAL(h, 0)->pgno; - (void)mpool_put(t->bt_mp, h, 0); - } - - (void)fprintf(stderr, "%d level%s with %ld keys", - levels, levels == 1 ? "" : "s", nkeys); - if (F_ISSET(t, R_RECNO)) - (void)fprintf(stderr, " (%ld header count)", (long)t->bt_nrecs); - (void)fprintf(stderr, - "\n%lu pages (leaf %ld, internal %ld, overflow %ld)\n", - (long)pinternal + pleaf + pcont, (long)pleaf, (long)pinternal, - (long)pcont); - (void)fprintf(stderr, "%ld cache hits, %ld cache misses\n", - bt_cache_hit, bt_cache_miss); - (void)fprintf(stderr, "%ld splits (%ld root splits, %ld sort splits)\n", - bt_split, bt_rootsplit, bt_sortsplit); - pleaf *= t->bt_psize - BTDATAOFF; - if (pleaf) - (void)fprintf(stderr, - "%.0f%% leaf fill (%ld bytes used, %ld bytes free)\n", - ((double)(pleaf - lfree) / pleaf) * 100, - pleaf - lfree, lfree); - pinternal *= t->bt_psize - BTDATAOFF; - if (pinternal) - (void)fprintf(stderr, - "%.0f%% internal fill (%ld bytes used, %ld bytes free\n", - ((double)(pinternal - ifree) / pinternal) * 100, - pinternal - ifree, ifree); - if (bt_pfxsaved) - (void)fprintf(stderr, "prefix checking removed %lu bytes.\n", - bt_pfxsaved); -} -#endif diff --git a/lib/libc/db/btree/bt_delete.c b/lib/libc/db/btree/bt_delete.c deleted file mode 100644 index 701c8b201..000000000 --- a/lib/libc/db/btree/bt_delete.c +++ /dev/null @@ -1,642 +0,0 @@ -/* $NetBSD: bt_delete.c,v 1.17 2009/01/29 02:02:36 lukem Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_delete.c,v 1.17 2009/01/29 02:02:36 lukem Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -static int __bt_bdelete(BTREE *, const DBT *); -static int __bt_curdel(BTREE *, const DBT *, PAGE *, u_int); -static int __bt_pdelete(BTREE *, PAGE *); -static int __bt_relink(BTREE *, PAGE *); -static int __bt_stkacq(BTREE *, PAGE **, CURSOR *); - -/* - * __bt_delete - * Delete the item(s) referenced by a key. - * - * Return RET_SPECIAL if the key is not found. - */ -int -__bt_delete(const DB *dbp, const DBT *key, u_int flags) -{ - BTREE *t; - CURSOR *c; - PAGE *h; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Check for change to a read-only tree. */ - if (F_ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - switch (flags) { - case 0: - status = __bt_bdelete(t, key); - break; - case R_CURSOR: - /* - * If flags is R_CURSOR, delete the cursor. Must already - * have started a scan and not have already deleted it. - */ - c = &t->bt_cursor; - if (F_ISSET(c, CURS_INIT)) { - if (F_ISSET(c, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * If the page is about to be emptied, we'll need to - * delete it, which means we have to acquire a stack. - */ - if (NEXTINDEX(h) == 1) - if (__bt_stkacq(t, &h, &t->bt_cursor)) - return (RET_ERROR); - - status = __bt_dleaf(t, NULL, h, (u_int)c->pg.index); - - if (NEXTINDEX(h) == 0 && status == RET_SUCCESS) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - } else - mpool_put(t->bt_mp, h, - (u_int)(status == RET_SUCCESS ? - MPOOL_DIRTY : 0)); - break; - } - /* FALLTHROUGH */ - default: - errno = EINVAL; - return (RET_ERROR); - } - if (status == RET_SUCCESS) - F_SET(t, B_MODIFIED); - return (status); -} - -/* - * __bt_stkacq -- - * Acquire a stack so we can delete a cursor entry. - * - * Parameters: - * t: tree - * hp: pointer to current, pinned PAGE pointer - * c: pointer to the cursor - * - * Returns: - * 0 on success, 1 on failure - */ -static int -__bt_stkacq(BTREE *t, PAGE **hp, CURSOR *c) -{ - BINTERNAL *bi; - EPG *e; - EPGNO *parent; - PAGE *h; - indx_t idx = 0; /* Pacify gcc */ - pgno_t pgno; - recno_t nextpg, prevpg; - int exact, level; - - /* - * Find the first occurrence of the key in the tree. Toss the - * currently locked page so we don't hit an already-locked page. - */ - h = *hp; - mpool_put(t->bt_mp, h, 0); - if ((e = __bt_search(t, &c->key, &exact)) == NULL) - return (1); - h = e->page; - - /* See if we got it in one shot. */ - if (h->pgno == c->pg.pgno) - goto ret; - - /* - * Move right, looking for the page. At each move we have to move - * up the stack until we don't have to move to the next page. If - * we have to change pages at an internal level, we have to fix the - * stack back up. - */ - while (h->pgno != c->pg.pgno) { - if ((nextpg = h->nextpg) == P_INVALID) - break; - mpool_put(t->bt_mp, h, 0); - - /* Move up the stack. */ - for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (1); - - /* Move to the next index. */ - if (parent->index != NEXTINDEX(h) - 1) { - idx = parent->index + 1; - BT_PUSH(t, h->pgno, idx); - break; - } - mpool_put(t->bt_mp, h, 0); - } - - /* Restore the stack. */ - while (level--) { - /* Push the next level down onto the stack. */ - bi = GETBINTERNAL(h, idx); - pgno = bi->pgno; - BT_PUSH(t, pgno, 0); - - /* Lose the currently pinned page. */ - mpool_put(t->bt_mp, h, 0); - - /* Get the next level down. */ - if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) - return (1); - idx = 0; - } - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, nextpg, 0)) == NULL) - return (1); - } - - if (h->pgno == c->pg.pgno) - goto ret; - - /* Reacquire the original stack. */ - mpool_put(t->bt_mp, h, 0); - if ((e = __bt_search(t, &c->key, &exact)) == NULL) - return (1); - h = e->page; - - /* - * Move left, looking for the page. At each move we have to move - * up the stack until we don't have to change pages to move to the - * next page. If we have to change pages at an internal level, we - * have to fix the stack back up. - */ - while (h->pgno != c->pg.pgno) { - if ((prevpg = h->prevpg) == P_INVALID) - break; - mpool_put(t->bt_mp, h, 0); - - /* Move up the stack. */ - for (level = 0; (parent = BT_POP(t)) != NULL; ++level) { - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (1); - - /* Move to the next index. */ - if (parent->index != 0) { - idx = parent->index - 1; - BT_PUSH(t, h->pgno, idx); - break; - } - mpool_put(t->bt_mp, h, 0); - } - - /* Restore the stack. */ - while (level--) { - /* Push the next level down onto the stack. */ - bi = GETBINTERNAL(h, idx); - pgno = bi->pgno; - - /* Lose the currently pinned page. */ - mpool_put(t->bt_mp, h, 0); - - /* Get the next level down. */ - if ((h = mpool_get(t->bt_mp, pgno, 0)) == NULL) - return (1); - - idx = NEXTINDEX(h) - 1; - BT_PUSH(t, pgno, idx); - } - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, prevpg, 0)) == NULL) - return (1); - } - - -ret: mpool_put(t->bt_mp, h, 0); - return ((*hp = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL); -} - -/* - * __bt_bdelete -- - * Delete all key/data pairs matching the specified key. - * - * Parameters: - * t: tree - * key: key to delete - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -static int -__bt_bdelete(BTREE *t, const DBT *key) -{ - EPG *e; - PAGE *h; - int deleted, exact, redo; - - deleted = 0; - - /* Find any matching record; __bt_search pins the page. */ -loop: if ((e = __bt_search(t, key, &exact)) == NULL) - return (deleted ? RET_SUCCESS : RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (deleted ? RET_SUCCESS : RET_SPECIAL); - } - - /* - * Delete forward, then delete backward, from the found key. If - * there are duplicates and we reach either side of the page, do - * the key search again, so that we get them all. - */ - redo = 0; - h = e->page; - do { - if (__bt_dleaf(t, key, h, (u_int)e->index)) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - if (F_ISSET(t, B_NODUPS)) { - if (NEXTINDEX(h) == 0) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - } else - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); - } - deleted = 1; - } while (e->index < NEXTINDEX(h) && __bt_cmp(t, key, e) == 0); - - /* Check for right-hand edge of the page. */ - if (e->index == NEXTINDEX(h)) - redo = 1; - - /* Delete from the key to the beginning of the page. */ - while (e->index-- > 0) { - if (__bt_cmp(t, key, e) != 0) - break; - if (__bt_dleaf(t, key, h, (u_int)e->index) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - if (e->index == 0) - redo = 1; - } - - /* Check for an empty page. */ - if (NEXTINDEX(h) == 0) { - if (__bt_pdelete(t, h)) - return (RET_ERROR); - goto loop; - } - - /* Put the page. */ - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - if (redo) - goto loop; - return (RET_SUCCESS); -} - -/* - * __bt_pdelete -- - * Delete a single page from the tree. - * - * Parameters: - * t: tree - * h: leaf page - * - * Returns: - * RET_SUCCESS, RET_ERROR. - * - * Side-effects: - * mpool_put's the page - */ -static int -__bt_pdelete(BTREE *t, PAGE *h) -{ - BINTERNAL *bi; - PAGE *pg; - EPGNO *parent; - indx_t cnt, idx, *ip, offset; - uint32_t nksize; - char *from; - - /* - * Walk the parent page stack -- a LIFO stack of the pages that were - * traversed when we searched for the page where the delete occurred. - * Each stack entry is a page number and a page index offset. The - * offset is for the page traversed on the search. We've just deleted - * a page, so we have to delete the key from the parent page. - * - * If the delete from the parent page makes it empty, this process may - * continue all the way up the tree. We stop if we reach the root page - * (which is never deleted, it's just not worth the effort) or if the - * delete does not empty the page. - */ - while ((parent = BT_POP(t)) != NULL) { - /* Get the parent page. */ - if ((pg = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - return (RET_ERROR); - - idx = parent->index; - bi = GETBINTERNAL(pg, idx); - - /* Free any overflow pages. */ - if (bi->flags & P_BIGKEY && - __ovfl_delete(t, bi->bytes) == RET_ERROR) { - mpool_put(t->bt_mp, pg, 0); - return (RET_ERROR); - } - - /* - * Free the parent if it has only the one key and it's not the - * root page. If it's the rootpage, turn it back into an empty - * leaf page. - */ - if (NEXTINDEX(pg) == 1) { - if (pg->pgno == P_ROOT) { - pg->lower = BTDATAOFF; - pg->upper = t->bt_psize; - pg->flags = P_BLEAF; - } else { - if (__bt_relink(t, pg) || __bt_free(t, pg)) - return (RET_ERROR); - continue; - } - } else { - /* Pack remaining key items at the end of the page. */ - nksize = NBINTERNAL(bi->ksize); - from = (char *)(void *)pg + pg->upper; - memmove(from + nksize, from, - (size_t)((char *)(void *)bi - from)); - pg->upper += nksize; - - /* Adjust indices' offsets, shift the indices down. */ - offset = pg->linp[idx]; - for (cnt = idx, ip = &pg->linp[0]; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nksize; - for (cnt = NEXTINDEX(pg) - idx; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nksize : ip[1]; - pg->lower -= sizeof(indx_t); - } - - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - break; - } - - /* Free the leaf page, as long as it wasn't the root. */ - if (h->pgno == P_ROOT) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); - } - return (__bt_relink(t, h) || __bt_free(t, h)); -} - -/* - * __bt_dleaf -- - * Delete a single record from a leaf page. - * - * Parameters: - * t: tree - * key: referenced key - * h: page - * idx: index on page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_dleaf(BTREE *t, const DBT *key, PAGE *h, u_int idx) -{ - BLEAF *bl; - indx_t cnt, *ip, offset; - uint32_t nbytes; - void *to; - char *from; - - /* If this record is referenced by the cursor, delete the cursor. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index == idx && - __bt_curdel(t, key, h, idx)) - return (RET_ERROR); - - /* If the entry uses overflow pages, make them available for reuse. */ - to = bl = GETBLEAF(h, idx); - if (bl->flags & P_BIGKEY && __ovfl_delete(t, bl->bytes) == RET_ERROR) - return (RET_ERROR); - if (bl->flags & P_BIGDATA && - __ovfl_delete(t, bl->bytes + bl->ksize) == RET_ERROR) - return (RET_ERROR); - - /* Pack the remaining key/data items at the end of the page. */ - nbytes = NBLEAF(bl); - from = (char *)(void *)h + h->upper; - memmove(from + nbytes, from, (size_t)((char *)(void *)to - from)); - h->upper += nbytes; - - /* Adjust the indices' offsets, shift the indices down. */ - offset = h->linp[idx]; - for (cnt = idx, ip = &h->linp[0]; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nbytes; - for (cnt = NEXTINDEX(h) - idx; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; - h->lower -= sizeof(indx_t); - - /* If the cursor is on this page, adjust it as necessary. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index > idx) - --t->bt_cursor.pg.index; - - return (RET_SUCCESS); -} - -/* - * __bt_curdel -- - * Delete the cursor. - * - * Parameters: - * t: tree - * key: referenced key (or NULL) - * h: page - * idx: index on page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -__bt_curdel(BTREE *t, const DBT *key, PAGE *h, u_int idx) -{ - CURSOR *c; - EPG e; - PAGE *pg; - int curcopy, status; - - /* - * If there are duplicates, move forward or backward to one. - * Otherwise, copy the key into the cursor area. - */ - c = &t->bt_cursor; - F_CLR(c, CURS_AFTER | CURS_BEFORE | CURS_ACQUIRE); - - curcopy = 0; - if (!F_ISSET(t, B_NODUPS)) { - /* - * We're going to have to do comparisons. If we weren't - * provided a copy of the key, i.e. the user is deleting - * the current cursor position, get one. - */ - if (key == NULL) { - e.page = h; - e.index = idx; - if ((status = __bt_ret(t, &e, - &c->key, &c->key, NULL, NULL, 1)) != RET_SUCCESS) - return (status); - curcopy = 1; - key = &c->key; - } - /* Check previous key, if not at the beginning of the page. */ - if (idx > 0) { - e.page = h; - e.index = idx - 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_BEFORE); - goto dup2; - } - } - /* Check next key, if not at the end of the page. */ - if (idx < (unsigned)(NEXTINDEX(h) - 1)) { - e.page = h; - e.index = idx + 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_AFTER); - goto dup2; - } - } - /* Check previous key if at the beginning of the page. */ - if (idx == 0 && h->prevpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (RET_ERROR); - e.page = pg; - e.index = NEXTINDEX(pg) - 1; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_BEFORE); - goto dup1; - } - mpool_put(t->bt_mp, pg, 0); - } - /* Check next key if at the end of the page. */ - if (idx == (unsigned)(NEXTINDEX(h) - 1) && h->nextpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (RET_ERROR); - e.page = pg; - e.index = 0; - if (__bt_cmp(t, key, &e) == 0) { - F_SET(c, CURS_AFTER); -dup1: mpool_put(t->bt_mp, pg, 0); -dup2: c->pg.pgno = e.page->pgno; - c->pg.index = e.index; - return (RET_SUCCESS); - } - mpool_put(t->bt_mp, pg, 0); - } - } - e.page = h; - e.index = idx; - if (curcopy || (status = - __bt_ret(t, &e, &c->key, &c->key, NULL, NULL, 1)) == RET_SUCCESS) { - F_SET(c, CURS_ACQUIRE); - return (RET_SUCCESS); - } - return (status); -} - -/* - * __bt_relink -- - * Link around a deleted page. - * - * Parameters: - * t: tree - * h: page to be deleted - */ -static int -__bt_relink(BTREE *t, PAGE *h) -{ - PAGE *pg; - - if (h->nextpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (RET_ERROR); - pg->prevpg = h->prevpg; - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - } - if (h->prevpg != P_INVALID) { - if ((pg = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (RET_ERROR); - pg->nextpg = h->nextpg; - mpool_put(t->bt_mp, pg, MPOOL_DIRTY); - } - return (0); -} diff --git a/lib/libc/db/btree/bt_get.c b/lib/libc/db/btree/bt_get.c deleted file mode 100644 index 772210a7b..000000000 --- a/lib/libc/db/btree/bt_get.c +++ /dev/null @@ -1,104 +0,0 @@ -/* $NetBSD: bt_get.c,v 1.13 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_get.c,v 1.13 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -/* - * __BT_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__bt_get(const DB *dbp, const DBT *key, DBT *data, u_int flags) -{ - BTREE *t; - EPG *e; - int exact, status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Get currently doesn't take any flags. */ - if (flags) { - errno = EINVAL; - return (RET_ERROR); - } - - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - if (!exact) { - mpool_put(t->bt_mp, e->page, 0); - return (RET_SPECIAL); - } - - status = __bt_ret(t, e, NULL, NULL, data, &t->bt_rdata, 0); - - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} diff --git a/lib/libc/db/btree/bt_open.c b/lib/libc/db/btree/bt_open.c deleted file mode 100644 index 53717afc2..000000000 --- a/lib/libc/db/btree/bt_open.c +++ /dev/null @@ -1,421 +0,0 @@ -/* $NetBSD: bt_open.c,v 1.27 2013/12/01 00:22:48 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_open.c,v 1.27 2013/12/01 00:22:48 christos Exp $"); - -/* - * Implementation of btree access method for 4.4BSD. - * - * The design here was originally based on that of the btree access method - * used in the Postgres database system at UC Berkeley. This implementation - * is wholly independent of the Postgres code. - */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -#ifdef DEBUG -#undef MINPSIZE -#define MINPSIZE 128 -#endif - -static int byteorder(void); -static int nroot(BTREE *); - -/* - * __BT_OPEN -- Open a btree. - * - * Creates and fills a DB struct, and calls the routine that actually - * opens the btree. - * - * Parameters: - * fname: filename (NULL for in-memory trees) - * flags: open flag bits - * mode: open permission bits - * b: BTREEINFO pointer - * - * Returns: - * NULL on failure, pointer to DB on success. - * - */ -DB * -__bt_open(const char *fname, int flags, mode_t mode, const BTREEINFO *openinfo, - int dflags) -{ - struct stat sb; - BTMETA m; - BTREE *t; - BTREEINFO b; - DB *dbp; - pgno_t ncache; - ssize_t nr; - size_t temp; - int machine_lorder; - - t = NULL; - - /* - * Intention is to make sure all of the user's selections are okay - * here and then use them without checking. Can't be complete, since - * we don't know the right page size, lorder or flags until the backing - * file is opened. Also, the file's page size can cause the cachesize - * to change. - */ - machine_lorder = byteorder(); - if (openinfo) { - b = *openinfo; - - /* Flags: R_DUP. */ - if (b.flags & ~(R_DUP)) - goto einval; - - /* - * Page size must be indx_t aligned and >= MINPSIZE. Default - * page size is set farther on, based on the underlying file - * transfer size. - */ - if (b.psize && - (b.psize < MINPSIZE || b.psize > MAX_PAGE_OFFSET + 1 || - b.psize & (sizeof(indx_t) - 1))) - goto einval; - - /* Minimum number of keys per page; absolute minimum is 2. */ - if (b.minkeypage) { - if (b.minkeypage < 2) - goto einval; - } else - b.minkeypage = DEFMINKEYPAGE; - - /* If no comparison, use default comparison and prefix. */ - if (b.compare == NULL) { - b.compare = __bt_defcmp; - if (b.prefix == NULL) - b.prefix = __bt_defpfx; - } - - if (b.lorder == 0) - b.lorder = machine_lorder; - } else { - b.compare = __bt_defcmp; - b.cachesize = 0; - b.flags = 0; - b.lorder = machine_lorder; - b.minkeypage = DEFMINKEYPAGE; - b.prefix = __bt_defpfx; - b.psize = 0; - } - - /* Check for the ubiquitous PDP-11. */ - if (b.lorder != BIG_ENDIAN && b.lorder != LITTLE_ENDIAN) - goto einval; - - /* Allocate and initialize DB and BTREE structures. */ - if ((t = malloc(sizeof(*t))) == NULL) - goto err; - memset(t, 0, sizeof(BTREE)); - t->bt_fd = -1; /* Don't close unopened fd on error. */ - t->bt_lorder = b.lorder; - t->bt_order = NOT; - t->bt_cmp = b.compare; - t->bt_pfx = b.prefix; - t->bt_rfd = -1; - - if ((t->bt_dbp = dbp = malloc(sizeof(*dbp))) == NULL) - goto err; - memset(t->bt_dbp, 0, sizeof(DB)); - if (t->bt_lorder != machine_lorder) - F_SET(t, B_NEEDSWAP); - - dbp->type = DB_BTREE; - dbp->internal = t; - dbp->close = __bt_close; - dbp->del = __bt_delete; - dbp->fd = __bt_fd; - dbp->get = __bt_get; - dbp->put = __bt_put; - dbp->seq = __bt_seq; - dbp->sync = __bt_sync; - - /* - * If no file name was supplied, this is an in-memory btree and we - * open a backing temporary file. Otherwise, it's a disk-based tree. - */ - if (fname) { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, B_RDONLY); - break; - case O_RDWR: - break; - case O_WRONLY: - default: - goto einval; - } - if ((t->bt_fd = __dbopen(fname, flags, mode, &sb)) == -1) - goto err; - } else { - if ((flags & O_ACCMODE) != O_RDWR) - goto einval; - if ((t->bt_fd = __dbtemp("bt.", &sb)) == -1) - goto err; - F_SET(t, B_INMEM); - } - - - if (sb.st_size) { - if ((nr = read(t->bt_fd, &m, sizeof(BTMETA))) < 0) - goto err; - if (nr != sizeof(BTMETA)) - goto eftype; - - /* - * Read in the meta-data. This can change the notion of what - * the lorder, page size and flags are, and, when the page size - * changes, the cachesize value can change too. If the user - * specified the wrong byte order for an existing database, we - * don't bother to return an error, we just clear the NEEDSWAP - * bit. - */ - if (m.magic == BTREEMAGIC) - F_CLR(t, B_NEEDSWAP); - else { - F_SET(t, B_NEEDSWAP); - M_32_SWAP(m.magic); - M_32_SWAP(m.version); - M_32_SWAP(m.psize); - M_32_SWAP(m.free); - M_32_SWAP(m.nrecs); - M_32_SWAP(m.flags); - } - if (m.magic != BTREEMAGIC || m.version != BTREEVERSION) - goto eftype; - if (m.psize < MINPSIZE || m.psize > MAX_PAGE_OFFSET + 1 || - m.psize & (sizeof(indx_t) - 1)) - goto eftype; - if (m.flags & ~SAVEMETA) - goto eftype; - b.psize = m.psize; - F_SET(t, m.flags); - t->bt_free = m.free; - t->bt_nrecs = m.nrecs; - } else { - /* - * Set the page size to the best value for I/O to this file. - * Don't overflow the page offset type. - */ - if (b.psize == 0) { - b.psize = sb.st_blksize; - if (b.psize < MINPSIZE) - b.psize = MINPSIZE; - if (b.psize > MAX_PAGE_OFFSET + 1) - b.psize = MAX_PAGE_OFFSET + 1; - } - - /* Set flag if duplicates permitted. */ - if (!(b.flags & R_DUP)) - F_SET(t, B_NODUPS); - - t->bt_free = P_INVALID; - t->bt_nrecs = 0; - F_SET(t, B_METADIRTY); - } - - t->bt_psize = b.psize; - - /* Set the cache size; must be a multiple of the page size. */ - if (b.cachesize && b.cachesize & (b.psize - 1)) - b.cachesize += (~b.cachesize & (b.psize - 1)) + 1; - if (b.cachesize < b.psize * MINCACHE) - b.cachesize = b.psize * MINCACHE; - - /* Calculate number of pages to cache. */ - ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize; - - /* - * The btree data structure requires that at least two keys can fit on - * a page, but other than that there's no fixed requirement. The user - * specified a minimum number per page, and we translated that into the - * number of bytes a key/data pair can use before being placed on an - * overflow page. This calculation includes the page header, the size - * of the index referencing the leaf item and the size of the leaf item - * structure. Also, don't let the user specify a minkeypage such that - * a key/data pair won't fit even if both key and data are on overflow - * pages. - */ - temp = (t->bt_psize - BTDATAOFF) / b.minkeypage - - (sizeof(indx_t) + NBLEAFDBT(0, 0)); - _DBFIT(temp, indx_t); - t->bt_ovflsize = (indx_t)temp; - if (t->bt_ovflsize < NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t)) { - size_t l = NBLEAFDBT(NOVFLSIZE, NOVFLSIZE) + sizeof(indx_t); - _DBFIT(l, indx_t); - t->bt_ovflsize = (indx_t)l; - } - - /* Initialize the buffer pool. */ - if ((t->bt_mp = - mpool_open(NULL, t->bt_fd, t->bt_psize, ncache)) == NULL) - goto err; - if (!F_ISSET(t, B_INMEM)) - mpool_filter(t->bt_mp, __bt_pgin, __bt_pgout, t); - - /* Create a root page if new tree. */ - if (nroot(t) == RET_ERROR) - goto err; - - /* Global flags. */ - if (dflags & DB_LOCK) - F_SET(t, B_DB_LOCK); - if (dflags & DB_SHMEM) - F_SET(t, B_DB_SHMEM); - if (dflags & DB_TXN) - F_SET(t, B_DB_TXN); - - return (dbp); - -einval: errno = EINVAL; - goto err; - -eftype: errno = EFTYPE; - goto err; - -err: if (t) { - if (t->bt_dbp) - free(t->bt_dbp); - if (t->bt_fd != -1) - (void)close(t->bt_fd); - free(t); - } - return (NULL); -} - -/* - * NROOT -- Create the root of a new tree. - * - * Parameters: - * t: tree - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -nroot(BTREE *t) -{ - PAGE *meta, *root; - pgno_t npg; - - if ((meta = mpool_get(t->bt_mp, 0, 0)) != NULL) { - mpool_put(t->bt_mp, meta, 0); - return (RET_SUCCESS); - } - if (errno != EINVAL) /* It's OK to not exist. */ - return (RET_ERROR); - errno = 0; - - if ((meta = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if ((root = mpool_new(t->bt_mp, &npg)) == NULL) - return (RET_ERROR); - - if (npg != P_ROOT) - return (RET_ERROR); - root->pgno = npg; - root->prevpg = root->nextpg = P_INVALID; - root->lower = BTDATAOFF; - root->upper = t->bt_psize; - root->flags = P_BLEAF; - memset(meta, 0, t->bt_psize); - mpool_put(t->bt_mp, meta, MPOOL_DIRTY); - mpool_put(t->bt_mp, root, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -static int -byteorder(void) -{ - uint32_t x; - uint8_t *p; - - x = 0x01020304; - p = (uint8_t *)(void *)&x; - switch (*p) { - case 1: - return (BIG_ENDIAN); - case 4: - return (LITTLE_ENDIAN); - default: - return (0); - } -} - -int -__bt_fd(const DB *dbp) -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* In-memory database can't have a file descriptor. */ - if (F_ISSET(t, B_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_fd); -} diff --git a/lib/libc/db/btree/bt_overflow.c b/lib/libc/db/btree/bt_overflow.c deleted file mode 100644 index e083852fc..000000000 --- a/lib/libc/db/btree/bt_overflow.c +++ /dev/null @@ -1,233 +0,0 @@ -/* $NetBSD: bt_overflow.c,v 1.20 2013/12/14 18:04:56 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_overflow.c,v 1.20 2013/12/14 18:04:56 christos Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -/* - * Big key/data code. - * - * Big key and data entries are stored on linked lists of pages. The initial - * reference is byte string stored with the key or data and is the page number - * and size. The actual record is stored in a chain of pages linked by the - * nextpg field of the PAGE header. - * - * The first page of the chain has a special property. If the record is used - * by an internal page, it cannot be deleted and the P_PRESERVE bit will be set - * in the header. - * - * XXX - * A single DBT is written to each chain, so a lot of space on the last page - * is wasted. This is a fairly major bug for some data sets. - */ - -/* - * __OVFL_GET -- Get an overflow key/data item. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, uint32_t } - * buf: storage address - * bufsz: storage size - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_get(BTREE *t, void *p, size_t *ssz, void **buf, size_t *bufsz) -{ - PAGE *h; - pgno_t pg; - uint32_t sz, nb, plen; - size_t temp; - - memmove(&pg, p, sizeof(pg)); - memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(uint32_t)); - *ssz = sz; - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - /* Make the buffer bigger as necessary. */ - if (*bufsz < sz) { - void *nbuf = realloc(*buf, sz); - if (nbuf == NULL) - return (RET_ERROR); - *buf = nbuf; - *bufsz = sz; - } - - /* - * Step through the linked list of pages, copying the data on each one - * into the buffer. Never copy more than the data's length. - */ - temp = t->bt_psize - BTDATAOFF; - _DBFIT(temp, uint32_t); - plen = (uint32_t)temp; - for (p = *buf;; p = (char *)p + nb, pg = h->nextpg) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - nb = MIN(sz, plen); - memmove(p, (char *)(void *)h + BTDATAOFF, nb); - mpool_put(t->bt_mp, h, 0); - - if ((sz -= nb) == 0) - break; - } - return (RET_SUCCESS); -} - -/* - * __OVFL_PUT -- Store an overflow key/data item. - * - * Parameters: - * t: tree - * data: DBT to store - * pgno: storage page number - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_put(BTREE *t, const DBT *dbt, pgno_t *pg) -{ - PAGE *h, *last; - void *p; - pgno_t npg; - uint32_t sz, nb, plen; - size_t temp; - - /* - * Allocate pages and copy the key/data record into them. Store the - * number of the first page in the chain. - */ - temp = t->bt_psize - BTDATAOFF; - _DBFIT(temp, uint32_t); - plen = (uint32_t)temp; - last = NULL; - p = dbt->data; - temp = dbt->size; - _DBFIT(temp, uint32_t); - sz = (uint32_t)temp; - for (;; p = (char *)p + plen, last = h) { - if ((h = __bt_new(t, &npg)) == NULL) - return (RET_ERROR); - - h->pgno = npg; - h->nextpg = h->prevpg = P_INVALID; - h->flags = P_OVERFLOW; - h->lower = h->upper = 0; - - nb = MIN(sz, plen); - (void)memmove((char *)(void *)h + BTDATAOFF, p, (size_t)nb); - - if (last) { - last->nextpg = h->pgno; - mpool_put(t->bt_mp, last, MPOOL_DIRTY); - } else - *pg = h->pgno; - - if ((sz -= nb) == 0) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - } - return (RET_SUCCESS); -} - -/* - * __OVFL_DELETE -- Delete an overflow chain. - * - * Parameters: - * t: tree - * p: pointer to { pgno_t, uint32_t } - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__ovfl_delete(BTREE *t, void *p) -{ - PAGE *h; - pgno_t pg; - uint32_t sz, plen; - size_t temp; - - (void)memmove(&pg, p, sizeof(pg)); - (void)memmove(&sz, (char *)p + sizeof(pgno_t), sizeof(uint32_t)); - -#ifdef DEBUG - if (pg == P_INVALID || sz == 0) - abort(); -#endif - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Don't delete chains used by internal pages. */ - if (h->flags & P_PRESERVE) { - mpool_put(t->bt_mp, h, 0); - return (RET_SUCCESS); - } - - /* Step through the chain, calling the free routine for each page. */ - temp = t->bt_psize - BTDATAOFF; - _DBFIT(temp, uint32_t); - plen = (uint32_t)temp; - for (;; sz -= plen) { - pg = h->nextpg; - __bt_free(t, h); - if (sz <= plen) - break; - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - } - return (RET_SUCCESS); -} diff --git a/lib/libc/db/btree/bt_page.c b/lib/libc/db/btree/bt_page.c deleted file mode 100644 index 0db4aeb8b..000000000 --- a/lib/libc/db/btree/bt_page.c +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: bt_page.c,v 1.13 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_page.c,v 1.13 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" -#include - -#include -#include - -#include -#include "btree.h" - -/* - * __bt_free -- - * Put a page on the freelist. - * - * Parameters: - * t: tree - * h: page to free - * - * Returns: - * RET_ERROR, RET_SUCCESS - * - * Side-effect: - * mpool_put's the page. - */ -int -__bt_free(BTREE *t, PAGE *h) -{ - /* Insert the page at the head of the free list. */ - h->prevpg = P_INVALID; - h->nextpg = t->bt_free; - t->bt_free = h->pgno; - F_SET(t, B_METADIRTY); - - /* Make sure the page gets written back. */ - return (mpool_put(t->bt_mp, h, MPOOL_DIRTY)); -} - -/* - * __bt_new -- - * Get a new page, preferably from the freelist. - * - * Parameters: - * t: tree - * npg: storage for page number. - * - * Returns: - * Pointer to a page, NULL on error. - */ -PAGE * -__bt_new(BTREE *t, pgno_t *npg) -{ - PAGE *h; - - if (t->bt_free != P_INVALID && - (h = mpool_get(t->bt_mp, t->bt_free, 0)) != NULL) { - *npg = t->bt_free; - t->bt_free = h->nextpg; - F_SET(t, B_METADIRTY); - return (h); - } - return (mpool_new(t->bt_mp, npg)); -} diff --git a/lib/libc/db/btree/bt_put.c b/lib/libc/db/btree/bt_put.c deleted file mode 100644 index 986d6c184..000000000 --- a/lib/libc/db/btree/bt_put.c +++ /dev/null @@ -1,319 +0,0 @@ -/* $NetBSD: bt_put.c,v 1.20 2011/06/26 22:20:31 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_put.c,v 1.20 2011/06/26 22:20:31 christos Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -static EPG *bt_fast(BTREE *, const DBT *, const DBT *, int *); - -/* - * __BT_PUT -- Add a btree item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the - * tree and R_NOOVERWRITE specified. - */ -int -__bt_put(const DB *dbp, DBT *key, const DBT *data, u_int flags) -{ - BTREE *t; - DBT tkey, tdata; - EPG *e = NULL; /* pacify gcc */ - PAGE *h; - indx_t idx, nxtindex; - pgno_t pg; - uint32_t nbytes, temp; - int dflags, exact, status; - char *dest, db[NOVFLSIZE], kb[NOVFLSIZE]; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Check for change to a read-only tree. */ - if (F_ISSET(t, B_RDONLY)) { - errno = EPERM; - return (RET_ERROR); - } - - switch (flags) { - case 0: - case R_NOOVERWRITE: - break; - case R_CURSOR: - /* - * If flags is R_CURSOR, put the cursor. Must already - * have started a scan and not have already deleted it. - */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, - CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE)) - break; - /* FALLTHROUGH */ - default: - errno = EINVAL; - return (RET_ERROR); - } - - /* - * If the key/data pair won't fit on a page, store it on overflow - * pages. Only put the key on the overflow page if the pair are - * still too big after moving the data to an overflow page. - * - * XXX - * If the insert fails later on, the overflow pages aren't recovered. - */ - dflags = 0; - if (key->size + data->size > t->bt_ovflsize) { - if (key->size > t->bt_ovflsize) { -storekey: if (__ovfl_put(t, key, &pg) == RET_ERROR) - return (RET_ERROR); - tkey.data = kb; - tkey.size = NOVFLSIZE; - memmove(kb, &pg, sizeof(pg)); - memmove(kb + sizeof(pgno_t), - &key->size, sizeof(uint32_t)); - dflags |= P_BIGKEY; - key = &tkey; - } - if (key->size + data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - memmove(db, &pg, sizeof(pg)); - _DBFIT(data->size, uint32_t); - temp = (uint32_t)data->size; - (void)memmove(db + sizeof(pgno_t), - &temp, sizeof(uint32_t)); - dflags |= P_BIGDATA; - data = &tdata; - } - if (key->size + data->size > t->bt_ovflsize) - goto storekey; - } - - /* Replace the cursor. */ - if (flags == R_CURSOR) { - if ((h = mpool_get(t->bt_mp, t->bt_cursor.pg.pgno, 0)) == NULL) - return (RET_ERROR); - idx = t->bt_cursor.pg.index; - goto delete; - } - - /* - * Find the key to delete, or, the location at which to insert. - * Bt_fast and __bt_search both pin the returned page. - */ - if (t->bt_order == NOT || (e = bt_fast(t, key, data, &exact)) == NULL) - if ((e = __bt_search(t, key, &exact)) == NULL) - return (RET_ERROR); - h = e->page; - idx = e->index; - - /* - * Add the key/data pair to the tree. If an identical key is already - * in the tree, and R_NOOVERWRITE is set, an error is returned. If - * R_NOOVERWRITE is not set, the key is either added (if duplicates are - * permitted) or an error is returned. - */ - switch (flags) { - case R_NOOVERWRITE: - if (!exact) - break; - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - default: - if (!exact || !F_ISSET(t, B_NODUPS)) - break; - /* - * !!! - * Note, the delete may empty the page, so we need to put a - * new entry into the page immediately. - */ -delete: if (__bt_dleaf(t, key, h, (u_int)idx) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, or the user has put a ceiling on the number of - * keys permitted in the page, split the page. The split code will - * insert the key and data and unpin the current page. If inserting - * into the offset array, shift the pointers up. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if ((uint32_t)h->upper - (uint32_t)h->lower < nbytes + sizeof(indx_t)) { - if ((status = __bt_split(t, h, key, - data, dflags, nbytes, (u_int)idx)) != RET_SUCCESS) - return (status); - goto success; - } - - if (idx < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + idx + 1, h->linp + idx, - (nxtindex - idx) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[idx] = h->upper -= nbytes; - dest = (char *)(void *)h + h->upper; - WR_BLEAF(dest, key, data, dflags); - - /* If the cursor is on this page, adjust it as necessary. */ - if (F_ISSET(&t->bt_cursor, CURS_INIT) && - !F_ISSET(&t->bt_cursor, CURS_ACQUIRE) && - t->bt_cursor.pg.pgno == h->pgno && t->bt_cursor.pg.index >= idx) - ++t->bt_cursor.pg.index; - - if (t->bt_order == NOT) { - if (h->nextpg == P_INVALID) { - if (idx == NEXTINDEX(h) - 1) { - t->bt_order = FORWARD; - t->bt_last.index = idx; - t->bt_last.pgno = h->pgno; - } - } else if (h->prevpg == P_INVALID) { - if (idx == 0) { - t->bt_order = BACK; - t->bt_last.index = 0; - t->bt_last.pgno = h->pgno; - } - } - } - - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - -success: - if (flags == R_SETCURSOR) - __bt_setcur(t, e->page->pgno, (u_int)e->index); - - F_SET(t, B_MODIFIED); - return (RET_SUCCESS); -} - -#ifdef STATISTICS -unsigned long bt_cache_hit, bt_cache_miss; -#endif - -/* - * BT_FAST -- Do a quick check for sorted data. - * - * Parameters: - * t: tree - * key: key to insert - * - * Returns: - * EPG for new record or NULL if not found. - */ -static EPG * -bt_fast(BTREE *t, const DBT *key, const DBT *data, int *exactp) -{ - PAGE *h; - uint32_t nbytes; - int cmp; - - if ((h = mpool_get(t->bt_mp, t->bt_last.pgno, 0)) == NULL) { - t->bt_order = NOT; - return (NULL); - } - t->bt_cur.page = h; - t->bt_cur.index = t->bt_last.index; - - /* - * If won't fit in this page or have too many keys in this page, - * have to search to get split stack. - */ - nbytes = NBLEAFDBT(key->size, data->size); - if ((uint32_t)h->upper - (uint32_t)h->lower < nbytes + sizeof(indx_t)) - goto miss; - - if (t->bt_order == FORWARD) { - if (t->bt_cur.page->nextpg != P_INVALID) - goto miss; - if (t->bt_cur.index != NEXTINDEX(h) - 1) - goto miss; - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) < 0) - goto miss; - t->bt_last.index = cmp ? ++t->bt_cur.index : t->bt_cur.index; - } else { - if (t->bt_cur.page->prevpg != P_INVALID) - goto miss; - if (t->bt_cur.index != 0) - goto miss; - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) > 0) - goto miss; - t->bt_last.index = 0; - } - *exactp = cmp == 0; -#ifdef STATISTICS - ++bt_cache_hit; -#endif - return (&t->bt_cur); - -miss: -#ifdef STATISTICS - ++bt_cache_miss; -#endif - t->bt_order = NOT; - mpool_put(t->bt_mp, h, 0); - return (NULL); -} diff --git a/lib/libc/db/btree/bt_search.c b/lib/libc/db/btree/bt_search.c deleted file mode 100644 index 00da7c9b6..000000000 --- a/lib/libc/db/btree/bt_search.c +++ /dev/null @@ -1,205 +0,0 @@ -/* $NetBSD: bt_search.c,v 1.17 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_search.c,v 1.17 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" -#include - -#include -#include - -#include -#include "btree.h" - -static int __bt_snext(BTREE *, PAGE *, const DBT *, int *); -static int __bt_sprev(BTREE *, PAGE *, const DBT *, int *); - -/* - * __bt_search -- - * Search a btree for a key. - * - * Parameters: - * t: tree to search - * key: key to find - * exactp: pointer to exact match flag - * - * Returns: - * The EPG for matching record, if any, or the EPG for the location - * of the key, if it were inserted into the tree, is entered into - * the bt_cur field of the tree. A pointer to the field is returned. - */ -EPG * -__bt_search(BTREE *t, const DBT *key, int *exactp) -{ - PAGE *h; - indx_t base, idx, lim; - pgno_t pg; - int cmp; - - BT_CLR(t); - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (NULL); - - /* Do a binary search on the current page. */ - t->bt_cur.page = h; - for (base = 0, lim = NEXTINDEX(h); lim; lim >>= 1) { - t->bt_cur.index = idx = base + ((uint32_t)lim >> 1); - if ((cmp = __bt_cmp(t, key, &t->bt_cur)) == 0) { - if (h->flags & P_BLEAF) { - *exactp = 1; - return (&t->bt_cur); - } - goto next; - } - if (cmp > 0) { - base = idx + 1; - --lim; - } - } - - /* - * If it's a leaf page, we're almost done. If no duplicates - * are allowed, or we have an exact match, we're done. Else, - * it's possible that there were matching keys on this page, - * which later deleted, and we're on a page with no matches - * while there are matches on other pages. If at the start or - * end of a page, check the adjacent page. - */ - if (h->flags & P_BLEAF) { - if (!F_ISSET(t, B_NODUPS)) { - if (base == 0 && - h->prevpg != P_INVALID && - __bt_sprev(t, h, key, exactp)) - return (&t->bt_cur); - if (base == NEXTINDEX(h) && - h->nextpg != P_INVALID && - __bt_snext(t, h, key, exactp)) - return (&t->bt_cur); - } - *exactp = 0; - t->bt_cur.index = base; - return (&t->bt_cur); - } - - /* - * No match found. Base is the smallest index greater than - * key and may be zero or a last + 1 index. If it's non-zero, - * decrement by one, and record the internal page which should - * be a parent page for the key. If a split later occurs, the - * inserted page will be to the right of the saved page. - */ - idx = base ? base - 1 : base; - -next: BT_PUSH(t, h->pgno, idx); - pg = GETBINTERNAL(h, idx)->pgno; - mpool_put(t->bt_mp, h, 0); - } -} - -/* - * __bt_snext -- - * Check for an exact match after the key. - * - * Parameters: - * t: tree - * h: current page - * key: key - * exactp: pointer to exact match flag - * - * Returns: - * If an exact match found. - */ -static int -__bt_snext(BTREE *t, PAGE *h, const DBT *key, int *exactp) -{ - EPG e; - - /* - * Get the next page. The key is either an exact - * match, or not as good as the one we already have. - */ - if ((e.page = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) - return (0); - e.index = 0; - if (__bt_cmp(t, key, &e) == 0) { - mpool_put(t->bt_mp, h, 0); - t->bt_cur = e; - *exactp = 1; - return (1); - } - mpool_put(t->bt_mp, e.page, 0); - return (0); -} - -/* - * __bt_sprev -- - * Check for an exact match before the key. - * - * Parameters: - * t: tree - * h: current page - * key: key - * exactp: pointer to exact match flag - * - * Returns: - * If an exact match found. - */ -static int -__bt_sprev(BTREE *t, PAGE *h, const DBT *key, int *exactp) -{ - EPG e; - - /* - * Get the previous page. The key is either an exact - * match, or not as good as the one we already have. - */ - if ((e.page = mpool_get(t->bt_mp, h->prevpg, 0)) == NULL) - return (0); - e.index = NEXTINDEX(e.page) - 1; - if (__bt_cmp(t, key, &e) == 0) { - mpool_put(t->bt_mp, h, 0); - t->bt_cur = e; - *exactp = 1; - return (1); - } - mpool_put(t->bt_mp, e.page, 0); - return (0); -} diff --git a/lib/libc/db/btree/bt_seq.c b/lib/libc/db/btree/bt_seq.c deleted file mode 100644 index 3f5b4cfa2..000000000 --- a/lib/libc/db/btree/bt_seq.c +++ /dev/null @@ -1,442 +0,0 @@ -/* $NetBSD: bt_seq.c,v 1.18 2013/09/04 13:03:22 ryoon Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_seq.c,v 1.18 2013/09/04 13:03:22 ryoon Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -static int __bt_first(BTREE *, const DBT *, EPG *, int *); -static int __bt_seqadv(BTREE *, EPG *, int); -static int __bt_seqset(BTREE *, EPG *, DBT *, int); - -/* - * Sequential scan support. - * - * The tree can be scanned sequentially, starting from either end of the - * tree or from any specific key. A scan request before any scanning is - * done is initialized as starting from the least node. - */ - -/* - * __bt_seq -- - * Btree sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__bt_seq(const DB *dbp, DBT *key, DBT *data, u_int flags) -{ - BTREE *t; - EPG e; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * If scan uninitialized as yet, or starting at a specific record, set - * the scan to a specific key. Both __bt_seqset and __bt_seqadv pin - * the page the cursor references if they're successful. - */ - switch (flags) { - case R_NEXT: - case R_PREV: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - status = __bt_seqadv(t, &e, (int)flags); - break; - } - /* FALLTHROUGH */ - case R_FIRST: - case R_LAST: - case R_CURSOR: - status = __bt_seqset(t, &e, key, (int)flags); - break; - default: - errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) { - __bt_setcur(t, e.page->pgno, (u_int)e.index); - - status = - __bt_ret(t, &e, key, &t->bt_rkey, data, &t->bt_rdata, 0); - - /* - * If the user is doing concurrent access, we copied the - * key/data, toss the page. - */ - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e.page, 0); - else - t->bt_pinned = e.page; - } - return (status); -} - -/* - * __bt_seqset -- - * Set the sequential scan to a specific key. - * - * Parameters: - * t: tree - * ep: storage for returned key - * key: key for initial scan position - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV - * - * Side effects: - * Pins the page the cursor references. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -__bt_seqset(BTREE *t, EPG *ep, DBT *key, int flags) -{ - PAGE *h; - pgno_t pg; - int exact; - - /* - * Find the first, last or specific key in the tree and point the - * cursor at it. The cursor may not be moved until a new key has - * been found. - */ - switch (flags) { - case R_CURSOR: /* Keyed scan. */ - /* - * Find the first instance of the key or the smallest key - * which is greater than or equal to the specified key. - */ - if (key->data == NULL || key->size == 0) { - errno = EINVAL; - return (RET_ERROR); - } - return (__bt_first(t, key, ep, &exact)); - case R_FIRST: /* First record. */ - case R_NEXT: - /* Walk down the left-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Check for an empty tree. */ - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, 0)->pgno; - mpool_put(t->bt_mp, h, 0); - } - ep->page = h; - ep->index = 0; - break; - case R_LAST: /* Last record. */ - case R_PREV: - /* Walk down the right-hand side of the tree. */ - for (pg = P_ROOT;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - - /* Check for an empty tree. */ - if (NEXTINDEX(h) == 0) { - mpool_put(t->bt_mp, h, 0); - return (RET_SPECIAL); - } - - if (h->flags & (P_BLEAF | P_RLEAF)) - break; - pg = GETBINTERNAL(h, NEXTINDEX(h) - 1)->pgno; - mpool_put(t->bt_mp, h, 0); - } - - ep->page = h; - ep->index = NEXTINDEX(h) - 1; - break; - } - return (RET_SUCCESS); -} - -/* - * __bt_seqadvance -- - * Advance the sequential scan. - * - * Parameters: - * t: tree - * flags: R_NEXT, R_PREV - * - * Side effects: - * Pins the page the new key/data record is on. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -static int -__bt_seqadv(BTREE *t, EPG *ep, int flags) -{ - CURSOR *c; - PAGE *h; - indx_t idx = 0; /* pacify gcc */ - pgno_t pg; - int exact; - - /* - * There are a couple of states that we can be in. The cursor has - * been initialized by the time we get here, but that's all we know. - */ - c = &t->bt_cursor; - - /* - * The cursor was deleted where there weren't any duplicate records, - * so the key was saved. Find out where that key would go in the - * current tree. It doesn't matter if the returned key is an exact - * match or not -- if it's an exact match, the record was added after - * the delete so we can just return it. If not, as long as there's - * a record there, return it. - */ - if (F_ISSET(c, CURS_ACQUIRE)) - return (__bt_first(t, &c->key, ep, &exact)); - - /* Get the page referenced by the cursor. */ - if ((h = mpool_get(t->bt_mp, c->pg.pgno, 0)) == NULL) - return (RET_ERROR); - - /* - * Find the next/previous record in the tree and point the cursor at - * it. The cursor may not be moved until a new key has been found. - */ - switch (flags) { - case R_NEXT: /* Next record. */ - /* - * The cursor was deleted in duplicate records, and moved - * forward to a record that has yet to be returned. Clear - * that flag, and return the record. - */ - if (F_ISSET(c, CURS_AFTER)) - goto usecurrent; - idx = c->pg.index; - if (++idx == NEXTINDEX(h)) { - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - idx = 0; - } - break; - case R_PREV: /* Previous record. */ - /* - * The cursor was deleted in duplicate records, and moved - * backward to a record that has yet to be returned. Clear - * that flag, and return the record. - */ - if (F_ISSET(c, CURS_BEFORE)) { -usecurrent: F_CLR(c, CURS_AFTER | CURS_BEFORE); - ep->page = h; - ep->index = c->pg.index; - return (RET_SUCCESS); - } - idx = c->pg.index; - if (idx == 0) { - pg = h->prevpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - idx = NEXTINDEX(h) - 1; - } else - --idx; - break; - } - - ep->page = h; - ep->index = idx; - return (RET_SUCCESS); -} - -/* - * __bt_first -- - * Find the first entry. - * - * Parameters: - * t: the tree - * key: the key - * erval: return EPG - * exactp: pointer to exact match flag - * - * Returns: - * The first entry in the tree greater than or equal to key, - * or RET_SPECIAL if no such key exists. - */ -static int -__bt_first(BTREE *t, const DBT *key, EPG *erval, int *exactp) -{ - PAGE *h; - EPG *ep, save; - pgno_t pg; - - /* - * Find any matching record; __bt_search pins the page. - * - * If it's an exact match and duplicates are possible, walk backwards - * in the tree until we find the first one. Otherwise, make sure it's - * a valid key (__bt_search may return an index just past the end of a - * page) and return it. - */ - if ((ep = __bt_search(t, key, exactp)) == NULL) - return (0); - if (*exactp) { - if (F_ISSET(t, B_NODUPS)) { - *erval = *ep; - return (RET_SUCCESS); - } - - /* - * Walk backwards, as long as the entry matches and there are - * keys left in the tree. Save a copy of each match in case - * we go too far. - */ - save = *ep; - h = ep->page; - do { - if (save.page->pgno != ep->page->pgno) { - mpool_put(t->bt_mp, save.page, 0); - save = *ep; - } else - save.index = ep->index; - - /* - * Don't unpin the page the last (or original) match - * was on, but make sure it's unpinned if an error - * occurs. - */ - if (ep->index == 0) { - if (h->prevpg == P_INVALID) - break; - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - if ((h = mpool_get(t->bt_mp, - h->prevpg, 0)) == NULL) - return (RET_ERROR); - ep->page = h; - ep->index = NEXTINDEX(h); - } - --ep->index; - } while (__bt_cmp(t, key, ep) == 0); - - /* - * Reach here with the last page that was looked at pinned, - * which may or may not be the same as the last (or original) - * match page. If it's not useful, release it. - */ - if (h->pgno != save.page->pgno) - mpool_put(t->bt_mp, h, 0); - - *erval = save; - return (RET_SUCCESS); - } - - /* If at the end of a page, find the next entry. */ - if (ep->index == NEXTINDEX(ep->page)) { - h = ep->page; - pg = h->nextpg; - mpool_put(t->bt_mp, h, 0); - if (pg == P_INVALID) - return (RET_SPECIAL); - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - ep->index = 0; - ep->page = h; - } - *erval = *ep; - return (RET_SUCCESS); -} - -/* - * __bt_setcur -- - * Set the cursor to an entry in the tree. - * - * Parameters: - * t: the tree - * pgno: page number - * idx: page index - */ -void -__bt_setcur(BTREE *t, pgno_t pgno, u_int idx) -{ - /* Lose any already deleted key. */ - if (t->bt_cursor.key.data != NULL) { - free(t->bt_cursor.key.data); - t->bt_cursor.key.size = 0; - t->bt_cursor.key.data = NULL; - } - F_CLR(&t->bt_cursor, CURS_ACQUIRE | CURS_AFTER | CURS_BEFORE); - - /* Update the cursor. */ - t->bt_cursor.pg.pgno = pgno; - t->bt_cursor.pg.index = idx; - F_SET(&t->bt_cursor, CURS_INIT); -} diff --git a/lib/libc/db/btree/bt_split.c b/lib/libc/db/btree/bt_split.c deleted file mode 100644 index f7356c7e3..000000000 --- a/lib/libc/db/btree/bt_split.c +++ /dev/null @@ -1,832 +0,0 @@ -/* $NetBSD: bt_split.c,v 1.20 2011/06/20 09:11:17 mrg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_split.c,v 1.20 2011/06/20 09:11:17 mrg Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include - -#include -#include "btree.h" - -static int bt_broot(BTREE *, PAGE *, PAGE *, PAGE *); -static PAGE *bt_page(BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t); -static int bt_preserve(BTREE *, pgno_t); -static PAGE *bt_psplit(BTREE *, PAGE *, PAGE *, PAGE *, indx_t *, size_t); -static PAGE *bt_root(BTREE *, PAGE *, PAGE **, PAGE **, indx_t *, size_t); -static int bt_rroot(BTREE *, PAGE *, PAGE *, PAGE *); -static recno_t rec_total(PAGE *); - -#ifdef STATISTICS -unsigned long bt_rootsplit, bt_split, bt_sortsplit, bt_pfxsaved; -#endif - -/* - * __BT_SPLIT -- Split the tree. - * - * Parameters: - * t: tree - * sp: page to split - * key: key to insert - * data: data to insert - * flags: BIGKEY/BIGDATA flags - * ilen: insert length - * skip: index to leave open - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__bt_split(BTREE *t, PAGE *sp, const DBT *key, const DBT *data, int flags, - size_t ilen, uint32_t argskip) -{ - BINTERNAL *bi = NULL; /* pacify gcc */ - BLEAF *bl = NULL, *tbl; /* pacify gcc */ - DBT a, b; - EPGNO *parent; - PAGE *h, *l, *r, *lchild, *rchild; - indx_t nxtindex; - uint16_t skip; - uint32_t n, nbytes, nksize = 0; /* pacify gcc */ - int parentsplit; - char *dest; - - /* - * Split the page into two pages, l and r. The split routines return - * a pointer to the page into which the key should be inserted and with - * skip set to the offset which should be used. Additionally, l and r - * are pinned. - */ - skip = argskip; - h = sp->pgno == P_ROOT ? - bt_root(t, sp, &l, &r, &skip, ilen) : - bt_page(t, sp, &l, &r, &skip, ilen); - if (h == NULL) - return (RET_ERROR); - - /* - * Insert the new key/data pair into the leaf page. (Key inserts - * always cause a leaf page to split first.) - */ - _DBFIT(ilen, indx_t); - h->upper -= (indx_t)ilen; - h->linp[skip] = h->upper; - dest = (char *)(void *)h + h->upper; - if (F_ISSET(t, R_RECNO)) - WR_RLEAF(dest, data, flags); - else - WR_BLEAF(dest, key, data, flags); - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (F_ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err2; - - /* - * Now we walk the parent page stack -- a LIFO stack of the pages that - * were traversed when we searched for the page that split. Each stack - * entry is a page number and a page index offset. The offset is for - * the page traversed on the search. We've just split a page, so we - * have to insert a new key into the parent page. - * - * If the insert into the parent page causes it to split, may have to - * continue splitting all the way up the tree. We stop if the root - * splits or the page inserted into didn't have to split to hold the - * new key. Some algorithms replace the key for the old page as well - * as the new page. We don't, as there's no reason to believe that the - * first key on the old page is any better than the key we have, and, - * in the case of a key being placed at index 0 causing the split, the - * key is unavailable. - * - * There are a maximum of 5 pages pinned at any time. We keep the left - * and right pages pinned while working on the parent. The 5 are the - * two children, left parent and right parent (when the parent splits) - * and the root page or the overflow key page when calling bt_preserve. - * This code must make sure that all pins are released other than the - * root page or overflow page which is unlocked elsewhere. - */ - while ((parent = BT_POP(t)) != NULL) { - lchild = l; - rchild = r; - - /* Get the parent page. */ - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - goto err2; - - /* - * The new key goes ONE AFTER the index, because the split - * was to the right. - */ - skip = parent->index + 1; - - /* - * Calculate the space needed on the parent page. - * - * Prefix trees: space hack when inserting into BINTERNAL - * pages. Retain only what's needed to distinguish between - * the new entry and the LAST entry on the page to its left. - * If the keys compare equal, retain the entire key. Note, - * we don't touch overflow keys, and the entire key must be - * retained for the next-to-left most key on the leftmost - * page of each level, or the search will fail. Applicable - * ONLY to internal pages that have leaf pages as children. - * Further reduction of the key between pairs of internal - * pages loses too much information. - */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - bi = GETBINTERNAL(rchild, 0); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - bl = GETBLEAF(rchild, 0); - nbytes = NBINTERNAL(bl->ksize); - if (t->bt_pfx && !(bl->flags & P_BIGKEY) && - (h->prevpg != P_INVALID || skip > 1)) { - size_t temp; - tbl = GETBLEAF(lchild, NEXTINDEX(lchild) - 1); - a.size = tbl->ksize; - a.data = tbl->bytes; - b.size = bl->ksize; - b.data = bl->bytes; - temp = t->bt_pfx(&a, &b); - _DBFIT(temp, uint32_t); - nksize = (uint32_t)temp; - n = NBINTERNAL(nksize); - if (n < nbytes) { -#ifdef STATISTICS - bt_pfxsaved += nbytes - n; -#endif - nbytes = n; - } else - nksize = 0; - } else - nksize = 0; - break; - case P_RINTERNAL: - case P_RLEAF: - nbytes = NRINTERNAL; - break; - default: - abort(); - } - - /* Split the parent page if necessary or shift the indices. */ - if ((uint32_t)h->upper - (uint32_t)h->lower < nbytes + sizeof(indx_t)) { - sp = h; - h = h->pgno == P_ROOT ? - bt_root(t, h, &l, &r, &skip, nbytes) : - bt_page(t, h, &l, &r, &skip, nbytes); - if (h == NULL) - goto err1; - parentsplit = 1; - } else { - if (skip < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + skip + 1, h->linp + skip, - (nxtindex - skip) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - parentsplit = 0; - } - - /* Insert the key into the parent page. */ - switch (rchild->flags & P_TYPE) { - case P_BINTERNAL: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)(void *)h + h->linp[skip]; - memmove(dest, bi, nbytes); - ((BINTERNAL *)(void *)dest)->pgno = rchild->pgno; - break; - case P_BLEAF: - h->linp[skip] = h->upper -= nbytes; - dest = (char *)(void *)h + h->linp[skip]; - WR_BINTERNAL(dest, nksize ? nksize : bl->ksize, - rchild->pgno, bl->flags & P_BIGKEY); - memmove(dest, bl->bytes, nksize ? nksize : bl->ksize); - if (bl->flags & P_BIGKEY) { - pgno_t pgno; - memcpy(&pgno, bl->bytes, sizeof(pgno)); - if (bt_preserve(t, pgno) == RET_ERROR) - goto err1; - } - break; - case P_RINTERNAL: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)(void *)h + h->linp[skip - 1]; - else - dest = (char *)(void *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)(void *)dest)->nrecs = rec_total(lchild); - ((RINTERNAL *)(void *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)(void *)h + h->linp[skip]; - ((RINTERNAL *)(void *)dest)->nrecs = rec_total(rchild); - ((RINTERNAL *)(void *)dest)->pgno = rchild->pgno; - break; - case P_RLEAF: - /* - * Update the left page count. If split - * added at index 0, fix the correct page. - */ - if (skip > 0) - dest = (char *)(void *)h + h->linp[skip - 1]; - else - dest = (char *)(void *)l + l->linp[NEXTINDEX(l) - 1]; - ((RINTERNAL *)(void *)dest)->nrecs = NEXTINDEX(lchild); - ((RINTERNAL *)(void *)dest)->pgno = lchild->pgno; - - /* Update the right page count. */ - h->linp[skip] = h->upper -= nbytes; - dest = (char *)(void *)h + h->linp[skip]; - ((RINTERNAL *)(void *)dest)->nrecs = NEXTINDEX(rchild); - ((RINTERNAL *)(void *)dest)->pgno = rchild->pgno; - break; - default: - abort(); - } - - /* Unpin the held pages. */ - if (!parentsplit) { - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - } - - /* If the root page was split, make it look right. */ - if (sp->pgno == P_ROOT && - (F_ISSET(t, R_RECNO) ? - bt_rroot(t, sp, l, r) : bt_broot(t, sp, l, r)) == RET_ERROR) - goto err1; - - mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - } - - /* Unpin the held pages. */ - mpool_put(t->bt_mp, l, MPOOL_DIRTY); - mpool_put(t->bt_mp, r, MPOOL_DIRTY); - - /* Clear any pages left on the stack. */ - return (RET_SUCCESS); - - /* - * If something fails in the above loop we were already walking back - * up the tree and the tree is now inconsistent. Nothing much we can - * do about it but release any memory we're holding. - */ -err1: mpool_put(t->bt_mp, lchild, MPOOL_DIRTY); - mpool_put(t->bt_mp, rchild, MPOOL_DIRTY); - -err2: mpool_put(t->bt_mp, l, 0); - mpool_put(t->bt_mp, r, 0); - __dbpanic(t->bt_dbp); - return (RET_ERROR); -} - -/* - * BT_PAGE -- Split a non-root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_page(BTREE *t, PAGE *h, PAGE **lp, PAGE **rp, indx_t *skip, size_t ilen) -{ - PAGE *l, *r, *tp; - pgno_t npg; - -#ifdef STATISTICS - ++bt_split; -#endif - /* Put the new right page for the split into place. */ - if ((r = __bt_new(t, &npg)) == NULL) - return (NULL); - r->pgno = npg; - r->lower = BTDATAOFF; - r->upper = t->bt_psize; - r->nextpg = h->nextpg; - r->prevpg = h->pgno; - r->flags = h->flags & P_TYPE; - - /* - * If we're splitting the last page on a level because we're appending - * a key to it (skip is NEXTINDEX()), it's likely that the data is - * sorted. Adding an empty page on the side of the level is less work - * and can push the fill factor much higher than normal. If we're - * wrong it's no big deal, we'll just do the split the right way next - * time. It may look like it's equally easy to do a similar hack for - * reverse sorted data, that is, split the tree left, but it's not. - * Don't even try. - */ - if (h->nextpg == P_INVALID && *skip == NEXTINDEX(h)) { -#ifdef STATISTICS - ++bt_sortsplit; -#endif - h->nextpg = r->pgno; - r->lower = BTDATAOFF + sizeof(indx_t); - *skip = 0; - *lp = h; - *rp = r; - return (r); - } - - /* Put the new left page for the split into place. */ - if ((l = calloc(1, t->bt_psize)) == NULL) { - mpool_put(t->bt_mp, r, 0); - return (NULL); - } -#ifdef PURIFY - memset(l, 0xff, t->bt_psize); -#endif - l->pgno = h->pgno; - l->nextpg = r->pgno; - l->prevpg = h->prevpg; - l->lower = BTDATAOFF; - l->upper = t->bt_psize; - l->flags = h->flags & P_TYPE; - - /* Fix up the previous pointer of the page after the split page. */ - if (h->nextpg != P_INVALID) { - if ((tp = mpool_get(t->bt_mp, h->nextpg, 0)) == NULL) { - free(l); - /* XXX mpool_free(t->bt_mp, r->pgno); */ - return (NULL); - } - tp->prevpg = r->pgno; - mpool_put(t->bt_mp, tp, MPOOL_DIRTY); - } - - /* - * Split right. The key/data pairs aren't sorted in the btree page so - * it's simpler to copy the data from the split page onto two new pages - * instead of copying half the data to the right page and compacting - * the left page in place. Since the left page can't change, we have - * to swap the original and the allocated left page after the split. - */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - /* Move the new left page onto the old left page. */ - memmove(h, l, t->bt_psize); - if (tp == l) - tp = h; - free(l); - - *lp = h; - *rp = r; - return (tp); -} - -/* - * BT_ROOT -- Split the root page of a btree. - * - * Parameters: - * t: tree - * h: root page - * lp: pointer to left page pointer - * rp: pointer to right page pointer - * skip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert or NULL on error. - */ -static PAGE * -bt_root(BTREE *t, PAGE *h, PAGE **lp, PAGE **rp, indx_t *skip, size_t ilen) -{ - PAGE *l, *r, *tp; - pgno_t lnpg, rnpg; - -#ifdef STATISTICS - ++bt_split; - ++bt_rootsplit; -#endif - /* Put the new left and right pages for the split into place. */ - if ((l = __bt_new(t, &lnpg)) == NULL || - (r = __bt_new(t, &rnpg)) == NULL) - return (NULL); - l->pgno = lnpg; - r->pgno = rnpg; - l->nextpg = r->pgno; - r->prevpg = l->pgno; - l->prevpg = r->nextpg = P_INVALID; - l->lower = r->lower = BTDATAOFF; - l->upper = r->upper = t->bt_psize; - l->flags = r->flags = h->flags & P_TYPE; - - /* Split the root page. */ - tp = bt_psplit(t, h, l, r, skip, ilen); - - *lp = l; - *rp = r; - return (tp); -} - -/* - * BT_RROOT -- Fix up the recno root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_rroot(BTREE *t, PAGE *h, PAGE *l, PAGE *r) -{ - char *dest; - uint32_t sz; - size_t temp; - - temp = t->bt_psize - NRINTERNAL; - _DBFIT(temp, uint32_t); - sz = (uint32_t)temp; - - /* Insert the left and right keys, set the header information. */ - _DBFIT(sz, indx_t); - h->linp[0] = h->upper = (indx_t)sz; - dest = (char *)(void *)h + h->upper; - WR_RINTERNAL(dest, - l->flags & P_RLEAF ? NEXTINDEX(l) : rec_total(l), l->pgno); - - h->linp[1] = h->upper -= NRINTERNAL; - dest = (char *)(void *)h + h->upper; - WR_RINTERNAL(dest, - r->flags & P_RLEAF ? NEXTINDEX(r) : rec_total(r), r->pgno); - - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to recno internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_RINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_BROOT -- Fix up the btree root page after it has been split. - * - * Parameters: - * t: tree - * h: root page - * l: left page - * r: right page - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -static int -bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r) -{ - BINTERNAL *bi = NULL; /* pacify gcc */ - BLEAF *bl; - uint32_t nbytes; - char *dest; - - /* - * If the root page was a leaf page, change it into an internal page. - * We copy the key we split on (but not the key's data, in the case of - * a leaf page) to the new root page. - * - * The btree comparison code guarantees that the left-most key on any - * level of the tree is never used, so it doesn't need to be filled in. - */ - nbytes = NBINTERNAL(0); - h->linp[0] = h->upper = t->bt_psize - nbytes; - dest = (char *)(void *)h + h->upper; - WR_BINTERNAL(dest, 0, l->pgno, 0); - - switch (h->flags & P_TYPE) { - case P_BLEAF: - bl = GETBLEAF(r, 0); - nbytes = NBINTERNAL(bl->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)(void *)h + h->upper; - WR_BINTERNAL(dest, bl->ksize, r->pgno, 0); - memmove(dest, bl->bytes, bl->ksize); - - /* - * If the key is on an overflow page, mark the overflow chain - * so it isn't deleted when the leaf copy of the key is deleted. - */ - if (bl->flags & P_BIGKEY) { - pgno_t pgno; - memcpy(&pgno, bl->bytes, sizeof(pgno)); - if (bt_preserve(t, pgno) == RET_ERROR) - return (RET_ERROR); - } - break; - case P_BINTERNAL: - bi = GETBINTERNAL(r, 0); - nbytes = NBINTERNAL(bi->ksize); - h->linp[1] = h->upper -= nbytes; - dest = (char *)(void *)h + h->upper; - memmove(dest, bi, nbytes); - ((BINTERNAL *)(void *)dest)->pgno = r->pgno; - break; - default: - abort(); - } - - /* There are two keys on the page. */ - h->lower = BTDATAOFF + 2 * sizeof(indx_t); - - /* Unpin the root page, set to btree internal page. */ - h->flags &= ~P_TYPE; - h->flags |= P_BINTERNAL; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} - -/* - * BT_PSPLIT -- Do the real work of splitting the page. - * - * Parameters: - * t: tree - * h: page to be split - * l: page to put lower half of data - * r: page to put upper half of data - * pskip: pointer to index to leave open - * ilen: insert length - * - * Returns: - * Pointer to page in which to insert. - */ -static PAGE * -bt_psplit(BTREE *t, PAGE *h, PAGE *l, PAGE *r, indx_t *pskip, size_t ilen) -{ - BINTERNAL *bi; - BLEAF *bl; - CURSOR *c; - RLEAF *rl; - PAGE *rval; - void *src = NULL; /* pacify gcc */ - indx_t full, half, nxt, off, skip, top, used; - uint32_t nbytes; - size_t temp; - int bigkeycnt, isbigkey; - - /* - * Split the data to the left and right pages. Leave the skip index - * open. Additionally, make some effort not to split on an overflow - * key. This makes internal page processing faster and can save - * space as overflow keys used by internal pages are never deleted. - */ - bigkeycnt = 0; - skip = *pskip; - temp = t->bt_psize - BTDATAOFF; - _DBFIT(temp, indx_t); - full = (indx_t)temp; - half = full / 2; - used = 0; - for (nxt = off = 0, top = NEXTINDEX(h); nxt < top; ++off) { - if (skip == off) { - _DBFIT(ilen, uint32_t); - nbytes = (uint32_t)ilen; - isbigkey = 0; /* XXX: not really known. */ - } else - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - isbigkey = bi->flags & P_BIGKEY; - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - isbigkey = bl->flags & P_BIGKEY; - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - isbigkey = 0; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - isbigkey = 0; - break; - default: - abort(); - } - - /* - * If the key/data pairs are substantial fractions of the max - * possible size for the page, it's possible to get situations - * where we decide to try and copy too much onto the left page. - * Make sure that doesn't happen. - */ - if ((skip <= off && used + nbytes + sizeof(indx_t) >= full) || - nxt == top - 1) { - --off; - break; - } - - /* Copy the key/data pair, if not the skipped index. */ - if (skip != off) { - ++nxt; - - l->linp[off] = l->upper -= nbytes; - memmove((char *)(void *)l + l->upper, src, nbytes); - } - - temp = nbytes + sizeof(indx_t); - _DBFIT(temp, indx_t); - used += (indx_t)temp; - if (used >= half) { - if (!isbigkey || bigkeycnt == 3) - break; - else - ++bigkeycnt; - } - } - - /* - * Off is the last offset that's valid for the left page. - * Nxt is the first offset to be placed on the right page. - */ - temp = (off + 1) * sizeof(indx_t); - _DBFIT(temp, indx_t); - l->lower += (indx_t)temp; - - /* - * If splitting the page that the cursor was on, the cursor has to be - * adjusted to point to the same record as before the split. If the - * cursor is at or past the skipped slot, the cursor is incremented by - * one. If the cursor is on the right page, it is decremented by the - * number of records split to the left page. - */ - c = &t->bt_cursor; - if (F_ISSET(c, CURS_INIT) && c->pg.pgno == h->pgno) { - if (c->pg.index >= skip) - ++c->pg.index; - if (c->pg.index < nxt) /* Left page. */ - c->pg.pgno = l->pgno; - else { /* Right page. */ - c->pg.pgno = r->pgno; - c->pg.index -= nxt; - } - } - - /* - * If the skipped index was on the left page, just return that page. - * Otherwise, adjust the skip index to reflect the new position on - * the right page. - */ - if (skip <= off) { - skip = MAX_PAGE_OFFSET; - rval = l; - } else { - rval = r; - *pskip -= nxt; - } - - for (off = 0; nxt < top; ++off) { - if (skip == nxt) { - ++off; - skip = MAX_PAGE_OFFSET; - } - switch (h->flags & P_TYPE) { - case P_BINTERNAL: - src = bi = GETBINTERNAL(h, nxt); - nbytes = NBINTERNAL(bi->ksize); - break; - case P_BLEAF: - src = bl = GETBLEAF(h, nxt); - nbytes = NBLEAF(bl); - break; - case P_RINTERNAL: - src = GETRINTERNAL(h, nxt); - nbytes = NRINTERNAL; - break; - case P_RLEAF: - src = rl = GETRLEAF(h, nxt); - nbytes = NRLEAF(rl); - break; - default: - abort(); - } - ++nxt; - r->linp[off] = r->upper -= nbytes; - memmove((char *)(void *)r + r->upper, src, nbytes); - } - temp = off * sizeof(indx_t); - _DBFIT(temp, indx_t); - r->lower += (indx_t)temp; - - /* If the key is being appended to the page, adjust the index. */ - if (skip == top) - r->lower += sizeof(indx_t); - - return (rval); -} - -/* - * BT_PRESERVE -- Mark a chain of pages as used by an internal node. - * - * Chains of indirect blocks pointed to by leaf nodes get reclaimed when the - * record that references them gets deleted. Chains pointed to by internal - * pages never get deleted. This routine marks a chain as pointed to by an - * internal page. - * - * Parameters: - * t: tree - * pg: page number of first page in the chain. - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -static int -bt_preserve(BTREE *t, pgno_t pg) -{ - PAGE *h; - - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - return (RET_ERROR); - h->flags |= P_PRESERVE; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * REC_TOTAL -- Return the number of recno entries below a page. - * - * Parameters: - * h: page - * - * Returns: - * The number of recno entries below a page. - * - * XXX - * These values could be set by the bt_psplit routine. The problem is that the - * entry has to be popped off of the stack etc. or the values have to be passed - * all the way back to bt_split/bt_rroot and it's not very clean. - */ -static recno_t -rec_total(PAGE *h) -{ - recno_t recs; - indx_t nxt, top; - - for (recs = 0, nxt = 0, top = NEXTINDEX(h); nxt < top; ++nxt) - recs += GETRINTERNAL(h, nxt)->nrecs; - return (recs); -} diff --git a/lib/libc/db/btree/bt_utils.c b/lib/libc/db/btree/bt_utils.c deleted file mode 100644 index 1fef38af5..000000000 --- a/lib/libc/db/btree/bt_utils.c +++ /dev/null @@ -1,250 +0,0 @@ -/* $NetBSD: bt_utils.c,v 1.16 2013/12/14 18:04:56 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: bt_utils.c,v 1.16 2013/12/14 18:04:56 christos Exp $"); - -#include - -#include -#include -#include -#include - -#include -#include "btree.h" - -/* - * __bt_ret -- - * Build return key/data pair. - * - * Parameters: - * t: tree - * e: key/data pair to be returned - * key: user's key structure (NULL if not to be filled in) - * rkey: memory area to hold key - * data: user's data structure (NULL if not to be filled in) - * rdata: memory area to hold data - * copy: always copy the key/data item - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__bt_ret(BTREE *t, EPG *e, DBT *key, DBT *rkey, DBT *data, DBT *rdata, int copy) -{ - BLEAF *bl; - void *p; - - bl = GETBLEAF(e->page, e->index); - - /* - * We must copy big keys/data to make them contiguous. Otherwise, - * leave the page pinned and don't copy unless the user specified - * concurrent access. - */ - if (key == NULL) - goto dataonly; - - if (bl->flags & P_BIGKEY) { - if (__ovfl_get(t, bl->bytes, - &key->size, &rkey->data, &rkey->size)) - return (RET_ERROR); - key->data = rkey->data; - } else if (copy || F_ISSET(t, B_DB_LOCK)) { - if (bl->ksize > rkey->size) { - p = realloc(rkey->data, bl->ksize); - if (p == NULL) - return (RET_ERROR); - rkey->data = p; - rkey->size = bl->ksize; - } - memmove(rkey->data, bl->bytes, bl->ksize); - key->size = bl->ksize; - key->data = rkey->data; - } else { - key->size = bl->ksize; - key->data = bl->bytes; - } - -dataonly: - if (data == NULL) - return (RET_SUCCESS); - - if (bl->flags & P_BIGDATA) { - if (__ovfl_get(t, bl->bytes + bl->ksize, - &data->size, &rdata->data, &rdata->size)) - return (RET_ERROR); - data->data = rdata->data; - } else if (copy || F_ISSET(t, B_DB_LOCK)) { - /* Use +1 in case the first record retrieved is 0 length. */ - if (bl->dsize + 1 > rdata->size) { - p = realloc(rdata->data, bl->dsize + 1); - if (p == NULL) - return (RET_ERROR); - rdata->data = p; - rdata->size = bl->dsize + 1; - } - memmove(rdata->data, bl->bytes + bl->ksize, bl->dsize); - data->size = bl->dsize; - data->data = rdata->data; - } else { - data->size = bl->dsize; - data->data = bl->bytes + bl->ksize; - } - - return (RET_SUCCESS); -} - -/* - * __BT_CMP -- Compare a key to a given record. - * - * Parameters: - * t: tree - * k1: DBT pointer of first arg to comparison - * e: pointer to EPG for comparison - * - * Returns: - * < 0 if k1 is < record - * = 0 if k1 is = record - * > 0 if k1 is > record - */ -int -__bt_cmp(BTREE *t, const DBT *k1, EPG *e) -{ - BINTERNAL *bi; - BLEAF *bl; - DBT k2; - PAGE *h; - void *bigkey; - - /* - * The left-most key on internal pages, at any level of the tree, is - * guaranteed by the following code to be less than any user key. - * This saves us from having to update the leftmost key on an internal - * page when the user inserts a new key in the tree smaller than - * anything we've yet seen. - */ - h = e->page; - if (e->index == 0 && h->prevpg == P_INVALID && !(h->flags & P_BLEAF)) - return (1); - - bigkey = NULL; - if (h->flags & P_BLEAF) { - bl = GETBLEAF(h, e->index); - if (bl->flags & P_BIGKEY) - bigkey = bl->bytes; - else { - k2.data = bl->bytes; - k2.size = bl->ksize; - } - } else { - bi = GETBINTERNAL(h, e->index); - if (bi->flags & P_BIGKEY) - bigkey = bi->bytes; - else { - k2.data = bi->bytes; - k2.size = bi->ksize; - } - } - - if (bigkey) { - if (__ovfl_get(t, bigkey, - &k2.size, &t->bt_rdata.data, &t->bt_rdata.size)) - return (RET_ERROR); - k2.data = t->bt_rdata.data; - } - return ((*t->bt_cmp)(k1, &k2)); -} - -/* - * __BT_DEFCMP -- Default comparison routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * < 0 if a is < b - * = 0 if a is = b - * > 0 if a is > b - */ -int -__bt_defcmp(const DBT *a, const DBT *b) -{ - size_t len; - uint8_t *p1, *p2; - - /* - * XXX - * If a size_t doesn't fit in an int, this routine can lose. - * What we need is a integral type which is guaranteed to be - * larger than a size_t, and there is no such thing. - */ - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2) - if (*p1 != *p2) - return ((int)*p1 - (int)*p2); - return ((int)a->size - (int)b->size); -} - -/* - * __BT_DEFPFX -- Default prefix routine. - * - * Parameters: - * a: DBT #1 - * b: DBT #2 - * - * Returns: - * Number of bytes needed to distinguish b from a. - */ -size_t -__bt_defpfx(const DBT *a, const DBT *b) -{ - uint8_t *p1, *p2; - size_t cnt, len; - - cnt = 1; - len = MIN(a->size, b->size); - for (p1 = a->data, p2 = b->data; len--; ++p1, ++p2, ++cnt) - if (*p1 != *p2) - return (cnt); - - /* a->size must be <= b->size, or they wouldn't be in this order. */ - return (a->size < b->size ? a->size + 1 : a->size); -} diff --git a/lib/libc/db/btree/btree.h b/lib/libc/db/btree/btree.h deleted file mode 100644 index 9bd0faa43..000000000 --- a/lib/libc/db/btree/btree.h +++ /dev/null @@ -1,433 +0,0 @@ -/* $NetBSD: btree.h,v 1.17 2013/09/04 13:03:22 ryoon Exp $ */ - -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - * - * @(#)btree.h 8.11 (Berkeley) 8/17/94 - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -/* Macros to set/clear/test flags. */ -#define F_SET(p, f) (p)->flags |= (f) -#define F_CLR(p, f) (p)->flags &= ~(f) -#define F_ISSET(p, f) ((p)->flags & (f)) - -#include - -#define DEFMINKEYPAGE (2) /* Minimum keys per page */ -#define MINCACHE (5) /* Minimum cached pages */ -#define MINPSIZE (512) /* Minimum page size */ - -/* - * Page 0 of a btree file contains a copy of the meta-data. This page is also - * used as an out-of-band page, i.e. page pointers that point to nowhere point - * to page 0. Page 1 is the root of the btree. - */ -#define P_INVALID 0 /* Invalid tree page number. */ -#define P_META 0 /* Tree metadata page number. */ -#define P_ROOT 1 /* Tree root page number. */ - -/* - * There are five page layouts in the btree: btree internal pages (BINTERNAL), - * btree leaf pages (BLEAF), recno internal pages (RINTERNAL), recno leaf pages - * (RLEAF) and overflow pages. All five page types have a page header (PAGE). - * This implementation requires that values within structures NOT be padded. - * (ANSI C permits random padding.) If your compiler pads randomly you'll have - * to do some work to get this package to run. - */ -typedef struct _page { - pgno_t pgno; /* this page's page number */ - pgno_t prevpg; /* left sibling */ - pgno_t nextpg; /* right sibling */ - -#define P_BINTERNAL 0x01 /* btree internal page */ -#define P_BLEAF 0x02 /* leaf page */ -#define P_OVERFLOW 0x04 /* overflow page */ -#define P_RINTERNAL 0x08 /* recno internal page */ -#define P_RLEAF 0x10 /* leaf page */ -#define P_TYPE 0x1f /* type mask */ -#define P_PRESERVE 0x20 /* never delete this chain of pages */ - uint32_t flags; - - indx_t lower; /* lower bound of free space on page */ - indx_t upper; /* upper bound of free space on page */ - indx_t linp[1]; /* indx_t-aligned VAR. LENGTH DATA */ -} PAGE; - -/* First and next index. */ -#define BTDATAOFF \ - (sizeof(pgno_t) + sizeof(pgno_t) + sizeof(pgno_t) + \ - sizeof(uint32_t) + sizeof(indx_t) + sizeof(indx_t)) - -#define _NEXTINDEX(p) (((p)->lower - BTDATAOFF) / sizeof(indx_t)) -#ifdef _DIAGNOSTIC -static __inline indx_t -NEXTINDEX(const PAGE *p) { - size_t x = _NEXTINDEX(p); - _DBFIT(x, indx_t); - return (indx_t)x; -} -#else -#define NEXTINDEX(p) (indx_t)_NEXTINDEX(p) -#endif - -/* - * For pages other than overflow pages, there is an array of offsets into the - * rest of the page immediately following the page header. Each offset is to - * an item which is unique to the type of page. The h_lower offset is just - * past the last filled-in index. The h_upper offset is the first item on the - * page. Offsets are from the beginning of the page. - * - * If an item is too big to store on a single page, a flag is set and the item - * is a { page, size } pair such that the page is the first page of an overflow - * chain with size bytes of item. Overflow pages are simply bytes without any - * external structure. - * - * The page number and size fields in the items are pgno_t-aligned so they can - * be manipulated without copying. (This presumes that 32 bit items can be - * manipulated on this system.) - */ -#define BTLALIGN(n) (((n) + sizeof(pgno_t) - 1) & ~(sizeof(pgno_t) - 1)) -#define NOVFLSIZE (sizeof(pgno_t) + sizeof(uint32_t)) - -/* - * For the btree internal pages, the item is a key. BINTERNALs are {key, pgno} - * pairs, such that the key compares less than or equal to all of the records - * on that page. For a tree without duplicate keys, an internal page with two - * consecutive keys, a and b, will have all records greater than or equal to a - * and less than b stored on the page associated with a. Duplicate keys are - * somewhat special and can cause duplicate internal and leaf page records and - * some minor modifications of the above rule. - */ -typedef struct _binternal { - uint32_t ksize; /* key size */ - pgno_t pgno; /* page number stored on */ -#define P_BIGDATA 0x01 /* overflow data */ -#define P_BIGKEY 0x02 /* overflow key */ - uint8_t flags; - char bytes[1]; /* data */ -} BINTERNAL; - -/* Get the page's BINTERNAL structure at index indx. */ -#define GETBINTERNAL(pg, indx) \ - ((BINTERNAL *)(void *)((char *)(void *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define _NBINTERNAL(len) \ - BTLALIGN(sizeof(uint32_t) + sizeof(pgno_t) + sizeof(uint8_t) + (len)) -#ifdef _DIAGNOSTIC -static __inline uint32_t -NBINTERNAL(uint32_t len) { - size_t x = _NBINTERNAL(len); - _DBFIT(x, uint32_t); - return (uint32_t)x; -} -#else -#define NBINTERNAL(len) (uint32_t)_NBINTERNAL(len) -#endif - -/* Copy a BINTERNAL entry to the page. */ -#define WR_BINTERNAL(p, size, pgno, flags) do { \ - _DBFIT(size, uint32_t); \ - *(uint32_t *)(void *)p = (uint32_t)size; \ - p += sizeof(uint32_t); \ - *(pgno_t *)(void *)p = pgno; \ - p += sizeof(pgno_t); \ - *(uint8_t *)(void *)p = flags; \ - p += sizeof(uint8_t); \ -} while (/*CONSTCOND*/0) - -/* - * For the recno internal pages, the item is a page number with the number of - * keys found on that page and below. - */ -typedef struct _rinternal { - recno_t nrecs; /* number of records */ - pgno_t pgno; /* page number stored below */ -} RINTERNAL; - -/* Get the page's RINTERNAL structure at index indx. */ -#define GETRINTERNAL(pg, indx) \ - ((RINTERNAL *)(void *)((char *)(void *)(pg) + (pg)->linp[indx])) - -/* Get the number of bytes in the entry. */ -#define NRINTERNAL \ - BTLALIGN(sizeof(recno_t) + sizeof(pgno_t)) - -/* Copy a RINTERNAL entry to the page. */ -#define WR_RINTERNAL(p, nrecs, pgno) do { \ - *(recno_t *)(void *)p = nrecs; \ - p += sizeof(recno_t); \ - *(pgno_t *)(void *)p = pgno; \ -} while (/*CONSTCOND*/0) - -/* For the btree leaf pages, the item is a key and data pair. */ -typedef struct _bleaf { - uint32_t ksize; /* size of key */ - uint32_t dsize; /* size of data */ - uint8_t flags; /* P_BIGDATA, P_BIGKEY */ - char bytes[1]; /* data */ -} BLEAF; - -/* Get the page's BLEAF structure at index indx. */ -#define GETBLEAF(pg, indx) \ - ((BLEAF *)(void *)((char *)(void *)(pg) + (pg)->linp[indx])) - - -/* Get the number of bytes in the user's key/data pair. */ -#define _NBLEAFDBT(ksize, dsize) \ - BTLALIGN(sizeof(uint32_t) + sizeof(uint32_t) + sizeof(uint8_t) + \ - (ksize) + (dsize)) -#ifdef _DIAGNOSTIC -static __inline uint32_t -NBLEAFDBT(size_t k, size_t d) { - size_t x = _NBLEAFDBT(k, d); - _DBFIT(x, uint32_t); - return (uint32_t)x; -} -#else -#define NBLEAFDBT(p, q) (uint32_t)_NBLEAFDBT(p, q) -#endif - -/* Get the number of bytes in the entry. */ -#define NBLEAF(p) NBLEAFDBT((p)->ksize, (p)->dsize) - -/* Copy a BLEAF entry to the page. */ -#define WR_BLEAF(p, key, data, flags) do { \ - _DBFIT(key->size, uint32_t); \ - *(uint32_t *)(void *)p = (uint32_t)key->size; \ - p += sizeof(uint32_t); \ - _DBFIT(data->size, uint32_t); \ - *(uint32_t *)(void *)p = (uint32_t)data->size; \ - p += sizeof(uint32_t); \ - *(uint8_t *)(void *)p = flags; \ - p += sizeof(uint8_t); \ - (void)memmove(p, key->data, key->size); \ - p += key->size; \ - (void)memmove(p, data->data, data->size); \ -} while (/*CONSTCOND*/0) - -/* For the recno leaf pages, the item is a data entry. */ -typedef struct _rleaf { - uint32_t dsize; /* size of data */ - uint8_t flags; /* P_BIGDATA */ - char bytes[1]; -} RLEAF; - -/* Get the page's RLEAF structure at index indx. */ -#define GETRLEAF(pg, indx) \ - ((RLEAF *)(void *)((char *)(void *)(pg) + (pg)->linp[indx])) - -#define _NRLEAFDBT(dsize) \ - BTLALIGN(sizeof(uint32_t) + sizeof(uint8_t) + (dsize)) - -#ifdef _DIAGNOSTIC -static __inline uint32_t -NRLEAFDBT(size_t d) { - size_t x = _NRLEAFDBT(d); - _DBFIT(x, uint32_t); - return (uint32_t)x; -} -#else -#define NRLEAFDBT(d) (uint32_t)_NRLEAFDBT(d) -#endif - -/* Get the number of bytes in the entry. */ -#define NRLEAF(p) NRLEAFDBT((p)->dsize) - -/* Get the number of bytes from the user's data. */ - -/* Copy a RLEAF entry to the page. */ -#define WR_RLEAF(p, data, flags) do { \ - _DBFIT(data->size, uint32_t); \ - *(uint32_t *)(void *)p = (uint32_t)data->size; \ - p += sizeof(uint32_t); \ - *(uint8_t *)(void *)p = flags; \ - p += sizeof(uint8_t); \ - memmove(p, data->data, data->size); \ -} while (/*CONSTCOND*/0) - -/* - * A record in the tree is either a pointer to a page and an index in the page - * or a page number and an index. These structures are used as a cursor, stack - * entry and search returns as well as to pass records to other routines. - * - * One comment about searches. Internal page searches must find the largest - * record less than key in the tree so that descents work. Leaf page searches - * must find the smallest record greater than key so that the returned index - * is the record's correct position for insertion. - */ -typedef struct _epgno { - pgno_t pgno; /* the page number */ - indx_t index; /* the index on the page */ -} EPGNO; - -typedef struct _epg { - PAGE *page; /* the (pinned) page */ - indx_t index; /* the index on the page */ -} EPG; - -/* - * About cursors. The cursor (and the page that contained the key/data pair - * that it referenced) can be deleted, which makes things a bit tricky. If - * there are no duplicates of the cursor key in the tree (i.e. B_NODUPS is set - * or there simply aren't any duplicates of the key) we copy the key that it - * referenced when it's deleted, and reacquire a new cursor key if the cursor - * is used again. If there are duplicates keys, we move to the next/previous - * key, and set a flag so that we know what happened. NOTE: if duplicate (to - * the cursor) keys are added to the tree during this process, it is undefined - * if they will be returned or not in a cursor scan. - * - * The flags determine the possible states of the cursor: - * - * CURS_INIT The cursor references *something*. - * CURS_ACQUIRE The cursor was deleted, and a key has been saved so that - * we can reacquire the right position in the tree. - * CURS_AFTER, CURS_BEFORE - * The cursor was deleted, and now references a key/data pair - * that has not yet been returned, either before or after the - * deleted key/data pair. - * XXX - * This structure is broken out so that we can eventually offer multiple - * cursors as part of the DB interface. - */ -typedef struct _cursor { - EPGNO pg; /* B: Saved tree reference. */ - DBT key; /* B: Saved key, or key.data == NULL. */ - recno_t rcursor; /* R: recno cursor (1-based) */ - -#define CURS_ACQUIRE 0x01 /* B: Cursor needs to be reacquired. */ -#define CURS_AFTER 0x02 /* B: Unreturned cursor after key. */ -#define CURS_BEFORE 0x04 /* B: Unreturned cursor before key. */ -#define CURS_INIT 0x08 /* RB: Cursor initialized. */ - uint8_t flags; -} CURSOR; - -/* - * The metadata of the tree. The nrecs field is used only by the RECNO code. - * This is because the btree doesn't really need it and it requires that every - * put or delete call modify the metadata. - */ -typedef struct _btmeta { - uint32_t magic; /* magic number */ - uint32_t version; /* version */ - uint32_t psize; /* page size */ - uint32_t free; /* page number of first free page */ - uint32_t nrecs; /* R: number of records */ - -#define SAVEMETA (B_NODUPS | R_RECNO) - uint32_t flags; /* bt_flags & SAVEMETA */ -} BTMETA; - -/* The in-memory btree/recno data structure. */ -typedef struct _btree { - MPOOL *bt_mp; /* memory pool cookie */ - - DB *bt_dbp; /* pointer to enclosing DB */ - - EPG bt_cur; /* current (pinned) page */ - PAGE *bt_pinned; /* page pinned across calls */ - - CURSOR bt_cursor; /* cursor */ - -#define BT_PUSH(t, p, i) { \ - t->bt_sp->pgno = p; \ - t->bt_sp->index = i; \ - ++t->bt_sp; \ -} -#define BT_POP(t) (t->bt_sp == t->bt_stack ? NULL : --t->bt_sp) -#define BT_CLR(t) (t->bt_sp = t->bt_stack) - EPGNO bt_stack[50]; /* stack of parent pages */ - EPGNO *bt_sp; /* current stack pointer */ - - DBT bt_rkey; /* returned key */ - DBT bt_rdata; /* returned data */ - - int bt_fd; /* tree file descriptor */ - - pgno_t bt_free; /* next free page */ - uint32_t bt_psize; /* page size */ - indx_t bt_ovflsize; /* cut-off for key/data overflow */ - int bt_lorder; /* byte order */ - /* sorted order */ - enum { NOT, BACK, FORWARD } bt_order; - EPGNO bt_last; /* last insert */ - - /* B: key comparison function */ - int (*bt_cmp)(const DBT *, const DBT *); - /* B: prefix comparison function */ - size_t (*bt_pfx)(const DBT *, const DBT *); - /* R: recno input function */ - int (*bt_irec)(struct _btree *, recno_t); - - FILE *bt_rfp; /* R: record FILE pointer */ - int bt_rfd; /* R: record file descriptor */ - - caddr_t bt_cmap; /* R: current point in mapped space */ - caddr_t bt_smap; /* R: start of mapped space */ - caddr_t bt_emap; /* R: end of mapped space */ - size_t bt_msize; /* R: size of mapped region. */ - - recno_t bt_nrecs; /* R: number of records */ - size_t bt_reclen; /* R: fixed record length */ - uint8_t bt_bval; /* R: delimiting byte/pad character */ - -/* - * NB: - * B_NODUPS and R_RECNO are stored on disk, and may not be changed. - */ -#define B_INMEM 0x00001 /* in-memory tree */ -#define B_METADIRTY 0x00002 /* need to write metadata */ -#define B_MODIFIED 0x00004 /* tree modified */ -#define B_NEEDSWAP 0x00008 /* if byte order requires swapping */ -#define B_RDONLY 0x00010 /* read-only tree */ - -#define B_NODUPS 0x00020 /* no duplicate keys permitted */ -#define R_RECNO 0x00080 /* record oriented tree */ - -#define R_CLOSEFP 0x00040 /* opened a file pointer */ -#define R_EOF 0x00100 /* end of input file reached. */ -#define R_FIXLEN 0x00200 /* fixed length records */ -#define R_MEMMAPPED 0x00400 /* memory mapped file. */ -#define R_INMEM 0x00800 /* in-memory file */ -#define R_MODIFIED 0x01000 /* modified file */ -#define R_RDONLY 0x02000 /* read-only file */ - -#define B_DB_LOCK 0x04000 /* DB_LOCK specified. */ -#define B_DB_SHMEM 0x08000 /* DB_SHMEM specified. */ -#define B_DB_TXN 0x10000 /* DB_TXN specified. */ - uint32_t flags; -} BTREE; - -#include "extern.h" diff --git a/lib/libc/db/btree/extern.h b/lib/libc/db/btree/extern.h deleted file mode 100644 index 665f852a5..000000000 --- a/lib/libc/db/btree/extern.h +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: extern.h,v 1.12 2008/09/26 11:41:06 tsutsui Exp $ */ - -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.10 (Berkeley) 7/20/94 - */ - -#ifndef _BTREE_EXTERN_H_ -#define _BTREE_EXTERN_H_ -int __bt_close(DB *); -int __bt_cmp(BTREE *, const DBT *, EPG *); -int __bt_crsrdel(BTREE *, EPGNO *); -int __bt_defcmp(const DBT *, const DBT *); -size_t __bt_defpfx(const DBT *, const DBT *); -int __bt_delete(const DB *, const DBT *, unsigned int); -int __bt_dleaf(BTREE *, const DBT *, PAGE *, unsigned int); -int __bt_fd(const DB *); -int __bt_free(BTREE *, PAGE *); -int __bt_get(const DB *, const DBT *, DBT *, unsigned int); -PAGE *__bt_new(BTREE *, pgno_t *); -void __bt_pgin(void *, pgno_t, void *); -void __bt_pgout(void *, pgno_t, void *); -int __bt_push(BTREE *, pgno_t, int); -int __bt_put(const DB *dbp, DBT *, const DBT *, unsigned int); -int __bt_ret(BTREE *, EPG *, DBT *, DBT *, DBT *, DBT *, int); -EPG *__bt_search(BTREE *, const DBT *, int *); -int __bt_seq(const DB *, DBT *, DBT *, unsigned int); -void __bt_setcur(BTREE *, pgno_t, unsigned int); -int __bt_split(BTREE *, PAGE *, - const DBT *, const DBT *, int, size_t, uint32_t); -int __bt_sync(const DB *, unsigned int); - -int __ovfl_delete(BTREE *, void *); -int __ovfl_get(BTREE *, void *, size_t *, void **, size_t *); -int __ovfl_put(BTREE *, const DBT *, pgno_t *); - -#ifdef DEBUG -void __bt_dmpage(PAGE *); -void __bt_dnpage(DB *, pgno_t); -void __bt_dpage(PAGE *); -void __bt_dump(DB *); -#endif -#ifdef STATISTICS -void __bt_stat(DB *); -#endif -#endif /* _BTREE_EXTERN_H_ */ diff --git a/lib/libc/db/changelog b/lib/libc/db/changelog deleted file mode 100644 index f820e56b5..000000000 --- a/lib/libc/db/changelog +++ /dev/null @@ -1,105 +0,0 @@ -# $NetBSD: changelog,v 1.2 1996/05/03 21:20:56 cgd Exp $ - -1.84 -> 1.85 - recno: #ifdef out use of mmap, it's not portable enough. - -1.83 -> 1.84 Thu Aug 18 15:46:07 EDT 1994 - recno: Rework fixed-length records so that closing and reopening - the file now works. Pad short records on input. Never do - signed comparison in recno input reading functions. - -1.82 -> 1.83 Tue Jul 26 15:33:44 EDT 1994 - btree: Rework cursor deletion code yet again; bugs with - deleting empty pages that only contained the cursor - record. - -1.81 -> 1.82 Sat Jul 16 11:01:50 EDT 1994 - btree: Fix bugs introduced by new cursor/deletion code. - Replace return kbuf/dbuf with real DBT's. - -1.80 -> 1.81 - btree: Fix bugs introduced by new cursor/deletion code. - all: Add #defines for Purify. - -1.79 -> 1.80 Wed Jul 13 22:41:54 EDT 1994 - btree Change deletion to coalesce empty pages. This is a major - change, cursors and duplicate pages all had to be reworked. - Return to a fixed stack. - recno: Affected by cursor changes. New cursor structures should - permit multiple cursors in the future. - -1.78 -> 1.79 Mon Jun 20 17:36:47 EDT 1994 - all: Minor cleanups of 1.78 for porting reasons; only - major change was inlining check of NULL pointer - so that __fix_realloc goes away. - -1.77 -> 1.78 Thu Jun 16 19:06:43 EDT 1994 - all: Move "standard" size typedef's into db.h. - -1.76 -> 1.77 Thu Jun 16 16:48:38 EDT 1994 - hash: Delete __init_ routine, has special meaning to OSF 2.0. - -1.74 -> 1.76 - all: Finish up the port to the Alpha. - -1.73 -> 1.74 - recno: Don't put the record if rec_search fails, in rec_rdelete. - Create fixed-length intermediate records past "end" of DB - correctly. - Realloc bug when reading in fixed records. - all: First cut at port to Alpha (64-bit architecture) using - 4.4BSD basic integral types typedef's. - Cast allocation pointers to shut up old compilers. - Rework PORT directory into OS/machine directories. - -1.72 -> 1.73 - btree: If enough duplicate records were inserted and then deleted - that internal pages had references to empty pages of the - duplicate keys, the search function ended up on the wrong - page. - -1.7 -> 1.72 12 Oct 1993 - hash: Support NET/2 hash formats. - -1.7 -> 1.71 16 Sep 1993 - btree/recno: - Fix bug in internal search routines that caused - return of invalid pointers. - -1.6 -> 1.7 07 Sep 1993 - hash: Fixed big key overflow bugs. - test: Portability hacks, rewrite test script, Makefile. - btree/recno: - Stop copying non-overflow key/data pairs. - PORT: Break PORT directory up into per architecture/OS - subdirectories. - -1.5 -> 1.6 06 Jun 1993 - hash: In PAIRFITS, the first comparison should look at (P)[2]. - The hash_realloc function was walking off the end of memory. - The overflow page number was wrong when bumping splitpoint. - -1.4 -> 1.5 23 May 1993 - hash: Set hash default fill factor dynamically. - recno: Fixed bug in sorted page splits. - Add page size parameter support. - Allow recno to specify the name of the underlying btree; - used for vi recovery. - btree/recno: - Support 64K pages. - btree/hash/recno: - Provide access to an underlying file descriptor. - Change sync routines to take a flag argument, recno - uses this to sync out the underlying btree. - -1.3 -> 1.4 10 May 1993 - recno: Delete the R_CURSORLOG flag from the recno interface. - Zero-length record fix for non-mmap reads. - Try and make SIZE_T_MAX test in open portable. - -1.2 -> 1.3 01 May 1993 - btree: Ignore user byte-order setting when reading already - existing database. Fixes to byte-order conversions. - -1.1 -> 1.2 15 Apr 1993 - No bug fixes, only compatibility hacks. diff --git a/lib/libc/db/db/Makefile.inc b/lib/libc/db/db/Makefile.inc deleted file mode 100644 index ffe98558f..000000000 --- a/lib/libc/db/db/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2013/12/01 00:22:48 christos Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/db - -SRCS+= db.c dbfile.c diff --git a/lib/libc/db/db/db.c b/lib/libc/db/db/db.c deleted file mode 100644 index c6338cb43..000000000 --- a/lib/libc/db/db/db.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: db.c,v 1.18 2015/05/19 13:20:52 christos Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: db.c,v 1.18 2015/05/19 13:20:52 christos Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#include -static int __dberr(void); - -#ifdef __weak_alias -__weak_alias(dbopen,_dbopen) -#endif - -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - -DB * -dbopen(const char *fname, int flags, mode_t mode, DBTYPE type, - const void *openinfo) -{ - -#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) -#if defined(__minix) -#define USE_OPEN_FLAGS \ - (O_CREAT | O_EXCL | O_NONBLOCK | O_RDONLY | \ - O_RDWR | O_TRUNC | O_CLOEXEC) -#else -#define USE_OPEN_FLAGS \ - (O_CREAT | O_EXCL | O_EXLOCK | O_NONBLOCK | O_RDONLY | \ - O_RDWR | O_SHLOCK | O_TRUNC | O_CLOEXEC) -#endif /* defined(__minix) */ - - if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) - switch (type) { - case DB_BTREE: - return (__bt_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, (int)(flags & DB_FLAGS))); - case DB_HASH: - return (__hash_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, (int)(flags & DB_FLAGS))); - case DB_RECNO: - return (__rec_open(fname, flags & USE_OPEN_FLAGS, - mode, openinfo, (int)(flags & DB_FLAGS))); - } - errno = EINVAL; - return (NULL); -} - -static int -__dberr(void) -{ - return (RET_ERROR); -} - -/* - * __DBPANIC -- Stop. - * - * Parameters: - * dbp: pointer to the DB structure. - */ -void -__dbpanic(DB *dbp) -{ - /* The only thing that can succeed is a close. */ - dbp->del = (int (*)(const struct __db *, const DBT*, u_int))__dberr; - dbp->fd = (int (*)(const struct __db *))__dberr; - dbp->get = (int (*)(const struct __db *, const DBT*, DBT *, u_int))__dberr; - dbp->put = (int (*)(const struct __db *, DBT *, const DBT *, u_int))__dberr; - dbp->seq = (int (*)(const struct __db *, DBT *, DBT *, u_int))__dberr; - dbp->sync = (int (*)(const struct __db *, u_int))__dberr; -} diff --git a/lib/libc/db/db/dbfile.c b/lib/libc/db/db/dbfile.c deleted file mode 100644 index 2179109a7..000000000 --- a/lib/libc/db/db/dbfile.c +++ /dev/null @@ -1,118 +0,0 @@ -/* $NetBSD: dbfile.c,v 1.1 2013/12/01 00:22:48 christos Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: dbfile.c,v 1.1 2013/12/01 00:22:48 christos Exp $"); - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -int -__dbopen(const char *file, int flags, mode_t mode, struct stat *sb) -{ - int fd; - int serrno; - -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - - if ((fd = open(file, flags | O_CLOEXEC, mode)) == -1) - return -1; - -#if O_CLOEXEC == 0 - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) - goto out; -#endif - - if (sb && fstat(fd, sb) == -1) - goto out; - - return fd; -out: - serrno = errno; - close(fd); - errno = serrno; - return -1; - -} - -int -__dbtemp(const char *prefix, struct stat *sb) -{ - sigset_t set, oset; - int len; - int fd, serrno; - char *envtmp; - char path[PATH_MAX]; - - if (issetugid()) - envtmp = NULL; - else - envtmp = getenv("TMPDIR"); - - len = snprintf(path, sizeof(path), "%s/%sXXXXXX", - envtmp ? envtmp : _PATH_TMP, prefix); - if ((size_t)len >= sizeof(path)) { - errno = ENAMETOOLONG; - return -1; - } - - (void)sigfillset(&set); - (void)sigprocmask(SIG_BLOCK, &set, &oset); - - if ((fd = mkstemp(path)) != -1) { - if (unlink(path) == -1) - goto out; - - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) - goto out; - - if (sb && fstat(fd, sb) == -1) - goto out; - } - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - return fd; -out: - serrno = errno; - (void)sigprocmask(SIG_SETMASK, &oset, NULL); - close(fd); - errno = serrno; - return -1; -} diff --git a/lib/libc/db/hash/Makefile.inc b/lib/libc/db/hash/Makefile.inc deleted file mode 100644 index d65b3106d..000000000 --- a/lib/libc/db/hash/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.9 2005/09/13 01:44:09 christos Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/hash - -SRCS+= hash.c hash_bigkey.c hash_buf.c hash_func.c hash_log2.c \ - hash_page.c ndbmdatum.c ndbm.c diff --git a/lib/libc/db/hash/extern.h b/lib/libc/db/hash/extern.h deleted file mode 100644 index 455bf51d8..000000000 --- a/lib/libc/db/hash/extern.h +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: extern.h,v 1.9 2008/08/26 21:18:38 joerg Exp $ */ - -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.4 (Berkeley) 6/16/94 - */ - -BUFHEAD *__add_ovflpage(HTAB *, BUFHEAD *); -int __addel(HTAB *, BUFHEAD *, const DBT *, const DBT *); -int __big_delete(HTAB *, BUFHEAD *); -int __big_insert(HTAB *, BUFHEAD *, const DBT *, const DBT *); -int __big_keydata(HTAB *, BUFHEAD *, DBT *, DBT *, int); -int __big_return(HTAB *, BUFHEAD *, int, DBT *, int); -int __big_split(HTAB *, BUFHEAD *, BUFHEAD *, BUFHEAD *, - int, uint32_t, SPLIT_RETURN *); -int __buf_free(HTAB *, int, int); -void __buf_init(HTAB *, u_int); -uint32_t __call_hash(HTAB *, char *, int); -int __delpair(HTAB *, BUFHEAD *, int); -int __expand_table(HTAB *); -int __find_bigpair(HTAB *, BUFHEAD *, int, char *, int); -uint16_t __find_last_page(HTAB *, BUFHEAD **); -void __free_ovflpage(HTAB *, BUFHEAD *); -BUFHEAD *__get_buf(HTAB *, uint32_t, BUFHEAD *, int); -int __get_page(HTAB *, char *, uint32_t, int, int, int); -int __ibitmap(HTAB *, int, int, int); -uint32_t __log2(uint32_t); -int __put_page(HTAB *, char *, uint32_t, int, int); -void __reclaim_buf(HTAB *, BUFHEAD *); -int __split_page(HTAB *, uint32_t, uint32_t); - -/* Default hash routine. */ -extern uint32_t (*__default_hash)(const void *, size_t); - -#ifdef HASH_STATISTICS -extern int hash_accesses, hash_collisions, hash_expansions, hash_overflows; -#endif diff --git a/lib/libc/db/hash/hash.c b/lib/libc/db/hash/hash.c deleted file mode 100644 index e0cb4f60d..000000000 --- a/lib/libc/db/hash/hash.c +++ /dev/null @@ -1,1005 +0,0 @@ -/* $NetBSD: hash.c,v 1.35 2015/06/22 21:16:02 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: hash.c,v 1.35 2015/06/22 21:16:02 christos Exp $"); - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static int alloc_segs(HTAB *, int); -static int flush_meta(HTAB *); -static int hash_access(HTAB *, ACTION, DBT *, DBT *); -static int hash_close(DB *); -static int hash_delete(const DB *, const DBT *, uint32_t); -static int hash_fd(const DB *); -static int hash_get(const DB *, const DBT *, DBT *, uint32_t); -static int hash_put(const DB *, DBT *, const DBT *, uint32_t); -static void *hash_realloc(SEGMENT **, size_t, size_t); -static int hash_seq(const DB *, DBT *, DBT *, uint32_t); -static int hash_sync(const DB *, uint32_t); -static int hdestroy(HTAB *); -static HTAB *init_hash(HTAB *, const char *, const HASHINFO *); -static int init_htab(HTAB *, size_t); -#if BYTE_ORDER == LITTLE_ENDIAN -static void swap_header(HTAB *); -static void swap_header_copy(HASHHDR *, HASHHDR *); -#endif - -/* Fast arithmetic, relying on powers of 2, */ -#define MOD(x, y) ((x) & ((y) - 1)) - -#define RETURN_ERROR(ERR, LOC) { save_errno = ERR; goto LOC; } - -/* Return values */ -#define SUCCESS (0) -#define ERROR (-1) -#define ABNORMAL (1) - -#ifdef HASH_STATISTICS -int hash_accesses, hash_collisions, hash_expansions, hash_overflows; -#endif - -/************************** INTERFACE ROUTINES ***************************/ -/* OPEN/CLOSE */ - -/* ARGSUSED */ -DB * -__hash_open(const char *file, int flags, mode_t mode, const HASHINFO *info, - int dflags) -{ - HTAB *hashp; - struct stat statbuf; - DB *dbp; - int bpages, new_table, nsegs, save_errno; - ssize_t hdrsize; - - if ((flags & O_ACCMODE) == O_WRONLY) { - errno = EINVAL; - return (NULL); - } - - if (!(hashp = calloc(1, sizeof(HTAB)))) - return (NULL); - hashp->fp = -1; - - /* - * Even if user wants write only, we need to be able to read - * the actual file, so we need to open it read/write. But, the - * field in the hashp structure needs to be accurate so that - * we can check accesses. - */ - hashp->flags = flags; - - new_table = 0; - if (!file || (flags & O_TRUNC) || - (stat(file, &statbuf) && (errno == ENOENT))) { - if (errno == ENOENT) - errno = 0; /* Just in case someone looks at errno */ - new_table = 1; - } - if (file) { - if ((hashp->fp = __dbopen(file, flags, mode, &statbuf)) == -1) - RETURN_ERROR(errno, error0); - new_table |= statbuf.st_size == 0; - } - if (new_table) { - if (!(hashp = init_hash(hashp, file, info))) - RETURN_ERROR(errno, error1); - } else { - /* Table already exists */ - if (info && info->hash) - hashp->hash = info->hash; - else - hashp->hash = __default_hash; - - hdrsize = read(hashp->fp, &hashp->hdr, sizeof(HASHHDR)); -#if BYTE_ORDER == LITTLE_ENDIAN - swap_header(hashp); -#endif - if (hdrsize == -1) - RETURN_ERROR(errno, error1); - if (hdrsize != sizeof(HASHHDR)) - RETURN_ERROR(EFTYPE, error1); - /* Verify file type, versions and hash function */ - if (hashp->MAGIC != HASHMAGIC) - RETURN_ERROR(EFTYPE, error1); -#define OLDHASHVERSION 1 - if (hashp->VERSION != HASHVERSION && - hashp->VERSION != OLDHASHVERSION) - RETURN_ERROR(EFTYPE, error1); - if (hashp->hash(CHARKEY, sizeof(CHARKEY)) != - (uint32_t)hashp->H_CHARKEY) - RETURN_ERROR(EFTYPE, error1); - /* - * Figure out how many segments we need. Max_Bucket is the - * maximum bucket number, so the number of buckets is - * max_bucket + 1. - */ - nsegs = (hashp->MAX_BUCKET + 1 + hashp->SGSIZE - 1) / - hashp->SGSIZE; - hashp->nsegs = 0; - if (alloc_segs(hashp, nsegs)) - /* - * If alloc_segs fails, table will have been destroyed - * and errno will have been set. - */ - return (NULL); - /* Read in bitmaps */ - bpages = (hashp->SPARES[hashp->OVFL_POINT] + - (unsigned int)(hashp->BSIZE << BYTE_SHIFT) - 1) >> - (hashp->BSHIFT + BYTE_SHIFT); - - hashp->nmaps = bpages; - (void)memset(&hashp->mapp[0], 0, bpages * sizeof(uint32_t *)); - } - - /* Initialize Buffer Manager */ - if (info && info->cachesize) - __buf_init(hashp, info->cachesize); - else - __buf_init(hashp, DEF_BUFSIZE); - - hashp->new_file = new_table; - hashp->save_file = file && (hashp->flags & O_RDWR); - hashp->cbucket = -1; - if (!(dbp = malloc(sizeof(*dbp)))) { - save_errno = errno; - hdestroy(hashp); - errno = save_errno; - return (NULL); - } - dbp->internal = hashp; - dbp->close = hash_close; - dbp->del = hash_delete; - dbp->fd = hash_fd; - dbp->get = hash_get; - dbp->put = hash_put; - dbp->seq = hash_seq; - dbp->sync = hash_sync; - dbp->type = DB_HASH; - -#ifdef DEBUG1 - (void)fprintf(stderr, -"%s\n%s%p\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%d\n%s%x\n%s%x\n%s%d\n%s%d\n", - "init_htab:", - "TABLE POINTER ", hashp, - "BUCKET SIZE ", hashp->BSIZE, - "BUCKET SHIFT ", hashp->BSHIFT, - "DIRECTORY SIZE ", hashp->DSIZE, - "SEGMENT SIZE ", hashp->SGSIZE, - "SEGMENT SHIFT ", hashp->SSHIFT, - "FILL FACTOR ", hashp->FFACTOR, - "MAX BUCKET ", hashp->MAX_BUCKET, - "OVFL POINT ", hashp->OVFL_POINT, - "LAST FREED ", hashp->LAST_FREED, - "HIGH MASK ", hashp->HIGH_MASK, - "LOW MASK ", hashp->LOW_MASK, - "NSEGS ", hashp->nsegs, - "NKEYS ", hashp->NKEYS); -#endif -#ifdef HASH_STATISTICS - hash_overflows = hash_accesses = hash_collisions = hash_expansions = 0; -#endif - return (dbp); - -error1: - if (hashp != NULL) - (void)close(hashp->fp); - -error0: - free(hashp); - errno = save_errno; - return (NULL); -} - -static int -hash_close(DB *dbp) -{ - HTAB *hashp; - int retval; - - if (!dbp) - return (ERROR); - - hashp = dbp->internal; - retval = hdestroy(hashp); - free(dbp); - return (retval); -} - -static int -hash_fd(const DB *dbp) -{ - HTAB *hashp; - - if (!dbp) - return (ERROR); - - hashp = dbp->internal; - if (hashp->fp == -1) { - errno = ENOENT; - return (-1); - } - return (hashp->fp); -} - -/************************** LOCAL CREATION ROUTINES **********************/ -static HTAB * -init_hash(HTAB *hashp, const char *file, const HASHINFO *info) -{ - struct stat statbuf; - int nelem; - - nelem = 1; - hashp->NKEYS = 0; - hashp->LORDER = BYTE_ORDER; - hashp->BSIZE = DEF_BUCKET_SIZE; - hashp->BSHIFT = DEF_BUCKET_SHIFT; - hashp->SGSIZE = DEF_SEGSIZE; - hashp->SSHIFT = DEF_SEGSIZE_SHIFT; - hashp->DSIZE = DEF_DIRSIZE; - hashp->FFACTOR = DEF_FFACTOR; - hashp->hash = __default_hash; - memset(hashp->SPARES, 0, sizeof(hashp->SPARES)); - memset(hashp->BITMAPS, 0, sizeof (hashp->BITMAPS)); - - /* Fix bucket size to be optimal for file system */ - if (file != NULL) { - if (stat(file, &statbuf)) - return (NULL); - hashp->BSIZE = MIN(statbuf.st_blksize, MAX_BSIZE); - hashp->BSHIFT = __log2((uint32_t)hashp->BSIZE); - } - - if (info) { - if (info->bsize) { - /* Round pagesize up to power of 2 */ - hashp->BSHIFT = __log2(info->bsize); - hashp->BSIZE = 1 << hashp->BSHIFT; - if (hashp->BSIZE > MAX_BSIZE) { - errno = EINVAL; - return (NULL); - } - } - if (info->ffactor) - hashp->FFACTOR = info->ffactor; - if (info->hash) - hashp->hash = info->hash; - if (info->nelem) - nelem = info->nelem; - if (info->lorder) { - if (info->lorder != BIG_ENDIAN && - info->lorder != LITTLE_ENDIAN) { - errno = EINVAL; - return (NULL); - } - hashp->LORDER = info->lorder; - } - } - /* init_htab should destroy the table and set errno if it fails */ - if (init_htab(hashp, (size_t)nelem)) - return (NULL); - else - return (hashp); -} -/* - * This calls alloc_segs which may run out of memory. Alloc_segs will destroy - * the table and set errno, so we just pass the error information along. - * - * Returns 0 on No Error - */ -static int -init_htab(HTAB *hashp, size_t nelem) -{ - int nbuckets; - uint32_t nsegs; - int l2; - - /* - * Divide number of elements by the fill factor and determine a - * desired number of buckets. Allocate space for the next greater - * power of two number of buckets. - */ - nelem = (nelem - 1) / hashp->FFACTOR + 1; - - _DBFIT(nelem, uint32_t); - l2 = __log2(MAX((uint32_t)nelem, 2)); - nbuckets = 1 << l2; - - hashp->SPARES[l2] = l2 + 1; - hashp->SPARES[l2 + 1] = l2 + 1; - hashp->OVFL_POINT = l2; - hashp->LAST_FREED = 2; - - /* First bitmap page is at: splitpoint l2 page offset 1 */ - if (__ibitmap(hashp, (int)OADDR_OF(l2, 1), l2 + 1, 0)) - return (-1); - - hashp->MAX_BUCKET = hashp->LOW_MASK = nbuckets - 1; - hashp->HIGH_MASK = (nbuckets << 1) - 1; - /* LINTED constant in conditional context */ - hashp->HDRPAGES = ((MAX(sizeof(HASHHDR), MINHDRSIZE) - 1) >> - hashp->BSHIFT) + 1; - - nsegs = (nbuckets - 1) / hashp->SGSIZE + 1; - nsegs = 1 << __log2(nsegs); - - if (nsegs > (uint32_t)hashp->DSIZE) - hashp->DSIZE = nsegs; - return (alloc_segs(hashp, (int)nsegs)); -} - -/********************** DESTROY/CLOSE ROUTINES ************************/ - -/* - * Flushes any changes to the file if necessary and destroys the hashp - * structure, freeing all allocated space. - */ -static int -hdestroy(HTAB *hashp) -{ - int i, save_errno; - - save_errno = 0; - -#ifdef HASH_STATISTICS - (void)fprintf(stderr, "hdestroy: accesses %d collisions %d\n", - hash_accesses, hash_collisions); - (void)fprintf(stderr, "hdestroy: expansions %d\n", - hash_expansions); - (void)fprintf(stderr, "hdestroy: overflows %d\n", - hash_overflows); - (void)fprintf(stderr, "keys %d maxp %d segmentcount %d\n", - hashp->NKEYS, hashp->MAX_BUCKET, hashp->nsegs); - - for (i = 0; i < NCACHED; i++) - (void)fprintf(stderr, - "spares[%d] = %d\n", i, hashp->SPARES[i]); -#endif - /* - * Call on buffer manager to free buffers, and if required, - * write them to disk. - */ - if (__buf_free(hashp, 1, hashp->save_file)) - save_errno = errno; - if (hashp->dir) { - free(*hashp->dir); /* Free initial segments */ - /* Free extra segments */ - while (hashp->exsegs--) - free(hashp->dir[--hashp->nsegs]); - free(hashp->dir); - } - if (flush_meta(hashp) && !save_errno) - save_errno = errno; - /* Free Bigmaps */ - for (i = 0; i < hashp->nmaps; i++) - if (hashp->mapp[i]) - free(hashp->mapp[i]); - - if (hashp->fp != -1) - (void)close(hashp->fp); - - free(hashp); - - if (save_errno) { - errno = save_errno; - return (ERROR); - } - return (SUCCESS); -} -/* - * Write modified pages to disk - * - * Returns: - * 0 == OK - * -1 ERROR - */ -static int -hash_sync(const DB *dbp, uint32_t flags) -{ - HTAB *hashp; - - if (flags != 0) { - errno = EINVAL; - return (ERROR); - } - - if (!dbp) - return (ERROR); - - hashp = dbp->internal; - if (!hashp->save_file) - return (0); - if (__buf_free(hashp, 0, 1) || flush_meta(hashp)) - return (ERROR); - hashp->new_file = 0; - return (0); -} - -/* - * Returns: - * 0 == OK - * -1 indicates that errno should be set - */ -static int -flush_meta(HTAB *hashp) -{ - HASHHDR *whdrp; -#if BYTE_ORDER == LITTLE_ENDIAN - HASHHDR whdr; -#endif - int fp, i; - ssize_t wsize; - - if (!hashp->save_file) - return (0); - hashp->MAGIC = HASHMAGIC; - hashp->VERSION = HASHVERSION; - hashp->H_CHARKEY = hashp->hash(CHARKEY, sizeof(CHARKEY)); - - fp = hashp->fp; - whdrp = &hashp->hdr; -#if BYTE_ORDER == LITTLE_ENDIAN - whdrp = &whdr; - swap_header_copy(&hashp->hdr, whdrp); -#endif - if ((wsize = pwrite(fp, whdrp, sizeof(HASHHDR), (off_t)0)) == -1) - return (-1); - else - if (wsize != sizeof(HASHHDR)) { - errno = EFTYPE; - hashp->err = errno; - return (-1); - } - for (i = 0; i < NCACHED; i++) - if (hashp->mapp[i]) - if (__put_page(hashp, (char *)(void *)hashp->mapp[i], - (u_int)hashp->BITMAPS[i], 0, 1)) - return (-1); - return (0); -} - -/*******************************SEARCH ROUTINES *****************************/ -/* - * All the access routines return - * - * Returns: - * 0 on SUCCESS - * 1 to indicate an external ERROR (i.e. key not found, etc) - * -1 to indicate an internal ERROR (i.e. out of memory, etc) - */ -static int -hash_get(const DB *dbp, const DBT *key, DBT *data, uint32_t flag) -{ - HTAB *hashp; - - hashp = dbp->internal; - if (flag) { - hashp->err = errno = EINVAL; - return (ERROR); - } - return (hash_access(hashp, HASH_GET, __UNCONST(key), data)); -} - -static int -hash_put(const DB *dbp, DBT *key, const DBT *data, uint32_t flag) -{ - HTAB *hashp; - - hashp = dbp->internal; - if (flag && flag != R_NOOVERWRITE) { - hashp->err = errno = EINVAL; - return (ERROR); - } - if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->err = errno = EPERM; - return (ERROR); - } - /* LINTED const castaway */ - return (hash_access(hashp, flag == R_NOOVERWRITE ? - HASH_PUTNEW : HASH_PUT, __UNCONST(key), __UNCONST(data))); -} - -static int -hash_delete(const DB *dbp, const DBT *key, uint32_t flag) -{ - HTAB *hashp; - - hashp = dbp->internal; - if (flag && flag != R_CURSOR) { - hashp->err = errno = EINVAL; - return (ERROR); - } - if ((hashp->flags & O_ACCMODE) == O_RDONLY) { - hashp->err = errno = EPERM; - return (ERROR); - } - return hash_access(hashp, HASH_DELETE, __UNCONST(key), NULL); -} - -/* - * Assume that hashp has been set in wrapper routine. - */ -static int -hash_access(HTAB *hashp, ACTION action, DBT *key, DBT *val) -{ - BUFHEAD *rbufp; - BUFHEAD *bufp, *save_bufp; - uint16_t *bp; - int n, ndx, off; - size_t size; - char *kp; - uint16_t pageno; - -#ifdef HASH_STATISTICS - hash_accesses++; -#endif - - off = hashp->BSIZE; - size = key->size; - kp = (char *)key->data; - rbufp = __get_buf(hashp, __call_hash(hashp, kp, (int)size), NULL, 0); - if (!rbufp) - return (ERROR); - save_bufp = rbufp; - - /* Pin the bucket chain */ - rbufp->flags |= BUF_PIN; - for (bp = (uint16_t *)(void *)rbufp->page, n = *bp++, ndx = 1; ndx < n;) - if (bp[1] >= REAL_KEY) { - /* Real key/data pair */ - if (size == (size_t)(off - *bp) && - memcmp(kp, rbufp->page + *bp, size) == 0) - goto found; - off = bp[1]; -#ifdef HASH_STATISTICS - hash_collisions++; -#endif - bp += 2; - ndx += 2; - } else if (bp[1] == OVFLPAGE) { - rbufp = __get_buf(hashp, (uint32_t)*bp, rbufp, 0); - if (!rbufp) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - /* FOR LOOP INIT */ - bp = (uint16_t *)(void *)rbufp->page; - n = *bp++; - ndx = 1; - off = hashp->BSIZE; - } else if (bp[1] < REAL_KEY) { - if ((ndx = - __find_bigpair(hashp, rbufp, ndx, kp, (int)size)) > 0) - goto found; - if (ndx == -2) { - bufp = rbufp; - if (!(pageno = - __find_last_page(hashp, &bufp))) { - ndx = 0; - rbufp = bufp; - break; /* FOR */ - } - rbufp = __get_buf(hashp, (uint32_t)pageno, - bufp, 0); - if (!rbufp) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - /* FOR LOOP INIT */ - bp = (uint16_t *)(void *)rbufp->page; - n = *bp++; - ndx = 1; - off = hashp->BSIZE; - } else { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - } - - /* Not found */ - switch (action) { - case HASH_PUT: - case HASH_PUTNEW: - if (__addel(hashp, rbufp, key, val)) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } else { - save_bufp->flags &= ~BUF_PIN; - return (SUCCESS); - } - case HASH_GET: - case HASH_DELETE: - default: - save_bufp->flags &= ~BUF_PIN; - return (ABNORMAL); - } - -found: - switch (action) { - case HASH_PUTNEW: - save_bufp->flags &= ~BUF_PIN; - return (ABNORMAL); - case HASH_GET: - bp = (uint16_t *)(void *)rbufp->page; - if (bp[ndx + 1] < REAL_KEY) { - if (__big_return(hashp, rbufp, ndx, val, 0)) - return (ERROR); - } else { - val->data = (uint8_t *)rbufp->page + (int)bp[ndx + 1]; - val->size = bp[ndx] - bp[ndx + 1]; - } - break; - case HASH_PUT: - if ((__delpair(hashp, rbufp, ndx)) || - (__addel(hashp, rbufp, key, val))) { - save_bufp->flags &= ~BUF_PIN; - return (ERROR); - } - break; - case HASH_DELETE: - if (__delpair(hashp, rbufp, ndx)) - return (ERROR); - /* - * Our index lags 2 behind on the same page when we are - * deleting the element pointed to by the index; otherwise - * deleting randomly from an iterated hash produces undefined - * results. - */ - if (ndx != hashp->cndx - 2 || rbufp != hashp->cpage) - break; - - if (hashp->cndx > 1) { - /* Move back one element */ - hashp->cndx -= 2; - } else { - /* - * Move back one page, and indicate to go to the last - * element of the previous page by setting cndx to -1 - */ - hashp->cbucket--; - hashp->cpage = NULL; - hashp->cndx = -1; - } - break; - default: - abort(); - } - save_bufp->flags &= ~BUF_PIN; - return (SUCCESS); -} - -static int -hash_seq(const DB *dbp, DBT *key, DBT *data, uint32_t flag) -{ - uint32_t bucket; - BUFHEAD *bufp = NULL; /* XXX: gcc */ - HTAB *hashp; - uint16_t *bp, ndx; - - hashp = dbp->internal; - if (flag && flag != R_FIRST && flag != R_NEXT) { - hashp->err = errno = EINVAL; - return (ERROR); - } -#ifdef HASH_STATISTICS - hash_accesses++; -#endif - if ((hashp->cbucket < 0) || (flag == R_FIRST)) { - hashp->cbucket = 0; - hashp->cndx = 1; - hashp->cpage = NULL; - } - -next_bucket: - for (bp = NULL; !bp || !bp[0]; ) { - if (!(bufp = hashp->cpage)) { - for (bucket = hashp->cbucket; - bucket <= (uint32_t)hashp->MAX_BUCKET; - bucket++) { - bufp = __get_buf(hashp, bucket, NULL, 0); - if (!bufp) - return (ERROR); - hashp->cpage = bufp; - bp = (uint16_t *)(void *)bufp->page; - if (bp[0]) - break; - } - hashp->cbucket = bucket; - if (hashp->cbucket > hashp->MAX_BUCKET) { - hashp->cbucket = -1; - return (ABNORMAL); - } - if (hashp->cndx == -1) { - /* move to the last element of the page */ - hashp->cndx = 1; - while (bp[hashp->cndx - 1] != 0) - hashp->cndx += 2; - } else { - /* start on the first element */ - hashp->cndx = 1; - } - } else { - bp = (uint16_t *)(void *)hashp->cpage->page; - if (flag == R_NEXT || flag == 0) { - if (hashp->cndx > bp[0]) { - hashp->cpage = NULL; - hashp->cbucket++; - hashp->cndx = 1; - goto next_bucket; - } - } - } - - - _DIAGASSERT(bp != NULL); - _DIAGASSERT(bufp != NULL); - while (bp[hashp->cndx + 1] == OVFLPAGE) { - bufp = hashp->cpage = - __get_buf(hashp, (uint32_t)bp[hashp->cndx], bufp, - 0); - if (!bufp) - return (ERROR); - bp = (uint16_t *)(void *)(bufp->page); - hashp->cndx = 1; - } - if (!bp[0]) { - hashp->cpage = NULL; - ++hashp->cbucket; - } - } - ndx = hashp->cndx; - if (bp[ndx + 1] < REAL_KEY) { - if (__big_keydata(hashp, bufp, key, data, 1)) - return (ERROR); - } else { - if (hashp->cpage == NULL) - return (ERROR); - key->data = (uint8_t *)hashp->cpage->page + bp[ndx]; - key->size = (ndx > 1 ? bp[ndx - 1] : hashp->BSIZE) - bp[ndx]; - data->data = (uint8_t *)hashp->cpage->page + bp[ndx + 1]; - data->size = bp[ndx] - bp[ndx + 1]; - } - hashp->cndx += 2; - return (SUCCESS); -} - -/********************************* UTILITIES ************************/ - -/* - * Returns: - * 0 ==> OK - * -1 ==> Error - */ -int -__expand_table(HTAB *hashp) -{ - uint32_t old_bucket, new_bucket; - int new_segnum, spare_ndx; - size_t dirsize; - -#ifdef HASH_STATISTICS - hash_expansions++; -#endif - new_bucket = ++hashp->MAX_BUCKET; - old_bucket = (hashp->MAX_BUCKET & hashp->LOW_MASK); - - new_segnum = new_bucket >> hashp->SSHIFT; - - /* Check if we need a new segment */ - if (new_segnum >= hashp->nsegs) { - /* Check if we need to expand directory */ - if (new_segnum >= hashp->DSIZE) { - /* Reallocate directory */ - dirsize = hashp->DSIZE * sizeof(SEGMENT *); - if (!hash_realloc(&hashp->dir, dirsize, dirsize << 1)) - return (-1); - dirsize <<= 1; - _DBFIT(dirsize, uint32_t); - hashp->DSIZE = (uint32_t)dirsize; - } - if ((hashp->dir[new_segnum] = - calloc((size_t)hashp->SGSIZE, sizeof(SEGMENT))) == NULL) - return (-1); - hashp->exsegs++; - hashp->nsegs++; - } - /* - * If the split point is increasing (MAX_BUCKET's log base 2 - * * increases), we need to copy the current contents of the spare - * split bucket to the next bucket. - */ - spare_ndx = __log2((uint32_t)(hashp->MAX_BUCKET + 1)); - if (spare_ndx > hashp->OVFL_POINT) { - hashp->SPARES[spare_ndx] = hashp->SPARES[hashp->OVFL_POINT]; - hashp->OVFL_POINT = spare_ndx; - } - - if (new_bucket > (uint32_t)hashp->HIGH_MASK) { - /* Starting a new doubling */ - hashp->LOW_MASK = hashp->HIGH_MASK; - hashp->HIGH_MASK = new_bucket | hashp->LOW_MASK; - } - /* Relocate records to the new bucket */ - return (__split_page(hashp, old_bucket, new_bucket)); -} - -/* - * If realloc guarantees that the pointer is not destroyed if the realloc - * fails, then this routine can go away. - */ -static void * -hash_realloc(SEGMENT **p_ptr, size_t oldsize, size_t newsize) -{ - void *p; - - if ((p = malloc(newsize)) != NULL) { - memmove(p, *p_ptr, oldsize); - memset((char *)p + oldsize, 0, newsize - oldsize); - free(*p_ptr); - *p_ptr = p; - } - return (p); -} - -uint32_t -__call_hash(HTAB *hashp, char *k, int len) -{ - int n, bucket; - - n = hashp->hash(k, (size_t)len); - bucket = n & hashp->HIGH_MASK; - if (bucket > hashp->MAX_BUCKET) - bucket = bucket & hashp->LOW_MASK; - return (bucket); -} - -/* - * Allocate segment table. On error, destroy the table and set errno. - * - * Returns 0 on success - */ -static int -alloc_segs(HTAB *hashp, int nsegs) -{ - int i; - SEGMENT store; - - int save_errno; - - hashp->dir = calloc((size_t)hashp->DSIZE, sizeof(SEGMENT *)); - if (hashp->dir == NULL) { - save_errno = errno; - (void)hdestroy(hashp); - errno = save_errno; - return (-1); - } - hashp->nsegs = nsegs; - if (nsegs == 0) - return 0; - /* Allocate segments */ - store = calloc((size_t)(nsegs << hashp->SSHIFT), sizeof(SEGMENT)); - if (store == NULL) { - save_errno = errno; - (void)hdestroy(hashp); - errno = save_errno; - return (-1); - } - for (i = 0; i < nsegs; i++) - hashp->dir[i] = &store[i << hashp->SSHIFT]; - return (0); -} - -#if BYTE_ORDER == LITTLE_ENDIAN -/* - * Hashp->hdr needs to be byteswapped. - */ -static void -swap_header_copy(HASHHDR *srcp, HASHHDR *destp) -{ - size_t i; - - P_32_COPY(srcp->magic, destp->magic); - P_32_COPY(srcp->version, destp->version); - P_32_COPY(srcp->lorder, destp->lorder); - P_32_COPY(srcp->bsize, destp->bsize); - P_32_COPY(srcp->bshift, destp->bshift); - P_32_COPY(srcp->dsize, destp->dsize); - P_32_COPY(srcp->ssize, destp->ssize); - P_32_COPY(srcp->sshift, destp->sshift); - P_32_COPY(srcp->ovfl_point, destp->ovfl_point); - P_32_COPY(srcp->last_freed, destp->last_freed); - P_32_COPY(srcp->max_bucket, destp->max_bucket); - P_32_COPY(srcp->high_mask, destp->high_mask); - P_32_COPY(srcp->low_mask, destp->low_mask); - P_32_COPY(srcp->ffactor, destp->ffactor); - P_32_COPY(srcp->nkeys, destp->nkeys); - P_32_COPY(srcp->hdrpages, destp->hdrpages); - P_32_COPY(srcp->h_charkey, destp->h_charkey); - for (i = 0; i < NCACHED; i++) { - P_32_COPY(srcp->spares[i], destp->spares[i]); - P_16_COPY(srcp->bitmaps[i], destp->bitmaps[i]); - } -} - -static void -swap_header(HTAB *hashp) -{ - HASHHDR *hdrp; - size_t i; - - hdrp = &hashp->hdr; - - M_32_SWAP(hdrp->magic); - M_32_SWAP(hdrp->version); - M_32_SWAP(hdrp->lorder); - M_32_SWAP(hdrp->bsize); - M_32_SWAP(hdrp->bshift); - M_32_SWAP(hdrp->dsize); - M_32_SWAP(hdrp->ssize); - M_32_SWAP(hdrp->sshift); - M_32_SWAP(hdrp->ovfl_point); - M_32_SWAP(hdrp->last_freed); - M_32_SWAP(hdrp->max_bucket); - M_32_SWAP(hdrp->high_mask); - M_32_SWAP(hdrp->low_mask); - M_32_SWAP(hdrp->ffactor); - M_32_SWAP(hdrp->nkeys); - M_32_SWAP(hdrp->hdrpages); - M_32_SWAP(hdrp->h_charkey); - for (i = 0; i < NCACHED; i++) { - M_32_SWAP(hdrp->spares[i]); - M_16_SWAP(hdrp->bitmaps[i]); - } -} -#endif diff --git a/lib/libc/db/hash/hash.h b/lib/libc/db/hash/hash.h deleted file mode 100644 index f3c87a86e..000000000 --- a/lib/libc/db/hash/hash.h +++ /dev/null @@ -1,295 +0,0 @@ -/* $NetBSD: hash.h,v 1.15 2008/08/26 21:18:38 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - * - * @(#)hash.h 8.3 (Berkeley) 5/31/94 - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -/* Operations */ -typedef enum { - HASH_GET, HASH_PUT, HASH_PUTNEW, HASH_DELETE, HASH_FIRST, HASH_NEXT -} ACTION; - -/* Buffer Management structures */ -typedef struct _bufhead BUFHEAD; - -struct _bufhead { - BUFHEAD *prev; /* LRU links */ - BUFHEAD *next; /* LRU links */ - BUFHEAD *ovfl; /* Overflow page buffer header */ - uint32_t addr; /* Address of this page */ - char *page; /* Actual page data */ - char flags; -#define BUF_MOD 0x0001 -#define BUF_DISK 0x0002 -#define BUF_BUCKET 0x0004 -#define BUF_PIN 0x0008 -}; - -#define IS_BUCKET(X) ((X) & BUF_BUCKET) - -typedef BUFHEAD **SEGMENT; - -/* Hash Table Information */ -typedef struct hashhdr { /* Disk resident portion */ - int32_t magic; /* Magic NO for hash tables */ - int32_t version; /* Version ID */ - uint32_t lorder; /* Byte Order */ - int32_t bsize; /* Bucket/Page Size */ - int32_t bshift; /* Bucket shift */ - int32_t dsize; /* Directory Size */ - int32_t ssize; /* Segment Size */ - int32_t sshift; /* Segment shift */ - int32_t ovfl_point; /* Where overflow pages are being - * allocated */ - int32_t last_freed; /* Last overflow page freed */ - int32_t max_bucket; /* ID of Maximum bucket in use */ - int32_t high_mask; /* Mask to modulo into entire table */ - int32_t low_mask; /* Mask to modulo into lower half of - * table */ - int32_t ffactor; /* Fill factor */ - int32_t nkeys; /* Number of keys in hash table */ - int32_t hdrpages; /* Size of table header */ - int32_t h_charkey; /* value of hash(CHARKEY) */ -#define NCACHED 32 /* number of bit maps and spare - * points */ - int32_t spares[NCACHED];/* spare pages for overflow */ - uint16_t bitmaps[NCACHED]; /* address of overflow page - * bitmaps */ -} HASHHDR; - -typedef struct htab { /* Memory resident data structure */ - HASHHDR hdr; /* Header */ - int nsegs; /* Number of allocated segments */ - int exsegs; /* Number of extra allocated - * segments */ - uint32_t (*hash)(const void *, size_t); /* Hash function */ - int flags; /* Flag values */ - int fp; /* File pointer */ - char *tmp_buf; /* Temporary Buffer for BIG data */ - char *tmp_key; /* Temporary Buffer for BIG keys */ - BUFHEAD *cpage; /* Current page */ - int cbucket; /* Current bucket */ - int cndx; /* Index of next item on cpage */ - int err; /* Error Number -- for DBM - * compatibility */ - int new_file; /* Indicates if fd is backing store - * or no */ - int save_file; /* Indicates whether we need to flush - * file at - * exit */ - uint32_t *mapp[NCACHED]; /* Pointers to page maps */ - int nmaps; /* Initial number of bitmaps */ - int nbufs; /* Number of buffers left to - * allocate */ - BUFHEAD bufhead; /* Header of buffer lru list */ - SEGMENT *dir; /* Hash Bucket directory */ -} HTAB; - -/* - * Constants - */ -#define MAX_BSIZE 65536 /* 2^16 */ -#define MIN_BUFFERS 6 -#define MINHDRSIZE 512 -#define DEF_BUFSIZE 65536 /* 64 K */ -#define DEF_BUCKET_SIZE 4096 -#define DEF_BUCKET_SHIFT 12 /* log2(BUCKET) */ -#define DEF_SEGSIZE 256 -#define DEF_SEGSIZE_SHIFT 8 /* log2(SEGSIZE) */ -#define DEF_DIRSIZE 256 -#define DEF_FFACTOR 65536 -#define MIN_FFACTOR 4 -#define SPLTMAX 8 -#define CHARKEY "%$sniglet^&" -#define NUMKEY 1038583 -#define BYTE_SHIFT 3 -#define INT_TO_BYTE 2 -#define INT_BYTE_SHIFT 5 -#define ALL_SET ((uint32_t)0xFFFFFFFF) -#define ALL_CLEAR 0 - -#define PTROF(X) ((BUFHEAD *)(void *)((u_long)(X)&~0x3)) -#define ISMOD(X) ((uint32_t)(u_long)(X)&0x1) -#define DOMOD(X) ((X) = (char *)(void *)((u_long)(X)|0x1)) -#define ISDISK(X) ((uint32_t)(u_long)(X)&0x2) -#define DODISK(X) ((X) = (char *)(void *)((u_long)(X)|0x2)) - -#define BITS_PER_MAP 32 - -/* Given the address of the beginning of a big map, clear/set the nth bit */ -#define CLRBIT(A, N) ((A)[(N)/BITS_PER_MAP] &= ~(1<<((N)%BITS_PER_MAP))) -#define SETBIT(A, N) ((A)[(N)/BITS_PER_MAP] |= (1<<((N)%BITS_PER_MAP))) -#define ISSET(A, N) ((A)[(N)/BITS_PER_MAP] & (1<<((N)%BITS_PER_MAP))) - -/* Overflow management */ -/* - * Overflow page numbers are allocated per split point. At each doubling of - * the table, we can allocate extra pages. So, an overflow page number has - * the top 5 bits indicate which split point and the lower 11 bits indicate - * which page at that split point is indicated (pages within split points are - * numberered starting with 1). - */ - -#define SPLITSHIFT 11 -#define SPLITMASK 0x7FF -#define SPLITNUM(N) (((uint32_t)(N)) >> SPLITSHIFT) -#define OPAGENUM(N) ((N) & SPLITMASK) -#define OADDR_OF(S,O) ((uint32_t)((uint32_t)(S) << SPLITSHIFT) + (O)) - -#define BUCKET_TO_PAGE(B) \ - (B) + hashp->HDRPAGES + \ - ((B) ? hashp->SPARES[__log2((uint32_t)((B)+1))-1] : 0) -#define OADDR_TO_PAGE(B) \ - BUCKET_TO_PAGE ( (1 << SPLITNUM((B))) -1 ) + OPAGENUM((B)); - -/* - * page.h contains a detailed description of the page format. - * - * Normally, keys and data are accessed from offset tables in the top of - * each page which point to the beginning of the key and data. There are - * four flag values which may be stored in these offset tables which indicate - * the following: - * - * - * OVFLPAGE Rather than a key data pair, this pair contains - * the address of an overflow page. The format of - * the pair is: - * OVERFLOW_PAGE_NUMBER OVFLPAGE - * - * PARTIAL_KEY This must be the first key/data pair on a page - * and implies that page contains only a partial key. - * That is, the key is too big to fit on a single page - * so it starts on this page and continues on the next. - * The format of the page is: - * KEY_OFF PARTIAL_KEY OVFL_PAGENO OVFLPAGE - * - * KEY_OFF -- offset of the beginning of the key - * PARTIAL_KEY -- 1 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * FULL_KEY This must be the first key/data pair on the page. It - * is used in two cases. - * - * Case 1: - * There is a complete key on the page but no data - * (because it wouldn't fit). The next page contains - * the data. - * - * Page format it: - * KEY_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE - * - * KEY_OFF -- offset of the beginning of the key - * FULL_KEY -- 2 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * Case 2: - * This page contains no key, but part of a large - * data field, which is continued on the next page. - * - * Page format it: - * DATA_OFF FULL_KEY OVFL_PAGENO OVFL_PAGE - * - * KEY_OFF -- offset of the beginning of the data on - * this page - * FULL_KEY -- 2 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * FULL_KEY_DATA - * This must be the first key/data pair on the page. - * There are two cases: - * - * Case 1: - * This page contains a key and the beginning of the - * data field, but the data field is continued on the - * next page. - * - * Page format is: - * KEY_OFF FULL_KEY_DATA OVFL_PAGENO DATA_OFF - * - * KEY_OFF -- offset of the beginning of the key - * FULL_KEY_DATA -- 3 - * OVFL_PAGENO - page number of the next overflow page - * DATA_OFF -- offset of the beginning of the data - * - * Case 2: - * This page contains the last page of a big data pair. - * There is no key, only the tail end of the data - * on this page. - * - * Page format is: - * DATA_OFF FULL_KEY_DATA - * - * DATA_OFF -- offset of the beginning of the data on - * this page - * FULL_KEY_DATA -- 3 - * OVFL_PAGENO - page number of the next overflow page - * OVFLPAGE -- 0 - * - * OVFL_PAGENO and OVFLPAGE are optional (they are - * not present if there is no next page). - */ - -#define OVFLPAGE 0 -#define PARTIAL_KEY 1 -#define FULL_KEY 2 -#define FULL_KEY_DATA 3 -#define REAL_KEY 4 - -/* Short hands for accessing structure */ -#define BSIZE hdr.bsize -#define BSHIFT hdr.bshift -#define DSIZE hdr.dsize -#define SGSIZE hdr.ssize -#define SSHIFT hdr.sshift -#define LORDER hdr.lorder -#define OVFL_POINT hdr.ovfl_point -#define LAST_FREED hdr.last_freed -#define MAX_BUCKET hdr.max_bucket -#define FFACTOR hdr.ffactor -#define HIGH_MASK hdr.high_mask -#define LOW_MASK hdr.low_mask -#define NKEYS hdr.nkeys -#define HDRPAGES hdr.hdrpages -#define SPARES hdr.spares -#define BITMAPS hdr.bitmaps -#define VERSION hdr.version -#define MAGIC hdr.magic -#define NEXT_FREE hdr.next_free -#define H_CHARKEY hdr.h_charkey diff --git a/lib/libc/db/hash/hash_bigkey.c b/lib/libc/db/hash/hash_bigkey.c deleted file mode 100644 index eba679d7f..000000000 --- a/lib/libc/db/hash/hash_bigkey.c +++ /dev/null @@ -1,680 +0,0 @@ -/* $NetBSD: hash_bigkey.c,v 1.24 2012/03/13 21:13:32 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: hash_bigkey.c,v 1.24 2012/03/13 21:13:32 christos Exp $"); - -/* - * PACKAGE: hash - * DESCRIPTION: - * Big key/data handling for the hashing package. - * - * ROUTINES: - * External - * __big_keydata - * __big_split - * __big_insert - * __big_return - * __big_delete - * __find_last_page - * Internal - * collect_key - * collect_data - */ - -#include - -#include -#include -#include -#include -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static int collect_key(HTAB *, BUFHEAD *, int, DBT *, int); -static int collect_data(HTAB *, BUFHEAD *, int, int); - -/* - * Big_insert - * - * You need to do an insert and the key/data pair is too big - * - * Returns: - * 0 ==> OK - *-1 ==> ERROR - */ -int -__big_insert(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) -{ - uint16_t *p, n; - size_t key_size, val_size; - uint16_t space, move_bytes, off; - char *cp, *key_data, *val_data; - size_t temp; - - cp = bufp->page; /* Character pointer of p. */ - p = (uint16_t *)(void *)cp; - - key_data = (char *)key->data; - _DBFIT(key->size, int); - key_size = key->size; - val_data = (char *)val->data; - _DBFIT(val->size, int); - val_size = val->size; - - /* First move the Key */ - - temp = FREESPACE(p) - BIGOVERHEAD; - _DBFIT(temp, uint16_t); - space = (uint16_t)temp; - while (key_size) { - size_t kspace = MIN(space, key_size); - _DBFIT(kspace, uint16_t); - move_bytes = (uint16_t)kspace; - off = OFFSET(p) - move_bytes; - memmove(cp + off, key_data, (size_t)move_bytes); - key_size -= move_bytes; - key_data += move_bytes; - n = p[0]; - p[++n] = off; - p[0] = ++n; - temp = off - PAGE_META(n); - _DBFIT(temp, uint16_t); - FREESPACE(p) = (uint16_t)temp; - OFFSET(p) = off; - p[n] = PARTIAL_KEY; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - n = p[0]; - if (!key_size) { - space = FREESPACE(p); - if (space) { - size_t vspace = MIN(space, val_size); - _DBFIT(vspace, uint16_t); - move_bytes = (uint16_t)vspace; - /* - * If the data would fit exactly in the - * remaining space, we must overflow it to the - * next page; otherwise the invariant that the - * data must end on a page with FREESPACE - * non-zero would fail. - */ - if (space == val_size && val_size == val->size) - goto toolarge; - off = OFFSET(p) - move_bytes; - memmove(cp + off, val_data, (size_t)move_bytes); - val_data += move_bytes; - val_size -= move_bytes; - p[n] = off; - p[n - 2] = FULL_KEY_DATA; - FREESPACE(p) = FREESPACE(p) - move_bytes; - OFFSET(p) = off; - } else { - toolarge: - p[n - 2] = FULL_KEY; - } - } - p = (uint16_t *)(void *)bufp->page; - cp = bufp->page; - bufp->flags |= BUF_MOD; - temp = FREESPACE(p) - BIGOVERHEAD; - _DBFIT(temp, uint16_t); - space = (uint16_t)temp; - } - - /* Now move the data */ - temp = FREESPACE(p) - BIGOVERHEAD; - _DBFIT(temp, uint16_t); - space = (uint16_t)temp; - while (val_size) { - size_t vspace = MIN(space, val_size); - _DBFIT(vspace, uint16_t); - move_bytes = (uint16_t)vspace; - /* - * Here's the hack to make sure that if the data ends on the - * same page as the key ends, FREESPACE is at least one. - */ - if (space == val_size && val_size == val->size) - move_bytes--; - off = OFFSET(p) - move_bytes; - memmove(cp + off, val_data, (size_t)move_bytes); - val_size -= move_bytes; - val_data += move_bytes; - n = p[0]; - p[++n] = off; - p[0] = ++n; - temp = off - PAGE_META(n); - _DBFIT(temp, uint16_t); - FREESPACE(p) = (uint16_t)temp; - OFFSET(p) = off; - if (val_size) { - p[n] = FULL_KEY; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - cp = bufp->page; - p = (uint16_t *)(void *)cp; - } else - p[n] = FULL_KEY_DATA; - bufp->flags |= BUF_MOD; - temp = FREESPACE(p) - BIGOVERHEAD; - _DBFIT(temp, uint16_t); - space = (uint16_t)temp; - } - return (0); -} - -/* - * Called when bufp's page contains a partial key (index should be 1) - * - * All pages in the big key/data pair except bufp are freed. We cannot - * free bufp because the page pointing to it is lost and we can't get rid - * of its pointer. - * - * Returns: - * 0 => OK - *-1 => ERROR - */ -int -__big_delete(HTAB *hashp, BUFHEAD *bufp) -{ - BUFHEAD *last_bfp, *rbufp; - uint16_t *bp, pageno; - int key_done, n; - size_t temp; - - rbufp = bufp; - last_bfp = NULL; - bp = (uint16_t *)(void *)bufp->page; - pageno = 0; - key_done = 0; - - while (!key_done || (bp[2] != FULL_KEY_DATA)) { - if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) - key_done = 1; - - /* - * If there is freespace left on a FULL_KEY_DATA page, then - * the data is short and fits entirely on this page, and this - * is the last page. - */ - if (bp[2] == FULL_KEY_DATA && FREESPACE(bp)) - break; - pageno = bp[bp[0] - 1]; - rbufp->flags |= BUF_MOD; - rbufp = __get_buf(hashp, (uint32_t)pageno, rbufp, 0); - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - last_bfp = rbufp; - if (!rbufp) - return (-1); /* Error. */ - bp = (uint16_t *)(void *)rbufp->page; - } - - /* - * If we get here then rbufp points to the last page of the big - * key/data pair. Bufp points to the first one -- it should now be - * empty pointing to the next page after this pair. Can't free it - * because we don't have the page pointing to it. - */ - - /* This is information from the last page of the pair. */ - n = bp[0]; - pageno = bp[n - 1]; - - /* Now, bp is the first page of the pair. */ - bp = (uint16_t *)(void *)bufp->page; - if (n > 2) { - /* There is an overflow page. */ - bp[1] = pageno; - bp[2] = OVFLPAGE; - bufp->ovfl = rbufp->ovfl; - } else - /* This is the last page. */ - bufp->ovfl = NULL; - n -= 2; - bp[0] = n; - temp = hashp->BSIZE - PAGE_META(n); - _DBFIT(temp, uint16_t); - FREESPACE(bp) = (uint16_t)temp; - OFFSET(bp) = hashp->BSIZE; - - bufp->flags |= BUF_MOD; - if (rbufp) - __free_ovflpage(hashp, rbufp); - if (last_bfp && last_bfp != rbufp) - __free_ovflpage(hashp, last_bfp); - - hashp->NKEYS--; - return (0); -} -/* - * Returns: - * 0 = key not found - * -1 = get next overflow page - * -2 means key not found and this is big key/data - * -3 error - */ -int -__find_bigpair(HTAB *hashp, BUFHEAD *bufp, int ndx, char *key, int size) -{ - uint16_t *bp; - char *p; - int ksize; - uint16_t bytes; - char *kkey; - - bp = (uint16_t *)(void *)bufp->page; - p = bufp->page; - ksize = size; - kkey = key; - - for (bytes = hashp->BSIZE - bp[ndx]; - bytes <= size && bp[ndx + 1] == PARTIAL_KEY; - bytes = hashp->BSIZE - bp[ndx]) { - if (memcmp(p + bp[ndx], kkey, (size_t)bytes)) - return (-2); - kkey += bytes; - ksize -= bytes; - bufp = __get_buf(hashp, (uint32_t)bp[ndx + 2], bufp, 0); - if (!bufp) - return (-3); - p = bufp->page; - bp = (uint16_t *)(void *)p; - ndx = 1; - } - - if (bytes != ksize || memcmp(p + bp[ndx], kkey, (size_t)bytes)) { -#ifdef HASH_STATISTICS - ++hash_collisions; -#endif - return (-2); - } else - return (ndx); -} - -/* - * Given the buffer pointer of the first overflow page of a big pair, - * find the end of the big pair - * - * This will set bpp to the buffer header of the last page of the big pair. - * It will return the pageno of the overflow page following the last page - * of the pair; 0 if there isn't any (i.e. big pair is the last key in the - * bucket) - */ -uint16_t -__find_last_page(HTAB *hashp, BUFHEAD **bpp) -{ - BUFHEAD *bufp; - uint16_t *bp, pageno; - int n; - - bufp = *bpp; - bp = (uint16_t *)(void *)bufp->page; - for (;;) { - n = bp[0]; - - /* - * This is the last page if: the tag is FULL_KEY_DATA and - * either only 2 entries OVFLPAGE marker is explicit there - * is freespace on the page. - */ - if (bp[2] == FULL_KEY_DATA && - ((n == 2) || (bp[n] == OVFLPAGE) || (FREESPACE(bp)))) - break; - - pageno = bp[n - 1]; - bufp = __get_buf(hashp, (uint32_t)pageno, bufp, 0); - if (!bufp) - return (0); /* Need to indicate an error! */ - bp = (uint16_t *)(void *)bufp->page; - } - - *bpp = bufp; - if (bp[0] > 2) - return (bp[3]); - else - return (0); -} - -/* - * Return the data for the key/data pair that begins on this page at this - * index (index should always be 1). - */ -int -__big_return(HTAB *hashp, BUFHEAD *bufp, int ndx, DBT *val, int set_current) -{ - BUFHEAD *save_p; - uint16_t *bp, len, off, save_addr; - char *tp; - - bp = (uint16_t *)(void *)bufp->page; - while (bp[ndx + 1] == PARTIAL_KEY) { - bufp = __get_buf(hashp, (uint32_t)bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (uint16_t *)(void *)bufp->page; - ndx = 1; - } - - if (bp[ndx + 1] == FULL_KEY) { - bufp = __get_buf(hashp, (uint32_t)bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (uint16_t *)(void *)bufp->page; - save_p = bufp; - save_addr = save_p->addr; - off = bp[1]; - len = 0; - } else - if (!FREESPACE(bp)) { - /* - * This is a hack. We can't distinguish between - * FULL_KEY_DATA that contains complete data or - * incomplete data, so we require that if the data - * is complete, there is at least 1 byte of free - * space left. - */ - off = bp[bp[0]]; - len = bp[1] - off; - save_p = bufp; - save_addr = bufp->addr; - bufp = __get_buf(hashp, (uint32_t)bp[bp[0] - 1], bufp, - 0); - if (!bufp) - return (-1); - bp = (uint16_t *)(void *)bufp->page; - } else { - /* The data is all on one page. */ - tp = (char *)(void *)bp; - off = bp[bp[0]]; - val->data = (uint8_t *)tp + off; - val->size = bp[1] - off; - if (set_current) { - if (bp[0] == 2) { /* No more buckets in - * chain */ - hashp->cpage = NULL; - hashp->cbucket++; - hashp->cndx = 1; - } else { - hashp->cpage = __get_buf(hashp, - (uint32_t)bp[bp[0] - 1], bufp, 0); - if (!hashp->cpage) - return (-1); - hashp->cndx = 1; - if (!((uint16_t *)(void *) - hashp->cpage->page)[0]) { - hashp->cbucket++; - hashp->cpage = NULL; - } - } - } - return (0); - } - - val->size = collect_data(hashp, bufp, (int)len, set_current); - if (val->size == (size_t)-1) - return (-1); - if (save_p->addr != save_addr) { - /* We are pretty short on buffers. */ - errno = EINVAL; /* OUT OF BUFFERS */ - return (-1); - } - memmove(hashp->tmp_buf, (save_p->page) + off, (size_t)len); - val->data = (uint8_t *)hashp->tmp_buf; - return (0); -} -/* - * Count how big the total datasize is by recursing through the pages. Then - * allocate a buffer and copy the data as you recurse up. - */ -static int -collect_data(HTAB *hashp, BUFHEAD *bufp, int len, int set) -{ - uint16_t *bp; - char *p; - BUFHEAD *xbp; - uint16_t save_addr; - int mylen, totlen; - - p = bufp->page; - bp = (uint16_t *)(void *)p; - mylen = hashp->BSIZE - bp[1]; - save_addr = bufp->addr; - - if (bp[2] == FULL_KEY_DATA) { /* End of Data */ - totlen = len + mylen; - if (hashp->tmp_buf) - free(hashp->tmp_buf); - if ((hashp->tmp_buf = calloc(1, (size_t)totlen)) == NULL) - return (-1); - if (set) { - hashp->cndx = 1; - if (bp[0] == 2) { /* No more buckets in chain */ - hashp->cpage = NULL; - hashp->cbucket++; - } else { - hashp->cpage = - __get_buf(hashp, (uint32_t)bp[bp[0] - 1], - bufp, 0); - if (!hashp->cpage) - return (-1); - else if (!((uint16_t *)(void *)hashp->cpage->page)[0]) { - hashp->cbucket++; - hashp->cpage = NULL; - } - } - } - } else { - xbp = __get_buf(hashp, (uint32_t)bp[bp[0] - 1], bufp, 0); - if (!xbp || ((totlen = - collect_data(hashp, xbp, len + mylen, set)) < 1)) - return (-1); - } - if (bufp->addr != save_addr) { - errno = EINVAL; /* Out of buffers. */ - return (-1); - } - memmove(&hashp->tmp_buf[len], (bufp->page) + bp[1], (size_t)mylen); - return (totlen); -} - -/* - * Fill in the key and data for this big pair. - */ -int -__big_keydata(HTAB *hashp, BUFHEAD *bufp, DBT *key, DBT *val, int set) -{ - key->size = collect_key(hashp, bufp, 0, val, set); - if (key->size == (size_t)-1) - return (-1); - key->data = (uint8_t *)hashp->tmp_key; - return (0); -} - -/* - * Count how big the total key size is by recursing through the pages. Then - * collect the data, allocate a buffer and copy the key as you recurse up. - */ -static int -collect_key(HTAB *hashp, BUFHEAD *bufp, int len, DBT *val, int set) -{ - BUFHEAD *xbp; - char *p; - int mylen, totlen; - uint16_t *bp, save_addr; - - p = bufp->page; - bp = (uint16_t *)(void *)p; - mylen = hashp->BSIZE - bp[1]; - - save_addr = bufp->addr; - totlen = len + mylen; - if (bp[2] == FULL_KEY || bp[2] == FULL_KEY_DATA) { /* End of Key. */ - if (hashp->tmp_key != NULL) - free(hashp->tmp_key); - if ((hashp->tmp_key = calloc(1, (size_t)totlen)) == NULL) - return (-1); - if (__big_return(hashp, bufp, 1, val, set)) - return (-1); - } else { - xbp = __get_buf(hashp, (uint32_t)bp[bp[0] - 1], bufp, 0); - if (!xbp || ((totlen = - collect_key(hashp, xbp, totlen, val, set)) < 1)) - return (-1); - } - if (bufp->addr != save_addr) { - errno = EINVAL; /* MIS -- OUT OF BUFFERS */ - return (-1); - } - memmove(&hashp->tmp_key[len], (bufp->page) + bp[1], (size_t)mylen); - return (totlen); -} - -/* - * Returns: - * 0 => OK - * -1 => error - */ -int -__big_split( - HTAB *hashp, - BUFHEAD *op, /* Pointer to where to put keys that go in old bucket */ - BUFHEAD *np, /* Pointer to new bucket page */ - /* Pointer to first page containing the big key/data */ - BUFHEAD *big_keyp, - int addr, /* Address of big_keyp */ - uint32_t obucket,/* Old Bucket */ - SPLIT_RETURN *ret -) -{ - BUFHEAD *tmpp; - uint16_t *tp; - BUFHEAD *bp; - DBT key, val; - uint32_t change; - uint16_t free_space, n, off; - size_t temp; - - bp = big_keyp; - - /* Now figure out where the big key/data goes */ - if (__big_keydata(hashp, big_keyp, &key, &val, 0)) - return (-1); - change = (__call_hash(hashp, key.data, (int)key.size) != obucket); - - if ((ret->next_addr = __find_last_page(hashp, &big_keyp)) != 0) { - if (!(ret->nextp = - __get_buf(hashp, (uint32_t)ret->next_addr, big_keyp, 0))) - return (-1); - } else - ret->nextp = NULL; - - /* Now make one of np/op point to the big key/data pair */ - _DIAGASSERT(np->ovfl == NULL); - if (change) - tmpp = np; - else - tmpp = op; - - tmpp->flags |= BUF_MOD; -#ifdef DEBUG1 - (void)fprintf(stderr, - "BIG_SPLIT: %d->ovfl was %d is now %d\n", tmpp->addr, - (tmpp->ovfl ? tmpp->ovfl->addr : 0), (bp ? bp->addr : 0)); -#endif - tmpp->ovfl = bp; /* one of op/np point to big_keyp */ - tp = (uint16_t *)(void *)tmpp->page; - _DIAGASSERT(FREESPACE(tp) >= OVFLSIZE); - n = tp[0]; - off = OFFSET(tp); - free_space = FREESPACE(tp); - tp[++n] = (uint16_t)addr; - tp[++n] = OVFLPAGE; - tp[0] = n; - OFFSET(tp) = off; - temp = free_space - OVFLSIZE; - _DBFIT(temp, uint16_t); - FREESPACE(tp) = (uint16_t)temp; - - /* - * Finally, set the new and old return values. BIG_KEYP contains a - * pointer to the last page of the big key_data pair. Make sure that - * big_keyp has no following page (2 elements) or create an empty - * following page. - */ - - ret->newp = np; - ret->oldp = op; - - tp = (uint16_t *)(void *)big_keyp->page; - big_keyp->flags |= BUF_MOD; - if (tp[0] > 2) { - /* - * There may be either one or two offsets on this page. If - * there is one, then the overflow page is linked on normally - * and tp[4] is OVFLPAGE. If there are two, tp[4] contains - * the second offset and needs to get stuffed in after the - * next overflow page is added. - */ - n = tp[4]; - free_space = FREESPACE(tp); - off = OFFSET(tp); - tp[0] -= 2; - temp = free_space + OVFLSIZE; - _DBFIT(temp, uint16_t); - FREESPACE(tp) = (uint16_t)temp; - OFFSET(tp) = off; - tmpp = __add_ovflpage(hashp, big_keyp); - if (!tmpp) - return (-1); - tp[4] = n; - } else - tmpp = big_keyp; - - if (change) - ret->newp = tmpp; - else - ret->oldp = tmpp; - return (0); -} diff --git a/lib/libc/db/hash/hash_buf.c b/lib/libc/db/hash/hash_buf.c deleted file mode 100644 index 6469736b7..000000000 --- a/lib/libc/db/hash/hash_buf.c +++ /dev/null @@ -1,338 +0,0 @@ -/* $NetBSD: hash_buf.c,v 1.18 2009/04/23 22:09:23 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: hash_buf.c,v 1.18 2009/04/23 22:09:23 christos Exp $"); - -/* - * PACKAGE: hash - * - * DESCRIPTION: - * Contains buffer management - * - * ROUTINES: - * External - * __buf_init - * __get_buf - * __buf_free - * __reclaim_buf - * Internal - * newbuf - */ - -#include - -#include -#include -#include -#include -#include -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static BUFHEAD *newbuf(HTAB *, uint32_t, BUFHEAD *); - -/* Unlink B from its place in the lru */ -#define BUF_REMOVE(B) { \ - (B)->prev->next = (B)->next; \ - (B)->next->prev = (B)->prev; \ -} - -/* Insert B after P */ -#define BUF_INSERT(B, P) { \ - (B)->next = (P)->next; \ - (B)->prev = (P); \ - (P)->next = (B); \ - (B)->next->prev = (B); \ -} - -#define MRU hashp->bufhead.next -#define LRU hashp->bufhead.prev - -#define MRU_INSERT(B) BUF_INSERT((B), &hashp->bufhead) -#define LRU_INSERT(B) BUF_INSERT((B), LRU) - -/* - * We are looking for a buffer with address "addr". If prev_bp is NULL, then - * address is a bucket index. If prev_bp is not NULL, then it points to the - * page previous to an overflow page that we are trying to find. - * - * CAVEAT: The buffer header accessed via prev_bp's ovfl field may no longer - * be valid. Therefore, you must always verify that its address matches the - * address you are seeking. - */ -BUFHEAD * -__get_buf( - HTAB *hashp, - uint32_t addr, - BUFHEAD *prev_bp, - int newpage /* If prev_bp set, indicates a new overflow page. */ -) -{ - BUFHEAD *bp; - uint32_t is_disk_mask; - int is_disk, segment_ndx = 0; /* pacify gcc */ - SEGMENT segp = NULL; /* pacify gcc */ - - is_disk = 0; - is_disk_mask = 0; - if (prev_bp) { - bp = prev_bp->ovfl; - if (!bp || (bp->addr != addr)) - bp = NULL; - if (!newpage) - is_disk = BUF_DISK; - } else { - /* Grab buffer out of directory */ - segment_ndx = addr & (hashp->SGSIZE - 1); - - /* valid segment ensured by __call_hash() */ - segp = hashp->dir[addr >> hashp->SSHIFT]; - _DIAGASSERT(segp != NULL); - bp = PTROF(segp[segment_ndx]); - is_disk_mask = ISDISK(segp[segment_ndx]); - is_disk = is_disk_mask || !hashp->new_file; - } - - if (!bp) { - bp = newbuf(hashp, addr, prev_bp); - if (!bp || - __get_page(hashp, bp->page, addr, !prev_bp, is_disk, 0)) - return (NULL); - if (!prev_bp) - segp[segment_ndx] = - (BUFHEAD *)(void *)((u_long)bp | is_disk_mask); - } else { - BUF_REMOVE(bp); - MRU_INSERT(bp); - } - return (bp); -} - -/* - * We need a buffer for this page. Either allocate one, or evict a resident - * one (if we have as many buffers as we're allowed) and put this one in. - * - * If newbuf finds an error (returning NULL), it also sets errno. - */ -static BUFHEAD * -newbuf(HTAB *hashp, uint32_t addr, BUFHEAD *prev_bp) -{ - BUFHEAD *bp; /* The buffer we're going to use */ - BUFHEAD *xbp; /* Temp pointer */ - BUFHEAD *next_xbp; - SEGMENT segp; - int segment_ndx; - uint16_t oaddr, *shortp; - - oaddr = 0; - bp = LRU; - /* - * If LRU buffer is pinned, the buffer pool is too small. We need to - * allocate more buffers. - */ - if (hashp->nbufs || (bp->flags & BUF_PIN)) { - /* Allocate a new one */ - if ((bp = calloc(1, sizeof(BUFHEAD))) == NULL) - return (NULL); - if ((bp->page = calloc(1, (size_t)hashp->BSIZE)) == NULL) { - free(bp); - return (NULL); - } - if (hashp->nbufs) - hashp->nbufs--; - } else { - /* Kick someone out */ - BUF_REMOVE(bp); - /* - * If this is an overflow page with addr 0, it's already been - * flushed back in an overflow chain and initialized. - */ - if ((bp->addr != 0) || (bp->flags & BUF_BUCKET)) { - /* - * Set oaddr before __put_page so that you get it - * before bytes are swapped. - */ - shortp = (uint16_t *)(void *)bp->page; - if (shortp[0]) - oaddr = shortp[shortp[0] - 1]; - if ((bp->flags & BUF_MOD) && __put_page(hashp, bp->page, - bp->addr, (int)IS_BUCKET(bp->flags), 0)) - return (NULL); - /* - * Update the pointer to this page (i.e. invalidate it). - * - * If this is a new file (i.e. we created it at open - * time), make sure that we mark pages which have been - * written to disk so we retrieve them from disk later, - * rather than allocating new pages. - */ - if (IS_BUCKET(bp->flags)) { - segment_ndx = bp->addr & (hashp->SGSIZE - 1); - segp = hashp->dir[bp->addr >> hashp->SSHIFT]; - _DIAGASSERT(segp != NULL); - - if (hashp->new_file && - ((bp->flags & BUF_MOD) || - ISDISK(segp[segment_ndx]))) - segp[segment_ndx] = (BUFHEAD *)BUF_DISK; - else - segp[segment_ndx] = NULL; - } - /* - * Since overflow pages can only be access by means of - * their bucket, free overflow pages associated with - * this bucket. - */ - for (xbp = bp; xbp->ovfl;) { - next_xbp = xbp->ovfl; - xbp->ovfl = 0; - xbp = next_xbp; - - /* Check that ovfl pointer is up date. */ - if (IS_BUCKET(xbp->flags) || - (oaddr != xbp->addr)) - break; - - shortp = (uint16_t *)(void *)xbp->page; - if (shortp[0]) - /* set before __put_page */ - oaddr = shortp[shortp[0] - 1]; - if ((xbp->flags & BUF_MOD) && __put_page(hashp, - xbp->page, xbp->addr, 0, 0)) - return (NULL); - xbp->addr = 0; - xbp->flags = 0; - BUF_REMOVE(xbp); - LRU_INSERT(xbp); - } - } - } - - /* Now assign this buffer */ - bp->addr = addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF1: %d->ovfl was %d is now %d\n", - bp->addr, (bp->ovfl ? bp->ovfl->addr : 0), 0); -#endif - bp->ovfl = NULL; - if (prev_bp) { - /* - * If prev_bp is set, this is an overflow page, hook it in to - * the buffer overflow links. - */ -#ifdef DEBUG1 - (void)fprintf(stderr, "NEWBUF2: %d->ovfl was %d is now %d\n", - prev_bp->addr, (prev_bp->ovfl ? prev_bp->ovfl->addr : 0), - (bp ? bp->addr : 0)); -#endif - prev_bp->ovfl = bp; - bp->flags = 0; - } else - bp->flags = BUF_BUCKET; - MRU_INSERT(bp); - return (bp); -} - -void -__buf_init(HTAB *hashp, u_int nbytes) -{ - BUFHEAD *bfp; - int npages; - - bfp = &(hashp->bufhead); - npages = (unsigned int)(nbytes + hashp->BSIZE - 1) >> hashp->BSHIFT; - npages = MAX(npages, MIN_BUFFERS); - - hashp->nbufs = npages; - bfp->next = bfp; - bfp->prev = bfp; - /* - * This space is calloc'd so these are already null. - * - * bfp->ovfl = NULL; - * bfp->flags = 0; - * bfp->page = NULL; - * bfp->addr = 0; - */ -} - -int -__buf_free(HTAB *hashp, int do_free, int to_disk) -{ - BUFHEAD *bp; - - /* Need to make sure that buffer manager has been initialized */ - if (!LRU) - return (0); - for (bp = LRU; bp != &hashp->bufhead;) { - /* Check that the buffer is valid */ - if (bp->addr || IS_BUCKET(bp->flags)) { - if (to_disk && (bp->flags & BUF_MOD) && - __put_page(hashp, bp->page, - bp->addr, IS_BUCKET(bp->flags), 0)) - return (-1); - } - /* Check if we are freeing stuff */ - if (do_free) { - if (bp->page) { - (void)memset(bp->page, 0, (size_t)hashp->BSIZE); - free(bp->page); - } - BUF_REMOVE(bp); - free(bp); - bp = LRU; - } else - bp = bp->prev; - } - return (0); -} - -void -__reclaim_buf(HTAB *hashp, BUFHEAD *bp) -{ - bp->ovfl = 0; - bp->addr = 0; - bp->flags = 0; - BUF_REMOVE(bp); - LRU_INSERT(bp); -} diff --git a/lib/libc/db/hash/hash_func.c b/lib/libc/db/hash/hash_func.c deleted file mode 100644 index 6dd136dc2..000000000 --- a/lib/libc/db/hash/hash_func.c +++ /dev/null @@ -1,208 +0,0 @@ -/* $NetBSD: hash_func.c,v 1.13 2008/09/10 17:52:35 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: hash_func.c,v 1.13 2008/09/10 17:52:35 joerg Exp $"); - -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -#if 0 -static uint32_t hash1(const void *, size_t) __attribute__((__unused__)); -static uint32_t hash2(const void *, size_t) __attribute__((__unused__)); -static uint32_t hash3(const void *, size_t) __attribute__((__unused__)); -#endif -static uint32_t hash4(const void *, size_t) __attribute__((__unused__)); - -/* Global default hash function */ -uint32_t (*__default_hash)(const void *, size_t) = hash4; -#if 0 -/* - * HASH FUNCTIONS - * - * Assume that we've already split the bucket to which this key hashes, - * calculate that bucket, and check that in fact we did already split it. - * - * This came from ejb's hsearch. - */ - -#define PRIME1 37 -#define PRIME2 1048583 - -static uint32_t -hash1(const void *keyarg, size_t len) -{ - const uint8_t *key; - uint32_t h; - - /* Convert string to integer */ - for (key = keyarg, h = 0; len--;) - h = h * PRIME1 ^ (*key++ - ' '); - h %= PRIME2; - return (h); -} - -/* - * Phong's linear congruential hash - */ -#define dcharhash(h, c) ((h) = 0x63c63cd9*(h) + 0x9c39c33d + (c)) - -static uint32_t -hash2(const void *keyarg, size_t len) -{ - const uint8_t *e, *key; - uint32_t h; - uint8_t c; - - key = keyarg; - e = key + len; - for (h = 0; key != e;) { - c = *key++; - if (!c && key > e) - break; - dcharhash(h, c); - } - return (h); -} - -/* - * This is INCREDIBLY ugly, but fast. We break the string up into 8 byte - * units. On the first time through the loop we get the "leftover bytes" - * (strlen % 8). On every other iteration, we perform 8 HASHC's so we handle - * all 8 bytes. Essentially, this saves us 7 cmp & branch instructions. If - * this routine is heavily used enough, it's worth the ugly coding. - * - * OZ's original sdbm hash - */ -static uint32_t -hash3(const void *keyarg, size_t len) -{ - const uint8_t *key; - size_t loop; - uint32_t h; - -#define HASHC h = *key++ + 65599 * h - - h = 0; - key = keyarg; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { - HASHC; - /* FALLTHROUGH */ - case 7: - HASHC; - /* FALLTHROUGH */ - case 6: - HASHC; - /* FALLTHROUGH */ - case 5: - HASHC; - /* FALLTHROUGH */ - case 4: - HASHC; - /* FALLTHROUGH */ - case 3: - HASHC; - /* FALLTHROUGH */ - case 2: - HASHC; - /* FALLTHROUGH */ - case 1: - HASHC; - } while (--loop); - } - } - return (h); -} -#endif - -/* Hash function from Chris Torek. */ -static uint32_t -hash4(const void *keyarg, size_t len) -{ - const uint8_t *key; - size_t loop; - uint32_t h; - -#define HASH4a h = (h << 5) - h + *key++; -#define HASH4b h = (h << 5) + h + *key++; -#define HASH4 HASH4b - - h = 0; - key = keyarg; - if (len > 0) { - loop = (len + 8 - 1) >> 3; - - switch (len & (8 - 1)) { - case 0: - do { - HASH4; - /* FALLTHROUGH */ - case 7: - HASH4; - /* FALLTHROUGH */ - case 6: - HASH4; - /* FALLTHROUGH */ - case 5: - HASH4; - /* FALLTHROUGH */ - case 4: - HASH4; - /* FALLTHROUGH */ - case 3: - HASH4; - /* FALLTHROUGH */ - case 2: - HASH4; - /* FALLTHROUGH */ - case 1: - HASH4; - } while (--loop); - } - } - return (h); -} diff --git a/lib/libc/db/hash/hash_log2.c b/lib/libc/db/hash/hash_log2.c deleted file mode 100644 index 74343da17..000000000 --- a/lib/libc/db/hash/hash_log2.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: hash_log2.c,v 1.13 2008/09/11 12:33:55 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: hash_log2.c,v 1.13 2008/09/11 12:33:55 joerg Exp $"); - -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -uint32_t -__log2(uint32_t num) -{ - uint32_t i, limit; - - if (num == 0) - return 0; - --num; - - limit = 0; - for (i = 0; limit < num; limit = limit * 2 + 1, i++) - continue; - return (i); -} diff --git a/lib/libc/db/hash/hash_page.c b/lib/libc/db/hash/hash_page.c deleted file mode 100644 index 5ca355ee8..000000000 --- a/lib/libc/db/hash/hash_page.c +++ /dev/null @@ -1,928 +0,0 @@ -/* $NetBSD: hash_page.c,v 1.26 2013/12/01 00:22:48 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: hash_page.c,v 1.26 2013/12/01 00:22:48 christos Exp $"); - -/* - * PACKAGE: hashing - * - * DESCRIPTION: - * Page manipulation for hashing package. - * - * ROUTINES: - * - * External - * __get_page - * __add_ovflpage - * Internal - * overflow_page - */ - -#include "namespace.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include "hash.h" -#include "page.h" -#include "extern.h" - -static uint32_t *fetch_bitmap(HTAB *, int); -static uint32_t first_free(uint32_t); -static uint16_t overflow_page(HTAB *); -static void putpair(char *, const DBT *, const DBT *); -static void squeeze_key(uint16_t *, const DBT *, const DBT *); -static int ugly_split(HTAB *, uint32_t, BUFHEAD *, BUFHEAD *, int, int); - -#define PAGE_INIT(P) { \ - ((uint16_t *)(void *)(P))[0] = 0; \ - temp = 3 * sizeof(uint16_t); \ - _DIAGASSERT((size_t)hashp->BSIZE >= temp); \ - ((uint16_t *)(void *)(P))[1] = (uint16_t)(hashp->BSIZE - temp); \ - ((uint16_t *)(void *)(P))[2] = hashp->BSIZE; \ -} - -/* - * This is called AFTER we have verified that there is room on the page for - * the pair (PAIRFITS has returned true) so we go right ahead and start moving - * stuff on. - */ -static void -putpair(char *p, const DBT *key, const DBT *val) -{ - uint16_t *bp, n, off; - size_t temp; - - bp = (uint16_t *)(void *)p; - - /* Enter the key first. */ - n = bp[0]; - - temp = OFFSET(bp); - _DIAGASSERT(temp >= key->size); - off = (uint16_t)(temp - key->size); - memmove(p + off, key->data, key->size); - bp[++n] = off; - - /* Now the data. */ - _DIAGASSERT(off >= val->size); - off -= (uint16_t)val->size; - memmove(p + off, val->data, val->size); - bp[++n] = off; - - /* Adjust page info. */ - bp[0] = n; - temp = (n + 3) * sizeof(uint16_t); - _DIAGASSERT(off >= temp); - bp[n + 1] = (uint16_t)(off - temp); - bp[n + 2] = off; -} - -/* - * Returns: - * 0 OK - * -1 error - */ -int -__delpair(HTAB *hashp, BUFHEAD *bufp, int ndx) -{ - uint16_t *bp, newoff; - int n; - uint16_t pairlen; - size_t temp; - - bp = (uint16_t *)(void *)bufp->page; - n = bp[0]; - - if (bp[ndx + 1] < REAL_KEY) - return (__big_delete(hashp, bufp)); - if (ndx != 1) - newoff = bp[ndx - 1]; - else - newoff = hashp->BSIZE; - pairlen = newoff - bp[ndx + 1]; - - if (ndx != (n - 1)) { - /* Hard Case -- need to shuffle keys */ - int i; - char *src = bufp->page + (int)OFFSET(bp); - char *dst = src + (int)pairlen; - memmove(dst, src, (size_t)(bp[ndx + 1] - OFFSET(bp))); - - /* Now adjust the pointers */ - for (i = ndx + 2; i <= n; i += 2) { - if (bp[i + 1] == OVFLPAGE) { - bp[i - 2] = bp[i]; - bp[i - 1] = bp[i + 1]; - } else { - bp[i - 2] = bp[i] + pairlen; - bp[i - 1] = bp[i + 1] + pairlen; - } - } - } - /* Finally adjust the page data */ - bp[n] = OFFSET(bp) + pairlen; - temp = bp[n + 1] + pairlen + 2 * sizeof(uint16_t); - _DIAGASSERT(temp <= 0xffff); - bp[n - 1] = (uint16_t)temp; - bp[0] = n - 2; - hashp->NKEYS--; - - bufp->flags |= BUF_MOD; - return (0); -} -/* - * Returns: - * 0 ==> OK - * -1 ==> Error - */ -int -__split_page(HTAB *hashp, uint32_t obucket, uint32_t nbucket) -{ - BUFHEAD *new_bufp, *old_bufp; - uint16_t *ino; - char *np; - DBT key, val; - int n, ndx, retval; - uint16_t copyto, diff, off, moved; - char *op; - size_t temp; - - copyto = (uint16_t)hashp->BSIZE; - off = (uint16_t)hashp->BSIZE; - old_bufp = __get_buf(hashp, obucket, NULL, 0); - if (old_bufp == NULL) - return (-1); - new_bufp = __get_buf(hashp, nbucket, NULL, 0); - if (new_bufp == NULL) - return (-1); - - old_bufp->flags |= (BUF_MOD | BUF_PIN); - new_bufp->flags |= (BUF_MOD | BUF_PIN); - - ino = (uint16_t *)(void *)(op = old_bufp->page); - np = new_bufp->page; - - moved = 0; - - for (n = 1, ndx = 1; n < ino[0]; n += 2) { - if (ino[n + 1] < REAL_KEY) { - retval = ugly_split(hashp, obucket, old_bufp, new_bufp, - (int)copyto, (int)moved); - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (retval); - - } - key.data = (uint8_t *)op + ino[n]; - key.size = off - ino[n]; - - if (__call_hash(hashp, key.data, (int)key.size) == obucket) { - /* Don't switch page */ - diff = copyto - off; - if (diff) { - copyto = ino[n + 1] + diff; - memmove(op + copyto, op + ino[n + 1], - (size_t)(off - ino[n + 1])); - ino[ndx] = copyto + ino[n] - ino[n + 1]; - ino[ndx + 1] = copyto; - } else - copyto = ino[n + 1]; - ndx += 2; - } else { - /* Switch page */ - val.data = (uint8_t *)op + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - putpair(np, &key, &val); - moved += 2; - } - - off = ino[n + 1]; - } - - /* Now clean up the page */ - ino[0] -= moved; - temp = sizeof(uint16_t) * (ino[0] + 3); - _DIAGASSERT(copyto >= temp); - FREESPACE(ino) = (uint16_t)(copyto - temp); - OFFSET(ino) = copyto; - -#ifdef DEBUG3 - (void)fprintf(stderr, "split %d/%d\n", - ((uint16_t *)np)[0] / 2, - ((uint16_t *)op)[0] / 2); -#endif - /* unpin both pages */ - old_bufp->flags &= ~BUF_PIN; - new_bufp->flags &= ~BUF_PIN; - return (0); -} - -/* - * Called when we encounter an overflow or big key/data page during split - * handling. This is special cased since we have to begin checking whether - * the key/data pairs fit on their respective pages and because we may need - * overflow pages for both the old and new pages. - * - * The first page might be a page with regular key/data pairs in which case - * we have a regular overflow condition and just need to go on to the next - * page or it might be a big key/data pair in which case we need to fix the - * big key/data pair. - * - * Returns: - * 0 ==> success - * -1 ==> failure - */ -static int -ugly_split( - HTAB *hashp, - uint32_t obucket, /* Same as __split_page. */ - BUFHEAD *old_bufp, - BUFHEAD *new_bufp, - int copyto, /* First byte on page which contains key/data values. */ - int moved /* Number of pairs moved to new page. */ -) -{ - BUFHEAD *bufp; /* Buffer header for ino */ - uint16_t *ino; /* Page keys come off of */ - uint16_t *np; /* New page */ - uint16_t *op; /* Page keys go on to if they aren't moving */ - size_t temp; - - BUFHEAD *last_bfp; /* Last buf header OVFL needing to be freed */ - DBT key, val; - SPLIT_RETURN ret; - uint16_t n, off, ov_addr, scopyto; - char *cino; /* Character value of ino */ - - bufp = old_bufp; - ino = (uint16_t *)(void *)old_bufp->page; - np = (uint16_t *)(void *)new_bufp->page; - op = (uint16_t *)(void *)old_bufp->page; - last_bfp = NULL; - scopyto = (uint16_t)copyto; /* ANSI */ - - n = ino[0] - 1; - while (n < ino[0]) { - if (ino[2] < REAL_KEY && ino[2] != OVFLPAGE) { - if (__big_split(hashp, old_bufp, - new_bufp, bufp, (int)bufp->addr, obucket, &ret)) - return (-1); - old_bufp = ret.oldp; - if (!old_bufp) - return (-1); - op = (uint16_t *)(void *)old_bufp->page; - new_bufp = ret.newp; - if (!new_bufp) - return (-1); - np = (uint16_t *)(void *)new_bufp->page; - bufp = ret.nextp; - if (!bufp) - return (0); - cino = (char *)bufp->page; - ino = (uint16_t *)(void *)cino; - last_bfp = ret.nextp; - } else if (ino[n + 1] == OVFLPAGE) { - ov_addr = ino[n]; - /* - * Fix up the old page -- the extra 2 are the fields - * which contained the overflow information. - */ - ino[0] -= (moved + 2); - temp = sizeof(uint16_t) * (ino[0] + 3); - _DIAGASSERT(scopyto >= temp); - FREESPACE(ino) = (uint16_t)(scopyto - temp); - OFFSET(ino) = scopyto; - - bufp = __get_buf(hashp, (uint32_t)ov_addr, bufp, 0); - if (!bufp) - return (-1); - - ino = (uint16_t *)(void *)bufp->page; - n = 1; - scopyto = hashp->BSIZE; - moved = 0; - - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - last_bfp = bufp; - } - /* Move regular sized pairs of there are any */ - off = hashp->BSIZE; - for (n = 1; (n < ino[0]) && (ino[n + 1] >= REAL_KEY); n += 2) { - cino = (char *)(void *)ino; - key.data = (uint8_t *)cino + ino[n]; - key.size = off - ino[n]; - val.data = (uint8_t *)cino + ino[n + 1]; - val.size = ino[n] - ino[n + 1]; - off = ino[n + 1]; - - if (__call_hash(hashp, key.data, (int)key.size) == obucket) { - /* Keep on old page */ - if (PAIRFITS(op, (&key), (&val))) - putpair((char *)(void *)op, &key, &val); - else { - old_bufp = - __add_ovflpage(hashp, old_bufp); - if (!old_bufp) - return (-1); - op = (uint16_t *)(void *)old_bufp->page; - putpair((char *)(void *)op, &key, &val); - } - old_bufp->flags |= BUF_MOD; - } else { - /* Move to new page */ - if (PAIRFITS(np, (&key), (&val))) - putpair((char *)(void *)np, &key, &val); - else { - new_bufp = - __add_ovflpage(hashp, new_bufp); - if (!new_bufp) - return (-1); - np = (uint16_t *)(void *)new_bufp->page; - putpair((char *)(void *)np, &key, &val); - } - new_bufp->flags |= BUF_MOD; - } - } - } - if (last_bfp) - __free_ovflpage(hashp, last_bfp); - return (0); -} - -/* - * Add the given pair to the page - * - * Returns: - * 0 ==> OK - * 1 ==> failure - */ -int -__addel(HTAB *hashp, BUFHEAD *bufp, const DBT *key, const DBT *val) -{ - uint16_t *bp, *sop; - int do_expand; - - bp = (uint16_t *)(void *)bufp->page; - do_expand = 0; - while (bp[0] && (bp[2] < REAL_KEY || bp[bp[0]] < REAL_KEY)) - /* Exception case */ - if (bp[2] == FULL_KEY_DATA && bp[0] == 2) - /* This is the last page of a big key/data pair - and we need to add another page */ - break; - else if (bp[2] < REAL_KEY && bp[bp[0]] != OVFLPAGE) { - bufp = __get_buf(hashp, (uint32_t)bp[bp[0] - 1], bufp, - 0); - if (!bufp) - return (-1); - bp = (uint16_t *)(void *)bufp->page; - } else if (bp[bp[0]] != OVFLPAGE) { - /* Short key/data pairs, no more pages */ - break; - } else { - /* Try to squeeze key on this page */ - if (bp[2] >= REAL_KEY && - FREESPACE(bp) >= PAIRSIZE(key, val)) { - squeeze_key(bp, key, val); - goto stats; - } else { - bufp = __get_buf(hashp, - (uint32_t)bp[bp[0] - 1], bufp, 0); - if (!bufp) - return (-1); - bp = (uint16_t *)(void *)bufp->page; - } - } - - if (PAIRFITS(bp, key, val)) - putpair(bufp->page, key, val); - else { - do_expand = 1; - bufp = __add_ovflpage(hashp, bufp); - if (!bufp) - return (-1); - sop = (uint16_t *)(void *)bufp->page; - - if (PAIRFITS(sop, key, val)) - putpair((char *)(void *)sop, key, val); - else - if (__big_insert(hashp, bufp, key, val)) - return (-1); - } -stats: - bufp->flags |= BUF_MOD; - /* - * If the average number of keys per bucket exceeds the fill factor, - * expand the table. - */ - hashp->NKEYS++; - if (do_expand || - (hashp->NKEYS / (hashp->MAX_BUCKET + 1) > hashp->FFACTOR)) - return (__expand_table(hashp)); - return (0); -} - -/* - * - * Returns: - * pointer on success - * NULL on error - */ -BUFHEAD * -__add_ovflpage(HTAB *hashp, BUFHEAD *bufp) -{ - uint16_t *sp; - uint16_t ndx, ovfl_num; - size_t temp; -#ifdef DEBUG1 - int tmp1, tmp2; -#endif - sp = (uint16_t *)(void *)bufp->page; - - /* Check if we are dynamically determining the fill factor */ - if (hashp->FFACTOR == DEF_FFACTOR) { - hashp->FFACTOR = (uint32_t)sp[0] >> 1; - if (hashp->FFACTOR < MIN_FFACTOR) - hashp->FFACTOR = MIN_FFACTOR; - } - bufp->flags |= BUF_MOD; - ovfl_num = overflow_page(hashp); -#ifdef DEBUG1 - tmp1 = bufp->addr; - tmp2 = bufp->ovfl ? bufp->ovfl->addr : 0; -#endif - if (!ovfl_num || !(bufp->ovfl = __get_buf(hashp, (uint32_t)ovfl_num, - bufp, 1))) - return (NULL); - bufp->ovfl->flags |= BUF_MOD; -#ifdef DEBUG1 - (void)fprintf(stderr, "ADDOVFLPAGE: %d->ovfl was %d is now %d\n", - tmp1, tmp2, bufp->ovfl->addr); -#endif - ndx = sp[0]; - /* - * Since a pair is allocated on a page only if there's room to add - * an overflow page, we know that the OVFL information will fit on - * the page. - */ - sp[ndx + 4] = OFFSET(sp); - temp = FREESPACE(sp); - _DIAGASSERT(temp >= OVFLSIZE); - sp[ndx + 3] = (uint16_t)(temp - OVFLSIZE); - sp[ndx + 1] = ovfl_num; - sp[ndx + 2] = OVFLPAGE; - sp[0] = ndx + 2; -#ifdef HASH_STATISTICS - hash_overflows++; -#endif - return (bufp->ovfl); -} - -/* - * Returns: - * 0 indicates SUCCESS - * -1 indicates FAILURE - */ -int -__get_page(HTAB *hashp, char *p, uint32_t bucket, int is_bucket, int is_disk, - int is_bitmap) -{ - int fd, page, size; - ssize_t rsize; - uint16_t *bp; - size_t temp; - - fd = hashp->fp; - size = hashp->BSIZE; - - if ((fd == -1) || !is_disk) { - PAGE_INIT(p); - return (0); - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((rsize = pread(fd, p, (size_t)size, (off_t)page << hashp->BSHIFT)) == -1) - return (-1); - bp = (uint16_t *)(void *)p; - if (!rsize) - bp[0] = 0; /* We hit the EOF, so initialize a new page */ - else - if (rsize != size) { - errno = EFTYPE; - return (-1); - } - if (!is_bitmap && !bp[0]) { - PAGE_INIT(p); - } else - if (hashp->LORDER != BYTE_ORDER) { - int i, max; - - if (is_bitmap) { - max = (uint32_t)hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - M_32_SWAP(((int *)(void *)p)[i]); - } else { - M_16_SWAP(bp[0]); - max = bp[0] + 2; - for (i = 1; i <= max; i++) - M_16_SWAP(bp[i]); - } - } - return (0); -} - -/* - * Write page p to disk - * - * Returns: - * 0 ==> OK - * -1 ==>failure - */ -int -__put_page(HTAB *hashp, char *p, uint32_t bucket, int is_bucket, int is_bitmap) -{ - int fd, page, size; - ssize_t wsize; - - size = hashp->BSIZE; - if ((hashp->fp == -1) && (hashp->fp = __dbtemp("_hash", NULL)) == -1) - return (-1); - fd = hashp->fp; - - if (hashp->LORDER != BYTE_ORDER) { - int i; - int max; - - if (is_bitmap) { - max = (uint32_t)hashp->BSIZE >> 2; /* divide by 4 */ - for (i = 0; i < max; i++) - M_32_SWAP(((int *)(void *)p)[i]); - } else { - max = ((uint16_t *)(void *)p)[0] + 2; - for (i = 0; i <= max; i++) - M_16_SWAP(((uint16_t *)(void *)p)[i]); - } - } - if (is_bucket) - page = BUCKET_TO_PAGE(bucket); - else - page = OADDR_TO_PAGE(bucket); - if ((wsize = pwrite(fd, p, (size_t)size, (off_t)page << hashp->BSHIFT)) == -1) - /* Errno is set */ - return (-1); - if (wsize != size) { - errno = EFTYPE; - return (-1); - } - return (0); -} - -#define BYTE_MASK ((1 << INT_BYTE_SHIFT) -1) -/* - * Initialize a new bitmap page. Bitmap pages are left in memory - * once they are read in. - */ -int -__ibitmap(HTAB *hashp, int pnum, int nbits, int ndx) -{ - uint32_t *ip; - int clearbytes, clearints; - - if ((ip = malloc((size_t)hashp->BSIZE)) == NULL) - return (1); - hashp->nmaps++; - clearints = ((uint32_t)(nbits - 1) >> INT_BYTE_SHIFT) + 1; - clearbytes = clearints << INT_TO_BYTE; - (void)memset(ip, 0, (size_t)clearbytes); - (void)memset(((char *)(void *)ip) + clearbytes, 0xFF, - (size_t)(hashp->BSIZE - clearbytes)); - ip[clearints - 1] = ALL_SET << (nbits & BYTE_MASK); - SETBIT(ip, 0); - hashp->BITMAPS[ndx] = (uint16_t)pnum; - hashp->mapp[ndx] = ip; - return (0); -} - -static uint32_t -first_free(uint32_t map) -{ - uint32_t i, mask; - - mask = 0x1; - for (i = 0; i < BITS_PER_MAP; i++) { - if (!(mask & map)) - return (i); - mask = mask << 1; - } - return (i); -} - -static uint16_t -overflow_page(HTAB *hashp) -{ - uint32_t *freep = NULL; - int max_free, offset, splitnum; - uint16_t addr; - int bit, first_page, free_bit, free_page, i, in_use_bits, j; -#ifdef DEBUG2 - int tmp1, tmp2; -#endif - splitnum = hashp->OVFL_POINT; - max_free = hashp->SPARES[splitnum]; - - free_page = (uint32_t)(max_free - 1) >> (hashp->BSHIFT + BYTE_SHIFT); - free_bit = (max_free - 1) & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - /* Look through all the free maps to find the first free block */ - first_page = (uint32_t)hashp->LAST_FREED >>(hashp->BSHIFT + BYTE_SHIFT); - for ( i = first_page; i <= free_page; i++ ) { - if (!(freep = (uint32_t *)hashp->mapp[i]) && - !(freep = fetch_bitmap(hashp, i))) - return (0); - if (i == free_page) - in_use_bits = free_bit; - else - in_use_bits = (hashp->BSIZE << BYTE_SHIFT) - 1; - - if (i == first_page) { - bit = hashp->LAST_FREED & - ((hashp->BSIZE << BYTE_SHIFT) - 1); - j = bit / BITS_PER_MAP; - bit = bit & ~(BITS_PER_MAP - 1); - } else { - bit = 0; - j = 0; - } - for (; bit <= in_use_bits; j++, bit += BITS_PER_MAP) - if (freep[j] != ALL_SET) - goto found; - } - - /* No Free Page Found */ - hashp->LAST_FREED = hashp->SPARES[splitnum]; - hashp->SPARES[splitnum]++; - offset = hashp->SPARES[splitnum] - - (splitnum ? hashp->SPARES[splitnum - 1] : 0); - -#define OVMSG "HASH: Out of overflow pages. Increase page size\n" - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - errno = EFBIG; - return (0); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 1; - } - - /* Check if we need to allocate a new bitmap page */ - if (free_bit == (hashp->BSIZE << BYTE_SHIFT) - 1) { - free_page++; - if (free_page >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - errno = EFBIG; - return (0); - } - /* - * This is tricky. The 1 indicates that you want the new page - * allocated with 1 clear bit. Actually, you are going to - * allocate 2 pages from this map. The first is going to be - * the map page, the second is the overflow page we were - * looking for. The init_bitmap routine automatically, sets - * the first bit of itself to indicate that the bitmap itself - * is in use. We would explicitly set the second bit, but - * don't have to if we tell init_bitmap not to leave it clear - * in the first place. - */ - if (__ibitmap(hashp, - (int)OADDR_OF(splitnum, offset), 1, free_page)) - return (0); - hashp->SPARES[splitnum]++; -#ifdef DEBUG2 - free_bit = 2; -#endif - offset++; - if (offset > SPLITMASK) { - if (++splitnum >= NCACHED) { - (void)write(STDERR_FILENO, OVMSG, - sizeof(OVMSG) - 1); - errno = EFBIG; - return (0); - } - hashp->OVFL_POINT = splitnum; - hashp->SPARES[splitnum] = hashp->SPARES[splitnum-1]; - hashp->SPARES[splitnum-1]--; - offset = 0; - } - } else { - /* - * Free_bit addresses the last used bit. Bump it to address - * the first available bit. - */ - free_bit++; - SETBIT(freep, free_bit); - } - - /* Calculate address of the new overflow page */ - addr = OADDR_OF(splitnum, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, free_bit, free_page); -#endif - return (addr); - -found: - bit = bit + first_free(freep[j]); - SETBIT(freep, bit); -#ifdef DEBUG2 - tmp1 = bit; - tmp2 = i; -#endif - /* - * Bits are addressed starting with 0, but overflow pages are addressed - * beginning at 1. Bit is a bit addressnumber, so we need to increment - * it to convert it to a page number. - */ - bit = 1 + bit + (i * (hashp->BSIZE << BYTE_SHIFT)); - if (bit >= hashp->LAST_FREED) - hashp->LAST_FREED = bit - 1; - - /* Calculate the split number for this page */ - for (i = 0; (i < splitnum) && (bit > hashp->SPARES[i]); i++); - offset = (i ? bit - hashp->SPARES[i - 1] : bit); - if (offset >= SPLITMASK) { - (void)write(STDERR_FILENO, OVMSG, sizeof(OVMSG) - 1); - errno = EFBIG; - return (0); /* Out of overflow pages */ - } - addr = OADDR_OF(i, offset); -#ifdef DEBUG2 - (void)fprintf(stderr, "OVERFLOW_PAGE: ADDR: %d BIT: %d PAGE %d\n", - addr, tmp1, tmp2); -#endif - - /* Allocate and return the overflow page */ - return (addr); -} - -/* - * Mark this overflow page as free. - */ -void -__free_ovflpage(HTAB *hashp, BUFHEAD *obufp) -{ - uint16_t addr; - uint32_t *freep; - int bit_address, free_page, free_bit; - uint16_t ndx; - - addr = obufp->addr; -#ifdef DEBUG1 - (void)fprintf(stderr, "Freeing %d\n", addr); -#endif - ndx = (((uint32_t)addr) >> SPLITSHIFT); - bit_address = - (ndx ? hashp->SPARES[ndx - 1] : 0) + (addr & SPLITMASK) - 1; - if (bit_address < hashp->LAST_FREED) - hashp->LAST_FREED = bit_address; - free_page = ((uint32_t)bit_address >> (hashp->BSHIFT + BYTE_SHIFT)); - free_bit = bit_address & ((hashp->BSIZE << BYTE_SHIFT) - 1); - - if (!(freep = hashp->mapp[free_page])) - freep = fetch_bitmap(hashp, free_page); - /* - * This had better never happen. It means we tried to read a bitmap - * that has already had overflow pages allocated off it, and we - * failed to read it from the file. - */ - _DIAGASSERT(freep != NULL); - CLRBIT(freep, free_bit); -#ifdef DEBUG2 - (void)fprintf(stderr, "FREE_OVFLPAGE: ADDR: %d BIT: %d PAGE %d\n", - obufp->addr, free_bit, free_page); -#endif - __reclaim_buf(hashp, obufp); -} - -/* - * We have to know that the key will fit, but the last entry on the page is - * an overflow pair, so we need to shift things. - */ -static void -squeeze_key(uint16_t *sp, const DBT *key, const DBT *val) -{ - char *p; - uint16_t free_space, n, off, pageno; - size_t temp; - - p = (char *)(void *)sp; - n = sp[0]; - free_space = FREESPACE(sp); - off = OFFSET(sp); - - pageno = sp[n - 1]; - _DIAGASSERT(off >= key->size); - off -= (uint16_t)key->size; - sp[n - 1] = off; - memmove(p + off, key->data, key->size); - _DIAGASSERT(off >= val->size); - off -= (uint16_t)val->size; - sp[n] = off; - memmove(p + off, val->data, val->size); - sp[0] = n + 2; - sp[n + 1] = pageno; - sp[n + 2] = OVFLPAGE; - temp = PAIRSIZE(key, val); - _DIAGASSERT(free_space >= temp); - FREESPACE(sp) = (uint16_t)(free_space - temp); - OFFSET(sp) = off; -} - -static uint32_t * -fetch_bitmap(HTAB *hashp, int ndx) -{ - if (ndx >= hashp->nmaps) - return (NULL); - if ((hashp->mapp[ndx] = malloc((size_t)hashp->BSIZE)) == NULL) - return (NULL); - if (__get_page(hashp, - (char *)(void *)hashp->mapp[ndx], (uint32_t)hashp->BITMAPS[ndx], 0, 1, 1)) { - free(hashp->mapp[ndx]); - return (NULL); - } - return (hashp->mapp[ndx]); -} - -#ifdef DEBUG4 -void print_chain(HTAB *, uint32_t); -void -print_chain(HTAB *hashp, uint32_t addr) -{ - BUFHEAD *bufp; - uint16_t *bp, oaddr; - - (void)fprintf(stderr, "%d ", addr); - bufp = __get_buf(hashp, addr, NULL, 0); - bp = (uint16_t *)bufp->page; - while (bp[0] && ((bp[bp[0]] == OVFLPAGE) || - ((bp[0] > 2) && bp[2] < REAL_KEY))) { - oaddr = bp[bp[0] - 1]; - (void)fprintf(stderr, "%d ", (int)oaddr); - bufp = __get_buf(hashp, (uint32_t)oaddr, bufp, 0); - bp = (uint16_t *)bufp->page; - } - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/lib/libc/db/hash/ndbm.c b/lib/libc/db/hash/ndbm.c deleted file mode 100644 index 1aea409b7..000000000 --- a/lib/libc/db/hash/ndbm.c +++ /dev/null @@ -1,115 +0,0 @@ -/* $NetBSD: ndbm.c,v 1.23 2008/09/11 12:58:00 joerg Exp $ */ -/* from: NetBSD: ndbm.c,v 1.18 2004/04/27 20:03:45 kleink Exp */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: ndbm.c,v 1.23 2008/09/11 12:58:00 joerg Exp $"); - -/* - * This package provides a dbm compatible interface to the new hashing - * package described in db(3). - */ -#include "namespace.h" -#include - -#include -#include -#include - -#include -#include "hash.h" - -/* - * Returns: - * *DBM on success - * NULL on failure - */ -DBM * -dbm_open(const char *file, int flags, mode_t mode) -{ - HASHINFO info; - char path[MAXPATHLEN]; - - info.bsize = 4096; - info.ffactor = 40; - info.nelem = 1; - info.cachesize = 0; - info.hash = NULL; - info.lorder = 0; - (void)strncpy(path, file, sizeof(path) - 1); - (void)strncat(path, DBM_SUFFIX, sizeof(path) - strlen(path) - 1); - if ((flags & O_ACCMODE) == O_WRONLY) { - flags &= ~O_WRONLY; - flags |= O_RDWR; - } - return ((DBM *)__hash_open(path, flags, mode, &info, 0)); -} - -void -dbm_close(DBM *db) -{ - (void)(db->close)(db); -} - -int -dbm_error(DBM *db) -{ - HTAB *hp; - - hp = db->internal; - return (hp->err); -} - -int -dbm_clearerr(DBM *db) -{ - HTAB *hp; - - hp = db->internal; - hp->err = 0; - return (0); -} - -int -dbm_dirfno(DBM *db) -{ - HTAB *hp; - - hp = db->internal; - return hp->fp; -} diff --git a/lib/libc/db/hash/ndbmdatum.c b/lib/libc/db/hash/ndbmdatum.c deleted file mode 100644 index 707140977..000000000 --- a/lib/libc/db/hash/ndbmdatum.c +++ /dev/null @@ -1,161 +0,0 @@ -/* $NetBSD: ndbmdatum.c,v 1.5 2012/03/13 21:13:33 christos Exp $ */ -/* from: NetBSD: ndbm.c,v 1.18 2004/04/27 20:03:45 kleink Exp */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: ndbmdatum.c,v 1.5 2012/03/13 21:13:33 christos Exp $"); - -/* - * This package provides a dbm compatible interface to the new hashing - * package described in db(3). - */ -#include "namespace.h" -#include - -#include -#include -#include - -#include -#include "hash.h" - -#ifndef datum_truncate -#define datum_truncate(a) (a) -#endif -/* - * Returns: - * DATUM on success - * NULL on failure - */ -datum -dbm_fetch(DBM *db, datum key) -{ - datum retdata; - int status; - DBT dbtkey, dbtretdata; - - dbtkey.data = key.dptr; - dbtkey.size = key.dsize; - status = (db->get)(db, &dbtkey, &dbtretdata, 0); - if (status) { - dbtretdata.data = NULL; - dbtretdata.size = 0; - } - retdata.dptr = dbtretdata.data; - retdata.dsize = datum_truncate(dbtretdata.size); - return (retdata); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -datum -dbm_firstkey(DBM *db) -{ - int status; - datum retkey; - DBT dbtretkey, dbtretdata; - - status = (db->seq)(db, &dbtretkey, &dbtretdata, R_FIRST); - if (status) - dbtretkey.data = NULL; - retkey.dptr = dbtretkey.data; - retkey.dsize = datum_truncate(dbtretkey.size); - return (retkey); -} - -/* - * Returns: - * DATUM on success - * NULL on failure - */ -datum -dbm_nextkey(DBM *db) -{ - int status; - datum retkey; - DBT dbtretkey, dbtretdata; - - status = (db->seq)(db, &dbtretkey, &dbtretdata, R_NEXT); - if (status) - dbtretkey.data = NULL; - retkey.dptr = dbtretkey.data; - retkey.dsize = datum_truncate(dbtretkey.size); - return (retkey); -} - -/* - * Returns: - * 0 on success - * <0 failure - */ -int -dbm_delete(DBM *db, datum key) -{ - int status; - DBT dbtkey; - - dbtkey.data = key.dptr; - dbtkey.size = key.dsize; - status = (db->del)(db, &dbtkey, 0); - if (status) - return (-1); - else - return (0); -} - -/* - * Returns: - * 0 on success - * <0 failure - * 1 if DBM_INSERT and entry exists - */ -int -dbm_store(DBM *db, datum key, datum data, int flags) -{ - DBT dbtkey, dbtdata; - - dbtkey.data = key.dptr; - dbtkey.size = key.dsize; - dbtdata.data = data.dptr; - dbtdata.size = data.dsize; - return ((db->put)(db, &dbtkey, &dbtdata, - (u_int)((flags == DBM_INSERT) ? R_NOOVERWRITE : 0))); -} diff --git a/lib/libc/db/hash/page.h b/lib/libc/db/hash/page.h deleted file mode 100644 index 40dc77d02..000000000 --- a/lib/libc/db/hash/page.h +++ /dev/null @@ -1,90 +0,0 @@ -/* $NetBSD: page.h,v 1.8 2008/08/26 21:18:38 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Margo Seltzer. - * - * 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. - * - * @(#)page.h 8.2 (Berkeley) 5/31/94 - */ - -/* - * Definitions for hashing page file format. - */ - -/* - * routines dealing with a data page - * - * page format: - * +------------------------------+ - * p | n | keyoff | datoff | keyoff | - * +------------+--------+--------+ - * | datoff | free | ptr | --> | - * +--------+---------------------+ - * | F R E E A R E A | - * +--------------+---------------+ - * | <---- - - - | data | - * +--------+-----+----+----------+ - * | key | data | key | - * +--------+----------+----------+ - * - * Pointer to the free space is always: p[p[0] + 2] - * Amount of free space on the page is: p[p[0] + 1] - */ - -/* - * How many bytes required for this pair? - * 2 shorts in the table at the top of the page + room for the - * key and room for the data - * - * We prohibit entering a pair on a page unless there is also room to append - * an overflow page. The reason for this it that you can get in a situation - * where a single key/data pair fits on a page, but you can't append an - * overflow page and later you'd have to split the key/data and handle like - * a big pair. - * You might as well do this up front. - */ - -#define PAIRSIZE(K,D) (2*sizeof(uint16_t) + (K)->size + (D)->size) -#define BIGOVERHEAD (4*sizeof(uint16_t)) -#define KEYSIZE(K) (4*sizeof(uint16_t) + (K)->size); -#define OVFLSIZE (2*sizeof(uint16_t)) -#define FREESPACE(P) ((P)[(P)[0]+1]) -#define OFFSET(P) ((P)[(P)[0]+2]) -#define PAIRFITS(P,K,D) \ - (((P)[2] >= REAL_KEY) && \ - (PAIRSIZE((K),(D)) + OVFLSIZE) <= FREESPACE((P))) -#define PAGE_META(N) (((N)+3) * sizeof(uint16_t)) - -typedef struct { - BUFHEAD *newp; - BUFHEAD *oldp; - BUFHEAD *nextp; - uint16_t next_addr; -} SPLIT_RETURN; diff --git a/lib/libc/db/man/Makefile.inc b/lib/libc/db/man/Makefile.inc deleted file mode 100644 index f45c41630..000000000 --- a/lib/libc/db/man/Makefile.inc +++ /dev/null @@ -1,15 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.10 2004/04/30 21:13:23 kleink Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/man - -MAN+= btree.3 dbm_clearerr.3 dbopen.3 hash.3 recno.3 mpool.3 -MLINKS+= dbm_clearerr.3 dbm_close.3 dbm_clearerr.3 dbm_delete.3 -MLINKS+= dbm_clearerr.3 dbm_dirfno.3 dbm_clearerr.3 dbm_error.3 -MLINKS+= dbm_clearerr.3 dbm_fetch.3 dbm_clearerr.3 dbm_firstkey.3 -MLINKS+= dbm_clearerr.3 dbm_nextkey.3 dbm_clearerr.3 dbm_open.3 -MLINKS+= dbm_clearerr.3 dbm_store.3 dbm_clearerr.3 ndbm.3 -MLINKS+= dbopen.3 db.3 -MLINKS+= mpool.3 mpool_open.3 mpool.3 mpool_filter.3 mpool.3 mpool_new.3 -MLINKS+= mpool.3 mpool_get.3 mpool.3 mpool_put.3 mpool.3 mpool_sync.3 -MLINKS+= mpool.3 mpool_close.3 diff --git a/lib/libc/db/man/btree.3 b/lib/libc/db/man/btree.3 deleted file mode 100644 index c226251c2..000000000 --- a/lib/libc/db/man/btree.3 +++ /dev/null @@ -1,254 +0,0 @@ -.\" $NetBSD: btree.3,v 1.13 2012/10/13 15:28:33 njoly Exp $ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)btree.3 8.4 (Berkeley) 8/18/94 -.\" -.Dd April 17, 2003 -.Dt BTREE 3 -.Os -.Sh NAME -.Nm btree -.Nd btree database access method -.Sh SYNOPSIS -.In sys/types.h -.In db.h -.Sh DESCRIPTION -The routine -.Fn dbopen -is the library interface to database files. -One of the supported file formats is btree files. -The general description of the database access methods is in -.Xr dbopen 3 , -this manual page describes only the btree specific information. -.Pp -The btree data structure is a sorted, balanced tree structure storing -associated key/data pairs. -.Pp -The btree access method specific data structure provided to -.Fn dbopen -is defined in the -.In db.h -include file as follows: -.Bd -literal -typedef struct { - u_long flags; - u_int cachesize; - int maxkeypage; - int minkeypage; - u_int psize; - int (*compare)(const DBT *key1, const DBT *key2); - size_t (*prefix)(const DBT *key1, const DBT *key2); - int lorder; -} BTREEINFO; -.Ed -.Pp -The elements of this structure are as follows: -.Bl -tag -width maxkeypagex -.It Fa flags -The flag value is specified by or'ing any of the following values: -.Bl -tag -width R_DUP -offset indent -.It Dv R_DUP -Permit duplicate keys in the tree, i.e. permit insertion if the key to -be inserted already exists in the tree. -The default behavior, as described in -.Xr dbopen 3 , -is to overwrite a matching key when inserting a new key or to fail if -the -.Dv R_NOOVERWRITE -flag is specified. -The -.Dv R_DUP -flag is overridden by the -.Dv R_NOOVERWRITE -flag, and if the -.Dv R_NOOVERWRITE -flag is specified, attempts to insert duplicate keys into the tree -will fail. -.Pp -If the database contains duplicate keys, the order of retrieval of -key/data pairs is undefined if the -.Em get -routine is used, however, -.Em seq -routine calls with the -.Dv R_CURSOR -flag set will always return the logical -.Dq first -of any group of duplicate keys. -.El -.It Fa cachesize -A suggested maximum size (in bytes) of the memory cache. -This value is -.Em only -advisory, and the access method will allocate more memory rather than -fail. -Since every search examines the root page of the tree, caching the -most recently used pages substantially improves access time. -In addition, physical writes are delayed as long as possible, so a -moderate cache can reduce the number of I/O operations significantly. -Obviously, using a cache increases (but only increases) the likelihood -of corruption or lost data if the system crashes while a tree is being -modified. -If -.Fa cachesize -is 0 (no size is specified) a default cache is used. -.It Fa maxkeypage -The maximum number of keys which will be stored on any single page. -Not currently implemented. -.\" The maximum number of keys which will be stored on any single page. -.\" Because of the way the btree data structure works, -.\" .Fa maxkeypage -.\" must always be greater than or equal to 2. -.\" If -.\" .Fa maxkeypage -.\" is 0 (no maximum number of keys is specified) the page fill factor is -.\" made as large as possible (which is almost invariably what is wanted). -.It Fa minkeypage -The minimum number of keys which will be stored on any single page. -This value is used to determine which keys will be stored on overflow -pages, i.e., if a key or data item is longer than the pagesize divided -by the -.Fa minkeypage -value, it will be stored on overflow pages instead of in the page -itself. -If -.Fa minkeypage -is 0 (no minimum number of keys is specified) a value of 2 is used. -.It Fa psize -Page size is the size (in bytes) of the pages used for nodes in the -tree. -The minimum page size is 512 bytes and the maximum page size is 64K. -If -.Fa psize -is 0 (no page size is specified) a page size is chosen based on the -underlying file system I/O block size. -.It Fa compare -Compare is the key comparison function. -It must return an integer less than, equal to, or greater than zero if -the first key argument is considered to be respectively less than, -equal to, or greater than the second key argument. -The same comparison function must be used on a given tree every time -it is opened. -If -.Fa compare -is -.Dv NULL -(no comparison function is specified), the keys are compared -lexically, with shorter keys considered less than longer keys. -.It Fa prefix -Prefix is the prefix comparison function. -If specified, this routine must return the number of bytes of the -second key argument which are necessary to determine that it is -greater than the first key argument. -If the keys are equal, the key length should be returned. -Note, the usefulness of this routine is very data dependent, but, in -some data sets can produce significantly reduced tree sizes and search -times. -If -.Fa prefix -is -.Dv NULL -(no prefix function is specified), -.Em and -no comparison function is specified, a default lexical comparison -routine is used. -If -.Fa prefix -is -.Dv NULL -and a comparison routine is specified, no prefix comparison is done. -.It Fa lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.Fa lorder -is 0 (no order is specified) the current host order is used. -.El -.Pp -If the file already exists (and the -.Dv O_TRUNC -flag is not specified), the values specified for the parameters flags, -lorder and psize are ignored in favor of the values used when the tree -was created. -.Pp -Forward sequential scans of a tree are from the least key to the -greatest. -.Pp -Space freed up by deleting key/data pairs from the tree is never -reclaimed, although it is normally made available for reuse. -This means that the btree storage structure is grow-only. -The only solutions are to avoid excessive deletions, or to create a -fresh tree periodically from a scan of an existing one. -.Pp -Searches, insertions, and deletions in a btree will all complete in -O lg base N where base is the average fill factor. -Often, inserting ordered data into btrees results in a low fill -factor. -This implementation has been modified to make ordered insertion the -best case, resulting in a much better than normal page fill factor. -.Sh ERRORS -The -.Nm -access method routines may fail and set -.Va errno -for any of the errors specified for the library routine -.Xr dbopen 3 . -.Sh SEE ALSO -.Xr dbopen 3 , -.Xr hash 3 , -.Xr mpool 3 , -.Xr recno 3 -.Rs -.%T "The Ubiquitous B-tree" -.%A "Douglas Comer" -.%J "ACM Comput. Surv." -.%V 2 -.%N 11 -.%D June 1979 -.%P 121-138 -.Re -.Rs -.%T "Prefix B-trees" -.%A "Bayer" -.%A "Unterauer" -.%J "ACM Transactions on Database Systems" -.%V Vol. 2 -.%N 1 -.%D March 1977 -.%P 11-26 -.Re -.Rs -.%B "The Art of Computer Programming Vol. 3: Sorting and Searching" -.%A "D.E. Knuth" -.%D 1968 -.%P 471-480 -.Re -.Sh BUGS -Only big and little endian byte order is supported. diff --git a/lib/libc/db/man/dbm_clearerr.3 b/lib/libc/db/man/dbm_clearerr.3 deleted file mode 100644 index d9f06721c..000000000 --- a/lib/libc/db/man/dbm_clearerr.3 +++ /dev/null @@ -1,306 +0,0 @@ -.\" $NetBSD: dbm_clearerr.3,v 1.5 2010/05/05 06:55:57 jruoho Exp $ -.\" -.\" Copyright (c) 2004 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd May 5, 2010 -.Dt DBM_CLEARERR 3 -.Os -.Sh NAME -.Nm dbm_clearerr , -.Nm dbm_close , -.Nm dbm_delete , -.Nm dbm_dirfno , -.Nm dbm_error , -.Nm dbm_fetch , -.Nm dbm_firstkey , -.Nm dbm_nextkey , -.Nm dbm_open , -.Nm dbm_store , -.Nm ndbm -.Nd database functions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ndbm.h -.Ft int -.Fn dbm_clearerr "DBM *db" -.Ft void -.Fn dbm_close "DBM *db" -.Ft int -.Fn dbm_delete "DBM *db" "datum key" -.Ft int -.Fn dbm_dirfno "DBM *db" -.Ft int -.Fn dbm_error "DBM *db" -.Ft datum -.Fn dbm_fetch "DBM *db" "datum key" -.Ft datum -.Fn dbm_firstkey "DBM *db" -.Ft datum -.Fn dbm_nextkey "DBM *db" -.Ft DBM * -.Fn dbm_open "const char *file" "int open_flags" "mode_t file_mode" -.Ft int -.Fn dbm_store "DBM *db" "datum key" "datum content" "int store_mode" -.Sh DESCRIPTION -The -.Nm ndbm -facility provides access to hash database files. -.Pp -Two data types are fundamental to the -.Nm ndbm -facility. -.Fa DBM -serves as a handle to a database. -It is an opaque type. -.Pp -The other data type is -.Fa datum , -which is a structure type which includes the following members: -.Bd -literal -offset indent -void * dptr -size_t dsize -.Ed -.Pp -A -.Fa datum -is thus given by -.Fa dptr -pointing at an object of -.Fa dsize -bytes in length. -.Pp -The -.Fn dbm_open -function opens a database. -The -.Fa file -argument is the pathname which the actual database file pathname -is based on. -This implementation uses a single file with the suffix -.Pa .db -appended to -.Fa file . -The -.Fa open_flags -argument has the same meaning as the -.Fa flags -argument to -.Xr open 2 -except that when opening a database for write-only access the file -is opened for read/write access, and the -.Dv O_APPEND -flag must not be specified. -The -.Fa file_mode -argument has the same meaning as the -.Fa mode -argument to -.Xr open 2 . -.Pp -For the following functions, the -.Fa db -argument is a handle previously returned by a call to -.Fn dbm_open . -.Pp -The -.Fn dbm_close -function closes a database. -.Pp -The -.Fn dbm_fetch -function retrieves a record from the database. -The -.Fa key -argument is a -.Fa datum -that identifies the record to be fetched. -.Pp -The -.Fn dbm_store -function stores a record into the database. -The -.Fa key -argument is a -.Fa datum -that identifies the record to be stored. -The -.Fa content -argument is a -.Fa datum -that specifies the value of the record to be stored. -The -.Fa store_mode -argument specifies the behavior of -.Fn dbm_store -if a record matching -.Fa key -is already present in the database, -.Fa db . -.Fa store_mode -must be one of the following: -.Bl -tag -width DBM_REPLACEXX -offset indent -.It Dv DBM_INSERT -If a record matching -.Fa key -is already present, it is left unchanged. -.It Dv DBM_REPLACE -If a record matching -.Fa key -is already present, its value is replaced by -.Fa content . -.El -.Pp -If no record matching -.Fa key -is present, a new record is inserted regardless of -.Fa store_mode . -.Pp -The -.Fn dbm_delete -function deletes a record from the database. -The -.Fa key -argument is a -.Fa datum -that identifies the record to be deleted. -.Pp -The -.Fn dbm_firstkey -function returns the first key in the database. -.Pp -The -.Fn dbm_nextkey -function returns the next key in the database. -In order to be meaningful, it must be preceded by a call to -.Fn dbm_firstkey . -.Pp -The -.Fn dbm_error -function returns the error indicator of the database. -.Pp -The -.Fn dbm_clearerr -function clears the error indicator of the database. -.Pp -The -.Fn dbm_dirfno -function returns the file descriptor of the underlying database file. -.Sh IMPLEMENTATION NOTES -The -.Nm ndbm -facility is implemented on top of the -.Xr hash 3 -access method of the -.Xr db 3 -database facility. -.Sh RETURN VALUES -The -.Fn dbm_open -function returns a pointer to a -.Fa DBM -when successful; otherwise a null pointer is returned. -.Pp -The -.Fn dbm_close -function returns no value. -.Pp -The -.Fn dbm_fetch -function returns a content -.Fa datum ; -if no record matching -.Fa key -was found or if an error occured, its -.Fa dptr -member is a null pointer. -.Pp -The -.Fn dbm_store -function returns 0 when then record was successfully inserted; -it returns 1 when called with -.Fa store_mode -being -.Dv DBM_INSERT -and a record matching -.Fa key -is already present; -otherwise a negative value is returned. -.Pp -The -.Fn dbm_delete -function returns 0 when the record was successfully deleted; -otherwise a negative value is returned. -.Pp -The -.Fn dbm_firstkey -and -.Fn dbm_nextkey -functions return a key -.Fa datum . -When the end of the database is reached or if an error occured, its -.Fa dptr -member is a null pointer. -.Pp -The -.Fn dbm_error -function returns 0 if the error indicator is clear; -if the error indicator is set a non-zero value is returned. -.Pp -The -.Fn dbm_clearerr -function always returns 0. -.Pp -The -.Fn dbm_dirfno -function returns the file descriptor of the underlying database file. -.Sh ERRORS -No errors are defined. -.Sh SEE ALSO -.Xr open 2 , -.Xr db 3 , -.Xr hash 3 -.Sh STANDARDS -The -.Fn dbm_clearerr , -.Fn dbm_close , -.Fn dbm_delete , -.Fn dbm_error , -.Fn dbm_fetch , -.Fn dbm_firstkey , -.Fn dbm_nextkey , -.Fn dbm_open , -and -.Fn dbm_store -functions conform to -.St -xpg4.2 -and -.St -susv2 . -The -.Fn dbm_dirfno -function is an extension. diff --git a/lib/libc/db/man/dbopen.3 b/lib/libc/db/man/dbopen.3 deleted file mode 100644 index 1db9a25f6..000000000 --- a/lib/libc/db/man/dbopen.3 +++ /dev/null @@ -1,538 +0,0 @@ -.\" $NetBSD: dbopen.3,v 1.19 2010/12/16 12:08:16 jruoho Exp $ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)dbopen.3 8.5 (Berkeley) 1/2/94 -.\" -.Dd December 16, 2010 -.Dt DBOPEN 3 -.Os -.Sh NAME -.Nm dbopen , -.Nm db -.Nd database access methods -.Sh SYNOPSIS -.In sys/types.h -.In limits.h -.In db.h -.In fcntl.h -.Ft DB * -.Fn dbopen "const char *file" "int flags" "mode_t mode" \ -"DBTYPE type" "const void *openinfo" -.Sh DESCRIPTION -.Nm -is the library interface to database files. -The supported file formats are btree, hashed, and UNIX file oriented. -The btree format is a representation of a sorted, balanced tree -structure. -The hashed format is an extensible, dynamic hashing scheme. -The flat-file format is a byte stream file with fixed or variable -length records. -The formats and file format specific information are described in -detail in their respective manual pages -.Xr btree 3 , -.Xr hash 3 , -and -.Xr recno 3 . -.Pp -The -.Fn dbopen -function opens -.Fa file -for reading and/or writing. -Files never intended to be preserved on disk may be created by setting -the file parameter to -.Dv NULL . -.Pp -The -.Fa flags -and -.Fa mode -arguments are as specified to the -.Xr open 2 -routine, however, only the -.Dv O_CREAT , -.Dv O_EXCL , -.Dv O_EXLOCK , -.Dv O_NONBLOCK , -.Dv O_RDONLY , -.Dv O_RDWR , -.Dv O_SHLOCK , -and -.Dv O_TRUNC -flags are meaningful. -(Note, opening a database file -.Dv O_WRONLY -is not possible.) -.\"Three additional options may be specified by or'ing -.\"them into the -.\".Fa flags -.\"argument. -.\".Pp -.\".Dv DB_LOCK -.\"Do the necessary locking in the database to support concurrent access. -.\"If concurrent access isn't needed or the database is read-only this -.\"flag should not be set, as it tends to have an associated performance -.\"penalty. -.\".Pp -.\".Dv DB_SHMEM -.\"Place the underlying memory pool used by the database in shared -.\"memory. -.\"Necessary for concurrent access. -.\".Pp -.\".Dv DB_TXN -.\"Support transactions in the database. -.\"The -.\".Dv DB_LOCK -.\"and -.\".Dv DB_SHMEM -.\"flags must be set as well. -.Pp -The -.Fa type -argument is of type -.Vt DBTYPE -(as defined in the -.In db.h -include file) and may be set to -.Dv DB_BTREE , -.Dv DB_HASH , -or -.Dv DB_RECNO . -.Pp -The -.Fa openinfo -argument is a pointer to an access method specific structure described -in the access method's manual page. -If -.Fa openinfo -is -.Dv NULL , -each access method will use defaults appropriate for the system and -the access method. -.Ss The DB Structure -The -.Fn dbopen -function returns a pointer to a DB structure on success and -.Dv NULL -on error. -The DB structure is defined in the -.In db.h -include file, and contains at least the following fields: -.Bd -literal -offset indent -typedef struct { - DBTYPE type; - int (*close)(const DB *db); - int (*del)(const DB *db, const DBT *key, u_int flags); - int (*fd)(const DB *db); - int (*get)(const DB *db, DBT *key, DBT *data, u_int flags); - int (*put)(const DB *db, DBT *key, const DBT *data, - u_int flags); - int (*sync)(const DB *db, u_int flags); - int (*seq)(const DB *db, DBT *key, DBT *data, u_int flags); -} DB; -.Ed -.Pp -These elements describe a database type and a set of functions -performing various actions. -These functions take a pointer to a structure as returned by -.Nm , -and sometimes one or more pointers to key/data structures and a flag -value. -.Bl -tag -width closex -offset indent -.It Fa type -The type of the underlying access method (and file format). -.It Fa close -A pointer to a routine to flush any cached information to disk, free -any allocated resources, and close the underlying file(s). -Since key/data pairs may be cached in memory, failing to sync the file -with a -.Fa close -or -.Fa sync -function may result in inconsistent or lost information. -.Fa close -routines return \-1 on error (setting -.Va errno ) -and 0 on success. -.It Fa del -A pointer to a routine to remove key/data pairs from the database. -.Pp -The parameter -.Fa flag -may be set to the following value: -.Bl -tag -width R_CURSORX -.It Dv R_CURSOR -Delete the record referenced by the cursor. -The cursor must have previously been initialized. -.El -.Pp -.Fa delete -routines return \-1 on error (setting -.Va errno ) , -0 on success, and 1 if the specified -.Fa key -was not in the file. -.It Fa fd -A pointer to a routine which returns a file descriptor representative -of the underlying database. -A file descriptor referencing the same file will be returned to all -processes which call -.Nm -with the same -.Fa file -name. -This file descriptor may be safely used as an argument to the -.Xr fcntl 2 -and -.Xr flock 2 -locking functions. -The file descriptor is not necessarily associated with any of the -underlying files used by the access method. -No file descriptor is available for in memory databases. -.Fa fd -routines return \-1 on error (setting -.Va errno ) , -and the file descriptor on success. -.It Fa get -A pointer to a routine which is the interface for keyed retrieval from -the database. -The address and length of the data associated with the specified -.Fa key -are returned in the structure referenced by -.Fa data . -.Fa get -routines return \-1 on error (setting -.Va errno ) , -0 on success, and 1 if the -.Fa key -was not in the file. -.It Fa put -A pointer to a routine to store key/data pairs in the database. -.Pp -The parameter -.Fa flag -may be set to one of the following values: -.Bl -tag -width R_NOOVERWRITEX -.It Dv R_CURSOR -Replace the key/data pair referenced by the cursor. -The cursor must have previously been initialized. -.It Dv R_IAFTER -Append the data immediately after the data referenced by -.Fa key , -creating a new key/data pair. -The record number of the appended key/data pair is returned in the -.Fa key -structure. -(Applicable only to the -.Dv DB_RECNO -access method.) -.It Dv R_IBEFORE -Insert the data immediately before the data referenced by -.Fa key , -creating a new key/data pair. -The record number of the inserted key/data pair is returned in the -.Fa key -structure. -(Applicable only to the -.Dv DB_RECNO -access method.) -.It Dv R_NOOVERWRITE -Enter the new key/data pair only if the key does not previously -exist. -.It Dv R_SETCURSOR -Store the key/data pair, setting or initializing the position of the -cursor to reference it. -(Applicable only to the -.Dv DB_BTREE -and -.Dv DB_RECNO -access methods.) -.El -.Pp -.Dv R_SETCURSOR -is available only for the -.Dv DB_BTREE -and -.Dv DB_RECNO -access methods because it implies that the keys have an inherent order -which does not change. -.Pp -.Dv R_IAFTER -and -.Dv R_IBEFORE -are available only for the -.Dv DB_RECNO -access method because they each imply that the access method is able -to create new keys. -This is only true if the keys are ordered and independent, record -numbers for example. -.Pp -The default behavior of the -.Fa put -routines is to enter the new key/data pair, replacing any previously -existing key. -.Pp -.Fa put -routines return \-1 on error (setting -.Va errno ) , -0 on success, and 1 if the -.Dv R_NOOVERWRITE -.Fa flag -was set and the key already exists in the file. -.It Fa seq -A pointer to a routine which is the interface for sequential -retrieval from the database. -The address and length of the key are returned in the structure -referenced by -.Fa key , -and the address and length of the data are returned in the -structure referenced by -.Fa data . -.Pp -Sequential key/data pair retrieval may begin at any time, and the -position of the -.Dq cursor -is not affected by calls to the -.Fa del , -.Fa get , -.Fa put , -or -.Fa sync -routines. -Modifications to the database during a sequential scan will be -reflected in the scan, i.e., records inserted behind the cursor will -not be returned while records inserted in front of the cursor will be -returned. -.Pp -The flag value -.Em must -be set to one of the following values: -.Bl -tag -width R_CURSORX -.It Dv R_CURSOR -The data associated with the specified key is returned. -This differs from the -.Fa get -routines in that it sets or initializes the cursor to the location of -the key as well. -(Note, for the -.Dv DB_BTREE -access method, the returned key is not necessarily an exact match for -the specified key. -The returned key is the smallest key greater than or equal to the -specified key, permitting partial key matches and range searches.) -.It Dv R_FIRST -The first key/data pair of the database is returned, and the cursor -is set or initialized to reference it. -.It Dv R_LAST -The last key/data pair of the database is returned, and the cursor -is set or initialized to reference it. -(Applicable only to the -.Dv DB_BTREE -and -.Dv DB_RECNO -access methods.) -.It Dv R_NEXT -Retrieve the key/data pair immediately after the cursor. -If the cursor is not yet set, this is the same as the -.Dv R_FIRST -flag. -.It Dv R_PREV -Retrieve the key/data pair immediately before the cursor. -If the cursor is not yet set, this is the same as the -.Dv R_LAST -flag. -(Applicable only to the -.Dv DB_BTREE -and -.Dv DB_RECNO -access methods.) -.El -.Pp -.Dv R_LAST -and -.Dv R_PREV -are available only for the -.Dv DB_BTREE -and -.Dv DB_RECNO -access methods because they each imply that the keys have an inherent -order which does not change. -.Pp -.Fa seq -routines return \-1 on error (setting -.Va errno ) , -0 on success and 1 if there are no key/data pairs less than or greater -than the specified or current key. -If the -.Dv DB_RECNO -access method is being used, and if the database file is a character -special file and no complete key/data pairs are currently available, -the -.Fa seq -routines return 2. -.It Fa sync -A pointer to a routine to flush any cached information to disk. -If the database is in memory only, the -.Fa sync -routine has no effect and will always succeed. -.Pp -The flag value may be set to the following value: -.Bl -tag -width ".Dv R_RECNOSYNC" -.It Dv R_RECNOSYNC -If the -.Dv DB_RECNO -access method is being used, this flag causes the sync routine to -apply to the btree file which underlies the recno file, not the recno -file itself. -(See the -.Fa bfname -field of the -.Xr recno 3 -manual page for more information.) -.El -.Pp -.Fa sync -routines return \-1 on error (setting -.Va errno ) -and 0 on success. -.El -.Ss Key/data Pairs -Access to all file types is based on key/data pairs. -Both keys and data are represented by the following data structure: -.Bd -literal -offset indent -typedef struct { - void *data; - size_t size; -} DBT; -.Ed -.Pp -The elements of the DBT structure are defined as follows: -.Bl -tag -width datax -offset indent -.It Fa data -A pointer to a byte string. -.It Fa size -The length of the byte string. -.El -.Pp -Key and data byte strings may reference strings of essentially -unlimited length although any two of them must fit into available -memory at the same time. -It should be noted that the access methods provide no guarantees about -byte string alignment. -.Sh ERRORS -The -.Nm -routine may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr open 2 -and -.Xr malloc 3 -or the following: -.Bl -tag -width Er -.It Er EFTYPE -A file is incorrectly formatted. -.It Er EINVAL -A parameter has been specified (hash function, pad byte, etc.) that is -incompatible with the current file specification or which is not -meaningful for the function (for example, use of the cursor without -prior initialization) or there is a mismatch between the version -number of file and the software. -.It Er EFBIG -The key could not be inserted due to limitations in the DB file format -(e.g., a hash database was out of overflow pages). -.El -.Pp -The -.Fa close -routines may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr close 2 , -.Xr read 2 , -.Xr write 2 , -.Xr free 3 , -or -.Xr fsync 2 . -.Pp -The -.Fa del , -.Fa get , -.Fa put , -and -.Fa seq -routines may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr read 2 , -.Xr write 2 , -.Xr free 3 , -or -.Xr malloc 3 . -.Pp -The -.Fa fd -routines will fail and set -.Va errno -to -.Er ENOENT -for in memory databases. -.Pp -The -.Fa sync -routines may fail and set -.Va errno -for any of the errors specified for the library routine -.Xr fsync 2 . -.Sh SEE ALSO -.Xr btree 3 , -.Xr hash 3 , -.Xr mpool 3 , -.Xr recno 3 -.Pp -.Rs -.%T LIBTP: Portable, Modular Transactions for UNIX -.%A Margo Seltzer -.%A Michael Olson -.%I USENIX Association -.%B Proceedings of the 1992 Winter USENIX Technical Conference -.%D 1992 -.%P 9-25 -.Re -.Sh BUGS -The typedef DBT is a mnemonic for -.Dq data base thang , -and was used because no one could think of a reasonable name that -wasn't already used. -.Pp -The file descriptor interface is a kludge and will be deleted in a -future version of the interface. -.Pp -None of the access methods provide any form of concurrent access, -locking, or transactions. diff --git a/lib/libc/db/man/hash.3 b/lib/libc/db/man/hash.3 deleted file mode 100644 index eaac286cb..000000000 --- a/lib/libc/db/man/hash.3 +++ /dev/null @@ -1,172 +0,0 @@ -.\" $NetBSD: hash.3,v 1.14 2010/12/16 11:57:20 jruoho Exp $ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)hash.3 8.6 (Berkeley) 8/18/94 -.\" -.Dd December 16, 2010 -.Dt HASH 3 -.Os -.Sh NAME -.Nm hash -.Nd hash database access method -.Sh SYNOPSIS -.In sys/types.h -.In db.h -.Sh DESCRIPTION -The routine -.Fn dbopen -is the library interface to database files. -One of the supported file formats is hash files. -The general description of the database access methods is in -.Xr dbopen 3 , -this manual page describes only the hash specific information. -.Pp -The hash data structure is an extensible, dynamic hashing scheme. -.Pp -The access method specific data structure provided to -.Fn dbopen -is defined in the -.In db.h -header as follows: -.Bd -literal -offset indent -typedef struct { - u_int bsize; - u_int ffactor; - u_int nelem; - u_int cachesize; - uint32_t (*hash)(const void *, size_t); - int lorder; -} HASHINFO; -.Ed -.Pp -The elements of this structure are as follows: -.Bl -tag -width cachesizex -.It Fa bsize -.Fa bsize -defines the hash table bucket size, and defaults to 4096 for in-memory tables. -If -.Fa bsize -is 0 (no bucket size is specified) a bucket size is chosen based on the -underlying file system I/O block size. -It may be preferable to increase the page size for disk-resident -tables and tables with large data items. -.It Fa ffactor -.Fa ffactor -indicates a desired density within the hash table. -It is an approximation of the number of keys allowed to accumulate in -any one bucket, determining when the hash table grows or shrinks. -The default value is 8. -.It Fa nelem -.Fa nelem -is an estimate of the final size of the hash table. -If not set or set too low, hash tables will expand gracefully as keys -are entered, although a slight performance degradation may be -noticed. -The default value is 1. -.It Fa cachesize -A suggested maximum size, in bytes, of the memory cache. -This value is -.Em only -advisory, and the access method will allocate more memory rather -than fail. -.It Fa hash -.Fa hash -is a user defined hash function. -Since no hash function performs equally well on all possible data, the -user may find that the built-in hash function does poorly on a -particular data set. -User specified hash functions must take two arguments (a pointer to a -byte string and a length) and return a 32-bit quantity to be used as -the hash value. -.It Fa lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.Fa lorder -is 0 (no order is specified) the current host order is used. -If the file already exists, the specified value is ignored and the -value specified when the tree was created is used. -.El -.Pp -If the file already exists (and the -.Dv O_TRUNC -flag is not specified), the values specified for the parameters -.Fa bsize , -.Fa ffactor , -.Fa lorder , -and -.Fa nelem -are ignored and the values specified when the tree was created are -used. -.Pp -If a hash function is specified, -.Fn hash_open -will attempt to determine if the hash function specified is the same -as the one with which the database was created, and will fail if it is -not. -.\".Pp -.\"Backward compatible interfaces to the routines described in -.\".Xr dbm 3 , -.\"and -.\".Xr ndbm 3 -.\"are provided, however these interfaces are not compatible with -.\"previous file formats. -.Sh ERRORS -The -.Nm -access method routines may fail and set -.Va errno -for any of the errors specified for the library routine -.Xr dbopen 3 . -.Sh SEE ALSO -.Xr btree 3 , -.Xr dbopen 3 , -.Xr mpool 3 , -.Xr recno 3 -.Pp -.Rs -.%T Dynamic Hash Tables -.%A Per-Ake Larson -.%J Communications of the ACM -.%D April 1988 -.%N Issue 4 -.%V Volume 31 -.Re -.Rs -.%T A New Hash Package for UNIX -.%A Margo Seltzer -.%I USENIX Association -.%B Proceedings of the 1991 Winter USENIX Technical Conference -.%D January 1991 -.%P 173-184 -.%U http://www.usenix.org/publications/library/proceedings/seltzer2.pdf -.Re -.Sh BUGS -Only big and little endian byte order is supported. diff --git a/lib/libc/db/man/mpool.3 b/lib/libc/db/man/mpool.3 deleted file mode 100644 index 32673f90f..000000000 --- a/lib/libc/db/man/mpool.3 +++ /dev/null @@ -1,226 +0,0 @@ -.\" $NetBSD: mpool.3,v 1.10 2010/12/16 11:49:35 jruoho Exp $ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)mpool.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd December 16, 2010 -.Dt MPOOL 3 -.Os -.Sh NAME -.Nm mpool , -.Nm mpool_open , -.Nm mpool_filter , -.Nm mpool_new , -.Nm mpool_get , -.Nm mpool_put , -.Nm mpool_sync , -.Nm mpool_close -.Nd shared memory buffer pool -.Sh SYNOPSIS -.In db.h -.In mpool.h -.Ft MPOOL * -.Fn mpool_open "DBT *key" "int fd" "pgno_t pagesize" "pgno_t maxcache" -.Ft void -.Fn mpool_filter "MPOOL *mp" "void (*pgin)(void *, pgno_t, void *)" \ -"void (*pgout)(void *, pgno_t, void *)" "void *pgcookie" -.Ft void * -.Fn mpool_new "MPOOL *mp" "pgno_t *pgnoaddr" -.Ft void * -.Fn mpool_get "MPOOL *mp" "pgno_t pgno" "u_int flags" -.Ft int -.Fn mpool_put "MPOOL *mp" "void *pgaddr" "u_int flags" -.Ft int -.Fn mpool_sync "MPOOL *mp" -.Ft int -.Fn mpool_close "MPOOL *mp" -.Sh DESCRIPTION -.Nm -is the library interface intended to provide page oriented buffer -management of files. -The buffers may be shared between processes. -.Pp -The function -.Fn mpool_open -initializes a memory pool. -The -.Fa key -argument is the byte string used to negotiate between multiple -processes wishing to share buffers. -If the file buffers are mapped in shared memory, all processes using -the same key will share the buffers. -If -.Fa key -is -.Dv NULL , -the buffers are mapped into private memory. -The -.Fa fd -argument is a file descriptor for the underlying file, which must be -seekable. -If -.Fa key -is -.No non- Ns Dv NULL -and matches a file already being mapped, the -.Fa fd -argument is ignored. -.Pp -The -.Fa pagesize -argument is the size, in bytes, of the pages into which the file is -broken up. -The -.Fa maxcache -argument is the maximum number of pages from the underlying file to -cache at any one time. -This value is not relative to the number of processes which share a -file's buffers, but will be the largest value specified by any of the -processes sharing the file. -.Pp -The -.Fn mpool_filter -function is intended to make transparent input and output processing -of the pages possible. -If the -.Fa pgin -function is specified, it is called each time a buffer is read into -the memory pool from the backing file. -If the -.Fa pgout -function is specified, it is called each time a buffer is written into -the backing file. -Both functions are are called with the -.Fa pgcookie -pointer, the page number and a pointer to the page to being read or -written. -.Pp -The function -.Fn mpool_new -takes an MPOOL pointer and an address as arguments. -If a new page can be allocated, a pointer to the page is returned and -the page number is stored into the -.Fa pgnoaddr -address. -Otherwise, -.Dv NULL -is returned and errno is set. -.Pp -The function -.Fn mpool_get -takes a MPOOL pointer and a page number as arguments. -If the page exists, a pointer to the page is returned. -Otherwise, -.Dv NULL -is returned and errno is set. -The flags parameter is not currently used. -.Pp -The function -.Fn mpool_put -unpins the page referenced by -.Fa pgaddr . -.Fa pgaddr -must be an address previously returned by -.Fn mpool_get -or -.Fn mpool_new . -The flag value is specified by or'ing any of the following values: -.Bl -tag -width MPOOL_DIRTYX -offset indent -.It Dv MPOOL_DIRTY -The page has been modified and needs to be written to the backing -file. -.El -.Pp -.Fn mpool_put -returns 0 on success and \-1 if an error occurs. -.Pp -The function -.Fn mpool_sync -writes all modified pages associated with the MPOOL pointer to the -backing file. -.Fn mpool_sync -returns 0 on success and \-1 if an error occurs. -.Pp -The -.Fn mpool_close -function frees up any allocated memory associated with the memory pool -cookie. -Modified pages are -.Em not -written to the backing file. -.Fn mpool_close -returns 0 on success and \-1 if an error occurs. -.Sh ERRORS -The -.Fn mpool_open -function may fail and set -.Va errno -for any of the errors specified for the library routine -.Xr malloc 3 . -.Pp -The -.Fn mpool_get -function may fail and set -.Va errno -for the following: -.Bl -tag -width Er -offset indent -.It Er EINVAL -The requested record doesn't exist. -.El -.Pp -The -.Fn mpool_new -and -.Fn mpool_get -functions may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr read 2 , -.Xr write 2 , -and -.Xr malloc 3 . -.Pp -The -.Fn mpool_sync -function may fail and set -.Va errno -for any of the errors specified for the library routine -.Xr write 2 . -.Pp -The -.Fn mpool_close -function may fail and set -.Va errno -for any of the errors specified for the library routine -.Xr free 3 . -.Sh SEE ALSO -.Xr btree 3 , -.Xr dbopen 3 , -.Xr hash 3 , -.Xr recno 3 diff --git a/lib/libc/db/man/recno.3 b/lib/libc/db/man/recno.3 deleted file mode 100644 index a38871fe7..000000000 --- a/lib/libc/db/man/recno.3 +++ /dev/null @@ -1,214 +0,0 @@ -.\" $NetBSD: recno.3,v 1.11 2010/03/22 19:30:53 joerg Exp $ -.\" -.\" Copyright (c) 1990, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)recno.3 8.5 (Berkeley) 8/18/94 -.\" -.Dd April 17, 2003 -.Dt RECNO 3 -.Os -.Sh NAME -.Nm recno -.Nd record number database access method -.Sh SYNOPSIS -.In sys/types.h -.In db.h -.Sh DESCRIPTION -The routine -.Fn dbopen -is the library interface to database files. -One of the supported file formats is record number files. -The general description of the database access methods is in -.Xr dbopen 3 , -this manual page describes only the recno specific information. -.Pp -The record number data structure is either variable or fixed-length -records stored in a flat-file format, accessed by the logical record -number. -The existence of record number five implies the existence of records -one through four, and the deletion of record number one causes -record number five to be renumbered to record number four, as well -as the cursor, if positioned after record number one, to shift down -one record. -.Pp -The recno access method specific data structure provided to -.Fn dbopen -is defined in the -.In db.h -include file as follows: -.Bd -literal -typedef struct { - u_long flags; - u_int cachesize; - u_int psize; - int lorder; - size_t reclen; - uint8_t bval; - char *bfname; -} RECNOINFO; -.Ed -.Pp -The elements of this structure are defined as follows: -.Bl -tag -width cachesizex -.It Fa flags -The flag value is specified by or'ing any of the following values: -.Bl -tag -width R_FIXEDLENX -offset indent -.It Dv R_FIXEDLEN -The records are fixed-length, not byte delimited. -The structure element -.Fa reclen -specifies the length of the record, and the structure element -.Fa bval -is used as the pad character. -Any records, inserted into the database, that are less than -.Fa reclen -bytes long are automatically padded. -.It Dv R_NOKEY -In the interface specified by -.Fn dbopen , -the sequential record retrieval fills in both the caller's key and -data structures. -If the -.Dv R_NOKEY -flag is specified, the cursor routines are not required to fill in the -key structure. -This permits applications to retrieve records at the end of files -without reading all of the intervening records. -.It Dv R_SNAPSHOT -This flag requires that a snapshot of the file be taken when -.Fn dbopen -is called, instead of permitting any unmodified records to be read -from the original file. -.El -.It Fa cachesize -A suggested maximum size, in bytes, of the memory cache. -This value is -.Em only -advisory, and the access method will allocate more memory rather than -fail. -If -.Fa cachesize -is 0 (no size is specified) a default cache is used. -.It Fa psize -The recno access method stores the in-memory copies of its records -in a btree. -This value is the size (in bytes) of the pages used for nodes in that -tree. -If -.Fa psize -is 0 (no page size is specified) a page size is chosen based on the -underlying file system I/O block size. -See -.Xr btree 3 -for more information. -.It Fa lorder -The byte order for integers in the stored database metadata. -The number should represent the order as an integer; for example, -big endian order would be the number 4,321. -If -.Fa lorder -is 0 (no order is specified) the current host order is used. -.It Fa reclen -The length of a fixed-length record. -.It Fa bval -The delimiting byte to be used to mark the end of a record for -variable-length records, and the pad character for fixed-length -records. -If no value is specified, newlines -.Pq Dq \en -are used to mark the end of variable-length records and fixed-length -records are padded with spaces. -.It Fa bfname -The recno access method stores the in-memory copies of its records -in a btree. -If bfname is -.No non- Ns Dv NULL , -it specifies the name of the btree file, as if specified as the file -name for a -.Fn dbopen -of a btree file. -.El -.Pp -The data part of the key/data pair used by the recno access method -is the same as other access methods. -The key is different. -The -.Fa data -field of the key should be a pointer to a memory location of type -recno_t, as defined in the -.In db.h -include file. -This type is normally the largest unsigned integral type available to -the implementation. -The -.Fa size -field of the key should be the size of that type. -.Pp -Because there can be no meta-data associated with the underlying -recno access method files, any changes made to the default values -(e.g., fixed record length or byte separator value) must be explicitly -specified each time the file is opened. -.Pp -In the interface specified by -.Fn dbopen , -using the -.Fa put -interface to create a new record will cause the creation of multiple, -empty records if the record number is more than one greater than the -largest record currently in the database. -.Sh ERRORS -The -.Nm -access method routines may fail and set -.Va errno -for any of the errors specified for the library routine -.Xr dbopen 3 -or the following: -.Bl -tag -width Er -.It Er EINVAL -An attempt was made to add a record to a fixed-length database that -was too large to fit. -.El -.Sh SEE ALSO -.Xr btree 3 , -.Xr dbopen 3 , -.Xr hash 3 , -.Xr mpool 3 -.Pp -.Rs -.%T "Document Processing in a Relational Database System" -.%A Michael Stonebraker -.%A Heidi Stettner -.%A Joseph Kalash -.%A Antonin Guttman -.%A Nadene Lynn -.%J Memorandum No. UCB/ERL M82/32 -.%D May 1982 -.Re -.Sh BUGS -Only big and little endian byte order is supported. diff --git a/lib/libc/db/mpool/Makefile.inc b/lib/libc/db/mpool/Makefile.inc deleted file mode 100644 index c9320fb0a..000000000 --- a/lib/libc/db/mpool/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 1995/02/27 13:23:53 cgd Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/mpool - -SRCS+= mpool.c diff --git a/lib/libc/db/mpool/mpool.c b/lib/libc/db/mpool/mpool.c deleted file mode 100644 index 020c53770..000000000 --- a/lib/libc/db/mpool/mpool.c +++ /dev/null @@ -1,461 +0,0 @@ -/* $NetBSD: mpool.c,v 1.21 2013/12/14 18:04:00 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: mpool.c,v 1.21 2013/12/14 18:04:00 christos Exp $"); - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include - -#include - -#define __MPOOLINTERFACE_PRIVATE -#include - -#ifdef __weak_alias -__weak_alias(mpool_close,_mpool_close) -__weak_alias(mpool_filter,_mpool_filter) -__weak_alias(mpool_get,_mpool_get) -__weak_alias(mpool_new,_mpool_new) -__weak_alias(mpool_open,_mpool_open) -__weak_alias(mpool_put,_mpool_put) -__weak_alias(mpool_sync,_mpool_sync) -#endif - -static BKT *mpool_bkt(MPOOL *); -static BKT *mpool_look(MPOOL *, pgno_t); -static int mpool_write(MPOOL *, BKT *); - -/* - * mpool_open -- - * Initialize a memory pool. - */ -/*ARGSUSED*/ -MPOOL * -mpool_open(void *key, int fd, pgno_t pagesize, pgno_t maxcache) -{ - struct stat sb; - MPOOL *mp; - int entry; - - /* - * Get information about the file. - * - * XXX - * We don't currently handle pipes, although we should. - */ - if (fstat(fd, &sb)) - return NULL; - if (!S_ISREG(sb.st_mode)) { - errno = ESPIPE; - return NULL; - } - - /* Allocate and initialize the MPOOL cookie. */ - if ((mp = calloc(1, sizeof(*mp))) == NULL) - return (NULL); - TAILQ_INIT(&mp->lqh); - for (entry = 0; entry < HASHSIZE; ++entry) - TAILQ_INIT(&mp->hqh[entry]); - mp->maxcache = maxcache; - mp->npages = (pgno_t)(sb.st_size / pagesize); - mp->pagesize = pagesize; - mp->fd = fd; - return mp; -} - -/* - * mpool_filter -- - * Initialize input/output filters. - */ -void -mpool_filter(MPOOL *mp, void (*pgin)(void *, pgno_t, void *), - void (*pgout)(void *, pgno_t, void *), void *pgcookie) -{ - mp->pgin = pgin; - mp->pgout = pgout; - mp->pgcookie = pgcookie; -} - -/* - * mpool_new -- - * Get a new page of memory. - */ -void * -mpool_new( MPOOL *mp, pgno_t *pgnoaddr) -{ - struct _hqh *head; - BKT *bp; - - if (mp->npages == MAX_PAGE_NUMBER) { - (void)fprintf(stderr, "mpool_new: page allocation overflow.\n"); - abort(); - } -#ifdef STATISTICS - ++mp->pagenew; -#endif - /* - * Get a BKT from the cache. Assign a new page number, attach - * it to the head of the hash chain, the tail of the lru chain, - * and return. - */ - if ((bp = mpool_bkt(mp)) == NULL) - return NULL; - *pgnoaddr = bp->pgno = mp->npages++; - bp->flags = MPOOL_PINNED; - - head = &mp->hqh[HASHKEY(bp->pgno)]; - TAILQ_INSERT_HEAD(head, bp, hq); - TAILQ_INSERT_TAIL(&mp->lqh, bp, q); - return bp->page; -} - -/* - * mpool_get - * Get a page. - */ -/*ARGSUSED*/ -void * -mpool_get(MPOOL *mp, pgno_t pgno, u_int flags) -{ - struct _hqh *head; - BKT *bp; - off_t off; - ssize_t nr; - - /* Check for attempt to retrieve a non-existent page. */ - if (pgno >= mp->npages) { - errno = EINVAL; - return NULL; - } - -#ifdef STATISTICS - ++mp->pageget; -#endif - - /* Check for a page that is cached. */ - if ((bp = mpool_look(mp, pgno)) != NULL) { -#ifdef DEBUG - if (bp->flags & MPOOL_PINNED) { - (void)fprintf(stderr, - "mpool_get: page %d already pinned\n", bp->pgno); - abort(); - } -#endif - /* - * Move the page to the head of the hash chain and the tail - * of the lru chain. - */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - TAILQ_REMOVE(head, bp, hq); - TAILQ_INSERT_HEAD(head, bp, hq); - TAILQ_REMOVE(&mp->lqh, bp, q); - TAILQ_INSERT_TAIL(&mp->lqh, bp, q); - - /* Return a pinned page. */ - bp->flags |= MPOOL_PINNED; - return bp->page; - } - - /* Get a page from the cache. */ - if ((bp = mpool_bkt(mp)) == NULL) - return NULL; - - /* Read in the contents. */ -#ifdef STATISTICS - ++mp->pageread; -#endif - off = mp->pagesize * pgno; - if ((nr = pread(mp->fd, bp->page, (size_t)mp->pagesize, off)) != (int)mp->pagesize) { - if (nr >= 0) - errno = EFTYPE; - return NULL; - } - - /* Set the page number, pin the page. */ - bp->pgno = pgno; - bp->flags = MPOOL_PINNED; - - /* - * Add the page to the head of the hash chain and the tail - * of the lru chain. - */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - TAILQ_INSERT_HEAD(head, bp, hq); - TAILQ_INSERT_TAIL(&mp->lqh, bp, q); - - /* Run through the user's filter. */ - if (mp->pgin != NULL) - (mp->pgin)(mp->pgcookie, bp->pgno, bp->page); - - return bp->page; -} - -/* - * mpool_put - * Return a page. - */ -/*ARGSUSED*/ -int -mpool_put(MPOOL *mp, void *page, u_int flags) -{ - BKT *bp; - -#ifdef STATISTICS - ++mp->pageput; -#endif - bp = (void *)((intptr_t)page - sizeof(BKT)); -#ifdef DEBUG - if (!(bp->flags & MPOOL_PINNED)) { - (void)fprintf(stderr, - "mpool_put: page %d not pinned\n", bp->pgno); - abort(); - } -#endif - bp->flags &= ~MPOOL_PINNED; - bp->flags |= flags & MPOOL_DIRTY; - return (RET_SUCCESS); -} - -/* - * mpool_close - * Close the buffer pool. - */ -int -mpool_close(MPOOL *mp) -{ - BKT *bp; - - /* Free up any space allocated to the lru pages. */ - while (!TAILQ_EMPTY(&mp->lqh)) { - bp = TAILQ_FIRST(&mp->lqh); - TAILQ_REMOVE(&mp->lqh, bp, q); - free(bp); - } - - /* Free the MPOOL cookie. */ - free(mp); - return RET_SUCCESS; -} - -/* - * mpool_sync - * Sync the pool to disk. - */ -int -mpool_sync(MPOOL *mp) -{ - BKT *bp; - - /* Walk the lru chain, flushing any dirty pages to disk. */ - TAILQ_FOREACH(bp, &mp->lqh, q) - if (bp->flags & MPOOL_DIRTY && - mpool_write(mp, bp) == RET_ERROR) - return RET_ERROR; - - /* Sync the file descriptor. */ - return fsync(mp->fd) ? RET_ERROR : RET_SUCCESS; -} - -/* - * mpool_bkt - * Get a page from the cache (or create one). - */ -static BKT * -mpool_bkt(MPOOL *mp) -{ - struct _hqh *head; - BKT *bp; - - /* If under the max cached, always create a new page. */ - if (mp->curcache < mp->maxcache) - goto new; - - /* - * If the cache is max'd out, walk the lru list for a buffer we - * can flush. If we find one, write it (if necessary) and take it - * off any lists. If we don't find anything we grow the cache anyway. - * The cache never shrinks. - */ - TAILQ_FOREACH(bp, &mp->lqh, q) - if (!(bp->flags & MPOOL_PINNED)) { - /* Flush if dirty. */ - if (bp->flags & MPOOL_DIRTY && - mpool_write(mp, bp) == RET_ERROR) - return NULL; -#ifdef STATISTICS - ++mp->pageflush; -#endif - /* Remove from the hash and lru queues. */ - head = &mp->hqh[HASHKEY(bp->pgno)]; - TAILQ_REMOVE(head, bp, hq); - TAILQ_REMOVE(&mp->lqh, bp, q); -#ifdef DEBUG - { - void *spage = bp->page; - (void)memset(bp, 0xff, - (size_t)(sizeof(BKT) + mp->pagesize)); - bp->page = spage; - } -#endif - return bp; - } - -new: if ((bp = calloc(1, (size_t)(sizeof(BKT) + mp->pagesize))) == NULL) - return NULL; -#ifdef STATISTICS - ++mp->pagealloc; -#endif -#if defined(DEBUG) || defined(PURIFY) - (void)memset(bp, 0xff, (size_t)(sizeof(BKT) + mp->pagesize)); -#endif - bp->page = (void *)((intptr_t)bp + sizeof(BKT)); - ++mp->curcache; - return bp; -} - -/* - * mpool_write - * Write a page to disk. - */ -static int -mpool_write(MPOOL *mp, BKT *bp) -{ - off_t off; - -#ifdef STATISTICS - ++mp->pagewrite; -#endif - - /* Run through the user's filter. */ - if (mp->pgout) - (mp->pgout)(mp->pgcookie, bp->pgno, bp->page); - - off = mp->pagesize * bp->pgno; - if (pwrite(mp->fd, bp->page, (size_t)mp->pagesize, off) != - (ssize_t)mp->pagesize) - return RET_ERROR; - - /* - * Re-run through the input filter since this page may soon be - * accessed via the cache, and whatever the user's output filter - * did may screw things up if we don't let the input filter - * restore the in-core copy. - */ - if (mp->pgin) - (mp->pgin)(mp->pgcookie, bp->pgno, bp->page); - - bp->flags &= ~MPOOL_DIRTY; - return RET_SUCCESS; -} - -/* - * mpool_look - * Lookup a page in the cache. - */ -static BKT * -mpool_look(MPOOL *mp, pgno_t pgno) -{ - struct _hqh *head; - BKT *bp; - - head = &mp->hqh[HASHKEY(pgno)]; - TAILQ_FOREACH(bp, head, hq) - if (bp->pgno == pgno) { -#ifdef STATISTICS - ++mp->cachehit; -#endif - return bp; - } -#ifdef STATISTICS - ++mp->cachemiss; -#endif - return NULL; -} - -#ifdef STATISTICS -/* - * mpool_stat - * Print out cache statistics. - */ -void -mpool_stat(mp) - MPOOL *mp; -{ - BKT *bp; - int cnt; - const char *sep; - - (void)fprintf(stderr, "%lu pages in the file\n", (u_long)mp->npages); - (void)fprintf(stderr, - "page size %lu, cacheing %lu pages of %lu page max cache\n", - (u_long)mp->pagesize, (u_long)mp->curcache, (u_long)mp->maxcache); - (void)fprintf(stderr, "%lu page puts, %lu page gets, %lu page new\n", - mp->pageput, mp->pageget, mp->pagenew); - (void)fprintf(stderr, "%lu page allocs, %lu page flushes\n", - mp->pagealloc, mp->pageflush); - if (mp->cachehit + mp->cachemiss) - (void)fprintf(stderr, - "%.0f%% cache hit rate (%lu hits, %lu misses)\n", - ((double)mp->cachehit / (mp->cachehit + mp->cachemiss)) - * 100, mp->cachehit, mp->cachemiss); - (void)fprintf(stderr, "%lu page reads, %lu page writes\n", - mp->pageread, mp->pagewrite); - - sep = ""; - cnt = 0; - TAILQ_FOREACH(bp, &mp->lqh, q) { - (void)fprintf(stderr, "%s%d", sep, bp->pgno); - if (bp->flags & MPOOL_DIRTY) - (void)fprintf(stderr, "d"); - if (bp->flags & MPOOL_PINNED) - (void)fprintf(stderr, "P"); - if (++cnt == 10) { - sep = "\n"; - cnt = 0; - } else - sep = ", "; - - } - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/lib/libc/db/recno/Makefile.inc b/lib/libc/db/recno/Makefile.inc deleted file mode 100644 index e7f78f4ce..000000000 --- a/lib/libc/db/recno/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 1996/05/03 21:38:43 cgd Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -.PATH: ${.CURDIR}/db/recno - -SRCS+= rec_close.c rec_delete.c rec_get.c rec_open.c rec_put.c rec_search.c \ - rec_seq.c rec_utils.c diff --git a/lib/libc/db/recno/extern.h b/lib/libc/db/recno/extern.h deleted file mode 100644 index f73c83de3..000000000 --- a/lib/libc/db/recno/extern.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: extern.h,v 1.8 2008/08/26 21:18:38 joerg Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)extern.h 8.3 (Berkeley) 6/4/94 - */ - -#include "../btree/extern.h" - -int __rec_close(DB *); -int __rec_delete(const DB *, const DBT *, u_int); -int __rec_dleaf(BTREE *, PAGE *, uint32_t); -int __rec_fd(const DB *); -int __rec_fmap(BTREE *, recno_t); -int __rec_fout(BTREE *); -int __rec_fpipe(BTREE *, recno_t); -int __rec_get(const DB *, const DBT *, DBT *, u_int); -int __rec_iput(BTREE *, recno_t, const DBT *, u_int); -int __rec_put(const DB *dbp, DBT *, const DBT *, u_int); -int __rec_ret(BTREE *, EPG *, recno_t, DBT *, DBT *); -EPG *__rec_search(BTREE *, recno_t, enum SRCHOP); -int __rec_seq(const DB *, DBT *, DBT *, u_int); -int __rec_sync(const DB *, u_int); -int __rec_vmap(BTREE *, recno_t); -int __rec_vout(BTREE *); -int __rec_vpipe(BTREE *, recno_t); diff --git a/lib/libc/db/recno/rec_close.c b/lib/libc/db/recno/rec_close.c deleted file mode 100644 index aa3104416..000000000 --- a/lib/libc/db/recno/rec_close.c +++ /dev/null @@ -1,186 +0,0 @@ -/* $NetBSD: rec_close.c,v 1.15 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_close.c,v 1.15 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_CLOSE -- Close a recno tree. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_close(DB *dbp) -{ - BTREE *t; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - if (__rec_sync(dbp, 0) == RET_ERROR) - return (RET_ERROR); - - /* Committed to closing. */ - status = RET_SUCCESS; - if (F_ISSET(t, R_MEMMAPPED) && munmap(t->bt_smap, t->bt_msize)) - status = RET_ERROR; - - if (!F_ISSET(t, R_INMEM)) { - if (F_ISSET(t, R_CLOSEFP)) { - if (fclose(t->bt_rfp)) - status = RET_ERROR; - } else { - if (close(t->bt_rfd)) - status = RET_ERROR; - } - } - - if (__bt_close(dbp) == RET_ERROR) - status = RET_ERROR; - - return (status); -} - -/* - * __REC_SYNC -- sync the recno tree to disk. - * - * Parameters: - * dbp: pointer to access method - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_sync(const DB *dbp, u_int flags) -{ - struct iovec iov[2]; - BTREE *t; - DBT data, key; - off_t off; - recno_t scursor, trec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - if (flags == R_RECNOSYNC) - return (__bt_sync(dbp, 0)); - - if (F_ISSET(t, R_RDONLY | R_INMEM) || !F_ISSET(t, R_MODIFIED)) - return (RET_SUCCESS); - - /* Read any remaining records into the tree. */ - if (!F_ISSET(t, R_EOF) && t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - return (RET_ERROR); - - /* Rewind the file descriptor. */ - if (lseek(t->bt_rfd, (off_t)0, SEEK_SET) != 0) - return (RET_ERROR); - - /* Save the cursor. */ - scursor = t->bt_cursor.rcursor; - - key.size = sizeof(recno_t); - key.data = &trec; - - if (F_ISSET(t, R_FIXLEN)) { - /* - * We assume that fixed length records are all fixed length. - * Any that aren't are either EINVAL'd or corrected by the - * record put code. - */ - status = (dbp->seq)(dbp, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - if (write(t->bt_rfd, data.data, data.size) != - (ssize_t) data.size) - return (RET_ERROR); - status = (dbp->seq)(dbp, &key, &data, R_NEXT); - } - } else { - iov[1].iov_base = &t->bt_bval; - iov[1].iov_len = 1; - - status = (dbp->seq)(dbp, &key, &data, R_FIRST); - while (status == RET_SUCCESS) { - iov[0].iov_base = data.data; - iov[0].iov_len = data.size; - if (writev(t->bt_rfd, iov, 2) != - (ssize_t) (data.size + 1)) - return (RET_ERROR); - status = (dbp->seq)(dbp, &key, &data, R_NEXT); - } - } - - /* Restore the cursor. */ - t->bt_cursor.rcursor = scursor; - - if (status == RET_ERROR) - return (RET_ERROR); - if ((off = lseek(t->bt_rfd, (off_t)0, SEEK_CUR)) == -1) - return (RET_ERROR); - if (ftruncate(t->bt_rfd, off)) - return (RET_ERROR); - F_CLR(t, R_MODIFIED); - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_delete.c b/lib/libc/db/recno/rec_delete.c deleted file mode 100644 index a9dea5767..000000000 --- a/lib/libc/db/recno/rec_delete.c +++ /dev/null @@ -1,197 +0,0 @@ -/* $NetBSD: rec_delete.c,v 1.17 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_delete.c,v 1.17 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -static int rec_rdelete(BTREE *, recno_t); - -/* - * __REC_DELETE -- Delete the item(s) referenced by a key. - * - * Parameters: - * dbp: pointer to access method - * key: key to delete - * flags: R_CURSOR if deleting what the cursor references - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__rec_delete(const DB *dbp, const DBT *key, u_int flags) -{ - BTREE *t; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - switch(flags) { - case 0: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - if (nrec > t->bt_nrecs) - return (RET_SPECIAL); - --nrec; - status = rec_rdelete(t, nrec); - break; - case R_CURSOR: - if (!F_ISSET(&t->bt_cursor, CURS_INIT)) - goto einval; - if (t->bt_nrecs == 0) - return (RET_SPECIAL); - status = rec_rdelete(t, t->bt_cursor.rcursor - 1); - if (status == RET_SUCCESS) - --t->bt_cursor.rcursor; - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (status == RET_SUCCESS) - F_SET(t, B_MODIFIED | R_MODIFIED); - return (status); -} - -/* - * REC_RDELETE -- Delete the data matching the specified key. - * - * Parameters: - * tree: tree - * nrec: record to delete - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -static int -rec_rdelete(BTREE *t, recno_t nrec) -{ - EPG *e; - PAGE *h; - int status; - - /* Find the record; __rec_search pins the page. */ - if ((e = __rec_search(t, nrec, SDELETE)) == NULL) - return (RET_ERROR); - - /* Delete the record. */ - h = e->page; - status = __rec_dleaf(t, h, (uint32_t)e->index); - if (status != RET_SUCCESS) { - mpool_put(t->bt_mp, h, 0); - return (status); - } - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - return (RET_SUCCESS); -} - -/* - * __REC_DLEAF -- Delete a single record from a recno leaf page. - * - * Parameters: - * t: tree - * index: index on current page to delete - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_dleaf(BTREE *t, PAGE *h, uint32_t idx) -{ - RLEAF *rl; - indx_t *ip, cnt, offset; - uint32_t nbytes; - char *from; - void *to; - size_t temp; - - /* - * Delete a record from a recno leaf page. Internal records are never - * deleted from internal pages, regardless of the records that caused - * them to be added being deleted. Pages made empty by deletion are - * not reclaimed. They are, however, made available for reuse. - * - * Pack the remaining entries at the end of the page, shift the indices - * down, overwriting the deleted record and its index. If the record - * uses overflow pages, make them available for reuse. - */ - to = rl = GETRLEAF(h, idx); - if (rl->flags & P_BIGDATA && __ovfl_delete(t, rl->bytes) == RET_ERROR) - return (RET_ERROR); - nbytes = NRLEAF(rl); - - /* - * Compress the key/data pairs. Compress and adjust the [BR]LEAF - * offsets. Reset the headers. - */ - from = (char *)(void *)h + h->upper; - memmove(from + nbytes, from, (size_t)((char *)to - from)); - h->upper += nbytes; - - offset = h->linp[idx]; - temp = &h->linp[idx] - (ip = &h->linp[0]); - _DBFIT(temp, uint16_t); - for (cnt = (uint16_t)temp; cnt--; ++ip) - if (ip[0] < offset) - ip[0] += nbytes; - temp = &h->linp[NEXTINDEX(h)] - ip; - _DBFIT(temp, uint16_t); - for (cnt = (uint16_t)temp; --cnt; ++ip) - ip[0] = ip[1] < offset ? ip[1] + nbytes : ip[1]; - h->lower -= sizeof(indx_t); - --t->bt_nrecs; - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_get.c b/lib/libc/db/recno/rec_get.c deleted file mode 100644 index 68144e62b..000000000 --- a/lib/libc/db/recno/rec_get.c +++ /dev/null @@ -1,299 +0,0 @@ -/* $NetBSD: rec_get.c,v 1.18 2013/12/25 19:42:23 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_get.c,v 1.18 2013/12/25 19:42:23 christos Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_GET -- Get a record from the btree. - * - * Parameters: - * dbp: pointer to access method - * key: key to find - * data: data to return - * flag: currently unused - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key not found. - */ -int -__rec_get(const DB *dbp, const DBT *key, DBT *data, u_int flags) -{ - BTREE *t; - EPG *e; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* Get currently doesn't take any flags, and keys of 0 are illegal. */ - if (flags || (nrec = *(recno_t *)key->data) == 0) { - errno = EINVAL; - return (RET_ERROR); - } - - /* - * If we haven't seen this record yet, try to find it in the - * original file. - */ - if (nrec > t->bt_nrecs) { - if (F_ISSET(t, R_EOF | R_INMEM)) - return (RET_SPECIAL); - if ((status = t->bt_irec(t, nrec)) != RET_SUCCESS) - return (status); - } - - --nrec; - if ((e = __rec_search(t, nrec, SEARCH)) == NULL) - return (RET_ERROR); - - status = __rec_ret(t, e, 0, NULL, data); - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} - -/* - * __REC_FPIPE -- Get fixed length records from a pipe. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_fpipe(BTREE *t, recno_t top) -{ - DBT data; - recno_t nrec; - size_t len; - int ch; - uint8_t *p; - - if (t->bt_rdata.size < t->bt_reclen) { - void *np = realloc(t->bt_rdata.data, t->bt_reclen); - if (np == NULL) - return (RET_ERROR); - t->bt_rdata.data = np; - t->bt_rdata.size = t->bt_reclen; - } - data.data = t->bt_rdata.data; - data.size = t->bt_reclen; - - for (nrec = t->bt_nrecs; nrec < top;) { - len = t->bt_reclen; - for (p = t->bt_rdata.data;; *p++ = ch) - if ((ch = getc(t->bt_rfp)) == EOF || !--len) { - if (ch != EOF) - *p = ch; - if (len != 0) - memset(p, t->bt_bval, len); - if (__rec_iput(t, - nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - ++nrec; - break; - } - if (ch == EOF) - break; - } - if (nrec < top) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - return (RET_SUCCESS); -} - -/* - * __REC_VPIPE -- Get variable length records from a pipe. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_vpipe(BTREE *t, recno_t top) -{ - DBT data; - recno_t nrec; - size_t sz; - int bval, ch; - uint8_t *p; - - bval = t->bt_bval; - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - for (p = t->bt_rdata.data, - sz = t->bt_rdata.size;; *p++ = ch, --sz) { - if ((ch = getc(t->bt_rfp)) == EOF || ch == bval) { - data.data = t->bt_rdata.data; - data.size = p - (uint8_t *)t->bt_rdata.data; - if (ch == EOF && data.size == 0) - break; - if (__rec_iput(t, nrec, &data, 0) - != RET_SUCCESS) - return (RET_ERROR); - break; - } - if (sz == 0) { - ptrdiff_t len = p - (uint8_t *)t->bt_rdata.data; - size_t tot = t->bt_rdata.size + (sz = 256); - void *np = realloc(t->bt_rdata.data, tot); - if (np == NULL) - return (RET_ERROR); - t->bt_rdata.size = tot; - t->bt_rdata.data = np; - p = (uint8_t *)t->bt_rdata.data + len; - } - } - if (ch == EOF) - break; - } - if (nrec < top) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - return (RET_SUCCESS); -} - -/* - * __REC_FMAP -- Get fixed length records from a file. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_fmap(BTREE *t, recno_t top) -{ - DBT data; - recno_t nrec; - uint8_t *sp, *ep, *p; - size_t len; - - if (t->bt_rdata.size < t->bt_reclen) { - void *np = realloc(t->bt_rdata.data, t->bt_reclen); - if (np == NULL) - return (RET_ERROR); - t->bt_rdata.data = np; - t->bt_rdata.size = t->bt_reclen; - } - data.data = t->bt_rdata.data; - data.size = t->bt_reclen; - - sp = (uint8_t *)t->bt_cmap; - ep = (uint8_t *)t->bt_emap; - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - if (sp >= ep) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - len = t->bt_reclen; - for (p = t->bt_rdata.data; - sp < ep && len > 0; *p++ = *sp++, --len); - if (len != 0) - memset(p, t->bt_bval, len); - if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - } - t->bt_cmap = (caddr_t)sp; - return (RET_SUCCESS); -} - -/* - * __REC_VMAP -- Get variable length records from a file. - * - * Parameters: - * t: tree - * cnt: records to read - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_vmap(BTREE *t, recno_t top) -{ - DBT data; - uint8_t *sp, *ep; - recno_t nrec; - int bval; - - sp = (uint8_t *)t->bt_cmap; - ep = (uint8_t *)t->bt_emap; - bval = t->bt_bval; - - for (nrec = t->bt_nrecs; nrec < top; ++nrec) { - if (sp >= ep) { - F_SET(t, R_EOF); - return (RET_SPECIAL); - } - for (data.data = sp; sp < ep && *sp != bval; ++sp); - data.size = sp - (uint8_t *)data.data; - if (__rec_iput(t, nrec, &data, 0) != RET_SUCCESS) - return (RET_ERROR); - ++sp; - } - t->bt_cmap = (caddr_t)sp; - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_open.c b/lib/libc/db/recno/rec_open.c deleted file mode 100644 index 5f9de858c..000000000 --- a/lib/libc/db/recno/rec_open.c +++ /dev/null @@ -1,244 +0,0 @@ -/* $NetBSD: rec_open.c,v 1.20 2013/12/01 00:22:48 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Mike Olson. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_open.c,v 1.20 2013/12/01 00:22:48 christos Exp $"); - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -DB * -__rec_open(const char *fname, int flags, mode_t mode, const RECNOINFO *openinfo, - int dflags) -{ - BTREE *t; - BTREEINFO btopeninfo; - DB *dbp; - PAGE *h; - struct stat sb; - int rfd = -1; /* pacify gcc */ - int sverrno; - - dbp = NULL; - /* Open the user's file -- if this fails, we're done. */ - if (fname != NULL) { - if ((rfd = __dbopen(fname, flags, mode, NULL)) == -1) - return NULL; - } - - /* Create a btree in memory (backed by disk). */ - if (openinfo) { - if (openinfo->flags & ~(R_FIXEDLEN | R_NOKEY | R_SNAPSHOT)) - goto einval; - btopeninfo.flags = 0; - btopeninfo.cachesize = openinfo->cachesize; - btopeninfo.maxkeypage = 0; - btopeninfo.minkeypage = 0; - btopeninfo.psize = openinfo->psize; - btopeninfo.compare = NULL; - btopeninfo.prefix = NULL; - btopeninfo.lorder = openinfo->lorder; - dbp = __bt_open(openinfo->bfname, - O_RDWR, S_IRUSR | S_IWUSR, &btopeninfo, dflags); - } else - dbp = __bt_open(NULL, O_RDWR, S_IRUSR | S_IWUSR, NULL, dflags); - if (dbp == NULL) - goto err; - - /* - * Some fields in the tree structure are recno specific. Fill them - * in and make the btree structure look like a recno structure. We - * don't change the bt_ovflsize value, it's close enough and slightly - * bigger. - */ - t = dbp->internal; - if (openinfo) { - if (openinfo->flags & R_FIXEDLEN) { - F_SET(t, R_FIXLEN); - t->bt_reclen = openinfo->reclen; - if (t->bt_reclen == 0) - goto einval; - } - t->bt_bval = openinfo->bval; - } else - t->bt_bval = '\n'; - - F_SET(t, R_RECNO); - if (fname == NULL) - F_SET(t, R_EOF | R_INMEM); - else - t->bt_rfd = rfd; - - if (fname != NULL) { - /* - * In 4.4BSD, stat(2) returns true for ISSOCK on pipes. - * Unfortunately, that's not portable, so we use lseek - * and check the errno values. - */ - errno = 0; - if (lseek(rfd, (off_t)0, SEEK_CUR) == -1 && errno == ESPIPE) { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, R_RDONLY); - break; - default: - goto einval; - } -slow: if ((t->bt_rfp = fdopen(rfd, "r")) == NULL) - goto err; - F_SET(t, R_CLOSEFP); - t->bt_irec = - F_ISSET(t, R_FIXLEN) ? __rec_fpipe : __rec_vpipe; - } else { - switch (flags & O_ACCMODE) { - case O_RDONLY: - F_SET(t, R_RDONLY); - break; - case O_RDWR: - break; - default: - goto einval; - } - - if (fstat(rfd, &sb)) - goto err; - /* - * Kluge -- we'd like to test to see if the file is too - * big to mmap. Since, we don't know what size or type - * off_t's or size_t's are, what the largest unsigned - * integral type is, or what random insanity the local - * C compiler will perpetrate, doing the comparison in - * a portable way is flatly impossible. Hope that mmap - * fails if the file is too large. - */ - if (sb.st_size == 0) - F_SET(t, R_EOF); - else { -#ifdef MMAP_NOT_AVAILABLE - /* - * XXX - * Mmap doesn't work correctly on many current - * systems. In particular, it can fail subtly, - * with cache coherency problems. Don't use it - * for now. - */ - t->bt_msize = sb.st_size; - if ((t->bt_smap = mmap(NULL, t->bt_msize, - PROT_READ, MAP_FILE | MAP_PRIVATE, rfd, - (off_t)0)) == (caddr_t)-1) - goto slow; - t->bt_cmap = t->bt_smap; - t->bt_emap = t->bt_smap + sb.st_size; - t->bt_irec = F_ISSET(t, R_FIXLEN) ? - __rec_fmap : __rec_vmap; - F_SET(t, R_MEMMAPPED); -#else - goto slow; -#endif - } - } - } - - /* Use the recno routines. */ - dbp->close = __rec_close; - dbp->del = __rec_delete; - dbp->fd = __rec_fd; - dbp->get = __rec_get; - dbp->put = __rec_put; - dbp->seq = __rec_seq; - dbp->sync = __rec_sync; - - /* If the root page was created, reset the flags. */ - if ((h = mpool_get(t->bt_mp, P_ROOT, 0)) == NULL) - goto err; - if ((h->flags & P_TYPE) == P_BLEAF) { - F_CLR(h, P_TYPE); - F_SET(h, P_RLEAF); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } else - mpool_put(t->bt_mp, h, 0); - - if (openinfo && openinfo->flags & R_SNAPSHOT && - !F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - goto err; - return (dbp); - -einval: errno = EINVAL; -err: sverrno = errno; - if (dbp != NULL) - (void)__bt_close(dbp); - if (fname != NULL) - (void)close(rfd); - errno = sverrno; - return (NULL); -} - -int -__rec_fd(const DB *dbp) -{ - BTREE *t; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* In-memory database can't have a file descriptor. */ - if (F_ISSET(t, R_INMEM)) { - errno = ENOENT; - return (-1); - } - return (t->bt_rfd); -} diff --git a/lib/libc/db/recno/rec_put.c b/lib/libc/db/recno/rec_put.c deleted file mode 100644 index 3539bd069..000000000 --- a/lib/libc/db/recno/rec_put.c +++ /dev/null @@ -1,282 +0,0 @@ -/* $NetBSD: rec_put.c,v 1.21 2013/12/14 18:04:56 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_put.c,v 1.21 2013/12/14 18:04:56 christos Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_PUT -- Add a recno item to the tree. - * - * Parameters: - * dbp: pointer to access method - * key: key - * data: data - * flag: R_CURSOR, R_IAFTER, R_IBEFORE, R_NOOVERWRITE - * - * Returns: - * RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is - * already in the tree and R_NOOVERWRITE specified. - */ -int -__rec_put(const DB *dbp, DBT *key, const DBT *data, u_int flags) -{ - BTREE *t; - DBT fdata, tdata; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - /* - * If using fixed-length records, and the record is long, return - * EINVAL. If it's short, pad it out. Use the record data return - * memory, it's only short-term. - */ - if (F_ISSET(t, R_FIXLEN) && data->size != t->bt_reclen) { - if (data->size > t->bt_reclen) - goto einval; - - if (t->bt_rdata.size < t->bt_reclen) { - void *np = realloc(t->bt_rdata.data, t->bt_reclen); - if (np == NULL) - return (RET_ERROR); - t->bt_rdata.data = np; - t->bt_rdata.size = t->bt_reclen; - } - memmove(t->bt_rdata.data, data->data, data->size); - memset((char *)t->bt_rdata.data + data->size, - t->bt_bval, t->bt_reclen - data->size); - fdata.data = t->bt_rdata.data; - fdata.size = t->bt_reclen; - } else { - fdata.data = data->data; - fdata.size = data->size; - } - - switch (flags) { - case R_CURSOR: - if (!F_ISSET(&t->bt_cursor, CURS_INIT)) - goto einval; - nrec = t->bt_cursor.rcursor; - break; - case R_SETCURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_IAFTER: - if ((nrec = *(recno_t *)key->data) == 0) { - nrec = 1; - flags = R_IBEFORE; - } - break; - case 0: - case R_IBEFORE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NOOVERWRITE: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - if (nrec <= t->bt_nrecs) - return (RET_SPECIAL); - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - /* - * Make sure that records up to and including the put record are - * already in the database. If skipping records, create empty ones. - */ - if (nrec > t->bt_nrecs) { - if (!F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, nrec) == RET_ERROR) - return (RET_ERROR); - if (nrec > t->bt_nrecs + 1) { - if (F_ISSET(t, R_FIXLEN)) { - if ((tdata.data = malloc(t->bt_reclen)) == NULL) - return (RET_ERROR); - tdata.size = t->bt_reclen; - memset(tdata.data, t->bt_bval, tdata.size); - } else { - tdata.data = NULL; - tdata.size = 0; - } - while (nrec > t->bt_nrecs + 1) - if (__rec_iput(t, - t->bt_nrecs, &tdata, 0) != RET_SUCCESS) - return (RET_ERROR); - if (F_ISSET(t, R_FIXLEN)) - free(tdata.data); - } - } - - if ((status = __rec_iput(t, nrec - 1, &fdata, flags)) != RET_SUCCESS) - return (status); - - switch (flags) { - case R_IAFTER: - nrec++; - break; - case R_SETCURSOR: - t->bt_cursor.rcursor = nrec; - break; - } - - F_SET(t, R_MODIFIED); - return (__rec_ret(t, NULL, nrec, key, NULL)); -} - -/* - * __REC_IPUT -- Add a recno item to the tree. - * - * Parameters: - * t: tree - * nrec: record number - * data: data - * - * Returns: - * RET_ERROR, RET_SUCCESS - */ -int -__rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags) -{ - DBT tdata; - EPG *e; - PAGE *h; - indx_t idx, nxtindex; - pgno_t pg; - uint32_t nbytes; - int dflags, status; - char *dest, db[NOVFLSIZE]; - - /* - * If the data won't fit on a page, store it on indirect pages. - * - * XXX - * If the insert fails later on, these pages aren't recovered. - */ - if (data->size > t->bt_ovflsize) { - if (__ovfl_put(t, data, &pg) == RET_ERROR) - return (RET_ERROR); - tdata.data = db; - tdata.size = NOVFLSIZE; - memcpy(db, &pg, sizeof(pg)); - _DBFIT(data->size, uint32_t); - *(uint32_t *)(void *)(db + sizeof(pgno_t)) = - (uint32_t)data->size; - dflags = P_BIGDATA; - data = &tdata; - } else - dflags = 0; - - /* __rec_search pins the returned page. */ - if ((e = __rec_search(t, nrec, - nrec > t->bt_nrecs || flags == R_IAFTER || flags == R_IBEFORE ? - SINSERT : SEARCH)) == NULL) - return (RET_ERROR); - - h = e->page; - idx = e->index; - - /* - * Add the specified key/data pair to the tree. The R_IAFTER and - * R_IBEFORE flags insert the key after/before the specified key. - * - * Pages are split as required. - */ - switch (flags) { - case R_IAFTER: - ++idx; - break; - case R_IBEFORE: - break; - default: - if (nrec < t->bt_nrecs && - __rec_dleaf(t, h, (uint32_t)idx) == RET_ERROR) { - mpool_put(t->bt_mp, h, 0); - return (RET_ERROR); - } - break; - } - - /* - * If not enough room, split the page. The split code will insert - * the key and data and unpin the current page. If inserting into - * the offset array, shift the pointers up. - */ - nbytes = NRLEAFDBT(data->size); - if ((uint32_t) (h->upper - h->lower) < nbytes + sizeof(indx_t)) { - status = __bt_split(t, h, NULL, data, dflags, nbytes, - (uint32_t)idx); - if (status == RET_SUCCESS) - ++t->bt_nrecs; - return (status); - } - - if (idx < (nxtindex = NEXTINDEX(h))) - memmove(h->linp + idx + 1, h->linp + idx, - (nxtindex - idx) * sizeof(indx_t)); - h->lower += sizeof(indx_t); - - h->linp[idx] = h->upper -= nbytes; - dest = (char *)(void *)h + h->upper; - WR_RLEAF(dest, data, dflags); - - ++t->bt_nrecs; - F_SET(t, B_MODIFIED); - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/rec_search.c b/lib/libc/db/recno/rec_search.c deleted file mode 100644 index 1238c8db3..000000000 --- a/lib/libc/db/recno/rec_search.c +++ /dev/null @@ -1,126 +0,0 @@ -/* $NetBSD: rec_search.c,v 1.14 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_search.c,v 1.14 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEARCH -- Search a btree for a key. - * - * Parameters: - * t: tree to search - * recno: key to find - * op: search operation - * - * Returns: - * EPG for matching record, if any, or the EPG for the location of the - * key, if it were inserted into the tree. - * - * Returns: - * The EPG for matching record, if any, or the EPG for the location - * of the key, if it were inserted into the tree, is entered into - * the bt_cur field of the tree. A pointer to the field is returned. - */ -EPG * -__rec_search(BTREE *t, recno_t recno, enum SRCHOP op) -{ - indx_t idx; - PAGE *h; - EPGNO *parent; - RINTERNAL *r; - pgno_t pg; - indx_t top; - recno_t total; - int sverrno; - - BT_CLR(t); - for (pg = P_ROOT, total = 0;;) { - if ((h = mpool_get(t->bt_mp, pg, 0)) == NULL) - goto err; - if (h->flags & P_RLEAF) { - t->bt_cur.page = h; - t->bt_cur.index = recno - total; - return (&t->bt_cur); - } - for (idx = 0, top = NEXTINDEX(h);;) { - r = GETRINTERNAL(h, idx); - if (++idx == top || total + r->nrecs > recno) - break; - total += r->nrecs; - } - - BT_PUSH(t, pg, idx - 1); - - pg = r->pgno; - switch (op) { - case SDELETE: - --GETRINTERNAL(h, (idx - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SINSERT: - ++GETRINTERNAL(h, (idx - 1))->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - break; - case SEARCH: - mpool_put(t->bt_mp, h, 0); - break; - } - - } - /* Try and recover the tree. */ -err: sverrno = errno; - if (op != SEARCH) - while ((parent = BT_POP(t)) != NULL) { - if ((h = mpool_get(t->bt_mp, parent->pgno, 0)) == NULL) - break; - if (op == SINSERT) - --GETRINTERNAL(h, parent->index)->nrecs; - else - ++GETRINTERNAL(h, parent->index)->nrecs; - mpool_put(t->bt_mp, h, MPOOL_DIRTY); - } - errno = sverrno; - return (NULL); -} diff --git a/lib/libc/db/recno/rec_seq.c b/lib/libc/db/recno/rec_seq.c deleted file mode 100644 index 3b1da48cc..000000000 --- a/lib/libc/db/recno/rec_seq.c +++ /dev/null @@ -1,131 +0,0 @@ -/* $NetBSD: rec_seq.c,v 1.14 2008/09/11 12:58:00 joerg Exp $ */ - -/*- - * Copyright (c) 1991, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_seq.c,v 1.14 2008/09/11 12:58:00 joerg Exp $"); - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __REC_SEQ -- Recno sequential scan interface. - * - * Parameters: - * dbp: pointer to access method - * key: key for positioning and return value - * data: data return value - * flags: R_CURSOR, R_FIRST, R_LAST, R_NEXT, R_PREV. - * - * Returns: - * RET_ERROR, RET_SUCCESS or RET_SPECIAL if there's no next key. - */ -int -__rec_seq(const DB *dbp, DBT *key, DBT *data, u_int flags) -{ - BTREE *t; - EPG *e; - recno_t nrec; - int status; - - t = dbp->internal; - - /* Toss any page pinned across calls. */ - if (t->bt_pinned != NULL) { - mpool_put(t->bt_mp, t->bt_pinned, 0); - t->bt_pinned = NULL; - } - - switch(flags) { - case R_CURSOR: - if ((nrec = *(recno_t *)key->data) == 0) - goto einval; - break; - case R_NEXT: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - nrec = t->bt_cursor.rcursor + 1; - break; - } - /* FALLTHROUGH */ - case R_FIRST: - nrec = 1; - break; - case R_PREV: - if (F_ISSET(&t->bt_cursor, CURS_INIT)) { - if ((nrec = t->bt_cursor.rcursor - 1) == 0) - return (RET_SPECIAL); - break; - } - /* FALLTHROUGH */ - case R_LAST: - if (!F_ISSET(t, R_EOF | R_INMEM) && - t->bt_irec(t, MAX_REC_NUMBER) == RET_ERROR) - return (RET_ERROR); - nrec = t->bt_nrecs; - break; - default: -einval: errno = EINVAL; - return (RET_ERROR); - } - - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) { - if (!F_ISSET(t, R_EOF | R_INMEM) && - (status = t->bt_irec(t, nrec)) != RET_SUCCESS) - return (status); - if (t->bt_nrecs == 0 || nrec > t->bt_nrecs) - return (RET_SPECIAL); - } - - if ((e = __rec_search(t, nrec - 1, SEARCH)) == NULL) - return (RET_ERROR); - - F_SET(&t->bt_cursor, CURS_INIT); - t->bt_cursor.rcursor = nrec; - - status = __rec_ret(t, e, nrec, key, data); - if (F_ISSET(t, B_DB_LOCK)) - mpool_put(t->bt_mp, e->page, 0); - else - t->bt_pinned = e->page; - return (status); -} diff --git a/lib/libc/db/recno/rec_utils.c b/lib/libc/db/recno/rec_utils.c deleted file mode 100644 index c4b59e3d8..000000000 --- a/lib/libc/db/recno/rec_utils.c +++ /dev/null @@ -1,116 +0,0 @@ -/* $NetBSD: rec_utils.c,v 1.14 2013/12/14 18:04:56 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -__RCSID("$NetBSD: rec_utils.c,v 1.14 2013/12/14 18:04:56 christos Exp $"); - -#include - -#include -#include -#include -#include - -#include -#include "recno.h" - -/* - * __rec_ret -- - * Build return data. - * - * Parameters: - * t: tree - * e: key/data pair to be returned - * nrec: record number - * key: user's key structure - * data: user's data structure - * - * Returns: - * RET_SUCCESS, RET_ERROR. - */ -int -__rec_ret(BTREE *t, EPG *e, recno_t nrec, DBT *key, DBT *data) -{ - RLEAF *rl; - void *p; - - if (key == NULL) - goto dataonly; - - /* We have to copy the key, it's not on the page. */ - if (sizeof(nrec) > t->bt_rkey.size) { - p = realloc(t->bt_rkey.data, sizeof(nrec)); - if (p == NULL) - return (RET_ERROR); - t->bt_rkey.data = p; - t->bt_rkey.size = sizeof(nrec); - } - memmove(t->bt_rkey.data, &nrec, sizeof(nrec)); - key->size = sizeof(nrec); - key->data = t->bt_rkey.data; - -dataonly: - if (data == NULL) - return (RET_SUCCESS); - - /* - * We must copy big keys/data to make them contigous. Otherwise, - * leave the page pinned and don't copy unless the user specified - * concurrent access. - */ - rl = GETRLEAF(e->page, e->index); - if (rl->flags & P_BIGDATA) { - if (__ovfl_get(t, rl->bytes, - &data->size, &t->bt_rdata.data, &t->bt_rdata.size)) - return (RET_ERROR); - data->data = t->bt_rdata.data; - } else if (F_ISSET(t, B_DB_LOCK)) { - /* Use +1 in case the first record retrieved is 0 length. */ - if (rl->dsize + 1 > t->bt_rdata.size) { - p = realloc(t->bt_rdata.data, rl->dsize + 1); - if (p == NULL) - return (RET_ERROR); - t->bt_rdata.data = p; - t->bt_rdata.size = rl->dsize + 1; - } - memmove(t->bt_rdata.data, rl->bytes, rl->dsize); - data->size = rl->dsize; - data->data = t->bt_rdata.data; - } else { - data->size = rl->dsize; - data->data = rl->bytes; - } - return (RET_SUCCESS); -} diff --git a/lib/libc/db/recno/recno.h b/lib/libc/db/recno/recno.h deleted file mode 100644 index 7ac0d176a..000000000 --- a/lib/libc/db/recno/recno.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: recno.h,v 1.6 2003/08/07 16:42:44 agc Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)recno.h 8.1 (Berkeley) 6/4/93 - */ - -enum SRCHOP { SDELETE, SINSERT, SEARCH}; /* Rec_search operation. */ - -#include "../btree/btree.h" -#include "extern.h" diff --git a/lib/libc/dlfcn/Makefile.inc b/lib/libc/dlfcn/Makefile.inc deleted file mode 100644 index f9ba7f7c9..000000000 --- a/lib/libc/dlfcn/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.3 2010/07/06 05:59:52 mrg Exp $ - -.PATH: ${.CURDIR}/dlfcn - -CPPFLAGS+= -I${NETBSDSRCDIR}/libexec/ld.elf_so -CPPFLAGS+= -I${.CURDIR}/dlfcn -SRCS+= dlfcn_elf.c diff --git a/lib/libc/dlfcn/dlfcn_elf.c b/lib/libc/dlfcn/dlfcn_elf.c deleted file mode 100644 index 977fc9887..000000000 --- a/lib/libc/dlfcn/dlfcn_elf.c +++ /dev/null @@ -1,207 +0,0 @@ -/* $NetBSD: dlfcn_elf.c,v 1.13 2012/06/24 15:26:03 christos Exp $ */ - -/* - * Copyright (c) 2000 Takuya SHIOZAKI - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dlfcn_elf.c,v 1.13 2012/06/24 15:26:03 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#undef dlopen -#undef dlclose -#undef dlsym -#undef dlerror -#undef dladdr -#undef dfinfo - -#define dlopen ___dlopen -#define dlclose ___dlclose -#define dlsym ___dlsym -#define dlvsym ___dlvsym -#define dlerror ___dlerror -#define dladdr ___dladdr -#define dlinfo ___dlinfo -#define dl_iterate_phdr ___dl_iterate_phdr - -#define ELFSIZE ARCH_ELFSIZE -#include "rtld.h" - -#ifdef __weak_alias -__weak_alias(dlopen,___dlopen) -__weak_alias(dlclose,___dlclose) -__weak_alias(dlsym,___dlsym) -__weak_alias(dlvsym,___dlvsym) -__weak_alias(dlerror,___dlerror) -__weak_alias(dladdr,___dladdr) -__weak_alias(dlinfo,___dlinfo) -__weak_alias(dl_iterate_phdr,___dl_iterate_phdr) - -__weak_alias(__dlopen,___dlopen) -__weak_alias(__dlclose,___dlclose) -__weak_alias(__dlsym,___dlsym) -__weak_alias(__dlvsym,___dlvsym) -__weak_alias(__dlerror,___dlerror) -__weak_alias(__dladdr,___dladdr) -__weak_alias(__dlinfo,___dlinfo) -__weak_alias(__dl_iterate_phdr,___dl_iterate_phdr) -#endif - -/* - * For ELF, the dynamic linker directly resolves references to its - * services to functions inside the dynamic linker itself. These - * weak-symbol stubs are necessary so that "ld" won't complain about - * undefined symbols. The stubs are executed only when the program is - * linked statically, or when a given service isn't implemented in the - * dynamic linker. They must return an error if called, and they must - * be weak symbols so that the dynamic linker can override them. - */ - -static char dlfcn_error[] = "Service unavailable"; - -/*ARGSUSED*/ -void * -dlopen(const char *name, int mode) -{ - - return NULL; -} - -/*ARGSUSED*/ -int -dlclose(void *fd) -{ - - return -1; -} - -/*ARGSUSED*/ -void * -dlsym(void *handle, const char *name) -{ - - return NULL; -} - -/*ARGSUSED*/ -void * -dlvsym(void *handle, const char *name, const char *version) -{ - - return NULL; -} - -/*ARGSUSED*/ -__aconst char * -dlerror(void) -{ - - return dlfcn_error; -} - -/*ARGSUSED*/ -int -dladdr(const void *addr, Dl_info *dli) -{ - - return 0; -} - -/*ARGSUSED*/ -int -dlinfo(void *handle, int req, void *v) -{ - - return -1; -} - -static const char *dlpi_name; -static Elf_Addr dlpi_addr; -static const Elf_Phdr *dlpi_phdr; -static Elf_Half dlpi_phnum; - -static void -dl_iterate_phdr_setup(void) -{ - const AuxInfo *aux; - - _DIAGASSERT(_dlauxinfo() != NULL); - - for (aux = _dlauxinfo(); aux->a_type != AT_NULL; ++aux) { - switch (aux->a_type) { - case AT_BASE: - dlpi_addr = aux->a_v; - break; - case AT_PHDR: - dlpi_phdr = (void *)aux->a_v; - break; - case AT_PHNUM: - _DIAGASSERT(__type_fit(Elf_Half, aux->a_v)); - dlpi_phnum = (Elf_Half)aux->a_v; - break; - case AT_SUN_EXECNAME: - dlpi_name = (void *)aux->a_v; - break; - } - } -} - -/*ARGSUSED*/ -int -dl_iterate_phdr(int (*callback)(struct dl_phdr_info *, size_t, void *), - void *data) -{ - static bool setup_done; - struct dl_phdr_info phdr_info; - - if (!setup_done) { - /* - * This can race on the first call to dl_iterate_phdr. - * dl_iterate_phdr_setup only touches field of pointer size - * and smaller and such stores are atomic. - */ - dl_iterate_phdr_setup(); -#if !defined(__minix) - membar_producer(); -#endif /* !defined(__minix) */ - setup_done = true; - } - - memset(&phdr_info, 0, sizeof(phdr_info)); - phdr_info.dlpi_addr = dlpi_addr; - phdr_info.dlpi_phdr = dlpi_phdr; - phdr_info.dlpi_phnum = dlpi_phnum; - phdr_info.dlpi_name = dlpi_name; - - return callback(&phdr_info, sizeof(phdr_info), data); -} diff --git a/lib/libc/gdtoa/Makefile.inc b/lib/libc/gdtoa/Makefile.inc deleted file mode 100644 index 5e966f572..000000000 --- a/lib/libc/gdtoa/Makefile.inc +++ /dev/null @@ -1,44 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.10 2014/01/16 20:31:42 christos Exp $ - -# gdtoa sources -.PATH: ${.CURDIR}/gdtoa -CPPFLAGS+=-I${.CURDIR}/gdtoa -I${.CURDIR}/locale - -CPPFLAGS+=-DNO_FENV_H - -# machine-dependent directory must provide the following: -# arith.h gd_qnan.h -CPPFLAGS+=-I${ARCHDIR}/gdtoa - -# machine-dependent Makefile must define names of modules to use for -# float conversions: -# strtof(): strtof{,_vaxf}.c -# and for long double conversions on platforms with extended-precision -# format, if supported (strtod.c will define an alias otherwise): -# strtold(): strtold_p{x,xL,Q}.c -# helpers: strtop{x,xL,Q}.c -.include "${ARCHDIR}/gdtoa/Makefile.inc" - -# public interfaces -SRCS+= strtod.c - -# private interfaces interfacing to libc -SRCS+= dtoa.c ldtoa.c hdtoa.c gdtoa.c - -.if !defined(__MINIX) -# local locking implementation -SRCS+= gdtoa_locks.c -.endif # !defined(__MINIX) - -# private interfaces -SRCS+= dmisc.c \ - gethex.c gmisc.c \ - hd_init.c hexnan.c \ - misc.c \ - smisc.c strtodg.c sum.c \ - ulp.c - -# XXX no hexadecimal floating-point string conversion for VAX FP yet -.if ${MACHINE_ARCH} != "vax" -SRCS+= strtord.c -.endif diff --git a/lib/libc/gdtoa/README b/lib/libc/gdtoa/README deleted file mode 100644 index 0c034f1bf..000000000 --- a/lib/libc/gdtoa/README +++ /dev/null @@ -1,364 +0,0 @@ -This directory contains source for a library of binary -> decimal -and decimal -> binary conversion routines, for single-, double-, -and extended-precision IEEE binary floating-point arithmetic, and -other IEEE-like binary floating-point, including "double double", -as in - - T. J. Dekker, "A Floating-Point Technique for Extending the - Available Precision", Numer. Math. 18 (1971), pp. 224-242 - -and - - "Inside Macintosh: PowerPC Numerics", Addison-Wesley, 1994 - -The conversion routines use double-precision floating-point arithmetic -and, where necessary, high precision integer arithmetic. The routines -are generalizations of the strtod and dtoa routines described in - - David M. Gay, "Correctly Rounded Binary-Decimal and - Decimal-Binary Conversions", Numerical Analysis Manuscript - No. 90-10, Bell Labs, Murray Hill, 1990; - http://cm.bell-labs.com/cm/cs/what/ampl/REFS/rounding.ps.gz - -(based in part on papers by Clinger and Steele & White: see the -references in the above paper). - -The present conversion routines should be able to use any of IEEE binary, -VAX, or IBM-mainframe double-precision arithmetic internally, but I (dmg) -have so far only had a chance to test them with IEEE double precision -arithmetic. - -The core conversion routines are strtodg for decimal -> binary conversions -and gdtoa for binary -> decimal conversions. These routines operate -on arrays of unsigned 32-bit integers of type ULong, a signed 32-bit -exponent of type Long, and arithmetic characteristics described in -struct FPI; FPI, Long, and ULong are defined in gdtoa.h. File arith.h -is supposed to provide #defines that cause gdtoa.h to define its -types correctly. File arithchk.c is source for a program that -generates a suitable arith.h on all systems where I've been able to -test it. - -The core conversion routines are meant to be called by helper routines -that know details of the particular binary arithmetic of interest and -convert. The present directory provides helper routines for 5 variants -of IEEE binary floating-point arithmetic, each indicated by one or -two letters: - - f IEEE single precision - d IEEE double precision - x IEEE extended precision, as on Intel 80x87 - and software emulations of Motorola 68xxx chips - that do not pad the way the 68xxx does, but - only store 80 bits - xL IEEE extended precision, as on Motorola 68xxx chips - Q quad precision, as on Sun Sparc chips - dd double double, pairs of IEEE double numbers - whose sum is the desired value - -For decimal -> binary conversions, there are three families of -helper routines: one for round-nearest (or the current rounding -mode on IEEE-arithmetic systems that provide the C99 fegetround() -function, if compiled with -DHonor_FLT_ROUNDS): - - strtof - strtod - strtodd - strtopd - strtopf - strtopx - strtopxL - strtopQ - -one with rounding direction specified: - - strtorf - strtord - strtordd - strtorx - strtorxL - strtorQ - -and one for computing an interval (at most one bit wide) that contains -the decimal number: - - strtoIf - strtoId - strtoIdd - strtoIx - strtoIxL - strtoIQ - -The latter call strtoIg, which makes one call on strtodg and adjusts -the result to provide the desired interval. On systems where native -arithmetic can easily make one-ulp adjustments on values in the -desired floating-point format, it might be more efficient to use the -native arithmetic. Routine strtodI is a variant of strtoId that -illustrates one way to do this for IEEE binary double-precision -arithmetic -- but whether this is more efficient remains to be seen. - -Functions strtod and strtof have "natural" return types, float and -double -- strtod is specified by the C standard, and strtof appears -in the stdlib.h of some systems, such as (at least some) Linux systems. -The other functions write their results to their final argument(s): -to the final two argument for the strtoI... (interval) functions, -and to the final argument for the others (strtop... and strtor...). -Where possible, these arguments have "natural" return types (double* -or float*), to permit at least some type checking. In reality, they -are viewed as arrays of ULong (or, for the "x" functions, UShort) -values. On systems where long double is the appropriate type, one can -pass long double* final argument(s) to these routines. The int value -that these routines return is the return value from the call they make -on strtodg; see the enum of possible return values in gdtoa.h. - -Source files g_ddfmt.c, misc.c, smisc.c, strtod.c, strtodg.c, and ulp.c -should use true IEEE double arithmetic (not, e.g., double extended), -at least for storing (and viewing the bits of) the variables declared -"double" within them. - -One detail indicated in struct FPI is whether the target binary -arithmetic departs from the IEEE standard by flushing denormalized -numbers to 0. On systems that do this, the helper routines for -conversion to double-double format (when compiled with -Sudden_Underflow #defined) penalize the bottom of the exponent -range so that they return a nonzero result only when the least -significant bit of the less significant member of the pair of -double values returned can be expressed as a normalized double -value. An alternative would be to drop to 53-bit precision near -the bottom of the exponent range. To get correct rounding, this -would (in general) require two calls on strtodg (one specifying -126-bit arithmetic, then, if necessary, one specifying 53-bit -arithmetic). - -By default, the core routine strtodg and strtod set errno to ERANGE -if the result overflows to +Infinity or underflows to 0. Compile -these routines with NO_ERRNO #defined to inhibit errno assignments. - -Routine strtod is based on netlib's "dtoa.c from fp", and -(f = strtod(s,se)) is more efficient for some conversions than, say, -strtord(s,se,1,&f). Parts of strtod require true IEEE double -arithmetic with the default rounding mode (round-to-nearest) and, on -systems with IEEE extended-precision registers, double-precision -(53-bit) rounding precision. If the machine uses (the equivalent of) -Intel 80x87 arithmetic, the call - _control87(PC_53, MCW_PC); -does this with many compilers. Whether this or another call is -appropriate depends on the compiler; for this to work, it may be -necessary to #include "float.h" or another system-dependent header -file. - -Source file strtodnrp.c gives a strtod that does not require 53-bit -rounding precision on systems (such as Intel IA32 systems) that may -suffer double rounding due to use of extended-precision registers. -For some conversions this variant of strtod is less efficient than the -one in strtod.c when the latter is run with 53-bit rounding precision. - -The values that the strto* routines return for NaNs are determined by -gd_qnan.h, which the makefile generates by running the program whose -source is qnan.c. Note that the rules for distinguishing signaling -from quiet NaNs are system-dependent. For cross-compilation, you need -to determine arith.h and gd_qnan.h suitably, e.g., using the -arithmetic of the target machine. - -C99's hexadecimal floating-point constants are recognized by the -strto* routines (but this feature has not yet been heavily tested). -Compiling with NO_HEX_FP #defined disables this feature. - -When compiled with -DINFNAN_CHECK, the strto* routines recognize C99's -NaN and Infinity syntax. Moreover, unless No_Hex_NaN is #defined, the -strto* routines also recognize C99's NaN(...) syntax: they accept -(case insensitively) strings of the form NaN(x), where x is a string -of hexadecimal digits and spaces; if there is only one string of -hexadecimal digits, it is taken for the fraction bits of the resulting -NaN; if there are two or more strings of hexadecimal digits, each -string is assigned to the next available sequence of 32-bit words of -fractions bits (starting with the most significant), right-aligned in -each sequence. - -For binary -> decimal conversions, I've provided just one family -of helper routines: - - g_ffmt - g_dfmt - g_ddfmt - g_xfmt - g_xLfmt - g_Qfmt - -which do a "%g" style conversion either to a specified number of decimal -places (if their ndig argument is positive), or to the shortest -decimal string that rounds to the given binary floating-point value -(if ndig <= 0). They write into a buffer supplied as an argument -and return either a pointer to the end of the string (a null character) -in the buffer, if the buffer was long enough, or 0. Other forms of -conversion are easily done with the help of gdtoa(), such as %e or %f -style and conversions with direction of rounding specified (so that, if -desired, the decimal value is either >= or <= the binary value). -On IEEE-arithmetic systems that provide the C99 fegetround() function, -if compiled with -DHonor_FLT_ROUNDS, these routines honor the current -rounding mode. - -For an example of more general conversions based on dtoa(), see -netlib's "printf.c from ampl/solvers". - -For double-double -> decimal, g_ddfmt() assumes IEEE-like arithmetic -of precision max(126, #bits(input)) bits, where #bits(input) is the -number of mantissa bits needed to represent the sum of the two double -values in the input. - -The makefile creates a library, gdtoa.a. To use the helper -routines, a program only needs to include gdtoa.h. All the -source files for gdtoa.a include a more extensive gdtoaimp.h; -among other things, gdtoaimp.h has #defines that make "internal" -names end in _D2A. To make a "system" library, one could modify -these #defines to make the names start with __. - -Various comments about possible #defines appear in gdtoaimp.h, -but for most purposes, arith.h should set suitable #defines. - -Systems with preemptive scheduling of multiple threads require some -manual intervention. On such systems, it's necessary to compile -dmisc.c, dtoa.c gdota.c, and misc.c with MULTIPLE_THREADS #defined, -and to provide (or suitably #define) two locks, acquired by -ACQUIRE_DTOA_LOCK(n) and freed by FREE_DTOA_LOCK(n) for n = 0 or 1. -(The second lock, accessed in pow5mult, ensures lazy evaluation of -only one copy of high powers of 5; omitting this lock would introduce -a small probability of wasting memory, but would otherwise be harmless.) -Routines that call dtoa or gdtoa directly must also invoke freedtoa(s) -to free the value s returned by dtoa or gdtoa. It's OK to do so whether -or not MULTIPLE_THREADS is #defined, and the helper g_*fmt routines -listed above all do this indirectly (in gfmt_D2A(), which they all call). - -By default, there is a private pool of memory of length 2000 bytes -for intermediate quantities, and MALLOC (see gdtoaimp.h) is called only -if the private pool does not suffice. 2000 is large enough that MALLOC -is called only under very unusual circumstances (decimal -> binary -conversion of very long strings) for conversions to and from double -precision. For systems with preemptively scheduled multiple threads -or for conversions to extended or quad, it may be appropriate to -#define PRIVATE_MEM nnnn, where nnnn is a suitable value > 2000. -For extended and quad precisions, -DPRIVATE_MEM=20000 is probably -plenty even for many digits at the ends of the exponent range. -Use of the private pool avoids some overhead. - -Directory test provides some test routines. See its README. -I've also tested this stuff (except double double conversions) -with Vern Paxson's testbase program: see - - V. Paxson and W. Kahan, "A Program for Testing IEEE Binary-Decimal - Conversion", manuscript, May 1991, - ftp://ftp.ee.lbl.gov/testbase-report.ps.Z . - -(The same ftp directory has source for testbase.) - -Some system-dependent additions to CFLAGS in the makefile: - - HU-UX: -Aa -Ae - OSF (DEC Unix): -ieee_with_no_inexact - SunOS 4.1x: -DKR_headers -DBad_float_h - -If you want to put this stuff into a shared library and your -operating system requires export lists for shared libraries, -the following would be an appropriate export list: - - dtoa - freedtoa - g_Qfmt - g_ddfmt - g_dfmt - g_ffmt - g_xLfmt - g_xfmt - gdtoa - strtoIQ - strtoId - strtoIdd - strtoIf - strtoIx - strtoIxL - strtod - strtodI - strtodg - strtof - strtopQ - strtopd - strtopdd - strtopf - strtopx - strtopxL - strtorQ - strtord - strtordd - strtorf - strtorx - strtorxL - -When time permits, I (dmg) hope to write in more detail about the -present conversion routines; for now, this README file must suffice. -Meanwhile, if you wish to write helper functions for other kinds of -IEEE-like arithmetic, some explanation of struct FPI and the bits -array may be helpful. Both gdtoa and strtodg operate on a bits array -described by FPI *fpi. The bits array is of type ULong, a 32-bit -unsigned integer type. Floating-point numbers have fpi->nbits bits, -with the least significant 32 bits in bits[0], the next 32 bits in -bits[1], etc. These numbers are regarded as integers multiplied by -2^e (i.e., 2 to the power of the exponent e), where e is the second -argument (be) to gdtoa and is stored in *exp by strtodg. The minimum -and maximum exponent values fpi->emin and fpi->emax for normalized -floating-point numbers reflect this arrangement. For example, the -P754 standard for binary IEEE arithmetic specifies doubles as having -53 bits, with normalized values of the form 1.xxxxx... times 2^(b-1023), -with 52 bits (the x's) and the biased exponent b represented explicitly; -b is an unsigned integer in the range 1 <= b <= 2046 for normalized -finite doubles, b = 0 for denormals, and b = 2047 for Infinities and NaNs. -To turn an IEEE double into the representation used by strtodg and gdtoa, -we multiply 1.xxxx... by 2^52 (to make it an integer) and reduce the -exponent e = (b-1023) by 52: - - fpi->emin = 1 - 1023 - 52 - fpi->emax = 1046 - 1023 - 52 - -In various wrappers for IEEE double, we actually write -53 + 1 rather -than -52, to emphasize that there are 53 bits including one implicit bit. -Field fpi->rounding indicates the desired rounding direction, with -possible values - FPI_Round_zero = toward 0, - FPI_Round_near = unbiased rounding -- the IEEE default, - FPI_Round_up = toward +Infinity, and - FPI_Round_down = toward -Infinity -given in gdtoa.h. - -Field fpi->sudden_underflow indicates whether strtodg should return -denormals or flush them to zero. Normal floating-point numbers have -bit fpi->nbits in the bits array on. Denormals have it off, with -exponent = fpi->emin. Strtodg provides distinct return values for normals -and denormals; see gdtoa.h. - -Compiling g__fmt.c, strtod.c, and strtodg.c with -DUSE_LOCALE causes -the decimal-point character to be taken from the current locale; otherwise -it is '.'. - -Source files dtoa.c and strtod.c in this directory are derived from -netlib's "dtoa.c from fp" and are meant to function equivalently. -When compiled with Honor_FLT_ROUNDS #defined (on systems that provide -FLT_ROUNDS and fegetround() as specified in the C99 standard), they -honor the current rounding mode. Because FLT_ROUNDS is buggy on some -(Linux) systems -- not reflecting calls on fesetround(), as the C99 -standard says it should -- when Honor_FLT_ROUNDS is #defined, the -current rounding mode is obtained from fegetround() rather than from -FLT_ROUNDS, unless Trust_FLT_ROUNDS is also #defined. - -Compile with -DUSE_LOCALE to use the current locale; otherwise -decimal points are assumed to be '.'. With -DUSE_LOCALE, unless -you also compile with -DNO_LOCALE_CACHE, the details about the -current "decimal point" character string are cached and assumed not -to change during the program's execution. - -On machines with a 64-bit long double and perhaps a 113-bit "quad" -type, you can invoke "make Printf" to add Printf (and variants, such -as Fprintf) to gdtoa.a. These are analogs, declared in stdio1.h, of -printf and fprintf, etc. in which %La, %Le, %Lf, and %Lg are for long -double and (if appropriate) %Lqa, %Lqe, %Lqf, and %Lqg are for quad -precision printing. - -Please send comments to David M. Gay (dmg at acm dot org, with " at " -changed at "@" and " dot " changed to "."). diff --git a/lib/libc/gdtoa/arithchk.c b/lib/libc/gdtoa/arithchk.c deleted file mode 100644 index 305aec415..000000000 --- a/lib/libc/gdtoa/arithchk.c +++ /dev/null @@ -1,191 +0,0 @@ -/* $NetBSD: arithchk.c,v 1.4 2012/06/24 15:26:03 christos Exp $ */ - -/**************************************************************** -Copyright (C) 1997, 1998 Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. -****************************************************************/ - -/* Try to deduce arith.h from arithmetic properties. */ - -#include - -static int dalign; -typedef struct -Akind { - char *name; - int kind; - } Akind; - -static Akind -IEEE_LITTLE_ENDIAN = { "IEEE_LITTLE_ENDIAN", 1 }, -IEEE_BIG_ENDIAN = { "IEEE_BIG_ENDIAN", 2 }, -IBM = { "IBM", 3 }, -VAX = { "VAX", 4 }, -CRAY = { "CRAY", 5}; - -static Akind * -Lcheck(void) -{ - union { - double d; - long L[2]; - } u; - struct { - double d; - long L; - } x[2]; - - if (sizeof(x) > 2*(sizeof(double) + sizeof(long))) - dalign = 1; - u.L[0] = u.L[1] = 0; - u.d = 1e13; - if (u.L[0] == 1117925532 && u.L[1] == -448790528) - return &IEEE_BIG_ENDIAN; - if (u.L[1] == 1117925532 && u.L[0] == -448790528) - return &IEEE_LITTLE_ENDIAN; - if (u.L[0] == -2065213935 && u.L[1] == 10752) - return &VAX; - if (u.L[0] == 1267827943 && u.L[1] == 704643072) - return &IBM; - return 0; - } - -static Akind * -icheck(void) -{ - union { - double d; - int L[2]; - } u; - struct { - double d; - int L; - } x[2]; - - if (sizeof(x) > 2*(sizeof(double) + sizeof(int))) - dalign = 1; - u.L[0] = u.L[1] = 0; - u.d = 1e13; - if (u.L[0] == 1117925532 && u.L[1] == -448790528) - return &IEEE_BIG_ENDIAN; - if (u.L[1] == 1117925532 && u.L[0] == -448790528) - return &IEEE_LITTLE_ENDIAN; - if (u.L[0] == -2065213935 && u.L[1] == 10752) - return &VAX; - if (u.L[0] == 1267827943 && u.L[1] == 704643072) - return &IBM; - return 0; - } - -char *emptyfmt = ""; /* avoid possible warning message with printf("") */ - -static Akind * -ccheck(void) -{ - union { - double d; - long L; - } u; - long Cray1; - - /* Cray1 = 4617762693716115456 -- without overflow on non-Crays */ - Cray1 = printf(emptyfmt) < 0 ? 0 : 4617762; - if (printf(emptyfmt, Cray1) >= 0) - Cray1 = 1000000*Cray1 + 693716; - if (printf(emptyfmt, Cray1) >= 0) - Cray1 = 1000000*Cray1 + 115456; - u.d = 1e13; - if (u.L == Cray1) - return &CRAY; - return 0; - } - -static int -fzcheck(void) -{ - double a, b; - int i; - - a = 1.; - b = .1; - for(i = 155;; b *= b, i >>= 1) { - if (i & 1) { - a *= b; - if (i == 1) - break; - } - } - b = a * a; - return b == 0.; - } - -int -main(void) -{ - Akind *a = 0; - int Ldef = 0; - FILE *f; - -#ifdef WRITE_ARITH_H /* for Symantec's buggy "make" */ - f = fopen("arith.h", "w"); - if (!f) { - printf("Cannot open arith.h\n"); - return 1; - } -#else - f = stdout; -#endif - - if (sizeof(double) == 2*sizeof(long)) - a = Lcheck(); - else if (sizeof(double) == 2*sizeof(int)) { - Ldef = 1; - a = icheck(); - } - else if (sizeof(double) == sizeof(long)) - a = ccheck(); - if (a) { - fprintf(f, "#define %s\n#define Arith_Kind_ASL %d\n", - a->name, a->kind); - if (Ldef) - fprintf(f, "#define Long int\n#define Intcast (int)(long)\n"); - if (dalign) - fprintf(f, "#define Double_Align\n"); - if (sizeof(char*) == 8) - fprintf(f, "#define X64_bit_pointers\n"); -#ifndef NO_LONG_LONG - if (sizeof(long long) < 8) -#endif - fprintf(f, "#define NO_LONG_LONG\n"); - if (a->kind <= 2 && fzcheck()) - fprintf(f, "#define Sudden_Underflow\n"); -#ifdef WRITE_ARITH_H - fclose(f); -#endif - return 0; - } - fprintf(f, "/* Unknown arithmetic */\n"); -#ifdef WRITE_ARITH_H - fclose(f); -#endif - return 1; - } diff --git a/lib/libc/gdtoa/dmisc.c b/lib/libc/gdtoa/dmisc.c deleted file mode 100644 index 121f8bbee..000000000 --- a/lib/libc/gdtoa/dmisc.c +++ /dev/null @@ -1,227 +0,0 @@ -/* $NetBSD: dmisc.c,v 1.4 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#ifndef MULTIPLE_THREADS - char *dtoa_result; -#endif - - char * -#ifdef KR_headers -rv_alloc(i) size_t i; -#else -rv_alloc(size_t i) -#endif -{ - size_t j; - int k, *r; - - j = sizeof(ULong); - for(k = 0; - sizeof(Bigint) - sizeof(ULong) - sizeof(int) + j <= i; - j <<= 1) - k++; - r = (int*)(void*)Balloc(k); - if (r == NULL) - return NULL; - *r = k; - return -#ifndef MULTIPLE_THREADS - dtoa_result = -#endif - (char *)(void *)(r+1); - } - - char * -#ifdef KR_headers -nrv_alloc(s, rve, n) CONST char *s; char **rve; size_t n; -#else -nrv_alloc(CONST char *s, char **rve, size_t n) -#endif -{ - char *rv, *t; - - t = rv = rv_alloc(n); - if (t == NULL) - return NULL; - while((*t = *s++) !=0) - t++; - if (rve) - *rve = t; - return rv; - } - -/* freedtoa(s) must be used to free values s returned by dtoa - * when MULTIPLE_THREADS is #defined. It should be used in all cases, - * but for consistency with earlier versions of dtoa, it is optional - * when MULTIPLE_THREADS is not defined. - */ - - void -#ifdef KR_headers -freedtoa(s) char *s; -#else -freedtoa(char *s) -#endif -{ - Bigint *b = (Bigint *)(void *)((int *)(void *)s - 1); - b->maxwds = 1 << (b->k = *(int*)(void*)b); - Bfree(b); -#ifndef MULTIPLE_THREADS - if (s == dtoa_result) - dtoa_result = 0; -#endif - } - - int -quorem -#ifdef KR_headers - (b, S) Bigint *b, *S; -#else - (Bigint *b, Bigint *S) -#endif -{ - int n; - ULong *bx, *bxe, q, *sx, *sxe; -#ifdef ULLong - ULLong borrow, carry, y, ys; -#else - ULong borrow, carry, y, ys; -#ifdef Pack_32 - ULong si, z, zs; -#endif -#endif - - n = S->wds; -#ifdef DEBUG - /*debug*/ if (b->wds > n) - /*debug*/ Bug("oversize b in quorem"); -#endif - if (b->wds < n) - return 0; - sx = S->x; - sxe = sx + --n; - bx = b->x; - bxe = bx + n; - q = *bxe / (*sxe + 1); /* ensure q <= true quotient */ -#ifdef DEBUG - /*debug*/ if (q > 9) - /*debug*/ Bug("oversized quotient in quorem"); -#endif - if (q) { - borrow = 0; - carry = 0; - do { -#ifdef ULLong - ys = *sx++ * (ULLong)q + carry; - carry = ys >> 32; - /* LINTED conversion */ - y = *bx - (ys & 0xffffffffUL) - borrow; - borrow = y >> 32 & 1UL; - /* LINTED conversion */ - *bx++ = y & 0xffffffffUL; -#else -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) * q + carry; - zs = (si >> 16) * q + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*bx >> 16) - (zs & 0xffff) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(bx, z, y); -#else - ys = *sx++ * q + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - *bx++ = y & 0xffff; -#endif -#endif - } - while(sx <= sxe); - if (!*bxe) { - bx = b->x; - while(--bxe > bx && !*bxe) - --n; - b->wds = n; - } - } - if (cmp(b, S) >= 0) { - q++; - borrow = 0; - carry = 0; - bx = b->x; - sx = S->x; - do { -#ifdef ULLong - ys = *sx++ + carry; - carry = ys >> 32; - /* LINTED conversion */ - y = *bx - (ys & 0xffffffffUL) - borrow; - borrow = y >> 32 & 1UL; - /* LINTED conversion */ - *bx++ = y & 0xffffffffUL; -#else -#ifdef Pack_32 - si = *sx++; - ys = (si & 0xffff) + carry; - zs = (si >> 16) + (ys >> 16); - carry = zs >> 16; - y = (*bx & 0xffff) - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*bx >> 16) - (zs & 0xffff) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(bx, z, y); -#else - ys = *sx++ + carry; - carry = ys >> 16; - y = *bx - (ys & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - *bx++ = y & 0xffff; -#endif -#endif - } - while(sx <= sxe); - bx = b->x; - bxe = bx + n; - if (!*bxe) { - while(--bxe > bx && !*bxe) - --n; - b->wds = n; - } - } - return q; - } diff --git a/lib/libc/gdtoa/dtoa.c b/lib/libc/gdtoa/dtoa.c deleted file mode 100644 index 66fe35cdc..000000000 --- a/lib/libc/gdtoa/dtoa.c +++ /dev/null @@ -1,842 +0,0 @@ -/* $NetBSD: dtoa.c,v 1.10 2012/05/16 17:48:59 alnsn Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 1999 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. - * - * Inspired by "How to Print Floating-Point Numbers Accurately" by - * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. - * - * Modifications: - * 1. Rather than iterating, we use a simple numeric overestimate - * to determine k = floor(log10(d)). We scale relevant - * quantities using O(log2(k)) rather than O(k) multiplications. - * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't - * try to generate digits strictly left to right. Instead, we - * compute with fewer bits and propagate the carry if necessary - * when rounding the final digit up. This is often faster. - * 3. Under the assumption that input will be rounded nearest, - * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. - * That is, we allow equality in stopping tests when the - * round-nearest rule will give the same floating-point value - * as would satisfaction of the stopping test with strict - * inequality. - * 4. We remove common factors of powers of 2 from relevant - * quantities. - * 5. When converting floating-point integers less than 1e16, - * we use floating-point arithmetic rather than resorting - * to multiple-precision integers. - * 6. When asked to produce fewer than 15 digits, we first try - * to get by with floating-point arithmetic; we resort to - * multiple-precision integer arithmetic only if we cannot - * guarantee that the floating-point calculation has given - * the correctly rounded result. For k requested digits and - * "uniformly" distributed input, the probability is - * something like 10^(k-15) that we must resort to the Long - * calculation. - */ - -#ifdef Honor_FLT_ROUNDS -#undef Check_FLT_ROUNDS -#define Check_FLT_ROUNDS -#else -#define Rounding Flt_Rounds -#endif - - char * -dtoa -#ifdef KR_headers - (d0, mode, ndigits, decpt, sign, rve) - double d0; int mode, ndigits, *decpt, *sign; char **rve; -#else - (double d0, int mode, int ndigits, int *decpt, int *sign, char **rve) -#endif -{ - /* Arguments ndigits, decpt, sign are similar to those - of ecvt and fcvt; trailing zeros are suppressed from - the returned string. If not null, *rve is set to point - to the end of the return value. If d is +-Infinity or NaN, - then *decpt is set to 9999. - - mode: - 0 ==> shortest string that yields d when read in - and rounded to nearest. - 1 ==> like 0, but with Steele & White stopping rule; - e.g. with IEEE P754 arithmetic , mode 0 gives - 1e23 whereas mode 1 gives 9.999999999999999e22. - 2 ==> max(1,ndigits) significant digits. This gives a - return value similar to that of ecvt, except - that trailing zeros are suppressed. - 3 ==> through ndigits past the decimal point. This - gives a return value similar to that from fcvt, - except that trailing zeros are suppressed, and - ndigits can be negative. - 4,5 ==> similar to 2 and 3, respectively, but (in - round-nearest mode) with the tests of mode 0 to - possibly return a shorter string that rounds to d. - With IEEE arithmetic and compilation with - -DHonor_FLT_ROUNDS, modes 4 and 5 behave the same - as modes 2 and 3 when FLT_ROUNDS != 1. - 6-9 ==> Debugging modes similar to mode - 4: don't try - fast floating-point estimate (if applicable). - - Values of mode other than 0-9 are treated as mode 0. - - Sufficient space is allocated to the return value - to hold the suppressed trailing zeros. - */ - - int bbits, b2, b5, be, dig, i, ieps, ilim0, - j, jj1, k, k0, k_check, leftright, m2, m5, s2, s5, - spec_case, try_quick; - int ilim = 0, ilim1 = 0; /* pacify gcc */ - Long L; -#ifndef Sudden_Underflow - int denorm; - ULong x; -#endif - Bigint *b, *b1, *delta, *mhi, *S; - Bigint *mlo = NULL; /* pacify gcc */ - U d, d2, eps; - double ds; - char *s, *s0; -#ifdef SET_INEXACT - int inexact, oldinexact; -#endif -#ifdef Honor_FLT_ROUNDS /*{*/ - int Rounding; -#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ - Rounding = Flt_Rounds; -#else /*}{*/ - Rounding = 1; - switch(fegetround()) { - case FE_TOWARDZERO: Rounding = 0; break; - case FE_UPWARD: Rounding = 2; break; - case FE_DOWNWARD: Rounding = 3; - } -#endif /*}}*/ -#endif /*}*/ - -#ifndef MULTIPLE_THREADS - if (dtoa_result) { - freedtoa(dtoa_result); - dtoa_result = 0; - } -#endif - d.d = d0; - if (word0(&d) & Sign_bit) { - /* set sign for everything, including 0's and NaNs */ - *sign = 1; - word0(&d) &= ~Sign_bit; /* clear sign bit */ - } - else - *sign = 0; - -#if defined(IEEE_Arith) + defined(VAX) -#ifdef IEEE_Arith - if ((word0(&d) & Exp_mask) == Exp_mask) -#else - if (word0(&d) == 0x8000) -#endif - { - /* Infinity or NaN */ - *decpt = 9999; -#ifdef IEEE_Arith - if (!word1(&d) && !(word0(&d) & 0xfffff)) - return nrv_alloc("Infinity", rve, 8); -#endif - return nrv_alloc("NaN", rve, 3); - } -#endif -#ifdef IBM - dval(&d) += 0; /* normalize */ -#endif - if (!dval(&d)) { - *decpt = 1; - return nrv_alloc("0", rve, 1); - } - -#ifdef SET_INEXACT - try_quick = oldinexact = get_inexact(); - inexact = 1; -#endif -#ifdef Honor_FLT_ROUNDS - if (Rounding >= 2) { - if (*sign) - Rounding = Rounding == 2 ? 0 : 2; - else - if (Rounding != 2) - Rounding = 0; - } -#endif - - b = d2b(dval(&d), &be, &bbits); - if (b == NULL) - return NULL; -#ifdef Sudden_Underflow - i = (int)(word0(&d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)); -#else - if (( i = (int)(word0(&d) >> Exp_shift1 & (Exp_mask>>Exp_shift1)) )!=0) { -#endif - dval(&d2) = dval(&d); - word0(&d2) &= Frac_mask1; - word0(&d2) |= Exp_11; -#ifdef IBM - if (( j = 11 - hi0bits(word0(&d2) & Frac_mask) )!=0) - dval(&d2) /= 1 << j; -#endif - - /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 - * log10(x) = log(x) / log(10) - * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) - * log10(&d) = (i-Bias)*log(2)/log(10) + log10(&d2) - * - * This suggests computing an approximation k to log10(&d) by - * - * k = (i - Bias)*0.301029995663981 - * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); - * - * We want k to be too large rather than too small. - * The error in the first-order Taylor series approximation - * is in our favor, so we just round up the constant enough - * to compensate for any error in the multiplication of - * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, - * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, - * adding 1e-13 to the constant term more than suffices. - * Hence we adjust the constant term to 0.1760912590558. - * (We could get a more accurate k by invoking log10, - * but this is probably not worthwhile.) - */ - - i -= Bias; -#ifdef IBM - i <<= 2; - i += j; -#endif -#ifndef Sudden_Underflow - denorm = 0; - } - else { - /* d is denormalized */ - - i = bbits + be + (Bias + (P-1) - 1); - x = i > 32 ? word0(&d) << (64 - i) | word1(&d) >> (i - 32) - : word1(&d) << (32 - i); - dval(&d2) = x; - word0(&d2) -= 31*Exp_msk1; /* adjust exponent */ - i -= (Bias + (P-1) - 1) + 1; - denorm = 1; - } -#endif - ds = (dval(&d2)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; - k = (int)ds; - if (ds < 0. && ds != k) - k--; /* want k = floor(ds) */ - k_check = 1; - if (k >= 0 && k <= Ten_pmax) { - if (dval(&d) < tens[k]) - k--; - k_check = 0; - } - j = bbits - i - 1; - if (j >= 0) { - b2 = 0; - s2 = j; - } - else { - b2 = -j; - s2 = 0; - } - if (k >= 0) { - b5 = 0; - s5 = k; - s2 += k; - } - else { - b2 -= k; - b5 = -k; - s5 = 0; - } - if (mode < 0 || mode > 9) - mode = 0; - -#ifndef SET_INEXACT -#ifdef Check_FLT_ROUNDS - try_quick = Rounding == 1; -#else - try_quick = 1; -#endif -#endif /*SET_INEXACT*/ - - if (mode > 5) { - mode -= 4; - try_quick = 0; - } - leftright = 1; - ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ - /* silence erroneous "gcc -Wall" warning. */ - switch(mode) { - case 0: - case 1: - i = 18; - ndigits = 0; - break; - case 2: - leftright = 0; - /* FALLTHROUGH */ - case 4: - if (ndigits <= 0) - ndigits = 1; - ilim = ilim1 = i = ndigits; - break; - case 3: - leftright = 0; - /* FALLTHROUGH */ - case 5: - i = ndigits + k + 1; - ilim = i; - ilim1 = i - 1; - if (i <= 0) - i = 1; - } - s = s0 = rv_alloc((size_t)i); - if (s == NULL) - return NULL; - -#ifdef Honor_FLT_ROUNDS - if (mode > 1 && Rounding != 1) - leftright = 0; -#endif - - if (ilim >= 0 && ilim <= Quick_max && try_quick) { - - /* Try to get by with floating-point arithmetic. */ - - i = 0; - dval(&d2) = dval(&d); - k0 = k; - ilim0 = ilim; - ieps = 2; /* conservative */ - if (k > 0) { - ds = tens[k&0xf]; - j = (unsigned int)k >> 4; - if (j & Bletch) { - /* prevent overflows */ - j &= Bletch - 1; - dval(&d) /= bigtens[n_bigtens-1]; - ieps++; - } - for(; j; j = (unsigned int)j >> 1, i++) - if (j & 1) { - ieps++; - ds *= bigtens[i]; - } - dval(&d) /= ds; - } - else if (( jj1 = -k )!=0) { - dval(&d) *= tens[jj1 & 0xf]; - for(j = jj1 >> 4; j; j >>= 1, i++) - if (j & 1) { - ieps++; - dval(&d) *= bigtens[i]; - } - } - if (k_check && dval(&d) < 1. && ilim > 0) { - if (ilim1 <= 0) - goto fast_failed; - ilim = ilim1; - k--; - dval(&d) *= 10.; - ieps++; - } - dval(&eps) = ieps*dval(&d) + 7.; - word0(&eps) -= (P-1)*Exp_msk1; - if (ilim == 0) { - S = mhi = 0; - dval(&d) -= 5.; - if (dval(&d) > dval(&eps)) - goto one_digit; - if (dval(&d) < -dval(&eps)) - goto no_digits; - goto fast_failed; - } -#ifndef No_leftright - if (leftright) { - /* Use Steele & White method of only - * generating digits needed. - */ - dval(&eps) = 0.5/tens[ilim-1] - dval(&eps); - for(i = 0;;) { - L = dval(&d); - dval(&d) -= L; - *s++ = '0' + (int)L; - if (dval(&d) < dval(&eps)) - goto ret1; - if (1. - dval(&d) < dval(&eps)) - goto bump_up; - if (++i >= ilim) - break; - dval(&eps) *= 10.; - dval(&d) *= 10.; - } - } - else { -#endif - /* Generate ilim digits, then fix them up. */ - dval(&eps) *= tens[ilim-1]; - for(i = 1;; i++, dval(&d) *= 10.) { - L = (Long)(dval(&d)); - if (!(dval(&d) -= L)) - ilim = i; - *s++ = '0' + (int)L; - if (i == ilim) { - if (dval(&d) > 0.5 + dval(&eps)) - goto bump_up; - else if (dval(&d) < 0.5 - dval(&eps)) { - while(*--s == '0'); - s++; - goto ret1; - } - break; - } - } -#ifndef No_leftright - } -#endif - fast_failed: - s = s0; - dval(&d) = dval(&d2); - k = k0; - ilim = ilim0; - } - - /* Do we have a "small" integer? */ - - if (be >= 0 && k <= Int_max) { - /* Yes. */ - ds = tens[k]; - if (ndigits < 0 && ilim <= 0) { - S = mhi = 0; - if (ilim < 0 || dval(&d) <= 5*ds) - goto no_digits; - goto one_digit; - } - for(i = 1;; i++, dval(&d) *= 10.) { - L = (Long)(dval(&d) / ds); - dval(&d) -= L*ds; -#ifdef Check_FLT_ROUNDS - /* If FLT_ROUNDS == 2, L will usually be high by 1 */ - if (dval(&d) < 0) { - L--; - dval(&d) += ds; - } -#endif - *s++ = '0' + (int)L; - if (!dval(&d)) { -#ifdef SET_INEXACT - inexact = 0; -#endif - break; - } - if (i == ilim) { -#ifdef Honor_FLT_ROUNDS - if (mode > 1) - switch(Rounding) { - case 0: goto ret1; - case 2: goto bump_up; - } -#endif - dval(&d) += dval(&d); -#ifdef ROUND_BIASED - if (dval(&d) >= ds) -#else - if (dval(&d) > ds || (dval(&d) == ds && L & 1)) -#endif - { - bump_up: - while(*--s == '9') - if (s == s0) { - k++; - *s = '0'; - break; - } - ++*s++; - } - break; - } - } - goto ret1; - } - - m2 = b2; - m5 = b5; - mhi = mlo = 0; - if (leftright) { - i = -#ifndef Sudden_Underflow - denorm ? be + (Bias + (P-1) - 1 + 1) : -#endif -#ifdef IBM - 1 + 4*P - 3 - bbits + ((bbits + be - 1) & 3); -#else - 1 + P - bbits; -#endif - b2 += i; - s2 += i; - mhi = i2b(1); - if (mhi == NULL) - return NULL; - } - if (m2 > 0 && s2 > 0) { - i = m2 < s2 ? m2 : s2; - b2 -= i; - m2 -= i; - s2 -= i; - } - if (b5 > 0) { - if (leftright) { - if (m5 > 0) { - mhi = pow5mult(mhi, m5); - if (mhi == NULL) - return NULL; - b1 = mult(mhi, b); - if (b1 == NULL) - return NULL; - Bfree(b); - b = b1; - } - if (( j = b5 - m5 )!=0) { - b = pow5mult(b, j); - if (b == NULL) - return NULL; - } - } - else { - b = pow5mult(b, b5); - if (b == NULL) - return NULL; - } - } - S = i2b(1); - if (S == NULL) - return NULL; - if (s5 > 0) { - S = pow5mult(S, s5); - if (S == NULL) - return NULL; - } - - /* Check for special case that d is a normalized power of 2. */ - - spec_case = 0; - if ((mode < 2 || leftright) -#ifdef Honor_FLT_ROUNDS - && Rounding == 1 -#endif - ) { - if (!word1(&d) && !(word0(&d) & Bndry_mask) -#ifndef Sudden_Underflow - && word0(&d) & (Exp_mask & ~Exp_msk1) -#endif - ) { - /* The special case */ - b2 += Log2P; - s2 += Log2P; - spec_case = 1; - } - } - - /* Arrange for convenient computation of quotients: - * shift left if necessary so divisor has 4 leading 0 bits. - * - * Perhaps we should just compute leading 28 bits of S once - * and for all and pass them and a shift to quorem, so it - * can do shifts and ors to compute the numerator for q. - */ -#ifdef Pack_32 - if (( i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0x1f )!=0) - i = 32 - i; -#else - if (( i = ((s5 ? 32 - hi0bits(S->x[S->wds-1]) : 1) + s2) & 0xf )!=0) - i = 16 - i; -#endif - if (i > 4) { - i -= 4; - b2 += i; - m2 += i; - s2 += i; - } - else if (i < 4) { - i += 28; - b2 += i; - m2 += i; - s2 += i; - } - if (b2 > 0) { - b = lshift(b, b2); - if (b == NULL) - return NULL; - } - if (s2 > 0) { - S = lshift(S, s2); - if (S == NULL) - return NULL; - } - if (k_check) { - if (cmp(b,S) < 0) { - k--; - b = multadd(b, 10, 0); /* we botched the k estimate */ - if (b == NULL) - return NULL; - if (leftright) { - mhi = multadd(mhi, 10, 0); - if (mhi == NULL) - return NULL; - } - ilim = ilim1; - } - } - if (ilim <= 0 && (mode == 3 || mode == 5)) { - if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { - /* no digits, fcvt style */ - no_digits: - k = -1 - ndigits; - goto ret; - } - one_digit: - *s++ = '1'; - k++; - goto ret; - } - if (leftright) { - if (m2 > 0) { - mhi = lshift(mhi, m2); - if (mhi == NULL) - return NULL; - } - - /* Compute mlo -- check for special case - * that d is a normalized power of 2. - */ - - mlo = mhi; - if (spec_case) { - mhi = Balloc(mhi->k); - if (mhi == NULL) - return NULL; - Bcopy(mhi, mlo); - mhi = lshift(mhi, Log2P); - if (mhi == NULL) - return NULL; - } - - for(i = 1;;i++) { - dig = quorem(b,S) + '0'; - /* Do we yet have the shortest decimal string - * that will round to d? - */ - j = cmp(b, mlo); - delta = diff(S, mhi); - if (delta == NULL) - return NULL; - jj1 = delta->sign ? 1 : cmp(b, delta); - Bfree(delta); -#ifndef ROUND_BIASED - if (jj1 == 0 && mode != 1 && !(word1(&d) & 1) -#ifdef Honor_FLT_ROUNDS - && Rounding >= 1 -#endif - ) { - if (dig == '9') - goto round_9_up; - if (j > 0) - dig++; -#ifdef SET_INEXACT - else if (!b->x[0] && b->wds <= 1) - inexact = 0; -#endif - *s++ = dig; - goto ret; - } -#endif - if (j < 0 || (j == 0 && mode != 1 -#ifndef ROUND_BIASED - && !(word1(&d) & 1) -#endif - )) { - if (!b->x[0] && b->wds <= 1) { -#ifdef SET_INEXACT - inexact = 0; -#endif - goto accept_dig; - } -#ifdef Honor_FLT_ROUNDS - if (mode > 1) - switch(Rounding) { - case 0: goto accept_dig; - case 2: goto keep_dig; - } -#endif /*Honor_FLT_ROUNDS*/ - if (jj1 > 0) { - b = lshift(b, 1); - if (b == NULL) - return NULL; - jj1 = cmp(b, S); -#ifdef ROUND_BIASED - if (jj1 >= 0 /*)*/ -#else - if ((jj1 > 0 || (jj1 == 0 && dig & 1)) -#endif - && dig++ == '9') - goto round_9_up; - } - accept_dig: - *s++ = dig; - goto ret; - } - if (jj1 > 0) { -#ifdef Honor_FLT_ROUNDS - if (!Rounding) - goto accept_dig; -#endif - if (dig == '9') { /* possible if i == 1 */ - round_9_up: - *s++ = '9'; - goto roundoff; - } - *s++ = dig + 1; - goto ret; - } -#ifdef Honor_FLT_ROUNDS - keep_dig: -#endif - *s++ = dig; - if (i == ilim) - break; - b = multadd(b, 10, 0); - if (b == NULL) - return NULL; - if (mlo == mhi) { - mlo = mhi = multadd(mhi, 10, 0); - if (mlo == NULL) - return NULL; - } - else { - mlo = multadd(mlo, 10, 0); - if (mlo == NULL) - return NULL; - mhi = multadd(mhi, 10, 0); - if (mhi == NULL) - return NULL; - } - } - } - else - for(i = 1;; i++) { - *s++ = dig = quorem(b,S) + '0'; - if (!b->x[0] && b->wds <= 1) { -#ifdef SET_INEXACT - inexact = 0; -#endif - goto ret; - } - if (i >= ilim) - break; - b = multadd(b, 10, 0); - if (b == NULL) - return NULL; - } - - /* Round off last digit */ - -#ifdef Honor_FLT_ROUNDS - switch(Rounding) { - case 0: goto trimzeros; - case 2: goto roundoff; - } -#endif - b = lshift(b, 1); - j = cmp(b, S); -#ifdef ROUND_BIASED - if (j >= 0) -#else - if (j > 0 || (j == 0 && dig & 1)) -#endif - { - roundoff: - while(*--s == '9') - if (s == s0) { - k++; - *s++ = '1'; - goto ret; - } - ++*s++; - } - else { -#ifdef Honor_FLT_ROUNDS - trimzeros: -#endif - while(*--s == '0'); - s++; - } - ret: - Bfree(S); - if (mhi) { - if (mlo && mlo != mhi) - Bfree(mlo); - Bfree(mhi); - } - ret1: -#ifdef SET_INEXACT - if (inexact) { - if (!oldinexact) { - word0(&d) = Exp_1 + (70 << Exp_shift); - word1(&d) = 0; - dval(&d) += 1.; - } - } - else if (!oldinexact) - clear_inexact(); -#endif - Bfree(b); - if (s == s0) { /* don't return empty string */ - *s++ = '0'; - k = 0; - } - *s = 0; - *decpt = k + 1; - if (rve) - *rve = s; - return s0; - } diff --git a/lib/libc/gdtoa/g_Qfmt.c b/lib/libc/gdtoa/g_Qfmt.c deleted file mode 100644 index f9291affe..000000000 --- a/lib/libc/gdtoa/g_Qfmt.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $NetBSD: g_Qfmt.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 3 -#define _1 2 -#define _2 1 -#define _3 0 -#endif - - char* -#ifdef KR_headers -g_Qfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize; -#else -g_Qfmt(char *buf, void *V, int ndig, size_t bufsize) -#endif -{ - static FPI fpi0 = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, 0 }; - char *b, *s, *se; - ULong bits[4], *L, sign; - int decpt, ex, i, mode; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - if (ndig < 0) - ndig = 0; - if (bufsize < ndig + 10) - return 0; - - L = (ULong*)V; - sign = L[_0] & 0x80000000L; - bits[3] = L[_0] & 0xffff; - bits[2] = L[_1]; - bits[1] = L[_2]; - bits[0] = L[_3]; - b = buf; - if ( (ex = (L[_0] & 0x7fff0000L) >> 16) !=0) { - if (ex == 0x7fff) { - /* Infinity or NaN */ - if (bits[0] | bits[1] | bits[2] | bits[3]) - b = strcp(b, "NaN"); - else { - b = buf; - if (sign) - *b++ = '-'; - b = strcp(b, "Infinity"); - } - return b; - } - i = STRTOG_Normal; - bits[3] |= 0x10000; - } - else if (bits[0] | bits[1] | bits[2] | bits[3]) { - i = STRTOG_Denormal; - ex = 1; - } - else { -#ifndef IGNORE_ZERO_SIGN - if (sign) - *b++ = '-'; -#endif - *b++ = '0'; - *b = 0; - return b; - } - ex -= 0x3fff + 112; - mode = 2; - if (ndig <= 0) { - if (bufsize < 48) - return 0; - mode = 0; - } - s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se); - if (s == NULL) - return NULL; - return g__fmt(buf, s, se, decpt, sign, bufsize); - } diff --git a/lib/libc/gdtoa/g__fmt.c b/lib/libc/gdtoa/g__fmt.c deleted file mode 100644 index 052978368..000000000 --- a/lib/libc/gdtoa/g__fmt.c +++ /dev/null @@ -1,147 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#ifdef USE_LOCALE -#include "locale.h" -#endif - - char * -#ifdef KR_headers -g__fmt(b, s, se, decpt, sign, blen) char *b; char *s; char *se; int decpt; ULong sign; size_t blen; -#else -g__fmt(char *b, char *s, char *se, int decpt, ULong sign, size_t blen) -#endif -{ - int i, j, k; - char *be, *s0; - size_t len; -#ifdef USE_LOCALE -#ifdef NO_LOCALE_CACHE - char *decimalpoint = localeconv()->decimal_point; - size_t dlen = strlen(decimalpoint); -#else - char *decimalpoint; - static char *decimalpoint_cache; - static size_t dlen; - if (!(s0 = decimalpoint_cache)) { - s0 = localeconv()->decimal_point; - dlen = strlen(s0); - if ((decimalpoint_cache = MALLOC(strlen(s0) + 1)) != NULL) { - strcpy(decimalpoint_cache, s0); - s0 = decimalpoint_cache; - } - } - decimalpoint = s0; -#endif -#else -#define dlen 0 -#endif - s0 = s; - len = (se-s) + dlen + 6; /* 6 = sign + e+dd + trailing null */ - if (blen < len) - goto ret0; - be = b + blen - 1; - if (sign) - *b++ = '-'; - if (decpt <= -4 || decpt > se - s + 5) { - *b++ = *s++; - if (*s) { -#ifdef USE_LOCALE - while((*b = *decimalpoint++)) - ++b; -#else - *b++ = '.'; -#endif - while((*b = *s++) !=0) - b++; - } - *b++ = 'e'; - /* sprintf(b, "%+.2d", decpt - 1); */ - if (--decpt < 0) { - *b++ = '-'; - decpt = -decpt; - } - else - *b++ = '+'; - for(j = 2, k = 10; 10*k <= decpt; j++, k *= 10){} - for(;;) { - i = decpt / k; - if (b >= be) - goto ret0; - *b++ = i + '0'; - if (--j <= 0) - break; - decpt -= i*k; - decpt *= 10; - } - *b = 0; - } - else if (decpt <= 0) { -#ifdef USE_LOCALE - while((*b = *decimalpoint++)) - ++b; -#else - *b++ = '.'; -#endif - if (be < b - decpt + (se - s)) - goto ret0; - for(; decpt < 0; decpt++) - *b++ = '0'; - while((*b = *s++) != 0) - b++; - } - else { - while((*b = *s++) != 0) { - b++; - if (--decpt == 0 && *s) { -#ifdef USE_LOCALE - while(*b = *decimalpoint++) - ++b; -#else - *b++ = '.'; -#endif - } - } - if (b + decpt > be) { - ret0: - b = 0; - goto ret; - } - for(; decpt > 0; decpt--) - *b++ = '0'; - *b = 0; - } - ret: - freedtoa(s0); - return b; - } diff --git a/lib/libc/gdtoa/g_ddfmt.c b/lib/libc/gdtoa/g_ddfmt.c deleted file mode 100644 index 742eee98c..000000000 --- a/lib/libc/gdtoa/g_ddfmt.c +++ /dev/null @@ -1,189 +0,0 @@ -/* $NetBSD: g_ddfmt.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg@acm.org). */ - -#include "gdtoaimp.h" -#include - - char * -#ifdef KR_headers -g_ddfmt(buf, dd0, ndig, bufsize) char *buf; double *dd0; int ndig; size_t bufsize; -#else -g_ddfmt(char *buf, double *dd0, int ndig, size_t bufsize) -#endif -{ - FPI fpi; - char *b, *s, *se; - ULong *L, bits0[4], *bits, *zx; - int bx, by, decpt, ex, ey, i, j, mode; - Bigint *x, *y, *z; - U *dd, ddx[2]; -#ifdef Honor_FLT_ROUNDS /*{{*/ - int Rounding; -#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ - Rounding = Flt_Rounds; -#else /*}{*/ - Rounding = 1; - switch(fegetround()) { - case FE_TOWARDZERO: Rounding = 0; break; - case FE_UPWARD: Rounding = 2; break; - case FE_DOWNWARD: Rounding = 3; - } -#endif /*}}*/ -#else /*}{*/ -#define Rounding FPI_Round_near -#endif /*}}*/ - - if (bufsize < 10 || bufsize < ndig + 8) - return 0; - - dd = (U*)dd0; - L = dd->L; - if ((L[_0] & 0x7ff00000L) == 0x7ff00000L) { - /* Infinity or NaN */ - if (L[_0] & 0xfffff || L[_1]) { - nanret: - return strcp(buf, "NaN"); - } - if ((L[2+_0] & 0x7ff00000) == 0x7ff00000) { - if (L[2+_0] & 0xfffff || L[2+_1]) - goto nanret; - if ((L[_0] ^ L[2+_0]) & 0x80000000L) - goto nanret; /* Infinity - Infinity */ - } - infret: - b = buf; - if (L[_0] & 0x80000000L) - *b++ = '-'; - return strcp(b, "Infinity"); - } - if ((L[2+_0] & 0x7ff00000) == 0x7ff00000) { - L += 2; - if (L[_0] & 0xfffff || L[_1]) - goto nanret; - goto infret; - } - if (dval(&dd[0]) + dval(&dd[1]) == 0.) { - b = buf; -#ifndef IGNORE_ZERO_SIGN - if (L[_0] & L[2+_0] & 0x80000000L) - *b++ = '-'; -#endif - *b++ = '0'; - *b = 0; - return b; - } - if ((L[_0] & 0x7ff00000L) < (L[2+_0] & 0x7ff00000L)) { - dval(&ddx[1]) = dval(&dd[0]); - dval(&ddx[0]) = dval(&dd[1]); - dd = ddx; - L = dd->L; - } - z = d2b(dval(&dd[0]), &ex, &bx); - if (z == NULL) - return NULL; - if (dval(&dd[1]) == 0.) - goto no_y; - x = z; - y = d2b(dval(&dd[1]), &ey, &by); - if (y == NULL) - return NULL; - if ( (i = ex - ey) !=0) { - if (i > 0) { - x = lshift(x, i); - if (x == NULL) - return NULL; - ex = ey; - } - else { - y = lshift(y, -i); - if (y == NULL) - return NULL; - } - } - if ((L[_0] ^ L[2+_0]) & 0x80000000L) { - z = diff(x, y); - if (z == NULL) - return NULL; - if (L[_0] & 0x80000000L) - z->sign = 1 - z->sign; - } - else { - z = sum(x, y); - if (z == NULL) - return NULL; - if (L[_0] & 0x80000000L) - z->sign = 1; - } - Bfree(x); - Bfree(y); - no_y: - bits = zx = z->x; - for(i = 0; !*zx; zx++) - i += 32; - i += lo0bits(zx); - if (i) { - rshift(z, i); - ex += i; - } - fpi.nbits = z->wds * 32 - hi0bits(z->x[j = z->wds-1]); - if (fpi.nbits < 106) { - fpi.nbits = 106; - if (j < 3) { - for(i = 0; i <= j; i++) - bits0[i] = bits[i]; - while(i < 4) - bits0[i++] = 0; - bits = bits0; - } - } - mode = 2; - if (ndig <= 0) { - if (bufsize < (int)(fpi.nbits * .301029995664) + 10) { - Bfree(z); - return 0; - } - mode = 0; - } - fpi.emin = 1-1023-53+1; - fpi.emax = 2046-1023-106+1; - fpi.rounding = Rounding; - fpi.sudden_underflow = 0; - i = STRTOG_Normal; - s = gdtoa(&fpi, ex, bits, &i, mode, ndig, &decpt, &se); - if (s == NULL) - return NULL; - b = g__fmt(buf, s, se, decpt, z->sign, bufsize); - if (b == NULL) - return NULL; - Bfree(z); - return b; - } diff --git a/lib/libc/gdtoa/g_dfmt.c b/lib/libc/gdtoa/g_dfmt.c deleted file mode 100644 index dd18e8903..000000000 --- a/lib/libc/gdtoa/g_dfmt.c +++ /dev/null @@ -1,99 +0,0 @@ -/* $NetBSD: g_dfmt.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - char* -#ifdef KR_headers -g_dfmt(buf, d, ndig, bufsize) char *buf; double *d; int ndig; size_t bufsize; -#else -g_dfmt(char *buf, double *d, int ndig, size_t bufsize) -#endif -{ - static FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, 0 }; - char *b, *s, *se; - ULong bits[2], *L, sign; - int decpt, ex, i, mode; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - if (ndig < 0) - ndig = 0; - if (bufsize < ndig + 10) - return 0; - - L = (ULong*)d; - sign = L[_0] & 0x80000000L; - if ((L[_0] & 0x7ff00000) == 0x7ff00000) { - /* Infinity or NaN */ - if (bufsize < 10) - return 0; - if (L[_0] & 0xfffff || L[_1]) { - return strcp(buf, "NaN"); - } - b = buf; - if (sign) - *b++ = '-'; - return strcp(b, "Infinity"); - } - if (L[_1] == 0 && (L[_0] ^ sign) == 0 /*d == 0.*/) { - b = buf; -#ifndef IGNORE_ZERO_SIGN - if (L[_0] & 0x80000000L) - *b++ = '-'; -#endif - *b++ = '0'; - *b = 0; - return b; - } - bits[0] = L[_1]; - bits[1] = L[_0] & 0xfffff; - if ( (ex = (L[_0] >> 20) & 0x7ff) !=0) - bits[1] |= 0x100000; - else - ex = 1; - ex -= 0x3ff + 52; - mode = 2; - if (ndig <= 0) - mode = 0; - i = STRTOG_Normal; - if (sign) - i = STRTOG_Normal | STRTOG_Neg; - s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se); - if (s == NULL) - return NULL; - return g__fmt(buf, s, se, decpt, sign, bufsize); - } diff --git a/lib/libc/gdtoa/g_ffmt.c b/lib/libc/gdtoa/g_ffmt.c deleted file mode 100644 index a260d799a..000000000 --- a/lib/libc/gdtoa/g_ffmt.c +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: g_ffmt.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - char* -#ifdef KR_headers -g_ffmt(buf, f, ndig, bufsize) char *buf; float *f; int ndig; size_t bufsize; -#else -g_ffmt(char *buf, float *f, int ndig, size_t bufsize) -#endif -{ - static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, 0 }; - char *b, *s, *se; - ULong bits[1], *L, sign; - int decpt, ex, i, mode; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - if (ndig < 0) - ndig = 0; - if (bufsize < ndig + 10) - return 0; - - L = (ULong*)f; - sign = L[0] & 0x80000000L; - if ((L[0] & 0x7f800000) == 0x7f800000) { - /* Infinity or NaN */ - if (L[0] & 0x7fffff) { - return strcp(buf, "NaN"); - } - b = buf; - if (sign) - *b++ = '-'; - return strcp(b, "Infinity"); - } - if (*f == 0.) { - b = buf; -#ifndef IGNORE_ZERO_SIGN - if (L[0] & 0x80000000L) - *b++ = '-'; -#endif - *b++ = '0'; - *b = 0; - return b; - } - bits[0] = L[0] & 0x7fffff; - if ( (ex = (L[0] >> 23) & 0xff) !=0) - bits[0] |= 0x800000; - else - ex = 1; - ex -= 0x7f + 23; - mode = 2; - if (ndig <= 0) { - if (bufsize < 16) - return 0; - mode = 0; - } - i = STRTOG_Normal; - s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se); - if (s == NULL) - return NULL; - return g__fmt(buf, s, se, decpt, sign, bufsize); - } diff --git a/lib/libc/gdtoa/g_xLfmt.c b/lib/libc/gdtoa/g_xLfmt.c deleted file mode 100644 index d35cd1acb..000000000 --- a/lib/libc/gdtoa/g_xLfmt.c +++ /dev/null @@ -1,117 +0,0 @@ -/* $NetBSD: g_xLfmt.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 2 -#define _1 1 -#define _2 0 -#endif - - char* -#ifdef KR_headers -g_xLfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize; -#else -g_xLfmt(char *buf, void *V, int ndig, size_t bufsize) -#endif -{ - static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 }; - char *b, *s, *se; - ULong bits[2], *L, sign; - int decpt, ex, i, mode; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - if (ndig < 0) - ndig = 0; - if (bufsize < ndig + 10) - return 0; - - L = (ULong*)V; - sign = L[_0] & 0x80000000L; - bits[1] = L[_1]; - bits[0] = L[_2]; - if ( (ex = (L[_0] >> 16) & 0x7fff) !=0) { - if (ex == 0x7fff) { - /* Infinity or NaN */ - if (bits[0] | bits[1]) - b = strcp(buf, "NaN"); - else { - b = buf; - if (sign) - *b++ = '-'; - b = strcp(b, "Infinity"); - } - return b; - } - i = STRTOG_Normal; - } - else if (bits[0] | bits[1]) { - i = STRTOG_Denormal; - } - else { - b = buf; -#ifndef IGNORE_ZERO_SIGN - if (sign) - *b++ = '-'; -#endif - *b++ = '0'; - *b = 0; - return b; - } - ex -= 0x3fff + 63; - mode = 2; - if (ndig <= 0) { - if (bufsize < 32) - return 0; - mode = 0; - } - s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se); - if (s == NULL) - return NULL; - return g__fmt(buf, s, se, decpt, sign, bufsize); - } diff --git a/lib/libc/gdtoa/g_xfmt.c b/lib/libc/gdtoa/g_xfmt.c deleted file mode 100644 index f7cd39142..000000000 --- a/lib/libc/gdtoa/g_xfmt.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $NetBSD: g_xfmt.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#define _4 4 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 4 -#define _1 3 -#define _2 2 -#define _3 1 -#define _4 0 -#endif - - char* -#ifdef KR_headers -g_xfmt(buf, V, ndig, bufsize) char *buf; char *V; int ndig; size_t bufsize; -#else -g_xfmt(char *buf, void *V, int ndig, size_t bufsize) -#endif -{ - static FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, 0 }; - char *b, *s, *se; - ULong bits[2], sign; - UShort *L; - int decpt, ex, i, mode; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - if (ndig < 0) - ndig = 0; - if (bufsize < ndig + 10) - return 0; - - L = (UShort *)V; - sign = L[_0] & 0x8000; - bits[1] = (L[_1] << 16) | L[_2]; - bits[0] = (L[_3] << 16) | L[_4]; - if ( (ex = L[_0] & 0x7fff) !=0) { - if (ex == 0x7fff) { - /* Infinity or NaN */ - if (bits[0] | bits[1]) - b = strcp(buf, "NaN"); - else { - b = buf; - if (sign) - *b++ = '-'; - b = strcp(b, "Infinity"); - } - return b; - } - i = STRTOG_Normal; - } - else if (bits[0] | bits[1]) { - i = STRTOG_Denormal; - ex = 1; - } - else { - b = buf; -#ifndef IGNORE_ZERO_SIGN - if (sign) - *b++ = '-'; -#endif - *b++ = '0'; - *b = 0; - return b; - } - ex -= 0x3fff + 63; - mode = 2; - if (ndig <= 0) { - if (bufsize < 32) - return 0; - mode = 0; - } - s = gdtoa(fpi, ex, bits, &i, mode, ndig, &decpt, &se); - if (s == NULL) - return NULL; - return g__fmt(buf, s, se, decpt, sign, bufsize); - } diff --git a/lib/libc/gdtoa/gdtoa.c b/lib/libc/gdtoa/gdtoa.c deleted file mode 100644 index c4a595abe..000000000 --- a/lib/libc/gdtoa/gdtoa.c +++ /dev/null @@ -1,824 +0,0 @@ -/* $NetBSD: gdtoa.c,v 1.6 2012/03/13 21:13:33 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 1999 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - static Bigint * -#ifdef KR_headers -bitstob(bits, nbits, bbits) ULong *bits; int nbits; int *bbits; -#else -bitstob(ULong *bits, int nbits, int *bbits) -#endif -{ - int i, k; - Bigint *b; - ULong *be, *x, *x0; - - i = ULbits; - k = 0; - while(i < nbits) { - i <<= 1; - k++; - } -#ifndef Pack_32 - if (!k) - k = 1; -#endif - b = Balloc(k); - if (b == NULL) - return NULL; - be = bits + (((unsigned int)nbits - 1) >> kshift); - x = x0 = b->x; - do { - *x++ = *bits & ALL_ON; -#ifdef Pack_16 - *x++ = (*bits >> 16) & ALL_ON; -#endif - } while(++bits <= be); - ptrdiff_t td = x - x0; - _DIAGASSERT(__type_fit(int, td)); - i = (int)td; - while(!x0[--i]) - if (!i) { - b->wds = 0; - *bbits = 0; - goto ret; - } - b->wds = i + 1; - *bbits = i*ULbits + 32 - hi0bits(b->x[i]); - ret: - return b; - } - -/* dtoa for IEEE arithmetic (dmg): convert double to ASCII string. - * - * Inspired by "How to Print Floating-Point Numbers Accurately" by - * Guy L. Steele, Jr. and Jon L. White [Proc. ACM SIGPLAN '90, pp. 112-126]. - * - * Modifications: - * 1. Rather than iterating, we use a simple numeric overestimate - * to determine k = floor(log10(d)). We scale relevant - * quantities using O(log2(k)) rather than O(k) multiplications. - * 2. For some modes > 2 (corresponding to ecvt and fcvt), we don't - * try to generate digits strictly left to right. Instead, we - * compute with fewer bits and propagate the carry if necessary - * when rounding the final digit up. This is often faster. - * 3. Under the assumption that input will be rounded nearest, - * mode 0 renders 1e23 as 1e23 rather than 9.999999999999999e22. - * That is, we allow equality in stopping tests when the - * round-nearest rule will give the same floating-point value - * as would satisfaction of the stopping test with strict - * inequality. - * 4. We remove common factors of powers of 2 from relevant - * quantities. - * 5. When converting floating-point integers less than 1e16, - * we use floating-point arithmetic rather than resorting - * to multiple-precision integers. - * 6. When asked to produce fewer than 15 digits, we first try - * to get by with floating-point arithmetic; we resort to - * multiple-precision integer arithmetic only if we cannot - * guarantee that the floating-point calculation has given - * the correctly rounded result. For k requested digits and - * "uniformly" distributed input, the probability is - * something like 10^(k-15) that we must resort to the Long - * calculation. - */ - - char * -gdtoa -#ifdef KR_headers - (fpi, be, bits, kindp, mode, ndigits, decpt, rve) - FPI *fpi; int be; ULong *bits; - int *kindp, mode, ndigits, *decpt; char **rve; -#else - (FPI *fpi, int be, ULong *bits, int *kindp, int mode, int ndigits, int *decpt, char **rve) -#endif -{ - /* Arguments ndigits and decpt are similar to the second and third - arguments of ecvt and fcvt; trailing zeros are suppressed from - the returned string. If not null, *rve is set to point - to the end of the return value. If d is +-Infinity or NaN, - then *decpt is set to 9999. - be = exponent: value = (integer represented by bits) * (2 to the power of be). - - mode: - 0 ==> shortest string that yields d when read in - and rounded to nearest. - 1 ==> like 0, but with Steele & White stopping rule; - e.g. with IEEE P754 arithmetic , mode 0 gives - 1e23 whereas mode 1 gives 9.999999999999999e22. - 2 ==> max(1,ndigits) significant digits. This gives a - return value similar to that of ecvt, except - that trailing zeros are suppressed. - 3 ==> through ndigits past the decimal point. This - gives a return value similar to that from fcvt, - except that trailing zeros are suppressed, and - ndigits can be negative. - 4-9 should give the same return values as 2-3, i.e., - 4 <= mode <= 9 ==> same return as mode - 2 + (mode & 1). These modes are mainly for - debugging; often they run slower but sometimes - faster than modes 2-3. - 4,5,8,9 ==> left-to-right digit generation. - 6-9 ==> don't try fast floating-point estimate - (if applicable). - - Values of mode other than 0-9 are treated as mode 0. - - Sufficient space is allocated to the return value - to hold the suppressed trailing zeros. - */ - - int bbits, b2, b5, be0, dig, i, ieps, ilim = 0, ilim0, ilim1 = 0, inex; - int j, jj1, k, k0, k_check, kind, leftright, m2, m5, nbits; - int rdir, s2, s5, spec_case, try_quick; - Long L; - Bigint *b, *b1, *delta, *mlo, *mhi, *mhi1, *S; - double d2, ds; - char *s, *s0; - U d, eps; - -#ifndef MULTIPLE_THREADS - if (dtoa_result) { - freedtoa(dtoa_result); - dtoa_result = 0; - } -#endif - inex = 0; - if (*kindp & STRTOG_NoMemory) - return NULL; - kind = *kindp &= ~STRTOG_Inexact; - switch(kind & STRTOG_Retmask) { - case STRTOG_Zero: - goto ret_zero; - case STRTOG_Normal: - case STRTOG_Denormal: - break; - case STRTOG_Infinite: - *decpt = -32768; - return nrv_alloc("Infinity", rve, 8); - case STRTOG_NaN: - *decpt = -32768; - return nrv_alloc("NaN", rve, 3); - default: - return 0; - } - b = bitstob(bits, nbits = fpi->nbits, &bbits); - if (b == NULL) - return NULL; - be0 = be; - if ( (i = trailz(b)) !=0) { - rshift(b, i); - be += i; - bbits -= i; - } - if (!b->wds) { - Bfree(b); - ret_zero: - *decpt = 1; - return nrv_alloc("0", rve, 1); - } - - dval(&d) = b2d(b, &i); - i = be + bbits - 1; - word0(&d) &= Frac_mask1; - word0(&d) |= Exp_11; -#ifdef IBM - if ( (j = 11 - hi0bits(word0(&d) & Frac_mask)) !=0) - dval(&d) /= 1 << j; -#endif - - /* log(x) ~=~ log(1.5) + (x-1.5)/1.5 - * log10(x) = log(x) / log(10) - * ~=~ log(1.5)/log(10) + (x-1.5)/(1.5*log(10)) - * log10(&d) = (i-Bias)*log(2)/log(10) + log10(d2) - * - * This suggests computing an approximation k to log10(&d) by - * - * k = (i - Bias)*0.301029995663981 - * + ( (d2-1.5)*0.289529654602168 + 0.176091259055681 ); - * - * We want k to be too large rather than too small. - * The error in the first-order Taylor series approximation - * is in our favor, so we just round up the constant enough - * to compensate for any error in the multiplication of - * (i - Bias) by 0.301029995663981; since |i - Bias| <= 1077, - * and 1077 * 0.30103 * 2^-52 ~=~ 7.2e-14, - * adding 1e-13 to the constant term more than suffices. - * Hence we adjust the constant term to 0.1760912590558. - * (We could get a more accurate k by invoking log10, - * but this is probably not worthwhile.) - */ -#ifdef IBM - i <<= 2; - i += j; -#endif - ds = (dval(&d)-1.5)*0.289529654602168 + 0.1760912590558 + i*0.301029995663981; - - /* correct assumption about exponent range */ - if ((j = i) < 0) - j = -j; - if ((j -= 1077) > 0) - ds += j * 7e-17; - - k = (int)ds; - if (ds < 0. && ds != k) - k--; /* want k = floor(ds) */ - k_check = 1; -#ifdef IBM - j = be + bbits - 1; - if ( (jj1 = j & 3) !=0) - dval(&d) *= 1 << jj1; - word0(&d) += j << Exp_shift - 2 & Exp_mask; -#else - word0(&d) += (be + bbits - 1) << Exp_shift; -#endif - if (k >= 0 && k <= Ten_pmax) { - if (dval(&d) < tens[k]) - k--; - k_check = 0; - } - j = bbits - i - 1; - if (j >= 0) { - b2 = 0; - s2 = j; - } - else { - b2 = -j; - s2 = 0; - } - if (k >= 0) { - b5 = 0; - s5 = k; - s2 += k; - } - else { - b2 -= k; - b5 = -k; - s5 = 0; - } - if (mode < 0 || mode > 9) - mode = 0; - try_quick = 1; - if (mode > 5) { - mode -= 4; - try_quick = 0; - } - else if (i >= -4 - Emin || i < Emin) - try_quick = 0; - leftright = 1; - ilim = ilim1 = -1; /* Values for cases 0 and 1; done here to */ - /* silence erroneous "gcc -Wall" warning. */ - switch(mode) { - case 0: - case 1: - i = (int)(nbits * .30103) + 3; - ndigits = 0; - break; - case 2: - leftright = 0; - /*FALLTHROUGH*/ - case 4: - if (ndigits <= 0) - ndigits = 1; - ilim = ilim1 = i = ndigits; - break; - case 3: - leftright = 0; - /*FALLTHROUGH*/ - case 5: - i = ndigits + k + 1; - ilim = i; - ilim1 = i - 1; - if (i <= 0) - i = 1; - } - s = s0 = rv_alloc((size_t)i); - if (s == NULL) - return NULL; - - if ( (rdir = fpi->rounding - 1) !=0) { - if (rdir < 0) - rdir = 2; - if (kind & STRTOG_Neg) - rdir = 3 - rdir; - } - - /* Now rdir = 0 ==> round near, 1 ==> round up, 2 ==> round down. */ - - if (ilim >= 0 && ilim <= Quick_max && try_quick && !rdir -#ifndef IMPRECISE_INEXACT - && k == 0 -#endif - ) { - - /* Try to get by with floating-point arithmetic. */ - - i = 0; - d2 = dval(&d); -#ifdef IBM - if ( (j = 11 - hi0bits(word0(&d) & Frac_mask)) !=0) - dval(&d) /= 1 << j; -#endif - k0 = k; - ilim0 = ilim; - ieps = 2; /* conservative */ - if (k > 0) { - ds = tens[k&0xf]; - j = (unsigned int)k >> 4; - if (j & Bletch) { - /* prevent overflows */ - j &= Bletch - 1; - dval(&d) /= bigtens[n_bigtens-1]; - ieps++; - } - for(; j; j /= 2, i++) - if (j & 1) { - ieps++; - ds *= bigtens[i]; - } - } - else { - ds = 1.; - if ( (jj1 = -k) !=0) { - dval(&d) *= tens[jj1 & 0xf]; - for(j = jj1 >> 4; j; j >>= 1, i++) - if (j & 1) { - ieps++; - dval(&d) *= bigtens[i]; - } - } - } - if (k_check && dval(&d) < 1. && ilim > 0) { - if (ilim1 <= 0) - goto fast_failed; - ilim = ilim1; - k--; - dval(&d) *= 10.; - ieps++; - } - dval(&eps) = ieps*dval(&d) + 7.; - word0(&eps) -= (P-1)*Exp_msk1; - if (ilim == 0) { - S = mhi = 0; - dval(&d) -= 5.; - if (dval(&d) > dval(&eps)) - goto one_digit; - if (dval(&d) < -dval(&eps)) - goto no_digits; - goto fast_failed; - } -#ifndef No_leftright - if (leftright) { - /* Use Steele & White method of only - * generating digits needed. - */ - dval(&eps) = ds*0.5/tens[ilim-1] - dval(&eps); - for(i = 0;;) { - L = (Long)(dval(&d)/ds); - dval(&d) -= L*ds; - *s++ = '0' + (int)L; - if (dval(&d) < dval(&eps)) { - if (dval(&d)) - inex = STRTOG_Inexlo; - goto ret1; - } - if (ds - dval(&d) < dval(&eps)) - goto bump_up; - if (++i >= ilim) - break; - dval(&eps) *= 10.; - dval(&d) *= 10.; - } - } - else { -#endif - /* Generate ilim digits, then fix them up. */ - dval(&eps) *= tens[ilim-1]; - for(i = 1;; i++, dval(&d) *= 10.) { - if ( (L = (Long)(dval(&d)/ds)) !=0) - dval(&d) -= L*ds; - *s++ = '0' + (int)L; - if (i == ilim) { - ds *= 0.5; - if (dval(&d) > ds + dval(&eps)) - goto bump_up; - else if (dval(&d) < ds - dval(&eps)) { - if (dval(&d)) - inex = STRTOG_Inexlo; - goto clear_trailing0; - } - break; - } - } -#ifndef No_leftright - } -#endif - fast_failed: - s = s0; - dval(&d) = d2; - k = k0; - ilim = ilim0; - } - - /* Do we have a "small" integer? */ - - if (be >= 0 && k <= Int_max) { - /* Yes. */ - ds = tens[k]; - if (ndigits < 0 && ilim <= 0) { - S = mhi = 0; - if (ilim < 0 || dval(&d) <= 5*ds) - goto no_digits; - goto one_digit; - } - for(i = 1;; i++, dval(&d) *= 10.) { - L = dval(&d) / ds; - dval(&d) -= L*ds; -#ifdef Check_FLT_ROUNDS - /* If FLT_ROUNDS == 2, L will usually be high by 1 */ - if (dval(&d) < 0) { - L--; - dval(&d) += ds; - } -#endif - *s++ = '0' + (int)L; - if (dval(&d) == 0.) - break; - if (i == ilim) { - if (rdir) { - if (rdir == 1) - goto bump_up; - inex = STRTOG_Inexlo; - goto ret1; - } - dval(&d) += dval(&d); -#ifdef ROUND_BIASED - if (dval(&d) >= ds) -#else - if (dval(&d) > ds || (dval(&d) == ds && L & 1)) -#endif - { - bump_up: - inex = STRTOG_Inexhi; - while(*--s == '9') - if (s == s0) { - k++; - *s = '0'; - break; - } - ++*s++; - } - else { - inex = STRTOG_Inexlo; - clear_trailing0: - while(*--s == '0'){} - ++s; - } - break; - } - } - goto ret1; - } - - m2 = b2; - m5 = b5; - mhi = mlo = 0; - if (leftright) { - i = nbits - bbits; - if (be - i++ < fpi->emin && mode != 3 && mode != 5) { - /* denormal */ - i = be - fpi->emin + 1; - if (mode >= 2 && ilim > 0 && ilim < i) - goto small_ilim; - } - else if (mode >= 2) { - small_ilim: - j = ilim - 1; - if (m5 >= j) - m5 -= j; - else { - s5 += j -= m5; - b5 += j; - m5 = 0; - } - if ((i = ilim) < 0) { - m2 -= i; - i = 0; - } - } - b2 += i; - s2 += i; - mhi = i2b(1); - } - if (m2 > 0 && s2 > 0) { - i = m2 < s2 ? m2 : s2; - b2 -= i; - m2 -= i; - s2 -= i; - } - if (b5 > 0) { - if (leftright) { - if (m5 > 0) { - mhi = pow5mult(mhi, m5); - if (mhi == NULL) - return NULL; - b1 = mult(mhi, b); - if (b1 == NULL) - return NULL; - Bfree(b); - b = b1; - } - if ( (j = b5 - m5) !=0) { - b = pow5mult(b, j); - if (b == NULL) - return NULL; - } - } - else { - b = pow5mult(b, b5); - if (b == NULL) - return NULL; - } - } - S = i2b(1); - if (S == NULL) - return NULL; - if (s5 > 0) { - S = pow5mult(S, s5); - if (S == NULL) - return NULL; - } - - /* Check for special case that d is a normalized power of 2. */ - - spec_case = 0; - if (mode < 2) { - if (bbits == 1 && be0 > fpi->emin + 1) { - /* The special case */ - b2++; - s2++; - spec_case = 1; - } - } - - /* Arrange for convenient computation of quotients: - * shift left if necessary so divisor has 4 leading 0 bits. - * - * Perhaps we should just compute leading 28 bits of S once - * and for all and pass them and a shift to quorem, so it - * can do shifts and ors to compute the numerator for q. - */ - i = ((s5 ? hi0bits(S->x[S->wds-1]) : ULbits - 1) - s2 - 4) & kmask; - m2 += i; - if ((b2 += i) > 0) - b = lshift(b, b2); - if ((s2 += i) > 0) - S = lshift(S, s2); - if (k_check) { - if (cmp(b,S) < 0) { - k--; - b = multadd(b, 10, 0); /* we botched the k estimate */ - if (b == NULL) - return NULL; - if (leftright) { - mhi = multadd(mhi, 10, 0); - if (mhi == NULL) - return NULL; - } - ilim = ilim1; - } - } - if (ilim <= 0 && mode > 2) { - if (ilim < 0 || cmp(b,S = multadd(S,5,0)) <= 0) { - /* no digits, fcvt style */ - no_digits: - k = -1 - ndigits; - inex = STRTOG_Inexlo; - goto ret; - } - one_digit: - inex = STRTOG_Inexhi; - *s++ = '1'; - k++; - goto ret; - } - if (leftright) { - if (m2 > 0) { - mhi = lshift(mhi, m2); - if (mhi == NULL) - return NULL; - } - - /* Compute mlo -- check for special case - * that d is a normalized power of 2. - */ - - mlo = mhi; - if (spec_case) { - mhi = Balloc(mhi->k); - if (mhi == NULL) - return NULL; - Bcopy(mhi, mlo); - mhi = lshift(mhi, 1); - if (mhi == NULL) - return NULL; - } - - for(i = 1;;i++) { - dig = quorem(b,S) + '0'; - /* Do we yet have the shortest decimal string - * that will round to d? - */ - j = cmp(b, mlo); - delta = diff(S, mhi); - if (delta == NULL) - return NULL; - jj1 = delta->sign ? 1 : cmp(b, delta); - Bfree(delta); -#ifndef ROUND_BIASED - if (jj1 == 0 && !mode && !(bits[0] & 1) && !rdir) { - if (dig == '9') - goto round_9_up; - if (j <= 0) { - if (b->wds > 1 || b->x[0]) - inex = STRTOG_Inexlo; - } - else { - dig++; - inex = STRTOG_Inexhi; - } - *s++ = dig; - goto ret; - } -#endif - if (j < 0 || (j == 0 && !mode -#ifndef ROUND_BIASED - && !(bits[0] & 1) -#endif - )) { - if (rdir && (b->wds > 1 || b->x[0])) { - if (rdir == 2) { - inex = STRTOG_Inexlo; - goto accept; - } - while (cmp(S,mhi) > 0) { - *s++ = dig; - mhi1 = multadd(mhi, 10, 0); - if (mhi1 == NULL) - return NULL; - if (mlo == mhi) - mlo = mhi1; - mhi = mhi1; - b = multadd(b, 10, 0); - if (b == NULL) - return NULL; - dig = quorem(b,S) + '0'; - } - if (dig++ == '9') - goto round_9_up; - inex = STRTOG_Inexhi; - goto accept; - } - if (jj1 > 0) { - b = lshift(b, 1); - if (b == NULL) - return NULL; - jj1 = cmp(b, S); -#ifdef ROUND_BIASED - if (jj1 >= 0 /*)*/ -#else - if ((jj1 > 0 || (jj1 == 0 && dig & 1)) -#endif - && dig++ == '9') - goto round_9_up; - inex = STRTOG_Inexhi; - } - if (b->wds > 1 || b->x[0]) - inex = STRTOG_Inexlo; - accept: - *s++ = dig; - goto ret; - } - if (jj1 > 0 && rdir != 2) { - if (dig == '9') { /* possible if i == 1 */ - round_9_up: - *s++ = '9'; - inex = STRTOG_Inexhi; - goto roundoff; - } - inex = STRTOG_Inexhi; - *s++ = dig + 1; - goto ret; - } - *s++ = dig; - if (i == ilim) - break; - b = multadd(b, 10, 0); - if (b == NULL) - return NULL; - if (mlo == mhi) { - mlo = mhi = multadd(mhi, 10, 0); - if (mlo == NULL) - return NULL; - } - else { - mlo = multadd(mlo, 10, 0); - if (mlo == NULL) - return NULL; - mhi = multadd(mhi, 10, 0); - if (mhi == NULL) - return NULL; - } - } - } - else - for(i = 1;; i++) { - *s++ = dig = quorem(b,S) + '0'; - if (i >= ilim) - break; - b = multadd(b, 10, 0); - if (b == NULL) - return NULL; - } - - /* Round off last digit */ - - if (rdir) { - if (rdir == 2 || (b->wds <= 1 && !b->x[0])) - goto chopzeros; - goto roundoff; - } - b = lshift(b, 1); - if (b == NULL) - return NULL; - j = cmp(b, S); -#ifdef ROUND_BIASED - if (j >= 0) -#else - if (j > 0 || (j == 0 && dig & 1)) -#endif - { - roundoff: - inex = STRTOG_Inexhi; - while(*--s == '9') - if (s == s0) { - k++; - *s++ = '1'; - goto ret; - } - ++*s++; - } - else { - chopzeros: - if (b->wds > 1 || b->x[0]) - inex = STRTOG_Inexlo; - while(*--s == '0'){} - ++s; - } - ret: - Bfree(S); - if (mhi) { - if (mlo && mlo != mhi) - Bfree(mlo); - Bfree(mhi); - } - ret1: - Bfree(b); - *s = 0; - *decpt = k + 1; - if (rve) - *rve = s; - *kindp |= inex; - return s0; - } diff --git a/lib/libc/gdtoa/gdtoa.h b/lib/libc/gdtoa/gdtoa.h deleted file mode 100644 index 6386a7802..000000000 --- a/lib/libc/gdtoa/gdtoa.h +++ /dev/null @@ -1,183 +0,0 @@ -/* $NetBSD: gdtoa.h,v 1.10 2013/04/18 21:54:10 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#ifndef GDTOA_H_INCLUDED -#define GDTOA_H_INCLUDED - -#include "arith.h" -#include /* for size_t */ -#include - -#ifndef __LOCALE_T_DECLARED -typedef struct _locale *locale_t; -#define __LOCALE_T_DECLARED -#endif - -#ifndef Long -#define Long int32_t -#endif -#ifndef ULong -#define ULong uint32_t -#endif -#ifndef UShort -#define UShort uint16_t -#endif - -#ifndef ANSI -#ifdef KR_headers -#define ANSI(x) () -#define Void /*nothing*/ -#else -#define ANSI(x) x -#define Void void -#endif -#endif /* ANSI */ - -#ifndef CONST -#ifdef KR_headers -#define CONST /* blank */ -#else -#define CONST const -#endif -#endif /* CONST */ - - enum { /* return values from strtodg */ - STRTOG_Zero = 0, - STRTOG_Normal = 1, - STRTOG_Denormal = 2, - STRTOG_Infinite = 3, - STRTOG_NaN = 4, - STRTOG_NaNbits = 5, - STRTOG_NoNumber = 6, - STRTOG_Retmask = 7, - - /* The following may be or-ed into one of the above values. */ - - STRTOG_Neg = 0x08, /* does not affect STRTOG_Inexlo or STRTOG_Inexhi */ - STRTOG_Inexlo = 0x10, /* returned result rounded toward zero */ - STRTOG_Inexhi = 0x20, /* returned result rounded away from zero */ - STRTOG_Inexact = 0x30, - STRTOG_Underflow= 0x40, - STRTOG_Overflow = 0x80, - STRTOG_NoMemory = 0x100 - }; - - typedef struct -FPI { - int nbits; - int emin; - int emax; - int rounding; - int sudden_underflow; - } FPI; - -enum { /* FPI.rounding values: same as FLT_ROUNDS */ - FPI_Round_zero = 0, - FPI_Round_near = 1, - FPI_Round_up = 2, - FPI_Round_down = 3 - }; - -#ifdef __cplusplus -extern "C" { -#endif - -#define dtoa __dtoa -#define gdtoa __gdtoa -#define ldtoa __ldtoa -#define hldtoa __hldtoa -#define hdtoa __hdtoa -#define freedtoa __freedtoa -#define strtodg __strtodg_D2A -#define strtopQ __strtopQ_D2A -#define strtopx __strtopx_D2A -#define strtopxL __strtopxL_D2A -#define strtord __strtord_D2A - -extern char* dtoa ANSI((double d, int mode, int ndigits, int *decpt, - int *sign, char **rve)); -extern char* hdtoa ANSI((double d, const char *xdigs, int ndigits, int *decpt, - int *sign, char **rve)); -extern char* ldtoa ANSI((long double *ld, int mode, int ndigits, int *decpt, - int *sign, char **rve)); -extern char* hldtoa ANSI((long double e, const char *xdigs, int ndigits, - int *decpt, int *sign, char **rve)); - -extern char* gdtoa ANSI((FPI *fpi, int be, ULong *bits, int *kindp, - int mode, int ndigits, int *decpt, char **rve)); -extern void freedtoa ANSI((char*)); -extern float strtof ANSI((CONST char *, char **)); -extern double strtod ANSI((CONST char *, char **)); -extern int strtodg ANSI((CONST char*, char**, CONST FPI*, Long*, ULong*, - locale_t)); - -extern char* g_ddfmt ANSI((char*, double*, int, size_t)); -extern char* g_dfmt ANSI((char*, double*, int, size_t)); -extern char* g_ffmt ANSI((char*, float*, int, size_t)); -extern char* g_Qfmt ANSI((char*, void*, int, size_t)); -extern char* g_xfmt ANSI((char*, void*, int, size_t)); -extern char* g_xLfmt ANSI((char*, void*, int, size_t)); - -extern int strtoId ANSI((CONST char*, char**, double*, double*)); -extern int strtoIdd ANSI((CONST char*, char**, double*, double*)); -extern int strtoIf ANSI((CONST char*, char**, float*, float*)); -extern int strtoIQ ANSI((CONST char*, char**, void*, void*)); -extern int strtoIx ANSI((CONST char*, char**, void*, void*)); -extern int strtoIxL ANSI((CONST char*, char**, void*, void*)); -extern int strtord ANSI((CONST char*, char**, int, double*, locale_t)); -extern int strtordd ANSI((CONST char*, char**, int, double*)); -extern int strtorf ANSI((CONST char*, char**, int, float*)); -extern int strtorQ ANSI((CONST char*, char**, int, void*)); -extern int strtorx ANSI((CONST char*, char**, int, void*)); -extern int strtorxL ANSI((CONST char*, char**, int, void*)); -#if 1 -extern int strtodI ANSI((CONST char*, char**, double*)); -extern int strtopd ANSI((CONST char*, char**, double*)); -extern int strtopdd ANSI((CONST char*, char**, double*)); -extern int strtopf ANSI((CONST char*, char**, float*)); -extern int strtopQ ANSI((CONST char*, char**, void*, locale_t)); -extern int strtopx ANSI((CONST char*, char**, void*, locale_t)); -extern int strtopxL ANSI((CONST char*, char**, void*, locale_t)); -#else -#define strtopd(s,se,x) strtord(s,se,1,x) -#define strtopdd(s,se,x) strtordd(s,se,1,x) -#define strtopf(s,se,x) strtorf(s,se,1,x) -#define strtopQ(s,se,x) strtorQ(s,se,1,x) -#define strtopx(s,se,x) strtorx(s,se,1,x) -#define strtopxL(s,se,x) strtorxL(s,se,1,x) -#endif - -#ifdef __cplusplus -} -#endif -#endif /* GDTOA_H_INCLUDED */ diff --git a/lib/libc/gdtoa/gdtoa_fltrnds.h b/lib/libc/gdtoa/gdtoa_fltrnds.h deleted file mode 100644 index 33e5f9e53..000000000 --- a/lib/libc/gdtoa/gdtoa_fltrnds.h +++ /dev/null @@ -1,18 +0,0 @@ - FPI *fpi, fpi1; - int Rounding; -#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ - Rounding = Flt_Rounds; -#else /*}{*/ - Rounding = 1; - switch(fegetround()) { - case FE_TOWARDZERO: Rounding = 0; break; - case FE_UPWARD: Rounding = 2; break; - case FE_DOWNWARD: Rounding = 3; - } -#endif /*}}*/ - fpi = &fpi0; - if (Rounding != 1) { - fpi1 = fpi0; - fpi = &fpi1; - fpi1.rounding = Rounding; - } diff --git a/lib/libc/gdtoa/gdtoa_locks.c b/lib/libc/gdtoa/gdtoa_locks.c deleted file mode 100644 index af02c0897..000000000 --- a/lib/libc/gdtoa/gdtoa_locks.c +++ /dev/null @@ -1,12 +0,0 @@ -/* $NetBSD: gdtoa_locks.c,v 1.2 2015/01/20 18:31:25 christos Exp $ */ - -/* - * Written by Klaus Klein , November 16, 2005. - * Public domain. - */ - -#include "gdtoaimp.h" - -#ifdef _REENTRANT -mutex_t __gdtoa_locks[2] = { MUTEX_INITIALIZER, MUTEX_INITIALIZER }; -#endif diff --git a/lib/libc/gdtoa/gdtoaimp.h b/lib/libc/gdtoa/gdtoaimp.h deleted file mode 100644 index 32a1bad59..000000000 --- a/lib/libc/gdtoa/gdtoaimp.h +++ /dev/null @@ -1,677 +0,0 @@ -/* $NetBSD: gdtoaimp.h,v 1.14 2013/04/19 10:41:53 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* This is a variation on dtoa.c that converts arbitary binary - floating-point formats to and from decimal notation. It uses - double-precision arithmetic internally, so there are still - various #ifdefs that adapt the calculations to the native - double-precision arithmetic (any of IEEE, VAX D_floating, - or IBM mainframe arithmetic). - - Please send bug reports to David M. Gay (dmg at acm dot org, - with " at " changed at "@" and " dot " changed to "."). - */ - -/* On a machine with IEEE extended-precision registers, it is - * necessary to specify double-precision (53-bit) rounding precision - * before invoking strtod or dtoa. If the machine uses (the equivalent - * of) Intel 80x87 arithmetic, the call - * _control87(PC_53, MCW_PC); - * does this with many compilers. Whether this or another call is - * appropriate depends on the compiler; for this to work, it may be - * necessary to #include "float.h" or another system-dependent header - * file. - */ - -/* strtod for IEEE-, VAX-, and IBM-arithmetic machines. - * - * This strtod returns a nearest machine number to the input decimal - * string (or sets errno to ERANGE). With IEEE arithmetic, ties are - * broken by the IEEE round-even rule. Otherwise ties are broken by - * biased rounding (add half and chop). - * - * Inspired loosely by William D. Clinger's paper "How to Read Floating - * Point Numbers Accurately" [Proc. ACM SIGPLAN '90, pp. 112-126]. - * - * Modifications: - * - * 1. We only require IEEE, IBM, or VAX double-precision - * arithmetic (not IEEE double-extended). - * 2. We get by with floating-point arithmetic in a case that - * Clinger missed -- when we're computing d * 10^n - * for a small integer d and the integer n is not too - * much larger than 22 (the maximum integer k for which - * we can represent 10^k exactly), we may be able to - * compute (d*10^k) * 10^(e-k) with just one roundoff. - * 3. Rather than a bit-at-a-time adjustment of the binary - * result in the hard case, we use floating-point - * arithmetic to determine the adjustment to within - * one bit; only in really hard cases do we need to - * compute a second residual. - * 4. Because of 3., we don't need a large table of powers of 10 - * for ten-to-e (just some small tables, e.g. of 10^k - * for 0 <= k <= 22). - */ - -/* - * #define IEEE_LITTLE_ENDIAN for IEEE-arithmetic machines where the least - * significant byte has the lowest address. - * #define IEEE_BIG_ENDIAN for IEEE-arithmetic machines where the most - * significant byte has the lowest address. - * #define Long int on machines with 32-bit ints and 64-bit longs. - * #define Sudden_Underflow for IEEE-format machines without gradual - * underflow (i.e., that flush to zero on underflow). - * #define IBM for IBM mainframe-style floating-point arithmetic. - * #define VAX for VAX-style floating-point arithmetic (D_floating). - * #define No_leftright to omit left-right logic in fast floating-point - * computation of dtoa. - * #define Check_FLT_ROUNDS if FLT_ROUNDS can assume the values 2 or 3. - * #define RND_PRODQUOT to use rnd_prod and rnd_quot (assembly routines - * that use extended-precision instructions to compute rounded - * products and quotients) with IBM. - * #define ROUND_BIASED for IEEE-format with biased rounding and arithmetic - * that rounds toward +Infinity. - * #define ROUND_BIASED_without_Round_Up for IEEE-format with biased - * rounding when the underlying floating-point arithmetic uses - * unbiased rounding. This prevent using ordinary floating-point - * arithmetic when the result could be computed with one rounding error. - * #define Inaccurate_Divide for IEEE-format with correctly rounded - * products but inaccurate quotients, e.g., for Intel i860. - * #define NO_LONG_LONG on machines that do not have a "long long" - * integer type (of >= 64 bits). On such machines, you can - * #define Just_16 to store 16 bits per 32-bit Long when doing - * high-precision integer arithmetic. Whether this speeds things - * up or slows things down depends on the machine and the number - * being converted. If long long is available and the name is - * something other than "long long", #define Llong to be the name, - * and if "unsigned Llong" does not work as an unsigned version of - * Llong, #define #ULLong to be the corresponding unsigned type. - * #define KR_headers for old-style C function headers. - * #define Bad_float_h if your system lacks a float.h or if it does not - * define some or all of DBL_DIG, DBL_MAX_10_EXP, DBL_MAX_EXP, - * FLT_RADIX, FLT_ROUNDS, and DBL_MAX. - * #define MALLOC your_malloc, where your_malloc(n) acts like malloc(n) - * if memory is available and otherwise does something you deem - * appropriate. If MALLOC is undefined, malloc will be invoked - * directly -- and assumed always to succeed. Similarly, if you - * want something other than the system's free() to be called to - * recycle memory acquired from MALLOC, #define FREE to be the - * name of the alternate routine. (FREE or free is only called in - * pathological cases, e.g., in a gdtoa call after a gdtoa return in - * mode 3 with thousands of digits requested.) - * #define Omit_Private_Memory to omit logic (added Jan. 1998) for making - * memory allocations from a private pool of memory when possible. - * When used, the private pool is PRIVATE_MEM bytes long: 2304 bytes, - * unless #defined to be a different length. This default length - * suffices to get rid of MALLOC calls except for unusual cases, - * such as decimal-to-binary conversion of a very long string of - * digits. When converting IEEE double precision values, the - * longest string gdtoa can return is about 751 bytes long. For - * conversions by strtod of strings of 800 digits and all gdtoa - * conversions of IEEE doubles in single-threaded executions with - * 8-byte pointers, PRIVATE_MEM >= 7400 appears to suffice; with - * 4-byte pointers, PRIVATE_MEM >= 7112 appears adequate. - * #define NO_INFNAN_CHECK if you do not wish to have INFNAN_CHECK - * #defined automatically on IEEE systems. On such systems, - * when INFNAN_CHECK is #defined, strtod checks - * for Infinity and NaN (case insensitively). - * When INFNAN_CHECK is #defined and No_Hex_NaN is not #defined, - * strtodg also accepts (case insensitively) strings of the form - * NaN(x), where x is a string of hexadecimal digits (optionally - * preceded by 0x or 0X) and spaces; if there is only one string - * of hexadecimal digits, it is taken for the fraction bits of the - * resulting NaN; if there are two or more strings of hexadecimal - * digits, each string is assigned to the next available sequence - * of 32-bit words of fractions bits (starting with the most - * significant), right-aligned in each sequence. - * Unless GDTOA_NON_PEDANTIC_NANCHECK is #defined, input "NaN(...)" - * is consumed even when ... has the wrong form (in which case the - * "(...)" is consumed but ignored). - * #define MULTIPLE_THREADS if the system offers preemptively scheduled - * multiple threads. In this case, you must provide (or suitably - * #define) two locks, acquired by ACQUIRE_DTOA_LOCK(n) and freed - * by FREE_DTOA_LOCK(n) for n = 0 or 1. (The second lock, accessed - * in pow5mult, ensures lazy evaluation of only one copy of high - * powers of 5; omitting this lock would introduce a small - * probability of wasting memory, but would otherwise be harmless.) - * You must also invoke freedtoa(s) to free the value s returned by - * dtoa. You may do so whether or not MULTIPLE_THREADS is #defined. - * #define IMPRECISE_INEXACT if you do not care about the setting of - * the STRTOG_Inexact bits in the special case of doing IEEE double - * precision conversions (which could also be done by the strtod in - * dtoa.c). - * #define NO_HEX_FP to disable recognition of C9x's hexadecimal - * floating-point constants. - * #define -DNO_ERRNO to suppress setting errno (in strtod.c and - * strtodg.c). - * #define NO_STRING_H to use private versions of memcpy. - * On some K&R systems, it may also be necessary to - * #define DECLARE_SIZE_T in this case. - * #define USE_LOCALE to use the current locale's decimal_point value. - */ - -/* #define IEEE_{BIG,LITTLE}_ENDIAN in ${ARCHDIR}/gdtoa/arith.h */ - -#include -#include -#define Short int16_t -#define UShort uint16_t -#define Long int32_t -#define ULong uint32_t -#define LLong int64_t -#define ULLong uint64_t - -#define INFNAN_CHECK -#ifdef _REENTRANT -#define MULTIPLE_THREADS -#endif -#define USE_LOCALE - -#ifndef GDTOAIMP_H_INCLUDED -#define GDTOAIMP_H_INCLUDED -#include "gdtoa.h" -#include "gd_qnan.h" -#ifdef Honor_FLT_ROUNDS -#include -#endif - -#ifdef DEBUG -#include "stdio.h" -#define Bug(x) {fprintf(stderr, "%s\n", x); exit(1);} -#endif - -#include "stdlib.h" -#include "string.h" - -#ifdef KR_headers -#define Char char -#else -#define Char void -#endif - -#ifdef MALLOC -extern Char *MALLOC ANSI((size_t)); -#else -#define MALLOC malloc -#endif - -#undef IEEE_Arith -#undef Avoid_Underflow -#ifdef IEEE_BIG_ENDIAN -#define IEEE_Arith -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define IEEE_Arith -#endif - -#include "errno.h" -#ifdef Bad_float_h - -#ifdef IEEE_Arith -#define DBL_DIG 15 -#define DBL_MAX_10_EXP 308 -#define DBL_MAX_EXP 1024 -#define FLT_RADIX 2 -#define DBL_MAX 1.7976931348623157e+308 -#endif - -#ifdef IBM -#define DBL_DIG 16 -#define DBL_MAX_10_EXP 75 -#define DBL_MAX_EXP 63 -#define FLT_RADIX 16 -#define DBL_MAX 7.2370055773322621e+75 -#endif - -#ifdef VAX -#define DBL_DIG 16 -#define DBL_MAX_10_EXP 38 -#define DBL_MAX_EXP 127 -#define FLT_RADIX 2 -#define DBL_MAX 1.7014118346046923e+38 -#define n_bigtens 2 -#endif - -#ifndef LONG_MAX -#define LONG_MAX 2147483647 -#endif - -#else /* ifndef Bad_float_h */ -#include "float.h" -#endif /* Bad_float_h */ - -#ifdef IEEE_Arith -#define Scale_Bit 0x10 -#define n_bigtens 5 -#endif - -#ifdef IBM -#define n_bigtens 3 -#endif - -#ifdef VAX -#define n_bigtens 2 -#endif - -#include "math.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#if defined(IEEE_LITTLE_ENDIAN) + defined(IEEE_BIG_ENDIAN) + defined(VAX) + defined(IBM) != 1 -Exactly one of IEEE_LITTLE_ENDIAN, IEEE_BIG_ENDIAN, VAX, or IBM should be defined. -#endif - -typedef union { double d; ULong L[2]; } __attribute__((__may_alias__)) U; - -#ifdef YES_ALIAS -#define dval(x) x -#ifdef IEEE_LITTLE_ENDIAN -#define word0(x) ((ULong *)x)[1] -#define word1(x) ((ULong *)x)[0] -#else -#define word0(x) ((ULong *)x)[0] -#define word1(x) ((ULong *)x)[1] -#endif -#else /* !YES_ALIAS */ -#ifdef IEEE_LITTLE_ENDIAN -#define word0(x) ( /* LINTED */ (U*)x)->L[1] -#define word1(x) ( /* LINTED */ (U*)x)->L[0] -#else -#define word0(x) ( /* LINTED */ (U*)x)->L[0] -#define word1(x) ( /* LINTED */ (U*)x)->L[1] -#endif -#define dval(x) ( /* LINTED */ (U*)x)->d -#endif /* YES_ALIAS */ - -/* The following definition of Storeinc is appropriate for MIPS processors. - * An alternative that might be better on some machines is - * #define Storeinc(a,b,c) (*a++ = b << 16 | c & 0xffff) - */ -#if defined(IEEE_LITTLE_ENDIAN) + defined(VAX) -#define Storeinc(a,b,c) \ - (((unsigned short *)(void *)a)[1] = (unsigned short)b, \ - ((unsigned short *)(void *)a)[0] = (unsigned short)c, \ - a++) -#else -#define Storeinc(a,b,c) \ - (((unsigned short *)(void *)a)[0] = (unsigned short)b, \ - ((unsigned short *)(void *)a)[1] = (unsigned short)c, \ - a++) -#endif - -/* #define P DBL_MANT_DIG */ -/* Ten_pmax = floor(P*log(2)/log(5)) */ -/* Bletch = (highest power of 2 < DBL_MAX_10_EXP) / 16 */ -/* Quick_max = floor((P-1)*log(FLT_RADIX)/log(10) - 1) */ -/* Int_max = floor(P*log(FLT_RADIX)/log(10) - 1) */ - -#ifdef IEEE_Arith -#define Exp_shift 20 -#define Exp_shift1 20 -#define Exp_msk1 0x100000 -#define Exp_msk11 0x100000 -#define Exp_mask 0x7ff00000 -#define P 53 -#define Bias 1023 -#define Emin (-1022) -#define Exp_1 0x3ff00000 -#define Exp_11 0x3ff00000 -#define Ebits 11 -#define Frac_mask 0xfffff -#define Frac_mask1 0xfffff -#define Ten_pmax 22 -#define Bletch 0x10 -#define Bndry_mask 0xfffff -#define Bndry_mask1 0xfffff -#define LSB 1 -#define Sign_bit 0x80000000 -#define Log2P 1 -#define Tiny0 0 -#define Tiny1 1 -#define Quick_max 14 -#define Int_max 14 - -#ifndef Flt_Rounds -#ifdef FLT_ROUNDS -#define Flt_Rounds FLT_ROUNDS -#else -#define Flt_Rounds 1 -#endif -#endif /*Flt_Rounds*/ - -#else /* ifndef IEEE_Arith */ -#undef Sudden_Underflow -#define Sudden_Underflow -#ifdef IBM -#undef Flt_Rounds -#define Flt_Rounds 0 -#define Exp_shift 24 -#define Exp_shift1 24 -#define Exp_msk1 0x1000000 -#define Exp_msk11 0x1000000 -#define Exp_mask 0x7f000000 -#define P 14 -#define Bias 65 -#define Exp_1 0x41000000 -#define Exp_11 0x41000000 -#define Ebits 8 /* exponent has 7 bits, but 8 is the right value in b2d */ -#define Frac_mask 0xffffff -#define Frac_mask1 0xffffff -#define Bletch 4 -#define Ten_pmax 22 -#define Bndry_mask 0xefffff -#define Bndry_mask1 0xffffff -#define LSB 1 -#define Sign_bit 0x80000000 -#define Log2P 4 -#define Tiny0 0x100000 -#define Tiny1 0 -#define Quick_max 14 -#define Int_max 15 -#else /* VAX */ -#undef Flt_Rounds -#define Flt_Rounds 1 -#define Exp_shift 23 -#define Exp_shift1 7 -#define Exp_msk1 0x80 -#define Exp_msk11 0x800000 -#define Exp_mask 0x7f80 -#define P 56 -#define Bias 129 -#define Emin (-127) /* XXX: Check this */ -#define Exp_1 0x40800000 -#define Exp_11 0x4080 -#define Ebits 8 -#define Frac_mask 0x7fffff -#define Frac_mask1 0xffff007f -#define Ten_pmax 24 -#define Bletch 2 -#define Bndry_mask 0xffff007f -#define Bndry_mask1 0xffff007f -#define LSB 0x10000 -#define Sign_bit 0x8000 -#define Log2P 1 -#define Tiny0 0x80 -#define Tiny1 0 -#define Quick_max 15 -#define Int_max 15 -#endif /* IBM, VAX */ -#endif /* IEEE_Arith */ - -#ifndef IEEE_Arith -#define ROUND_BIASED -#else -#ifdef ROUND_BIASED_without_Round_Up -#undef ROUND_BIASED -#define ROUND_BIASED -#endif -#endif - -#ifdef RND_PRODQUOT -#define rounded_product(a,b) a = rnd_prod(a, b) -#define rounded_quotient(a,b) a = rnd_quot(a, b) -#ifdef KR_headers -extern double rnd_prod(), rnd_quot(); -#else -extern double rnd_prod(double, double), rnd_quot(double, double); -#endif -#else -#define rounded_product(a,b) a *= b -#define rounded_quotient(a,b) a /= b -#endif - -#define Big0 (Frac_mask1 | Exp_msk1*(DBL_MAX_EXP+Bias-1)) -#define Big1 0xffffffff - -#undef Pack_16 -#ifndef Pack_32 -#define Pack_32 -#endif - -#ifdef NO_LONG_LONG -#undef ULLong -#ifdef Just_16 -#undef Pack_32 -#define Pack_16 -/* When Pack_32 is not defined, we store 16 bits per 32-bit Long. - * This makes some inner loops simpler and sometimes saves work - * during multiplications, but it often seems to make things slightly - * slower. Hence the default is now to store 32 bits per Long. - */ -#endif -#else /* long long available */ -#ifndef Llong -#define Llong long long -#endif -#ifndef ULLong -#define ULLong unsigned Llong -#endif -#endif /* NO_LONG_LONG */ - -#ifdef Pack_32 -#define ULbits 32 -#define kshift 5 -#define kmask 31 -#define ALL_ON 0xffffffff -#else -#define ULbits 16 -#define kshift 4 -#define kmask 15 -#define ALL_ON 0xffff -#endif - -#ifndef MULTIPLE_THREADS -#define ACQUIRE_DTOA_LOCK(n) /*nothing*/ -#define FREE_DTOA_LOCK(n) /*nothing*/ -#else -#include "reentrant.h" - -extern mutex_t __gdtoa_locks[2]; - -#define ACQUIRE_DTOA_LOCK(n) \ - do { \ - if (__isthreaded) \ - mutex_lock(&__gdtoa_locks[n]); \ - } while (/* CONSTCOND */ 0) -#define FREE_DTOA_LOCK(n) \ - do { \ - if (__isthreaded) \ - mutex_unlock(&__gdtoa_locks[n]); \ - } while (/* CONSTCOND */ 0) -#endif - -#define Kmax (sizeof(size_t) << 3) - - struct -Bigint { - struct Bigint *next; - int k, maxwds, sign, wds; - ULong x[1]; - }; - - typedef struct Bigint Bigint; - -#ifdef NO_STRING_H -#ifdef DECLARE_SIZE_T -typedef unsigned int size_t; -#endif -extern void memcpy_D2A ANSI((void*, const void*, size_t)); -#define Bcopy(x,y) memcpy_D2A(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) -#else /* !NO_STRING_H */ -#define Bcopy(x,y) memcpy(&x->sign,&y->sign,y->wds*sizeof(ULong) + 2*sizeof(int)) -#endif /* NO_STRING_H */ - -#define Balloc __Balloc_D2A -#define Bfree __Bfree_D2A -#define ULtoQ __ULtoQ_D2A -#define ULtof __ULtof_D2A -#define ULtod __ULtod_D2A -#define ULtodd __ULtodd_D2A -#define ULtox __ULtox_D2A -#define ULtoxL __ULtoxL_D2A -#define any_on __any_on_D2A -#define b2d __b2d_D2A -#define bigtens __bigtens_D2A -#define cmp __cmp_D2A -#define copybits __copybits_D2A -#define d2b __d2b_D2A -#define decrement __decrement_D2A -#define diff __diff_D2A -#define dtoa_result __dtoa_result_D2A -#define g__fmt __g__fmt_D2A -#define gethex __gethex_D2A -#define hexdig __hexdig_D2A -#define hexdig_init_D2A __hexdig_init_D2A -#define hexnan __hexnan_D2A -#define hi0bits __hi0bits_D2A -#define hi0bits_D2A __hi0bits_D2A -#define i2b __i2b_D2A -#define increment __increment_D2A -#define lo0bits __lo0bits_D2A -#define lshift __lshift_D2A -#define match __match_D2A -#define mult __mult_D2A -#define multadd __multadd_D2A -#define nrv_alloc __nrv_alloc_D2A -#define pow5mult __pow5mult_D2A -#define quorem __quorem_D2A -#define ratio __ratio_D2A -#define rshift __rshift_D2A -#define rv_alloc __rv_alloc_D2A -#define s2b __s2b_D2A -#define set_ones __set_ones_D2A -#define strcp __strcp_D2A -#define strcp_D2A __strcp_D2A -#define strtoIg __strtoIg_D2A -#define sum __sum_D2A -#define tens __tens_D2A -#define tinytens __tinytens_D2A -#define tinytens __tinytens_D2A -#define trailz __trailz_D2A -#define ulp __ulp_D2A - - extern char *dtoa_result; - extern CONST double bigtens[], tens[], tinytens[]; - extern unsigned char hexdig[]; - - extern Bigint *Balloc ANSI((int)); - extern void Bfree ANSI((Bigint*)); - extern void ULtof ANSI((ULong*, ULong*, Long, int)); - extern void ULtod ANSI((ULong*, ULong*, Long, int)); - extern void ULtodd ANSI((ULong*, ULong*, Long, int)); - extern void ULtoQ ANSI((ULong*, ULong*, Long, int)); - extern void ULtox ANSI((UShort*, ULong*, Long, int)); - extern void ULtoxL ANSI((ULong*, ULong*, Long, int)); - extern ULong any_on ANSI((Bigint*, int)); - extern double b2d ANSI((Bigint*, int*)); - extern int cmp ANSI((Bigint*, Bigint*)); - extern void copybits ANSI((ULong*, int, Bigint*)); - extern Bigint *d2b ANSI((double, int*, int*)); - extern void decrement ANSI((Bigint*)); - extern Bigint *diff ANSI((Bigint*, Bigint*)); - extern char *dtoa ANSI((double d, int mode, int ndigits, - int *decpt, int *sign, char **rve)); - extern char *g__fmt ANSI((char*, char*, char*, int, ULong, size_t)); - extern int gethex ANSI((CONST char**, CONST FPI*, Long*, Bigint**, int, locale_t)); - extern void hexdig_init_D2A(Void); - extern int hexnan ANSI((CONST char**, CONST FPI*, ULong*)); - extern int hi0bits_D2A ANSI((ULong)); - extern Bigint *i2b ANSI((int)); - extern Bigint *increment ANSI((Bigint*)); - extern int lo0bits ANSI((ULong*)); - extern Bigint *lshift ANSI((Bigint*, int)); - extern int match ANSI((CONST char**, CONST char*)); - extern Bigint *mult ANSI((Bigint*, Bigint*)); - extern Bigint *multadd ANSI((Bigint*, int, int)); - extern char *nrv_alloc ANSI((CONST char*, char **, size_t)); - extern Bigint *pow5mult ANSI((Bigint*, int)); - extern int quorem ANSI((Bigint*, Bigint*)); - extern double ratio ANSI((Bigint*, Bigint*)); - extern void rshift ANSI((Bigint*, int)); - extern char *rv_alloc ANSI((size_t)); - extern Bigint *s2b ANSI((CONST char*, int, int, ULong, size_t)); - extern Bigint *set_ones ANSI((Bigint*, int)); - extern char *strcp ANSI((char*, const char*)); - extern int strtoIg ANSI((CONST char*, char**, FPI*, Long*, Bigint**, int*)); - extern double strtod ANSI((const char *s00, char **se)); - extern Bigint *sum ANSI((Bigint*, Bigint*)); - extern int trailz ANSI((CONST Bigint*)); - extern double ulp ANSI((U*)); - -#ifdef __cplusplus -} -#endif -/* - * NAN_WORD0 and NAN_WORD1 are only referenced in strtod.c. Prior to - * 20050115, they used to be hard-wired here (to 0x7ff80000 and 0, - * respectively), but now are determined by compiling and running - * qnan.c to generate gd_qnan.h, which specifies d_QNAN0 and d_QNAN1. - * Formerly gdtoaimp.h recommended supplying suitable -DNAN_WORD0=... - * and -DNAN_WORD1=... values if necessary. This should still work. - * (On HP Series 700/800 machines, -DNAN_WORD0=0x7ff40000 works.) - */ -#ifdef IEEE_Arith -#ifndef NO_INFNAN_CHECK -#undef INFNAN_CHECK -#define INFNAN_CHECK -#endif -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#ifndef NAN_WORD0 -#define NAN_WORD0 d_QNAN0 -#endif -#ifndef NAN_WORD1 -#define NAN_WORD1 d_QNAN1 -#endif -#else -#define _0 1 -#define _1 0 -#ifndef NAN_WORD0 -#define NAN_WORD0 d_QNAN1 -#endif -#ifndef NAN_WORD1 -#define NAN_WORD1 d_QNAN0 -#endif -#endif -#else -#undef INFNAN_CHECK -#endif - -#undef SI -#ifdef Sudden_Underflow -#define SI 1 -#else -#define SI 0 -#endif - -#endif /* GDTOAIMP_H_INCLUDED */ diff --git a/lib/libc/gdtoa/gethex.c b/lib/libc/gdtoa/gethex.c deleted file mode 100644 index 9818a284d..000000000 --- a/lib/libc/gdtoa/gethex.c +++ /dev/null @@ -1,338 +0,0 @@ -/* $NetBSD: gethex.c,v 1.6 2013/04/19 10:41:53 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#ifdef USE_LOCALE -#include "locale.h" -#endif - - int -gethex( CONST char **sp, CONST FPI *fpi, Long *expt, Bigint **bp, int sign, locale_t loc) -{ - Bigint *b; - CONST char *decpt, *s, *s0, *s1; - int big, esign, havedig, irv, j, k, n, n0, nbits, up, zret; - ULong L, lostbits, *x; - Long e, e1; -#ifdef USE_LOCALE - int i; - const char *decimalpoint = localeconv_l(loc)->decimal_point; -#endif - - if (!hexdig[(unsigned char)'0']) - hexdig_init_D2A(); - *bp = 0; - havedig = 0; - s0 = *(CONST char **)sp + 2; - while(s0[havedig] == '0') - havedig++; - s0 += havedig; - s = s0; - decpt = 0; - zret = 0; - e = 0; - if (hexdig[(unsigned char)*s]) - havedig++; - else { - zret = 1; -#ifdef USE_LOCALE - for(i = 0; decimalpoint[i]; ++i) { - if (s[i] != decimalpoint[i]) - goto pcheck; - } - decpt = s += i; -#else - if (*s != '.') - goto pcheck; - decpt = ++s; -#endif - if (!hexdig[(unsigned char)*s]) - goto pcheck; - while(*s == '0') - s++; - if (hexdig[(unsigned char)*s]) - zret = 0; - havedig = 1; - s0 = s; - } - while(hexdig[(unsigned char)*s]) - s++; -#ifdef USE_LOCALE - if (*s == *decimalpoint && !decpt) { - for(i = 1; decimalpoint[i]; ++i) { - if (s[i] != decimalpoint[i]) - goto pcheck; - } - decpt = s += i; -#else - if (*s == '.' && !decpt) { - decpt = ++s; -#endif - while(hexdig[(unsigned char)*s]) - s++; - }/*}*/ - if (decpt) - e = -(((Long)(s-decpt)) << 2); - pcheck: - s1 = s; - big = esign = 0; - switch(*s) { - case 'p': - case 'P': - switch(*++s) { - case '-': - esign = 1; - /* FALLTHROUGH */ - case '+': - s++; - } - if ((n = hexdig[(unsigned char)*s]) == 0 || n > 0x19) { - s = s1; - break; - } - e1 = n - 0x10; - while((n = hexdig[(unsigned char)*++s]) !=0 && n <= 0x19) { - if (e1 & 0xf8000000) - big = 1; - e1 = 10*e1 + n - 0x10; - } - if (esign) - e1 = -e1; - e += e1; - } - *sp = __UNCONST(s); - if (!havedig) - *sp = (char*)__UNCONST(s0) - 1; - if (zret) - return STRTOG_Zero; - if (big) { - if (esign) { - switch(fpi->rounding) { - case FPI_Round_up: - if (sign) - break; - goto ret_tiny; - case FPI_Round_down: - if (!sign) - break; - goto ret_tiny; - } - goto retz; - ret_tiny: - b = Balloc(0); - b->wds = 1; - b->x[0] = 1; - goto dret; - } - switch(fpi->rounding) { - case FPI_Round_near: - goto ovfl1; - case FPI_Round_up: - if (!sign) - goto ovfl1; - goto ret_big; - case FPI_Round_down: - if (sign) - goto ovfl1; - goto ret_big; - } - ret_big: - nbits = fpi->nbits; - n0 = n = (unsigned int)nbits >> kshift; - if (nbits & kmask) - ++n; - for(j = n, k = 0; (j = (unsigned int)j >> 1) != 0; ++k); - *bp = b = Balloc(k); - b->wds = n; - for(j = 0; j < n0; ++j) - b->x[j] = ALL_ON; - if (n > n0) - b->x[j] = ULbits >> (ULbits - (nbits & kmask)); - *expt = fpi->emin; - return STRTOG_Normal | STRTOG_Inexlo; - } - n = (int)(s1 - s0) - 1; - for(k = 0; n > (1 << (kshift-2)) - 1; n = (unsigned int)n >> 1) - k++; - b = Balloc(k); - if (b == NULL) - return STRTOG_NoMemory; - x = b->x; - n = 0; - L = 0; -#ifdef USE_LOCALE - for(i = 0; decimalpoint[i+1]; ++i); -#endif - while(s1 > s0) { -#ifdef USE_LOCALE - if (*--s1 == decimalpoint[i]) { - s1 -= i; - continue; - } -#else - if (*--s1 == '.') - continue; -#endif - if (n == ULbits) { - *x++ = L; - L = 0; - n = 0; - } - L |= (hexdig[(unsigned char)*s1] & 0x0f) << n; - n += 4; - } - *x++ = L; - b->wds = n = (int)(x - b->x); - n = ULbits*n - hi0bits(L); - nbits = fpi->nbits; - lostbits = 0; - x = b->x; - if (n > nbits) { - n -= nbits; - if (any_on(b,n)) { - lostbits = 1; - k = n - 1; - if (x[(unsigned int)k>>kshift] & 1 << (k & kmask)) { - lostbits = 2; - if (k > 0 && any_on(b,k)) - lostbits = 3; - } - } - rshift(b, n); - e += n; - } - else if (n < nbits) { - n = nbits - n; - b = lshift(b, n); - if (b == NULL) - return STRTOG_NoMemory; - e -= n; - x = b->x; - } - if (e > fpi->emax) { - ovfl: - Bfree(b); - ovfl1: -#ifndef NO_ERRNO - errno = ERANGE; -#endif - return STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; - } - irv = STRTOG_Normal; - if (e < fpi->emin) { - irv = STRTOG_Denormal; - n = fpi->emin - e; - if (n >= nbits) { - switch (fpi->rounding) { - case FPI_Round_near: - if (n == nbits && (n < 2 || any_on(b,n-1))) - goto one_bit; - break; - case FPI_Round_up: - if (!sign) - goto one_bit; - break; - case FPI_Round_down: - if (sign) { - one_bit: - x[0] = b->wds = 1; - dret: - *bp = b; - *expt = fpi->emin; -#ifndef NO_ERRNO - errno = ERANGE; -#endif - return STRTOG_Denormal | STRTOG_Inexhi - | STRTOG_Underflow; - } - } - Bfree(b); - retz: -#ifndef NO_ERRNO - errno = ERANGE; -#endif - return STRTOG_Zero | STRTOG_Inexlo | STRTOG_Underflow; - } - k = n - 1; - if (lostbits) - lostbits = 1; - else if (k > 0) - lostbits = any_on(b,k); - if (x[(unsigned int)k>>kshift] & 1 << (k & kmask)) - lostbits |= 2; - nbits -= n; - rshift(b,n); - e = fpi->emin; - } - if (lostbits) { - up = 0; - switch(fpi->rounding) { - case FPI_Round_zero: - break; - case FPI_Round_near: - if (lostbits & 2 - && (lostbits | x[0]) & 1) - up = 1; - break; - case FPI_Round_up: - up = 1 - sign; - break; - case FPI_Round_down: - up = sign; - } - if (up) { - k = b->wds; - b = increment(b); - x = b->x; - if (irv == STRTOG_Denormal) { - if (nbits == fpi->nbits - 1 - && x[(unsigned int)nbits >> kshift] & 1 << (nbits & kmask)) - irv = STRTOG_Normal; - } - else if (b->wds > k - || ((n = nbits & kmask) !=0 - && hi0bits(x[k-1]) < 32-n)) { - rshift(b,1); - if (++e > fpi->emax) - goto ovfl; - } - irv |= STRTOG_Inexhi; - } - else - irv |= STRTOG_Inexlo; - } - *bp = b; - *expt = e; - return irv; - } diff --git a/lib/libc/gdtoa/gmisc.c b/lib/libc/gdtoa/gmisc.c deleted file mode 100644 index 9c54580f9..000000000 --- a/lib/libc/gdtoa/gmisc.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: gmisc.c,v 1.4 2012/03/13 21:13:34 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - void -#ifdef KR_headers -rshift(b, k) Bigint *b; int k; -#else -rshift(Bigint *b, int k) -#endif -{ - ULong *x, *x1, *xe, y; - int n; - - x = x1 = b->x; - n = (unsigned int)k >> kshift; - if (n < b->wds) { - xe = x + b->wds; - x += n; - if (k &= kmask) { - n = ULbits - k; - y = *x++ >> k; - while(x < xe) { - *x1++ = (y | (*x << n)) & ALL_ON; - y = *x++ >> k; - } - if ((*x1 = y) !=0) - x1++; - } - else - while(x < xe) - *x1++ = *x++; - } - - ptrdiff_t td = x1 - b->x; - _DIAGASSERT(__type_fit(int, td)); - if ((b->wds = (int)td) == 0) - b->x[0] = 0; - } - - int -#ifdef KR_headers -trailz(b) CONST Bigint *b; -#else -trailz(CONST Bigint *b) -#endif -{ - ULong L; - CONST ULong *x, *xe; - int n = 0; - - x = b->x; - xe = x + b->wds; - for(n = 0; x < xe && !*x; x++) - n += ULbits; - if (x < xe) { - L = *x; - n += lo0bits(&L); - } - return n; - } diff --git a/lib/libc/gdtoa/hd_init.c b/lib/libc/gdtoa/hd_init.c deleted file mode 100644 index 55d5d426c..000000000 --- a/lib/libc/gdtoa/hd_init.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: hd_init.c,v 1.2 2006/01/25 15:27:42 kleink Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - unsigned char hexdig[256]; - - static void -#ifdef KR_headers -htinit(h, s, inc) unsigned char *h; CONST unsigned char *s; int inc; -#else -htinit(unsigned char *h, CONST unsigned char *s, int inc) -#endif -{ - int i, j; - for(i = 0; (j = s[i]) !=0; i++) - h[j] = i + inc; - } - - void -hexdig_init_D2A(Void) -{ -#define USC (CONST unsigned char *) - htinit(hexdig, USC "0123456789", 0x10); - htinit(hexdig, USC "abcdef", 0x10 + 10); - htinit(hexdig, USC "ABCDEF", 0x10 + 10); - } diff --git a/lib/libc/gdtoa/hdtoa.c b/lib/libc/gdtoa/hdtoa.c deleted file mode 100644 index 243bd05ff..000000000 --- a/lib/libc/gdtoa/hdtoa.c +++ /dev/null @@ -1,371 +0,0 @@ -/* $NetBSD: hdtoa.c,v 1.9 2011/07/04 11:46:41 mrg Exp $ */ - -/*- - * Copyright (c) 2004, 2005 David Schultz - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if 0 -__FBSDID("$FreeBSD: src/lib/libc/gdtoa/_hdtoa.c,v 1.4 2007/01/03 04:57:58 das Exp $"); -#else -__RCSID("$NetBSD: hdtoa.c,v 1.9 2011/07/04 11:46:41 mrg Exp $"); -#endif - -#include -#include -#include -#ifndef __vax__ -#include -#else -#include -#define ieee_double_u vax_dfloating_u -#define dblu_d dfltu_d -#define dblu_dbl dfltu_dflt -#define dbl_sign dflt_sign -#define dbl_exp dflt_exp -#define dbl_frach dflt_frach -#define dbl_fracm dflt_fracm -#define dbl_fracl dflt_fracl -#define DBL_FRACHBITS DFLT_FRACHBITS -#define DBL_FRACMBITS DFLT_FRACMBITS -#define DBL_FRACLBITS DFLT_FRACLBITS -#define DBL_EXPBITS DFLT_EXPBITS -#endif -#include "gdtoaimp.h" - -/* Strings values used by dtoa() */ -#define INFSTR "Infinity" -#define NANSTR "NaN" - -#define DBL_ADJ (DBL_MAX_EXP - 2 + ((DBL_MANT_DIG - 1) % 4)) -#define LDBL_ADJ (LDBL_MAX_EXP - 2 + ((LDBL_MANT_DIG - 1) % 4)) - -/* - * Round up the given digit string. If the digit string is fff...f, - * this procedure sets it to 100...0 and returns 1 to indicate that - * the exponent needs to be bumped. Otherwise, 0 is returned. - */ -static int -roundup(char *s0, int ndigits) -{ - char *s; - - for (s = s0 + ndigits - 1; *s == 0xf; s--) { - if (s == s0) { - *s = 1; - return (1); - } - *s = 0; - } - ++*s; - return (0); -} - -/* - * Round the given digit string to ndigits digits according to the - * current rounding mode. Note that this could produce a string whose - * value is not representable in the corresponding floating-point - * type. The exponent pointed to by decpt is adjusted if necessary. - */ -static void -dorounding(char *s0, int ndigits, int sign, int *decpt) -{ - int adjust = 0; /* do we need to adjust the exponent? */ - - switch (FLT_ROUNDS) { - case 0: /* toward zero */ - default: /* implementation-defined */ - break; - case 1: /* to nearest, halfway rounds to even */ - if ((s0[ndigits] > 8) || - (s0[ndigits] == 8 && s0[ndigits - 1] & 1)) - adjust = roundup(s0, ndigits); - break; - case 2: /* toward +inf */ - if (sign == 0) - adjust = roundup(s0, ndigits); - break; - case 3: /* toward -inf */ - if (sign != 0) - adjust = roundup(s0, ndigits); - break; - } - - if (adjust) - *decpt += 4; -} - -/* - * This procedure converts a double-precision number in IEEE format - * into a string of hexadecimal digits and an exponent of 2. Its - * behavior is bug-for-bug compatible with dtoa() in mode 2, with the - * following exceptions: - * - * - An ndigits < 0 causes it to use as many digits as necessary to - * represent the number exactly. - * - The additional xdigs argument should point to either the string - * "0123456789ABCDEF" or the string "0123456789abcdef", depending on - * which case is desired. - * - This routine does not repeat dtoa's mistake of setting decpt - * to 9999 in the case of an infinity or NaN. INT_MAX is used - * for this purpose instead. - * - * Note that the C99 standard does not specify what the leading digit - * should be for non-zero numbers. For instance, 0x1.3p3 is the same - * as 0x2.6p2 is the same as 0x4.cp3. This implementation chooses the - * first digit so that subsequent digits are aligned on nibble - * boundaries (before rounding). - * - * Inputs: d, xdigs, ndigits - * Outputs: decpt, sign, rve - */ -char * -hdtoa(double d, const char *xdigs, int ndigits, int *decpt, int *sign, - char **rve) -{ - static const int sigfigs = (DBL_MANT_DIG + 3) / 4; - union ieee_double_u u; - char *s, *s0; - size_t bufsize; - - u.dblu_d = d; - *sign = u.dblu_dbl.dbl_sign; - - switch (fpclassify(d)) { - case FP_NORMAL: - *decpt = u.dblu_dbl.dbl_exp - DBL_ADJ; - break; - case FP_ZERO: - *decpt = 1; - return (nrv_alloc("0", rve, 1)); - case FP_SUBNORMAL: -#ifdef __vax__ - /* (DBL_MAX_EXP=127 / 2) + 2 = 65? */ - u.dblu_d *= 0x1p65; - *decpt = u.dblu_dbl.dbl_exp - (65 + DBL_ADJ); -#else - /* (DBL_MAX_EXP=1024 / 2) + 2 = 514? */ - u.dblu_d *= 0x1p514; - *decpt = u.dblu_dbl.dbl_exp - (514 + DBL_ADJ); -#endif - break; - case FP_INFINITE: - *decpt = INT_MAX; - return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1)); - case FP_NAN: - *decpt = INT_MAX; - return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1)); - default: - abort(); - } - - /* FP_NORMAL or FP_SUBNORMAL */ - - if (ndigits == 0) /* dtoa() compatibility */ - ndigits = 1; - - /* - * For simplicity, we generate all the digits even if the - * caller has requested fewer. - */ - bufsize = (sigfigs > ndigits) ? sigfigs : ndigits; - s0 = rv_alloc(bufsize); - if (s0 == NULL) - return NULL; - - /* - * We work from right to left, first adding any requested zero - * padding, then the least significant portion of the - * mantissa, followed by the most significant. The buffer is - * filled with the byte values 0x0 through 0xf, which are - * converted to xdigs[0x0] through xdigs[0xf] after the - * rounding phase. - */ - for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--) - *s = 0; - for (; s > s0 + sigfigs - (DBL_FRACLBITS / 4) - 1 && s > s0; s--) { - *s = u.dblu_dbl.dbl_fracl & 0xf; - u.dblu_dbl.dbl_fracl >>= 4; - } -#ifdef DBL_FRACMBITS - for (; s > s0; s--) { - *s = u.dblu_dbl.dbl_fracm & 0xf; - u.dblu_dbl.dbl_fracm >>= 4; - } -#endif - for (; s > s0; s--) { - *s = u.dblu_dbl.dbl_frach & 0xf; - u.dblu_dbl.dbl_frach >>= 4; - } - - /* - * At this point, we have snarfed all the bits in the - * mantissa, with the possible exception of the highest-order - * (partial) nibble, which is dealt with by the next - * statement. We also tack on the implicit normalization bit. - */ - *s = u.dblu_dbl.dbl_frach | (1U << ((DBL_MANT_DIG - 1) % 4)); - - /* If ndigits < 0, we are expected to auto-size the precision. */ - if (ndigits < 0) { - for (ndigits = sigfigs; s0[ndigits - 1] == 0; ndigits--) - continue; - } - - if (sigfigs > ndigits && s0[ndigits] != 0) - dorounding(s0, ndigits, u.dblu_dbl.dbl_sign, decpt); - - s = s0 + ndigits; - if (rve != NULL) - *rve = s; - *s-- = '\0'; - for (; s >= s0; s--) - *s = xdigs[(unsigned int)*s]; - - return (s0); -} - -#if (LDBL_MANT_DIG > DBL_MANT_DIG) - -/* - * This is the long double version of hdtoa(). - */ -char * -hldtoa(long double e, const char *xdigs, int ndigits, int *decpt, int *sign, - char **rve) -{ - static const int sigfigs = (LDBL_MANT_DIG + 3) / 4; - union ieee_ext_u u; - char *s, *s0; - size_t bufsize; - - memset(&u, 0, sizeof u); - u.extu_ld = e; - *sign = u.extu_ext.ext_sign; - - switch (fpclassify(e)) { - case FP_NORMAL: - *decpt = u.extu_ext.ext_exp - LDBL_ADJ; - break; - case FP_ZERO: - *decpt = 1; - return (nrv_alloc("0", rve, 1)); - case FP_SUBNORMAL: - u.extu_ld *= 0x1p514L; - *decpt = u.extu_ext.ext_exp - (514 + LDBL_ADJ); - break; - case FP_INFINITE: - *decpt = INT_MAX; - return (nrv_alloc(INFSTR, rve, sizeof(INFSTR) - 1)); - case FP_NAN: - *decpt = INT_MAX; - return (nrv_alloc(NANSTR, rve, sizeof(NANSTR) - 1)); - default: - abort(); - } - - /* FP_NORMAL or FP_SUBNORMAL */ - - if (ndigits == 0) /* dtoa() compatibility */ - ndigits = 1; - - /* - * For simplicity, we generate all the digits even if the - * caller has requested fewer. - */ - bufsize = (sigfigs > ndigits) ? sigfigs : ndigits; - s0 = rv_alloc(bufsize); - if (s0 == NULL) - return NULL; - - /* - * We work from right to left, first adding any requested zero - * padding, then the least significant portion of the - * mantissa, followed by the most significant. The buffer is - * filled with the byte values 0x0 through 0xf, which are - * converted to xdigs[0x0] through xdigs[0xf] after the - * rounding phase. - */ - for (s = s0 + bufsize - 1; s > s0 + sigfigs - 1; s--) - *s = 0; - for (; s > s0 + sigfigs - (EXT_FRACLBITS / 4) - 1 && s > s0; s--) { - *s = u.extu_ext.ext_fracl & 0xf; - u.extu_ext.ext_fracl >>= 4; - } -#ifdef EXT_FRACHMBITS - for (; s > s0; s--) { - *s = u.extu_ext.ext_frachm & 0xf; - u.extu_ext.ext_frachm >>= 4; - } -#endif -#ifdef EXT_FRACLMBITS - for (; s > s0; s--) { - *s = u.extu_ext.ext_fraclm & 0xf; - u.extu_ext.ext_fraclm >>= 4; - } -#endif - for (; s > s0; s--) { - *s = u.extu_ext.ext_frach & 0xf; - u.extu_ext.ext_frach >>= 4; - } - - /* - * At this point, we have snarfed all the bits in the - * mantissa, with the possible exception of the highest-order - * (partial) nibble, which is dealt with by the next - * statement. We also tack on the implicit normalization bit. - */ - *s = u.extu_ext.ext_frach | (1U << ((LDBL_MANT_DIG - 1) % 4)); - - /* If ndigits < 0, we are expected to auto-size the precision. */ - if (ndigits < 0) { - for (ndigits = sigfigs; s0[ndigits - 1] == 0; ndigits--) - continue; - } - - if (sigfigs > ndigits && s0[ndigits] != 0) - dorounding(s0, ndigits, u.extu_ext.ext_sign, decpt); - - s = s0 + ndigits; - if (rve != NULL) - *rve = s; - *s-- = '\0'; - for (; s >= s0; s--) - *s = xdigs[(unsigned int)*s]; - - return (s0); -} - -#else /* (LDBL_MANT_DIG == DBL_MANT_DIG) */ - -char * -hldtoa(long double e, const char *xdigs, int ndigits, int *decpt, int *sign, - char **rve) -{ - - return (hdtoa((double)e, xdigs, ndigits, decpt, sign, rve)); -} - -#endif /* (LDBL_MANT_DIG == DBL_MANT_DIG) */ diff --git a/lib/libc/gdtoa/hexnan.c b/lib/libc/gdtoa/hexnan.c deleted file mode 100644 index 267703e78..000000000 --- a/lib/libc/gdtoa/hexnan.c +++ /dev/null @@ -1,152 +0,0 @@ -/* $NetBSD: hexnan.c,v 1.5 2011/03/21 04:52:09 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - static void -#ifdef KR_headers -L_shift(x, x1, i) ULong *x; ULong *x1; int i; -#else -L_shift(ULong *x, ULong *x1, int i) -#endif -{ - int j; - - i = 8 - i; - i <<= 2; - j = ULbits - i; - do { - *x |= x[1] << j; - x[1] >>= i; - } while(++x < x1); - } - - int -#ifdef KR_headers -hexnan(sp, fpi, x0) - CONST char **sp; CONST FPI *fpi; ULong *x0; -#else -hexnan( CONST char **sp, CONST FPI *fpi, ULong *x0) -#endif -{ - ULong c, h, *x, *x1, *xe; - CONST char *s; - int havedig, hd0, i, nbits; - - if (!hexdig['0']) - hexdig_init_D2A(); - nbits = fpi->nbits; - x = x0 + ((unsigned int)nbits >> kshift); - if (nbits & kmask) - x++; - *--x = 0; - x1 = xe = x; - havedig = hd0 = i = 0; - s = *sp; - /* allow optional initial 0x or 0X */ - while((c = *(CONST unsigned char*)(s+1)) && c <= ' ') - ++s; - if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X') - && *(CONST unsigned char*)(s+3) > ' ') - s += 2; - while((c = *(CONST unsigned char*)++s) != '\0') { - if (!(h = hexdig[c])) { - if (c <= ' ') { - if (hd0 < havedig) { - if (x < x1 && i < 8) - L_shift(x, x1, i); - if (x <= x0) { - i = 8; - continue; - } - hd0 = havedig; - *--x = 0; - x1 = x; - i = 0; - } - while(*(CONST unsigned char*)(s+1) <= ' ') - ++s; - if (s[1] == '0' && (s[2] == 'x' || s[2] == 'X') - && *(CONST unsigned char*)(s+3) > ' ') - s += 2; - continue; - } - if (/*(*/ c == ')' && havedig) { - *sp = s + 1; - break; - } -#ifndef GDTOA_NON_PEDANTIC_NANCHECK - do { - if (/*(*/ c == ')') { - *sp = s + 1; - break; - } - } while((c = *++s) != '\0'); -#endif - return STRTOG_NaN; - } - havedig++; - if (++i > 8) { - if (x <= x0) - continue; - i = 1; - *--x = 0; - } - *x = (*x << 4) | (h & 0xf); - } - if (!havedig) - return STRTOG_NaN; - if (x < x1 && i < 8) - L_shift(x, x1, i); - if (x > x0) { - x1 = x0; - do *x1++ = *x++; - while(x <= xe); - do *x1++ = 0; - while(x1 <= xe); - } - else { - /* truncate high-order word if necessary */ - if ( (i = nbits & (ULbits-1)) !=0) - *xe &= ((ULong)0xffffffff) >> (ULbits - i); - } - for(x1 = xe;; --x1) { - if (*x1 != 0) - break; - if (x1 == x0) { - *x1 = 1; - break; - } - } - return STRTOG_NaNbits; - } diff --git a/lib/libc/gdtoa/ldtoa.c b/lib/libc/gdtoa/ldtoa.c deleted file mode 100644 index de026025a..000000000 --- a/lib/libc/gdtoa/ldtoa.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $NetBSD: ldtoa.c,v 1.4 2007/02/23 17:45:59 christos Exp $ */ - -/*- - * Copyright (c) 2003 David Schultz - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if 0 -__FBSDID("$FreeBSD: src/lib/libc/gdtoa/_ldtoa.c,v 1.2 2004/01/18 07:53:49 das Exp $"); -#else -__RCSID("$NetBSD: ldtoa.c,v 1.4 2007/02/23 17:45:59 christos Exp $"); -#endif - -#include -#include -#include -#include -#include -#ifndef __vax__ -#include -#endif -#include "gdtoaimp.h" - -/* - * ldtoa() is a wrapper for gdtoa() that makes it smell like dtoa(), - * except that the floating point argument is passed by reference. - * When dtoa() is passed a NaN or infinity, it sets expt to 9999. - * However, a long double could have a valid exponent of 9999, so we - * use INT_MAX in ldtoa() instead. - */ -char * -ldtoa(long double *ld, int mode, int ndigits, int *decpt, int *sign, char **rve) -{ -#ifdef EXT_EXPBITS - static FPI fpi = { - LDBL_MANT_DIG, /* nbits */ - LDBL_MIN_EXP - LDBL_MANT_DIG, /* emin */ - LDBL_MAX_EXP - LDBL_MANT_DIG, /* emax */ - FPI_Round_near, /* rounding */ -#ifdef Sudden_Underflow /* unused, but correct anyway */ - 1 -#else - 0 -#endif - }; - int be, kind; - char *ret; - union ieee_ext_u u; - uint32_t bits[(LDBL_MANT_DIG + 31) / 32]; - - u.extu_ld = *ld; - *sign = u.extu_ext.ext_sign; - be = u.extu_ext.ext_exp - (LDBL_MAX_EXP - 1) - (LDBL_MANT_DIG - 1); - EXT_TO_ARRAY32(u, bits); - - switch (fpclassify(u.extu_ld)) { - case FP_NORMAL: - kind = STRTOG_Normal; -#ifdef LDBL_IMPLICIT_NBIT - bits[LDBL_MANT_DIG / 32] |= 1 << ((LDBL_MANT_DIG - 1) % 32); -#endif /* LDBL_IMPLICIT_NBIT */ - break; - case FP_ZERO: - kind = STRTOG_Zero; - break; - case FP_SUBNORMAL: - kind = STRTOG_Denormal; -#ifdef LDBL_IMPLICIT_NBIT - be++; -#endif - break; - case FP_INFINITE: - kind = STRTOG_Infinite; - break; - case FP_NAN: - kind = STRTOG_NaN; - break; - default: - abort(); - } - - ret = gdtoa(&fpi, be, (ULong *)bits, &kind, mode, ndigits, decpt, rve); - if (*decpt == -32768) - *decpt = INT_MAX; - return ret; -#else - return dtoa((double)*ld, mode, ndigits, decpt, sign, rve); -#endif -} diff --git a/lib/libc/gdtoa/makefile b/lib/libc/gdtoa/makefile deleted file mode 100644 index 62f14df2e..000000000 --- a/lib/libc/gdtoa/makefile +++ /dev/null @@ -1,87 +0,0 @@ -# $NetBSD: makefile,v 1.4 2011/03/20 23:15:35 christos Exp $ - -# /**************************************************************** -# Copyright (C) 1998 by Lucent Technologies -# All Rights Reserved -# -# Permission to use, copy, modify, and distribute this software and -# its documentation for any purpose and without fee is hereby -# granted, provided that the above copyright notice appear in all -# copies and that both that the copyright notice and this -# permission notice and warranty disclaimer appear in supporting -# documentation, and that the name of Lucent or any of its entities -# not be used in advertising or publicity pertaining to -# distribution of the software without specific, written prior -# permission. -# -# LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -# IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -# THIS SOFTWARE. -# -# ****************************************************************/ - -.SUFFIXES: .c .o -CC = cc -CFLAGS = -g - -.c.o: - $(CC) -c $(CFLAGS) $*.c - -# invoke "make Printf" to add printf.o to gdtoa.a (if desired) - -all: arith.h gd_qnan.h gdtoa.a - -arith.h: arithchk.c - $(CC) $(CFLAGS) arithchk.c || $(CC) -DNO_LONG_LONG $(CFLAGS) arithchk.c - ./a.out >arith.h - rm -f a.out arithchk.o - -gd_qnan.h: arith.h qnan.c - $(CC) $(CFLAGS) qnan.c - ./a.out >gd_qnan.h - rm -f a.out qnan.o - -gdtoa.a: dmisc.c dtoa.c g_Qfmt.c g__fmt.c g_ddfmt.c g_dfmt.c\ - g_ffmt.c g_xLfmt.c g_xfmt.c gdtoa.c gethex.c gmisc.c hd_init.c\ - hexnan.c misc.c smisc.c strtoIQ.c strtoId.c strtoIdd.c\ - strtoIf.c strtoIg.c strtoIx.c strtoIxL.c strtod.c strtodI.c\ - strtodg.c strtof.c strtopQ.c strtopd.c strtopdd.c strtopf.c\ - strtopx.c strtopxL.c strtorQ.c strtord.c strtordd.c strtorf.c\ - strtorx.c strtorxL.c sum.c ulp.c - $(CC) -c $(CFLAGS) $? - x=`echo $? | sed 's/\.c/.o/g'` && ar ruv gdtoa.a $$x && rm $$x - ranlib gdtoa.a || true - -Printf: all printf.c - $(CC) -c $(CFLAGS) printf.c - ar ruv gdtoa.a printf.o - rm printf.o - touch Printf - -# If your system lacks ranlib, you do not need it. - -xs0 = README arithchk.c dmisc.c dtoa.c g_Qfmt.c g__fmt.c g_ddfmt.c\ - g_dfmt.c g_ffmt.c g_xLfmt.c g_xfmt.c gdtoa.c gdtoa.h\ - gdtoa_fltrnds.h gdtoaimp.h gethex.c gmisc.c hd_init.c hexnan.c\ - makefile misc.c printf.c printf.c0 qnan.c smisc.c stdio1.h\ - strtoIQ.c strtoId.c strtoIdd.c strtoIf.c strtoIg.c strtoIx.c\ - strtoIxL.c strtod.c strtodI.c strtodg.c strtodnrp.c strtof.c\ - strtopQ.c strtopd.c strtopdd.c strtopf.c strtopx.c strtopxL.c\ - strtorQ.c strtord.c strtordd.c strtorf.c strtorx.c strtorxL.c\ - sum.c ulp.c - -# "make -r xsum.out" to check for transmission errors; source for xsum is -# netlib's "xsum.c from f2c", e.g., -# ftp://netlib.bell-labs.com/netlib/f2c/xsum.c.gz - -xsum.out: xsum0.out $(xs0) - xsum $(xs0) >xsum1.out - cmp xsum0.out xsum1.out && mv xsum1.out xsum.out || diff xsum[01].out - -clean: - rm -f arith.h gd_qnan.h *.[ao] Printf xsum.out xsum1.out diff --git a/lib/libc/gdtoa/misc.c b/lib/libc/gdtoa/misc.c deleted file mode 100644 index 9f3d4c008..000000000 --- a/lib/libc/gdtoa/misc.c +++ /dev/null @@ -1,920 +0,0 @@ -/* $NetBSD: misc.c,v 1.11 2011/11/21 09:46:19 mlelstv Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 1999 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - static Bigint *freelist[Kmax+1]; -#ifndef Omit_Private_Memory -#ifndef PRIVATE_MEM -#define PRIVATE_MEM 2304 -#endif -#define PRIVATE_mem ((PRIVATE_MEM+sizeof(double)-1)/sizeof(double)) -static double private_mem[PRIVATE_mem], *pmem_next = private_mem; -#endif - - Bigint * -Balloc -#ifdef KR_headers - (k) int k; -#else - (int k) -#endif -{ - int x; - Bigint *rv; -#ifndef Omit_Private_Memory - size_t len; -#endif - - ACQUIRE_DTOA_LOCK(0); - /* The k > Kmax case does not need ACQUIRE_DTOA_LOCK(0), */ - /* but this case seems very unlikely. */ - if ((size_t)k <= Kmax && (rv = freelist[k]) !=0) { - freelist[k] = rv->next; - } - else { - x = 1 << k; -#ifdef Omit_Private_Memory - rv = (Bigint *)MALLOC(sizeof(Bigint) + (x-1)*sizeof(ULong)); -#else - len = (sizeof(Bigint) + (x-1)*sizeof(ULong) + sizeof(double) - 1) - /sizeof(double); - if ((size_t)k <= Kmax && pmem_next - private_mem + len <= PRIVATE_mem) { - rv = (Bigint*)(void *)pmem_next; - pmem_next += len; - } - else - rv = (Bigint*)MALLOC(len*sizeof(double)); -#endif - if (rv == NULL) { - FREE_DTOA_LOCK(0); - return NULL; - } - rv->k = k; - rv->maxwds = x; - } - FREE_DTOA_LOCK(0); - rv->sign = rv->wds = 0; - return rv; - } - - void -Bfree -#ifdef KR_headers - (v) Bigint *v; -#else - (Bigint *v) -#endif -{ - if (v) { - if ((size_t)v->k > Kmax) -#ifdef FREE - FREE((void*)v); -#else - free((void*)v); -#endif - else { - ACQUIRE_DTOA_LOCK(0); - v->next = freelist[v->k]; - freelist[v->k] = v; - FREE_DTOA_LOCK(0); - } - } - } - - int -lo0bits -#ifdef KR_headers - (y) ULong *y; -#else - (ULong *y) -#endif -{ - int k; - ULong x = *y; - - if (x & 7) { - if (x & 1) - return 0; - if (x & 2) { - *y = x >> 1; - return 1; - } - *y = x >> 2; - return 2; - } - k = 0; - if (!(x & 0xffff)) { - k = 16; - x >>= 16; - } - if (!(x & 0xff)) { - k += 8; - x >>= 8; - } - if (!(x & 0xf)) { - k += 4; - x >>= 4; - } - if (!(x & 0x3)) { - k += 2; - x >>= 2; - } - if (!(x & 1)) { - k++; - x >>= 1; - if (!x) - return 32; - } - *y = x; - return k; - } - - Bigint * -multadd -#ifdef KR_headers - (b, m, a) Bigint *b; int m, a; -#else - (Bigint *b, int m, int a) /* multiply by m and add a */ -#endif -{ - int i, wds; -#ifdef ULLong - ULong *x; - ULLong carry, y; -#else - ULong carry, *x, y; -#ifdef Pack_32 - ULong xi, z; -#endif -#endif - Bigint *b1; - - wds = b->wds; - x = b->x; - i = 0; - carry = a; - do { -#ifdef ULLong - y = *x * (ULLong)m + carry; - carry = y >> 32; - /* LINTED conversion */ - *x++ = y & 0xffffffffUL; -#else -#ifdef Pack_32 - xi = *x; - y = (xi & 0xffff) * m + carry; - z = (xi >> 16) * m + (y >> 16); - carry = z >> 16; - *x++ = (z << 16) + (y & 0xffff); -#else - y = *x * m + carry; - carry = y >> 16; - *x++ = y & 0xffff; -#endif -#endif - } - while(++i < wds); - if (carry) { - if (wds >= b->maxwds) { - b1 = Balloc(b->k+1); - if (b1 == NULL) { - Bfree(b); - return NULL; - } - Bcopy(b1, b); - Bfree(b); - b = b1; - } - /* LINTED conversion */ - b->x[wds++] = carry; - b->wds = wds; - } - return b; - } - - int -hi0bits_D2A -#ifdef KR_headers - (x) ULong x; -#else - (ULong x) -#endif -{ - int k = 0; - - if (!(x & 0xffff0000)) { - k = 16; - x <<= 16; - } - if (!(x & 0xff000000)) { - k += 8; - x <<= 8; - } - if (!(x & 0xf0000000)) { - k += 4; - x <<= 4; - } - if (!(x & 0xc0000000)) { - k += 2; - x <<= 2; - } - if (!(x & 0x80000000)) { - k++; - if (!(x & 0x40000000)) - return 32; - } - return k; - } - - Bigint * -i2b -#ifdef KR_headers - (i) int i; -#else - (int i) -#endif -{ - Bigint *b; - - b = Balloc(1); - if (b == NULL) - return NULL; - b->x[0] = i; - b->wds = 1; - return b; - } - - Bigint * -mult -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - Bigint *c; - int k, wa, wb, wc; - ULong *x, *xa, *xae, *xb, *xbe, *xc, *xc0; - ULong y; -#ifdef ULLong - ULLong carry, z; -#else - ULong carry, z; -#ifdef Pack_32 - ULong z2; -#endif -#endif - - if (a->wds < b->wds) { - c = a; - a = b; - b = c; - } - k = a->k; - wa = a->wds; - wb = b->wds; - wc = wa + wb; - if (wc > a->maxwds) - k++; - c = Balloc(k); - if (c == NULL) - return NULL; - for(x = c->x, xa = x + wc; x < xa; x++) - *x = 0; - xa = a->x; - xae = xa + wa; - xb = b->x; - xbe = xb + wb; - xc0 = c->x; -#ifdef ULLong - for(; xb < xbe; xc0++) { - if ( (y = *xb++) !=0) { - x = xa; - xc = xc0; - carry = 0; - do { - z = *x++ * (ULLong)y + *xc + carry; - carry = z >> 32; - /* LINTED conversion */ - *xc++ = z & 0xffffffffUL; - } - while(x < xae); - /* LINTED conversion */ - *xc = carry; - } - } -#else -#ifdef Pack_32 - for(; xb < xbe; xb++, xc0++) { - if ( (y = *xb & 0xffff) !=0) { - x = xa; - xc = xc0; - carry = 0; - do { - z = (*x & 0xffff) * y + (*xc & 0xffff) + carry; - carry = z >> 16; - z2 = (*x++ >> 16) * y + (*xc >> 16) + carry; - carry = z2 >> 16; - Storeinc(xc, z2, z); - } - while(x < xae); - *xc = carry; - } - if ( (y = *xb >> 16) !=0) { - x = xa; - xc = xc0; - carry = 0; - z2 = *xc; - do { - z = (*x & 0xffff) * y + (*xc >> 16) + carry; - carry = z >> 16; - Storeinc(xc, z, z2); - z2 = (*x++ >> 16) * y + (*xc & 0xffff) + carry; - carry = z2 >> 16; - } - while(x < xae); - *xc = z2; - } - } -#else - for(; xb < xbe; xc0++) { - if ( (y = *xb++) !=0) { - x = xa; - xc = xc0; - carry = 0; - do { - z = *x++ * y + *xc + carry; - carry = z >> 16; - *xc++ = z & 0xffff; - } - while(x < xae); - *xc = carry; - } - } -#endif -#endif - for(xc0 = c->x, xc = xc0 + wc; wc > 0 && !*--xc; --wc) ; - c->wds = wc; - return c; - } - - static Bigint *p5s; - - Bigint * -pow5mult -#ifdef KR_headers - (b, k) Bigint *b; int k; -#else - (Bigint *b, int k) -#endif -{ - Bigint *b1, *p5, *p51; - int i; - static CONST int p05[3] = { 5, 25, 125 }; - - if ( (i = k & 3) !=0) { - b = multadd(b, p05[i-1], 0); - if (b == NULL) - return NULL; - } - - if (!(k = (unsigned int)k >> 2)) - return b; - if ((p5 = p5s) == 0) { - /* first time */ -#ifdef MULTIPLE_THREADS - ACQUIRE_DTOA_LOCK(1); - if (!(p5 = p5s)) { - p5 = p5s = i2b(625); - if (p5 == NULL) { - FREE_DTOA_LOCK(1); - return NULL; - } - p5->next = 0; - } - FREE_DTOA_LOCK(1); -#else - p5 = p5s = i2b(625); - if (p5 == NULL) - return NULL; - p5->next = 0; -#endif - } - for(;;) { - if (k & 1) { - b1 = mult(b, p5); - if (b1 == NULL) - return NULL; - Bfree(b); - b = b1; - } - if (!(k = (unsigned int)k >> 1)) - break; - if ((p51 = p5->next) == 0) { -#ifdef MULTIPLE_THREADS - ACQUIRE_DTOA_LOCK(1); - if (!(p51 = p5->next)) { - p51 = p5->next = mult(p5,p5); - if (p51 == NULL) { - FREE_DTOA_LOCK(1); - return NULL; - } - p51->next = 0; - } - FREE_DTOA_LOCK(1); -#else - p51 = p5->next = mult(p5,p5); - if (p51 == NULL) - return NULL; - p51->next = 0; -#endif - } - p5 = p51; - } - return b; - } - - Bigint * -lshift -#ifdef KR_headers - (b, k) Bigint *b; int k; -#else - (Bigint *b, int k) -#endif -{ - int i, k1, n, n1; - Bigint *b1; - ULong *x, *x1, *xe, z; - - n = (unsigned int)k >> kshift; - k1 = b->k; - n1 = n + b->wds + 1; - for(i = b->maxwds; n1 > i; i <<= 1) - k1++; - b1 = Balloc(k1); - if (b1 == NULL) - return NULL; - x1 = b1->x; - for(i = 0; i < n; i++) - *x1++ = 0; - x = b->x; - xe = x + b->wds; - if (k &= kmask) { -#ifdef Pack_32 - k1 = 32 - k; - z = 0; - do { - *x1++ = *x << k | z; - z = *x++ >> k1; - } - while(x < xe); - if ((*x1 = z) !=0) - ++n1; -#else - k1 = 16 - k; - z = 0; - do { - *x1++ = *x << k & 0xffff | z; - z = *x++ >> k1; - } - while(x < xe); - if (*x1 = z) - ++n1; -#endif - } - else do - *x1++ = *x++; - while(x < xe); - b1->wds = n1 - 1; - Bfree(b); - return b1; - } - - int -cmp -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - ULong *xa, *xa0, *xb, *xb0; - int i, j; - - i = a->wds; - j = b->wds; -#ifdef DEBUG - if (i > 1 && !a->x[i-1]) - Bug("cmp called with a->x[a->wds-1] == 0"); - if (j > 1 && !b->x[j-1]) - Bug("cmp called with b->x[b->wds-1] == 0"); -#endif - if (i -= j) - return i; - xa0 = a->x; - xa = xa0 + j; - xb0 = b->x; - xb = xb0 + j; - for(;;) { - if (*--xa != *--xb) - return *xa < *xb ? -1 : 1; - if (xa <= xa0) - break; - } - return 0; - } - - Bigint * -diff -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - Bigint *c; - int i, wa, wb; - ULong *xa, *xae, *xb, *xbe, *xc; -#ifdef ULLong - ULLong borrow, y; -#else - ULong borrow, y; -#ifdef Pack_32 - ULong z; -#endif -#endif - - i = cmp(a,b); - if (!i) { - c = Balloc(0); - if (c == NULL) - return NULL; - c->wds = 1; - c->x[0] = 0; - return c; - } - if (i < 0) { - c = a; - a = b; - b = c; - i = 1; - } - else - i = 0; - c = Balloc(a->k); - if (c == NULL) - return NULL; - c->sign = i; - wa = a->wds; - xa = a->x; - xae = xa + wa; - wb = b->wds; - xb = b->x; - xbe = xb + wb; - xc = c->x; - borrow = 0; -#ifdef ULLong - do { - y = (ULLong)*xa++ - *xb++ - borrow; - borrow = y >> 32 & 1UL; - /* LINTED conversion */ - *xc++ = y & 0xffffffffUL; - } - while(xb < xbe); - while(xa < xae) { - y = *xa++ - borrow; - borrow = y >> 32 & 1UL; - /* LINTED conversion */ - *xc++ = y & 0xffffffffUL; - } -#else -#ifdef Pack_32 - do { - y = (*xa & 0xffff) - (*xb & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*xa++ >> 16) - (*xb++ >> 16) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } - while(xb < xbe); - while(xa < xae) { - y = (*xa & 0xffff) - borrow; - borrow = (y & 0x10000) >> 16; - z = (*xa++ >> 16) - borrow; - borrow = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } -#else - do { - y = *xa++ - *xb++ - borrow; - borrow = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } - while(xb < xbe); - while(xa < xae) { - y = *xa++ - borrow; - borrow = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } -#endif -#endif - while(!*--xc) - wa--; - c->wds = wa; - return c; - } - - double -b2d -#ifdef KR_headers - (a, e) Bigint *a; int *e; -#else - (Bigint *a, int *e) -#endif -{ - ULong *xa, *xa0, w, y, z; - int k; - U d; -#ifdef VAX - ULong d0, d1; -#else -#define d0 word0(&d) -#define d1 word1(&d) -#endif - - xa0 = a->x; - xa = xa0 + a->wds; - y = *--xa; -#ifdef DEBUG - if (!y) Bug("zero y in b2d"); -#endif - k = hi0bits(y); - *e = 32 - k; -#ifdef Pack_32 - if (k < Ebits) { - d0 = Exp_1 | y >> (Ebits - k); - w = xa > xa0 ? *--xa : 0; - d1 = y << ((32-Ebits) + k) | w >> (Ebits - k); - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - if (k -= Ebits) { - d0 = Exp_1 | y << k | z >> (32 - k); - y = xa > xa0 ? *--xa : 0; - d1 = z << k | y >> (32 - k); - } - else { - d0 = Exp_1 | y; - d1 = z; - } -#else - if (k < Ebits + 16) { - z = xa > xa0 ? *--xa : 0; - d0 = Exp_1 | y << k - Ebits | z >> Ebits + 16 - k; - w = xa > xa0 ? *--xa : 0; - y = xa > xa0 ? *--xa : 0; - d1 = z << k + 16 - Ebits | w << k - Ebits | y >> 16 + Ebits - k; - goto ret_d; - } - z = xa > xa0 ? *--xa : 0; - w = xa > xa0 ? *--xa : 0; - k -= Ebits + 16; - d0 = Exp_1 | y << k + 16 | z << k | w >> 16 - k; - y = xa > xa0 ? *--xa : 0; - d1 = w << k + 16 | y << k; -#endif - ret_d: -#ifdef VAX - word0(&d) = d0 >> 16 | d0 << 16; - word1(&d) = d1 >> 16 | d1 << 16; -#endif - return dval(&d); - } -#undef d0 -#undef d1 - - Bigint * -d2b -#ifdef KR_headers - (dd, e, bits) double dd; int *e, *bits; -#else - (double dd, int *e, int *bits) -#endif -{ - Bigint *b; - U d; -#ifndef Sudden_Underflow - int i; -#endif - int de, k; - ULong *x, y, z; -#ifdef VAX - ULong d0, d1; -#else -#define d0 word0(&d) -#define d1 word1(&d) -#endif - d.d = dd; -#ifdef VAX - d0 = word0(&d) >> 16 | word0(&d) << 16; - d1 = word1(&d) >> 16 | word1(&d) << 16; -#endif - -#ifdef Pack_32 - b = Balloc(1); -#else - b = Balloc(2); -#endif - if (b == NULL) - return NULL; - x = b->x; - - z = d0 & Frac_mask; - d0 &= 0x7fffffff; /* clear sign bit, which we ignore */ -#ifdef Sudden_Underflow - de = (int)(d0 >> Exp_shift); -#ifndef IBM - z |= Exp_msk11; -#endif -#else - if ( (de = (int)(d0 >> Exp_shift)) !=0) - z |= Exp_msk1; -#endif -#ifdef Pack_32 - if ( (y = d1) !=0) { - if ( (k = lo0bits(&y)) !=0) { - x[0] = y | z << (32 - k); - z >>= k; - } - else - x[0] = y; -#ifndef Sudden_Underflow - i = -#endif - b->wds = (x[1] = z) !=0 ? 2 : 1; - } - else { - k = lo0bits(&z); - x[0] = z; -#ifndef Sudden_Underflow - i = -#endif - b->wds = 1; - k += 32; - } -#else - if ( (y = d1) !=0) { - if ( (k = lo0bits(&y)) !=0) - if (k >= 16) { - x[0] = y | z << 32 - k & 0xffff; - x[1] = z >> k - 16 & 0xffff; - x[2] = z >> k; - i = 2; - } - else { - x[0] = y & 0xffff; - x[1] = y >> 16 | z << 16 - k & 0xffff; - x[2] = z >> k & 0xffff; - x[3] = z >> k+16; - i = 3; - } - else { - x[0] = y & 0xffff; - x[1] = y >> 16; - x[2] = z & 0xffff; - x[3] = z >> 16; - i = 3; - } - } - else { -#ifdef DEBUG - if (!z) - Bug("Zero passed to d2b"); -#endif - k = lo0bits(&z); - if (k >= 16) { - x[0] = z; - i = 0; - } - else { - x[0] = z & 0xffff; - x[1] = z >> 16; - i = 1; - } - k += 32; - } - while(!x[i]) - --i; - b->wds = i + 1; -#endif -#ifndef Sudden_Underflow - if (de) { -#endif -#ifdef IBM - *e = (de - Bias - (P-1) << 2) + k; - *bits = 4*P + 8 - k - hi0bits(word0(&d) & Frac_mask); -#else - *e = de - Bias - (P-1) + k; - *bits = P - k; -#endif -#ifndef Sudden_Underflow - } - else { - *e = de - Bias - (P-1) + 1 + k; -#ifdef Pack_32 - *bits = 32*i - hi0bits(x[i-1]); -#else - *bits = (i+2)*16 - hi0bits(x[i]); -#endif - } -#endif - return b; - } -#undef d0 -#undef d1 - - CONST double -#ifdef IEEE_Arith -bigtens[] = { 1e16, 1e32, 1e64, 1e128, 1e256 }; -CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, 1e-256 - }; -#else -#ifdef IBM -bigtens[] = { 1e16, 1e32, 1e64 }; -CONST double tinytens[] = { 1e-16, 1e-32, 1e-64 }; -#else -bigtens[] = { 1e16, 1e32 }; -CONST double tinytens[] = { 1e-16, 1e-32 }; -#endif -#endif - - CONST double -tens[] = { - 1e0, 1e1, 1e2, 1e3, 1e4, 1e5, 1e6, 1e7, 1e8, 1e9, - 1e10, 1e11, 1e12, 1e13, 1e14, 1e15, 1e16, 1e17, 1e18, 1e19, - 1e20, 1e21, 1e22 -#ifdef VAX - , 1e23, 1e24 -#endif - }; - - char * -#ifdef KR_headers -strcp_D2A(a, b) char *a; char *b; -#else -strcp_D2A(char *a, CONST char *b) -#endif -{ - while((*a = *b++)) - a++; - return a; - } - -#ifdef NO_STRING_H - - Char * -#ifdef KR_headers -memcpy_D2A(a, b, len) Char *a; Char *b; size_t len; -#else -memcpy_D2A(void *a1, void *b1, size_t len) -#endif -{ - char *a = (char*)a1, *ae = a + len; - char *b = (char*)b1, *a0 = a; - while(a < ae) - *a++ = *b++; - return a0; - } - -#endif /* NO_STRING_H */ diff --git a/lib/libc/gdtoa/qnan.c b/lib/libc/gdtoa/qnan.c deleted file mode 100644 index 2e5ce8924..000000000 --- a/lib/libc/gdtoa/qnan.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: qnan.c,v 1.2 2006/01/25 15:27:42 kleink Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 2005 by David M. Gay -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and its -documentation for any purpose and without fee is hereby granted, -provided that the above copyright notice appear in all copies and that -both that the copyright notice and this permission notice and warranty -disclaimer appear in supporting documentation, and that the name of -the author or any of his current or former employers not be used in -advertising or publicity pertaining to distribution of the software -without specific, written prior permission. - -THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN -NO EVENT SHALL THE AUTHOR OR ANY OF HIS CURRENT OR FORMER EMPLOYERS BE -LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY -DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, -WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS -SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Program to compute quiet NaNs of various precisions (float, */ -/* double, and perhaps long double) on the current system, */ -/* provided the system uses binary IEEE (P754) arithmetic. */ -/* Note that one system's quiet NaN may be a signaling NaN on */ -/* another system. The IEEE arithmetic standards (P754, P854) */ -/* do not specify how to distinguish signaling NaNs from quiet */ -/* ones, and this detail varies across systems. The computed */ -/* NaN values are encoded in #defines for values for an */ -/* unsigned 32-bit integer type, called Ulong below, and */ -/* (for long double) perhaps as unsigned short values. Once */ -/* upon a time, there were PC compilers for Intel CPUs that */ -/* had sizeof(long double) = 10. Are such compilers still */ -/* distributed? */ - -#include -#include "arith.h" - -#ifndef Long -#define Long long -#endif - -typedef unsigned Long Ulong; - -#undef HAVE_IEEE -#ifdef IEEE_LITTLE_ENDIAN -#define _0 1 -#define _1 0 -#define HAVE_IEEE -#endif -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define HAVE_IEEE -#endif - -#define UL (unsigned long) - - int -main(void) -{ -#ifdef HAVE_IEEE - typedef union { - float f; - double d; - Ulong L[4]; -#ifndef NO_LONG_LONG - unsigned short u[5]; - long double D; -#endif - } U; - U a, b, c; - int i; - - a.L[0] = b.L[0] = 0x7f800000; - c.f = a.f - b.f; - printf("#define f_QNAN 0x%lx\n", UL c.L[0]); - a.L[_0] = b.L[_0] = 0x7ff00000; - a.L[_1] = b.L[_1] = 0; - c.d = a.d - b.d; /* quiet NaN */ - printf("#define d_QNAN0 0x%lx\n", UL c.L[0]); - printf("#define d_QNAN1 0x%lx\n", UL c.L[1]); -#ifdef NO_LONG_LONG - for(i = 0; i < 4; i++) - printf("#define ld_QNAN%d 0xffffffff\n", i); - for(i = 0; i < 5; i++) - printf("#define ldus_QNAN%d 0xffff\n", i); -#else - b.D = c.D = a.d; - if (printf("") < 0) - c.D = 37; /* never executed; just defeat optimization */ - a.L[2] = a.L[3] = 0; - a.D = b.D - c.D; - for(i = 0; i < 4; i++) - printf("#define ld_QNAN%d 0x%lx\n", i, UL a.L[i]); - for(i = 0; i < 5; i++) - printf("#define ldus_QNAN%d 0x%x\n", i, a.u[i]); -#endif -#endif /* HAVE_IEEE */ - return 0; - } diff --git a/lib/libc/gdtoa/smisc.c b/lib/libc/gdtoa/smisc.c deleted file mode 100644 index 27b9d6a8c..000000000 --- a/lib/libc/gdtoa/smisc.c +++ /dev/null @@ -1,202 +0,0 @@ -/* $NetBSD: smisc.c,v 1.5 2012/03/13 21:13:34 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 1999 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - Bigint * -s2b -#ifdef KR_headers - (s, nd0, nd, y9, dplen) CONST char *s; int dplen, nd0, nd; ULong y9; -#else - (CONST char *s, int nd0, int nd, ULong y9, size_t dplen) -#endif -{ - Bigint *b; - int i, k; - Long x, y; - - x = (nd + 8) / 9; - for(k = 0, y = 1; x > y; y <<= 1, k++) ; -#ifdef Pack_32 - b = Balloc(k); - if (b == NULL) - return NULL; - b->x[0] = y9; - b->wds = 1; -#else - b = Balloc(k+1); - if (b == NULL) - return NULL; - b->x[0] = y9 & 0xffff; - b->wds = (b->x[1] = y9 >> 16) ? 2 : 1; -#endif - - i = 9; - if (9 < nd0) { - s += 9; - do { - b = multadd(b, 10, *s++ - '0'); - if (b == NULL) - return NULL; - } while(++i < nd0); - s += dplen; - } - else - s += dplen + 9; - for(; i < nd; i++) { - b = multadd(b, 10, *s++ - '0'); - if (b == NULL) - return NULL; - } - return b; - } - double -ratio -#ifdef KR_headers - (a, b) Bigint *a, *b; -#else - (Bigint *a, Bigint *b) -#endif -{ - U da, db; - int k, ka, kb; - - dval(&da) = b2d(a, &ka); - dval(&db) = b2d(b, &kb); - k = ka - kb + ULbits*(a->wds - b->wds); -#ifdef IBM - if (k > 0) { - word0(&da) += (k >> 2)*Exp_msk1; - if (k &= 3) - dval(&da) *= 1 << k; - } - else { - k = -k; - word0(&db) += (k >> 2)*Exp_msk1; - if (k &= 3) - dval(&db) *= 1 << k; - } -#else - if (k > 0) - word0(&da) += k*Exp_msk1; - else { - k = -k; - word0(&db) += k*Exp_msk1; - } -#endif - return dval(&da) / dval(&db); - } - -#ifdef INFNAN_CHECK - - int -match -#ifdef KR_headers - (sp, t) CONST char **sp, *t; -#else - (CONST char **sp, CONST char *t) -#endif -{ - int c, d; - CONST char *s = *sp; - - while( (d = *t++) !=0) { - if ((c = *++s) >= 'A' && c <= 'Z') - c += 'a' - 'A'; - if (c != d) - return 0; - } - *sp = s + 1; - return 1; - } -#endif /* INFNAN_CHECK */ - - void -#ifdef KR_headers -copybits(c, n, b) ULong *c; int n; Bigint *b; -#else -copybits(ULong *c, int n, Bigint *b) -#endif -{ - ULong *ce, *x, *xe; -#ifdef Pack_16 - int nw, nw1; -#endif - - ce = c + ((unsigned int)(n-1) >> kshift) + 1; - x = b->x; -#ifdef Pack_32 - xe = x + b->wds; - while(x < xe) - *c++ = *x++; -#else - nw = b->wds; - nw1 = nw & 1; - for(xe = x + (nw - nw1); x < xe; x += 2) - Storeinc(c, x[1], x[0]); - if (nw1) - *c++ = *x; -#endif - while(c < ce) - *c++ = 0; - } - - ULong -#ifdef KR_headers -any_on(b, k) Bigint *b; int k; -#else -any_on(Bigint *b, int k) -#endif -{ - int n, nwds; - ULong *x, *x0, x1, x2; - - x = b->x; - nwds = b->wds; - n = (unsigned int)k >> kshift; - if (n > nwds) - n = nwds; - else if (n < nwds && (k &= kmask)) { - x1 = x2 = x[n]; - x1 >>= k; - x1 <<= k; - if (x1 != x2) - return 1; - } - x0 = x; - x += n; - while(x > x0) - if (*--x) - return 1; - return 0; - } diff --git a/lib/libc/gdtoa/strtoIQ.c b/lib/libc/gdtoa/strtoIQ.c deleted file mode 100644 index dfb5aaf23..000000000 --- a/lib/libc/gdtoa/strtoIQ.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: strtoIQ.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtoIQ(s, sp, a, b) CONST char *s; char **sp; void *a; void *b; -#else -strtoIQ(CONST char *s, char **sp, void *a, void *b) -#endif -{ - static FPI fpi = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI }; - Long exp[2]; - Bigint *B[2]; - int k, rv[2]; - ULong *L = (ULong *)a, *M = (ULong *)b; - - B[0] = Balloc(2); - if (B[0] == NULL) - return STRTOG_NoMemory; - B[0]->wds = 4; - k = strtoIg(s, sp, &fpi, exp, B, rv); - if (k == STRTOG_NoMemory) - return k; - ULtoQ(L, B[0]->x, exp[0], rv[0]); - Bfree(B[0]); - if (B[1]) { - ULtoQ(M, B[1]->x, exp[1], rv[1]); - Bfree(B[1]); - } - else { - M[0] = L[0]; - M[1] = L[1]; - M[2] = L[2]; - M[3] = L[3]; - } - return k; - } diff --git a/lib/libc/gdtoa/strtoId.c b/lib/libc/gdtoa/strtoId.c deleted file mode 100644 index 7cbfca213..000000000 --- a/lib/libc/gdtoa/strtoId.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: strtoId.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtoId(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1; -#else -strtoId(CONST char *s, char **sp, double *f0, double *f1) -#endif -{ - static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; - Long exp[2]; - Bigint *B[2]; - int k, rv[2]; - - B[0] = Balloc(1); - if (B[0] == NULL) - return STRTOG_NoMemory; - B[0]->wds = 2; - k = strtoIg(s, sp, &fpi, exp, B, rv); - if (k == STRTOG_NoMemory) - return k; - ULtod((ULong*)f0, B[0]->x, exp[0], rv[0]); - Bfree(B[0]); - if (B[1]) { - ULtod((ULong*)f1, B[1]->x, exp[1], rv[1]); - Bfree(B[1]); - } - else { - ((ULong*)f1)[0] = ((ULong*)f0)[0]; - ((ULong*)f1)[1] = ((ULong*)f0)[1]; - } - return k; - } diff --git a/lib/libc/gdtoa/strtoIdd.c b/lib/libc/gdtoa/strtoIdd.c deleted file mode 100644 index cf938ea45..000000000 --- a/lib/libc/gdtoa/strtoIdd.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: strtoIdd.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtoIdd(s, sp, f0, f1) CONST char *s; char **sp; double *f0, *f1; -#else -strtoIdd(CONST char *s, char **sp, double *f0, double *f1) -#endif -{ -#ifdef Sudden_Underflow - static FPI fpi = { 106, 1-1023, 2046-1023-106+1, 1, 1 }; -#else - static FPI fpi = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 }; -#endif - Long exp[2]; - Bigint *B[2]; - int k, rv[2]; - - B[0] = Balloc(2); - if (B[0] == NULL) - return STRTOG_NoMemory; - B[0]->wds = 4; - k = strtoIg(s, sp, &fpi, exp, B, rv); - if (k == STRTOG_NoMemory) - return k; - ULtodd((ULong*)f0, B[0]->x, exp[0], rv[0]); - Bfree(B[0]); - if (B[1]) { - ULtodd((ULong*)f1, B[1]->x, exp[1], rv[1]); - Bfree(B[1]); - } - else { - ((ULong*)f1)[0] = ((ULong*)f0)[0]; - ((ULong*)f1)[1] = ((ULong*)f0)[1]; - ((ULong*)f1)[2] = ((ULong*)f0)[2]; - ((ULong*)f1)[3] = ((ULong*)f0)[3]; - } - return k; - } diff --git a/lib/libc/gdtoa/strtoIf.c b/lib/libc/gdtoa/strtoIf.c deleted file mode 100644 index 087acdc71..000000000 --- a/lib/libc/gdtoa/strtoIf.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: strtoIf.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtoIf(s, sp, f0, f1) CONST char *s; char **sp; float *f0, *f1; -#else -strtoIf(CONST char *s, char **sp, float *f0, float *f1) -#endif -{ - static FPI fpi = { 24, 1-127-24+1, 254-127-24+1, 1, SI }; - Long exp[2]; - Bigint *B[2]; - int k, rv[2]; - - B[0] = Balloc(0); - if (B[0] == NULL) - return STRTOG_NoMemory; - B[0]->wds = 1; - k = strtoIg(s, sp, &fpi, exp, B, rv); - if (k == STRTOG_NoMemory) - return k; - ULtof((ULong*)f0, B[0]->x, exp[0], rv[0]); - Bfree(B[0]); - if (B[1]) { - ULtof((ULong*)f1, B[1]->x, exp[1], rv[1]); - Bfree(B[1]); - } - else - *(ULong*)f1 = *(ULong*)f0; - return k; - } diff --git a/lib/libc/gdtoa/strtoIg.c b/lib/libc/gdtoa/strtoIg.c deleted file mode 100644 index 0dc3e36c7..000000000 --- a/lib/libc/gdtoa/strtoIg.c +++ /dev/null @@ -1,143 +0,0 @@ -/* $NetBSD: strtoIg.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtoIg(s00, se, fpi, exp, B, rvp) CONST char *s00; char **se; FPI *fpi; Long *exp; Bigint **B; int *rvp; -#else -strtoIg(CONST char *s00, char **se, FPI *fpi, Long *exp, Bigint **B, int *rvp) -#endif -{ - Bigint *b, *b1; - int i, nb, nw, nw1, rv, rv1, swap; - unsigned int nb1, nb11; - Long e1; - - b = *B; - rv = strtodg(s00, se, fpi, exp, b->x); - if (rv == STRTOG_NoMemory) - return rv; - if (!(rv & STRTOG_Inexact)) { - B[1] = 0; - return *rvp = rv; - } - e1 = exp[0]; - rv1 = rv ^ STRTOG_Inexact; - b1 = Balloc(b->k); - if (b1 == NULL) - return STRTOG_NoMemory; - Bcopy(b1, b); - nb = fpi->nbits; - nb1 = nb & 31; - nb11 = (nb1 - 1) & 31; - nw = b->wds; - nw1 = nw - 1; - if (rv & STRTOG_Inexlo) { - swap = 0; - b1 = increment(b1); - if ((rv & STRTOG_Retmask) == STRTOG_Zero) { - if (fpi->sudden_underflow) { - b1->x[0] = 0; - b1->x[nw1] = 1L << nb11; - rv1 += STRTOG_Normal - STRTOG_Zero; - rv1 &= ~STRTOG_Underflow; - goto swapcheck; - } - rv1 &= STRTOG_Inexlo | STRTOG_Underflow | STRTOG_Zero; - rv1 |= STRTOG_Inexhi | STRTOG_Denormal; - goto swapcheck; - } - if (b1->wds > nw - || (nb1 && b1->x[nw1] & 1L << nb1)) { - if (++e1 > fpi->emax) - rv1 = STRTOG_Infinite | STRTOG_Inexhi; - rshift(b1, 1); - } - else if ((rv & STRTOG_Retmask) == STRTOG_Denormal) { - if (b1->x[nw1] & 1L << nb11) { - rv1 += STRTOG_Normal - STRTOG_Denormal; - rv1 &= ~STRTOG_Underflow; - } - } - } - else { - swap = STRTOG_Neg; - if ((rv & STRTOG_Retmask) == STRTOG_Infinite) { - b1 = set_ones(b1, nb); - e1 = fpi->emax; - rv1 = STRTOG_Normal | STRTOG_Inexlo; - goto swapcheck; - } - decrement(b1); - if ((rv & STRTOG_Retmask) == STRTOG_Denormal) { - for(i = nw1; !b1->x[i]; --i) - if (!i) { - rv1 = STRTOG_Zero | STRTOG_Inexlo; - break; - } - goto swapcheck; - } - if (!(b1->x[nw1] & 1L << nb11)) { - if (e1 == fpi->emin) { - if (fpi->sudden_underflow) - rv1 += STRTOG_Zero - STRTOG_Normal; - else - rv1 += STRTOG_Denormal - STRTOG_Normal; - rv1 |= STRTOG_Underflow; - } - else { - b1 = lshift(b1, 1); - b1->x[0] |= 1; - --e1; - } - } - } - swapcheck: - if (swap ^ (rv & STRTOG_Neg)) { - rvp[0] = rv1; - rvp[1] = rv; - B[0] = b1; - B[1] = b; - exp[1] = exp[0]; - exp[0] = e1; - } - else { - rvp[0] = rv; - rvp[1] = rv1; - B[1] = b1; - exp[1] = e1; - } - return rv; - } diff --git a/lib/libc/gdtoa/strtoIx.c b/lib/libc/gdtoa/strtoIx.c deleted file mode 100644 index 966e4e364..000000000 --- a/lib/libc/gdtoa/strtoIx.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: strtoIx.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtoIx(s, sp, a, b) CONST char *s; char **sp; void *a; void *b; -#else -strtoIx(CONST char *s, char **sp, void *a, void *b) -#endif -{ - static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; - Long exp[2]; - Bigint *B[2]; - int k, rv[2]; - UShort *L = (UShort *)a, *M = (UShort *)b; - - B[0] = Balloc(1); - if (B[0] == NULL) - return STRTOG_NoMemory; - B[0]->wds = 2; - k = strtoIg(s, sp, &fpi, exp, B, rv); - if (k == STRTOG_NoMemory) - return k; - ULtox(L, B[0]->x, exp[0], rv[0]); - Bfree(B[0]); - if (B[1]) { - ULtox(M, B[1]->x, exp[1], rv[1]); - Bfree(B[1]); - } - else { - M[0] = L[0]; - M[1] = L[1]; - M[2] = L[2]; - M[3] = L[3]; - M[4] = L[4]; - } - return k; - } diff --git a/lib/libc/gdtoa/strtoIxL.c b/lib/libc/gdtoa/strtoIxL.c deleted file mode 100644 index e61069674..000000000 --- a/lib/libc/gdtoa/strtoIxL.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: strtoIxL.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtoIxL(s, sp, a, b) CONST char *s; char **sp; void *a; void *b; -#else -strtoIxL(CONST char *s, char **sp, void *a, void *b) -#endif -{ - static FPI fpi = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; - Long exp[2]; - Bigint *B[2]; - int k, rv[2]; - ULong *L = (ULong *)a, *M = (ULong *)b; - - B[0] = Balloc(1); - if (B[0] == NULL) - return STRTOG_NoMemory; - B[0]->wds = 2; - k = strtoIg(s, sp, &fpi, exp, B, rv); - if (k == STRTOG_NoMemory) - return k; - ULtoxL(L, B[0]->x, exp[0], rv[0]); - Bfree(B[0]); - if (B[1]) { - ULtoxL(M, B[1]->x, exp[1], rv[1]); - Bfree(B[1]); - } - else { - M[0] = L[0]; - M[1] = L[1]; - M[2] = L[2]; - } - return k; - } diff --git a/lib/libc/gdtoa/strtod.c b/lib/libc/gdtoa/strtod.c deleted file mode 100644 index 1f9323423..000000000 --- a/lib/libc/gdtoa/strtod.c +++ /dev/null @@ -1,1117 +0,0 @@ -/* $NetBSD: strtod.c,v 1.14 2013/05/17 12:55:57 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "namespace.h" -#include "gdtoaimp.h" -#ifndef NO_FENV_H -#include -#endif - -#ifdef USE_LOCALE -#include -#include "setlocale_local.h" -#endif - -#ifdef IEEE_Arith -#ifndef NO_IEEE_Scale -#define Avoid_Underflow -#undef tinytens -/* The factor of 2^106 in tinytens[4] helps us avoid setting the underflow */ -/* flag unnecessarily. It leads to a song and dance at the end of strtod. */ -static CONST double tinytens[] = { 1e-16, 1e-32, 1e-64, 1e-128, - 9007199254740992.*9007199254740992.e-256 - }; -#endif -#endif - -#ifdef Honor_FLT_ROUNDS -#undef Check_FLT_ROUNDS -#define Check_FLT_ROUNDS -#else -#define Rounding Flt_Rounds -#endif - -#ifndef __HAVE_LONG_DOUBLE -__strong_alias(_strtold, strtod) -__weak_alias(strtold, _strtold) -__strong_alias(_strtold_l, strtod_l) -__weak_alias(strtold_l, _strtold_l) -#endif - -#ifdef Avoid_Underflow /*{*/ - static double -sulp -#ifdef KR_headers - (x, scale) U *x; int scale; -#else - (U *x, int scale) -#endif -{ - U u; - double rv; - int i; - - rv = ulp(x); - if (!scale || (i = 2*P + 1 - ((word0(x) & Exp_mask) >> Exp_shift)) <= 0) - return rv; /* Is there an example where i <= 0 ? */ - word0(&u) = Exp_1 + (i << Exp_shift); - word1(&u) = 0; - return rv * u.d; - } -#endif /*}*/ - -static double -_int_strtod_l(CONST char *s00, char **se, locale_t loc) -{ -#ifdef Avoid_Underflow - int scale; -#endif -#ifdef INFNAN_CHECK - int decpt; -#endif - int bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, dsign, - e, e1, esign, i, j, k, nd, nd0, nf, nz, nz0, sign; - CONST char *s, *s0, *s1; - double aadj; - Long L; - U adj, aadj1, rv, rv0; - ULong y, z; - Bigint *bb = NULL, *bb1, *bd0; - Bigint *bd = NULL, *bs = NULL, *delta = NULL; /* pacify gcc */ -#ifdef Avoid_Underflow - ULong Lsb, Lsb1; -#endif -#ifdef SET_INEXACT - int inexact, oldinexact; -#endif -#ifdef USE_LOCALE /*{{*/ - char *decimalpoint = localeconv_l(loc)->decimal_point; - size_t dplen = strlen(decimalpoint); -#endif /*USE_LOCALE}}*/ - -#ifdef Honor_FLT_ROUNDS /*{*/ - int Rounding; -#ifdef Trust_FLT_ROUNDS /*{{ only define this if FLT_ROUNDS really works! */ - Rounding = Flt_Rounds; -#else /*}{*/ - Rounding = 1; - switch(fegetround()) { - case FE_TOWARDZERO: Rounding = 0; break; - case FE_UPWARD: Rounding = 2; break; - case FE_DOWNWARD: Rounding = 3; - } -#endif /*}}*/ -#endif /*}*/ - -#ifdef INFNAN_CHECK - decpt = 0; -#endif - sign = nz0 = nz = 0; - dval(&rv) = 0.; - for(s = s00;;s++) switch(*s) { - case '-': - sign = 1; - /* FALLTHROUGH */ - case '+': - if (*++s) - goto break2; - /* FALLTHROUGH */ - case 0: - goto ret0; - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case ' ': - continue; - default: - goto break2; - } - break2: - if (*s == '0') { -#ifndef NO_HEX_FP /*{*/ - { - static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; - Long expt; - ULong bits[2]; - switch(s[1]) { - case 'x': - case 'X': - { -#ifdef Honor_FLT_ROUNDS - FPI fpi1 = fpi; - fpi1.rounding = Rounding; -#else -#define fpi1 fpi -#endif - switch((i = gethex(&s, &fpi1, &expt, &bb, sign, loc)) & STRTOG_Retmask) { - case STRTOG_NoNumber: - s = s00; - sign = 0; - /* FALLTHROUGH */ - case STRTOG_Zero: - break; - default: - if (bb) { - copybits(bits, fpi.nbits, bb); - Bfree(bb); - } - ULtod((/* LINTED */(U*)&rv)->L, bits, expt, i); - }} - goto ret; - } - } -#endif /*}*/ - nz0 = 1; - while(*++s == '0') ; - if (!*s) - goto ret; - } - s0 = s; - y = z = 0; - for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) - if (nd < 9) - y = 10*y + c - '0'; - else if (nd < 16) - z = 10*z + c - '0'; - nd0 = nd; -#ifdef USE_LOCALE - if (c == *decimalpoint) { - for(i = 1; decimalpoint[i]; ++i) - if (s[i] != decimalpoint[i]) - goto dig_done; - s += i; - c = *s; -#else - if (c == '.') { - c = *++s; -#endif -#ifdef INFNAN_CHECK - decpt = 1; -#endif - if (!nd) { - for(; c == '0'; c = *++s) - nz++; - if (c > '0' && c <= '9') { - s0 = s; - nf += nz; - nz = 0; - goto have_dig; - } - goto dig_done; - } - for(; c >= '0' && c <= '9'; c = *++s) { - have_dig: - nz++; - if (c -= '0') { - nf += nz; - for(i = 1; i < nz; i++) - if (nd++ < 9) - y *= 10; - else if (nd <= DBL_DIG + 1) - z *= 10; - if (nd++ < 9) - y = 10*y + c; - else if (nd <= DBL_DIG + 1) - z = 10*z + c; - nz = 0; - } - } - }/*}*/ - dig_done: - e = 0; - if (c == 'e' || c == 'E') { - if (!nd && !nz && !nz0) { - goto ret0; - } - s00 = s; - esign = 0; - switch(c = *++s) { - case '-': - esign = 1; - /* FALLTHROUGH */ - case '+': - c = *++s; - } - if (c >= '0' && c <= '9') { - while(c == '0') - c = *++s; - if (c > '0' && c <= '9') { - L = c - '0'; - s1 = s; - while((c = *++s) >= '0' && c <= '9') - L = 10*L + c - '0'; - if (s - s1 > 8 || L > 19999) - /* Avoid confusion from exponents - * so large that e might overflow. - */ - e = 19999; /* safe for 16 bit ints */ - else - e = (int)L; - if (esign) - e = -e; - } - else - e = 0; - } - else - s = s00; - } - if (!nd) { - if (!nz && !nz0) { -#ifdef INFNAN_CHECK - /* Check for Nan and Infinity */ - ULong bits[2]; - static FPI fpinan = /* only 52 explicit bits */ - { 52, 1-1023-53+1, 2046-1023-53+1, 1, SI }; - if (!decpt) - switch(c) { - case 'i': - case 'I': - if (match(&s,"nf")) { - --s; - if (!match(&s,"inity")) - ++s; - word0(&rv) = 0x7ff00000; - word1(&rv) = 0; - goto ret; - } - break; - case 'n': - case 'N': - if (match(&s, "an")) { -#ifndef No_Hex_NaN - if (*s == '(' /*)*/ - && hexnan(&s, &fpinan, bits) - == STRTOG_NaNbits) { - word0(&rv) = 0x7ff00000 | bits[1]; - word1(&rv) = bits[0]; - } - else { -#endif - word0(&rv) = NAN_WORD0; - word1(&rv) = NAN_WORD1; -#ifndef No_Hex_NaN - } -#endif - goto ret; - } - } -#endif /* INFNAN_CHECK */ - ret0: - s = s00; - sign = 0; - } - goto ret; - } - e1 = e -= nf; - - /* Now we have nd0 digits, starting at s0, followed by a - * decimal point, followed by nd-nd0 digits. The number we're - * after is the integer represented by those digits times - * 10**e */ - - if (!nd0) - nd0 = nd; - k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; - dval(&rv) = y; - if (k > 9) { -#ifdef SET_INEXACT - if (k > DBL_DIG) - oldinexact = get_inexact(); -#endif - dval(&rv) = tens[k - 9] * dval(&rv) + z; - } - bd0 = 0; - if (nd <= DBL_DIG -#ifndef RND_PRODQUOT -#ifndef Honor_FLT_ROUNDS - && Flt_Rounds == 1 -#endif -#endif - ) { - if (!e) - goto ret; -#ifndef ROUND_BIASED_without_Round_Up - if (e > 0) { - if (e <= Ten_pmax) { -#ifdef VAX - goto vax_ovfl_check; -#else -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv.d = -rv.d; - sign = 0; - } -#endif - /* rv = */ rounded_product(dval(&rv), tens[e]); - goto ret; -#endif - } - i = DBL_DIG - nd; - if (e <= Ten_pmax + i) { - /* A fancier test would sometimes let us do - * this for larger i values. - */ -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv.d = -rv.d; - sign = 0; - } -#endif - e -= i; - dval(&rv) *= tens[i]; -#ifdef VAX - /* VAX exponent range is so narrow we must - * worry about overflow here... - */ - vax_ovfl_check: - word0(&rv) -= P*Exp_msk1; - /* rv = */ rounded_product(dval(&rv), tens[e]); - if ((word0(&rv) & Exp_mask) - > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) - goto ovfl; - word0(&rv) += P*Exp_msk1; -#else - /* rv = */ rounded_product(dval(&rv), tens[e]); -#endif - goto ret; - } - } -#ifndef Inaccurate_Divide - else if (e >= -Ten_pmax) { -#ifdef Honor_FLT_ROUNDS - /* round correctly FLT_ROUNDS = 2 or 3 */ - if (sign) { - rv.d = -rv.d; - sign = 0; - } -#endif - /* rv = */ rounded_quotient(dval(&rv), tens[-e]); - goto ret; - } -#endif -#endif /* ROUND_BIASED_without_Round_Up */ - } - e1 += nd - k; - -#ifdef IEEE_Arith -#ifdef SET_INEXACT - inexact = 1; - if (k <= DBL_DIG) - oldinexact = get_inexact(); -#endif -#ifdef Avoid_Underflow - scale = 0; -#endif -#ifdef Honor_FLT_ROUNDS - if (Rounding >= 2) { - if (sign) - Rounding = Rounding == 2 ? 0 : 2; - else - if (Rounding != 2) - Rounding = 0; - } -#endif -#endif /*IEEE_Arith*/ - - /* Get starting approximation = rv * 10**e1 */ - - if (e1 > 0) { - if ( (i = e1 & 15) !=0) - dval(&rv) *= tens[i]; - if (e1 &= ~15) { - if (e1 > DBL_MAX_10_EXP) { - ovfl: - /* Can't trust HUGE_VAL */ -#ifdef IEEE_Arith -#ifdef Honor_FLT_ROUNDS - switch(Rounding) { - case 0: /* toward 0 */ - case 3: /* toward -infinity */ - word0(&rv) = Big0; - word1(&rv) = Big1; - break; - default: - word0(&rv) = Exp_mask; - word1(&rv) = 0; - } -#else /*Honor_FLT_ROUNDS*/ - word0(&rv) = Exp_mask; - word1(&rv) = 0; -#endif /*Honor_FLT_ROUNDS*/ -#ifdef SET_INEXACT - /* set overflow bit */ - dval(&rv0) = 1e300; - dval(&rv0) *= dval(&rv0); -#endif -#else /*IEEE_Arith*/ - word0(&rv) = Big0; - word1(&rv) = Big1; -#endif /*IEEE_Arith*/ - range_err: - if (bd0) { - Bfree(bb); - Bfree(bd); - Bfree(bs); - Bfree(bd0); - Bfree(delta); - } -#ifndef NO_ERRNO - errno = ERANGE; -#endif - goto ret; - } - e1 = (unsigned int)e1 >> 4; - for(j = 0; e1 > 1; j++, e1 = (unsigned int)e1 >> 1) - if (e1 & 1) - dval(&rv) *= bigtens[j]; - /* The last multiplication could overflow. */ - word0(&rv) -= P*Exp_msk1; - dval(&rv) *= bigtens[j]; - if ((z = word0(&rv) & Exp_mask) - > Exp_msk1*(DBL_MAX_EXP+Bias-P)) - goto ovfl; - if (z > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) { - /* set to largest number */ - /* (Can't trust DBL_MAX) */ - word0(&rv) = Big0; - word1(&rv) = Big1; - } - else - word0(&rv) += P*Exp_msk1; - } - } - else if (e1 < 0) { - e1 = -e1; - if ( (i = e1 & 15) !=0) - dval(&rv) /= tens[i]; - if (e1 >>= 4) { - if (e1 >= 1 << n_bigtens) - goto undfl; -#ifdef Avoid_Underflow - if (e1 & Scale_Bit) - scale = 2*P; - for(j = 0; e1 > 0; j++, e1 = (unsigned int)e1 >> 1) - if (e1 & 1) - dval(&rv) *= tinytens[j]; - if (scale && (j = 2*P + 1 - ((word0(&rv) & Exp_mask) - >> Exp_shift)) > 0) { - /* scaled rv is denormal; zap j low bits */ - if (j >= 32) { - word1(&rv) = 0; - if (j >= 53) - word0(&rv) = (P+2)*Exp_msk1; - else - word0(&rv) &= 0xffffffffU << (j-32); - } - else - word1(&rv) &= 0xffffffffU << j; - } -#else - for(j = 0; e1 > 1; j++, e1 = (unsigned int)e1 >> 1) - if (e1 & 1) - dval(&rv) *= tinytens[j]; - /* The last multiplication could underflow. */ - dval(&rv0) = dval(&rv); - dval(&rv) *= tinytens[j]; - if (!dval(&rv)) { - dval(&rv) = 2.*dval(&rv0); - dval(&rv) *= tinytens[j]; -#endif - if (!dval(&rv)) { - undfl: - dval(&rv) = 0.; - goto range_err; - } -#ifndef Avoid_Underflow - word0(&rv) = Tiny0; - word1(&rv) = Tiny1; - /* The refinement below will clean - * this approximation up. - */ - } -#endif - } - } - - /* Now the hard part -- adjusting rv to the correct value.*/ - - /* Put digits into bd: true value = bd * 10^e */ - - bd0 = s2b(s0, nd0, nd, y, dplen); - if (bd0 == NULL) - goto ovfl; - - for(;;) { - bd = Balloc(bd0->k); - if (bd == NULL) - goto ovfl; - Bcopy(bd, bd0); - bb = d2b(dval(&rv), &bbe, &bbbits); /* rv = bb * 2^bbe */ - if (bb == NULL) - goto ovfl; - bs = i2b(1); - if (bs == NULL) - goto ovfl; - - if (e >= 0) { - bb2 = bb5 = 0; - bd2 = bd5 = e; - } - else { - bb2 = bb5 = -e; - bd2 = bd5 = 0; - } - if (bbe >= 0) - bb2 += bbe; - else - bd2 -= bbe; - bs2 = bb2; -#ifdef Honor_FLT_ROUNDS - if (Rounding != 1) - bs2++; -#endif -#ifdef Avoid_Underflow - Lsb = LSB; - Lsb1 = 0; - j = bbe - scale; - i = j + bbbits - 1; /* logb(rv) */ - j = P + 1 - bbbits; - if (i < Emin) { /* denormal */ - i = Emin - i; - j -= i; - if (i < 32) - Lsb <<= i; - else - Lsb1 = Lsb << (i-32); - } -#else /*Avoid_Underflow*/ -#ifdef Sudden_Underflow -#ifdef IBM - j = 1 + 4*P - 3 - bbbits + ((bbe + bbbits - 1) & 3); -#else - j = P + 1 - bbbits; -#endif -#else /*Sudden_Underflow*/ - j = bbe; - i = j + bbbits - 1; /* logb(&rv) */ - if (i < Emin) /* denormal */ - j += P - Emin; - else - j = P + 1 - bbbits; -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - bb2 += j; - bd2 += j; -#ifdef Avoid_Underflow - bd2 += scale; -#endif - i = bb2 < bd2 ? bb2 : bd2; - if (i > bs2) - i = bs2; - if (i > 0) { - bb2 -= i; - bd2 -= i; - bs2 -= i; - } - if (bb5 > 0) { - bs = pow5mult(bs, bb5); - if (bs == NULL) - goto ovfl; - bb1 = mult(bs, bb); - if (bb1 == NULL) - goto ovfl; - Bfree(bb); - bb = bb1; - } - if (bb2 > 0) { - bb = lshift(bb, bb2); - if (bb == NULL) - goto ovfl; - } - if (bd5 > 0) { - bd = pow5mult(bd, bd5); - if (bd == NULL) - goto ovfl; - } - if (bd2 > 0) { - bd = lshift(bd, bd2); - if (bd == NULL) - goto ovfl; - } - if (bs2 > 0) { - bs = lshift(bs, bs2); - if (bs == NULL) - goto ovfl; - } - delta = diff(bb, bd); - if (delta == NULL) - goto ovfl; - dsign = delta->sign; - delta->sign = 0; - i = cmp(delta, bs); -#ifdef Honor_FLT_ROUNDS - if (Rounding != 1) { - if (i < 0) { - /* Error is less than an ulp */ - if (!delta->x[0] && delta->wds <= 1) { - /* exact */ -#ifdef SET_INEXACT - inexact = 0; -#endif - break; - } - if (Rounding) { - if (dsign) { - dval(&adj) = 1.; - goto apply_adj; - } - } - else if (!dsign) { - dval(&adj) = -1.; - if (!word1(&rv) - && !(word0(&rv) & Frac_mask)) { - y = word0(&rv) & Exp_mask; -#ifdef Avoid_Underflow - if (!scale || y > 2*P*Exp_msk1) -#else - if (y) -#endif - { - delta = lshift(delta,Log2P); - if (cmp(delta, bs) <= 0) - dval(&adj) = -0.5; - } - } - apply_adj: -#ifdef Avoid_Underflow - if (scale && (y = word0(&rv) & Exp_mask) - <= 2*P*Exp_msk1) - word0(&adj) += (2*P+1)*Exp_msk1 - y; -#else -#ifdef Sudden_Underflow - if ((word0(&rv) & Exp_mask) <= - P*Exp_msk1) { - word0(&rv) += P*Exp_msk1; - dval(&rv) += adj*ulp(&rv); - word0(&rv) -= P*Exp_msk1; - } - else -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - dval(&rv) += adj.d*ulp(&rv); - } - break; - } - dval(&adj) = ratio(delta, bs); - if (adj.d < 1.) - dval(&adj) = 1.; - if (adj.d <= 0x7ffffffe) { - /* dval(&adj) = Rounding ? ceil(&adj) : floor(&adj); */ - y = adj.d; - if (y != adj.d) { - if (!((Rounding>>1) ^ dsign)) - y++; - dval(&adj) = y; - } - } -#ifdef Avoid_Underflow - if (scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1) - word0(&adj) += (2*P+1)*Exp_msk1 - y; -#else -#ifdef Sudden_Underflow - if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) { - word0(&rv) += P*Exp_msk1; - dval(&adj) *= ulp(&rv); - if (dsign) - dval(&rv) += adj; - else - dval(&rv) -= adj; - word0(&rv) -= P*Exp_msk1; - goto cont; - } -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - dval(&adj) *= ulp(&rv); - if (dsign) { - if (word0(&rv) == Big0 && word1(&rv) == Big1) - goto ovfl; - dval(&rv) += adj.d; - } - else - dval(&rv) -= adj.d; - goto cont; - } -#endif /*Honor_FLT_ROUNDS*/ - - if (i < 0) { - /* Error is less than half an ulp -- check for - * special case of mantissa a power of two. - */ - if (dsign || word1(&rv) || word0(&rv) & Bndry_mask -#ifdef IEEE_Arith -#ifdef Avoid_Underflow - || (word0(&rv) & Exp_mask) <= (2*P+1)*Exp_msk1 -#else - || (word0(&rv) & Exp_mask) <= Exp_msk1 -#endif -#endif - ) { -#ifdef SET_INEXACT - if (!delta->x[0] && delta->wds <= 1) - inexact = 0; -#endif - break; - } - if (!delta->x[0] && delta->wds <= 1) { - /* exact result */ -#ifdef SET_INEXACT - inexact = 0; -#endif - break; - } - delta = lshift(delta,Log2P); - if (cmp(delta, bs) > 0) - goto drop_down; - break; - } - if (i == 0) { - /* exactly half-way between */ - if (dsign) { - if ((word0(&rv) & Bndry_mask1) == Bndry_mask1 - && word1(&rv) == ( -#ifdef Avoid_Underflow - (scale && (y = word0(&rv) & Exp_mask) <= 2*P*Exp_msk1) - ? (0xffffffff & (0xffffffff << (2*P+1-(y>>Exp_shift)))) : -#endif - 0xffffffff)) { - /*boundary case -- increment exponent*/ - if (word0(&rv) == Big0 && word1(&rv) == Big1) - goto ovfl; - word0(&rv) = (word0(&rv) & Exp_mask) - + Exp_msk1 -#ifdef IBM - | Exp_msk1 >> 4 -#endif - ; - word1(&rv) = 0; -#ifdef Avoid_Underflow - dsign = 0; -#endif - break; - } - } - else if (!(word0(&rv) & Bndry_mask) && !word1(&rv)) { - drop_down: - /* boundary case -- decrement exponent */ -#ifdef Sudden_Underflow /*{{*/ - L = word0(&rv) & Exp_mask; -#ifdef IBM - if (L < Exp_msk1) -#else -#ifdef Avoid_Underflow - if (L <= (scale ? (2*P+1)*Exp_msk1 : Exp_msk1)) -#else - if (L <= Exp_msk1) -#endif /*Avoid_Underflow*/ -#endif /*IBM*/ - goto undfl; - L -= Exp_msk1; -#else /*Sudden_Underflow}{*/ -#ifdef Avoid_Underflow - if (scale) { - L = word0(&rv) & Exp_mask; - if (L <= (2*P+1)*Exp_msk1) { - if (L > (P+2)*Exp_msk1) - /* round even ==> */ - /* accept rv */ - break; - /* rv = smallest denormal */ - goto undfl; - } - } -#endif /*Avoid_Underflow*/ - L = (word0(&rv) & Exp_mask) - Exp_msk1; -#endif /*Sudden_Underflow}}*/ - word0(&rv) = L | Bndry_mask1; - word1(&rv) = 0xffffffff; -#ifdef IBM - goto cont; -#else - break; -#endif - } -#ifndef ROUND_BIASED -#ifdef Avoid_Underflow - if (Lsb1) { - if (!(word0(&rv) & Lsb1)) - break; - } - else if (!(word1(&rv) & Lsb)) - break; -#else - if (!(word1(&rv) & LSB)) - break; -#endif -#endif - if (dsign) -#ifdef Avoid_Underflow - dval(&rv) += sulp(&rv, scale); -#else - dval(&rv) += ulp(&rv); -#endif -#ifndef ROUND_BIASED - else { -#ifdef Avoid_Underflow - dval(&rv) -= sulp(&rv, scale); -#else - dval(&rv) -= ulp(&rv); -#endif -#ifndef Sudden_Underflow - if (!dval(&rv)) - goto undfl; -#endif - } -#ifdef Avoid_Underflow - dsign = 1 - dsign; -#endif -#endif - break; - } - if ((aadj = ratio(delta, bs)) <= 2.) { - if (dsign) - aadj = dval(&aadj1) = 1.; - else if (word1(&rv) || word0(&rv) & Bndry_mask) { -#ifndef Sudden_Underflow - if (word1(&rv) == Tiny1 && !word0(&rv)) - goto undfl; -#endif - aadj = 1.; - dval(&aadj1) = -1.; - } - else { - /* special case -- power of FLT_RADIX to be */ - /* rounded down... */ - - if (aadj < 2./FLT_RADIX) - aadj = 1./FLT_RADIX; - else - aadj *= 0.5; - dval(&aadj1) = -aadj; - } - } - else { - aadj *= 0.5; - dval(&aadj1) = dsign ? aadj : -aadj; -#ifdef Check_FLT_ROUNDS - /* CONSTCOND */ - switch(Rounding) { - case 2: /* towards +infinity */ - dval(&aadj1) -= 0.5; - break; - case 0: /* towards 0 */ - case 3: /* towards -infinity */ - dval(&aadj1) += 0.5; - } -#else - /* CONSTCOND */ - if (Flt_Rounds == 0) - dval(&aadj1) += 0.5; -#endif /*Check_FLT_ROUNDS*/ - } - y = word0(&rv) & Exp_mask; - - /* Check for overflow */ - - if (y == Exp_msk1*(DBL_MAX_EXP+Bias-1)) { - dval(&rv0) = dval(&rv); - word0(&rv) -= P*Exp_msk1; - dval(&adj) = dval(&aadj1) * ulp(&rv); - dval(&rv) += dval(&adj); - if ((word0(&rv) & Exp_mask) >= - Exp_msk1*(DBL_MAX_EXP+Bias-P)) { - if (word0(&rv0) == Big0 && word1(&rv0) == Big1) - goto ovfl; - word0(&rv) = Big0; - word1(&rv) = Big1; - goto cont; - } - else - word0(&rv) += P*Exp_msk1; - } - else { -#ifdef Avoid_Underflow - if (scale && y <= 2*P*Exp_msk1) { - if (aadj <= 0x7fffffff) { - if ((z = aadj) == 0) - z = 1; - aadj = z; - dval(&aadj1) = dsign ? aadj : -aadj; - } - word0(&aadj1) += (2*P+1)*Exp_msk1 - y; - } - dval(&adj) = dval(&aadj1) * ulp(&rv); - dval(&rv) += dval(&adj); -#else -#ifdef Sudden_Underflow - if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) { - dval(&rv0) = dval(&rv); - word0(&rv) += P*Exp_msk1; - dval(&adj) = dval(&aadj1) * ulp(&rv); - dval(&rv) += dval(&adj); -#ifdef IBM - if ((word0(&rv) & Exp_mask) < P*Exp_msk1) -#else - if ((word0(&rv) & Exp_mask) <= P*Exp_msk1) -#endif - { - if (word0(&rv0) == Tiny0 - && word1(&rv0) == Tiny1) - goto undfl; - word0(&rv) = Tiny0; - word1(&rv) = Tiny1; - goto cont; - } - else - word0(&rv) -= P*Exp_msk1; - } - else { - dval(&adj) = dval(&aadj1) * ulp(&rv); - dval(&rv) += dval(&adj); - } -#else /*Sudden_Underflow*/ - /* Compute dval(&adj) so that the IEEE rounding rules will - * correctly round rv + dval(&adj) in some half-way cases. - * If rv * ulp(&rv) is denormalized (i.e., - * y <= (P-1)*Exp_msk1), we must adjust aadj to avoid - * trouble from bits lost to denormalization; - * example: 1.2e-307 . - */ - if (y <= (P-1)*Exp_msk1 && aadj > 1.) { - dval(&aadj1) = (double)(int)(aadj + 0.5); - if (!dsign) - dval(&aadj1) = -dval(&aadj1); - } - dval(&adj) = dval(&aadj1) * ulp(&rv); - dval(&rv) += adj; -#endif /*Sudden_Underflow*/ -#endif /*Avoid_Underflow*/ - } - z = word0(&rv) & Exp_mask; -#ifndef SET_INEXACT -#ifdef Avoid_Underflow - if (!scale) -#endif - if (y == z) { - /* Can we stop now? */ - L = (Long)aadj; - aadj -= L; - /* The tolerances below are conservative. */ - if (dsign || word1(&rv) || word0(&rv) & Bndry_mask) { - if (aadj < .4999999 || aadj > .5000001) - break; - } - else if (aadj < .4999999/FLT_RADIX) - break; - } -#endif - cont: - Bfree(bb); - Bfree(bd); - Bfree(bs); - Bfree(delta); - } - Bfree(bb); - Bfree(bd); - Bfree(bs); - Bfree(bd0); - Bfree(delta); -#ifdef SET_INEXACT - if (inexact) { - if (!oldinexact) { - word0(&rv0) = Exp_1 + (70 << Exp_shift); - word1(&rv0) = 0; - dval(&rv0) += 1.; - } - } - else if (!oldinexact) - clear_inexact(); -#endif -#ifdef Avoid_Underflow - if (scale) { - word0(&rv0) = Exp_1 - 2*P*Exp_msk1; - word1(&rv0) = 0; - dval(&rv) *= dval(&rv0); -#ifndef NO_ERRNO - /* try to avoid the bug of testing an 8087 register value */ -#ifdef IEEE_Arith - if (!(word0(&rv) & Exp_mask)) -#else - if (word0(&rv) == 0 && word1(&rv) == 0) -#endif - errno = ERANGE; -#endif - } -#endif /* Avoid_Underflow */ -#ifdef SET_INEXACT - if (inexact && !(word0(&rv) & Exp_mask)) { - /* set underflow bit */ - dval(&rv0) = 1e-300; - dval(&rv0) *= dval(&rv0); - } -#endif - ret: - if (se) - *se = __UNCONST(s); - return sign ? -dval(&rv) : dval(&rv); - } - -double -strtod(CONST char *s, char **sp) -{ - return _int_strtod_l(s, sp, _current_locale()); -} - -#ifdef __weak_alias -__weak_alias(strtod_l, _strtod_l) -#endif - -double -strtod_l(CONST char *s, char **sp, locale_t loc) -{ - return _int_strtod_l(s, sp, loc); -} diff --git a/lib/libc/gdtoa/strtodI.c b/lib/libc/gdtoa/strtodI.c deleted file mode 100644 index 54b96a839..000000000 --- a/lib/libc/gdtoa/strtodI.c +++ /dev/null @@ -1,167 +0,0 @@ -/* $NetBSD: strtodI.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - static double -#ifdef KR_headers -ulpdown(d) U *d; -#else -ulpdown(U *d) -#endif -{ - double u; - ULong *L = d->L; - - u = ulp(d); - if (!(L[_1] | (L[_0] & 0xfffff)) - && (L[_0] & 0x7ff00000) > 0x00100000) - u *= 0.5; - return u; - } - - int -#ifdef KR_headers -strtodI(s, sp, dd) CONST char *s; char **sp; double *dd; -#else -strtodI(CONST char *s, char **sp, double *dd) -#endif -{ - static FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; - ULong bits[2], sign; - Long exp; - int j, k; - U *u; - - k = strtodg(s, sp, &fpi, &exp, bits); - if (k == STRTOG_NoMemory) - return k; - u = (U*)dd; - sign = k & STRTOG_Neg ? 0x80000000L : 0; - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - dval(&u[0]) = dval(&u[1]) = 0.; - break; - - case STRTOG_Zero: - dval(&u[0]) = dval(&u[1]) = 0.; -#ifdef Sudden_Underflow - if (k & STRTOG_Inexact) { - if (sign) - word0(&u[0]) = 0x80100000L; - else - word0(&u[1]) = 0x100000L; - } - break; -#else - goto contain; -#endif - - case STRTOG_Denormal: - word1(&u[0]) = bits[0]; - word0(&u[0]) = bits[1]; - goto contain; - - case STRTOG_Normal: - word1(&u[0]) = bits[0]; - word0(&u[0]) = (bits[1] & ~0x100000) | ((exp + 0x3ff + 52) << 20); - contain: - j = k & STRTOG_Inexact; - if (sign) { - word0(&u[0]) |= sign; - j = STRTOG_Inexact - j; - } - switch(j) { - case STRTOG_Inexlo: -#ifdef Sudden_Underflow - if ((u->L[_0] & 0x7ff00000) < 0x3500000) { - word0(&u[1]) = word0(&u[0]) + 0x3500000; - word1(&u[1]) = word1(&u[0]); - dval(&u[1]) += ulp(&u[1]); - word0(&u[1]) -= 0x3500000; - if (!(word0(&u[1]) & 0x7ff00000)) { - word0(&u[1]) = sign; - word1(&u[1]) = 0; - } - } - else -#endif - dval(&u[1]) = dval(&u[0]) + ulp(&u[0]); - break; - case STRTOG_Inexhi: - dval(&u[1]) = dval(&u[0]); -#ifdef Sudden_Underflow - if ((word0(&u[0]) & 0x7ff00000) < 0x3500000) { - word0(&u[0]) += 0x3500000; - dval(&u[0]) -= ulpdown(u); - word0(&u[0]) -= 0x3500000; - if (!(word0(&u[0]) & 0x7ff00000)) { - word0(&u[0]) = sign; - word1(&u[0]) = 0; - } - } - else -#endif - dval(&u[0]) -= ulpdown(u); - break; - default: - dval(&u[1]) = dval(&u[0]); - } - break; - - case STRTOG_Infinite: - word0(&u[0]) = word0(&u[1]) = sign | 0x7ff00000; - word1(&u[0]) = word1(&u[1]) = 0; - if (k & STRTOG_Inexact) { - if (sign) { - word0(&u[1]) = 0xffefffffL; - word1(&u[1]) = 0xffffffffL; - } - else { - word0(&u[0]) = 0x7fefffffL; - word1(&u[0]) = 0xffffffffL; - } - } - break; - - case STRTOG_NaN: - u->L[0] = (u+1)->L[0] = d_QNAN0; - u->L[1] = (u+1)->L[1] = d_QNAN1; - break; - - case STRTOG_NaNbits: - word0(&u[0]) = word0(&u[1]) = 0x7ff00000 | sign | bits[1]; - word1(&u[0]) = word1(&u[1]) = bits[0]; - } - return k; - } diff --git a/lib/libc/gdtoa/strtodg.c b/lib/libc/gdtoa/strtodg.c deleted file mode 100644 index d0a910594..000000000 --- a/lib/libc/gdtoa/strtodg.c +++ /dev/null @@ -1,1106 +0,0 @@ -/* $NetBSD: strtodg.c,v 1.12 2013/04/19 10:41:53 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#ifdef USE_LOCALE -#include "locale.h" -#endif - -#ifndef VAX - static CONST int -fivesbits[] = { 0, 3, 5, 7, 10, 12, 14, 17, 19, 21, - 24, 26, 28, 31, 33, 35, 38, 40, 42, 45, - 47, 49, 52 - }; -#endif - - Bigint * -#ifdef KR_headers -increment(b) Bigint *b; -#else -increment(Bigint *b) -#endif -{ - ULong *x, *xe; - Bigint *b1; -#ifdef Pack_16 - ULong carry = 1, y; -#endif - - x = b->x; - xe = x + b->wds; -#ifdef Pack_32 - do { - if (*x < (ULong)0xffffffffL) { - ++*x; - return b; - } - *x++ = 0; - } while(x < xe); -#else - do { - y = *x + carry; - carry = y >> 16; - *x++ = y & 0xffff; - if (!carry) - return b; - } while(x < xe); - if (carry) -#endif - { - if (b->wds >= b->maxwds) { - b1 = Balloc(b->k+1); - if (b1 == NULL) - return NULL; - Bcopy(b1,b); - Bfree(b); - b = b1; - } - b->x[b->wds++] = 1; - } - return b; - } - - void -#ifdef KR_headers -decrement(b) Bigint *b; -#else -decrement(Bigint *b) -#endif -{ - ULong *x, *xe; -#ifdef Pack_16 - ULong borrow = 1, y; -#endif - - x = b->x; - xe = x + b->wds; -#ifdef Pack_32 - do { - if (*x) { - --*x; - break; - } - *x++ = 0xffffffffUL; - } - while(x < xe); -#else - do { - y = *x - borrow; - borrow = (y & 0x10000) >> 16; - *x++ = y & 0xffff; - } while(borrow && x < xe); -#endif - } - - static int -#ifdef KR_headers -all_on(b, n) CONST Bigint *b; int n; -#else -all_on(CONST Bigint *b, int n) -#endif -{ - CONST ULong *x, *xe; - - x = b->x; - xe = x + ((unsigned int)n >> kshift); - while(x < xe) - if ((*x++ & ALL_ON) != ALL_ON) - return 0; - if (n &= kmask) - return ((*x | (ALL_ON << n)) & ALL_ON) == ALL_ON; - return 1; - } - - Bigint * -#ifdef KR_headers -set_ones(b, n) Bigint *b; int n; -#else -set_ones(Bigint *b, int n) -#endif -{ - int k; - ULong *x, *xe; - - k = (unsigned int)(n + ((1 << kshift) - 1)) >> kshift; - if (b->k < k) { - Bfree(b); - b = Balloc(k); - if (b == NULL) - return NULL; - } - k = (unsigned int)n >> kshift; - if (n &= kmask) - k++; - b->wds = k; - x = b->x; - xe = x + k; - while(x < xe) - *x++ = ALL_ON; - if (n) - x[-1] >>= ULbits - n; - return b; - } - - static int -rvOK -#ifdef KR_headers - (d, fpi, expt, bits, exact, rd, irv) - U *d; CONST FPI *fpi; Long *expt; ULong *bits; int exact, rd, *irv; -#else - (U *d, CONST FPI *fpi, Long *expt, ULong *bits, int exact, int rd, int *irv) -#endif -{ - Bigint *b; - ULong carry, inex, lostbits; - int bdif, e, j, k, k1, nb, rv; - - carry = rv = 0; - b = d2b(dval(d), &e, &bdif); - bdif -= nb = fpi->nbits; - e += bdif; - if (bdif <= 0) { - if (exact) - goto trunc; - goto ret; - } - if (P == nb) { - if ( -#ifndef IMPRECISE_INEXACT - exact && -#endif - fpi->rounding == -#ifdef RND_PRODQUOT - FPI_Round_near -#else - Flt_Rounds -#endif - ) goto trunc; - goto ret; - } - switch(rd) { - case 1: /* round down (toward -Infinity) */ - goto trunc; - case 2: /* round up (toward +Infinity) */ - break; - default: /* round near */ - k = bdif - 1; - if (!k) { - if (!exact) - goto ret; - if (b->x[0] & 2) - break; - goto trunc; - } - if (b->x[(unsigned int)k>>kshift] & ((ULong)1 << (k & kmask))) - break; - goto trunc; - } - /* "break" cases: round up 1 bit, then truncate; bdif > 0 */ - carry = 1; - trunc: - inex = lostbits = 0; - if (bdif > 0) { - if ( (lostbits = any_on(b, bdif)) !=0) - inex = STRTOG_Inexlo; - rshift(b, bdif); - if (carry) { - inex = STRTOG_Inexhi; - b = increment(b); - if ( (j = nb & kmask) !=0) - j = ULbits - j; - if (hi0bits(b->x[b->wds - 1]) != j) { - if (!lostbits) - lostbits = b->x[0] & 1; - rshift(b, 1); - e++; - } - } - } - else if (bdif < 0) - b = lshift(b, -bdif); - if (e < fpi->emin) { - k = fpi->emin - e; - e = fpi->emin; - if (k > nb || fpi->sudden_underflow) { - b->wds = inex = 0; - *irv = STRTOG_Underflow | STRTOG_Inexlo; - } - else { - k1 = k - 1; - if (k1 > 0 && !lostbits) - lostbits = any_on(b, k1); - if (!lostbits && !exact) - goto ret; - lostbits |= - carry = b->x[(unsigned int)k1>>kshift] & - (1 << (k1 & kmask)); - rshift(b, k); - *irv = STRTOG_Denormal; - if (carry) { - b = increment(b); - inex = STRTOG_Inexhi | STRTOG_Underflow; - } - else if (lostbits) - inex = STRTOG_Inexlo | STRTOG_Underflow; - } - } - else if (e > fpi->emax) { - e = fpi->emax + 1; - *irv = STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; -#ifndef NO_ERRNO - errno = ERANGE; -#endif - b->wds = inex = 0; - } - *expt = e; - copybits(bits, nb, b); - *irv |= inex; - rv = 1; - ret: - Bfree(b); - return rv; - } - -#ifndef VAX - static int -#ifdef KR_headers -mantbits(d) U *d; -#else -mantbits(U *d) -#endif -{ - ULong L; -#ifdef VAX - L = word1(d) << 16 | word1(d) >> 16; - if (L) -#else - if ( (L = word1(d)) !=0) -#endif - return P - lo0bits(&L); -#ifdef VAX - L = word0(d) << 16 | word0(d) >> 16 | Exp_msk11; -#else - L = word0(d) | Exp_msk1; -#endif - return P - 32 - lo0bits(&L); - } -#endif /* !VAX */ - - int -strtodg(CONST char *s00, char **se, CONST FPI *fpi, Long *expt, ULong *bits, - locale_t loc) -{ - int abe, abits, asub; -#ifdef INFNAN_CHECK - int decpt; -#endif - int bb0, bb2, bb5, bbe, bd2, bd5, bbbits, bs2, c, denorm; - int dsign, e, e1, e2, emin, esign, finished, i, inex, irv; - int j, k, nbits, nd, nd0, nf, nz, nz0, rd, rvbits, rve, rve1, sign; - int sudden_underflow = 0; /* pacify gcc */ - CONST char *s, *s0, *s1; - double adj0, tol; - Long L; - U adj, rv; - ULong *b, *be, y, z; - Bigint *ab, *bb, *bb1, *bd, *bd0, *bs, *delta, *rvb, *rvb0; -#ifdef USE_LOCALE /*{{*/ - char *decimalpoint = localeconv_l(loc)->decimal_point; - size_t dplen = strlen(decimalpoint); -#endif /*USE_LOCALE}}*/ - - e2 = 0; /* XXX gcc */ - - irv = STRTOG_Zero; - denorm = sign = nz0 = nz = 0; - dval(&rv) = 0.; - rvb = 0; - nbits = fpi->nbits; - for(s = s00;;s++) switch(*s) { - case '-': - sign = 1; - /* FALLTHROUGH */ - case '+': - if (*++s) - goto break2; - /* FALLTHROUGH */ - case 0: - sign = 0; - irv = STRTOG_NoNumber; - s = s00; - goto ret; - case '\t': - case '\n': - case '\v': - case '\f': - case '\r': - case ' ': - continue; - default: - goto break2; - } - break2: - if (*s == '0') { -#ifndef NO_HEX_FP - switch(s[1]) { - case 'x': - case 'X': - irv = gethex(&s, fpi, expt, &rvb, sign, loc); - if (irv == STRTOG_NoNumber) { - s = s00; - sign = 0; - } - goto ret; - } -#endif - nz0 = 1; - while(*++s == '0') ; - if (!*s) - goto ret; - } - sudden_underflow = fpi->sudden_underflow; - s0 = s; - y = z = 0; -#ifdef INFNAN_CHECK - decpt = 0; -#endif - for(nd = nf = 0; (c = *s) >= '0' && c <= '9'; nd++, s++) - if (nd < 9) - y = 10*y + c - '0'; - else if (nd < 16) - z = 10*z + c - '0'; - nd0 = nd; -#ifdef USE_LOCALE - if (c == *decimalpoint) { - for(i = 1; decimalpoint[i]; ++i) - if (s[i] != decimalpoint[i]) - goto dig_done; - s += i; - c = *s; -#else - if (c == '.') { - c = *++s; -#endif -#ifdef INFNAN_CHECK - decpt = 1; -#endif - if (!nd) { - for(; c == '0'; c = *++s) - nz++; - if (c > '0' && c <= '9') { - s0 = s; - nf += nz; - nz = 0; - goto have_dig; - } - goto dig_done; - } - for(; c >= '0' && c <= '9'; c = *++s) { - have_dig: - nz++; - if (c -= '0') { - nf += nz; - for(i = 1; i < nz; i++) - if (nd++ < 9) - y *= 10; - else if (nd <= DBL_DIG + 1) - z *= 10; - if (nd++ < 9) - y = 10*y + c; - else if (nd <= DBL_DIG + 1) - z = 10*z + c; - nz = 0; - } - } - }/*}*/ - dig_done: - e = 0; - if (c == 'e' || c == 'E') { - if (!nd && !nz && !nz0) { - irv = STRTOG_NoNumber; - s = s00; - goto ret; - } - s00 = s; - esign = 0; - switch(c = *++s) { - case '-': - esign = 1; - /* FALLTHROUGH */ - case '+': - c = *++s; - } - if (c >= '0' && c <= '9') { - while(c == '0') - c = *++s; - if (c > '0' && c <= '9') { - L = c - '0'; - s1 = s; - while((c = *++s) >= '0' && c <= '9') - L = 10*L + c - '0'; - if (s - s1 > 8 || L > 19999) - /* Avoid confusion from exponents - * so large that e might overflow. - */ - e = 19999; /* safe for 16 bit ints */ - else - e = (int)L; - if (esign) - e = -e; - } - else - e = 0; - } - else - s = s00; - } - if (!nd) { - if (!nz && !nz0) { -#ifdef INFNAN_CHECK - /* Check for Nan and Infinity */ - if (!decpt) - switch(c) { - case 'i': - case 'I': - if (match(&s,"nf")) { - --s; - if (!match(&s,"inity")) - ++s; - irv = STRTOG_Infinite; - goto infnanexp; - } - break; - case 'n': - case 'N': - if (match(&s, "an")) { - irv = STRTOG_NaN; - *expt = fpi->emax + 1; -#ifndef No_Hex_NaN - if (*s == '(') /*)*/ - irv = hexnan(&s, fpi, bits); -#endif - goto infnanexp; - } - } -#endif /* INFNAN_CHECK */ - irv = STRTOG_NoNumber; - s = s00; - } - goto ret; - } - - irv = STRTOG_Normal; - e1 = e -= nf; - rd = 0; - switch(fpi->rounding & 3) { - case FPI_Round_up: - rd = 2 - sign; - break; - case FPI_Round_zero: - rd = 1; - break; - case FPI_Round_down: - rd = 1 + sign; - } - - /* Now we have nd0 digits, starting at s0, followed by a - * decimal point, followed by nd-nd0 digits. The number we're - * after is the integer represented by those digits times - * 10**e */ - - if (!nd0) - nd0 = nd; - k = nd < DBL_DIG + 1 ? nd : DBL_DIG + 1; - dval(&rv) = y; - if (k > 9) - dval(&rv) = tens[k - 9] * dval(&rv) + z; - bd0 = 0; - if (nbits <= P && nd <= DBL_DIG) { - if (!e) { - if (rvOK(&rv, fpi, expt, bits, 1, rd, &irv)) - goto ret; - } - else if (e > 0) { - if (e <= Ten_pmax) { -#ifdef VAX - goto vax_ovfl_check; -#else - i = fivesbits[e] + mantbits(&rv) <= P; - /* rv = */ rounded_product(dval(&rv), tens[e]); - if (rvOK(&rv, fpi, expt, bits, i, rd, &irv)) - goto ret; - e1 -= e; - goto rv_notOK; -#endif - } - i = DBL_DIG - nd; - if (e <= Ten_pmax + i) { - /* A fancier test would sometimes let us do - * this for larger i values. - */ - e2 = e - i; - e1 -= i; - dval(&rv) *= tens[i]; -#ifdef VAX - /* VAX exponent range is so narrow we must - * worry about overflow here... - */ - vax_ovfl_check: - dval(&adj) = dval(&rv); - word0(&adj) -= P*Exp_msk1; - /* adj = */ rounded_product(dval(&adj), tens[e2]); - if ((word0(&adj) & Exp_mask) - > Exp_msk1*(DBL_MAX_EXP+Bias-1-P)) - goto rv_notOK; - word0(&adj) += P*Exp_msk1; - dval(&rv) = dval(&adj); -#else - /* rv = */ rounded_product(dval(&rv), tens[e2]); -#endif - if (rvOK(&rv, fpi, expt, bits, 0, rd, &irv)) - goto ret; - e1 -= e2; - } - } -#ifndef Inaccurate_Divide - else if (e >= -Ten_pmax) { - /* rv = */ rounded_quotient(dval(&rv), tens[-e]); - if (rvOK(&rv, fpi, expt, bits, 0, rd, &irv)) - goto ret; - e1 -= e; - } -#endif - } - rv_notOK: - e1 += nd - k; - - /* Get starting approximation = rv * 10**e1 */ - - e2 = 0; - if (e1 > 0) { - if ( (i = e1 & 15) !=0) - dval(&rv) *= tens[i]; - if (e1 &= ~15) { - e1 = (unsigned int)e1 >> 4; - while(e1 >= (1 << (n_bigtens-1))) { - e2 += ((word0(&rv) & Exp_mask) - >> Exp_shift1) - Bias; - word0(&rv) &= ~Exp_mask; - word0(&rv) |= Bias << Exp_shift1; - dval(&rv) *= bigtens[n_bigtens-1]; - e1 -= 1 << (n_bigtens-1); - } - e2 += ((word0(&rv) & Exp_mask) >> Exp_shift1) - Bias; - word0(&rv) &= ~Exp_mask; - word0(&rv) |= Bias << Exp_shift1; - for(j = 0; e1 > 0; j++, e1 = (unsigned int)e1 >> 1) - if (e1 & 1) - dval(&rv) *= bigtens[j]; - } - } - else if (e1 < 0) { - e1 = -e1; - if ( (i = e1 & 15) !=0) - dval(&rv) /= tens[i]; - if (e1 &= ~15) { - e1 = (unsigned int)e1 >> 4; - while(e1 >= (1 << (n_bigtens-1))) { - e2 += ((word0(&rv) & Exp_mask) - >> Exp_shift1) - Bias; - word0(&rv) &= ~Exp_mask; - word0(&rv) |= Bias << Exp_shift1; - dval(&rv) *= tinytens[n_bigtens-1]; - e1 -= 1 << (n_bigtens-1); - } - e2 += ((word0(&rv) & Exp_mask) >> Exp_shift1) - Bias; - word0(&rv) &= ~Exp_mask; - word0(&rv) |= Bias << Exp_shift1; - for(j = 0; e1 > 0; j++, e1 = (unsigned int)e1 >> 1) - if (e1 & 1) - dval(&rv) *= tinytens[j]; - } - } -#ifdef IBM - /* e2 is a correction to the (base 2) exponent of the return - * value, reflecting adjustments above to avoid overflow in the - * native arithmetic. For native IBM (base 16) arithmetic, we - * must multiply e2 by 4 to change from base 16 to 2. - */ - e2 <<= 2; -#endif - rvb = d2b(dval(&rv), &rve, &rvbits); /* rv = rvb * 2^rve */ - if (rvb == NULL) - return STRTOG_NoMemory; - rve += e2; - if ((j = rvbits - nbits) > 0) { - rshift(rvb, j); - rvbits = nbits; - rve += j; - } - bb0 = 0; /* trailing zero bits in rvb */ - e2 = rve + rvbits - nbits; - if (e2 > fpi->emax + 1) - goto huge; - rve1 = rve + rvbits - nbits; - if (e2 < (emin = fpi->emin)) { - denorm = 1; - j = rve - emin; - if (j > 0) { - rvb = lshift(rvb, j); - rvbits += j; - } - else if (j < 0) { - rvbits += j; - if (rvbits <= 0) { - if (rvbits < -1) { - ufl: - rvb->wds = 0; - rvb->x[0] = 0; - *expt = emin; - irv = STRTOG_Underflow | STRTOG_Inexlo; - goto ret; - } - rvb->x[0] = rvb->wds = rvbits = 1; - } - else - rshift(rvb, -j); - } - rve = rve1 = emin; - if (sudden_underflow && e2 + 1 < emin) - goto ufl; - } - - /* Now the hard part -- adjusting rv to the correct value.*/ - - /* Put digits into bd: true value = bd * 10^e */ - - bd0 = s2b(s0, nd0, nd, y, dplen); - - for(;;) { - bd = Balloc(bd0->k); - if (bd == NULL) - return STRTOG_NoMemory; - Bcopy(bd, bd0); - bb = Balloc(rvb->k); - if (bb == NULL) - return STRTOG_NoMemory; - Bcopy(bb, rvb); - bbbits = rvbits - bb0; - bbe = rve + bb0; - bs = i2b(1); - if (bs == NULL) - return STRTOG_NoMemory; - - if (e >= 0) { - bb2 = bb5 = 0; - bd2 = bd5 = e; - } - else { - bb2 = bb5 = -e; - bd2 = bd5 = 0; - } - if (bbe >= 0) - bb2 += bbe; - else - bd2 -= bbe; - bs2 = bb2; - j = nbits + 1 - bbbits; - i = bbe + bbbits - nbits; - if (i < emin) /* denormal */ - j += i - emin; - bb2 += j; - bd2 += j; - i = bb2 < bd2 ? bb2 : bd2; - if (i > bs2) - i = bs2; - if (i > 0) { - bb2 -= i; - bd2 -= i; - bs2 -= i; - } - if (bb5 > 0) { - bs = pow5mult(bs, bb5); - if (bs == NULL) - return STRTOG_NoMemory; - bb1 = mult(bs, bb); - if (bb1 == NULL) - return STRTOG_NoMemory; - Bfree(bb); - bb = bb1; - } - bb2 -= bb0; - if (bb2 > 0) { - bb = lshift(bb, bb2); - if (bb == NULL) - return STRTOG_NoMemory; - } - else if (bb2 < 0) - rshift(bb, -bb2); - if (bd5 > 0) { - bd = pow5mult(bd, bd5); - if (bd == NULL) - return STRTOG_NoMemory; - } - if (bd2 > 0) { - bd = lshift(bd, bd2); - if (bd == NULL) - return STRTOG_NoMemory; - } - if (bs2 > 0) { - bs = lshift(bs, bs2); - if (bs == NULL) - return STRTOG_NoMemory; - } - asub = 1; - inex = STRTOG_Inexhi; - delta = diff(bb, bd); - if (delta == NULL) - return STRTOG_NoMemory; - if (delta->wds <= 1 && !delta->x[0]) - break; - dsign = delta->sign; - delta->sign = finished = 0; - L = 0; - i = cmp(delta, bs); - if (rd && i <= 0) { - irv = STRTOG_Normal; - if ( (finished = dsign ^ (rd&1)) !=0) { - if (dsign != 0) { - irv |= STRTOG_Inexhi; - goto adj1; - } - irv |= STRTOG_Inexlo; - if (rve1 == emin) - goto adj1; - for(i = 0, j = nbits; j >= ULbits; - i++, j -= ULbits) { - if (rvb->x[i] & ALL_ON) - goto adj1; - } - if (j > 1 && lo0bits(rvb->x + i) < j - 1) - goto adj1; - rve = rve1 - 1; - rvb = set_ones(rvb, rvbits = nbits); - if (rvb == NULL) - return STRTOG_NoMemory; - break; - } - irv |= dsign ? STRTOG_Inexlo : STRTOG_Inexhi; - break; - } - if (i < 0) { - /* Error is less than half an ulp -- check for - * special case of mantissa a power of two. - */ - irv = dsign - ? STRTOG_Normal | STRTOG_Inexlo - : STRTOG_Normal | STRTOG_Inexhi; - if (dsign || bbbits > 1 || denorm || rve1 == emin) - break; - delta = lshift(delta,1); - if (delta == NULL) - return STRTOG_NoMemory; - if (cmp(delta, bs) > 0) { - irv = STRTOG_Normal | STRTOG_Inexlo; - goto drop_down; - } - break; - } - if (i == 0) { - /* exactly half-way between */ - if (dsign) { - if (denorm && all_on(rvb, rvbits)) { - /*boundary case -- increment exponent*/ - rvb->wds = 1; - rvb->x[0] = 1; - rve = emin + nbits - (rvbits = 1); - irv = STRTOG_Normal | STRTOG_Inexhi; - denorm = 0; - break; - } - irv = STRTOG_Normal | STRTOG_Inexlo; - } - else if (bbbits == 1) { - irv = STRTOG_Normal; - drop_down: - /* boundary case -- decrement exponent */ - if (rve1 == emin) { - irv = STRTOG_Normal | STRTOG_Inexhi; - if (rvb->wds == 1 && rvb->x[0] == 1) - sudden_underflow = 1; - break; - } - rve -= nbits; - rvb = set_ones(rvb, rvbits = nbits); - if (rvb == NULL) - return STRTOG_NoMemory; - break; - } - else - irv = STRTOG_Normal | STRTOG_Inexhi; - if ((bbbits < nbits && !denorm) || !(rvb->x[0] & 1)) - break; - if (dsign) { - rvb = increment(rvb); - if (rvb == NULL) - return STRTOG_NoMemory; - j = kmask & (ULbits - (rvbits & kmask)); - if (hi0bits(rvb->x[rvb->wds - 1]) != j) - rvbits++; - irv = STRTOG_Normal | STRTOG_Inexhi; - } - else { - if (bbbits == 1) - goto undfl; - decrement(rvb); - irv = STRTOG_Normal | STRTOG_Inexlo; - } - break; - } - if ((dval(&adj) = ratio(delta, bs)) <= 2.) { - adj1: - inex = STRTOG_Inexlo; - if (dsign) { - asub = 0; - inex = STRTOG_Inexhi; - } - else if (denorm && bbbits <= 1) { - undfl: - rvb->wds = 0; - rve = emin; - irv = STRTOG_Underflow | STRTOG_Inexlo; - break; - } - adj0 = dval(&adj) = 1.; - } - else { - adj0 = dval(&adj) *= 0.5; - if (dsign) { - asub = 0; - inex = STRTOG_Inexlo; - } - if (dval(&adj) < 2147483647.) { - L = adj0; - adj0 -= L; - switch(rd) { - case 0: - if (adj0 >= .5) - goto inc_L; - break; - case 1: - if (asub && adj0 > 0.) - goto inc_L; - break; - case 2: - if (!asub && adj0 > 0.) { - inc_L: - L++; - inex = STRTOG_Inexact - inex; - } - } - dval(&adj) = L; - } - } - y = rve + rvbits; - - /* adj *= ulp(dval(&rv)); */ - /* if (asub) rv -= adj; else rv += adj; */ - - if (!denorm && rvbits < nbits) { - rvb = lshift(rvb, j = nbits - rvbits); - if (rvb == NULL) - return STRTOG_NoMemory; - rve -= j; - rvbits = nbits; - } - ab = d2b(dval(&adj), &abe, &abits); - if (ab == NULL) - return STRTOG_NoMemory; - if (abe < 0) - rshift(ab, -abe); - else if (abe > 0) - ab = lshift(ab, abe); - rvb0 = rvb; - if (asub) { - /* rv -= adj; */ - j = hi0bits(rvb->x[rvb->wds-1]); - rvb = diff(rvb, ab); - if (rvb == NULL) - return STRTOG_NoMemory; - k = rvb0->wds - 1; - if (denorm) - /* do nothing */; - else if (rvb->wds <= k - || hi0bits( rvb->x[k]) > - hi0bits(rvb0->x[k])) { - /* unlikely; can only have lost 1 high bit */ - if (rve1 == emin) { - --rvbits; - denorm = 1; - } - else { - rvb = lshift(rvb, 1); - if (rvb == NULL) - return STRTOG_NoMemory; - --rve; - --rve1; - L = finished = 0; - } - } - } - else { - rvb = sum(rvb, ab); - if (rvb == NULL) - return STRTOG_NoMemory; - k = rvb->wds - 1; - if (k >= rvb0->wds - || hi0bits(rvb->x[k]) < hi0bits(rvb0->x[k])) { - if (denorm) { - if (++rvbits == nbits) - denorm = 0; - } - else { - rshift(rvb, 1); - rve++; - rve1++; - L = 0; - } - } - } - Bfree(ab); - Bfree(rvb0); - if (finished) - break; - - z = rve + rvbits; - if (y == z && L) { - /* Can we stop now? */ - tol = dval(&adj) * 5e-16; /* > max rel error */ - dval(&adj) = adj0 - .5; - if (dval(&adj) < -tol) { - if (adj0 > tol) { - irv |= inex; - break; - } - } - else if (dval(&adj) > tol && adj0 < 1. - tol) { - irv |= inex; - break; - } - } - bb0 = denorm ? 0 : trailz(rvb); - Bfree(bb); - Bfree(bd); - Bfree(bs); - Bfree(delta); - } - if (!denorm && (j = nbits - rvbits)) { - if (j > 0) - rvb = lshift(rvb, j); - else - rshift(rvb, -j); - rve -= j; - } - *expt = rve; - Bfree(bb); - Bfree(bd); - Bfree(bs); - Bfree(bd0); - Bfree(delta); - if (rve > fpi->emax) { - switch(fpi->rounding & 3) { - case FPI_Round_near: - goto huge; - case FPI_Round_up: - if (!sign) - goto huge; - break; - case FPI_Round_down: - if (sign) - goto huge; - } - /* Round to largest representable magnitude */ - Bfree(rvb); - rvb = 0; - irv = STRTOG_Normal | STRTOG_Inexlo; - *expt = fpi->emax; - b = bits; - be = b + ((unsigned int)(fpi->nbits + 31) >> 5); - while(b < be) - *b++ = (unsigned int)-1; - if ((j = fpi->nbits & 0x1f) != 0) - *--be >>= (32 - j); - goto ret; - huge: - rvb->wds = 0; - irv = STRTOG_Infinite | STRTOG_Overflow | STRTOG_Inexhi; -#ifndef NO_ERRNO - errno = ERANGE; -#endif -#ifdef INFNAN_CHECK - infnanexp: -#endif - *expt = fpi->emax + 1; - } - ret: - if (denorm) { - if (sudden_underflow) { - rvb->wds = 0; - irv = STRTOG_Underflow | STRTOG_Inexlo; -#ifndef NO_ERRNO - errno = ERANGE; -#endif - } - else { - irv = (irv & ~STRTOG_Retmask) | - (rvb->wds > 0 ? STRTOG_Denormal : STRTOG_Zero); - if (irv & STRTOG_Inexact) { - irv |= STRTOG_Underflow; -#ifndef NO_ERRNO - errno = ERANGE; -#endif - } - } - } - if (se) - *se = __UNCONST(s); - if (sign) - irv |= STRTOG_Neg; - if (rvb) { - copybits(bits, nbits, rvb); - Bfree(rvb); - } - return irv; - } diff --git a/lib/libc/gdtoa/strtodnrp.c b/lib/libc/gdtoa/strtodnrp.c deleted file mode 100644 index 1c5dc7242..000000000 --- a/lib/libc/gdtoa/strtodnrp.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: strtodnrp.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 2004 by David M. Gay. -All Rights Reserved -Based on material in the rest of /netlib/fp/gdota.tar.gz, -which is copyright (C) 1998, 2000 by Lucent Technologies. - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* This is a variant of strtod that works on Intel ia32 systems */ -/* with the default extended-precision arithmetic -- it does not */ -/* require setting the precision control to 53 bits. */ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - double -#ifdef KR_headers -strtod(s, sp) CONST char *s; char **sp; -#else -strtod(CONST char *s, char **sp) -#endif -{ - static const FPI fpi = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; - ULong bits[2]; - Long expt; - int k; - union { ULong L[2]; double d; } u; - - k = strtodg(s, sp, &fpi, &expt, bits); - if (k == STRTOG_NoMemory) { - errno = ERANGE; - u.L[0] = Big0; - u.L[1] = Big1; - return u.d; - } - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - u.L[0] = u.L[1] = 0; - break; - - case STRTOG_Normal: - u.L[_1] = bits[0]; - u.L[_0] = (bits[1] & ~0x100000) | ((expt + 0x3ff + 52) << 20); - break; - - case STRTOG_Denormal: - u.L[_1] = bits[0]; - u.L[_0] = bits[1]; - break; - - case STRTOG_Infinite: - u.L[_0] = 0x7ff00000; - u.L[_1] = 0; - break; - - case STRTOG_NaN: - u.L[0] = d_QNAN0; - u.L[1] = d_QNAN1; - break; - - case STRTOG_NaNbits: - u.L[_0] = 0x7ff00000 | bits[1]; - u.L[_1] = bits[0]; - } - if (k & STRTOG_Neg) - u.L[_0] |= 0x80000000L; - return u.d; - } diff --git a/lib/libc/gdtoa/strtof.c b/lib/libc/gdtoa/strtof.c deleted file mode 100644 index ca2d268bf..000000000 --- a/lib/libc/gdtoa/strtof.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $NetBSD: strtof.c,v 1.7 2013/05/17 12:55:57 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "namespace.h" -#include "gdtoaimp.h" - -#include -#include "setlocale_local.h" - -#ifdef __weak_alias -__weak_alias(strtof, _strtof) -__weak_alias(strtof_l, _strtof_l) -#endif - -static float -_int_strtof_l(CONST char *s, char **sp, locale_t loc) -{ - static CONST FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI }; - ULong bits[1]; - Long expt; - int k; - union { ULong L[1]; float f; } u; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - k = strtodg(s, sp, fpi, &expt, bits, loc); - if (k == STRTOG_NoMemory) { - errno = ERANGE; - return HUGE_VALF; - } - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - u.L[0] = 0; - break; - - case STRTOG_Normal: - case STRTOG_NaNbits: - u.L[0] = (bits[0] & 0x7fffff) | ((expt + 0x7f + 23) << 23); - break; - - case STRTOG_Denormal: - u.L[0] = bits[0]; - break; - - case STRTOG_Infinite: - u.L[0] = 0x7f800000; - break; - - case STRTOG_NaN: - u.L[0] = f_QNAN; - break; - - default: - u.L[0] = 0; /* for gcc warning */ - break; - } - if (k & STRTOG_Neg) - u.L[0] |= 0x80000000L; - return u.f; - } - -float -strtof(CONST char *s, char **sp) -{ - return _int_strtof_l(s, sp, _current_locale()); -} - -float -strtof_l(CONST char *s, char **sp, locale_t loc) -{ - return _int_strtof_l(s, sp, loc); -} diff --git a/lib/libc/gdtoa/strtof_vaxf.c b/lib/libc/gdtoa/strtof_vaxf.c deleted file mode 100644 index 8eaeec89a..000000000 --- a/lib/libc/gdtoa/strtof_vaxf.c +++ /dev/null @@ -1,93 +0,0 @@ -/* $NetBSD: strtof_vaxf.c,v 1.8 2013/05/17 12:55:57 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Adapted to VAX F_floating by Klaus Klein . */ - -#include "namespace.h" -#include "gdtoaimp.h" -#include -#include "setlocale_local.h" - -#ifdef __weak_alias -__weak_alias(strtof, _strtof) -__weak_alias(strtof_l, _strtof_l) -#endif - -static float -_int_strtof_l(CONST char *s, char **sp, locale_t loc) -{ - static CONST FPI fpi = { 24, 1-128-1-24+1, 255-128-1-24+1, 1, SI }; - ULong bits[1]; - Long expt; - int k; - union { ULong L[1]; float f; } u; - - k = strtodg(s, sp, &fpi, &expt, bits, loc); - if (k == STRTOG_NoMemory) { - errno = ERANGE; - return HUGE_VALF; - } - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - default: - u.f = 0.0; - break; - - case STRTOG_Normal: - u.L[0] = ((bits[0] & 0x0000ffff) << 16) | /* FracLo */ - ((bits[0] & 0x007f0000) >> 16) | /* FracHi */ - ((expt + 128 + 1 + 23) << 7); /* Exp */ - break; - - case STRTOG_Infinite: - u.f = HUGE_VALF; - break; - - } - if (k & STRTOG_Neg) - u.L[0] |= 0x00008000L; - return u.f; -} - -float -strtof(CONST char *s, char **sp) -{ - return _int_strtof_l(s, sp, _current_locale()); -} - -float -strtof_l(CONST char *s, char **sp, locale_t loc) -{ - return _int_strtof_l(s, sp, loc); -} diff --git a/lib/libc/gdtoa/strtold_pQ.c b/lib/libc/gdtoa/strtold_pQ.c deleted file mode 100644 index 630d9dfe6..000000000 --- a/lib/libc/gdtoa/strtold_pQ.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: strtold_pQ.c,v 1.1 2006/03/15 17:35:18 kleink Exp $ */ - -#define GDTOA_LD_FMT Q -#include "strtold_subr.c" diff --git a/lib/libc/gdtoa/strtold_px.c b/lib/libc/gdtoa/strtold_px.c deleted file mode 100644 index 779da854a..000000000 --- a/lib/libc/gdtoa/strtold_px.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: strtold_px.c,v 1.1 2006/03/15 17:35:18 kleink Exp $ */ - -#define GDTOA_LD_FMT x -#include "strtold_subr.c" diff --git a/lib/libc/gdtoa/strtold_pxL.c b/lib/libc/gdtoa/strtold_pxL.c deleted file mode 100644 index 04c019320..000000000 --- a/lib/libc/gdtoa/strtold_pxL.c +++ /dev/null @@ -1,4 +0,0 @@ -/* $NetBSD: strtold_pxL.c,v 1.1 2006/03/15 17:35:18 kleink Exp $ */ - -#define GDTOA_LD_FMT xL -#include "strtold_subr.c" diff --git a/lib/libc/gdtoa/strtold_subr.c b/lib/libc/gdtoa/strtold_subr.c deleted file mode 100644 index 1f5e1aa59..000000000 --- a/lib/libc/gdtoa/strtold_subr.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: strtold_subr.c,v 1.3 2013/05/17 12:55:57 joerg Exp $ */ - -/* - * Written by Klaus Klein , November 16, 2005. - * Public domain. - */ - -/* - * NOTICE: This is not a standalone file. To use it, #include it in - * the format-specific strtold_*.c, like so: - * - * #define GDTOA_LD_FMT - * #include "strtold_subr.c" - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: strtold_subr.c,v 1.3 2013/05/17 12:55:57 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include "gdtoa.h" - -#include -#include "setlocale_local.h" - -#ifdef __weak_alias -__weak_alias(strtold, _strtold) -__weak_alias(strtold_l, _strtold_l) -#endif - -#ifndef __HAVE_LONG_DOUBLE -#error no extended-precision long double type -#endif - -#ifndef GDTOA_LD_FMT -#error GDTOA_LD_FMT must be defined by format-specific source file -#endif - -#define STRTOP(x) __CONCAT(strtop, x) - -static long double -_int_strtold_l(const char *nptr, char **endptr, locale_t loc) -{ - long double ld; - - (void)STRTOP(GDTOA_LD_FMT)(nptr, endptr, &ld, loc); - return ld; -} - -long double -strtold(CONST char *s, char **sp) -{ - return _int_strtold_l(s, sp, _current_locale()); -} - -long double -strtold_l(CONST char *s, char **sp, locale_t loc) -{ - return _int_strtold_l(s, sp, loc); -} diff --git a/lib/libc/gdtoa/strtopQ.c b/lib/libc/gdtoa/strtopQ.c deleted file mode 100644 index 9833cc384..000000000 --- a/lib/libc/gdtoa/strtopQ.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $NetBSD: strtopQ.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 3 -#define _1 2 -#define _2 1 -#define _3 0 -#endif - - int -strtopQ(CONST char *s, char **sp, void *V, locale_t loc) -{ - static CONST FPI fpi0 = { 113, 1-16383-113+1, 32766 - 16383 - 113 + 1, 1, SI }; - ULong bits[4]; - Long expt; - int k; - ULong *L = (ULong*)V; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - k = strtodg(s, sp, fpi, &expt, bits, loc); - if (k == STRTOG_NoMemory) - return k; - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = L[2] = L[3] = 0; - break; - - case STRTOG_Normal: - case STRTOG_NaNbits: - L[_3] = bits[0]; - L[_2] = bits[1]; - L[_1] = bits[2]; - L[_0] = (bits[3] & ~0x10000) | ((expt + 0x3fff + 112) << 16); - break; - - case STRTOG_Denormal: - L[_3] = bits[0]; - L[_2] = bits[1]; - L[_1] = bits[2]; - L[_0] = bits[3]; - break; - - case STRTOG_Infinite: - L[_0] = 0x7fff0000; - L[_1] = L[_2] = L[_3] = 0; - break; - - case STRTOG_NaN: - L[0] = ld_QNAN0; - L[1] = ld_QNAN1; - L[2] = ld_QNAN2; - L[3] = ld_QNAN3; - } - if (k & STRTOG_Neg) - L[_0] |= 0x80000000L; - return k; - } diff --git a/lib/libc/gdtoa/strtopd.c b/lib/libc/gdtoa/strtopd.c deleted file mode 100644 index 832027150..000000000 --- a/lib/libc/gdtoa/strtopd.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: strtopd.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtopd(s, sp, d) char *s; char **sp; double *d; -#else -strtopd(CONST char *s, char **sp, double *d) -#endif -{ - static FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; - ULong bits[2]; - Long expt; - int k; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - k = strtodg(s, sp, fpi, &expt, bits); - if (k == STRTOG_NoMemory) - return k; - ULtod((ULong*)d, bits, expt, k); - return k; - } diff --git a/lib/libc/gdtoa/strtopdd.c b/lib/libc/gdtoa/strtopdd.c deleted file mode 100644 index 74ff16521..000000000 --- a/lib/libc/gdtoa/strtopdd.c +++ /dev/null @@ -1,187 +0,0 @@ -/* $NetBSD: strtopdd.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtopdd(s, sp, dd) CONST char *s; char **sp; double *dd; -#else -strtopdd(CONST char *s, char **sp, double *dd) -#endif -{ -#ifdef Sudden_Underflow - static FPI fpi0 = { 106, 1-1023, 2046-1023-106+1, 1, 1 }; -#else - static FPI fpi0 = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 }; -#endif - ULong bits[4]; - Long expt; - int i, j, rv; - typedef union { - double d[2]; - ULong L[4]; - } U; - U *u; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - rv = strtodg(s, sp, fpi, &expt, bits); - if (rv == STRTOG_NoMemory) - return rv; - u = (U*)dd; - switch(rv & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - u->d[0] = u->d[1] = 0.; - break; - - case STRTOG_Normal: - u->L[_1] = (bits[1] >> 21 | bits[2] << 11) & 0xffffffffL; - u->L[_0] = (bits[2] >> 21) | ((bits[3] << 11) & 0xfffff) - | ((expt + 0x3ff + 105) << 20); - expt += 0x3ff + 52; - if (bits[1] &= 0x1fffff) { - i = hi0bits(bits[1]) - 11; - if (i >= expt) { - i = expt - 1; - expt = 0; - } - else - expt -= i; - if (i > 0) { - bits[1] = bits[1] << i | bits[0] >> (32-i); - bits[0] = bits[0] << i & 0xffffffffL; - } - } - else if (bits[0]) { - i = hi0bits(bits[0]) + 21; - if (i >= expt) { - i = expt - 1; - expt = 0; - } - else - expt -= i; - if (i < 32) { - bits[1] = bits[0] >> (32 - i); - bits[0] = bits[0] << i & 0xffffffffL; - } - else { - bits[1] = bits[0] << (i - 32); - bits[0] = 0; - } - } - else { - u->L[2] = u->L[3] = 0; - break; - } - u->L[2+_1] = bits[0]; - u->L[2+_0] = (bits[1] & 0xfffff) | (expt << 20); - break; - - case STRTOG_Denormal: - if (bits[3]) - goto nearly_normal; - if (bits[2]) - goto partly_normal; - if (bits[1] & 0xffe00000) - goto hardly_normal; - /* completely denormal */ - u->L[2] = u->L[3] = 0; - u->L[_1] = bits[0]; - u->L[_0] = bits[1]; - break; - - nearly_normal: - i = hi0bits(bits[3]) - 11; /* i >= 12 */ - j = 32 - i; - u->L[_0] = ((bits[3] << i | bits[2] >> j) & 0xfffff) - | ((65 - i) << 20); - u->L[_1] = (bits[2] << i | bits[1] >> j) & 0xffffffffL; - u->L[2+_0] = bits[1] & ((1L << j) - 1); - u->L[2+_1] = bits[0]; - break; - - partly_normal: - i = hi0bits(bits[2]) - 11; - if (i < 0) { - j = -i; - i += 32; - u->L[_0] = (bits[2] >> j & 0xfffff) | (33 + j) << 20; - u->L[_1] = ((bits[2] << i) | (bits[1] >> j)) & 0xffffffffL; - u->L[2+_0] = bits[1] & ((1L << j) - 1); - u->L[2+_1] = bits[0]; - break; - } - if (i == 0) { - u->L[_0] = (bits[2] & 0xfffff) | (33 << 20); - u->L[_1] = bits[1]; - u->L[2+_0] = 0; - u->L[2+_1] = bits[0]; - break; - } - j = 32 - i; - u->L[_0] = (((bits[2] << i) | (bits[1] >> j)) & 0xfffff) - | ((j + 1) << 20); - u->L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL; - u->L[2+_0] = 0; - u->L[2+_1] = bits[0] & ((1L << j) - 1); - break; - - hardly_normal: - j = 11 - hi0bits(bits[1]); - i = 32 - j; - u->L[_0] = (bits[1] >> j & 0xfffff) | ((j + 1) << 20); - u->L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL; - u->L[2+_0] = 0; - u->L[2+_1] = bits[0] & ((1L << j) - 1); - break; - - case STRTOG_Infinite: - u->L[_0] = u->L[2+_0] = 0x7ff00000; - u->L[_1] = u->L[2+_1] = 0; - break; - - case STRTOG_NaN: - u->L[0] = u->L[2] = d_QNAN0; - u->L[1] = u->L[3] = d_QNAN1; - } - if (rv & STRTOG_Neg) { - u->L[ _0] |= 0x80000000L; - u->L[2+_0] |= 0x80000000L; - } - return rv; - } diff --git a/lib/libc/gdtoa/strtopf.c b/lib/libc/gdtoa/strtopf.c deleted file mode 100644 index 880aa82cc..000000000 --- a/lib/libc/gdtoa/strtopf.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: strtopf.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - int -#ifdef KR_headers -strtopf(s, sp, f) CONST char *s; char **sp; float *f; -#else -strtopf(CONST char *s, char **sp, float *f) -#endif -{ - static FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI }; - ULong bits[1], *L; - Long expt; - int k; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - k = strtodg(s, sp, fpi, &expt, bits); - if (k == STRTOG_NoMemory) - return k; - L = (ULong*)f; - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = 0; - break; - - case STRTOG_Normal: - case STRTOG_NaNbits: - L[0] = (bits[0] & 0x7fffff) | ((expt + 0x7f + 23) << 23); - break; - - case STRTOG_Denormal: - L[0] = bits[0]; - break; - - case STRTOG_Infinite: - L[0] = 0x7f800000; - break; - - case STRTOG_NaN: - L[0] = f_QNAN; - } - if (k & STRTOG_Neg) - L[0] |= 0x80000000L; - return k; - } diff --git a/lib/libc/gdtoa/strtopx.c b/lib/libc/gdtoa/strtopx.c deleted file mode 100644 index 79b5e4f68..000000000 --- a/lib/libc/gdtoa/strtopx.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $NetBSD: strtopx.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#define _4 4 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 4 -#define _1 3 -#define _2 2 -#define _3 1 -#define _4 0 -#endif - - int -strtopx(CONST char *s, char **sp, void *V, locale_t loc) -{ - static const FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; - ULong bits[2]; - Long expt; - int k; - UShort *L = (UShort*)V; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - k = strtodg(s, sp, fpi, &expt, bits, loc); - if (k == STRTOG_NoMemory) - return k; - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = L[2] = L[3] = L[4] = 0; - break; - - case STRTOG_Denormal: - L[_0] = 0; - goto normal_bits; - - case STRTOG_Normal: - case STRTOG_NaNbits: - L[_0] = expt + 0x3fff + 63; - normal_bits: - L[_4] = (UShort)bits[0]; - L[_3] = (UShort)(bits[0] >> 16); - L[_2] = (UShort)bits[1]; - L[_1] = (UShort)(bits[1] >> 16); - break; - - case STRTOG_Infinite: - L[_0] = 0x7fff; - L[_1] = 0x8000; - L[_2] = L[_3] = L[_4] = 0; - break; - - case STRTOG_NaN: - L[0] = ldus_QNAN0; - L[1] = ldus_QNAN1; - L[2] = ldus_QNAN2; - L[3] = ldus_QNAN3; - L[4] = ldus_QNAN4; - } - if (k & STRTOG_Neg) - L[_0] |= 0x8000; - return k; - } diff --git a/lib/libc/gdtoa/strtopxL.c b/lib/libc/gdtoa/strtopxL.c deleted file mode 100644 index 4624be407..000000000 --- a/lib/libc/gdtoa/strtopxL.c +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: strtopxL.c,v 1.6 2013/04/18 21:54:11 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 2 -#define _1 1 -#define _2 0 -#endif - - int -strtopxL(CONST char *s, char **sp, void *V, locale_t loc) -{ - static CONST FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; - ULong bits[2]; - Long expt; - int k; - ULong *L = (ULong*)V; -#ifdef Honor_FLT_ROUNDS -#include "gdtoa_fltrnds.h" -#else -#define fpi &fpi0 -#endif - - k = strtodg(s, sp, fpi, &expt, bits, loc); - if (k == STRTOG_NoMemory) - return k; - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = L[2] = 0; - break; - - case STRTOG_Normal: - case STRTOG_Denormal: - case STRTOG_NaNbits: - L[_2] = bits[0]; - L[_1] = bits[1]; - L[_0] = (expt + 0x3fff + 63) << 16; - break; - - case STRTOG_Infinite: - L[_0] = 0x7fff << 16; - L[_1] = 0x80000000; - L[_2] = 0; - break; - - case STRTOG_NaN: - L[0] = ld_QNAN0; - L[1] = ld_QNAN1; - L[2] = ld_QNAN2; - } - if (k & STRTOG_Neg) - L[_0] |= 0x80000000L; - return k; - } diff --git a/lib/libc/gdtoa/strtorQ.c b/lib/libc/gdtoa/strtorQ.c deleted file mode 100644 index a001271a8..000000000 --- a/lib/libc/gdtoa/strtorQ.c +++ /dev/null @@ -1,121 +0,0 @@ -/* $NetBSD: strtorQ.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 3 -#define _1 2 -#define _2 1 -#define _3 0 -#endif - - void -#ifdef KR_headers -ULtoQ(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k; -#else -ULtoQ(ULong *L, ULong *bits, Long expt, int k) -#endif -{ - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = L[2] = L[3] = 0; - break; - - case STRTOG_Normal: - case STRTOG_NaNbits: - L[_3] = bits[0]; - L[_2] = bits[1]; - L[_1] = bits[2]; - L[_0] = (bits[3] & ~0x10000) | ((expt + 0x3fff + 112) << 16); - break; - - case STRTOG_Denormal: - L[_3] = bits[0]; - L[_2] = bits[1]; - L[_1] = bits[2]; - L[_0] = bits[3]; - break; - - case STRTOG_Infinite: - L[_0] = 0x7fff0000; - L[_1] = L[_2] = L[_3] = 0; - break; - - case STRTOG_NaN: - L[0] = ld_QNAN0; - L[1] = ld_QNAN1; - L[2] = ld_QNAN2; - L[3] = ld_QNAN3; - } - if (k & STRTOG_Neg) - L[_0] |= 0x80000000L; - } - - int -#ifdef KR_headers -strtorQ(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L; -#else -strtorQ(CONST char *s, char **sp, int rounding, void *L) -#endif -{ - static FPI fpi0 = { 113, 1-16383-113+1, 32766-16383-113+1, 1, SI }; - FPI *fpi, fpi1; - ULong bits[4]; - Long expt; - int k; - - fpi = &fpi0; - if (rounding != FPI_Round_near) { - fpi1 = fpi0; - fpi1.rounding = rounding; - fpi = &fpi1; - } - k = strtodg(s, sp, fpi, &expt, bits); - if (k == STRTOG_NoMemory) - return k; - ULtoQ((ULong*)L, bits, expt, k); - return k; - } diff --git a/lib/libc/gdtoa/strtord.c b/lib/libc/gdtoa/strtord.c deleted file mode 100644 index 9b8c215c1..000000000 --- a/lib/libc/gdtoa/strtord.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $NetBSD: strtord.c,v 1.5 2013/04/18 21:54:11 joerg Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - void -#ifdef KR_headers -ULtod(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k; -#else -ULtod(ULong *L, ULong *bits, Long expt, int k) -#endif -{ - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = 0; - break; - - case STRTOG_Denormal: - L[_1] = bits[0]; - L[_0] = bits[1]; - break; - - case STRTOG_Normal: - case STRTOG_NaNbits: - L[_1] = bits[0]; - L[_0] = (bits[1] & ~0x100000) | ((expt + 0x3ff + 52) << 20); - break; - - case STRTOG_Infinite: - L[_0] = 0x7ff00000; - L[_1] = 0; - break; - -#ifdef d_QNAN0 - case STRTOG_NaN: - L[0] = d_QNAN0; - L[1] = d_QNAN1; -#endif - } - if (k & STRTOG_Neg) - L[_0] |= 0x80000000L; - } - - int -strtord(CONST char *s, char **sp, int rounding, double *d, locale_t loc) -{ - static CONST FPI fpi0 = { 53, 1-1023-53+1, 2046-1023-53+1, 1, SI }; - CONST FPI *fpi; - FPI fpi1; - ULong bits[2]; - Long expt; - int k; - - fpi = &fpi0; - if (rounding != FPI_Round_near) { - fpi1 = fpi0; - fpi1.rounding = rounding; - fpi = &fpi1; - } - k = strtodg(s, sp, fpi, &expt, bits, loc); - if (k == STRTOG_NoMemory) - return k; - ULtod((/* LINTED */(U*)d)->L, bits, expt, k); - return k; - } diff --git a/lib/libc/gdtoa/strtordd.c b/lib/libc/gdtoa/strtordd.c deleted file mode 100644 index d60f52941..000000000 --- a/lib/libc/gdtoa/strtordd.c +++ /dev/null @@ -1,204 +0,0 @@ -/* $NetBSD: strtordd.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - void -#ifdef KR_headers -ULtodd(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k; -#else -ULtodd(ULong *L, ULong *bits, Long expt, int k) -#endif -{ - int i, j; - - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = L[2] = L[3] = 0; - break; - - case STRTOG_Normal: - L[_1] = (bits[1] >> 21 | bits[2] << 11) & (ULong)0xffffffffL; - L[_0] = (bits[2] >> 21) | (bits[3] << 11 & 0xfffff) - | ((expt + 0x3ff + 105) << 20); - expt += 0x3ff + 52; - if (bits[1] &= 0x1fffff) { - i = hi0bits(bits[1]) - 11; - if (i >= expt) { - i = expt - 1; - expt = 0; - } - else - expt -= i; - if (i > 0) { - bits[1] = bits[1] << i | bits[0] >> (32-i); - bits[0] = bits[0] << i & (ULong)0xffffffffL; - } - } - else if (bits[0]) { - i = hi0bits(bits[0]) + 21; - if (i >= expt) { - i = expt - 1; - expt = 0; - } - else - expt -= i; - if (i < 32) { - bits[1] = bits[0] >> (32 - i); - bits[0] = bits[0] << i & (ULong)0xffffffffL; - } - else { - bits[1] = bits[0] << (i - 32); - bits[0] = 0; - } - } - else { - L[2] = L[3] = 0; - break; - } - L[2+_1] = bits[0]; - L[2+_0] = (bits[1] & 0xfffff) | (expt << 20); - break; - - case STRTOG_Denormal: - if (bits[3]) - goto nearly_normal; - if (bits[2]) - goto partly_normal; - if (bits[1] & 0xffe00000) - goto hardly_normal; - /* completely denormal */ - L[2] = L[3] = 0; - L[_1] = bits[0]; - L[_0] = bits[1]; - break; - - nearly_normal: - i = hi0bits(bits[3]) - 11; /* i >= 12 */ - j = 32 - i; - L[_0] = ((bits[3] << i | bits[2] >> j) & 0xfffff) - | ((65 - i) << 20); - L[_1] = (bits[2] << i | bits[1] >> j) & 0xffffffffL; - L[2+_0] = bits[1] & (((ULong)1L << j) - 1); - L[2+_1] = bits[0]; - break; - - partly_normal: - i = hi0bits(bits[2]) - 11; - if (i < 0) { - j = -i; - i += 32; - L[_0] = (bits[2] >> j & 0xfffff) | ((33 + j) << 20); - L[_1] = (bits[2] << i | bits[1] >> j) & 0xffffffffL; - L[2+_0] = bits[1] & (((ULong)1L << j) - 1); - L[2+_1] = bits[0]; - break; - } - if (i == 0) { - L[_0] = (bits[2] & 0xfffff) | (33 << 20); - L[_1] = bits[1]; - L[2+_0] = 0; - L[2+_1] = bits[0]; - break; - } - j = 32 - i; - L[_0] = (((bits[2] << i) | (bits[1] >> j)) & 0xfffff) - | ((j + 1) << 20); - L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL; - L[2+_0] = 0; - L[2+_1] = bits[0] & ((1L << j) - 1); - break; - - hardly_normal: - j = 11 - hi0bits(bits[1]); - i = 32 - j; - L[_0] = (bits[1] >> j & 0xfffff) | ((j + 1) << 20); - L[_1] = (bits[1] << i | bits[0] >> j) & 0xffffffffL; - L[2+_0] = 0; - L[2+_1] = bits[0] & (((ULong)1L << j) - 1); - break; - - case STRTOG_Infinite: - L[_0] = L[2+_0] = 0x7ff00000; - L[_1] = L[2+_1] = 0; - break; - - case STRTOG_NaN: - L[0] = L[2] = d_QNAN0; - L[1] = L[3] = d_QNAN1; - break; - - case STRTOG_NaNbits: - L[_1] = (bits[1] >> 21 | bits[2] << 11) & (ULong)0xffffffffL; - L[_0] = bits[2] >> 21 | bits[3] << 11 - | (ULong)0x7ff00000L; - L[2+_1] = bits[0]; - L[2+_0] = bits[1] | (ULong)0x7ff00000L; - } - if (k & STRTOG_Neg) { - L[_0] |= 0x80000000L; - L[2+_0] |= 0x80000000L; - } - } - - int -#ifdef KR_headers -strtordd(s, sp, rounding, dd) CONST char *s; char **sp; int rounding; double *dd; -#else -strtordd(CONST char *s, char **sp, int rounding, double *dd) -#endif -{ -#ifdef Sudden_Underflow - static CONST FPI fpi0 = { 106, 1-1023, 2046-1023-106+1, 1, 1 }; -#else - static CONST FPI fpi0 = { 106, 1-1023-53+1, 2046-1023-106+1, 1, 0 }; -#endif - CONST FPI *fpi; - FPI fpi1; - ULong bits[4]; - Long expt; - int k; - - fpi = &fpi0; - if (rounding != FPI_Round_near) { - fpi1 = fpi0; - fpi1.rounding = rounding; - fpi = &fpi1; - } - k = strtodg(s, sp, fpi, &expt, bits); - if (k == STRTOG_NoMemory) - return k; - ULtodd((ULong*)dd, bits, expt, k); - return k; - } diff --git a/lib/libc/gdtoa/strtorf.c b/lib/libc/gdtoa/strtorf.c deleted file mode 100644 index 5cf3c2dc4..000000000 --- a/lib/libc/gdtoa/strtorf.c +++ /dev/null @@ -1,94 +0,0 @@ -/* $NetBSD: strtorf.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - void -#ifdef KR_headers -ULtof(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k; -#else -ULtof(ULong *L, ULong *bits, Long expt, int k) -#endif -{ - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - *L = 0; - break; - - case STRTOG_Normal: - case STRTOG_NaNbits: - L[0] = (bits[0] & 0x7fffff) | ((expt + 0x7f + 23) << 23); - break; - - case STRTOG_Denormal: - L[0] = bits[0]; - break; - - case STRTOG_Infinite: - L[0] = 0x7f800000; - break; - - case STRTOG_NaN: - L[0] = f_QNAN; - } - if (k & STRTOG_Neg) - L[0] |= 0x80000000L; - } - - int -#ifdef KR_headers -strtorf(s, sp, rounding, f) CONST char *s; char **sp; int rounding; float *f; -#else -strtorf(CONST char *s, char **sp, int rounding, float *f) -#endif -{ - static CONST FPI fpi0 = { 24, 1-127-24+1, 254-127-24+1, 1, SI }; - CONST FPI *fpi; - FPI fpi1; - ULong bits[1]; - Long expt; - int k; - - fpi = &fpi0; - if (rounding != FPI_Round_near) { - fpi1 = fpi0; - fpi1.rounding = rounding; - fpi = &fpi1; - } - k = strtodg(s, sp, fpi, &expt, bits); - if (k == STRTOG_NoMemory) - return k; - ULtof((ULong*)f, bits, expt, k); - return k; - } diff --git a/lib/libc/gdtoa/strtorx.c b/lib/libc/gdtoa/strtorx.c deleted file mode 100644 index d0305a2ac..000000000 --- a/lib/libc/gdtoa/strtorx.c +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: strtorx.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#define _4 4 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 4 -#define _1 3 -#define _2 2 -#define _3 1 -#define _4 0 -#endif - - void -#ifdef KR_headers -ULtox(L, bits, expt, k) UShort *L; ULong *bits; Long expt; int k; -#else -ULtox(UShort *L, ULong *bits, Long expt, int k) -#endif -{ - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = L[2] = L[3] = L[4] = 0; - break; - - case STRTOG_Denormal: - L[_0] = 0; - goto normal_bits; - - case STRTOG_Normal: - case STRTOG_NaNbits: - L[_0] = expt + 0x3fff + 63; - normal_bits: - L[_4] = (UShort)bits[0]; - L[_3] = (UShort)(bits[0] >> 16); - L[_2] = (UShort)bits[1]; - L[_1] = (UShort)(bits[1] >> 16); - break; - - case STRTOG_Infinite: - L[_0] = 0x7fff; - L[_1] = 0x8000; - L[_2] = L[_3] = L[_4] = 0; - break; - - case STRTOG_NaN: - L[0] = ldus_QNAN0; - L[1] = ldus_QNAN1; - L[2] = ldus_QNAN2; - L[3] = ldus_QNAN3; - L[4] = ldus_QNAN4; - } - if (k & STRTOG_Neg) - L[_0] |= 0x8000; - } - - int -#ifdef KR_headers -strtorx(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L; -#else -strtorx(CONST char *s, char **sp, int rounding, void *L) -#endif -{ - static CONST FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; - CONST FPI *fpi; - FPI fpi1; - ULong bits[2]; - Long expt; - int k; - - fpi = &fpi0; - if (rounding != FPI_Round_near) { - fpi1 = fpi0; - fpi1.rounding = rounding; - fpi = &fpi1; - } - k = strtodg(s, sp, fpi, &expt, bits); - if (k == STRTOG_NoMemory) - return k; - ULtox((UShort*)L, bits, expt, k); - return k; - } diff --git a/lib/libc/gdtoa/strtorxL.c b/lib/libc/gdtoa/strtorxL.c deleted file mode 100644 index a8f7b403f..000000000 --- a/lib/libc/gdtoa/strtorxL.c +++ /dev/null @@ -1,113 +0,0 @@ -/* $NetBSD: strtorxL.c,v 1.4 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2000 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 2 -#define _1 1 -#define _2 0 -#endif - - void -#ifdef KR_headers -ULtoxL(L, bits, expt, k) ULong *L; ULong *bits; Long expt; int k; -#else -ULtoxL(ULong *L, ULong *bits, Long expt, int k) -#endif -{ - switch(k & STRTOG_Retmask) { - case STRTOG_NoNumber: - case STRTOG_Zero: - L[0] = L[1] = L[2] = 0; - break; - - case STRTOG_Normal: - case STRTOG_Denormal: - case STRTOG_NaNbits: - L[_0] = (expt + 0x3fff + 63) << 16; - L[_1] = bits[1]; - L[_2] = bits[0]; - break; - - case STRTOG_Infinite: - L[_0] = 0x7fff << 16; - L[_1] = 0x80000000; - L[_2] = 0; - break; - - case STRTOG_NaN: - L[0] = ld_QNAN0; - L[1] = ld_QNAN1; - L[2] = ld_QNAN2; - } - if (k & STRTOG_Neg) - L[_0] |= 0x80000000L; - } - - int -#ifdef KR_headers -strtorxL(s, sp, rounding, L) CONST char *s; char **sp; int rounding; void *L; -#else -strtorxL(CONST char *s, char **sp, int rounding, void *L) -#endif -{ - static CONST FPI fpi0 = { 64, 1-16383-64+1, 32766 - 16383 - 64 + 1, 1, SI }; - CONST FPI *fpi; - FPI fpi1; - ULong bits[2]; - Long expt; - int k; - - fpi = &fpi0; - if (rounding != FPI_Round_near) { - fpi1 = fpi0; - fpi1.rounding = rounding; - fpi = &fpi1; - } - k = strtodg(s, sp, fpi, &expt, bits); - if (k == STRTOG_NoMemory) - return k; - ULtoxL((ULong*)L, bits, expt, k); - return k; - } diff --git a/lib/libc/gdtoa/sum.c b/lib/libc/gdtoa/sum.c deleted file mode 100644 index 6a987a1a4..000000000 --- a/lib/libc/gdtoa/sum.c +++ /dev/null @@ -1,104 +0,0 @@ -/* $NetBSD: sum.c,v 1.2 2008/03/21 23:13:48 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - Bigint * -#ifdef KR_headers -sum(a, b) Bigint *a; Bigint *b; -#else -sum(Bigint *a, Bigint *b) -#endif -{ - Bigint *c; - ULong carry, *xc, *xa, *xb, *xe, y; -#ifdef Pack_32 - ULong z; -#endif - - if (a->wds < b->wds) { - c = b; b = a; a = c; - } - c = Balloc(a->k); - if (c == NULL) - return NULL; - c->wds = a->wds; - carry = 0; - xa = a->x; - xb = b->x; - xc = c->x; - xe = xc + b->wds; -#ifdef Pack_32 - do { - y = (*xa & 0xffff) + (*xb & 0xffff) + carry; - carry = (y & 0x10000) >> 16; - z = (*xa++ >> 16) + (*xb++ >> 16) + carry; - carry = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } - while(xc < xe); - xe += a->wds - b->wds; - while(xc < xe) { - y = (*xa & 0xffff) + carry; - carry = (y & 0x10000) >> 16; - z = (*xa++ >> 16) + carry; - carry = (z & 0x10000) >> 16; - Storeinc(xc, z, y); - } -#else - do { - y = *xa++ + *xb++ + carry; - carry = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } - while(xc < xe); - xe += a->wds - b->wds; - while(xc < xe) { - y = *xa++ + carry; - carry = (y & 0x10000) >> 16; - *xc++ = y & 0xffff; - } -#endif - if (carry) { - if (c->wds == c->maxwds) { - b = Balloc(c->k + 1); - if (b == NULL) - return NULL; - Bcopy(b, c); - Bfree(c); - c = b; - } - c->x[c->wds++] = 1; - } - return c; - } diff --git a/lib/libc/gdtoa/test/Q.ou0 b/lib/libc/gdtoa/test/Q.ou0 deleted file mode 100644 index 66c7e9b0b..000000000 --- a/lib/libc/gdtoa/test/Q.ou0 +++ /dev/null @@ -1,1180 +0,0 @@ - -Input: 1.23 - -strtoQ consumes 4 bytes and returns 17 -with bits = #3fff3ae1 47ae147a e147ae14 7ae147ae -g_Qfmt(0) gives 4 bytes: "1.23" - -strtoIQ returns 17, consuming 4 bytes. -fI[0] = #3fff3ae1 47ae147a e147ae14 7ae147ae -fI[1] = #3fff3ae1 47ae147a e147ae14 7ae147af -fI[0] == strtod - - -Input: 1.23e+20 - -strtoQ consumes 8 bytes and returns 1 -with bits = #4041aabd f2145b43 0 0 -g_Qfmt(0) gives 8 bytes: "1.23e+20" - -strtoIQ returns 1, consuming 8 bytes. -fI[0] == fI[1] = #4041aabd f2145b43 0 0 - - -Input: 1.23e-20 - -strtoQ consumes 8 bytes and returns 17 -with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841 -g_Qfmt(0) gives 8 bytes: "1.23e-20" - -strtoIQ returns 17, consuming 8 bytes. -fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841 -fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842 -fI[0] == strtod - - -Input: 1.23456789 - -strtoQ consumes 10 bytes and returns 17 -with bits = #3fff3c0c a4283de1 b7eb6945 1304948f -g_Qfmt(0) gives 10 bytes: "1.23456789" - -strtoIQ returns 17, consuming 10 bytes. -fI[0] = #3fff3c0c a4283de1 b7eb6945 1304948f -fI[1] = #3fff3c0c a4283de1 b7eb6945 13049490 -fI[0] == strtod - - -Input: 1.23456589e+20 - -strtoQ consumes 14 bytes and returns 1 -with bits = #4041ac53 7a660b99 74000000 0 -g_Qfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIQ returns 1, consuming 14 bytes. -fI[0] == fI[1] = #4041ac53 7a660b99 74000000 0 - - -Input: 1.23e+30 - -strtoQ consumes 8 bytes and returns 1 -with bits = #4062f0cb 4e8fb79 4945600 0 -g_Qfmt(0) gives 8 bytes: "1.23e+30" - -strtoIQ returns 1, consuming 8 bytes. -fI[0] == fI[1] = #4062f0cb 4e8fb79 4945600 0 - - -Input: 1.23e-30 - -strtoQ consumes 8 bytes and returns 17 -with bits = #3f9b8f28 66f5010a a9d63f9e d7e8ba14 -g_Qfmt(0) gives 8 bytes: "1.23e-30" - -strtoIQ returns 17, consuming 8 bytes. -fI[0] = #3f9b8f28 66f5010a a9d63f9e d7e8ba14 -fI[1] = #3f9b8f28 66f5010a a9d63f9e d7e8ba15 -fI[0] == strtod - - -Input: 1.23456789e-20 - -strtoQ consumes 14 bytes and returns 33 -with bits = #3fbcd268 1471e7ad a6a4a029 d86c1fa2 -g_Qfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIQ returns 33, consuming 14 bytes. -fI[0] = #3fbcd268 1471e7ad a6a4a029 d86c1fa1 -fI[1] = #3fbcd268 1471e7ad a6a4a029 d86c1fa2 -fI[1] == strtod - - -Input: 1.23456789e-30 - -strtoQ consumes 14 bytes and returns 17 -with bits = #3f9b90a3 e33bbd99 51f85855 5a6b19d4 -g_Qfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIQ returns 17, consuming 14 bytes. -fI[0] = #3f9b90a3 e33bbd99 51f85855 5a6b19d4 -fI[1] = #3f9b90a3 e33bbd99 51f85855 5a6b19d5 -fI[0] == strtod - - -Input: 1.234567890123456789 - -strtoQ consumes 20 bytes and returns 17 -with bits = #3fff3c0c a428c59f b71a4194 68dd175b -g_Qfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIQ returns 17, consuming 20 bytes. -fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b -fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c -fI[0] == strtod - - -Input: 1.23456789012345678901234567890123456789 - -strtoQ consumes 40 bytes and returns 17 -with bits = #3fff3c0c a428c59f b71a7be1 6b6b6d5b -g_Qfmt(0) gives 36 bytes: "1.2345678901234567890123456789012346" - -strtoIQ returns 17, consuming 40 bytes. -fI[0] = #3fff3c0c a428c59f b71a7be1 6b6b6d5b -fI[1] = #3fff3c0c a428c59f b71a7be1 6b6b6d5c -fI[0] == strtod - - -Input: 1.23e306 - -strtoQ consumes 8 bytes and returns 33 -with bits = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55 -g_Qfmt(0) gives 9 bytes: "1.23e+306" - -strtoIQ returns 33, consuming 8 bytes. -fI[0] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b54 -fI[1] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55 -fI[1] == strtod - - -Input: 1.23e-306 - -strtoQ consumes 9 bytes and returns 17 -with bits = #3c06ba3b 85da396e 7e496ab7 d233c3dd -g_Qfmt(0) gives 9 bytes: "1.23e-306" - -strtoIQ returns 17, consuming 9 bytes. -fI[0] = #3c06ba3b 85da396e 7e496ab7 d233c3dd -fI[1] = #3c06ba3b 85da396e 7e496ab7 d233c3de -fI[0] == strtod - - -Input: 1.23e-320 - -strtoQ consumes 9 bytes and returns 33 -with bits = #3bd83731 86e30898 7e33b2e8 355f847b -g_Qfmt(0) gives 9 bytes: "1.23e-320" - -strtoIQ returns 33, consuming 9 bytes. -fI[0] = #3bd83731 86e30898 7e33b2e8 355f847a -fI[1] = #3bd83731 86e30898 7e33b2e8 355f847b -fI[1] == strtod - - -Input: 1.23e-20 - -strtoQ consumes 8 bytes and returns 17 -with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841 -g_Qfmt(0) gives 8 bytes: "1.23e-20" - -strtoIQ returns 17, consuming 8 bytes. -fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841 -fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842 -fI[0] == strtod - - -Input: 1.23456789e307 - -strtoQ consumes 14 bytes and returns 17 -with bits = #43fb194b 14bdaecd bcea468c 902464cf -g_Qfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIQ returns 17, consuming 14 bytes. -fI[0] = #43fb194b 14bdaecd bcea468c 902464cf -fI[1] = #43fb194b 14bdaecd bcea468c 902464d0 -fI[0] == strtod - - -Input: 1.23456589e-307 - -strtoQ consumes 15 bytes and returns 17 -with bits = #3c036319 6bb9845f a6d234e3 39163574 -g_Qfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIQ returns 17, consuming 15 bytes. -fI[0] = #3c036319 6bb9845f a6d234e3 39163574 -fI[1] = #3c036319 6bb9845f a6d234e3 39163575 -fI[0] == strtod - - -Input: 1.234567890123456789 - -strtoQ consumes 20 bytes and returns 17 -with bits = #3fff3c0c a428c59f b71a4194 68dd175b -g_Qfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIQ returns 17, consuming 20 bytes. -fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b -fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c -fI[0] == strtod - - -Input: 1.234567890123456789e301 - -strtoQ consumes 24 bytes and returns 33 -with bits = #43e726f5 175f5641 3017ea80 763990ef -g_Qfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIQ returns 33, consuming 24 bytes. -fI[0] = #43e726f5 175f5641 3017ea80 763990ee -fI[1] = #43e726f5 175f5641 3017ea80 763990ef -fI[1] == strtod - - -Input: 1.234567890123456789e-301 - -strtoQ consumes 25 bytes and returns 17 -with bits = #3c1752a6 4e34ba0d 35b19b04 3222fce5 -g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIQ returns 17, consuming 25 bytes. -fI[0] = #3c1752a6 4e34ba0d 35b19b04 3222fce5 -fI[1] = #3c1752a6 4e34ba0d 35b19b04 3222fce6 -fI[0] == strtod - - -Input: 1.234567890123456789e-321 - -strtoQ consumes 25 bytes and returns 17 -with bits = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de -g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-321" - -strtoIQ returns 17, consuming 25 bytes. -fI[0] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de -fI[1] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7df -fI[0] == strtod - - -Input: 1e23 - -strtoQ consumes 4 bytes and returns 1 -with bits = #404b52d0 2c7e14af 68000000 0 -g_Qfmt(0) gives 5 bytes: "1e+23" - -strtoIQ returns 1, consuming 4 bytes. -fI[0] == fI[1] = #404b52d0 2c7e14af 68000000 0 - - -Input: 1e310 - -strtoQ consumes 5 bytes and returns 33 -with bits = #4404bd03 c8140697 9e9ff00e fefd4cbd -g_Qfmt(0) gives 6 bytes: "1e+310" - -strtoIQ returns 33, consuming 5 bytes. -fI[0] = #4404bd03 c8140697 9e9ff00e fefd4cbc -fI[1] = #4404bd03 c8140697 9e9ff00e fefd4cbd -fI[1] == strtod - - -Input: 9.0259718793241475e-277 - -strtoQ consumes 23 bytes and returns 17 -with bits = #3c69ffff ffffffff f9ed5779 ac118fe1 -g_Qfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIQ returns 17, consuming 23 bytes. -fI[0] = #3c69ffff ffffffff f9ed5779 ac118fe1 -fI[1] = #3c69ffff ffffffff f9ed5779 ac118fe2 -fI[0] == strtod - - -Input: 9.025971879324147880346310405869e-277 - -strtoQ consumes 37 bytes and returns 33 -with bits = #3c6a0000 0 0 9a -g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277" - -strtoIQ returns 33, consuming 37 bytes. -fI[0] = #3c6a0000 0 0 99 -fI[1] = #3c6a0000 0 0 9a -fI[1] == strtod - - -Input: 9.025971879324147880346310405868e-277 - -strtoQ consumes 37 bytes and returns 17 -with bits = #3c69ffff ffffffff ffffffff fffffcb5 -g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405868e-277" - -strtoIQ returns 17, consuming 37 bytes. -fI[0] = #3c69ffff ffffffff ffffffff fffffcb5 -fI[1] = #3c69ffff ffffffff ffffffff fffffcb6 -fI[0] == strtod - - -Input: 2.2250738585072014e-308 - -strtoQ consumes 23 bytes and returns 33 -with bits = #3c010000 0 8c304c cf867de0 -g_Qfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIQ returns 33, consuming 23 bytes. -fI[0] = #3c010000 0 8c304c cf867ddf -fI[1] = #3c010000 0 8c304c cf867de0 -fI[1] == strtod - - -Input: 2.2250738585072013e-308 - -strtoQ consumes 23 bytes and returns 33 -with bits = #3c00ffff ffffffff fa9e4c4f 4c1e8a10 -g_Qfmt(0) gives 23 bytes: "2.2250738585072013e-308" - -strtoIQ returns 33, consuming 23 bytes. -fI[0] = #3c00ffff ffffffff fa9e4c4f 4c1e8a0f -fI[1] = #3c00ffff ffffffff fa9e4c4f 4c1e8a10 -fI[1] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff1999 99999999 99999999 99999999 -g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -fI[0] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff1999 99999999 99999999 99999999 -g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -fI[1] = #bfff1999 99999999 99999999 99999999 -fI[1] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff3333 33333333 33333333 33333333 -g_Qfmt(0) gives 3 bytes: "1.2" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -fI[1] = #3fff3333 33333333 33333333 33333334 -fI[0] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff3333 33333333 33333333 33333333 -g_Qfmt(0) gives 4 bytes: "-1.2" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -fI[1] = #bfff3333 33333333 33333333 33333333 -fI[1] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff4ccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -fI[0] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff4ccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -fI[1] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff6666 66666666 66666666 66666666 -g_Qfmt(0) gives 3 bytes: "1.4" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -fI[1] = #3fff6666 66666666 66666666 66666667 -fI[0] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff6666 66666666 66666666 66666666 -g_Qfmt(0) gives 4 bytes: "-1.4" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -fI[1] = #bfff6666 66666666 66666666 66666666 -fI[1] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff9999 99999999 99999999 99999999 -g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -fI[0] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff9999 99999999 99999999 99999999 -g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -fI[1] = #bfff9999 99999999 99999999 99999999 -fI[1] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffb333 33333333 33333333 33333333 -g_Qfmt(0) gives 3 bytes: "1.7" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -fI[1] = #3fffb333 33333333 33333333 33333334 -fI[0] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffb333 33333333 33333333 33333333 -g_Qfmt(0) gives 4 bytes: "-1.7" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -fI[1] = #bfffb333 33333333 33333333 33333333 -fI[1] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffcccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -fI[0] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffcccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -fI[1] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffe666 66666666 66666666 66666666 -g_Qfmt(0) gives 3 bytes: "1.9" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -fI[1] = #3fffe666 66666666 66666666 66666667 -fI[0] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffe666 66666666 66666666 66666666 -g_Qfmt(0) gives 4 bytes: "-1.9" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -fI[1] = #bfffe666 66666666 66666666 66666666 -fI[1] == strtod - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff1999 99999999 99999999 9999999a -g_Qfmt(0) gives 3 bytes: "1.1" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -fI[1] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff1999 99999999 99999999 9999999a -g_Qfmt(0) gives 4 bytes: "-1.1" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -fI[1] = #bfff1999 99999999 99999999 99999999 -fI[0] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff3333 33333333 33333333 33333333 -g_Qfmt(0) gives 3 bytes: "1.2" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -fI[1] = #3fff3333 33333333 33333333 33333334 -fI[0] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff3333 33333333 33333333 33333333 -g_Qfmt(0) gives 4 bytes: "-1.2" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -fI[1] = #bfff3333 33333333 33333333 33333333 -fI[1] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff4ccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 3 bytes: "1.3" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -fI[1] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff4ccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 4 bytes: "-1.3" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -fI[0] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff6666 66666666 66666666 66666666 -g_Qfmt(0) gives 3 bytes: "1.4" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -fI[1] = #3fff6666 66666666 66666666 66666667 -fI[0] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff6666 66666666 66666666 66666666 -g_Qfmt(0) gives 4 bytes: "-1.4" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -fI[1] = #bfff6666 66666666 66666666 66666666 -fI[1] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff9999 99999999 99999999 9999999a -g_Qfmt(0) gives 3 bytes: "1.6" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -fI[1] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff9999 99999999 99999999 9999999a -g_Qfmt(0) gives 4 bytes: "-1.6" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -fI[1] = #bfff9999 99999999 99999999 99999999 -fI[0] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffb333 33333333 33333333 33333333 -g_Qfmt(0) gives 3 bytes: "1.7" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -fI[1] = #3fffb333 33333333 33333333 33333334 -fI[0] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffb333 33333333 33333333 33333333 -g_Qfmt(0) gives 4 bytes: "-1.7" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -fI[1] = #bfffb333 33333333 33333333 33333333 -fI[1] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffcccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 3 bytes: "1.8" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -fI[1] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffcccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 4 bytes: "-1.8" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -fI[0] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffe666 66666666 66666666 66666666 -g_Qfmt(0) gives 3 bytes: "1.9" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -fI[1] = #3fffe666 66666666 66666666 66666667 -fI[0] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffe666 66666666 66666666 66666666 -g_Qfmt(0) gives 4 bytes: "-1.9" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -fI[1] = #bfffe666 66666666 66666666 66666666 -fI[1] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff1999 99999999 99999999 9999999a -g_Qfmt(0) gives 3 bytes: "1.1" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -fI[1] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff1999 99999999 99999999 99999999 -g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -fI[1] = #bfff1999 99999999 99999999 99999999 -fI[1] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff3333 33333333 33333333 33333334 -g_Qfmt(0) gives 36 bytes: "1.2000000000000000000000000000000002" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -fI[1] = #3fff3333 33333333 33333333 33333334 -fI[1] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff3333 33333333 33333333 33333333 -g_Qfmt(0) gives 4 bytes: "-1.2" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -fI[1] = #bfff3333 33333333 33333333 33333333 -fI[1] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff4ccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 3 bytes: "1.3" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -fI[1] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff4ccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -fI[1] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff6666 66666666 66666666 66666667 -g_Qfmt(0) gives 36 bytes: "1.4000000000000000000000000000000001" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -fI[1] = #3fff6666 66666666 66666666 66666667 -fI[1] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff6666 66666666 66666666 66666666 -g_Qfmt(0) gives 4 bytes: "-1.4" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -fI[1] = #bfff6666 66666666 66666666 66666666 -fI[1] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff9999 99999999 99999999 9999999a -g_Qfmt(0) gives 3 bytes: "1.6" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -fI[1] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff9999 99999999 99999999 99999999 -g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -fI[1] = #bfff9999 99999999 99999999 99999999 -fI[1] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffb333 33333333 33333333 33333334 -g_Qfmt(0) gives 36 bytes: "1.7000000000000000000000000000000002" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -fI[1] = #3fffb333 33333333 33333333 33333334 -fI[1] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffb333 33333333 33333333 33333333 -g_Qfmt(0) gives 4 bytes: "-1.7" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -fI[1] = #bfffb333 33333333 33333333 33333333 -fI[1] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffcccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 3 bytes: "1.8" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -fI[1] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffcccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -fI[1] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffe666 66666666 66666666 66666667 -g_Qfmt(0) gives 36 bytes: "1.9000000000000000000000000000000001" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -fI[1] = #3fffe666 66666666 66666666 66666667 -fI[1] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffe666 66666666 66666666 66666666 -g_Qfmt(0) gives 4 bytes: "-1.9" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -fI[1] = #bfffe666 66666666 66666666 66666666 -fI[1] == strtod - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff1999 99999999 99999999 99999999 -g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -fI[0] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff1999 99999999 99999999 9999999a -g_Qfmt(0) gives 4 bytes: "-1.1" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -fI[1] = #bfff1999 99999999 99999999 99999999 -fI[0] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff3333 33333333 33333333 33333333 -g_Qfmt(0) gives 3 bytes: "1.2" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -fI[1] = #3fff3333 33333333 33333333 33333334 -fI[0] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff3333 33333333 33333333 33333334 -g_Qfmt(0) gives 37 bytes: "-1.2000000000000000000000000000000002" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -fI[1] = #bfff3333 33333333 33333333 33333333 -fI[0] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff4ccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -fI[0] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff4ccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 4 bytes: "-1.3" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -fI[0] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff6666 66666666 66666666 66666666 -g_Qfmt(0) gives 3 bytes: "1.4" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -fI[1] = #3fff6666 66666666 66666666 66666667 -fI[0] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff6666 66666666 66666666 66666667 -g_Qfmt(0) gives 37 bytes: "-1.4000000000000000000000000000000001" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -fI[1] = #bfff6666 66666666 66666666 66666666 -fI[0] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff9999 99999999 99999999 99999999 -g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -fI[0] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff9999 99999999 99999999 9999999a -g_Qfmt(0) gives 4 bytes: "-1.6" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -fI[1] = #bfff9999 99999999 99999999 99999999 -fI[0] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffb333 33333333 33333333 33333333 -g_Qfmt(0) gives 3 bytes: "1.7" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -fI[1] = #3fffb333 33333333 33333333 33333334 -fI[0] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffb333 33333333 33333333 33333334 -g_Qfmt(0) gives 37 bytes: "-1.7000000000000000000000000000000002" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -fI[1] = #bfffb333 33333333 33333333 33333333 -fI[0] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffcccc cccccccc cccccccc cccccccc -g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -fI[0] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffcccc cccccccc cccccccc cccccccd -g_Qfmt(0) gives 4 bytes: "-1.8" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -fI[0] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffe666 66666666 66666666 66666666 -g_Qfmt(0) gives 3 bytes: "1.9" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -fI[1] = #3fffe666 66666666 66666666 66666667 -fI[0] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffe666 66666666 66666666 66666667 -g_Qfmt(0) gives 37 bytes: "-1.9000000000000000000000000000000001" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -fI[1] = #bfffe666 66666666 66666666 66666666 -fI[0] == strtod - diff --git a/lib/libc/gdtoa/test/Q.ou1 b/lib/libc/gdtoa/test/Q.ou1 deleted file mode 100644 index cb2a23f61..000000000 --- a/lib/libc/gdtoa/test/Q.ou1 +++ /dev/null @@ -1,1468 +0,0 @@ - -Input: 1.23 - -strtoQ consumes 4 bytes and returns 17 -with bits = #3fff3ae1 47ae147a e147ae14 7ae147ae -printf("%.35Lg") gives 1.23 -g_Qfmt(0) gives 4 bytes: "1.23" - -strtoIQ returns 17, consuming 4 bytes. -fI[0] = #3fff3ae1 47ae147a e147ae14 7ae147ae -= 1.23 -fI[1] = #3fff3ae1 47ae147a e147ae14 7ae147af -= 1.2300000000000000000000000000000002 -fI[0] == strtod - - -Input: 1.23e+20 - -strtoQ consumes 8 bytes and returns 1 -with bits = #4041aabd f2145b43 0 0 -printf("%.35Lg") gives 123000000000000000000 -g_Qfmt(0) gives 8 bytes: "1.23e+20" - -strtoIQ returns 1, consuming 8 bytes. -fI[0] == fI[1] = #4041aabd f2145b43 0 0 -= 123000000000000000000 - - -Input: 1.23e-20 - -strtoQ consumes 8 bytes and returns 17 -with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841 -printf("%.35Lg") gives 1.2299999999999999999999999999999999e-20 -g_Qfmt(0) gives 8 bytes: "1.23e-20" - -strtoIQ returns 17, consuming 8 bytes. -fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841 -= 1.2299999999999999999999999999999999e-20 -fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842 -= 1.2300000000000000000000000000000001e-20 -fI[0] == strtod - - -Input: 1.23456789 - -strtoQ consumes 10 bytes and returns 17 -with bits = #3fff3c0c a4283de1 b7eb6945 1304948f -printf("%.35Lg") gives 1.2345678899999999999999999999999999 -g_Qfmt(0) gives 10 bytes: "1.23456789" - -strtoIQ returns 17, consuming 10 bytes. -fI[0] = #3fff3c0c a4283de1 b7eb6945 1304948f -= 1.2345678899999999999999999999999999 -fI[1] = #3fff3c0c a4283de1 b7eb6945 13049490 -= 1.2345678900000000000000000000000001 -fI[0] == strtod - - -Input: 1.23456589e+20 - -strtoQ consumes 14 bytes and returns 1 -with bits = #4041ac53 7a660b99 74000000 0 -printf("%.35Lg") gives 123456589000000000000 -g_Qfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIQ returns 1, consuming 14 bytes. -fI[0] == fI[1] = #4041ac53 7a660b99 74000000 0 -= 123456589000000000000 - - -Input: 1.23e+30 - -strtoQ consumes 8 bytes and returns 1 -with bits = #4062f0cb 4e8fb79 4945600 0 -printf("%.35Lg") gives 1230000000000000000000000000000 -g_Qfmt(0) gives 8 bytes: "1.23e+30" - -strtoIQ returns 1, consuming 8 bytes. -fI[0] == fI[1] = #4062f0cb 4e8fb79 4945600 0 -= 1230000000000000000000000000000 - - -Input: 1.23e-30 - -strtoQ consumes 8 bytes and returns 17 -with bits = #3f9b8f28 66f5010a a9d63f9e d7e8ba14 -printf("%.35Lg") gives 1.2299999999999999999999999999999999e-30 -g_Qfmt(0) gives 8 bytes: "1.23e-30" - -strtoIQ returns 17, consuming 8 bytes. -fI[0] = #3f9b8f28 66f5010a a9d63f9e d7e8ba14 -= 1.2299999999999999999999999999999999e-30 -fI[1] = #3f9b8f28 66f5010a a9d63f9e d7e8ba15 -= 1.2300000000000000000000000000000001e-30 -fI[0] == strtod - - -Input: 1.23456789e-20 - -strtoQ consumes 14 bytes and returns 33 -with bits = #3fbcd268 1471e7ad a6a4a029 d86c1fa2 -printf("%.35Lg") gives 1.2345678900000000000000000000000001e-20 -g_Qfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIQ returns 33, consuming 14 bytes. -fI[0] = #3fbcd268 1471e7ad a6a4a029 d86c1fa1 -= 1.2345678899999999999999999999999999e-20 -fI[1] = #3fbcd268 1471e7ad a6a4a029 d86c1fa2 -= 1.2345678900000000000000000000000001e-20 -fI[1] == strtod - - -Input: 1.23456789e-30 - -strtoQ consumes 14 bytes and returns 17 -with bits = #3f9b90a3 e33bbd99 51f85855 5a6b19d4 -printf("%.35Lg") gives 1.23456789e-30 -g_Qfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIQ returns 17, consuming 14 bytes. -fI[0] = #3f9b90a3 e33bbd99 51f85855 5a6b19d4 -= 1.23456789e-30 -fI[1] = #3f9b90a3 e33bbd99 51f85855 5a6b19d5 -= 1.2345678900000000000000000000000001e-30 -fI[0] == strtod - - -Input: 1.234567890123456789 - -strtoQ consumes 20 bytes and returns 17 -with bits = #3fff3c0c a428c59f b71a4194 68dd175b -printf("%.35Lg") gives 1.234567890123456789 -g_Qfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIQ returns 17, consuming 20 bytes. -fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b -= 1.234567890123456789 -fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c -= 1.2345678901234567890000000000000002 -fI[0] == strtod - - -Input: 1.23456789012345678901234567890123456789 - -strtoQ consumes 40 bytes and returns 17 -with bits = #3fff3c0c a428c59f b71a7be1 6b6b6d5b -printf("%.35Lg") gives 1.2345678901234567890123456789012346 -g_Qfmt(0) gives 36 bytes: "1.2345678901234567890123456789012346" - -strtoIQ returns 17, consuming 40 bytes. -fI[0] = #3fff3c0c a428c59f b71a7be1 6b6b6d5b -= 1.2345678901234567890123456789012346 -fI[1] = #3fff3c0c a428c59f b71a7be1 6b6b6d5c -= 1.2345678901234567890123456789012347 -fI[0] == strtod - - -Input: 1.23e306 - -strtoQ consumes 8 bytes and returns 33 -with bits = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55 -printf("%.35Lg") gives 1.23e+306 -g_Qfmt(0) gives 9 bytes: "1.23e+306" - -strtoIQ returns 33, consuming 8 bytes. -fI[0] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b54 -= 1.2299999999999999999999999999999999e+306 -fI[1] = #43f7c067 6cd1c61f 4daac5f1 e9fa3b55 -= 1.23e+306 -fI[1] == strtod - - -Input: 1.23e-306 - -strtoQ consumes 9 bytes and returns 17 -with bits = #3c06ba3b 85da396e 7e496ab7 d233c3dd -printf("%.35Lg") gives 1.23e-306 -g_Qfmt(0) gives 9 bytes: "1.23e-306" - -strtoIQ returns 17, consuming 9 bytes. -fI[0] = #3c06ba3b 85da396e 7e496ab7 d233c3dd -= 1.23e-306 -fI[1] = #3c06ba3b 85da396e 7e496ab7 d233c3de -= 1.2300000000000000000000000000000001e-306 -fI[0] == strtod - - -Input: 1.23e-320 - -strtoQ consumes 9 bytes and returns 33 -with bits = #3bd83731 86e30898 7e33b2e8 355f847b -printf("%.35Lg") gives 1.2300000000000000000000000000000001e-320 -g_Qfmt(0) gives 9 bytes: "1.23e-320" - -strtoIQ returns 33, consuming 9 bytes. -fI[0] = #3bd83731 86e30898 7e33b2e8 355f847a -= 1.2299999999999999999999999999999999e-320 -fI[1] = #3bd83731 86e30898 7e33b2e8 355f847b -= 1.2300000000000000000000000000000001e-320 -fI[1] == strtod - - -Input: 1.23e-20 - -strtoQ consumes 8 bytes and returns 17 -with bits = #3fbcd0ae 4cf76753 9e4cbca ad934841 -printf("%.35Lg") gives 1.2299999999999999999999999999999999e-20 -g_Qfmt(0) gives 8 bytes: "1.23e-20" - -strtoIQ returns 17, consuming 8 bytes. -fI[0] = #3fbcd0ae 4cf76753 9e4cbca ad934841 -= 1.2299999999999999999999999999999999e-20 -fI[1] = #3fbcd0ae 4cf76753 9e4cbca ad934842 -= 1.2300000000000000000000000000000001e-20 -fI[0] == strtod - - -Input: 1.23456789e307 - -strtoQ consumes 14 bytes and returns 17 -with bits = #43fb194b 14bdaecd bcea468c 902464cf -printf("%.35Lg") gives 1.2345678899999999999999999999999999e+307 -g_Qfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIQ returns 17, consuming 14 bytes. -fI[0] = #43fb194b 14bdaecd bcea468c 902464cf -= 1.2345678899999999999999999999999999e+307 -fI[1] = #43fb194b 14bdaecd bcea468c 902464d0 -= 1.2345678900000000000000000000000001e+307 -fI[0] == strtod - - -Input: 1.23456589e-307 - -strtoQ consumes 15 bytes and returns 17 -with bits = #3c036319 6bb9845f a6d234e3 39163574 -printf("%.35Lg") gives 1.23456589e-307 -g_Qfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIQ returns 17, consuming 15 bytes. -fI[0] = #3c036319 6bb9845f a6d234e3 39163574 -= 1.23456589e-307 -fI[1] = #3c036319 6bb9845f a6d234e3 39163575 -= 1.2345658900000000000000000000000002e-307 -fI[0] == strtod - - -Input: 1.234567890123456789 - -strtoQ consumes 20 bytes and returns 17 -with bits = #3fff3c0c a428c59f b71a4194 68dd175b -printf("%.35Lg") gives 1.234567890123456789 -g_Qfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIQ returns 17, consuming 20 bytes. -fI[0] = #3fff3c0c a428c59f b71a4194 68dd175b -= 1.234567890123456789 -fI[1] = #3fff3c0c a428c59f b71a4194 68dd175c -= 1.2345678901234567890000000000000002 -fI[0] == strtod - - -Input: 1.234567890123456789e301 - -strtoQ consumes 24 bytes and returns 33 -with bits = #43e726f5 175f5641 3017ea80 763990ef -printf("%.35Lg") gives 1.2345678901234567890000000000000001e+301 -g_Qfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIQ returns 33, consuming 24 bytes. -fI[0] = #43e726f5 175f5641 3017ea80 763990ee -= 1.2345678901234567889999999999999999e+301 -fI[1] = #43e726f5 175f5641 3017ea80 763990ef -= 1.2345678901234567890000000000000001e+301 -fI[1] == strtod - - -Input: 1.234567890123456789e-301 - -strtoQ consumes 25 bytes and returns 17 -with bits = #3c1752a6 4e34ba0d 35b19b04 3222fce5 -printf("%.35Lg") gives 1.234567890123456789e-301 -g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIQ returns 17, consuming 25 bytes. -fI[0] = #3c1752a6 4e34ba0d 35b19b04 3222fce5 -= 1.234567890123456789e-301 -fI[1] = #3c1752a6 4e34ba0d 35b19b04 3222fce6 -= 1.2345678901234567890000000000000002e-301 -fI[0] == strtod - - -Input: 1.234567890123456789e-321 - -strtoQ consumes 25 bytes and returns 17 -with bits = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de -printf("%.35Lg") gives 1.234567890123456789e-321 -g_Qfmt(0) gives 25 bytes: "1.234567890123456789e-321" - -strtoIQ returns 17, consuming 25 bytes. -fI[0] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7de -= 1.234567890123456789e-321 -fI[1] = #3bd4f3c2 3699d4db 99d1ea94 2fecd7df -= 1.2345678901234567890000000000000001e-321 -fI[0] == strtod - - -Input: 1e23 - -strtoQ consumes 4 bytes and returns 1 -with bits = #404b52d0 2c7e14af 68000000 0 -printf("%.35Lg") gives 100000000000000000000000 -g_Qfmt(0) gives 5 bytes: "1e+23" - -strtoIQ returns 1, consuming 4 bytes. -fI[0] == fI[1] = #404b52d0 2c7e14af 68000000 0 -= 100000000000000000000000 - - -Input: 1e310 - -strtoQ consumes 5 bytes and returns 33 -with bits = #4404bd03 c8140697 9e9ff00e fefd4cbd -printf("%.35Lg") gives 1e+310 -g_Qfmt(0) gives 6 bytes: "1e+310" - -strtoIQ returns 33, consuming 5 bytes. -fI[0] = #4404bd03 c8140697 9e9ff00e fefd4cbc -= 9.9999999999999999999999999999999992e+309 -fI[1] = #4404bd03 c8140697 9e9ff00e fefd4cbd -= 1e+310 -fI[1] == strtod - - -Input: 9.0259718793241475e-277 - -strtoQ consumes 23 bytes and returns 17 -with bits = #3c69ffff ffffffff f9ed5779 ac118fe1 -printf("%.35Lg") gives 9.0259718793241474999999999999999997e-277 -g_Qfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIQ returns 17, consuming 23 bytes. -fI[0] = #3c69ffff ffffffff f9ed5779 ac118fe1 -= 9.0259718793241474999999999999999997e-277 -fI[1] = #3c69ffff ffffffff f9ed5779 ac118fe2 -= 9.0259718793241475000000000000000006e-277 -fI[0] == strtod - - -Input: 9.025971879324147880346310405869e-277 - -strtoQ consumes 37 bytes and returns 33 -with bits = #3c6a0000 0 0 9a -printf("%.35Lg") gives 9.0259718793241478803463104058690004e-277 -g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277" - -strtoIQ returns 33, consuming 37 bytes. -fI[0] = #3c6a0000 0 0 99 -= 9.0259718793241478803463104058689987e-277 -fI[1] = #3c6a0000 0 0 9a -= 9.0259718793241478803463104058690004e-277 -fI[1] == strtod - - -Input: 9.025971879324147880346310405868e-277 - -strtoQ consumes 37 bytes and returns 17 -with bits = #3c69ffff ffffffff ffffffff fffffcb5 -printf("%.35Lg") gives 9.025971879324147880346310405868e-277 -g_Qfmt(0) gives 37 bytes: "9.025971879324147880346310405868e-277" - -strtoIQ returns 17, consuming 37 bytes. -fI[0] = #3c69ffff ffffffff ffffffff fffffcb5 -= 9.025971879324147880346310405868e-277 -fI[1] = #3c69ffff ffffffff ffffffff fffffcb6 -= 9.0259718793241478803463104058680009e-277 -fI[0] == strtod - - -Input: 2.2250738585072014e-308 - -strtoQ consumes 23 bytes and returns 33 -with bits = #3c010000 0 8c304c cf867de0 -printf("%.35Lg") gives 2.2250738585072014000000000000000001e-308 -g_Qfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIQ returns 33, consuming 23 bytes. -fI[0] = #3c010000 0 8c304c cf867ddf -= 2.2250738585072013999999999999999997e-308 -fI[1] = #3c010000 0 8c304c cf867de0 -= 2.2250738585072014000000000000000001e-308 -fI[1] == strtod - - -Input: 2.2250738585072013e-308 - -strtoQ consumes 23 bytes and returns 33 -with bits = #3c00ffff ffffffff fa9e4c4f 4c1e8a10 -printf("%.35Lg") gives 2.2250738585072013e-308 -g_Qfmt(0) gives 23 bytes: "2.2250738585072013e-308" - -strtoIQ returns 33, consuming 23 bytes. -fI[0] = #3c00ffff ffffffff fa9e4c4f 4c1e8a0f -= 2.2250738585072012999999999999999998e-308 -fI[1] = #3c00ffff ffffffff fa9e4c4f 4c1e8a10 -= 2.2250738585072013e-308 -fI[1] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff1999 99999999 99999999 99999999 -printf("%.35Lg") gives 1.0999999999999999999999999999999999 -g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -= 1.0999999999999999999999999999999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -= 1.1000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff1999 99999999 99999999 99999999 -printf("%.35Lg") gives -1.0999999999999999999999999999999999 -g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -= -1.1000000000000000000000000000000001 -fI[1] = #bfff1999 99999999 99999999 99999999 -= -1.0999999999999999999999999999999999 -fI[1] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff3333 33333333 33333333 33333333 -printf("%.35Lg") gives 1.2 -g_Qfmt(0) gives 3 bytes: "1.2" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -= 1.2 -fI[1] = #3fff3333 33333333 33333333 33333334 -= 1.2000000000000000000000000000000002 -fI[0] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff3333 33333333 33333333 33333333 -printf("%.35Lg") gives -1.2 -g_Qfmt(0) gives 4 bytes: "-1.2" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -= -1.2000000000000000000000000000000002 -fI[1] = #bfff3333 33333333 33333333 33333333 -= -1.2 -fI[1] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff4ccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives 1.2999999999999999999999999999999998 -g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -= 1.2999999999999999999999999999999998 -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -= 1.3 -fI[0] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff4ccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives -1.2999999999999999999999999999999998 -g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -= -1.3 -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -= -1.2999999999999999999999999999999998 -fI[1] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff6666 66666666 66666666 66666666 -printf("%.35Lg") gives 1.3999999999999999999999999999999999 -g_Qfmt(0) gives 3 bytes: "1.4" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -= 1.3999999999999999999999999999999999 -fI[1] = #3fff6666 66666666 66666666 66666667 -= 1.4000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff6666 66666666 66666666 66666666 -printf("%.35Lg") gives -1.3999999999999999999999999999999999 -g_Qfmt(0) gives 4 bytes: "-1.4" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -= -1.4000000000000000000000000000000001 -fI[1] = #bfff6666 66666666 66666666 66666666 -= -1.3999999999999999999999999999999999 -fI[1] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -printf("%.35Lg") gives 1.5 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 -= 1.5 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -printf("%.35Lg") gives -1.5 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 -= -1.5 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff9999 99999999 99999999 99999999 -printf("%.35Lg") gives 1.5999999999999999999999999999999999 -g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -= 1.5999999999999999999999999999999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -= 1.6000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff9999 99999999 99999999 99999999 -printf("%.35Lg") gives -1.5999999999999999999999999999999999 -g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -= -1.6000000000000000000000000000000001 -fI[1] = #bfff9999 99999999 99999999 99999999 -= -1.5999999999999999999999999999999999 -fI[1] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffb333 33333333 33333333 33333333 -printf("%.35Lg") gives 1.7 -g_Qfmt(0) gives 3 bytes: "1.7" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -= 1.7 -fI[1] = #3fffb333 33333333 33333333 33333334 -= 1.7000000000000000000000000000000002 -fI[0] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffb333 33333333 33333333 33333333 -printf("%.35Lg") gives -1.7 -g_Qfmt(0) gives 4 bytes: "-1.7" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -= -1.7000000000000000000000000000000002 -fI[1] = #bfffb333 33333333 33333333 33333333 -= -1.7 -fI[1] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffcccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives 1.7999999999999999999999999999999998 -g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -= 1.7999999999999999999999999999999998 -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -= 1.8 -fI[0] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffcccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives -1.7999999999999999999999999999999998 -g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -= -1.8 -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -= -1.7999999999999999999999999999999998 -fI[1] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffe666 66666666 66666666 66666666 -printf("%.35Lg") gives 1.8999999999999999999999999999999999 -g_Qfmt(0) gives 3 bytes: "1.9" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -= 1.8999999999999999999999999999999999 -fI[1] = #3fffe666 66666666 66666666 66666667 -= 1.9000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffe666 66666666 66666666 66666666 -printf("%.35Lg") gives -1.8999999999999999999999999999999999 -g_Qfmt(0) gives 4 bytes: "-1.9" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -= -1.9000000000000000000000000000000001 -fI[1] = #bfffe666 66666666 66666666 66666666 -= -1.8999999999999999999999999999999999 -fI[1] == strtod - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff1999 99999999 99999999 9999999a -printf("%.35Lg") gives 1.1000000000000000000000000000000001 -g_Qfmt(0) gives 3 bytes: "1.1" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -= 1.0999999999999999999999999999999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -= 1.1000000000000000000000000000000001 -fI[1] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff1999 99999999 99999999 9999999a -printf("%.35Lg") gives -1.1000000000000000000000000000000001 -g_Qfmt(0) gives 4 bytes: "-1.1" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -= -1.1000000000000000000000000000000001 -fI[1] = #bfff1999 99999999 99999999 99999999 -= -1.0999999999999999999999999999999999 -fI[0] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff3333 33333333 33333333 33333333 -printf("%.35Lg") gives 1.2 -g_Qfmt(0) gives 3 bytes: "1.2" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -= 1.2 -fI[1] = #3fff3333 33333333 33333333 33333334 -= 1.2000000000000000000000000000000002 -fI[0] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff3333 33333333 33333333 33333333 -printf("%.35Lg") gives -1.2 -g_Qfmt(0) gives 4 bytes: "-1.2" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -= -1.2000000000000000000000000000000002 -fI[1] = #bfff3333 33333333 33333333 33333333 -= -1.2 -fI[1] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff4ccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives 1.3 -g_Qfmt(0) gives 3 bytes: "1.3" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -= 1.2999999999999999999999999999999998 -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -= 1.3 -fI[1] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff4ccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives -1.3 -g_Qfmt(0) gives 4 bytes: "-1.3" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -= -1.3 -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -= -1.2999999999999999999999999999999998 -fI[0] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff6666 66666666 66666666 66666666 -printf("%.35Lg") gives 1.3999999999999999999999999999999999 -g_Qfmt(0) gives 3 bytes: "1.4" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -= 1.3999999999999999999999999999999999 -fI[1] = #3fff6666 66666666 66666666 66666667 -= 1.4000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff6666 66666666 66666666 66666666 -printf("%.35Lg") gives -1.3999999999999999999999999999999999 -g_Qfmt(0) gives 4 bytes: "-1.4" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -= -1.4000000000000000000000000000000001 -fI[1] = #bfff6666 66666666 66666666 66666666 -= -1.3999999999999999999999999999999999 -fI[1] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -printf("%.35Lg") gives 1.5 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 -= 1.5 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -printf("%.35Lg") gives -1.5 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 -= -1.5 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff9999 99999999 99999999 9999999a -printf("%.35Lg") gives 1.6000000000000000000000000000000001 -g_Qfmt(0) gives 3 bytes: "1.6" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -= 1.5999999999999999999999999999999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -= 1.6000000000000000000000000000000001 -fI[1] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff9999 99999999 99999999 9999999a -printf("%.35Lg") gives -1.6000000000000000000000000000000001 -g_Qfmt(0) gives 4 bytes: "-1.6" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -= -1.6000000000000000000000000000000001 -fI[1] = #bfff9999 99999999 99999999 99999999 -= -1.5999999999999999999999999999999999 -fI[0] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffb333 33333333 33333333 33333333 -printf("%.35Lg") gives 1.7 -g_Qfmt(0) gives 3 bytes: "1.7" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -= 1.7 -fI[1] = #3fffb333 33333333 33333333 33333334 -= 1.7000000000000000000000000000000002 -fI[0] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffb333 33333333 33333333 33333333 -printf("%.35Lg") gives -1.7 -g_Qfmt(0) gives 4 bytes: "-1.7" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -= -1.7000000000000000000000000000000002 -fI[1] = #bfffb333 33333333 33333333 33333333 -= -1.7 -fI[1] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffcccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives 1.8 -g_Qfmt(0) gives 3 bytes: "1.8" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -= 1.7999999999999999999999999999999998 -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -= 1.8 -fI[1] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffcccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives -1.8 -g_Qfmt(0) gives 4 bytes: "-1.8" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -= -1.8 -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -= -1.7999999999999999999999999999999998 -fI[0] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffe666 66666666 66666666 66666666 -printf("%.35Lg") gives 1.8999999999999999999999999999999999 -g_Qfmt(0) gives 3 bytes: "1.9" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -= 1.8999999999999999999999999999999999 -fI[1] = #3fffe666 66666666 66666666 66666667 -= 1.9000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffe666 66666666 66666666 66666666 -printf("%.35Lg") gives -1.8999999999999999999999999999999999 -g_Qfmt(0) gives 4 bytes: "-1.9" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -= -1.9000000000000000000000000000000001 -fI[1] = #bfffe666 66666666 66666666 66666666 -= -1.8999999999999999999999999999999999 -fI[1] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff1999 99999999 99999999 9999999a -printf("%.35Lg") gives 1.1000000000000000000000000000000001 -g_Qfmt(0) gives 3 bytes: "1.1" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -= 1.0999999999999999999999999999999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -= 1.1000000000000000000000000000000001 -fI[1] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff1999 99999999 99999999 99999999 -printf("%.35Lg") gives -1.0999999999999999999999999999999999 -g_Qfmt(0) gives 37 bytes: "-1.0999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -= -1.1000000000000000000000000000000001 -fI[1] = #bfff1999 99999999 99999999 99999999 -= -1.0999999999999999999999999999999999 -fI[1] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff3333 33333333 33333333 33333334 -printf("%.35Lg") gives 1.2000000000000000000000000000000002 -g_Qfmt(0) gives 36 bytes: "1.2000000000000000000000000000000002" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -= 1.2 -fI[1] = #3fff3333 33333333 33333333 33333334 -= 1.2000000000000000000000000000000002 -fI[1] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff3333 33333333 33333333 33333333 -printf("%.35Lg") gives -1.2 -g_Qfmt(0) gives 4 bytes: "-1.2" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -= -1.2000000000000000000000000000000002 -fI[1] = #bfff3333 33333333 33333333 33333333 -= -1.2 -fI[1] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff4ccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives 1.3 -g_Qfmt(0) gives 3 bytes: "1.3" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -= 1.2999999999999999999999999999999998 -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -= 1.3 -fI[1] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff4ccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives -1.2999999999999999999999999999999998 -g_Qfmt(0) gives 37 bytes: "-1.2999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -= -1.3 -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -= -1.2999999999999999999999999999999998 -fI[1] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff6666 66666666 66666666 66666667 -printf("%.35Lg") gives 1.4000000000000000000000000000000001 -g_Qfmt(0) gives 36 bytes: "1.4000000000000000000000000000000001" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -= 1.3999999999999999999999999999999999 -fI[1] = #3fff6666 66666666 66666666 66666667 -= 1.4000000000000000000000000000000001 -fI[1] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff6666 66666666 66666666 66666666 -printf("%.35Lg") gives -1.3999999999999999999999999999999999 -g_Qfmt(0) gives 4 bytes: "-1.4" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -= -1.4000000000000000000000000000000001 -fI[1] = #bfff6666 66666666 66666666 66666666 -= -1.3999999999999999999999999999999999 -fI[1] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -printf("%.35Lg") gives 1.5 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 -= 1.5 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -printf("%.35Lg") gives -1.5 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 -= -1.5 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fff9999 99999999 99999999 9999999a -printf("%.35Lg") gives 1.6000000000000000000000000000000001 -g_Qfmt(0) gives 3 bytes: "1.6" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -= 1.5999999999999999999999999999999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -= 1.6000000000000000000000000000000001 -fI[1] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfff9999 99999999 99999999 99999999 -printf("%.35Lg") gives -1.5999999999999999999999999999999999 -g_Qfmt(0) gives 37 bytes: "-1.5999999999999999999999999999999999" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -= -1.6000000000000000000000000000000001 -fI[1] = #bfff9999 99999999 99999999 99999999 -= -1.5999999999999999999999999999999999 -fI[1] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffb333 33333333 33333333 33333334 -printf("%.35Lg") gives 1.7000000000000000000000000000000002 -g_Qfmt(0) gives 36 bytes: "1.7000000000000000000000000000000002" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -= 1.7 -fI[1] = #3fffb333 33333333 33333333 33333334 -= 1.7000000000000000000000000000000002 -fI[1] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffb333 33333333 33333333 33333333 -printf("%.35Lg") gives -1.7 -g_Qfmt(0) gives 4 bytes: "-1.7" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -= -1.7000000000000000000000000000000002 -fI[1] = #bfffb333 33333333 33333333 33333333 -= -1.7 -fI[1] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffcccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives 1.8 -g_Qfmt(0) gives 3 bytes: "1.8" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -= 1.7999999999999999999999999999999998 -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -= 1.8 -fI[1] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffcccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives -1.7999999999999999999999999999999998 -g_Qfmt(0) gives 37 bytes: "-1.7999999999999999999999999999999998" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -= -1.8 -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -= -1.7999999999999999999999999999999998 -fI[1] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 33 -with bits = #3fffe666 66666666 66666666 66666667 -printf("%.35Lg") gives 1.9000000000000000000000000000000001 -g_Qfmt(0) gives 36 bytes: "1.9000000000000000000000000000000001" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -= 1.8999999999999999999999999999999999 -fI[1] = #3fffe666 66666666 66666666 66666667 -= 1.9000000000000000000000000000000001 -fI[1] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 25 -with bits = #bfffe666 66666666 66666666 66666666 -printf("%.35Lg") gives -1.8999999999999999999999999999999999 -g_Qfmt(0) gives 4 bytes: "-1.9" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -= -1.9000000000000000000000000000000001 -fI[1] = #bfffe666 66666666 66666666 66666666 -= -1.8999999999999999999999999999999999 -fI[1] == strtod - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff1999 99999999 99999999 99999999 -printf("%.35Lg") gives 1.0999999999999999999999999999999999 -g_Qfmt(0) gives 36 bytes: "1.0999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff1999 99999999 99999999 99999999 -= 1.0999999999999999999999999999999999 -fI[1] = #3fff1999 99999999 99999999 9999999a -= 1.1000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.1 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff1999 99999999 99999999 9999999a -printf("%.35Lg") gives -1.1000000000000000000000000000000001 -g_Qfmt(0) gives 4 bytes: "-1.1" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff1999 99999999 99999999 9999999a -= -1.1000000000000000000000000000000001 -fI[1] = #bfff1999 99999999 99999999 99999999 -= -1.0999999999999999999999999999999999 -fI[0] == strtod - - -Input: 1.2 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff3333 33333333 33333333 33333333 -printf("%.35Lg") gives 1.2 -g_Qfmt(0) gives 3 bytes: "1.2" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff3333 33333333 33333333 33333333 -= 1.2 -fI[1] = #3fff3333 33333333 33333333 33333334 -= 1.2000000000000000000000000000000002 -fI[0] == strtod - - -Input: -1.2 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff3333 33333333 33333333 33333334 -printf("%.35Lg") gives -1.2000000000000000000000000000000002 -g_Qfmt(0) gives 37 bytes: "-1.2000000000000000000000000000000002" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff3333 33333333 33333333 33333334 -= -1.2000000000000000000000000000000002 -fI[1] = #bfff3333 33333333 33333333 33333333 -= -1.2 -fI[0] == strtod - - -Input: 1.3 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff4ccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives 1.2999999999999999999999999999999998 -g_Qfmt(0) gives 36 bytes: "1.2999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff4ccc cccccccc cccccccc cccccccc -= 1.2999999999999999999999999999999998 -fI[1] = #3fff4ccc cccccccc cccccccc cccccccd -= 1.3 -fI[0] == strtod - - -Input: -1.3 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff4ccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives -1.3 -g_Qfmt(0) gives 4 bytes: "-1.3" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff4ccc cccccccc cccccccc cccccccd -= -1.3 -fI[1] = #bfff4ccc cccccccc cccccccc cccccccc -= -1.2999999999999999999999999999999998 -fI[0] == strtod - - -Input: 1.4 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff6666 66666666 66666666 66666666 -printf("%.35Lg") gives 1.3999999999999999999999999999999999 -g_Qfmt(0) gives 3 bytes: "1.4" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fff6666 66666666 66666666 66666666 -= 1.3999999999999999999999999999999999 -fI[1] = #3fff6666 66666666 66666666 66666667 -= 1.4000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.4 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff6666 66666666 66666666 66666667 -printf("%.35Lg") gives -1.4000000000000000000000000000000001 -g_Qfmt(0) gives 37 bytes: "-1.4000000000000000000000000000000001" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfff6666 66666666 66666666 66666667 -= -1.4000000000000000000000000000000001 -fI[1] = #bfff6666 66666666 66666666 66666666 -= -1.3999999999999999999999999999999999 -fI[0] == strtod - - -Input: 1.5 - -strtoQ consumes 3 bytes and returns 1 -with bits = #3fff8000 0 0 0 -printf("%.35Lg") gives 1.5 -g_Qfmt(0) gives 3 bytes: "1.5" - -strtoIQ returns 1, consuming 3 bytes. -fI[0] == fI[1] = #3fff8000 0 0 0 -= 1.5 - - -Input: -1.5 - -strtoQ consumes 4 bytes and returns 9 -with bits = #bfff8000 0 0 0 -printf("%.35Lg") gives -1.5 -g_Qfmt(0) gives 4 bytes: "-1.5" - -strtoIQ returns 9, consuming 4 bytes. -fI[0] == fI[1] = #bfff8000 0 0 0 -= -1.5 - - -Input: 1.6 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fff9999 99999999 99999999 99999999 -printf("%.35Lg") gives 1.5999999999999999999999999999999999 -g_Qfmt(0) gives 36 bytes: "1.5999999999999999999999999999999999" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fff9999 99999999 99999999 99999999 -= 1.5999999999999999999999999999999999 -fI[1] = #3fff9999 99999999 99999999 9999999a -= 1.6000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.6 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfff9999 99999999 99999999 9999999a -printf("%.35Lg") gives -1.6000000000000000000000000000000001 -g_Qfmt(0) gives 4 bytes: "-1.6" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfff9999 99999999 99999999 9999999a -= -1.6000000000000000000000000000000001 -fI[1] = #bfff9999 99999999 99999999 99999999 -= -1.5999999999999999999999999999999999 -fI[0] == strtod - - -Input: 1.7 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffb333 33333333 33333333 33333333 -printf("%.35Lg") gives 1.7 -g_Qfmt(0) gives 3 bytes: "1.7" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffb333 33333333 33333333 33333333 -= 1.7 -fI[1] = #3fffb333 33333333 33333333 33333334 -= 1.7000000000000000000000000000000002 -fI[0] == strtod - - -Input: -1.7 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffb333 33333333 33333333 33333334 -printf("%.35Lg") gives -1.7000000000000000000000000000000002 -g_Qfmt(0) gives 37 bytes: "-1.7000000000000000000000000000000002" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffb333 33333333 33333333 33333334 -= -1.7000000000000000000000000000000002 -fI[1] = #bfffb333 33333333 33333333 33333333 -= -1.7 -fI[0] == strtod - - -Input: 1.8 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffcccc cccccccc cccccccc cccccccc -printf("%.35Lg") gives 1.7999999999999999999999999999999998 -g_Qfmt(0) gives 36 bytes: "1.7999999999999999999999999999999998" - -strtoIQ returns 33, consuming 3 bytes. -fI[0] = #3fffcccc cccccccc cccccccc cccccccc -= 1.7999999999999999999999999999999998 -fI[1] = #3fffcccc cccccccc cccccccc cccccccd -= 1.8 -fI[0] == strtod - - -Input: -1.8 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffcccc cccccccc cccccccc cccccccd -printf("%.35Lg") gives -1.8 -g_Qfmt(0) gives 4 bytes: "-1.8" - -strtoIQ returns 41, consuming 4 bytes. -fI[0] = #bfffcccc cccccccc cccccccc cccccccd -= -1.8 -fI[1] = #bfffcccc cccccccc cccccccc cccccccc -= -1.7999999999999999999999999999999998 -fI[0] == strtod - - -Input: 1.9 - -strtoQ consumes 3 bytes and returns 17 -with bits = #3fffe666 66666666 66666666 66666666 -printf("%.35Lg") gives 1.8999999999999999999999999999999999 -g_Qfmt(0) gives 3 bytes: "1.9" - -strtoIQ returns 17, consuming 3 bytes. -fI[0] = #3fffe666 66666666 66666666 66666666 -= 1.8999999999999999999999999999999999 -fI[1] = #3fffe666 66666666 66666666 66666667 -= 1.9000000000000000000000000000000001 -fI[0] == strtod - - -Input: -1.9 - -strtoQ consumes 4 bytes and returns 41 -with bits = #bfffe666 66666666 66666666 66666667 -printf("%.35Lg") gives -1.9000000000000000000000000000000001 -g_Qfmt(0) gives 37 bytes: "-1.9000000000000000000000000000000001" - -strtoIQ returns 25, consuming 4 bytes. -fI[0] = #bfffe666 66666666 66666666 66666667 -= -1.9000000000000000000000000000000001 -fI[1] = #bfffe666 66666666 66666666 66666666 -= -1.8999999999999999999999999999999999 -fI[0] == strtod - diff --git a/lib/libc/gdtoa/test/Qtest.c b/lib/libc/gdtoa/test/Qtest.c deleted file mode 100644 index 057c2ed80..000000000 --- a/lib/libc/gdtoa/test/Qtest.c +++ /dev/null @@ -1,178 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test program for g_Qfmt, strtoIQ, strtopQ, and strtorQ. - * - * Inputs (on stdin): - * r rounding_mode - * n ndig - * number - * #hex0 hex1 hex2 hex3 - * - * rounding_mode values: - * 0 = toward zero - * 1 = nearest - * 2 = toward +Infinity - * 3 = toward -Infinity - * - * where number is a decimal floating-point number, - * hex0 is a string of <= 8 Hex digits for the most significant - * word of the number, hex1 is a similar string for the next - * word, etc., and ndig is a parameters to g_Qfmt. - */ - -#include "gdtoa.h" -#include -#include -#include - - extern int getround ANSI((int,char*)); - - static char ibuf[2048], obuf[2048]; -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 3 -#define _1 2 -#define _2 1 -#define _3 0 -#endif - -#define U (unsigned long) - - int -main(Void) -{ - char *s, *s1, *se, *se1; - int Ltest, i, dItry, ndig = 0, r = 1; - union { long double d; ULong bits[4]; } u, v[2], w; - - w.bits[0] = w.bits[3] = 0; - w.d = 1.; - u.d = 3.; - w.d = w.d / u.d; - Ltest = sizeof(long double) == 16 && w.bits[0] && w.bits[3]; - while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) { - while(*s <= ' ') - if (!*s++) - continue; - dItry = 0; - switch(*s) { - case 'r': - r = getround(r, s); - continue; - case 'n': - i = s[1]; - if (i <= ' ' || (i >= '0' && i <= '9')) { - ndig = atoi(s+1); - continue; - } - break; /* nan? */ - case '#': - /* sscanf(s+1, "%lx %lx %lx %lx", &u.bits[_0], */ - /* &u.bits[_1], &u.bits[_2], &u.bits[_3]); */ - u.bits[_0] = (ULong)strtoul(s1 = s+1, &se, 16); - if (se > s1) { - u.bits[_1] = (ULong)strtoul(s1 = se, &se, 16); - if (se > s1) { - u.bits[_2] = (ULong)strtoul(s1 = se, &se, 16); - if (se > s1) - u.bits[_3] = (ULong)strtoul(s1 = se, &se, 16); - } - } - printf("\nInput: %s", ibuf); - printf(" --> f = #%lx %lx %lx %lx\n", U u.bits[_0], - U u.bits[_1], U u.bits[_2], U u.bits[_3]); - goto fmt_test; - } - dItry = 1; - printf("\nInput: %s", ibuf); - i = strtorQ(ibuf, &se, r, u.bits); - if (r == 1 && (strtopQ(ibuf,&se1,v[0].bits) != i - || se != se1 || memcmp(u.bits, v[0].bits, 16))) - printf("***strtoQ and strtorQ disagree!!\n:"); - printf("\nstrtoQ consumes %d bytes and returns %d\n", - (int)(se-ibuf), i); - printf("with bits = #%lx %lx %lx %lx\n", - U u.bits[_0], U u.bits[_1], U u.bits[_2], U u.bits[_3]); - fmt_test: - if (Ltest) - printf("printf(\"%%.35Lg\") gives %.35Lg\n", u.d); - se = g_Qfmt(obuf, u.bits, ndig, sizeof(obuf)); - printf("g_Qfmt(%d) gives %d bytes: \"%s\"\n\n", ndig, - (int)(se-obuf), se ? obuf : ""); - if (!dItry) - continue; - printf("strtoIQ returns %d,", - strtoIQ(ibuf, &se, v[0].bits, v[1].bits)); - printf(" consuming %d bytes.\n", (int)(se-ibuf)); - if (!memcmp(v[0].bits, v[1].bits, 16)) { - if (!memcpy(u.bits, v[0].bits, 16)) - printf("fI[0] == fI[1] == strtoQ\n"); - else { - printf("fI[0] == fI[1] = #%lx %lx %lx %lx\n", - U v[0].bits[_0], U v[0].bits[_1], - U v[0].bits[_2], U v[0].bits[_3]); - if (Ltest) - printf("= %.35Lg\n", v[0].d); - } - } - else { - printf("fI[0] = #%lx %lx %lx %lx\n", - U v[0].bits[_0], U v[0].bits[_1], - U v[0].bits[_2], U v[0].bits[_3]); - if (Ltest) - printf("= %.35Lg\n", v[0].d); - printf("fI[1] = #%lx %lx %lx %lx\n", - U v[1].bits[_0], U v[1].bits[_1], - U v[1].bits[_2], U v[1].bits[_3]); - if (Ltest) - printf("= %.35Lg\n", v[1].d); - if (!memcmp(v[0].bits, u.bits, 16)) - printf("fI[0] == strtod\n"); - else if (!memcmp(v[1].bits, u.bits, 16)) - printf("fI[1] == strtod\n"); - else - printf("**** Both differ from strtod ****\n"); - } - printf("\n"); - } - return 0; - } diff --git a/lib/libc/gdtoa/test/README b/lib/libc/gdtoa/test/README deleted file mode 100644 index 042ecfea0..000000000 --- a/lib/libc/gdtoa/test/README +++ /dev/null @@ -1,81 +0,0 @@ -This directory contains source for several test programs: - -dt is for conversion to/from double; it permits input of pairs of -32-bit hex integers as #hhhhhhhh hhhhhhhh (i.e., the initial '#' -indicates hex input). No initial # ==> decimal input. -After the input number is an optional : mode ndigits -(colon, and decimal integers for parameters "mode" and "ndigits" -to gdtoa). - -Qtest, ddtest, dtest, ftest, xLtest and xtest are for conversion to/from - - f IEEE single precision - d IEEE double precision - xL IEEE extended precision, as on Motorola 680x0 chips - x IEEE extended precision, as on Intel 80x87 chips or - software emulation of Motorola 680x0 chips - Q quad precision, as on Sun Sparc chips - dd double double, pairs of IEEE double numbers - whose sum is the desired value - -They're all similar, except for the precision. They test both -directed roundings and interval input (the strtoI* routines). -Lines that begin with "r" specify or interrogate the desired rounding -direction: - - 0 = toward 0 - 1 = nearest (default) - 2 = toward +Infinity - 3 = toward -Infinity - -These are the FPI_Round_* values in gdota.h. The "r" value is sticky: -it stays in effect til changed. To change the value, give a line that -starts with r followed by 0, 1, 2, or 3. To check the value, give "r" -by itself. - -Lines that begin with n followed by a number specify the ndig -argument for subsequent calls to the relevant g_*fmt routine. - -Lines that start with # followed by the appropriate number of -hexadecimal strings (see the comments) give the big-endian -internal representation of the desired number. - -When routines Qtest, xLtest, and xtest are used on machines whose -long double is of type "quad" (for Qtest) or "extended" (for x*test), -they try to print with %Lg as another way to show binary values. - -Program ddtest also accepts (white-space separated) pairs of decimal -input numbers; it converts both with strtod and feeds the result -to g_ddfmt. - -Program dItest exercises strtodI and strtoId. - -Programs dItestsi and ddtestsi are for testing the sudden-underflow -logic (on double and double-double conversions). - -Program strtodt tests strtod on some hard cases (in file testnos3) -posted by Fred Tydeman to comp.arch.arithmetic on 26 Feb. 1996. -To get correct results on Intel (x86) systems, the rounding precision -must be set to 53 bits. This can be done, e.g., by invoking -fpinit_ASL(), whose source appears in -http://www.netlib.org/ampl/solvers/fpinit.c . - -The obad directory shows results expected on (at least some) Intel x86 -Linux systems and may not be relevant to other systems. - -You can optionally compile getround.c with -DHonor_FLT_ROUNDS -to manually test strtof, strtod, etc., using fegetround(). -You can also or alternatively compile getround.c with --DUSE_MY_LOCALE (when ../gdtoa.a is compiled with -DUSE_LOCALE) -to test multi-byte decimal points. - -If in the parent directory, you have sucessfully invoked "make Printf" -to add a "printf" (called Printf and accessed via ../stdio1.h), then -here you can use "make pf_test" and (if you have both a 64-bit long -double and a 113-bit "quad" double type) "make pf_testLq" for a brief -test of %g and %a variants in Printf. - -These are simple test programs, not meant for exhaustive testing, -but for manually testing "interesting" cases. Paxson's testbase -is good for more exhaustive testing, in part with random inputs. -See ftp://ftp.ee.lbl.gov/testbase-report.ps.Z . diff --git a/lib/libc/gdtoa/test/d.out b/lib/libc/gdtoa/test/d.out deleted file mode 100644 index a0ac991c4..000000000 --- a/lib/libc/gdtoa/test/d.out +++ /dev/null @@ -1,986 +0,0 @@ - -Input: 1.23 -strtod consumes 4 bytes and returns 17 with f = 1.23 = #3ff3ae14 7ae147ae -g_dfmt(0) gives 4 bytes: "1.23" - -strtoId returns 17, consuming 4 bytes. -fI[0] = #3ff3ae14 7ae147ae = 1.23 -fI[1] = #3ff3ae14 7ae147af = 1.2300000000000002 -fI[0] == strtod - - -Input: 1.23e+20 -strtod consumes 8 bytes and returns 1 with f = 1.23e+20 = #441aabdf 2145b430 -g_dfmt(0) gives 8 bytes: "1.23e+20" - -strtoId returns 1, consuming 8 bytes. -fI[0] == fI[1] == strtod - - -Input: 1.23e-20 -strtod consumes 8 bytes and returns 33 with f = 1.2300000000000001e-20 = #3bcd0ae4 cf767531 -g_dfmt(0) gives 8 bytes: "1.23e-20" - -strtoId returns 33, consuming 8 bytes. -fI[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20 -fI[1] = #3bcd0ae4 cf767531 = 1.2300000000000001e-20 -fI[1] == strtod - - -Input: 1.23456789 -strtod consumes 10 bytes and returns 17 with f = 1.2345678899999999 = #3ff3c0ca 4283de1b -g_dfmt(0) gives 10 bytes: "1.23456789" - -strtoId returns 17, consuming 10 bytes. -fI[0] = #3ff3c0ca 4283de1b = 1.2345678899999999 -fI[1] = #3ff3c0ca 4283de1c = 1.2345678900000001 -fI[0] == strtod - - -Input: 1.23456589e+20 -strtod consumes 14 bytes and returns 17 with f = 1.23456589e+20 = #441ac537 a660b997 -g_dfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoId returns 17, consuming 14 bytes. -fI[0] = #441ac537 a660b997 = 1.23456589e+20 -fI[1] = #441ac537 a660b998 = 1.2345658900000001e+20 -fI[0] == strtod - - -Input: 1.23e+30 -strtod consumes 8 bytes and returns 17 with f = 1.23e+30 = #462f0cb0 4e8fb790 -g_dfmt(0) gives 8 bytes: "1.23e+30" - -strtoId returns 17, consuming 8 bytes. -fI[0] = #462f0cb0 4e8fb790 = 1.23e+30 -fI[1] = #462f0cb0 4e8fb791 = 1.2300000000000001e+30 -fI[0] == strtod - - -Input: 1.23e-30 -strtod consumes 8 bytes and returns 33 with f = 1.2300000000000001e-30 = #39b8f286 6f5010ab -g_dfmt(0) gives 8 bytes: "1.23e-30" - -strtoId returns 33, consuming 8 bytes. -fI[0] = #39b8f286 6f5010aa = 1.2299999999999999e-30 -fI[1] = #39b8f286 6f5010ab = 1.2300000000000001e-30 -fI[1] == strtod - - -Input: 1.23456789e-20 -strtod consumes 14 bytes and returns 17 with f = 1.2345678899999999e-20 = #3bcd2681 471e7ada -g_dfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoId returns 17, consuming 14 bytes. -fI[0] = #3bcd2681 471e7ada = 1.2345678899999999e-20 -fI[1] = #3bcd2681 471e7adb = 1.2345678900000001e-20 -fI[0] == strtod - - -Input: 1.23456789e-30 -strtod consumes 14 bytes and returns 17 with f = 1.23456789e-30 = #39b90a3e 33bbd995 -g_dfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoId returns 17, consuming 14 bytes. -fI[0] = #39b90a3e 33bbd995 = 1.23456789e-30 -fI[1] = #39b90a3e 33bbd996 = 1.2345678900000002e-30 -fI[0] == strtod - - -Input: 1.234567890123456789 -strtod consumes 20 bytes and returns 17 with f = 1.2345678901234567 = #3ff3c0ca 428c59fb -g_dfmt(0) gives 18 bytes: "1.2345678901234567" - -strtoId returns 17, consuming 20 bytes. -fI[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -fI[1] = #3ff3c0ca 428c59fc = 1.2345678901234569 -fI[0] == strtod - - -Input: 1.23456789012345678901234567890123456789 -strtod consumes 40 bytes and returns 17 with f = 1.2345678901234567 = #3ff3c0ca 428c59fb -g_dfmt(0) gives 18 bytes: "1.2345678901234567" - -strtoId returns 17, consuming 40 bytes. -fI[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -fI[1] = #3ff3c0ca 428c59fc = 1.2345678901234569 -fI[0] == strtod - - -Input: 1.23e306 -strtod consumes 8 bytes and returns 33 with f = 1.23e+306 = #7f7c0676 cd1c61f5 -g_dfmt(0) gives 9 bytes: "1.23e+306" - -strtoId returns 33, consuming 8 bytes. -fI[0] = #7f7c0676 cd1c61f4 = 1.2299999999999999e+306 -fI[1] = #7f7c0676 cd1c61f5 = 1.23e+306 -fI[1] == strtod - - -Input: 1.23e-306 -strtod consumes 9 bytes and returns 33 with f = 1.23e-306 = #6ba3b8 5da396e8 -g_dfmt(0) gives 9 bytes: "1.23e-306" - -strtoId returns 33, consuming 9 bytes. -fI[0] = #6ba3b8 5da396e7 = 1.2299999999999999e-306 -fI[1] = #6ba3b8 5da396e8 = 1.23e-306 -fI[1] == strtod - - -Input: 1.23e-320 -strtod consumes 9 bytes and returns 98 with f = 1.2302234581447039e-320 = #0 9ba -g_dfmt(0) gives 9 bytes: "1.23e-320" - -strtoId returns 98, consuming 9 bytes. -fI[0] = #0 9b9 = 1.2297293924988626e-320 -fI[1] = #0 9ba = 1.2302234581447039e-320 -fI[1] == strtod - - -Input: 1.23e-20 -strtod consumes 8 bytes and returns 33 with f = 1.2300000000000001e-20 = #3bcd0ae4 cf767531 -g_dfmt(0) gives 8 bytes: "1.23e-20" - -strtoId returns 33, consuming 8 bytes. -fI[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20 -fI[1] = #3bcd0ae4 cf767531 = 1.2300000000000001e-20 -fI[1] == strtod - - -Input: 1.23456789e307 -strtod consumes 14 bytes and returns 33 with f = 1.23456789e+307 = #7fb194b1 4bdaecdc -g_dfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoId returns 33, consuming 14 bytes. -fI[0] = #7fb194b1 4bdaecdb = 1.2345678899999998e+307 -fI[1] = #7fb194b1 4bdaecdc = 1.23456789e+307 -fI[1] == strtod - - -Input: 1.23456589e-307 -strtod consumes 15 bytes and returns 17 with f = 1.2345658899999999e-307 = #363196 bb9845fa -g_dfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoId returns 17, consuming 15 bytes. -fI[0] = #363196 bb9845fa = 1.2345658899999999e-307 -fI[1] = #363196 bb9845fb = 1.2345658900000001e-307 -fI[0] == strtod - - -Input: 1.234567890123456789 -strtod consumes 20 bytes and returns 17 with f = 1.2345678901234567 = #3ff3c0ca 428c59fb -g_dfmt(0) gives 18 bytes: "1.2345678901234567" - -strtoId returns 17, consuming 20 bytes. -fI[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -fI[1] = #3ff3c0ca 428c59fc = 1.2345678901234569 -fI[0] == strtod - - -Input: 1.234567890123456789e301 -strtod consumes 24 bytes and returns 17 with f = 1.2345678901234568e+301 = #7e726f51 75f56413 -g_dfmt(0) gives 23 bytes: "1.2345678901234568e+301" - -strtoId returns 17, consuming 24 bytes. -fI[0] = #7e726f51 75f56413 = 1.2345678901234568e+301 -fI[1] = #7e726f51 75f56414 = 1.234567890123457e+301 -fI[0] == strtod - - -Input: 1.234567890123456789e-301 -strtod consumes 25 bytes and returns 17 with f = 1.2345678901234567e-301 = #1752a64 e34ba0d3 -g_dfmt(0) gives 23 bytes: "1.2345678901234567e-301" - -strtoId returns 17, consuming 25 bytes. -fI[0] = #1752a64 e34ba0d3 = 1.2345678901234567e-301 -fI[1] = #1752a64 e34ba0d4 = 1.2345678901234569e-301 -fI[0] == strtod - - -Input: 1.234567890123456789e-321 -strtod consumes 25 bytes and returns 98 with f = 1.2351641146031164e-321 = #0 fa -g_dfmt(0) gives 10 bytes: "1.235e-321" - -strtoId returns 98, consuming 25 bytes. -fI[0] = #0 f9 = 1.2302234581447039e-321 -fI[1] = #0 fa = 1.2351641146031164e-321 -fI[1] == strtod - - -Input: 1e23 -strtod consumes 4 bytes and returns 17 with f = 9.9999999999999992e+22 = #44b52d02 c7e14af6 -g_dfmt(0) gives 5 bytes: "1e+23" - -strtoId returns 17, consuming 4 bytes. -fI[0] = #44b52d02 c7e14af6 = 9.9999999999999992e+22 -fI[1] = #44b52d02 c7e14af7 = 1.0000000000000001e+23 -fI[0] == strtod - - -Input: 1e310 -strtod consumes 5 bytes and returns 163 with f = Infinity = #7ff00000 0 -g_dfmt(0) gives 8 bytes: "Infinity" - -strtoId returns 163, consuming 5 bytes. -fI[0] = #7fefffff ffffffff = 1.7976931348623157e+308 -fI[1] = #7ff00000 0 = Infinity -fI[1] == strtod - - -Input: 9.0259718793241475e-277 -strtod consumes 23 bytes and returns 33 with f = 9.0259718793241479e-277 = #6a00000 0 -g_dfmt(0) gives 22 bytes: "9.025971879324148e-277" - -strtoId returns 33, consuming 23 bytes. -fI[0] = #69fffff ffffffff = 9.0259718793241469e-277 -fI[1] = #6a00000 0 = 9.0259718793241479e-277 -fI[1] == strtod - - -Input: 9.025971879324147880346310405869e-277 -strtod consumes 37 bytes and returns 17 with f = 9.0259718793241479e-277 = #6a00000 0 -g_dfmt(0) gives 22 bytes: "9.025971879324148e-277" - -strtoId returns 17, consuming 37 bytes. -fI[0] = #6a00000 0 = 9.0259718793241479e-277 -fI[1] = #6a00000 1 = 9.0259718793241499e-277 -fI[0] == strtod - - -Input: 9.025971879324147880346310405868e-277 -strtod consumes 37 bytes and returns 33 with f = 9.0259718793241479e-277 = #6a00000 0 -g_dfmt(0) gives 22 bytes: "9.025971879324148e-277" - -strtoId returns 33, consuming 37 bytes. -fI[0] = #69fffff ffffffff = 9.0259718793241469e-277 -fI[1] = #6a00000 0 = 9.0259718793241479e-277 -fI[1] == strtod - - -Input: 2.2250738585072014e-308 -strtod consumes 23 bytes and returns 17 with f = 2.2250738585072014e-308 = #100000 0 -g_dfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoId returns 17, consuming 23 bytes. -fI[0] = #100000 0 = 2.2250738585072014e-308 -fI[1] = #100000 1 = 2.2250738585072019e-308 -fI[0] == strtod - - -Input: 2.2250738585072013e-308 -strtod consumes 23 bytes and returns 33 with f = 2.2250738585072014e-308 = #100000 0 -g_dfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoId returns 33, consuming 23 bytes. -fI[0] = #fffff ffffffff = 2.2250738585072009e-308 -fI[1] = #100000 0 = 2.2250738585072014e-308 -fI[1] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 -strtod consumes 3 bytes and returns 17 with f = 1.0999999999999999 = #3ff19999 99999999 -g_dfmt(0) gives 18 bytes: "1.0999999999999999" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff19999 99999999 = 1.0999999999999999 -fI[1] = #3ff19999 9999999a = 1.1000000000000001 -fI[0] == strtod - - -Input: -1.1 -strtod consumes 4 bytes and returns 25 with f = -1.0999999999999999 = #bff19999 99999999 -g_dfmt(0) gives 19 bytes: "-1.0999999999999999" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff19999 9999999a = -1.1000000000000001 -fI[1] = #bff19999 99999999 = -1.0999999999999999 -fI[1] == strtod - - -Input: 1.2 -strtod consumes 3 bytes and returns 17 with f = 1.2 = #3ff33333 33333333 -g_dfmt(0) gives 3 bytes: "1.2" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff33333 33333333 = 1.2 -fI[1] = #3ff33333 33333334 = 1.2000000000000002 -fI[0] == strtod - - -Input: -1.2 -strtod consumes 4 bytes and returns 25 with f = -1.2 = #bff33333 33333333 -g_dfmt(0) gives 4 bytes: "-1.2" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff33333 33333334 = -1.2000000000000002 -fI[1] = #bff33333 33333333 = -1.2 -fI[1] == strtod - - -Input: 1.3 -strtod consumes 3 bytes and returns 17 with f = 1.2999999999999998 = #3ff4cccc cccccccc -g_dfmt(0) gives 18 bytes: "1.2999999999999998" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff4cccc cccccccc = 1.2999999999999998 -fI[1] = #3ff4cccc cccccccd = 1.3 -fI[0] == strtod - - -Input: -1.3 -strtod consumes 4 bytes and returns 25 with f = -1.2999999999999998 = #bff4cccc cccccccc -g_dfmt(0) gives 19 bytes: "-1.2999999999999998" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff4cccc cccccccd = -1.3 -fI[1] = #bff4cccc cccccccc = -1.2999999999999998 -fI[1] == strtod - - -Input: 1.4 -strtod consumes 3 bytes and returns 17 with f = 1.3999999999999999 = #3ff66666 66666666 -g_dfmt(0) gives 3 bytes: "1.4" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff66666 66666666 = 1.3999999999999999 -fI[1] = #3ff66666 66666667 = 1.4000000000000001 -fI[0] == strtod - - -Input: -1.4 -strtod consumes 4 bytes and returns 25 with f = -1.3999999999999999 = #bff66666 66666666 -g_dfmt(0) gives 4 bytes: "-1.4" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff66666 66666667 = -1.4000000000000001 -fI[1] = #bff66666 66666666 = -1.3999999999999999 -fI[1] == strtod - - -Input: 1.5 -strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0 -g_dfmt(0) gives 3 bytes: "1.5" - -strtoId returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtod - - -Input: -1.5 -strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0 -g_dfmt(0) gives 4 bytes: "-1.5" - -strtoId returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtod - - -Input: 1.6 -strtod consumes 3 bytes and returns 17 with f = 1.5999999999999999 = #3ff99999 99999999 -g_dfmt(0) gives 18 bytes: "1.5999999999999999" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff99999 99999999 = 1.5999999999999999 -fI[1] = #3ff99999 9999999a = 1.6000000000000001 -fI[0] == strtod - - -Input: -1.6 -strtod consumes 4 bytes and returns 25 with f = -1.5999999999999999 = #bff99999 99999999 -g_dfmt(0) gives 19 bytes: "-1.5999999999999999" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff99999 9999999a = -1.6000000000000001 -fI[1] = #bff99999 99999999 = -1.5999999999999999 -fI[1] == strtod - - -Input: 1.7 -strtod consumes 3 bytes and returns 17 with f = 1.7 = #3ffb3333 33333333 -g_dfmt(0) gives 3 bytes: "1.7" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffb3333 33333333 = 1.7 -fI[1] = #3ffb3333 33333334 = 1.7000000000000002 -fI[0] == strtod - - -Input: -1.7 -strtod consumes 4 bytes and returns 25 with f = -1.7 = #bffb3333 33333333 -g_dfmt(0) gives 4 bytes: "-1.7" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffb3333 33333334 = -1.7000000000000002 -fI[1] = #bffb3333 33333333 = -1.7 -fI[1] == strtod - - -Input: 1.8 -strtod consumes 3 bytes and returns 17 with f = 1.7999999999999998 = #3ffccccc cccccccc -g_dfmt(0) gives 18 bytes: "1.7999999999999998" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ffccccc cccccccc = 1.7999999999999998 -fI[1] = #3ffccccc cccccccd = 1.8 -fI[0] == strtod - - -Input: -1.8 -strtod consumes 4 bytes and returns 25 with f = -1.7999999999999998 = #bffccccc cccccccc -g_dfmt(0) gives 19 bytes: "-1.7999999999999998" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bffccccc cccccccd = -1.8 -fI[1] = #bffccccc cccccccc = -1.7999999999999998 -fI[1] == strtod - - -Input: 1.9 -strtod consumes 3 bytes and returns 17 with f = 1.8999999999999999 = #3ffe6666 66666666 -g_dfmt(0) gives 3 bytes: "1.9" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffe6666 66666666 = 1.8999999999999999 -fI[1] = #3ffe6666 66666667 = 1.9000000000000001 -fI[0] == strtod - - -Input: -1.9 -strtod consumes 4 bytes and returns 25 with f = -1.8999999999999999 = #bffe6666 66666666 -g_dfmt(0) gives 4 bytes: "-1.9" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffe6666 66666667 = -1.9000000000000001 -fI[1] = #bffe6666 66666666 = -1.8999999999999999 -fI[1] == strtod - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 -strtod consumes 3 bytes and returns 33 with f = 1.1000000000000001 = #3ff19999 9999999a -g_dfmt(0) gives 3 bytes: "1.1" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff19999 99999999 = 1.0999999999999999 -fI[1] = #3ff19999 9999999a = 1.1000000000000001 -fI[1] == strtod - - -Input: -1.1 -strtod consumes 4 bytes and returns 41 with f = -1.1000000000000001 = #bff19999 9999999a -g_dfmt(0) gives 4 bytes: "-1.1" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff19999 9999999a = -1.1000000000000001 -fI[1] = #bff19999 99999999 = -1.0999999999999999 -fI[0] == strtod - - -Input: 1.2 -strtod consumes 3 bytes and returns 17 with f = 1.2 = #3ff33333 33333333 -g_dfmt(0) gives 3 bytes: "1.2" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff33333 33333333 = 1.2 -fI[1] = #3ff33333 33333334 = 1.2000000000000002 -fI[0] == strtod - - -Input: -1.2 -strtod consumes 4 bytes and returns 25 with f = -1.2 = #bff33333 33333333 -g_dfmt(0) gives 4 bytes: "-1.2" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff33333 33333334 = -1.2000000000000002 -fI[1] = #bff33333 33333333 = -1.2 -fI[1] == strtod - - -Input: 1.3 -strtod consumes 3 bytes and returns 33 with f = 1.3 = #3ff4cccc cccccccd -g_dfmt(0) gives 3 bytes: "1.3" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff4cccc cccccccc = 1.2999999999999998 -fI[1] = #3ff4cccc cccccccd = 1.3 -fI[1] == strtod - - -Input: -1.3 -strtod consumes 4 bytes and returns 41 with f = -1.3 = #bff4cccc cccccccd -g_dfmt(0) gives 4 bytes: "-1.3" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff4cccc cccccccd = -1.3 -fI[1] = #bff4cccc cccccccc = -1.2999999999999998 -fI[0] == strtod - - -Input: 1.4 -strtod consumes 3 bytes and returns 17 with f = 1.3999999999999999 = #3ff66666 66666666 -g_dfmt(0) gives 3 bytes: "1.4" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff66666 66666666 = 1.3999999999999999 -fI[1] = #3ff66666 66666667 = 1.4000000000000001 -fI[0] == strtod - - -Input: -1.4 -strtod consumes 4 bytes and returns 25 with f = -1.3999999999999999 = #bff66666 66666666 -g_dfmt(0) gives 4 bytes: "-1.4" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff66666 66666667 = -1.4000000000000001 -fI[1] = #bff66666 66666666 = -1.3999999999999999 -fI[1] == strtod - - -Input: 1.5 -strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0 -g_dfmt(0) gives 3 bytes: "1.5" - -strtoId returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtod - - -Input: -1.5 -strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0 -g_dfmt(0) gives 4 bytes: "-1.5" - -strtoId returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtod - - -Input: 1.6 -strtod consumes 3 bytes and returns 33 with f = 1.6000000000000001 = #3ff99999 9999999a -g_dfmt(0) gives 3 bytes: "1.6" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff99999 99999999 = 1.5999999999999999 -fI[1] = #3ff99999 9999999a = 1.6000000000000001 -fI[1] == strtod - - -Input: -1.6 -strtod consumes 4 bytes and returns 41 with f = -1.6000000000000001 = #bff99999 9999999a -g_dfmt(0) gives 4 bytes: "-1.6" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff99999 9999999a = -1.6000000000000001 -fI[1] = #bff99999 99999999 = -1.5999999999999999 -fI[0] == strtod - - -Input: 1.7 -strtod consumes 3 bytes and returns 17 with f = 1.7 = #3ffb3333 33333333 -g_dfmt(0) gives 3 bytes: "1.7" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffb3333 33333333 = 1.7 -fI[1] = #3ffb3333 33333334 = 1.7000000000000002 -fI[0] == strtod - - -Input: -1.7 -strtod consumes 4 bytes and returns 25 with f = -1.7 = #bffb3333 33333333 -g_dfmt(0) gives 4 bytes: "-1.7" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffb3333 33333334 = -1.7000000000000002 -fI[1] = #bffb3333 33333333 = -1.7 -fI[1] == strtod - - -Input: 1.8 -strtod consumes 3 bytes and returns 33 with f = 1.8 = #3ffccccc cccccccd -g_dfmt(0) gives 3 bytes: "1.8" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ffccccc cccccccc = 1.7999999999999998 -fI[1] = #3ffccccc cccccccd = 1.8 -fI[1] == strtod - - -Input: -1.8 -strtod consumes 4 bytes and returns 41 with f = -1.8 = #bffccccc cccccccd -g_dfmt(0) gives 4 bytes: "-1.8" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bffccccc cccccccd = -1.8 -fI[1] = #bffccccc cccccccc = -1.7999999999999998 -fI[0] == strtod - - -Input: 1.9 -strtod consumes 3 bytes and returns 17 with f = 1.8999999999999999 = #3ffe6666 66666666 -g_dfmt(0) gives 3 bytes: "1.9" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffe6666 66666666 = 1.8999999999999999 -fI[1] = #3ffe6666 66666667 = 1.9000000000000001 -fI[0] == strtod - - -Input: -1.9 -strtod consumes 4 bytes and returns 25 with f = -1.8999999999999999 = #bffe6666 66666666 -g_dfmt(0) gives 4 bytes: "-1.9" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffe6666 66666667 = -1.9000000000000001 -fI[1] = #bffe6666 66666666 = -1.8999999999999999 -fI[1] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 -strtod consumes 3 bytes and returns 33 with f = 1.1000000000000001 = #3ff19999 9999999a -g_dfmt(0) gives 3 bytes: "1.1" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff19999 99999999 = 1.0999999999999999 -fI[1] = #3ff19999 9999999a = 1.1000000000000001 -fI[1] == strtod - - -Input: -1.1 -strtod consumes 4 bytes and returns 25 with f = -1.0999999999999999 = #bff19999 99999999 -g_dfmt(0) gives 19 bytes: "-1.0999999999999999" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff19999 9999999a = -1.1000000000000001 -fI[1] = #bff19999 99999999 = -1.0999999999999999 -fI[1] == strtod - - -Input: 1.2 -strtod consumes 3 bytes and returns 33 with f = 1.2000000000000002 = #3ff33333 33333334 -g_dfmt(0) gives 18 bytes: "1.2000000000000002" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff33333 33333333 = 1.2 -fI[1] = #3ff33333 33333334 = 1.2000000000000002 -fI[1] == strtod - - -Input: -1.2 -strtod consumes 4 bytes and returns 25 with f = -1.2 = #bff33333 33333333 -g_dfmt(0) gives 4 bytes: "-1.2" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff33333 33333334 = -1.2000000000000002 -fI[1] = #bff33333 33333333 = -1.2 -fI[1] == strtod - - -Input: 1.3 -strtod consumes 3 bytes and returns 33 with f = 1.3 = #3ff4cccc cccccccd -g_dfmt(0) gives 3 bytes: "1.3" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff4cccc cccccccc = 1.2999999999999998 -fI[1] = #3ff4cccc cccccccd = 1.3 -fI[1] == strtod - - -Input: -1.3 -strtod consumes 4 bytes and returns 25 with f = -1.2999999999999998 = #bff4cccc cccccccc -g_dfmt(0) gives 19 bytes: "-1.2999999999999998" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff4cccc cccccccd = -1.3 -fI[1] = #bff4cccc cccccccc = -1.2999999999999998 -fI[1] == strtod - - -Input: 1.4 -strtod consumes 3 bytes and returns 33 with f = 1.4000000000000001 = #3ff66666 66666667 -g_dfmt(0) gives 18 bytes: "1.4000000000000001" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff66666 66666666 = 1.3999999999999999 -fI[1] = #3ff66666 66666667 = 1.4000000000000001 -fI[1] == strtod - - -Input: -1.4 -strtod consumes 4 bytes and returns 25 with f = -1.3999999999999999 = #bff66666 66666666 -g_dfmt(0) gives 4 bytes: "-1.4" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff66666 66666667 = -1.4000000000000001 -fI[1] = #bff66666 66666666 = -1.3999999999999999 -fI[1] == strtod - - -Input: 1.5 -strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0 -g_dfmt(0) gives 3 bytes: "1.5" - -strtoId returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtod - - -Input: -1.5 -strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0 -g_dfmt(0) gives 4 bytes: "-1.5" - -strtoId returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtod - - -Input: 1.6 -strtod consumes 3 bytes and returns 33 with f = 1.6000000000000001 = #3ff99999 9999999a -g_dfmt(0) gives 3 bytes: "1.6" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff99999 99999999 = 1.5999999999999999 -fI[1] = #3ff99999 9999999a = 1.6000000000000001 -fI[1] == strtod - - -Input: -1.6 -strtod consumes 4 bytes and returns 25 with f = -1.5999999999999999 = #bff99999 99999999 -g_dfmt(0) gives 19 bytes: "-1.5999999999999999" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff99999 9999999a = -1.6000000000000001 -fI[1] = #bff99999 99999999 = -1.5999999999999999 -fI[1] == strtod - - -Input: 1.7 -strtod consumes 3 bytes and returns 33 with f = 1.7000000000000002 = #3ffb3333 33333334 -g_dfmt(0) gives 18 bytes: "1.7000000000000002" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffb3333 33333333 = 1.7 -fI[1] = #3ffb3333 33333334 = 1.7000000000000002 -fI[1] == strtod - - -Input: -1.7 -strtod consumes 4 bytes and returns 25 with f = -1.7 = #bffb3333 33333333 -g_dfmt(0) gives 4 bytes: "-1.7" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffb3333 33333334 = -1.7000000000000002 -fI[1] = #bffb3333 33333333 = -1.7 -fI[1] == strtod - - -Input: 1.8 -strtod consumes 3 bytes and returns 33 with f = 1.8 = #3ffccccc cccccccd -g_dfmt(0) gives 3 bytes: "1.8" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ffccccc cccccccc = 1.7999999999999998 -fI[1] = #3ffccccc cccccccd = 1.8 -fI[1] == strtod - - -Input: -1.8 -strtod consumes 4 bytes and returns 25 with f = -1.7999999999999998 = #bffccccc cccccccc -g_dfmt(0) gives 19 bytes: "-1.7999999999999998" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bffccccc cccccccd = -1.8 -fI[1] = #bffccccc cccccccc = -1.7999999999999998 -fI[1] == strtod - - -Input: 1.9 -strtod consumes 3 bytes and returns 33 with f = 1.9000000000000001 = #3ffe6666 66666667 -g_dfmt(0) gives 18 bytes: "1.9000000000000001" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffe6666 66666666 = 1.8999999999999999 -fI[1] = #3ffe6666 66666667 = 1.9000000000000001 -fI[1] == strtod - - -Input: -1.9 -strtod consumes 4 bytes and returns 25 with f = -1.8999999999999999 = #bffe6666 66666666 -g_dfmt(0) gives 4 bytes: "-1.9" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffe6666 66666667 = -1.9000000000000001 -fI[1] = #bffe6666 66666666 = -1.8999999999999999 -fI[1] == strtod - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 -strtod consumes 3 bytes and returns 17 with f = 1.0999999999999999 = #3ff19999 99999999 -g_dfmt(0) gives 18 bytes: "1.0999999999999999" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff19999 99999999 = 1.0999999999999999 -fI[1] = #3ff19999 9999999a = 1.1000000000000001 -fI[0] == strtod - - -Input: -1.1 -strtod consumes 4 bytes and returns 41 with f = -1.1000000000000001 = #bff19999 9999999a -g_dfmt(0) gives 4 bytes: "-1.1" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff19999 9999999a = -1.1000000000000001 -fI[1] = #bff19999 99999999 = -1.0999999999999999 -fI[0] == strtod - - -Input: 1.2 -strtod consumes 3 bytes and returns 17 with f = 1.2 = #3ff33333 33333333 -g_dfmt(0) gives 3 bytes: "1.2" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff33333 33333333 = 1.2 -fI[1] = #3ff33333 33333334 = 1.2000000000000002 -fI[0] == strtod - - -Input: -1.2 -strtod consumes 4 bytes and returns 41 with f = -1.2000000000000002 = #bff33333 33333334 -g_dfmt(0) gives 19 bytes: "-1.2000000000000002" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff33333 33333334 = -1.2000000000000002 -fI[1] = #bff33333 33333333 = -1.2 -fI[0] == strtod - - -Input: 1.3 -strtod consumes 3 bytes and returns 17 with f = 1.2999999999999998 = #3ff4cccc cccccccc -g_dfmt(0) gives 18 bytes: "1.2999999999999998" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff4cccc cccccccc = 1.2999999999999998 -fI[1] = #3ff4cccc cccccccd = 1.3 -fI[0] == strtod - - -Input: -1.3 -strtod consumes 4 bytes and returns 41 with f = -1.3 = #bff4cccc cccccccd -g_dfmt(0) gives 4 bytes: "-1.3" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff4cccc cccccccd = -1.3 -fI[1] = #bff4cccc cccccccc = -1.2999999999999998 -fI[0] == strtod - - -Input: 1.4 -strtod consumes 3 bytes and returns 17 with f = 1.3999999999999999 = #3ff66666 66666666 -g_dfmt(0) gives 3 bytes: "1.4" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ff66666 66666666 = 1.3999999999999999 -fI[1] = #3ff66666 66666667 = 1.4000000000000001 -fI[0] == strtod - - -Input: -1.4 -strtod consumes 4 bytes and returns 41 with f = -1.4000000000000001 = #bff66666 66666667 -g_dfmt(0) gives 19 bytes: "-1.4000000000000001" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bff66666 66666667 = -1.4000000000000001 -fI[1] = #bff66666 66666666 = -1.3999999999999999 -fI[0] == strtod - - -Input: 1.5 -strtod consumes 3 bytes and returns 1 with f = 1.5 = #3ff80000 0 -g_dfmt(0) gives 3 bytes: "1.5" - -strtoId returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtod - - -Input: -1.5 -strtod consumes 4 bytes and returns 9 with f = -1.5 = #bff80000 0 -g_dfmt(0) gives 4 bytes: "-1.5" - -strtoId returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtod - - -Input: 1.6 -strtod consumes 3 bytes and returns 17 with f = 1.5999999999999999 = #3ff99999 99999999 -g_dfmt(0) gives 18 bytes: "1.5999999999999999" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ff99999 99999999 = 1.5999999999999999 -fI[1] = #3ff99999 9999999a = 1.6000000000000001 -fI[0] == strtod - - -Input: -1.6 -strtod consumes 4 bytes and returns 41 with f = -1.6000000000000001 = #bff99999 9999999a -g_dfmt(0) gives 4 bytes: "-1.6" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bff99999 9999999a = -1.6000000000000001 -fI[1] = #bff99999 99999999 = -1.5999999999999999 -fI[0] == strtod - - -Input: 1.7 -strtod consumes 3 bytes and returns 17 with f = 1.7 = #3ffb3333 33333333 -g_dfmt(0) gives 3 bytes: "1.7" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffb3333 33333333 = 1.7 -fI[1] = #3ffb3333 33333334 = 1.7000000000000002 -fI[0] == strtod - - -Input: -1.7 -strtod consumes 4 bytes and returns 41 with f = -1.7000000000000002 = #bffb3333 33333334 -g_dfmt(0) gives 19 bytes: "-1.7000000000000002" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffb3333 33333334 = -1.7000000000000002 -fI[1] = #bffb3333 33333333 = -1.7 -fI[0] == strtod - - -Input: 1.8 -strtod consumes 3 bytes and returns 17 with f = 1.7999999999999998 = #3ffccccc cccccccc -g_dfmt(0) gives 18 bytes: "1.7999999999999998" - -strtoId returns 33, consuming 3 bytes. -fI[0] = #3ffccccc cccccccc = 1.7999999999999998 -fI[1] = #3ffccccc cccccccd = 1.8 -fI[0] == strtod - - -Input: -1.8 -strtod consumes 4 bytes and returns 41 with f = -1.8 = #bffccccc cccccccd -g_dfmt(0) gives 4 bytes: "-1.8" - -strtoId returns 41, consuming 4 bytes. -fI[0] = #bffccccc cccccccd = -1.8 -fI[1] = #bffccccc cccccccc = -1.7999999999999998 -fI[0] == strtod - - -Input: 1.9 -strtod consumes 3 bytes and returns 17 with f = 1.8999999999999999 = #3ffe6666 66666666 -g_dfmt(0) gives 3 bytes: "1.9" - -strtoId returns 17, consuming 3 bytes. -fI[0] = #3ffe6666 66666666 = 1.8999999999999999 -fI[1] = #3ffe6666 66666667 = 1.9000000000000001 -fI[0] == strtod - - -Input: -1.9 -strtod consumes 4 bytes and returns 41 with f = -1.9000000000000001 = #bffe6666 66666667 -g_dfmt(0) gives 19 bytes: "-1.9000000000000001" - -strtoId returns 25, consuming 4 bytes. -fI[0] = #bffe6666 66666667 = -1.9000000000000001 -fI[1] = #bffe6666 66666666 = -1.8999999999999999 -fI[0] == strtod - diff --git a/lib/libc/gdtoa/test/dI.out b/lib/libc/gdtoa/test/dI.out deleted file mode 100644 index b4070de80..000000000 --- a/lib/libc/gdtoa/test/dI.out +++ /dev/null @@ -1,168 +0,0 @@ - -Input: 1.23 -strtodI consumes 4 bytes and returns 17 -dd[0] = #3ff3ae14 7ae147ae = 1.23 -dd[1] = #3ff3ae14 7ae147af = 1.2300000000000002 - - -Input: 1.23e+20 -strtodI consumes 8 bytes and returns 1 -dd[0] = #441aabdf 2145b430 = 1.23e+20 -dd[1] = #441aabdf 2145b430 = 1.23e+20 - - -Input: 1.23e-20 -strtodI consumes 8 bytes and returns 33 -dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20 -dd[1] = #3bcd0ae4 cf767531 = 1.23e-20 - - -Input: 1.23456789 -strtodI consumes 10 bytes and returns 17 -dd[0] = #3ff3c0ca 4283de1b = 1.23456789 -dd[1] = #3ff3c0ca 4283de1c = 1.2345678900000001 - - -Input: 1.23456589e+20 -strtodI consumes 14 bytes and returns 17 -dd[0] = #441ac537 a660b997 = 1.23456589e+20 -dd[1] = #441ac537 a660b998 = 123456589000000010000 - - -Input: 1.23e+30 -strtodI consumes 8 bytes and returns 17 -dd[0] = #462f0cb0 4e8fb790 = 1.23e+30 -dd[1] = #462f0cb0 4e8fb791 = 1.2300000000000001e+30 - - -Input: 1.23e-30 -strtodI consumes 8 bytes and returns 33 -dd[0] = #39b8f286 6f5010aa = 1.2299999999999999e-30 -dd[1] = #39b8f286 6f5010ab = 1.23e-30 - - -Input: 1.23456789e-20 -strtodI consumes 14 bytes and returns 17 -dd[0] = #3bcd2681 471e7ada = 1.23456789e-20 -dd[1] = #3bcd2681 471e7adb = 1.2345678900000001e-20 - - -Input: 1.23456789e-30 -strtodI consumes 14 bytes and returns 17 -dd[0] = #39b90a3e 33bbd995 = 1.23456789e-30 -dd[1] = #39b90a3e 33bbd996 = 1.2345678900000002e-30 - - -Input: 1.234567890123456789 -strtodI consumes 20 bytes and returns 17 -dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457 - - -Input: 1.23456789012345678901234567890123456789 -strtodI consumes 40 bytes and returns 17 -dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457 - - -Input: 1.23e306 -strtodI consumes 8 bytes and returns 33 -dd[0] = #7f7c0676 cd1c61f4 = 1.2299999999999999e+306 -dd[1] = #7f7c0676 cd1c61f5 = 1.23e+306 - - -Input: 1.23e-306 -strtodI consumes 9 bytes and returns 33 -dd[0] = #6ba3b8 5da396e7 = 1.2299999999999999e-306 -dd[1] = #6ba3b8 5da396e8 = 1.23e-306 - - -Input: 1.23e-320 -strtodI consumes 9 bytes and returns 98 -dd[0] = #0 9b9 = 1.2297e-320 -dd[1] = #0 9ba = 1.23e-320 - - -Input: 1.23e-20 -strtodI consumes 8 bytes and returns 33 -dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20 -dd[1] = #3bcd0ae4 cf767531 = 1.23e-20 - - -Input: 1.23456789e307 -strtodI consumes 14 bytes and returns 33 -dd[0] = #7fb194b1 4bdaecdb = 1.2345678899999998e+307 -dd[1] = #7fb194b1 4bdaecdc = 1.23456789e+307 - - -Input: 1.23456589e-307 -strtodI consumes 15 bytes and returns 17 -dd[0] = #363196 bb9845fa = 1.23456589e-307 -dd[1] = #363196 bb9845fb = 1.2345658900000001e-307 - - -Input: 1.234567890123456789 -strtodI consumes 20 bytes and returns 17 -dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457 - - -Input: 1.234567890123456789e301 -strtodI consumes 24 bytes and returns 17 -dd[0] = #7e726f51 75f56413 = 1.2345678901234568e+301 -dd[1] = #7e726f51 75f56414 = 1.234567890123457e+301 - - -Input: 1.234567890123456789e-301 -strtodI consumes 25 bytes and returns 17 -dd[0] = #1752a64 e34ba0d3 = 1.2345678901234567e-301 -dd[1] = #1752a64 e34ba0d4 = 1.234567890123457e-301 - - -Input: 1.234567890123456789e-321 -strtodI consumes 25 bytes and returns 98 -dd[0] = #0 f9 = 1.23e-321 -dd[1] = #0 fa = 1.235e-321 - - -Input: 1e23 -strtodI consumes 4 bytes and returns 17 -dd[0] = #44b52d02 c7e14af6 = 1e+23 -dd[1] = #44b52d02 c7e14af7 = 1.0000000000000001e+23 - - -Input: 1e310 -strtodI consumes 5 bytes and returns 163 -dd[0] = #7fefffff ffffffff = 1.7976931348623157e+308 -dd[1] = #7ff00000 0 = Infinity - - -Input: 9.0259718793241475e-277 -strtodI consumes 23 bytes and returns 33 -dd[0] = #69fffff ffffffff = 9.025971879324147e-277 -dd[1] = #6a00000 0 = 9.025971879324148e-277 - - -Input: 9.025971879324147880346310405869e-277 -strtodI consumes 37 bytes and returns 17 -dd[0] = #6a00000 0 = 9.025971879324148e-277 -dd[1] = #6a00000 1 = 9.02597187932415e-277 - - -Input: 9.025971879324147880346310405868e-277 -strtodI consumes 37 bytes and returns 33 -dd[0] = #69fffff ffffffff = 9.025971879324147e-277 -dd[1] = #6a00000 0 = 9.025971879324148e-277 - - -Input: 2.2250738585072014e-308 -strtodI consumes 23 bytes and returns 17 -dd[0] = #100000 0 = 2.2250738585072014e-308 -dd[1] = #100000 1 = 2.225073858507202e-308 - - -Input: 2.2250738585072013e-308 -strtodI consumes 23 bytes and returns 33 -dd[0] = #fffff ffffffff = 2.225073858507201e-308 -dd[1] = #100000 0 = 2.2250738585072014e-308 - diff --git a/lib/libc/gdtoa/test/dIsi.out b/lib/libc/gdtoa/test/dIsi.out deleted file mode 100644 index 3388a1a4b..000000000 --- a/lib/libc/gdtoa/test/dIsi.out +++ /dev/null @@ -1,168 +0,0 @@ - -Input: 1.23 -strtodI consumes 4 bytes and returns 17 -dd[0] = #3ff3ae14 7ae147ae = 1.23 -dd[1] = #3ff3ae14 7ae147af = 1.2300000000000002 - - -Input: 1.23e+20 -strtodI consumes 8 bytes and returns 1 -dd[0] = #441aabdf 2145b430 = 1.23e+20 -dd[1] = #441aabdf 2145b430 = 1.23e+20 - - -Input: 1.23e-20 -strtodI consumes 8 bytes and returns 33 -dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20 -dd[1] = #3bcd0ae4 cf767531 = 1.23e-20 - - -Input: 1.23456789 -strtodI consumes 10 bytes and returns 17 -dd[0] = #3ff3c0ca 4283de1b = 1.23456789 -dd[1] = #3ff3c0ca 4283de1c = 1.2345678900000001 - - -Input: 1.23456589e+20 -strtodI consumes 14 bytes and returns 17 -dd[0] = #441ac537 a660b997 = 1.23456589e+20 -dd[1] = #441ac537 a660b998 = 123456589000000010000 - - -Input: 1.23e+30 -strtodI consumes 8 bytes and returns 17 -dd[0] = #462f0cb0 4e8fb790 = 1.23e+30 -dd[1] = #462f0cb0 4e8fb791 = 1.2300000000000001e+30 - - -Input: 1.23e-30 -strtodI consumes 8 bytes and returns 33 -dd[0] = #39b8f286 6f5010aa = 1.2299999999999999e-30 -dd[1] = #39b8f286 6f5010ab = 1.23e-30 - - -Input: 1.23456789e-20 -strtodI consumes 14 bytes and returns 17 -dd[0] = #3bcd2681 471e7ada = 1.23456789e-20 -dd[1] = #3bcd2681 471e7adb = 1.2345678900000001e-20 - - -Input: 1.23456789e-30 -strtodI consumes 14 bytes and returns 17 -dd[0] = #39b90a3e 33bbd995 = 1.23456789e-30 -dd[1] = #39b90a3e 33bbd996 = 1.2345678900000002e-30 - - -Input: 1.234567890123456789 -strtodI consumes 20 bytes and returns 17 -dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457 - - -Input: 1.23456789012345678901234567890123456789 -strtodI consumes 40 bytes and returns 17 -dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457 - - -Input: 1.23e306 -strtodI consumes 8 bytes and returns 33 -dd[0] = #7f7c0676 cd1c61f4 = 1.2299999999999999e+306 -dd[1] = #7f7c0676 cd1c61f5 = 1.23e+306 - - -Input: 1.23e-306 -strtodI consumes 9 bytes and returns 33 -dd[0] = #6ba3b8 5da396e7 = 1.2299999999999999e-306 -dd[1] = #6ba3b8 5da396e8 = 1.23e-306 - - -Input: 1.23e-320 -strtodI consumes 9 bytes and returns 80 -dd[0] = #0 0 = 0 -dd[1] = #100000 0 = 2.2250738585072014e-308 - - -Input: 1.23e-20 -strtodI consumes 8 bytes and returns 33 -dd[0] = #3bcd0ae4 cf767530 = 1.2299999999999999e-20 -dd[1] = #3bcd0ae4 cf767531 = 1.23e-20 - - -Input: 1.23456789e307 -strtodI consumes 14 bytes and returns 33 -dd[0] = #7fb194b1 4bdaecdb = 1.2345678899999998e+307 -dd[1] = #7fb194b1 4bdaecdc = 1.23456789e+307 - - -Input: 1.23456589e-307 -strtodI consumes 15 bytes and returns 17 -dd[0] = #363196 bb9845fa = 1.23456589e-307 -dd[1] = #363196 bb9845fb = 1.2345658900000001e-307 - - -Input: 1.234567890123456789 -strtodI consumes 20 bytes and returns 17 -dd[0] = #3ff3c0ca 428c59fb = 1.2345678901234567 -dd[1] = #3ff3c0ca 428c59fc = 1.234567890123457 - - -Input: 1.234567890123456789e301 -strtodI consumes 24 bytes and returns 17 -dd[0] = #7e726f51 75f56413 = 1.2345678901234568e+301 -dd[1] = #7e726f51 75f56414 = 1.234567890123457e+301 - - -Input: 1.234567890123456789e-301 -strtodI consumes 25 bytes and returns 17 -dd[0] = #1752a64 e34ba0d3 = 1.2345678901234567e-301 -dd[1] = #1752a64 e34ba0d4 = 1.234567890123457e-301 - - -Input: 1.234567890123456789e-321 -strtodI consumes 25 bytes and returns 80 -dd[0] = #0 0 = 0 -dd[1] = #100000 0 = 2.2250738585072014e-308 - - -Input: 1e23 -strtodI consumes 4 bytes and returns 17 -dd[0] = #44b52d02 c7e14af6 = 1e+23 -dd[1] = #44b52d02 c7e14af7 = 1.0000000000000001e+23 - - -Input: 1e310 -strtodI consumes 5 bytes and returns 163 -dd[0] = #7fefffff ffffffff = 1.7976931348623157e+308 -dd[1] = #7ff00000 0 = Infinity - - -Input: 9.0259718793241475e-277 -strtodI consumes 23 bytes and returns 33 -dd[0] = #69fffff ffffffff = 9.025971879324147e-277 -dd[1] = #6a00000 0 = 9.025971879324148e-277 - - -Input: 9.025971879324147880346310405869e-277 -strtodI consumes 37 bytes and returns 17 -dd[0] = #6a00000 0 = 9.025971879324148e-277 -dd[1] = #6a00000 1 = 9.02597187932415e-277 - - -Input: 9.025971879324147880346310405868e-277 -strtodI consumes 37 bytes and returns 33 -dd[0] = #69fffff ffffffff = 9.025971879324147e-277 -dd[1] = #6a00000 0 = 9.025971879324148e-277 - - -Input: 2.2250738585072014e-308 -strtodI consumes 23 bytes and returns 17 -dd[0] = #100000 0 = 2.2250738585072014e-308 -dd[1] = #100000 1 = 2.225073858507202e-308 - - -Input: 2.2250738585072013e-308 -strtodI consumes 23 bytes and returns 33 -dd[0] = #0 0 = 0 -dd[1] = #100000 0 = 2.2250738585072014e-308 - diff --git a/lib/libc/gdtoa/test/dItest.c b/lib/libc/gdtoa/test/dItest.c deleted file mode 100644 index 1724c7153..000000000 --- a/lib/libc/gdtoa/test/dItest.c +++ /dev/null @@ -1,82 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" -#include -#include - - static char ibuf[2048]; - -#define U (unsigned long) - - static void -#ifdef KR_headers -dshow(what, d) char *what; double d; -#else -dshow(char *what, double d) -#endif -{ - char buf[32]; - g_dfmt(buf, &d, 0, sizeof(buf)); - printf("%s = #%lx %lx = %s\n", what, - U ((ULong*)&d)[_0], U ((ULong*)&d)[_1], buf); - } - - int -main(Void) -{ - /* Input: one number per line */ - - char *s, *se, *se1; - int i, j; - double dd[2], dd1, dd2; - static char cfmt[] = "%s consumes %d bytes and returns %d\n"; - - while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) { - while(*s <= ' ') - if (!*s++) - continue; - printf("\nInput: %s", ibuf); - i = strtodI(ibuf, &se, dd); - printf(cfmt, "strtodI", (int)(se-ibuf), i); - dshow("dd[0]", dd[0]); - dshow("dd[1]", dd[1]); - printf("\n"); - j = strtoId(ibuf, &se1, &dd1, &dd2); - if (j != i || se != se1 - || dd[0] != dd1 || dd[1] != dd2) { - printf(cfmt, "**** strtoId", (int)(se-ibuf), j); - dshow("dd1", dd1); - dshow("dd2", dd2); - } - } - return 0; - } diff --git a/lib/libc/gdtoa/test/dd.out b/lib/libc/gdtoa/test/dd.out deleted file mode 100644 index b1d274447..000000000 --- a/lib/libc/gdtoa/test/dd.out +++ /dev/null @@ -1,1356 +0,0 @@ - -Input: 1.23 -strtopdd consumes 4 bytes and returns 17 -dd[0] = 1.23 = #3ff3ae14 7ae147ae -dd[1] = 1.7763568394002496e-17 = #3c747ae1 47ae1478 -g_ddfmt(0) gives 4 bytes: "1.23" - -strtoIdd returns 17, consuming 4 bytes. -ddI[0] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1478 -= 1.23 + 1.7763568394002496e-17 -ddI[1] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1480 -= 1.23 + 1.776356839400252e-17 -ddI[0] == strtod - - -Input: 1.23e+20 -strtopdd consumes 8 bytes and returns 1 -dd[0] = 1.23e+20 = #441aabdf 2145b430 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 8 bytes: "1.23e+20" - -strtoIdd returns 1, consuming 8 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.23e-20 -strtopdd consumes 8 bytes and returns 33 -dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530 -dd[1] = 9.304023318521521e-37 = #3873c997 955b2691 -g_ddfmt(0) gives 8 bytes: "1.23e-20" - -strtoIdd returns 33, consuming 8 bytes. -ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690 -= 1.2299999999999999e-20 + 9.3040233185215194e-37 -ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691 -= 1.2299999999999999e-20 + 9.3040233185215211e-37 -ddI[1] == strtod - - -Input: 1.23456789 -strtopdd consumes 10 bytes and returns 17 -dd[0] = 1.23456789 = #3ff3c0ca 4283de1b -dd[1] = 1.0990618193318369e-16 = #3c9fada5 144c1252 -g_ddfmt(0) gives 10 bytes: "1.23456789" - -strtoIdd returns 17, consuming 10 bytes. -ddI[0] = #3ff3c0ca 4283de1b + 3c9fada5 144c1252 -= 1.2345678899999999 + 1.0990618193318369e-16 -ddI[1] = #3ff3c0ca 4283de1b + 3c9fada5 144c1254 -= 1.2345678899999999 + 1.0990618193318371e-16 -ddI[0] == strtod - - -Input: 1.23456589e+20 -strtopdd consumes 14 bytes and returns 1 -dd[0] = 1.23456589e+20 = #441ac537 a660b997 -dd[1] = 4096 = #40b00000 0 -g_ddfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIdd returns 1, consuming 14 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.23e+30 -strtopdd consumes 8 bytes and returns 1 -dd[0] = 1.23e+30 = #462f0cb0 4e8fb790 -dd[1] = 40281156091904 = #42c25158 0 -g_ddfmt(0) gives 8 bytes: "1.23e+30" - -strtoIdd returns 1, consuming 8 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.23e-30 -strtopdd consumes 8 bytes and returns 17 -dd[0] = 1.2299999999999999e-30 = #39b8f286 6f5010aa -dd[1] = 1.076909723013918e-46 = #3663ac7f 3dafd174 -g_ddfmt(0) gives 8 bytes: "1.23e-30" - -strtoIdd returns 17, consuming 8 bytes. -ddI[0] = #39b8f286 6f5010aa + 3663ac7f 3dafd174 -= 1.2299999999999999e-30 + 1.076909723013918e-46 -ddI[1] = #39b8f286 6f5010aa + 3663ac7f 3dafd175 -= 1.2299999999999999e-30 + 1.0769097230139181e-46 -ddI[0] == strtod - - -Input: 1.23456789e-20 -strtopdd consumes 14 bytes and returns 17 -dd[0] = 1.23456789e-20 = #3bcd2681 471e7ada -dd[1] = 6.247111971663133e-37 = #386a9280 a761b07e -g_ddfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIdd returns 17, consuming 14 bytes. -ddI[0] = #3bcd2681 471e7ada + 386a9280 a761b07e -= 1.2345678899999999e-20 + 6.2471119716631328e-37 -ddI[1] = #3bcd2681 471e7ada + 386a9280 a761b080 -= 1.2345678899999999e-20 + 6.2471119716631345e-37 -ddI[0] == strtod - - -Input: 1.23456789e-30 -strtopdd consumes 14 bytes and returns 33 -dd[0] = 1.23456789e-30 = #39b90a3e 33bbd995 -dd[1] = 2.1567930523648577e-47 = #363f8585 55a6b1a0 -g_ddfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIdd returns 33, consuming 14 bytes. -ddI[0] = #39b90a3e 33bbd995 + 363f8585 55a6b198 -= 1.23456789e-30 + 2.1567930523648558e-47 -ddI[1] = #39b90a3e 33bbd995 + 363f8585 55a6b1a0 -= 1.23456789e-30 + 2.1567930523648577e-47 -ddI[1] == strtod - - -Input: 1.234567890123456789 -strtopdd consumes 20 bytes and returns 33 -dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb -dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e -g_ddfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIdd returns 33, consuming 20 bytes. -ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c -= 1.2345678901234567 + 9.8567864525888563e-17 -ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e -= 1.2345678901234567 + 9.8567864525888588e-17 -ddI[1] == strtod - - -Input: 1.23456789012345678901234567890123456789 -strtopdd consumes 40 bytes and returns 33 -dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb -dd[1] = 9.858021020478982e-17 = #3c9c69ef 85adadb6 -g_ddfmt(0) gives 34 bytes: "1.23456789012345678901234567890124" - -strtoIdd returns 33, consuming 40 bytes. -ddI[0] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb4 -= 1.2345678901234567 + 9.8580210204789798e-17 -ddI[1] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb6 -= 1.2345678901234567 + 9.8580210204789823e-17 -ddI[1] == strtod - - -Input: 1.23e306 -strtopdd consumes 8 bytes and returns 33 -dd[0] = 1.2299999999999999e+306 = #7f7c0676 cd1c61f4 -dd[1] = 1.3319001448659015e+290 = #7c2b558b e3d3f477 -g_ddfmt(0) gives 9 bytes: "1.23e+306" - -strtoIdd returns 33, consuming 8 bytes. -ddI[0] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f476 -= 1.2299999999999999e+306 + 1.3319001448659013e+290 -ddI[1] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f477 -= 1.2299999999999999e+306 + 1.3319001448659015e+290 -ddI[1] == strtod - - -Input: 1.23e-306 -strtopdd consumes 9 bytes and returns 98 -dd[0] = 1.2299999999999999e-306 = #6ba3b8 5da396e7 -dd[1] = 1.43e-322 = #0 1d -g_ddfmt(0) gives 9 bytes: "1.23e-306" - -strtoIdd returns 98, consuming 9 bytes. -ddI[0] = #6ba3b8 5da396e7 + 0 1c -= 1.2299999999999999e-306 + 1.3833838083554903e-322 -ddI[1] = #6ba3b8 5da396e7 + 0 1d -= 1.2299999999999999e-306 + 1.432790372939615e-322 -ddI[1] == strtod - - -Input: 1.23e-320 -strtopdd consumes 9 bytes and returns 98 -dd[0] = 1.23e-320 = #0 9ba -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 9 bytes: "1.23e-320" - -strtoIdd returns 98, consuming 9 bytes. -ddI[0] = #0 9b9 + 0 0 -= 1.2297293924988626e-320 + 0 -ddI[1] = #0 9ba + 0 0 -= 1.2302234581447039e-320 + 0 -ddI[1] == strtod - - -Input: 1.23e-20 -strtopdd consumes 8 bytes and returns 33 -dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530 -dd[1] = 9.304023318521521e-37 = #3873c997 955b2691 -g_ddfmt(0) gives 8 bytes: "1.23e-20" - -strtoIdd returns 33, consuming 8 bytes. -ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690 -= 1.2299999999999999e-20 + 9.3040233185215194e-37 -ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691 -= 1.2299999999999999e-20 + 9.3040233185215211e-37 -ddI[1] == strtod - - -Input: 1.23456789e307 -strtopdd consumes 14 bytes and returns 33 -dd[0] = 1.2345678899999998e+307 = #7fb194b1 4bdaecdb -dd[1] = 2.0137933598720243e+291 = #7c69d48d 192048ca -g_ddfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIdd returns 33, consuming 14 bytes. -ddI[0] = #7fb194b1 4bdaecdb + 7c69d48d 192048c9 -= 1.2345678899999998e+307 + 2.013793359872024e+291 -ddI[1] = #7fb194b1 4bdaecdb + 7c69d48d 192048ca -= 1.2345678899999998e+307 + 2.0137933598720243e+291 -ddI[1] == strtod - - -Input: 1.23456589e-307 -strtopdd consumes 15 bytes and returns 98 -dd[0] = 1.23456589e-307 = #363196 bb9845fa -dd[1] = 1e-323 = #0 2 -g_ddfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIdd returns 98, consuming 15 bytes. -ddI[0] = #363196 bb9845fa + 0 1 -= 1.2345658899999999e-307 + 4.9406564584124654e-324 -ddI[1] = #363196 bb9845fa + 0 2 -= 1.2345658899999999e-307 + 9.8813129168249309e-324 -ddI[1] == strtod - - -Input: 1.234567890123456789 -strtopdd consumes 20 bytes and returns 33 -dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb -dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e -g_ddfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIdd returns 33, consuming 20 bytes. -ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c -= 1.2345678901234567 + 9.8567864525888563e-17 -ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e -= 1.2345678901234567 + 9.8567864525888588e-17 -ddI[1] == strtod - - -Input: 1.234567890123456789e301 -strtopdd consumes 24 bytes and returns 33 -dd[0] = 1.2345678901234568e+301 = #7e726f51 75f56413 -dd[1] = 1.3892003943918827e+283 = #7ab7ea80 76399100 -g_ddfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIdd returns 33, consuming 24 bytes. -ddI[0] = #7e726f51 75f56413 + 7ab7ea80 76399080 -= 1.2345678901234568e+301 + 1.3892003943918563e+283 -ddI[1] = #7e726f51 75f56413 + 7ab7ea80 76399100 -= 1.2345678901234568e+301 + 1.3892003943918827e+283 -ddI[1] == strtod - - -Input: 1.234567890123456789e-301 -strtopdd consumes 25 bytes and returns 82 -dd[0] = 1.2345678901234567e-301 = #1752a64 e34ba0d3 -dd[1] = 7.374365e-318 = #0 16c66c -g_ddfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIdd returns 82, consuming 25 bytes. -ddI[0] = #1752a64 e34ba0d3 + 0 16c66c -= 1.2345678901234567e-301 + 7.374364541948945e-318 -ddI[1] = #1752a64 e34ba0d3 + 0 16c66d -= 1.2345678901234567e-301 + 7.3743694826054034e-318 -ddI[0] == strtod - - -Input: 1.234567890123456789e-321 -strtopdd consumes 25 bytes and returns 98 -dd[0] = 1.235e-321 = #0 fa -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 10 bytes: "1.235e-321" - -strtoIdd returns 98, consuming 25 bytes. -ddI[0] = #0 f9 + 0 0 -= 1.2302234581447039e-321 + 0 -ddI[1] = #0 fa + 0 0 -= 1.2351641146031164e-321 + 0 -ddI[1] == strtod - - -Input: 1e23 -strtopdd consumes 4 bytes and returns 1 -dd[0] = 1e+23 = #44b52d02 c7e14af6 -dd[1] = 8388608 = #41600000 0 -g_ddfmt(0) gives 5 bytes: "1e+23" - -strtoIdd returns 1, consuming 4 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1e310 -strtopdd consumes 5 bytes and returns 163 -dd[0] = Infinity = #7ff00000 0 -dd[1] = Infinity = #7ff00000 0 -g_ddfmt(0) gives 8 bytes: "Infinity" - -strtoIdd returns 163, consuming 5 bytes. -ddI[0] = #7fefffff ffffffff + 7c9fffff ffffffff -= 1.7976931348623157e+308 + 1.9958403095347196e+292 -ddI[1] = #7ff00000 0 + 7ff00000 0 -= Infinity + Infinity -ddI[1] == strtod - - -Input: 9.0259718793241475e-277 -strtopdd consumes 23 bytes and returns 33 -dd[0] = 9.025971879324147e-277 = #69fffff ffffffff -dd[1] = 6.217378695986177e-293 = #343daae f3582320 -g_ddfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIdd returns 33, consuming 23 bytes. -ddI[0] = #69fffff ffffffff + 343daae f358231f -= 9.0259718793241469e-277 + 6.2173786959861757e-293 -ddI[1] = #69fffff ffffffff + 343daae f3582320 -= 9.0259718793241469e-277 + 6.2173786959861768e-293 -ddI[1] == strtod - - -Input: 9.025971879324147880346310405869e-277 -strtopdd consumes 37 bytes and returns 17 -dd[0] = 9.025971879324148e-277 = #6a00000 0 -dd[1] = 2.2250738585072014e-308 = #100000 0 -g_ddfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277" - -strtoIdd returns 17, consuming 37 bytes. -ddI[0] = #6a00000 0 + 100000 0 -= 9.0259718793241479e-277 + 2.2250738585072014e-308 -ddI[1] = #6a00000 0 + 200000 0 -= 9.0259718793241479e-277 + 4.4501477170144028e-308 -ddI[0] == strtod - - -Input: 9.025971879324147880346310405868e-277 -strtopdd consumes 37 bytes and returns 17 -dd[0] = 9.025971879324147e-277 = #69fffff ffffffff -dd[1] = 1.0020841800044856e-292 = #34fffff fffffff9 -g_ddfmt(0) gives 37 bytes: "9.025971879324147880346310405868e-277" - -strtoIdd returns 17, consuming 37 bytes. -ddI[0] = #69fffff ffffffff + 34fffff fffffff9 -= 9.0259718793241469e-277 + 1.0020841800044856e-292 -ddI[1] = #69fffff ffffffff + 34fffff fffffffa -= 9.0259718793241469e-277 + 1.0020841800044857e-292 -ddI[0] == strtod - - -Input: 2.2250738585072014e-308 -strtopdd consumes 23 bytes and returns 82 -dd[0] = 2.2250738585072014e-308 = #100000 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIdd returns 82, consuming 23 bytes. -ddI[0] = #100000 0 + 0 0 -= 2.2250738585072014e-308 + 0 -ddI[1] = #100000 1 + 0 0 -= 2.2250738585072019e-308 + 0 -ddI[0] == strtod - - -Input: 2.2250738585072013e-308 -strtopdd consumes 23 bytes and returns 98 -dd[0] = 2.2250738585072014e-308 = #100000 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIdd returns 98, consuming 23 bytes. -ddI[0] = #fffff ffffffff + 0 0 -= 2.2250738585072009e-308 + 0 -ddI[1] = #100000 0 + 0 0 -= 2.2250738585072014e-308 + 0 -ddI[1] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.0999999999999999 = #3ff19999 99999999 -dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333 -g_ddfmt(0) gives 3 bytes: "1.1" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff19999 99999999 + 3ca33333 33333333 -= 1.0999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff19999 99999999 + 3ca33333 33333334 -= 1.0999999999999999 + 1.332267629550188e-16 -ddI[0] == strtod - - -Input: -1.1 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.0999999999999999 = #bff19999 99999999 -dd[1] = -1.3322676295501878e-16 = #bca33333 33333333 -g_ddfmt(0) gives 4 bytes: "-1.1" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff19999 99999999 + bca33333 33333334 -= -1.0999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff19999 99999999 + bca33333 33333333 -= -1.0999999999999999 + -1.3322676295501878e-16 -ddI[1] == strtod - - -Input: 1.2 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.2 = #3ff33333 33333333 -dd[1] = 4.440892098500625e-17 = #3c899999 99999998 -g_ddfmt(0) gives 3 bytes: "1.2" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff33333 33333333 + 3c899999 99999998 -= 1.2 + 4.4408920985006252e-17 -ddI[1] = #3ff33333 33333333 + 3c899999 9999999c -= 1.2 + 4.4408920985006276e-17 -ddI[0] == strtod - - -Input: -1.2 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.2 = #bff33333 33333333 -dd[1] = -4.440892098500625e-17 = #bc899999 99999998 -g_ddfmt(0) gives 4 bytes: "-1.2" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff33333 33333333 + bc899999 9999999c -= -1.2 + -4.4408920985006276e-17 -ddI[1] = #bff33333 33333333 + bc899999 99999998 -= -1.2 + -4.4408920985006252e-17 -ddI[1] == strtod - - -Input: 1.3 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc -dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999 -g_ddfmt(0) gives 34 bytes: "1.29999999999999999999999999999999" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999 -= 1.2999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a -= 1.2999999999999998 + 1.7763568394002506e-16 -ddI[0] == strtod - - -Input: -1.3 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.2999999999999998 = #bff4cccc cccccccc -dd[1] = -1.7763568394002503e-16 = #bca99999 99999999 -g_ddfmt(0) gives 35 bytes: "-1.29999999999999999999999999999999" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff4cccc cccccccc + bca99999 9999999a -= -1.2999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bff4cccc cccccccc + bca99999 99999999 -= -1.2999999999999998 + -1.7763568394002503e-16 -ddI[1] == strtod - - -Input: 1.4 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.4 = #3ff66666 66666666 -dd[1] = 8.88178419700125e-17 = #3c999999 99999998 -g_ddfmt(0) gives 34 bytes: "1.39999999999999999999999999999998" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff66666 66666666 + 3c999999 99999998 -= 1.3999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ff66666 66666666 + 3c999999 9999999a -= 1.3999999999999999 + 8.8817841970012528e-17 -ddI[0] == strtod - - -Input: -1.4 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.4 = #bff66666 66666666 -dd[1] = -8.88178419700125e-17 = #bc999999 99999998 -g_ddfmt(0) gives 35 bytes: "-1.39999999999999999999999999999998" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff66666 66666666 + bc999999 9999999a -= -1.3999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bff66666 66666666 + bc999999 99999998 -= -1.3999999999999999 + -8.8817841970012504e-17 -ddI[1] == strtod - - -Input: 1.5 -strtopdd consumes 3 bytes and returns 1 -dd[0] = 1.5 = #3ff80000 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 1, consuming 3 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: -1.5 -strtopdd consumes 4 bytes and returns 9 -dd[0] = -1.5 = #bff80000 0 -dd[1] = -0 = #80000000 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 9, consuming 4 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.6 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.5999999999999999 = #3ff99999 99999999 -dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333 -g_ddfmt(0) gives 3 bytes: "1.6" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff99999 99999999 + 3ca33333 33333333 -= 1.5999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff99999 99999999 + 3ca33333 33333334 -= 1.5999999999999999 + 1.332267629550188e-16 -ddI[0] == strtod - - -Input: -1.6 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.5999999999999999 = #bff99999 99999999 -dd[1] = -1.3322676295501878e-16 = #bca33333 33333333 -g_ddfmt(0) gives 4 bytes: "-1.6" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff99999 99999999 + bca33333 33333334 -= -1.5999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff99999 99999999 + bca33333 33333333 -= -1.5999999999999999 + -1.3322676295501878e-16 -ddI[1] == strtod - - -Input: 1.7 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.7 = #3ffb3333 33333333 -dd[1] = 4.440892098500625e-17 = #3c899999 99999998 -g_ddfmt(0) gives 3 bytes: "1.7" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ffb3333 33333333 + 3c899999 99999998 -= 1.7 + 4.4408920985006252e-17 -ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c -= 1.7 + 4.4408920985006276e-17 -ddI[0] == strtod - - -Input: -1.7 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.7 = #bffb3333 33333333 -dd[1] = -4.440892098500625e-17 = #bc899999 99999998 -g_ddfmt(0) gives 4 bytes: "-1.7" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bffb3333 33333333 + bc899999 9999999c -= -1.7 + -4.4408920985006276e-17 -ddI[1] = #bffb3333 33333333 + bc899999 99999998 -= -1.7 + -4.4408920985006252e-17 -ddI[1] == strtod - - -Input: 1.8 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.7999999999999998 = #3ffccccc cccccccc -dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999 -g_ddfmt(0) gives 34 bytes: "1.79999999999999999999999999999999" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999 -= 1.7999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a -= 1.7999999999999998 + 1.7763568394002506e-16 -ddI[0] == strtod - - -Input: -1.8 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.7999999999999998 = #bffccccc cccccccc -dd[1] = -1.7763568394002503e-16 = #bca99999 99999999 -g_ddfmt(0) gives 35 bytes: "-1.79999999999999999999999999999999" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffccccc cccccccc + bca99999 9999999a -= -1.7999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bffccccc cccccccc + bca99999 99999999 -= -1.7999999999999998 + -1.7763568394002503e-16 -ddI[1] == strtod - - -Input: 1.9 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.9 = #3ffe6666 66666666 -dd[1] = 8.88178419700125e-17 = #3c999999 99999998 -g_ddfmt(0) gives 34 bytes: "1.89999999999999999999999999999998" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffe6666 66666666 + 3c999999 99999998 -= 1.8999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a -= 1.8999999999999999 + 8.8817841970012528e-17 -ddI[0] == strtod - - -Input: -1.9 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.9 = #bffe6666 66666666 -dd[1] = -8.88178419700125e-17 = #bc999999 99999998 -g_ddfmt(0) gives 35 bytes: "-1.89999999999999999999999999999998" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffe6666 66666666 + bc999999 9999999a -= -1.8999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bffe6666 66666666 + bc999999 99999998 -= -1.8999999999999999 + -8.8817841970012504e-17 -ddI[1] == strtod - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.0999999999999999 = #3ff19999 99999999 -dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333 -g_ddfmt(0) gives 3 bytes: "1.1" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff19999 99999999 + 3ca33333 33333333 -= 1.0999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff19999 99999999 + 3ca33333 33333334 -= 1.0999999999999999 + 1.332267629550188e-16 -ddI[0] == strtod - - -Input: -1.1 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.0999999999999999 = #bff19999 99999999 -dd[1] = -1.3322676295501878e-16 = #bca33333 33333333 -g_ddfmt(0) gives 4 bytes: "-1.1" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff19999 99999999 + bca33333 33333334 -= -1.0999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff19999 99999999 + bca33333 33333333 -= -1.0999999999999999 + -1.3322676295501878e-16 -ddI[1] == strtod - - -Input: 1.2 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.2 = #3ff33333 33333333 -dd[1] = 4.440892098500625e-17 = #3c899999 99999998 -g_ddfmt(0) gives 3 bytes: "1.2" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff33333 33333333 + 3c899999 99999998 -= 1.2 + 4.4408920985006252e-17 -ddI[1] = #3ff33333 33333333 + 3c899999 9999999c -= 1.2 + 4.4408920985006276e-17 -ddI[0] == strtod - - -Input: -1.2 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.2 = #bff33333 33333333 -dd[1] = -4.440892098500625e-17 = #bc899999 99999998 -g_ddfmt(0) gives 4 bytes: "-1.2" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff33333 33333333 + bc899999 9999999c -= -1.2 + -4.4408920985006276e-17 -ddI[1] = #bff33333 33333333 + bc899999 99999998 -= -1.2 + -4.4408920985006252e-17 -ddI[1] == strtod - - -Input: 1.3 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc -dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a -g_ddfmt(0) gives 3 bytes: "1.3" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999 -= 1.2999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a -= 1.2999999999999998 + 1.7763568394002506e-16 -ddI[1] == strtod - - -Input: -1.3 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.2999999999999998 = #bff4cccc cccccccc -dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.3" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff4cccc cccccccc + bca99999 9999999a -= -1.2999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bff4cccc cccccccc + bca99999 99999999 -= -1.2999999999999998 + -1.7763568394002503e-16 -ddI[0] == strtod - - -Input: 1.4 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.4 = #3ff66666 66666666 -dd[1] = 8.881784197001253e-17 = #3c999999 9999999a -g_ddfmt(0) gives 3 bytes: "1.4" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff66666 66666666 + 3c999999 99999998 -= 1.3999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ff66666 66666666 + 3c999999 9999999a -= 1.3999999999999999 + 8.8817841970012528e-17 -ddI[1] == strtod - - -Input: -1.4 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.4 = #bff66666 66666666 -dd[1] = -8.881784197001253e-17 = #bc999999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.4" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff66666 66666666 + bc999999 9999999a -= -1.3999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bff66666 66666666 + bc999999 99999998 -= -1.3999999999999999 + -8.8817841970012504e-17 -ddI[0] == strtod - - -Input: 1.5 -strtopdd consumes 3 bytes and returns 1 -dd[0] = 1.5 = #3ff80000 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 1, consuming 3 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: -1.5 -strtopdd consumes 4 bytes and returns 9 -dd[0] = -1.5 = #bff80000 0 -dd[1] = -0 = #80000000 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 9, consuming 4 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.6 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.5999999999999999 = #3ff99999 99999999 -dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333 -g_ddfmt(0) gives 3 bytes: "1.6" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff99999 99999999 + 3ca33333 33333333 -= 1.5999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff99999 99999999 + 3ca33333 33333334 -= 1.5999999999999999 + 1.332267629550188e-16 -ddI[0] == strtod - - -Input: -1.6 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.5999999999999999 = #bff99999 99999999 -dd[1] = -1.3322676295501878e-16 = #bca33333 33333333 -g_ddfmt(0) gives 4 bytes: "-1.6" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff99999 99999999 + bca33333 33333334 -= -1.5999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff99999 99999999 + bca33333 33333333 -= -1.5999999999999999 + -1.3322676295501878e-16 -ddI[1] == strtod - - -Input: 1.7 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.7 = #3ffb3333 33333333 -dd[1] = 4.440892098500625e-17 = #3c899999 99999998 -g_ddfmt(0) gives 3 bytes: "1.7" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ffb3333 33333333 + 3c899999 99999998 -= 1.7 + 4.4408920985006252e-17 -ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c -= 1.7 + 4.4408920985006276e-17 -ddI[0] == strtod - - -Input: -1.7 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.7 = #bffb3333 33333333 -dd[1] = -4.440892098500625e-17 = #bc899999 99999998 -g_ddfmt(0) gives 4 bytes: "-1.7" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bffb3333 33333333 + bc899999 9999999c -= -1.7 + -4.4408920985006276e-17 -ddI[1] = #bffb3333 33333333 + bc899999 99999998 -= -1.7 + -4.4408920985006252e-17 -ddI[1] == strtod - - -Input: 1.8 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.7999999999999998 = #3ffccccc cccccccc -dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a -g_ddfmt(0) gives 3 bytes: "1.8" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999 -= 1.7999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a -= 1.7999999999999998 + 1.7763568394002506e-16 -ddI[1] == strtod - - -Input: -1.8 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.7999999999999998 = #bffccccc cccccccc -dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.8" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffccccc cccccccc + bca99999 9999999a -= -1.7999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bffccccc cccccccc + bca99999 99999999 -= -1.7999999999999998 + -1.7763568394002503e-16 -ddI[0] == strtod - - -Input: 1.9 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.9 = #3ffe6666 66666666 -dd[1] = 8.881784197001253e-17 = #3c999999 9999999a -g_ddfmt(0) gives 3 bytes: "1.9" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffe6666 66666666 + 3c999999 99999998 -= 1.8999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a -= 1.8999999999999999 + 8.8817841970012528e-17 -ddI[1] == strtod - - -Input: -1.9 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.9 = #bffe6666 66666666 -dd[1] = -8.881784197001253e-17 = #bc999999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.9" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffe6666 66666666 + bc999999 9999999a -= -1.8999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bffe6666 66666666 + bc999999 99999998 -= -1.8999999999999999 + -8.8817841970012504e-17 -ddI[0] == strtod - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.0999999999999999 = #3ff19999 99999999 -dd[1] = 1.332267629550188e-16 = #3ca33333 33333334 -g_ddfmt(0) gives 34 bytes: "1.10000000000000000000000000000002" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff19999 99999999 + 3ca33333 33333333 -= 1.0999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff19999 99999999 + 3ca33333 33333334 -= 1.0999999999999999 + 1.332267629550188e-16 -ddI[1] == strtod - - -Input: -1.1 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.0999999999999999 = #bff19999 99999999 -dd[1] = -1.3322676295501878e-16 = #bca33333 33333333 -g_ddfmt(0) gives 4 bytes: "-1.1" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff19999 99999999 + bca33333 33333334 -= -1.0999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff19999 99999999 + bca33333 33333333 -= -1.0999999999999999 + -1.3322676295501878e-16 -ddI[1] == strtod - - -Input: 1.2 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.2 = #3ff33333 33333333 -dd[1] = 4.4408920985006276e-17 = #3c899999 9999999c -g_ddfmt(0) gives 34 bytes: "1.20000000000000000000000000000001" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff33333 33333333 + 3c899999 99999998 -= 1.2 + 4.4408920985006252e-17 -ddI[1] = #3ff33333 33333333 + 3c899999 9999999c -= 1.2 + 4.4408920985006276e-17 -ddI[1] == strtod - - -Input: -1.2 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.2 = #bff33333 33333333 -dd[1] = -4.440892098500625e-17 = #bc899999 99999998 -g_ddfmt(0) gives 4 bytes: "-1.2" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff33333 33333333 + bc899999 9999999c -= -1.2 + -4.4408920985006276e-17 -ddI[1] = #bff33333 33333333 + bc899999 99999998 -= -1.2 + -4.4408920985006252e-17 -ddI[1] == strtod - - -Input: 1.3 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc -dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a -g_ddfmt(0) gives 3 bytes: "1.3" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999 -= 1.2999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a -= 1.2999999999999998 + 1.7763568394002506e-16 -ddI[1] == strtod - - -Input: -1.3 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.2999999999999998 = #bff4cccc cccccccc -dd[1] = -1.7763568394002503e-16 = #bca99999 99999999 -g_ddfmt(0) gives 35 bytes: "-1.29999999999999999999999999999999" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff4cccc cccccccc + bca99999 9999999a -= -1.2999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bff4cccc cccccccc + bca99999 99999999 -= -1.2999999999999998 + -1.7763568394002503e-16 -ddI[1] == strtod - - -Input: 1.4 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.4 = #3ff66666 66666666 -dd[1] = 8.881784197001253e-17 = #3c999999 9999999a -g_ddfmt(0) gives 3 bytes: "1.4" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff66666 66666666 + 3c999999 99999998 -= 1.3999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ff66666 66666666 + 3c999999 9999999a -= 1.3999999999999999 + 8.8817841970012528e-17 -ddI[1] == strtod - - -Input: -1.4 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.4 = #bff66666 66666666 -dd[1] = -8.88178419700125e-17 = #bc999999 99999998 -g_ddfmt(0) gives 35 bytes: "-1.39999999999999999999999999999998" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff66666 66666666 + bc999999 9999999a -= -1.3999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bff66666 66666666 + bc999999 99999998 -= -1.3999999999999999 + -8.8817841970012504e-17 -ddI[1] == strtod - - -Input: 1.5 -strtopdd consumes 3 bytes and returns 1 -dd[0] = 1.5 = #3ff80000 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 1, consuming 3 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: -1.5 -strtopdd consumes 4 bytes and returns 9 -dd[0] = -1.5 = #bff80000 0 -dd[1] = -0 = #80000000 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 9, consuming 4 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.6 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.5999999999999999 = #3ff99999 99999999 -dd[1] = 1.332267629550188e-16 = #3ca33333 33333334 -g_ddfmt(0) gives 34 bytes: "1.60000000000000000000000000000002" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff99999 99999999 + 3ca33333 33333333 -= 1.5999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff99999 99999999 + 3ca33333 33333334 -= 1.5999999999999999 + 1.332267629550188e-16 -ddI[1] == strtod - - -Input: -1.6 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.5999999999999999 = #bff99999 99999999 -dd[1] = -1.3322676295501878e-16 = #bca33333 33333333 -g_ddfmt(0) gives 4 bytes: "-1.6" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff99999 99999999 + bca33333 33333334 -= -1.5999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff99999 99999999 + bca33333 33333333 -= -1.5999999999999999 + -1.3322676295501878e-16 -ddI[1] == strtod - - -Input: 1.7 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.7 = #3ffb3333 33333333 -dd[1] = 4.4408920985006276e-17 = #3c899999 9999999c -g_ddfmt(0) gives 34 bytes: "1.70000000000000000000000000000001" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ffb3333 33333333 + 3c899999 99999998 -= 1.7 + 4.4408920985006252e-17 -ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c -= 1.7 + 4.4408920985006276e-17 -ddI[1] == strtod - - -Input: -1.7 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.7 = #bffb3333 33333333 -dd[1] = -4.440892098500625e-17 = #bc899999 99999998 -g_ddfmt(0) gives 4 bytes: "-1.7" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bffb3333 33333333 + bc899999 9999999c -= -1.7 + -4.4408920985006276e-17 -ddI[1] = #bffb3333 33333333 + bc899999 99999998 -= -1.7 + -4.4408920985006252e-17 -ddI[1] == strtod - - -Input: 1.8 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.7999999999999998 = #3ffccccc cccccccc -dd[1] = 1.7763568394002506e-16 = #3ca99999 9999999a -g_ddfmt(0) gives 3 bytes: "1.8" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999 -= 1.7999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a -= 1.7999999999999998 + 1.7763568394002506e-16 -ddI[1] == strtod - - -Input: -1.8 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.7999999999999998 = #bffccccc cccccccc -dd[1] = -1.7763568394002503e-16 = #bca99999 99999999 -g_ddfmt(0) gives 35 bytes: "-1.79999999999999999999999999999999" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffccccc cccccccc + bca99999 9999999a -= -1.7999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bffccccc cccccccc + bca99999 99999999 -= -1.7999999999999998 + -1.7763568394002503e-16 -ddI[1] == strtod - - -Input: 1.9 -strtopdd consumes 3 bytes and returns 33 -dd[0] = 1.9 = #3ffe6666 66666666 -dd[1] = 8.881784197001253e-17 = #3c999999 9999999a -g_ddfmt(0) gives 3 bytes: "1.9" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffe6666 66666666 + 3c999999 99999998 -= 1.8999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a -= 1.8999999999999999 + 8.8817841970012528e-17 -ddI[1] == strtod - - -Input: -1.9 -strtopdd consumes 4 bytes and returns 25 -dd[0] = -1.9 = #bffe6666 66666666 -dd[1] = -8.88178419700125e-17 = #bc999999 99999998 -g_ddfmt(0) gives 35 bytes: "-1.89999999999999999999999999999998" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffe6666 66666666 + bc999999 9999999a -= -1.8999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bffe6666 66666666 + bc999999 99999998 -= -1.8999999999999999 + -8.8817841970012504e-17 -ddI[1] == strtod - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.0999999999999999 = #3ff19999 99999999 -dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333 -g_ddfmt(0) gives 3 bytes: "1.1" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff19999 99999999 + 3ca33333 33333333 -= 1.0999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff19999 99999999 + 3ca33333 33333334 -= 1.0999999999999999 + 1.332267629550188e-16 -ddI[0] == strtod - - -Input: -1.1 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.0999999999999999 = #bff19999 99999999 -dd[1] = -1.332267629550188e-16 = #bca33333 33333334 -g_ddfmt(0) gives 35 bytes: "-1.10000000000000000000000000000002" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff19999 99999999 + bca33333 33333334 -= -1.0999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff19999 99999999 + bca33333 33333333 -= -1.0999999999999999 + -1.3322676295501878e-16 -ddI[0] == strtod - - -Input: 1.2 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.2 = #3ff33333 33333333 -dd[1] = 4.440892098500625e-17 = #3c899999 99999998 -g_ddfmt(0) gives 3 bytes: "1.2" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff33333 33333333 + 3c899999 99999998 -= 1.2 + 4.4408920985006252e-17 -ddI[1] = #3ff33333 33333333 + 3c899999 9999999c -= 1.2 + 4.4408920985006276e-17 -ddI[0] == strtod - - -Input: -1.2 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.2 = #bff33333 33333333 -dd[1] = -4.4408920985006276e-17 = #bc899999 9999999c -g_ddfmt(0) gives 35 bytes: "-1.20000000000000000000000000000001" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff33333 33333333 + bc899999 9999999c -= -1.2 + -4.4408920985006276e-17 -ddI[1] = #bff33333 33333333 + bc899999 99999998 -= -1.2 + -4.4408920985006252e-17 -ddI[0] == strtod - - -Input: 1.3 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.2999999999999998 = #3ff4cccc cccccccc -dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999 -g_ddfmt(0) gives 34 bytes: "1.29999999999999999999999999999999" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff4cccc cccccccc + 3ca99999 99999999 -= 1.2999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ff4cccc cccccccc + 3ca99999 9999999a -= 1.2999999999999998 + 1.7763568394002506e-16 -ddI[0] == strtod - - -Input: -1.3 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.2999999999999998 = #bff4cccc cccccccc -dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.3" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff4cccc cccccccc + bca99999 9999999a -= -1.2999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bff4cccc cccccccc + bca99999 99999999 -= -1.2999999999999998 + -1.7763568394002503e-16 -ddI[0] == strtod - - -Input: 1.4 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.4 = #3ff66666 66666666 -dd[1] = 8.88178419700125e-17 = #3c999999 99999998 -g_ddfmt(0) gives 34 bytes: "1.39999999999999999999999999999998" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ff66666 66666666 + 3c999999 99999998 -= 1.3999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ff66666 66666666 + 3c999999 9999999a -= 1.3999999999999999 + 8.8817841970012528e-17 -ddI[0] == strtod - - -Input: -1.4 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.4 = #bff66666 66666666 -dd[1] = -8.881784197001253e-17 = #bc999999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.4" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bff66666 66666666 + bc999999 9999999a -= -1.3999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bff66666 66666666 + bc999999 99999998 -= -1.3999999999999999 + -8.8817841970012504e-17 -ddI[0] == strtod - - -Input: 1.5 -strtopdd consumes 3 bytes and returns 1 -dd[0] = 1.5 = #3ff80000 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 1, consuming 3 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: -1.5 -strtopdd consumes 4 bytes and returns 9 -dd[0] = -1.5 = #bff80000 0 -dd[1] = -0 = #80000000 0 -g_ddfmt(0) gives 3 bytes: "1.5" - -strtoIdd returns 9, consuming 4 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.6 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.5999999999999999 = #3ff99999 99999999 -dd[1] = 1.3322676295501878e-16 = #3ca33333 33333333 -g_ddfmt(0) gives 3 bytes: "1.6" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ff99999 99999999 + 3ca33333 33333333 -= 1.5999999999999999 + 1.3322676295501878e-16 -ddI[1] = #3ff99999 99999999 + 3ca33333 33333334 -= 1.5999999999999999 + 1.332267629550188e-16 -ddI[0] == strtod - - -Input: -1.6 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.5999999999999999 = #bff99999 99999999 -dd[1] = -1.332267629550188e-16 = #bca33333 33333334 -g_ddfmt(0) gives 35 bytes: "-1.60000000000000000000000000000002" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bff99999 99999999 + bca33333 33333334 -= -1.5999999999999999 + -1.332267629550188e-16 -ddI[1] = #bff99999 99999999 + bca33333 33333333 -= -1.5999999999999999 + -1.3322676295501878e-16 -ddI[0] == strtod - - -Input: 1.7 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.7 = #3ffb3333 33333333 -dd[1] = 4.440892098500625e-17 = #3c899999 99999998 -g_ddfmt(0) gives 3 bytes: "1.7" - -strtoIdd returns 17, consuming 3 bytes. -ddI[0] = #3ffb3333 33333333 + 3c899999 99999998 -= 1.7 + 4.4408920985006252e-17 -ddI[1] = #3ffb3333 33333333 + 3c899999 9999999c -= 1.7 + 4.4408920985006276e-17 -ddI[0] == strtod - - -Input: -1.7 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.7 = #bffb3333 33333333 -dd[1] = -4.4408920985006276e-17 = #bc899999 9999999c -g_ddfmt(0) gives 35 bytes: "-1.70000000000000000000000000000001" - -strtoIdd returns 25, consuming 4 bytes. -ddI[0] = #bffb3333 33333333 + bc899999 9999999c -= -1.7 + -4.4408920985006276e-17 -ddI[1] = #bffb3333 33333333 + bc899999 99999998 -= -1.7 + -4.4408920985006252e-17 -ddI[0] == strtod - - -Input: 1.8 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.7999999999999998 = #3ffccccc cccccccc -dd[1] = 1.7763568394002503e-16 = #3ca99999 99999999 -g_ddfmt(0) gives 34 bytes: "1.79999999999999999999999999999999" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffccccc cccccccc + 3ca99999 99999999 -= 1.7999999999999998 + 1.7763568394002503e-16 -ddI[1] = #3ffccccc cccccccc + 3ca99999 9999999a -= 1.7999999999999998 + 1.7763568394002506e-16 -ddI[0] == strtod - - -Input: -1.8 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.7999999999999998 = #bffccccc cccccccc -dd[1] = -1.7763568394002506e-16 = #bca99999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.8" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffccccc cccccccc + bca99999 9999999a -= -1.7999999999999998 + -1.7763568394002506e-16 -ddI[1] = #bffccccc cccccccc + bca99999 99999999 -= -1.7999999999999998 + -1.7763568394002503e-16 -ddI[0] == strtod - - -Input: 1.9 -strtopdd consumes 3 bytes and returns 17 -dd[0] = 1.9 = #3ffe6666 66666666 -dd[1] = 8.88178419700125e-17 = #3c999999 99999998 -g_ddfmt(0) gives 34 bytes: "1.89999999999999999999999999999998" - -strtoIdd returns 33, consuming 3 bytes. -ddI[0] = #3ffe6666 66666666 + 3c999999 99999998 -= 1.8999999999999999 + 8.8817841970012504e-17 -ddI[1] = #3ffe6666 66666666 + 3c999999 9999999a -= 1.8999999999999999 + 8.8817841970012528e-17 -ddI[0] == strtod - - -Input: -1.9 -strtopdd consumes 4 bytes and returns 41 -dd[0] = -1.9 = #bffe6666 66666666 -dd[1] = -8.881784197001253e-17 = #bc999999 9999999a -g_ddfmt(0) gives 4 bytes: "-1.9" - -strtoIdd returns 41, consuming 4 bytes. -ddI[0] = #bffe6666 66666666 + bc999999 9999999a -= -1.8999999999999999 + -8.8817841970012528e-17 -ddI[1] = #bffe6666 66666666 + bc999999 99999998 -= -1.8999999999999999 + -8.8817841970012504e-17 -ddI[0] == strtod - diff --git a/lib/libc/gdtoa/test/ddsi.out b/lib/libc/gdtoa/test/ddsi.out deleted file mode 100644 index 1677707f2..000000000 --- a/lib/libc/gdtoa/test/ddsi.out +++ /dev/null @@ -1,376 +0,0 @@ - -Input: 1.23 -strtopdd consumes 4 bytes and returns 17 -dd[0] = 1.23 = #3ff3ae14 7ae147ae -dd[1] = 1.7763568394002496e-17 = #3c747ae1 47ae1478 -g_ddfmt(0) gives 4 bytes: "1.23" - -strtoIdd returns 17, consuming 4 bytes. -ddI[0] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1478 -= 1.23 + 1.7763568394002496e-17 -ddI[1] = #3ff3ae14 7ae147ae + 3c747ae1 47ae1480 -= 1.23 + 1.776356839400252e-17 -ddI[0] == strtod - - -Input: 1.23e+20 -strtopdd consumes 8 bytes and returns 1 -dd[0] = 1.23e+20 = #441aabdf 2145b430 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 8 bytes: "1.23e+20" - -strtoIdd returns 1, consuming 8 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.23e-20 -strtopdd consumes 8 bytes and returns 33 -dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530 -dd[1] = 9.304023318521521e-37 = #3873c997 955b2691 -g_ddfmt(0) gives 8 bytes: "1.23e-20" - -strtoIdd returns 33, consuming 8 bytes. -ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690 -= 1.2299999999999999e-20 + 9.3040233185215194e-37 -ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691 -= 1.2299999999999999e-20 + 9.3040233185215211e-37 -ddI[1] == strtod - - -Input: 1.23456789 -strtopdd consumes 10 bytes and returns 17 -dd[0] = 1.23456789 = #3ff3c0ca 4283de1b -dd[1] = 1.0990618193318369e-16 = #3c9fada5 144c1252 -g_ddfmt(0) gives 10 bytes: "1.23456789" - -strtoIdd returns 17, consuming 10 bytes. -ddI[0] = #3ff3c0ca 4283de1b + 3c9fada5 144c1252 -= 1.2345678899999999 + 1.0990618193318369e-16 -ddI[1] = #3ff3c0ca 4283de1b + 3c9fada5 144c1254 -= 1.2345678899999999 + 1.0990618193318371e-16 -ddI[0] == strtod - - -Input: 1.23456589e+20 -strtopdd consumes 14 bytes and returns 1 -dd[0] = 1.23456589e+20 = #441ac537 a660b997 -dd[1] = 4096 = #40b00000 0 -g_ddfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIdd returns 1, consuming 14 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.23e+30 -strtopdd consumes 8 bytes and returns 1 -dd[0] = 1.23e+30 = #462f0cb0 4e8fb790 -dd[1] = 40281156091904 = #42c25158 0 -g_ddfmt(0) gives 8 bytes: "1.23e+30" - -strtoIdd returns 1, consuming 8 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1.23e-30 -strtopdd consumes 8 bytes and returns 17 -dd[0] = 1.2299999999999999e-30 = #39b8f286 6f5010aa -dd[1] = 1.076909723013918e-46 = #3663ac7f 3dafd174 -g_ddfmt(0) gives 8 bytes: "1.23e-30" - -strtoIdd returns 17, consuming 8 bytes. -ddI[0] = #39b8f286 6f5010aa + 3663ac7f 3dafd174 -= 1.2299999999999999e-30 + 1.076909723013918e-46 -ddI[1] = #39b8f286 6f5010aa + 3663ac7f 3dafd175 -= 1.2299999999999999e-30 + 1.0769097230139181e-46 -ddI[0] == strtod - - -Input: 1.23456789e-20 -strtopdd consumes 14 bytes and returns 17 -dd[0] = 1.23456789e-20 = #3bcd2681 471e7ada -dd[1] = 6.247111971663133e-37 = #386a9280 a761b07e -g_ddfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIdd returns 17, consuming 14 bytes. -ddI[0] = #3bcd2681 471e7ada + 386a9280 a761b07e -= 1.2345678899999999e-20 + 6.2471119716631328e-37 -ddI[1] = #3bcd2681 471e7ada + 386a9280 a761b080 -= 1.2345678899999999e-20 + 6.2471119716631345e-37 -ddI[0] == strtod - - -Input: 1.23456789e-30 -strtopdd consumes 14 bytes and returns 33 -dd[0] = 1.23456789e-30 = #39b90a3e 33bbd995 -dd[1] = 2.1567930523648577e-47 = #363f8585 55a6b1a0 -g_ddfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIdd returns 33, consuming 14 bytes. -ddI[0] = #39b90a3e 33bbd995 + 363f8585 55a6b198 -= 1.23456789e-30 + 2.1567930523648558e-47 -ddI[1] = #39b90a3e 33bbd995 + 363f8585 55a6b1a0 -= 1.23456789e-30 + 2.1567930523648577e-47 -ddI[1] == strtod - - -Input: 1.234567890123456789 -strtopdd consumes 20 bytes and returns 33 -dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb -dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e -g_ddfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIdd returns 33, consuming 20 bytes. -ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c -= 1.2345678901234567 + 9.8567864525888563e-17 -ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e -= 1.2345678901234567 + 9.8567864525888588e-17 -ddI[1] == strtod - - -Input: 1.23456789012345678901234567890123456789 -strtopdd consumes 40 bytes and returns 33 -dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb -dd[1] = 9.858021020478982e-17 = #3c9c69ef 85adadb6 -g_ddfmt(0) gives 34 bytes: "1.23456789012345678901234567890124" - -strtoIdd returns 33, consuming 40 bytes. -ddI[0] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb4 -= 1.2345678901234567 + 9.8580210204789798e-17 -ddI[1] = #3ff3c0ca 428c59fb + 3c9c69ef 85adadb6 -= 1.2345678901234567 + 9.8580210204789823e-17 -ddI[1] == strtod - - -Input: 1.23e306 -strtopdd consumes 8 bytes and returns 33 -dd[0] = 1.2299999999999999e+306 = #7f7c0676 cd1c61f4 -dd[1] = 1.3319001448659015e+290 = #7c2b558b e3d3f477 -g_ddfmt(0) gives 9 bytes: "1.23e+306" - -strtoIdd returns 33, consuming 8 bytes. -ddI[0] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f476 -= 1.2299999999999999e+306 + 1.3319001448659013e+290 -ddI[1] = #7f7c0676 cd1c61f4 + 7c2b558b e3d3f477 -= 1.2299999999999999e+306 + 1.3319001448659015e+290 -ddI[1] == strtod - - -Input: 1.23e-306 -strtopdd consumes 9 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 9 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 1.23e-320 -strtopdd consumes 9 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 9 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 1.23e-20 -strtopdd consumes 8 bytes and returns 33 -dd[0] = 1.2299999999999999e-20 = #3bcd0ae4 cf767530 -dd[1] = 9.304023318521521e-37 = #3873c997 955b2691 -g_ddfmt(0) gives 8 bytes: "1.23e-20" - -strtoIdd returns 33, consuming 8 bytes. -ddI[0] = #3bcd0ae4 cf767530 + 3873c997 955b2690 -= 1.2299999999999999e-20 + 9.3040233185215194e-37 -ddI[1] = #3bcd0ae4 cf767530 + 3873c997 955b2691 -= 1.2299999999999999e-20 + 9.3040233185215211e-37 -ddI[1] == strtod - - -Input: 1.23456789e307 -strtopdd consumes 14 bytes and returns 33 -dd[0] = 1.2345678899999998e+307 = #7fb194b1 4bdaecdb -dd[1] = 2.0137933598720243e+291 = #7c69d48d 192048ca -g_ddfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIdd returns 33, consuming 14 bytes. -ddI[0] = #7fb194b1 4bdaecdb + 7c69d48d 192048c9 -= 1.2345678899999998e+307 + 2.013793359872024e+291 -ddI[1] = #7fb194b1 4bdaecdb + 7c69d48d 192048ca -= 1.2345678899999998e+307 + 2.0137933598720243e+291 -ddI[1] == strtod - - -Input: 1.23456589e-307 -strtopdd consumes 15 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 15 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 1.234567890123456789 -strtopdd consumes 20 bytes and returns 33 -dd[0] = 1.2345678901234567 = #3ff3c0ca 428c59fb -dd[1] = 9.856786452588859e-17 = #3c9c6906 51a3745e -g_ddfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIdd returns 33, consuming 20 bytes. -ddI[0] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745c -= 1.2345678901234567 + 9.8567864525888563e-17 -ddI[1] = #3ff3c0ca 428c59fb + 3c9c6906 51a3745e -= 1.2345678901234567 + 9.8567864525888588e-17 -ddI[1] == strtod - - -Input: 1.234567890123456789e301 -strtopdd consumes 24 bytes and returns 33 -dd[0] = 1.2345678901234568e+301 = #7e726f51 75f56413 -dd[1] = 1.3892003943918827e+283 = #7ab7ea80 76399100 -g_ddfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIdd returns 33, consuming 24 bytes. -ddI[0] = #7e726f51 75f56413 + 7ab7ea80 76399080 -= 1.2345678901234568e+301 + 1.3892003943918563e+283 -ddI[1] = #7e726f51 75f56413 + 7ab7ea80 76399100 -= 1.2345678901234568e+301 + 1.3892003943918827e+283 -ddI[1] == strtod - - -Input: 1.234567890123456789e-301 -strtopdd consumes 25 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 25 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 1.234567890123456789e-321 -strtopdd consumes 25 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 25 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 1e23 -strtopdd consumes 4 bytes and returns 1 -dd[0] = 1e+23 = #44b52d02 c7e14af6 -dd[1] = 8388608 = #41600000 0 -g_ddfmt(0) gives 5 bytes: "1e+23" - -strtoIdd returns 1, consuming 4 bytes. -ddI[0] == ddI[1] == strtopdd - - -Input: 1e310 -strtopdd consumes 5 bytes and returns 163 -dd[0] = Infinity = #7ff00000 0 -dd[1] = Infinity = #7ff00000 0 -g_ddfmt(0) gives 8 bytes: "Infinity" - -strtoIdd returns 163, consuming 5 bytes. -ddI[0] = #7fefffff ffffffff + 7c9fffff ffffffff -= 1.7976931348623157e+308 + 1.9958403095347196e+292 -ddI[1] = #7ff00000 0 + 7ff00000 0 -= Infinity + Infinity -ddI[1] == strtod - - -Input: 9.0259718793241475e-277 -strtopdd consumes 23 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 23 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 9.025971879324147880346310405869e-277 -strtopdd consumes 37 bytes and returns 17 -dd[0] = 9.025971879324148e-277 = #6a00000 0 -dd[1] = 2.2250738585072014e-308 = #100000 0 -g_ddfmt(0) gives 37 bytes: "9.025971879324147880346310405869e-277" - -strtoIdd returns 17, consuming 37 bytes. -ddI[0] = #6a00000 0 + 100000 0 -= 9.0259718793241479e-277 + 2.2250738585072014e-308 -ddI[1] = #6a00000 0 + 200000 0 -= 9.0259718793241479e-277 + 4.4501477170144028e-308 -ddI[0] == strtod - - -Input: 9.025971879324147880346310405868e-277 -strtopdd consumes 37 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 37 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 2.2250738585072014e-308 -strtopdd consumes 23 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 23 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - - -Input: 2.2250738585072013e-308 -strtopdd consumes 23 bytes and returns 80 -dd[0] = 0 = #0 0 -dd[1] = 0 = #0 0 -g_ddfmt(0) gives 1 bytes: "0" - -strtoIdd returns 80, consuming 23 bytes. -ddI[0] = #0 0 + 0 0 -= 0 + 0 -ddI[1] = #6a00000 0 + 0 0 -= 9.0259718793241479e-277 + 0 -ddI[0] == strtod - diff --git a/lib/libc/gdtoa/test/ddtest.c b/lib/libc/gdtoa/test/ddtest.c deleted file mode 100644 index 2cf31524a..000000000 --- a/lib/libc/gdtoa/test/ddtest.c +++ /dev/null @@ -1,177 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test program for g_ddfmt, strtoIdd, strtopdd, and strtordd. - * - * Inputs (on stdin): - * r rounding_mode - * n ndig - * number - * #hex0 hex1 hex2 hex3 - * - * rounding_mode values: - * 0 = toward zero - * 1 = nearest - * 2 = toward +Infinity - * 3 = toward -Infinity - * - * where number is a decimal floating-point number, - * hex0 is a string of <= 8 Hex digits for the most significant - * word of the number, hex1 is a similar string for the next - * word, etc., and ndig is a parameters to g_ddfmt. - */ - -#include "gdtoaimp.h" -#include -#include - - extern int getround ANSI((int,char*)); - - static char ibuf[2048], obuf[1024]; - -#define U (unsigned long) - - static void -#ifdef KR_headers -dprint(what, d) char *what; double d; -#else -dprint(char *what, double d) -#endif -{ - char buf[32]; - union { double d; ULong L[2]; } u; - - u.d = d; - g_dfmt(buf,&d,0,sizeof(buf)); - printf("%s = %s = #%lx %lx\n", what, buf, U u.L[_0], U u.L[_1]); - } - - int -main(Void) -{ - char *s, *s1, *se, *se1; - int dItry, i, j, r = 1, ndig = 0; - double ddI[4]; - long LL[4]; - union { double dd[2]; ULong L[4]; } u; - - while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) { - while(*s <= ' ') - if (!*s++) - continue; - dItry = 0; - switch(*s) { - case 'r': - r = getround(r, s); - continue; - case 'n': - i = s[1]; - if (i <= ' ' || (i >= '0' && i <= '9')) { - ndig = atoi(s+1); - continue; - } - break; /* nan? */ - case '#': - LL[0] = u.L[_0]; - LL[1] = u.L[_1]; - LL[2] = u.L[2+_0]; - LL[3] = u.L[2+_1]; - sscanf(s+1, "%lx %lx %lx %lx", &LL[0], &LL[1], - &LL[2], &LL[3]); - u.L[_0] = LL[0]; - u.L[_1] = LL[1]; - u.L[2+_0] = LL[2]; - u.L[2+_1] = LL[3]; - printf("\nInput: %s", ibuf); - printf(" --> f = #%lx %lx %lx %lx\n", - LL[0],LL[1],LL[2],LL[3]); - goto fmt_test; - } - printf("\nInput: %s", ibuf); - for(s1 = s; *s1 > ' '; s1++){}; - while(*s1 <= ' ' && *s1) s1++; - if (!*s1) { - dItry = 1; - i = strtordd(ibuf, &se, r, u.dd); - if (r == 1) { - j = strtopdd(ibuf, &se1, ddI); - if (i != j || u.dd[0] != ddI[0] - || u.dd[1] != ddI[1] || se != se1) - printf("***strtopdd and strtordd disagree!!\n:"); - } - printf("strtopdd consumes %d bytes and returns %d\n", - (int)(se-ibuf), i); - } - else { - u.dd[0] = strtod(s, &se); - u.dd[1] = strtod(se, &se); - } - fmt_test: - dprint("dd[0]", u.dd[0]); - dprint("dd[1]", u.dd[1]); - se = g_ddfmt(obuf, u.dd, ndig, sizeof(obuf)); - printf("g_ddfmt(%d) gives %d bytes: \"%s\"\n\n", - ndig, (int)(se-obuf), se ? obuf : ""); - if (!dItry) - continue; - printf("strtoIdd returns %d,", strtoIdd(ibuf, &se, ddI,&ddI[2])); - printf(" consuming %d bytes.\n", (int)(se-ibuf)); - if (ddI[0] == ddI[2] && ddI[1] == ddI[3]) { - if (ddI[0] == u.dd[0] && ddI[1] == u.dd[1]) - printf("ddI[0] == ddI[1] == strtopdd\n"); - else - printf("ddI[0] == ddI[1] = #%lx %lx + %lx %lx\n= %.17g + %17.g\n", - U ((ULong*)ddI)[_0], - U ((ULong*)ddI)[_1], - U ((ULong*)ddI)[2+_0], - U ((ULong*)ddI)[2+_1], - ddI[0], ddI[1]); - } - else { - printf("ddI[0] = #%lx %lx + %lx %lx\n= %.17g + %.17g\n", - U ((ULong*)ddI)[_0], U ((ULong*)ddI)[_1], - U ((ULong*)ddI)[2+_0], U ((ULong*)ddI)[2+_1], - ddI[0], ddI[1]); - printf("ddI[1] = #%lx %lx + %lx %lx\n= %.17g + %.17g\n", - U ((ULong*)ddI)[4+_0], U ((ULong*)ddI)[4+_1], - U ((ULong*)ddI)[6+_0], U ((ULong*)ddI)[6+_1], - ddI[2], ddI[3]); - if (ddI[0] == u.dd[0] && ddI[1] == u.dd[1]) - printf("ddI[0] == strtod\n"); - else if (ddI[2] == u.dd[0] && ddI[3] == u.dd[1]) - printf("ddI[1] == strtod\n"); - else - printf("**** Both differ from strtopdd ****\n"); - } - printf("\n"); - } - return 0; - } diff --git a/lib/libc/gdtoa/test/dt.c b/lib/libc/gdtoa/test/dt.c deleted file mode 100644 index 355476ff2..000000000 --- a/lib/libc/gdtoa/test/dt.c +++ /dev/null @@ -1,291 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test program for strtod and dtoa. - * - * Inputs (on stdin): - * number[: mode [ndigits]] - * or - * #hex0 hex1[: mode [ndigits]] - * where number is a decimal floating-point number, - * hex0 is a string of Hex digits for the most significant - * word of the number, hex1 is a similar string for the other - * (least significant) word, and mode and ndigits are - * parameters to dtoa. - */ - -#include -#include "gdtoa.h" -int STRTOD_DIGLIM = 24; -#ifdef KR_headers -#define Void /*void*/ -#else -#define Void void -#endif - -#ifdef __STDC__ -#include -#else -#ifdef __cplusplus -extern "C" double atof(const char*); -#else -extern double atof ANSI((char*)); -#endif -#endif - -typedef union { double d; ULong L[2]; } U; - -#ifdef IEEE_8087 -#define word0(x) (x)->L[1] -#define word1(x) (x)->L[0] -#else -#define word0(x) (x)->L[0] -#define word1(x) (x)->L[1] -#endif -#define dval(x) (x)->d - -#include "errno.h" - -#ifdef __cplusplus -extern "C" char *dtoa(double, int, int, int*, int*, char **); -#else -extern char *dtoa ANSI((double, int, int, int*, int*, char **)); -#endif - - static void -#ifdef KR_headers -g_fmt(b, x) char *b; double x; -#else -g_fmt(char *b, double x) -#endif -{ - char *s, *se; - int decpt, i, j, k, sign; - - if (!x) { - *b++ = '0'; - *b = 0; - return; - } - s = dtoa(x, 0, 0, &decpt, &sign, &se); - if (sign) - *b++ = '-'; - if (decpt == 9999) /* Infinity or Nan */ { - while((*b++ = *s++)); - return; - } - if (decpt <= -4 || decpt > se - s + 5) { - *b++ = *s++; - if (*s) { - *b++ = '.'; - while((*b = *s++)) - b++; - } - *b++ = 'e'; - /* sprintf(b, "%+.2d", decpt - 1); */ - if (--decpt < 0) { - *b++ = '-'; - decpt = -decpt; - } - else - *b++ = '+'; - for(j = 2, k = 10; 10*k <= decpt; j++, k *= 10){}; - for(;;) { - i = decpt / k; - *b++ = i + '0'; - if (--j <= 0) - break; - decpt -= i*k; - decpt *= 10; - } - *b = 0; - } - else if (decpt <= 0) { - *b++ = '.'; - for(; decpt < 0; decpt++) - *b++ = '0'; - while((*b++ = *s++)); - } - else { - while((*b = *s++)) { - b++; - if (--decpt == 0 && *s) - *b++ = '.'; - } - for(; decpt > 0; decpt--) - *b++ = '0'; - *b = 0; - } - } - - static void -baderrno(Void) -{ - fflush(stdout); - perror("\nerrno strtod"); - fflush(stderr); - } - -#define UL (unsigned long) - - static void -#ifdef KR_headers -check(d) U *d; -#else -check(U *d) -#endif -{ - char buf[64]; - int decpt, sign; - char *s, *se; - U d1; - - s = dtoa(dval(d), 0, 0, &decpt, &sign, &se); - sprintf(buf, "%s%s%se%d", sign ? "-" : "", - decpt == 9999 ? "" : ".", s, decpt); - errno = 0; - dval(&d1) = strtod(buf, (char **)0); - if (errno) - baderrno(); - if (dval(d) != dval(&d1)) { - printf("sent d = %.17g = 0x%lx %lx, buf = %s\n", - dval(d), UL word0(d), UL word1(d), buf); - printf("got d1 = %.17g = 0x%lx %lx\n", - dval(&d1), UL word0(&d1), UL word1(&d1)); - } - } - - int -main(Void) -{ - U d, d1; - char buf[2048], buf1[32]; - char *fmt, *s, *s1, *se; - int decpt, sign; - int mode = 0, ndigits = 17; - ULong x, y; -#ifdef VAX - ULong z; -#endif - - while(fgets(buf, sizeof(buf), stdin)) { - if (*buf == '*') { - printf("%s", buf); - continue; - } - printf("Input: %s", buf); - if (*buf == '#') { - x = word0(&d); - y = word1(&d); - /* sscanf(buf+1, "%lx %lx:%d %d", &x, &y, &mode, &ndigits); */ - x = (ULong)strtoul(s1 = buf+1, &se, 16); - if (se > s1) { - y = (ULong)strtoul(s1 = se, &se, 16); - if (se > s1) - sscanf(se, ":%d %d", &mode, &ndigits); - } - word0(&d) = x; - word1(&d) = y; - fmt = "Output: d =\n%.17g = 0x%lx %lx\n"; - } - else if (*buf == '*') { - x = strtoul(buf,&s,10); - if (!*s && x > 18) - STRTOD_DIGLIM = (int)x; - printf("STRTOD_DIGLIM = %lu\n", UL x); - continue; - } - else { - errno = 0; - dval(&d) = strtod(buf,&se); - if (*se == ':') - sscanf(se+1,"%d %d", &mode, &ndigits); - dval(&d1) = atof(buf); - fmt = "Output: d =\n%.17g = 0x%lx %lx, se = %s"; - if (errno) - baderrno(); - } - printf(fmt, dval(&d), UL word0(&d), UL word1(&d), se); - g_fmt(buf1, dval(&d)); - printf("\tg_fmt gives \"%s\"\n", buf1); - if (*buf != '#' && dval(&d) != dval(&d1)) - printf("atof gives\n\ - d1 = %.17g = 0x%lx %lx\nversus\n\ - d = %.17g = 0x%lx %lx\n", dval(&d1), UL word0(&d1), UL word1(&d1), - dval(&d), UL word0(&d), UL word1(&d)); - check(&d); - s = dtoa(dval(&d), mode, ndigits, &decpt, &sign, &se); - printf("\tdtoa(mode = %d, ndigits = %d):\n", mode, ndigits); - printf("\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n", - sign, decpt, (int)(se-s), s); - x = word1(&d); - if (x != 0xffffffff - && (word0(&d) & 0x7ff00000) != 0x7ff00000) { -#ifdef VAX - z = x << 16 | x >> 16; - z++; - z = z << 16 | z >> 16; - word1(&d) = z; -#else - word1(&d) = x + 1; -#endif - printf("\tnextafter(d,+Inf) = %.17g = 0x%lx %lx:\n", - dval(&d), UL word0(&d), UL word1(&d)); - g_fmt(buf1, dval(&d)); - printf("\tg_fmt gives \"%s\"\n", buf1); - s = dtoa(dval(&d), mode, ndigits, &decpt, &sign, &se); - printf( - "\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n", - sign, decpt, (int)(se-s), s); - check(&d); - } - if (x) { -#ifdef VAX - z = x << 16 | x >> 16; - z--; - z = z << 16 | z >> 16; - word1(&d) = z; -#else - word1(&d) = x - 1; -#endif - printf("\tnextafter(d,-Inf) = %.17g = 0x%lx %lx:\n", - dval(&d), UL word0(&d), UL word1(&d)); - g_fmt(buf1, dval(&d)); - printf("\tg_fmt gives \"%s\"\n", buf1); - s = dtoa(dval(&d), mode, ndigits, &decpt, &sign, &se); - printf( - "\tdtoa returns sign = %d, decpt = %d, %d digits:\n%s\n", - sign, decpt, (int)(se-s), s); - check(&d); - } - } - return 0; - } diff --git a/lib/libc/gdtoa/test/dtest.c b/lib/libc/gdtoa/test/dtest.c deleted file mode 100644 index 0140f2ed3..000000000 --- a/lib/libc/gdtoa/test/dtest.c +++ /dev/null @@ -1,139 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test program for g_dfmt, strtoId, strtod, strtopd, and strtord. - * - * Inputs (on stdin): - * r rounding_mode - * n ndig - * number - * #hex0 hex1 - * - * rounding_mode values: - * 0 = toward zero - * 1 = nearest - * 2 = toward +Infinity - * 3 = toward -Infinity - * - * where number is a decimal floating-point number, - * hex0 is a string of Hex <= 8 digits for the most significant - * word of the number, hex1 is a similar string for the other - * (least significant) word, and ndig is a parameters to g_dfmt. - */ - -#include "gdtoaimp.h" -#include -#include - - extern int getround ANSI((int,char*)); - - static char ibuf[2048], obuf[1024]; - -#define U (unsigned long) - - int -main(Void) -{ - char *s, *se, *se1; - double f1, fI[2]; - int i, i1, ndig = 0, r = 1; - long LL[2]; - union { double f; ULong L[2]; } u; - - while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) { - while(*s <= ' ') - if (!*s++) - continue; - switch(*s) { - case 'r': - r = getround(r, s); - continue; - case 'n': - i = s[1]; - if (i <= ' ' || (i >= '0' && i <= '9')) { - ndig = atoi(s+1); - continue; - } - break; /* nan? */ - case '#': - LL[0] = u.L[_0]; - LL[1] = u.L[_1]; - sscanf(s+1, "%lx %lx", &LL[0], &LL[1]); - u.L[_0] = LL[0]; - u.L[_1] = LL[1]; - printf("\nInput: %s", ibuf); - printf("--> f = #%lx %lx\n", (long)u.L[_0], (long)u.L[_1]); - goto fmt_test; - } - printf("\nInput: %s", ibuf); - i = strtord(ibuf, &se, r, &u.f); - if (r == 1) { - if ((u.f != strtod(ibuf, &se1) || se1 != se)) - printf("***strtod and strtord disagree!!\n"); - i1 = strtopd(ibuf, &se, &f1); - if (i != i1 || u.f != f1 || se != se1) - printf("***strtord and strtopd disagree!!\n"); - } - printf("strtod consumes %d bytes and returns %d with f = %.17g = #%lx %lx\n", - (int)(se-ibuf), i, u.f, U u.L[_0], U u.L[_1]); - fmt_test: - se = g_dfmt(obuf, &u.f, ndig, sizeof(obuf)); - printf("g_dfmt(%d) gives %d bytes: \"%s\"\n\n", - ndig, (int)(se-obuf), se ? obuf : ""); - if (*s == '#') - continue; - printf("strtoId returns %d,", strtoId(ibuf, &se, fI, &fI[1])); - printf(" consuming %d bytes.\n", (int)(se-ibuf)); - if (fI[0] == fI[1]) { - if (fI[0] == u.f) - printf("fI[0] == fI[1] == strtod\n"); - else - printf("fI[0] == fI[1] = #%lx %lx = %.17g\n", - U ((ULong*)fI)[_0], U ((ULong*)fI)[_1], - fI[0]); - } - else { - printf("fI[0] = #%lx %lx = %.17g\n", - U ((ULong*)fI)[_0], U ((ULong*)fI)[_1], fI[0]); - printf("fI[1] = #%lx %lx = %.17g\n", - U ((ULong*)&fI[1])[_0], U ((ULong*)&fI[1])[_1], - fI[1]); - if (fI[0] == u.f) - printf("fI[0] == strtod\n"); - else if (fI[1] == u.f) - printf("fI[1] == strtod\n"); - else - printf("**** Both differ from strtod ****\n"); - } - printf("\n"); - } - return 0; - } diff --git a/lib/libc/gdtoa/test/dtst.out b/lib/libc/gdtoa/test/dtst.out deleted file mode 100644 index 7b7a09a60..000000000 --- a/lib/libc/gdtoa/test/dtst.out +++ /dev/null @@ -1,684 +0,0 @@ -Input: 1.23 -Output: d = -1.23 = 0x3ff3ae14 7ae147ae, se = - g_fmt gives "1.23" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 1, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002 = 0x3ff3ae14 7ae147af: - g_fmt gives "1.2300000000000002" - dtoa returns sign = 0, decpt = 1, 17 digits: -12300000000000002 - nextafter(d,-Infinity) = 1.2299999999999998 = 0x3ff3ae14 7ae147ad: - g_fmt gives "1.2299999999999998" - dtoa returns sign = 0, decpt = 1, 17 digits: -12299999999999998 -Input: 1.23e+20 -Output: d = -1.23e+20 = 0x441aabdf 2145b430, se = - g_fmt gives "1.23e+20" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 21, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e+20 = 0x441aabdf 2145b431: - g_fmt gives "123000000000000020000" - dtoa returns sign = 0, decpt = 21, 17 digits: -12300000000000002 - nextafter(d,-Infinity) = 1.2299999999999998e+20 = 0x441aabdf 2145b42f: - g_fmt gives "122999999999999980000" - dtoa returns sign = 0, decpt = 21, 17 digits: -12299999999999998 -Input: 1.23e-20 -Output: d = -1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = - g_fmt gives "1.23e-20" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -19, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532: - g_fmt gives "1.2300000000000002e-20" - dtoa returns sign = 0, decpt = -19, 17 digits: -12300000000000002 - nextafter(d,-Infinity) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530: - g_fmt gives "1.2299999999999999e-20" - dtoa returns sign = 0, decpt = -19, 17 digits: -12299999999999999 -Input: 1.23456789 -Output: d = -1.2345678899999999 = 0x3ff3c0ca 4283de1b, se = - g_fmt gives "1.23456789" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 1, 9 digits: -123456789 - nextafter(d,+Infinity) = 1.2345678900000001 = 0x3ff3c0ca 4283de1c: - g_fmt gives "1.2345678900000001" - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678900000001 - nextafter(d,-Infinity) = 1.2345678899999997 = 0x3ff3c0ca 4283de1a: - g_fmt gives "1.2345678899999997" - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678899999997 -Input: 1.23456589e+20 -Output: d = -1.23456589e+20 = 0x441ac537 a660b997, se = - g_fmt gives "1.23456589e+20" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 21, 9 digits: -123456589 - nextafter(d,+Infinity) = 1.2345658900000001e+20 = 0x441ac537 a660b998: - g_fmt gives "123456589000000010000" - dtoa returns sign = 0, decpt = 21, 17 digits: -12345658900000001 - nextafter(d,-Infinity) = 1.2345658899999998e+20 = 0x441ac537 a660b996: - g_fmt gives "123456588999999980000" - dtoa returns sign = 0, decpt = 21, 17 digits: -12345658899999998 -Input: 1.23e+30 -Output: d = -1.23e+30 = 0x462f0cb0 4e8fb790, se = - g_fmt gives "1.23e+30" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 31, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000001e+30 = 0x462f0cb0 4e8fb791: - g_fmt gives "1.2300000000000001e+30" - dtoa returns sign = 0, decpt = 31, 17 digits: -12300000000000001 - nextafter(d,-Infinity) = 1.2299999999999998e+30 = 0x462f0cb0 4e8fb78f: - g_fmt gives "1.2299999999999998e+30" - dtoa returns sign = 0, decpt = 31, 17 digits: -12299999999999998 -Input: 1.23e-30 -Output: d = -1.2300000000000001e-30 = 0x39b8f286 6f5010ab, se = - g_fmt gives "1.23e-30" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -29, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e-30 = 0x39b8f286 6f5010ac: - g_fmt gives "1.2300000000000002e-30" - dtoa returns sign = 0, decpt = -29, 17 digits: -12300000000000002 - nextafter(d,-Infinity) = 1.2299999999999999e-30 = 0x39b8f286 6f5010aa: - g_fmt gives "1.2299999999999999e-30" - dtoa returns sign = 0, decpt = -29, 17 digits: -12299999999999999 -Input: 1.23456789e-20 -Output: d = -1.2345678899999999e-20 = 0x3bcd2681 471e7ada, se = - g_fmt gives "1.23456789e-20" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -19, 9 digits: -123456789 - nextafter(d,+Infinity) = 1.2345678900000001e-20 = 0x3bcd2681 471e7adb: - g_fmt gives "1.2345678900000001e-20" - dtoa returns sign = 0, decpt = -19, 17 digits: -12345678900000001 - nextafter(d,-Infinity) = 1.2345678899999998e-20 = 0x3bcd2681 471e7ad9: - g_fmt gives "1.2345678899999998e-20" - dtoa returns sign = 0, decpt = -19, 17 digits: -12345678899999998 -Input: 1.23456789e-30 -Output: d = -1.23456789e-30 = 0x39b90a3e 33bbd995, se = - g_fmt gives "1.23456789e-30" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -29, 9 digits: -123456789 - nextafter(d,+Infinity) = 1.2345678900000002e-30 = 0x39b90a3e 33bbd996: - g_fmt gives "1.2345678900000002e-30" - dtoa returns sign = 0, decpt = -29, 17 digits: -12345678900000002 - nextafter(d,-Infinity) = 1.2345678899999998e-30 = 0x39b90a3e 33bbd994: - g_fmt gives "1.2345678899999998e-30" - dtoa returns sign = 0, decpt = -29, 17 digits: -12345678899999998 -Input: 1.234567890123456789 -Output: d = -1.2345678901234567 = 0x3ff3c0ca 428c59fb, se = - g_fmt gives "1.2345678901234567" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678901234567 - nextafter(d,+Infinity) = 1.2345678901234569 = 0x3ff3c0ca 428c59fc: - g_fmt gives "1.234567890123457" - dtoa returns sign = 0, decpt = 1, 16 digits: -1234567890123457 - nextafter(d,-Infinity) = 1.2345678901234565 = 0x3ff3c0ca 428c59fa: - g_fmt gives "1.2345678901234565" - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678901234565 -Input: 1.23456789012345678901234567890123456789 -Output: d = -1.2345678901234567 = 0x3ff3c0ca 428c59fb, se = - g_fmt gives "1.2345678901234567" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678901234567 - nextafter(d,+Infinity) = 1.2345678901234569 = 0x3ff3c0ca 428c59fc: - g_fmt gives "1.234567890123457" - dtoa returns sign = 0, decpt = 1, 16 digits: -1234567890123457 - nextafter(d,-Infinity) = 1.2345678901234565 = 0x3ff3c0ca 428c59fa: - g_fmt gives "1.2345678901234565" - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678901234565 -Input: 1.23e306 -Output: d = -1.23e+306 = 0x7f7c0676 cd1c61f5, se = - g_fmt gives "1.23e+306" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 307, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e+306 = 0x7f7c0676 cd1c61f6: - g_fmt gives "1.2300000000000002e+306" - dtoa returns sign = 0, decpt = 307, 17 digits: -12300000000000002 - nextafter(d,-Infinity) = 1.2299999999999999e+306 = 0x7f7c0676 cd1c61f4: - g_fmt gives "1.2299999999999999e+306" - dtoa returns sign = 0, decpt = 307, 17 digits: -12299999999999999 -Input: 1.23e-306 -Output: d = -1.23e-306 = 0x6ba3b8 5da396e8, se = - g_fmt gives "1.23e-306" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -305, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e-306 = 0x6ba3b8 5da396e9: - g_fmt gives "1.2300000000000002e-306" - dtoa returns sign = 0, decpt = -305, 17 digits: -12300000000000002 - nextafter(d,-Infinity) = 1.2299999999999999e-306 = 0x6ba3b8 5da396e7: - g_fmt gives "1.2299999999999999e-306" - dtoa returns sign = 0, decpt = -305, 17 digits: -12299999999999999 -Input: 1.23e-320 -Output: d = -1.2302234581447039e-320 = 0x0 9ba, se = - g_fmt gives "1.23e-320" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -319, 3 digits: -123 - nextafter(d,+Infinity) = 1.2307175237905451e-320 = 0x0 9bb: - g_fmt gives "1.2307e-320" - dtoa returns sign = 0, decpt = -319, 5 digits: -12307 - nextafter(d,-Infinity) = 1.2297293924988626e-320 = 0x0 9b9: - g_fmt gives "1.2297e-320" - dtoa returns sign = 0, decpt = -319, 5 digits: -12297 -Input: 1.23e-20 -Output: d = -1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = - g_fmt gives "1.23e-20" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -19, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532: - g_fmt gives "1.2300000000000002e-20" - dtoa returns sign = 0, decpt = -19, 17 digits: -12300000000000002 - nextafter(d,-Infinity) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530: - g_fmt gives "1.2299999999999999e-20" - dtoa returns sign = 0, decpt = -19, 17 digits: -12299999999999999 -Input: 1.23456789e307 -Output: d = -1.23456789e+307 = 0x7fb194b1 4bdaecdc, se = - g_fmt gives "1.23456789e+307" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 308, 9 digits: -123456789 - nextafter(d,+Infinity) = 1.2345678900000003e+307 = 0x7fb194b1 4bdaecdd: - g_fmt gives "1.2345678900000003e+307" - dtoa returns sign = 0, decpt = 308, 17 digits: -12345678900000003 - nextafter(d,-Infinity) = 1.2345678899999998e+307 = 0x7fb194b1 4bdaecdb: - g_fmt gives "1.2345678899999998e+307" - dtoa returns sign = 0, decpt = 308, 17 digits: -12345678899999998 -Input: 1.23456589e-307 -Output: d = -1.2345658899999999e-307 = 0x363196 bb9845fa, se = - g_fmt gives "1.23456589e-307" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -306, 9 digits: -123456589 - nextafter(d,+Infinity) = 1.2345658900000001e-307 = 0x363196 bb9845fb: - g_fmt gives "1.2345658900000001e-307" - dtoa returns sign = 0, decpt = -306, 17 digits: -12345658900000001 - nextafter(d,-Infinity) = 1.2345658899999997e-307 = 0x363196 bb9845f9: - g_fmt gives "1.2345658899999997e-307" - dtoa returns sign = 0, decpt = -306, 17 digits: -12345658899999997 -Input: 1.234567890123456789 -Output: d = -1.2345678901234567 = 0x3ff3c0ca 428c59fb, se = - g_fmt gives "1.2345678901234567" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678901234567 - nextafter(d,+Infinity) = 1.2345678901234569 = 0x3ff3c0ca 428c59fc: - g_fmt gives "1.234567890123457" - dtoa returns sign = 0, decpt = 1, 16 digits: -1234567890123457 - nextafter(d,-Infinity) = 1.2345678901234565 = 0x3ff3c0ca 428c59fa: - g_fmt gives "1.2345678901234565" - dtoa returns sign = 0, decpt = 1, 17 digits: -12345678901234565 -Input: 1.234567890123456789e301 -Output: d = -1.2345678901234568e+301 = 0x7e726f51 75f56413, se = - g_fmt gives "1.2345678901234568e+301" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 302, 17 digits: -12345678901234568 - nextafter(d,+Infinity) = 1.234567890123457e+301 = 0x7e726f51 75f56414: - g_fmt gives "1.234567890123457e+301" - dtoa returns sign = 0, decpt = 302, 16 digits: -1234567890123457 - nextafter(d,-Infinity) = 1.2345678901234565e+301 = 0x7e726f51 75f56412: - g_fmt gives "1.2345678901234565e+301" - dtoa returns sign = 0, decpt = 302, 17 digits: -12345678901234565 -Input: 1.234567890123456789e-301 -Output: d = -1.2345678901234567e-301 = 0x1752a64 e34ba0d3, se = - g_fmt gives "1.2345678901234567e-301" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -300, 17 digits: -12345678901234567 - nextafter(d,+Infinity) = 1.2345678901234569e-301 = 0x1752a64 e34ba0d4: - g_fmt gives "1.234567890123457e-301" - dtoa returns sign = 0, decpt = -300, 16 digits: -1234567890123457 - nextafter(d,-Infinity) = 1.2345678901234565e-301 = 0x1752a64 e34ba0d2: - g_fmt gives "1.2345678901234565e-301" - dtoa returns sign = 0, decpt = -300, 17 digits: -12345678901234565 -Input: 1.234567890123456789e-321 -Output: d = -1.2351641146031164e-321 = 0x0 fa, se = - g_fmt gives "1.235e-321" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -320, 4 digits: -1235 - nextafter(d,+Infinity) = 1.2401047710615288e-321 = 0x0 fb: - g_fmt gives "1.24e-321" - dtoa returns sign = 0, decpt = -320, 3 digits: -124 - nextafter(d,-Infinity) = 1.2302234581447039e-321 = 0x0 f9: - g_fmt gives "1.23e-321" - dtoa returns sign = 0, decpt = -320, 3 digits: -123 -Input: 1e23 -Output: d = -9.9999999999999992e+22 = 0x44b52d02 c7e14af6, se = - g_fmt gives "1e+23" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 24, 1 digits: -1 - nextafter(d,+Infinity) = 1.0000000000000001e+23 = 0x44b52d02 c7e14af7: - g_fmt gives "1.0000000000000001e+23" - dtoa returns sign = 0, decpt = 24, 17 digits: -10000000000000001 - nextafter(d,-Infinity) = 9.9999999999999975e+22 = 0x44b52d02 c7e14af5: - g_fmt gives "9.999999999999997e+22" - dtoa returns sign = 0, decpt = 23, 16 digits: -9999999999999997 -Input: 1e310 -Output: d = -Infinity = 0x7ff00000 0, se = - g_fmt gives "Infinity" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = 9999, 8 digits: -Infinity -Input: 9.0259718793241475e-277 -Output: d = -9.0259718793241479e-277 = 0x6a00000 0, se = - g_fmt gives "9.025971879324148e-277" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -276, 16 digits: -9025971879324148 - nextafter(d,+Infinity) = 9.0259718793241499e-277 = 0x6a00000 1: - g_fmt gives "9.02597187932415e-277" - dtoa returns sign = 0, decpt = -276, 15 digits: -902597187932415 -Input: 9.025971879324147880346310405869e-277 -Output: d = -9.0259718793241479e-277 = 0x6a00000 0, se = - g_fmt gives "9.025971879324148e-277" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -276, 16 digits: -9025971879324148 - nextafter(d,+Infinity) = 9.0259718793241499e-277 = 0x6a00000 1: - g_fmt gives "9.02597187932415e-277" - dtoa returns sign = 0, decpt = -276, 15 digits: -902597187932415 -Input: 9.025971879324147880346310405868e-277 -Output: d = -9.0259718793241479e-277 = 0x6a00000 0, se = - g_fmt gives "9.025971879324148e-277" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -276, 16 digits: -9025971879324148 - nextafter(d,+Infinity) = 9.0259718793241499e-277 = 0x6a00000 1: - g_fmt gives "9.02597187932415e-277" - dtoa returns sign = 0, decpt = -276, 15 digits: -902597187932415 -Input: 2.2250738585072014e-308 -Output: d = -2.2250738585072014e-308 = 0x100000 0, se = - g_fmt gives "2.2250738585072014e-308" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -307, 17 digits: -22250738585072014 - nextafter(d,+Infinity) = 2.2250738585072019e-308 = 0x100000 1: - g_fmt gives "2.225073858507202e-308" - dtoa returns sign = 0, decpt = -307, 16 digits: -2225073858507202 -Input: 2.2250738585072013e-308 -Output: d = -2.2250738585072014e-308 = 0x100000 0, se = - g_fmt gives "2.2250738585072014e-308" - dtoa(mode = 0, ndigits = 17): - dtoa returns sign = 0, decpt = -307, 17 digits: -22250738585072014 - nextafter(d,+Infinity) = 2.2250738585072019e-308 = 0x100000 1: - g_fmt gives "2.225073858507202e-308" - dtoa returns sign = 0, decpt = -307, 16 digits: -2225073858507202 -Input: 1.23:2 6 -Output: d = -1.23 = 0x3ff3ae14 7ae147ae, se = :2 6 - g_fmt gives "1.23" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = 1, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002 = 0x3ff3ae14 7ae147af: - g_fmt gives "1.2300000000000002" - dtoa returns sign = 0, decpt = 1, 3 digits: -123 - nextafter(d,-Infinity) = 1.2299999999999998 = 0x3ff3ae14 7ae147ad: - g_fmt gives "1.2299999999999998" - dtoa returns sign = 0, decpt = 1, 3 digits: -123 -Input: 1.23:4 6 -Output: d = -1.23 = 0x3ff3ae14 7ae147ae, se = :4 6 - g_fmt gives "1.23" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = 1, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002 = 0x3ff3ae14 7ae147af: - g_fmt gives "1.2300000000000002" - dtoa returns sign = 0, decpt = 1, 3 digits: -123 - nextafter(d,-Infinity) = 1.2299999999999998 = 0x3ff3ae14 7ae147ad: - g_fmt gives "1.2299999999999998" - dtoa returns sign = 0, decpt = 1, 3 digits: -123 -Input: 1.23e+20:2 6 -Output: d = -1.23e+20 = 0x441aabdf 2145b430, se = :2 6 - g_fmt gives "1.23e+20" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = 21, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e+20 = 0x441aabdf 2145b431: - g_fmt gives "123000000000000020000" - dtoa returns sign = 0, decpt = 21, 3 digits: -123 - nextafter(d,-Infinity) = 1.2299999999999998e+20 = 0x441aabdf 2145b42f: - g_fmt gives "122999999999999980000" - dtoa returns sign = 0, decpt = 21, 3 digits: -123 -Input: 1.23e+20:4 6 -Output: d = -1.23e+20 = 0x441aabdf 2145b430, se = :4 6 - g_fmt gives "1.23e+20" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = 21, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e+20 = 0x441aabdf 2145b431: - g_fmt gives "123000000000000020000" - dtoa returns sign = 0, decpt = 21, 3 digits: -123 - nextafter(d,-Infinity) = 1.2299999999999998e+20 = 0x441aabdf 2145b42f: - g_fmt gives "122999999999999980000" - dtoa returns sign = 0, decpt = 21, 3 digits: -123 -Input: 1.23e-20:2 6 -Output: d = -1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = :2 6 - g_fmt gives "1.23e-20" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = -19, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532: - g_fmt gives "1.2300000000000002e-20" - dtoa returns sign = 0, decpt = -19, 3 digits: -123 - nextafter(d,-Infinity) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530: - g_fmt gives "1.2299999999999999e-20" - dtoa returns sign = 0, decpt = -19, 3 digits: -123 -Input: 1.23e-20:4 6 -Output: d = -1.2300000000000001e-20 = 0x3bcd0ae4 cf767531, se = :4 6 - g_fmt gives "1.23e-20" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = -19, 3 digits: -123 - nextafter(d,+Infinity) = 1.2300000000000002e-20 = 0x3bcd0ae4 cf767532: - g_fmt gives "1.2300000000000002e-20" - dtoa returns sign = 0, decpt = -19, 3 digits: -123 - nextafter(d,-Infinity) = 1.2299999999999999e-20 = 0x3bcd0ae4 cf767530: - g_fmt gives "1.2299999999999999e-20" - dtoa returns sign = 0, decpt = -19, 3 digits: -123 -Input: 1.23456789:2 6 -Output: d = -1.2345678899999999 = 0x3ff3c0ca 4283de1b, se = :2 6 - g_fmt gives "1.23456789" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 - nextafter(d,+Infinity) = 1.2345678900000001 = 0x3ff3c0ca 4283de1c: - g_fmt gives "1.2345678900000001" - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345678899999997 = 0x3ff3c0ca 4283de1a: - g_fmt gives "1.2345678899999997" - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 -Input: 1.23456789:4 6 -Output: d = -1.2345678899999999 = 0x3ff3c0ca 4283de1b, se = :4 6 - g_fmt gives "1.23456789" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 - nextafter(d,+Infinity) = 1.2345678900000001 = 0x3ff3c0ca 4283de1c: - g_fmt gives "1.2345678900000001" - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345678899999997 = 0x3ff3c0ca 4283de1a: - g_fmt gives "1.2345678899999997" - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 -Input: 1.23456589e+20:2 6 -Output: d = -1.23456589e+20 = 0x441ac537 a660b997, se = :2 6 - g_fmt gives "1.23456589e+20" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 - nextafter(d,+Infinity) = 1.2345658900000001e+20 = 0x441ac537 a660b998: - g_fmt gives "123456589000000010000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345658899999998e+20 = 0x441ac537 a660b996: - g_fmt gives "123456588999999980000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 -Input: 1.23456589e+20:4 6 -Output: d = -1.23456589e+20 = 0x441ac537 a660b997, se = :4 6 - g_fmt gives "1.23456589e+20" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 - nextafter(d,+Infinity) = 1.2345658900000001e+20 = 0x441ac537 a660b998: - g_fmt gives "123456589000000010000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345658899999998e+20 = 0x441ac537 a660b996: - g_fmt gives "123456588999999980000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 -Input: 1.23456789e-20:2 6 -Output: d = -1.2345678899999999e-20 = 0x3bcd2681 471e7ada, se = :2 6 - g_fmt gives "1.23456789e-20" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 - nextafter(d,+Infinity) = 1.2345678900000001e-20 = 0x3bcd2681 471e7adb: - g_fmt gives "1.2345678900000001e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345678899999998e-20 = 0x3bcd2681 471e7ad9: - g_fmt gives "1.2345678899999998e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 -Input: 1.23456789e-20:4 6 -Output: d = -1.2345678899999999e-20 = 0x3bcd2681 471e7ada, se = :4 6 - g_fmt gives "1.23456789e-20" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 - nextafter(d,+Infinity) = 1.2345678900000001e-20 = 0x3bcd2681 471e7adb: - g_fmt gives "1.2345678900000001e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345678899999998e-20 = 0x3bcd2681 471e7ad9: - g_fmt gives "1.2345678899999998e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 -Input: 1234565:2 6 -Output: d = -1234565 = 0x4132d685 0, se = :2 6 - g_fmt gives "1234565" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = 7, 6 digits: -123456 - nextafter(d,+Infinity) = 1234565.0000000002 = 0x4132d685 1: - g_fmt gives "1234565.0000000002" - dtoa returns sign = 0, decpt = 7, 6 digits: -123457 -Input: 1234565:4 6 -Output: d = -1234565 = 0x4132d685 0, se = :4 6 - g_fmt gives "1234565" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = 7, 6 digits: -123456 - nextafter(d,+Infinity) = 1234565.0000000002 = 0x4132d685 1: - g_fmt gives "1234565.0000000002" - dtoa returns sign = 0, decpt = 7, 6 digits: -123457 -Input: 1.234565:2 6 -Output: d = -1.2345649999999999 = 0x3ff3c0c7 3abc9470, se = :2 6 - g_fmt gives "1.234565" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = 1, 6 digits: -123456 - nextafter(d,+Infinity) = 1.2345650000000001 = 0x3ff3c0c7 3abc9471: - g_fmt gives "1.2345650000000001" - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345649999999997 = 0x3ff3c0c7 3abc946f: - g_fmt gives "1.2345649999999997" - dtoa returns sign = 0, decpt = 1, 6 digits: -123456 -Input: 1.234565:4 6 -Output: d = -1.2345649999999999 = 0x3ff3c0c7 3abc9470, se = :4 6 - g_fmt gives "1.234565" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = 1, 6 digits: -123456 - nextafter(d,+Infinity) = 1.2345650000000001 = 0x3ff3c0c7 3abc9471: - g_fmt gives "1.2345650000000001" - dtoa returns sign = 0, decpt = 1, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345649999999997 = 0x3ff3c0c7 3abc946f: - g_fmt gives "1.2345649999999997" - dtoa returns sign = 0, decpt = 1, 6 digits: -123456 -Input: 1.234565e+20:2 6 -Output: d = -1.234565e+20 = 0x441ac536 6299040d, se = :2 6 - g_fmt gives "1.234565e+20" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = 21, 6 digits: -123456 - nextafter(d,+Infinity) = 1.2345650000000002e+20 = 0x441ac536 6299040e: - g_fmt gives "123456500000000020000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345649999999998e+20 = 0x441ac536 6299040c: - g_fmt gives "123456499999999980000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123456 -Input: 1.234565e+20:4 6 -Output: d = -1.234565e+20 = 0x441ac536 6299040d, se = :4 6 - g_fmt gives "1.234565e+20" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = 21, 6 digits: -123456 - nextafter(d,+Infinity) = 1.2345650000000002e+20 = 0x441ac536 6299040e: - g_fmt gives "123456500000000020000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345649999999998e+20 = 0x441ac536 6299040c: - g_fmt gives "123456499999999980000" - dtoa returns sign = 0, decpt = 21, 6 digits: -123456 -Input: 1.234565e-20:2 6 -Output: d = -1.234565e-20 = 0x3bcd267c ce45a93f, se = :2 6 - g_fmt gives "1.234565e-20" - dtoa(mode = 2, ndigits = 6): - dtoa returns sign = 0, decpt = -19, 6 digits: -123456 - nextafter(d,+Infinity) = 1.2345650000000001e-20 = 0x3bcd267c ce45a940: - g_fmt gives "1.2345650000000001e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345649999999998e-20 = 0x3bcd267c ce45a93e: - g_fmt gives "1.2345649999999998e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123456 -Input: 1.234565e-20:4 6 -Output: d = -1.234565e-20 = 0x3bcd267c ce45a93f, se = :4 6 - g_fmt gives "1.234565e-20" - dtoa(mode = 4, ndigits = 6): - dtoa returns sign = 0, decpt = -19, 6 digits: -123456 - nextafter(d,+Infinity) = 1.2345650000000001e-20 = 0x3bcd267c ce45a940: - g_fmt gives "1.2345650000000001e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123457 - nextafter(d,-Infinity) = 1.2345649999999998e-20 = 0x3bcd267c ce45a93e: - g_fmt gives "1.2345649999999998e-20" - dtoa returns sign = 0, decpt = -19, 6 digits: -123456 diff --git a/lib/libc/gdtoa/test/f.out b/lib/libc/gdtoa/test/f.out deleted file mode 100644 index d82e4e6f9..000000000 --- a/lib/libc/gdtoa/test/f.out +++ /dev/null @@ -1,988 +0,0 @@ - -Input: 1.23 -strtof consumes 4 bytes and returns 1.23 = #3f9d70a4 -g_ffmt(0) gives 4 bytes: "1.23" - -strtoIf returns 33, consuming 4 bytes. -fI[0] = #3f9d70a3 = 1.2299999 -fI[1] = #3f9d70a4 = 1.23 -fI[1] == strtof - - -Input: 1.23e+20 -strtof consumes 8 bytes and returns 1.23e+20 = #60d55ef9 -g_ffmt(0) gives 8 bytes: "1.23e+20" - -strtoIf returns 17, consuming 8 bytes. -fI[0] = #60d55ef9 = 1.23e+20 -fI[1] = #60d55efa = 1.2300001e+20 -fI[0] == strtof - - -Input: 1.23e-20 -strtof consumes 8 bytes and returns 1.23e-20 = #1e685726 -g_ffmt(0) gives 8 bytes: "1.23e-20" - -strtoIf returns 17, consuming 8 bytes. -fI[0] = #1e685726 = 1.23e-20 -fI[1] = #1e685727 = 1.23e-20 -fI[0] == strtof - - -Input: 1.23456789 -strtof consumes 10 bytes and returns 1.2345679 = #3f9e0652 -g_ffmt(0) gives 9 bytes: "1.2345679" - -strtoIf returns 17, consuming 10 bytes. -fI[0] = #3f9e0652 = 1.2345679 -fI[1] = #3f9e0653 = 1.234568 -fI[0] == strtof - - -Input: 1.23456589e+20 -strtof consumes 14 bytes and returns 1.2345659e+20 = #60d629bd -g_ffmt(0) gives 13 bytes: "1.2345659e+20" - -strtoIf returns 17, consuming 14 bytes. -fI[0] = #60d629bd = 1.2345659e+20 -fI[1] = #60d629be = 1.234566e+20 -fI[0] == strtof - - -Input: 1.23e+30 -strtof consumes 8 bytes and returns 1.23e+30 = #71786582 -g_ffmt(0) gives 8 bytes: "1.23e+30" - -strtoIf returns 17, consuming 8 bytes. -fI[0] = #71786582 = 1.23e+30 -fI[1] = #71786583 = 1.23e+30 -fI[0] == strtof - - -Input: 1.23e-30 -strtof consumes 8 bytes and returns 1.23e-30 = #dc79433 -g_ffmt(0) gives 8 bytes: "1.23e-30" - -strtoIf returns 17, consuming 8 bytes. -fI[0] = #dc79433 = 1.23e-30 -fI[1] = #dc79434 = 1.23e-30 -fI[0] == strtof - - -Input: 1.23456789e-20 -strtof consumes 14 bytes and returns 1.2345679e-20 = #1e69340a -g_ffmt(0) gives 13 bytes: "1.2345679e-20" - -strtoIf returns 17, consuming 14 bytes. -fI[0] = #1e69340a = 1.2345679e-20 -fI[1] = #1e69340b = 1.234568e-20 -fI[0] == strtof - - -Input: 1.23456789e-30 -strtof consumes 14 bytes and returns 1.2345679e-30 = #dc851f2 -g_ffmt(0) gives 13 bytes: "1.2345679e-30" - -strtoIf returns 33, consuming 14 bytes. -fI[0] = #dc851f1 = 1.2345678e-30 -fI[1] = #dc851f2 = 1.2345679e-30 -fI[1] == strtof - - -Input: 1.234567890123456789 -strtof consumes 20 bytes and returns 1.2345679 = #3f9e0652 -g_ffmt(0) gives 9 bytes: "1.2345679" - -strtoIf returns 17, consuming 20 bytes. -fI[0] = #3f9e0652 = 1.2345679 -fI[1] = #3f9e0653 = 1.234568 -fI[0] == strtof - - -Input: 1.23456789012345678901234567890123456789 -strtof consumes 40 bytes and returns 1.2345679 = #3f9e0652 -g_ffmt(0) gives 9 bytes: "1.2345679" - -strtoIf returns 17, consuming 40 bytes. -fI[0] = #3f9e0652 = 1.2345679 -fI[1] = #3f9e0653 = 1.234568 -fI[0] == strtof - - -Input: 1.23e306 -strtof consumes 8 bytes and returns Infinity = #7f800000 -g_ffmt(0) gives 8 bytes: "Infinity" - -strtoIf returns 163, consuming 8 bytes. -fI[0] = #7f7fffff = 3.4028235e+38 -fI[1] = #7f800000 = Infinity -fI[1] == strtof - - -Input: 1.23e-306 -strtof consumes 9 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 9 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 1.23e-320 -strtof consumes 9 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 9 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 1.23e-20 -strtof consumes 8 bytes and returns 1.23e-20 = #1e685726 -g_ffmt(0) gives 8 bytes: "1.23e-20" - -strtoIf returns 17, consuming 8 bytes. -fI[0] = #1e685726 = 1.23e-20 -fI[1] = #1e685727 = 1.23e-20 -fI[0] == strtof - - -Input: 1.23456789e307 -strtof consumes 14 bytes and returns Infinity = #7f800000 -g_ffmt(0) gives 8 bytes: "Infinity" - -strtoIf returns 163, consuming 14 bytes. -fI[0] = #7f7fffff = 3.4028235e+38 -fI[1] = #7f800000 = Infinity -fI[1] == strtof - - -Input: 1.23456589e-307 -strtof consumes 15 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 15 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 1.234567890123456789 -strtof consumes 20 bytes and returns 1.2345679 = #3f9e0652 -g_ffmt(0) gives 9 bytes: "1.2345679" - -strtoIf returns 17, consuming 20 bytes. -fI[0] = #3f9e0652 = 1.2345679 -fI[1] = #3f9e0653 = 1.234568 -fI[0] == strtof - - -Input: 1.234567890123456789e301 -strtof consumes 24 bytes and returns Infinity = #7f800000 -g_ffmt(0) gives 8 bytes: "Infinity" - -strtoIf returns 163, consuming 24 bytes. -fI[0] = #7f7fffff = 3.4028235e+38 -fI[1] = #7f800000 = Infinity -fI[1] == strtof - - -Input: 1.234567890123456789e-301 -strtof consumes 25 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 25 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 1.234567890123456789e-321 -strtof consumes 25 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 25 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 1e23 -strtof consumes 4 bytes and returns 9.9999998e+22 = #65a96816 -g_ffmt(0) gives 5 bytes: "1e+23" - -strtoIf returns 17, consuming 4 bytes. -fI[0] = #65a96816 = 9.9999998e+22 -fI[1] = #65a96817 = 1.0000001e+23 -fI[0] == strtof - - -Input: 1e310 -strtof consumes 5 bytes and returns Infinity = #7f800000 -g_ffmt(0) gives 8 bytes: "Infinity" - -strtoIf returns 163, consuming 5 bytes. -fI[0] = #7f7fffff = 3.4028235e+38 -fI[1] = #7f800000 = Infinity -fI[1] == strtof - - -Input: 9.0259718793241475e-277 -strtof consumes 23 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 23 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 9.025971879324147880346310405869e-277 -strtof consumes 37 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 37 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 9.025971879324147880346310405868e-277 -strtof consumes 37 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 37 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 2.2250738585072014e-308 -strtof consumes 23 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 23 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - - -Input: 2.2250738585072013e-308 -strtof consumes 23 bytes and returns 0 = #0 -g_ffmt(0) gives 1 bytes: "0" - -strtoIf returns 80, consuming 23 bytes. -fI[0] = #0 = 0 -fI[1] = #1 = 1.4012985e-45 -fI[0] == strtof - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 -strtof consumes 3 bytes and returns 1.0999999 = #3f8ccccc -g_ffmt(0) gives 9 bytes: "1.0999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f8ccccc = 1.0999999 -fI[1] = #3f8ccccd = 1.1 -fI[0] == strtof - - -Input: -1.1 -strtof consumes 4 bytes and returns -1.0999999 = #bf8ccccc -g_ffmt(0) gives 10 bytes: "-1.0999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf8ccccd = -1.1 -fI[1] = #bf8ccccc = -1.0999999 -fI[1] == strtof - - -Input: 1.2 -strtof consumes 3 bytes and returns 1.1999999 = #3f999999 -g_ffmt(0) gives 9 bytes: "1.1999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f999999 = 1.1999999 -fI[1] = #3f99999a = 1.2 -fI[0] == strtof - - -Input: -1.2 -strtof consumes 4 bytes and returns -1.1999999 = #bf999999 -g_ffmt(0) gives 10 bytes: "-1.1999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf99999a = -1.2 -fI[1] = #bf999999 = -1.1999999 -fI[1] == strtof - - -Input: 1.3 -strtof consumes 3 bytes and returns 1.3 = #3fa66666 -g_ffmt(0) gives 3 bytes: "1.3" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fa66666 = 1.3 -fI[1] = #3fa66667 = 1.3000001 -fI[0] == strtof - - -Input: -1.3 -strtof consumes 4 bytes and returns -1.3 = #bfa66666 -g_ffmt(0) gives 4 bytes: "-1.3" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfa66667 = -1.3000001 -fI[1] = #bfa66666 = -1.3 -fI[1] == strtof - - -Input: 1.4 -strtof consumes 3 bytes and returns 1.4 = #3fb33333 -g_ffmt(0) gives 3 bytes: "1.4" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fb33333 = 1.4 -fI[1] = #3fb33334 = 1.4000001 -fI[0] == strtof - - -Input: -1.4 -strtof consumes 4 bytes and returns -1.4 = #bfb33333 -g_ffmt(0) gives 4 bytes: "-1.4" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfb33334 = -1.4000001 -fI[1] = #bfb33333 = -1.4 -fI[1] == strtof - - -Input: 1.5 -strtof consumes 3 bytes and returns 1.5 = #3fc00000 -g_ffmt(0) gives 3 bytes: "1.5" - -strtoIf returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtof - - -Input: -1.5 -strtof consumes 4 bytes and returns -1.5 = #bfc00000 -g_ffmt(0) gives 4 bytes: "-1.5" - -strtoIf returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtof - - -Input: 1.6 -strtof consumes 3 bytes and returns 1.5999999 = #3fcccccc -g_ffmt(0) gives 9 bytes: "1.5999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fcccccc = 1.5999999 -fI[1] = #3fcccccd = 1.6 -fI[0] == strtof - - -Input: -1.6 -strtof consumes 4 bytes and returns -1.5999999 = #bfcccccc -g_ffmt(0) gives 10 bytes: "-1.5999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfcccccd = -1.6 -fI[1] = #bfcccccc = -1.5999999 -fI[1] == strtof - - -Input: 1.7 -strtof consumes 3 bytes and returns 1.6999999 = #3fd99999 -g_ffmt(0) gives 9 bytes: "1.6999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fd99999 = 1.6999999 -fI[1] = #3fd9999a = 1.7 -fI[0] == strtof - - -Input: -1.7 -strtof consumes 4 bytes and returns -1.6999999 = #bfd99999 -g_ffmt(0) gives 10 bytes: "-1.6999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfd9999a = -1.7 -fI[1] = #bfd99999 = -1.6999999 -fI[1] == strtof - - -Input: 1.8 -strtof consumes 3 bytes and returns 1.8 = #3fe66666 -g_ffmt(0) gives 3 bytes: "1.8" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fe66666 = 1.8 -fI[1] = #3fe66667 = 1.8000001 -fI[0] == strtof - - -Input: -1.8 -strtof consumes 4 bytes and returns -1.8 = #bfe66666 -g_ffmt(0) gives 4 bytes: "-1.8" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfe66667 = -1.8000001 -fI[1] = #bfe66666 = -1.8 -fI[1] == strtof - - -Input: 1.9 -strtof consumes 3 bytes and returns 1.9 = #3ff33333 -g_ffmt(0) gives 3 bytes: "1.9" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3ff33333 = 1.9 -fI[1] = #3ff33334 = 1.9000001 -fI[0] == strtof - - -Input: -1.9 -strtof consumes 4 bytes and returns -1.9 = #bff33333 -g_ffmt(0) gives 4 bytes: "-1.9" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bff33334 = -1.9000001 -fI[1] = #bff33333 = -1.9 -fI[1] == strtof - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 -strtof consumes 3 bytes and returns 1.1 = #3f8ccccd -g_ffmt(0) gives 3 bytes: "1.1" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f8ccccc = 1.0999999 -fI[1] = #3f8ccccd = 1.1 -fI[1] == strtof - - -Input: -1.1 -strtof consumes 4 bytes and returns -1.1 = #bf8ccccd -g_ffmt(0) gives 4 bytes: "-1.1" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf8ccccd = -1.1 -fI[1] = #bf8ccccc = -1.0999999 -fI[0] == strtof - - -Input: 1.2 -strtof consumes 3 bytes and returns 1.2 = #3f99999a -g_ffmt(0) gives 3 bytes: "1.2" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f999999 = 1.1999999 -fI[1] = #3f99999a = 1.2 -fI[1] == strtof - - -Input: -1.2 -strtof consumes 4 bytes and returns -1.2 = #bf99999a -g_ffmt(0) gives 4 bytes: "-1.2" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf99999a = -1.2 -fI[1] = #bf999999 = -1.1999999 -fI[0] == strtof - - -Input: 1.3 -strtof consumes 3 bytes and returns 1.3 = #3fa66666 -g_ffmt(0) gives 3 bytes: "1.3" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fa66666 = 1.3 -fI[1] = #3fa66667 = 1.3000001 -fI[0] == strtof - - -Input: -1.3 -strtof consumes 4 bytes and returns -1.3 = #bfa66666 -g_ffmt(0) gives 4 bytes: "-1.3" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfa66667 = -1.3000001 -fI[1] = #bfa66666 = -1.3 -fI[1] == strtof - - -Input: 1.4 -strtof consumes 3 bytes and returns 1.4 = #3fb33333 -g_ffmt(0) gives 3 bytes: "1.4" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fb33333 = 1.4 -fI[1] = #3fb33334 = 1.4000001 -fI[0] == strtof - - -Input: -1.4 -strtof consumes 4 bytes and returns -1.4 = #bfb33333 -g_ffmt(0) gives 4 bytes: "-1.4" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfb33334 = -1.4000001 -fI[1] = #bfb33333 = -1.4 -fI[1] == strtof - - -Input: 1.5 -strtof consumes 3 bytes and returns 1.5 = #3fc00000 -g_ffmt(0) gives 3 bytes: "1.5" - -strtoIf returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtof - - -Input: -1.5 -strtof consumes 4 bytes and returns -1.5 = #bfc00000 -g_ffmt(0) gives 4 bytes: "-1.5" - -strtoIf returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtof - - -Input: 1.6 -strtof consumes 3 bytes and returns 1.6 = #3fcccccd -g_ffmt(0) gives 3 bytes: "1.6" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fcccccc = 1.5999999 -fI[1] = #3fcccccd = 1.6 -fI[1] == strtof - - -Input: -1.6 -strtof consumes 4 bytes and returns -1.6 = #bfcccccd -g_ffmt(0) gives 4 bytes: "-1.6" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfcccccd = -1.6 -fI[1] = #bfcccccc = -1.5999999 -fI[0] == strtof - - -Input: 1.7 -strtof consumes 3 bytes and returns 1.7 = #3fd9999a -g_ffmt(0) gives 3 bytes: "1.7" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fd99999 = 1.6999999 -fI[1] = #3fd9999a = 1.7 -fI[1] == strtof - - -Input: -1.7 -strtof consumes 4 bytes and returns -1.7 = #bfd9999a -g_ffmt(0) gives 4 bytes: "-1.7" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfd9999a = -1.7 -fI[1] = #bfd99999 = -1.6999999 -fI[0] == strtof - - -Input: 1.8 -strtof consumes 3 bytes and returns 1.8 = #3fe66666 -g_ffmt(0) gives 3 bytes: "1.8" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fe66666 = 1.8 -fI[1] = #3fe66667 = 1.8000001 -fI[0] == strtof - - -Input: -1.8 -strtof consumes 4 bytes and returns -1.8 = #bfe66666 -g_ffmt(0) gives 4 bytes: "-1.8" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfe66667 = -1.8000001 -fI[1] = #bfe66666 = -1.8 -fI[1] == strtof - - -Input: 1.9 -strtof consumes 3 bytes and returns 1.9 = #3ff33333 -g_ffmt(0) gives 3 bytes: "1.9" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3ff33333 = 1.9 -fI[1] = #3ff33334 = 1.9000001 -fI[0] == strtof - - -Input: -1.9 -strtof consumes 4 bytes and returns -1.9 = #bff33333 -g_ffmt(0) gives 4 bytes: "-1.9" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bff33334 = -1.9000001 -fI[1] = #bff33333 = -1.9 -fI[1] == strtof - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 -strtof consumes 3 bytes and returns 1.1 = #3f8ccccd -g_ffmt(0) gives 3 bytes: "1.1" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f8ccccc = 1.0999999 -fI[1] = #3f8ccccd = 1.1 -fI[1] == strtof - - -Input: -1.1 -strtof consumes 4 bytes and returns -1.0999999 = #bf8ccccc -g_ffmt(0) gives 10 bytes: "-1.0999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf8ccccd = -1.1 -fI[1] = #bf8ccccc = -1.0999999 -fI[1] == strtof - - -Input: 1.2 -strtof consumes 3 bytes and returns 1.2 = #3f99999a -g_ffmt(0) gives 3 bytes: "1.2" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f999999 = 1.1999999 -fI[1] = #3f99999a = 1.2 -fI[1] == strtof - - -Input: -1.2 -strtof consumes 4 bytes and returns -1.1999999 = #bf999999 -g_ffmt(0) gives 10 bytes: "-1.1999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf99999a = -1.2 -fI[1] = #bf999999 = -1.1999999 -fI[1] == strtof - - -Input: 1.3 -strtof consumes 3 bytes and returns 1.3000001 = #3fa66667 -g_ffmt(0) gives 9 bytes: "1.3000001" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fa66666 = 1.3 -fI[1] = #3fa66667 = 1.3000001 -fI[1] == strtof - - -Input: -1.3 -strtof consumes 4 bytes and returns -1.3 = #bfa66666 -g_ffmt(0) gives 4 bytes: "-1.3" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfa66667 = -1.3000001 -fI[1] = #bfa66666 = -1.3 -fI[1] == strtof - - -Input: 1.4 -strtof consumes 3 bytes and returns 1.4000001 = #3fb33334 -g_ffmt(0) gives 9 bytes: "1.4000001" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fb33333 = 1.4 -fI[1] = #3fb33334 = 1.4000001 -fI[1] == strtof - - -Input: -1.4 -strtof consumes 4 bytes and returns -1.4 = #bfb33333 -g_ffmt(0) gives 4 bytes: "-1.4" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfb33334 = -1.4000001 -fI[1] = #bfb33333 = -1.4 -fI[1] == strtof - - -Input: 1.5 -strtof consumes 3 bytes and returns 1.5 = #3fc00000 -g_ffmt(0) gives 3 bytes: "1.5" - -strtoIf returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtof - - -Input: -1.5 -strtof consumes 4 bytes and returns -1.5 = #bfc00000 -g_ffmt(0) gives 4 bytes: "-1.5" - -strtoIf returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtof - - -Input: 1.6 -strtof consumes 3 bytes and returns 1.6 = #3fcccccd -g_ffmt(0) gives 3 bytes: "1.6" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fcccccc = 1.5999999 -fI[1] = #3fcccccd = 1.6 -fI[1] == strtof - - -Input: -1.6 -strtof consumes 4 bytes and returns -1.5999999 = #bfcccccc -g_ffmt(0) gives 10 bytes: "-1.5999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfcccccd = -1.6 -fI[1] = #bfcccccc = -1.5999999 -fI[1] == strtof - - -Input: 1.7 -strtof consumes 3 bytes and returns 1.7 = #3fd9999a -g_ffmt(0) gives 3 bytes: "1.7" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fd99999 = 1.6999999 -fI[1] = #3fd9999a = 1.7 -fI[1] == strtof - - -Input: -1.7 -strtof consumes 4 bytes and returns -1.6999999 = #bfd99999 -g_ffmt(0) gives 10 bytes: "-1.6999999" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfd9999a = -1.7 -fI[1] = #bfd99999 = -1.6999999 -fI[1] == strtof - - -Input: 1.8 -strtof consumes 3 bytes and returns 1.8000001 = #3fe66667 -g_ffmt(0) gives 9 bytes: "1.8000001" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fe66666 = 1.8 -fI[1] = #3fe66667 = 1.8000001 -fI[1] == strtof - - -Input: -1.8 -strtof consumes 4 bytes and returns -1.8 = #bfe66666 -g_ffmt(0) gives 4 bytes: "-1.8" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfe66667 = -1.8000001 -fI[1] = #bfe66666 = -1.8 -fI[1] == strtof - - -Input: 1.9 -strtof consumes 3 bytes and returns 1.9000001 = #3ff33334 -g_ffmt(0) gives 9 bytes: "1.9000001" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3ff33333 = 1.9 -fI[1] = #3ff33334 = 1.9000001 -fI[1] == strtof - - -Input: -1.9 -strtof consumes 4 bytes and returns -1.9 = #bff33333 -g_ffmt(0) gives 4 bytes: "-1.9" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bff33334 = -1.9000001 -fI[1] = #bff33333 = -1.9 -fI[1] == strtof - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 -strtof consumes 3 bytes and returns 1.0999999 = #3f8ccccc -g_ffmt(0) gives 9 bytes: "1.0999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f8ccccc = 1.0999999 -fI[1] = #3f8ccccd = 1.1 -fI[0] == strtof - - -Input: -1.1 -strtof consumes 4 bytes and returns -1.1 = #bf8ccccd -g_ffmt(0) gives 4 bytes: "-1.1" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf8ccccd = -1.1 -fI[1] = #bf8ccccc = -1.0999999 -fI[0] == strtof - - -Input: 1.2 -strtof consumes 3 bytes and returns 1.1999999 = #3f999999 -g_ffmt(0) gives 9 bytes: "1.1999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3f999999 = 1.1999999 -fI[1] = #3f99999a = 1.2 -fI[0] == strtof - - -Input: -1.2 -strtof consumes 4 bytes and returns -1.2 = #bf99999a -g_ffmt(0) gives 4 bytes: "-1.2" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bf99999a = -1.2 -fI[1] = #bf999999 = -1.1999999 -fI[0] == strtof - - -Input: 1.3 -strtof consumes 3 bytes and returns 1.3 = #3fa66666 -g_ffmt(0) gives 3 bytes: "1.3" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fa66666 = 1.3 -fI[1] = #3fa66667 = 1.3000001 -fI[0] == strtof - - -Input: -1.3 -strtof consumes 4 bytes and returns -1.3000001 = #bfa66667 -g_ffmt(0) gives 10 bytes: "-1.3000001" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfa66667 = -1.3000001 -fI[1] = #bfa66666 = -1.3 -fI[0] == strtof - - -Input: 1.4 -strtof consumes 3 bytes and returns 1.4 = #3fb33333 -g_ffmt(0) gives 3 bytes: "1.4" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fb33333 = 1.4 -fI[1] = #3fb33334 = 1.4000001 -fI[0] == strtof - - -Input: -1.4 -strtof consumes 4 bytes and returns -1.4000001 = #bfb33334 -g_ffmt(0) gives 10 bytes: "-1.4000001" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfb33334 = -1.4000001 -fI[1] = #bfb33333 = -1.4 -fI[0] == strtof - - -Input: 1.5 -strtof consumes 3 bytes and returns 1.5 = #3fc00000 -g_ffmt(0) gives 3 bytes: "1.5" - -strtoIf returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtof - - -Input: -1.5 -strtof consumes 4 bytes and returns -1.5 = #bfc00000 -g_ffmt(0) gives 4 bytes: "-1.5" - -strtoIf returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtof - - -Input: 1.6 -strtof consumes 3 bytes and returns 1.5999999 = #3fcccccc -g_ffmt(0) gives 9 bytes: "1.5999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fcccccc = 1.5999999 -fI[1] = #3fcccccd = 1.6 -fI[0] == strtof - - -Input: -1.6 -strtof consumes 4 bytes and returns -1.6 = #bfcccccd -g_ffmt(0) gives 4 bytes: "-1.6" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfcccccd = -1.6 -fI[1] = #bfcccccc = -1.5999999 -fI[0] == strtof - - -Input: 1.7 -strtof consumes 3 bytes and returns 1.6999999 = #3fd99999 -g_ffmt(0) gives 9 bytes: "1.6999999" - -strtoIf returns 33, consuming 3 bytes. -fI[0] = #3fd99999 = 1.6999999 -fI[1] = #3fd9999a = 1.7 -fI[0] == strtof - - -Input: -1.7 -strtof consumes 4 bytes and returns -1.7 = #bfd9999a -g_ffmt(0) gives 4 bytes: "-1.7" - -strtoIf returns 41, consuming 4 bytes. -fI[0] = #bfd9999a = -1.7 -fI[1] = #bfd99999 = -1.6999999 -fI[0] == strtof - - -Input: 1.8 -strtof consumes 3 bytes and returns 1.8 = #3fe66666 -g_ffmt(0) gives 3 bytes: "1.8" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3fe66666 = 1.8 -fI[1] = #3fe66667 = 1.8000001 -fI[0] == strtof - - -Input: -1.8 -strtof consumes 4 bytes and returns -1.8000001 = #bfe66667 -g_ffmt(0) gives 10 bytes: "-1.8000001" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bfe66667 = -1.8000001 -fI[1] = #bfe66666 = -1.8 -fI[0] == strtof - - -Input: 1.9 -strtof consumes 3 bytes and returns 1.9 = #3ff33333 -g_ffmt(0) gives 3 bytes: "1.9" - -strtoIf returns 17, consuming 3 bytes. -fI[0] = #3ff33333 = 1.9 -fI[1] = #3ff33334 = 1.9000001 -fI[0] == strtof - - -Input: -1.9 -strtof consumes 4 bytes and returns -1.9000001 = #bff33334 -g_ffmt(0) gives 10 bytes: "-1.9000001" - -strtoIf returns 25, consuming 4 bytes. -fI[0] = #bff33334 = -1.9000001 -fI[1] = #bff33333 = -1.9 -fI[0] == strtof - diff --git a/lib/libc/gdtoa/test/ftest.c b/lib/libc/gdtoa/test/ftest.c deleted file mode 100644 index 2006fdcdd..000000000 --- a/lib/libc/gdtoa/test/ftest.c +++ /dev/null @@ -1,140 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test program for g_ffmt, strtof, strtoIf, strtopf, and strtorf. - * - * Inputs (on stdin): - * r rounding_mode - * n ndig - * number - * #hex - * - * rounding_mode values: - * 0 = toward zero - * 1 = nearest - * 2 = toward +Infinity - * 3 = toward -Infinity - * - * where number is a decimal floating-point number, - * hex is a string of <= 8 Hex digits for the internal representation - * of the number, and ndig is a parameters to g_ffmt. - */ - -#include "gdtoa.h" -#include -#include - - extern int getround ANSI((int,char*)); - - static char ibuf[2048], obuf[1024]; - -#define U (unsigned long) - - int -main(Void) -{ - char *s, *se, *se1; - int dItry, i, i1, ndig = 0, r = 1; - float f1, fI[2]; - union { float f; ULong L[1]; } u; - - while( (s = fgets(ibuf, sizeof(ibuf), stdin)) !=0) { - while(*s <= ' ') - if (!*s++) - continue; - dItry = 0; - switch(*s) { - case 'r': - r = getround(r, s); - continue; - case 'n': - i = s[1]; - if (i <= ' ' || (i >= '0' && i <= '9')) { - ndig = atoi(s+1); - continue; - } - break; /* nan? */ - case '#': - /* sscanf(s+1, "%lx", &u.L[0]); */ - u.L[0] = (ULong)strtoul(s+1, &se, 16); - printf("\nInput: %s", ibuf); - printf(" --> f = #%lx\n", U u.L[0]); - goto fmt_test; - } - dItry = 1; - printf("\nInput: %s", ibuf); - i = strtorf(ibuf, &se, r, &u.f); - if (r == 1) { - if (u.f != (i1 = strtopf(ibuf, &se1, &f1), f1) - || se != se1 || i != i1) { - printf("***strtopf and strtorf disagree!!\n"); - if (u.f != f1) - printf("\tf1 = %g\n", (double)f1); - if (i != i1) - printf("\ti = %d but i1 = %d\n", i, i1); - if (se != se1) - printf("se - se1 = %d\n", (int)(se-se1)); - } - if (u.f != strtof(ibuf, &se1) || se != se1) - printf("***strtof and strtorf disagree!\n"); - } - printf("strtof consumes %d bytes and returns %.8g = #%lx\n", - (int)(se-ibuf), u.f, U u.L[0]); - fmt_test: - se = g_ffmt(obuf, &u.f, ndig, sizeof(obuf)); - printf("g_ffmt(%d) gives %d bytes: \"%s\"\n\n", - ndig, (int)(se-obuf), se ? obuf : ""); - if (!dItry) - continue; - printf("strtoIf returns %d,", strtoIf(ibuf, &se, fI, &fI[1])); - printf(" consuming %d bytes.\n", (int)(se-ibuf)); - if (fI[0] == fI[1]) { - if (fI[0] == u.f) - printf("fI[0] == fI[1] == strtof\n"); - else - printf("fI[0] == fI[1] = #%lx = %.8g\n", - U *(ULong*)fI, fI[0]); - } - else { - printf("fI[0] = #%lx = %.8g\nfI[1] = #%lx = %.8g\n", - U *(ULong*)fI, fI[0], - U *(ULong*)&fI[1], fI[1]); - if (fI[0] == u.f) - printf("fI[0] == strtof\n"); - else if (fI[1] == u.f) - printf("fI[1] == strtof\n"); - else - printf("**** Both differ from strtof ****\n"); - } - printf("\n"); - } - return 0; - } diff --git a/lib/libc/gdtoa/test/getround.c b/lib/libc/gdtoa/test/getround.c deleted file mode 100644 index 05eb199e7..000000000 --- a/lib/libc/gdtoa/test/getround.c +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include -#include - -static char *dir[4] = { "toward zero", "nearest", "toward +Infinity", - "toward -Infinity" }; - -#ifdef Honor_FLT_ROUNDS -#include -static int fe_conv[4] = {FE_TOWARDZERO, FE_TONEAREST, FE_UPWARD, FE_DOWNWARD }; -#endif - - int -#ifdef KR_headers -getround(r, s) int r; char *s; -#else -getround(int r, char *s) -#endif -{ - int i; - - while(*++s <= ' ') { - if (!*s) { - printf("Current round mode for strtor... is %d (%s).\n", - r, dir[r]); - return r; - } - } - i = atoi(s); - if (i >= 0 && i < 4) { - printf("Rounding mode for strtor... "); - if (i == r) - printf("was and is %d (%s)\n", i, dir[i]); - else - printf("changed from %d (%s) to %d (%s)\n", - r, dir[r], i, dir[i]); -#ifdef Honor_FLT_ROUNDS - fesetround(fe_conv[i]); -#endif - return i; - } - printf("Bad rounding direction %d: choose among\n", i); - for(i = 0; i < 4; i++) - printf("\t%d (%s)\n", i, dir[i]); - printf("Leaving rounding mode for strtor... at %d (%s)\n", r, dir[r]); - return r; - } - -#ifdef USE_MY_LOCALE -#include - - struct lconv * -localeconv(void) -{ - static struct lconv mylocale; - mylocale.decimal_point = ""; - return &mylocale; - } -#endif - diff --git a/lib/libc/gdtoa/test/makefile b/lib/libc/gdtoa/test/makefile deleted file mode 100644 index 79c9874ea..000000000 --- a/lib/libc/gdtoa/test/makefile +++ /dev/null @@ -1,169 +0,0 @@ -# /**************************************************************** -# Copyright (C) 1998, 2000 by Lucent Technologies -# All Rights Reserved -# -# Permission to use, copy, modify, and distribute this software and -# its documentation for any purpose and without fee is hereby -# granted, provided that the above copyright notice appear in all -# copies and that both that the copyright notice and this -# permission notice and warranty disclaimer appear in supporting -# documentation, and that the name of Lucent or any of its entities -# not be used in advertising or publicity pertaining to -# distribution of the software without specific, written prior -# permission. -# -# LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -# IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -# SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -# IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -# ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -# THIS SOFTWARE. -# -# ****************************************************************/ - -CC = cc -CFLAGS = -g -I.. -CFLAGS+=-I${.CURDIR}/../../arch/${MACHINE_ARCH}/gdtoa -L = -lm -L1 = -lm -#use "L1=-lm" when compiled with -DHonor_FLTP_ROUNDS or -DUSE_LOCALE -INFFIX = | sed 's/[Ii][Nn][Ff][intyINTY]*/Infinity/g' - -.PATH: /usr/src/lib/libc/gdtoa - -all: dt dItest ddtest dtest ftest Qtest xLtest xtest ddtestsi dItestsi tests - -dt = dt.o $A -dt: $(dt) - $(CC) -o dt $(dt) $L - -dItest = dItest.o getround.o g_dfmt.o strtoId.o strtodI.o \ - g__fmt.o strtoIg.o -dItest: $(dItest) - $(CC) -o dItest $(dItest) $(L1) - -ddtest = ddtest.o getround.o g_dfmt.o strtordd.o strtopdd.o g_ddfmt.o \ - strtoIdd.o g__fmt.o strtoIg.o -ddtest: $(ddtest) - $(CC) -o ddtest $(ddtest) $L - -dtest = dtest.o getround.o g_dfmt.o strtopd.o strtoId.o \ - g__fmt.o strtoIg.o -dtest: $(dtest) - $(CC) -o dtest $(dtest) $L - -ftest = ftest.o getround.o strtorf.o strtopf.o g_ffmt.o strtoIf.o \ - g__fmt.o strtoIg.o -ftest: $(ftest) - $(CC) -o ftest $(ftest) $(L1) - -Qtest = Qtest.o getround.o strtorQ.o g_Qfmt.o strtoIQ.o strtopQ.o \ - g__fmt.o strtoIg.o -Qtest: $(Qtest) - $(CC) -o Qtest $(Qtest) $(L1) - -xtest = xtest.o getround.o strtorx.o g_xfmt.o strtoIx.o \ - g__fmt.o strtoIg.o -xtest: $(xtest) - $(CC) -o xtest $(xtest) $(L1) - -xLtest = xLtest.o getround.o strtorxL.o strtopxL.o g_xLfmt.o strtoIxL.o \ - g__fmt.o strtoIg.o -xLtest: $(xLtest) - $(CC) -o xLtest $(xLtest) $(L1) - -ddtestsi = ddtest.o strtopddSI.o strtorddSI.o strtoIddSI.o getround.o \ - g_dfmt.o g_ddfmt.o g__fmt.o strtoIg.o -ddtestsi: $(ddtestsi) - $(CC) -o ddtestsi $(ddtestsi) $L - -dItestsi = dItest.o strtodISI.o strtoIdSI.o getround.o \ - g_dfmt.o g__fmt.o strtoIg.o -dItestsi: $(dItestsi) - $(CC) -o dItestsi $(dItestsi) $(L1) - -strtodt = strtodt.o $A -strtodt: $(strtodt) - $(CC) -o strtodt $(strtodt) $L - -pftest = pftest.o $A -pftest: $(pftest) - $(CC) -o pftest $(pftest) $L - -## On Intel (and Intel-like) systems using extended-precision registers -## for double-precision (C type double) computations that sometimes suffer -## double rounding errors, the test below involving strtodt generally shows -## five lines of unexpected results. Variant strtodtnrp uses ../strtodrnp.c -## (which does all computations in integer arithmetic) and should show no -## unexpected results. - -strtodtnrp = strtodt.o strtodnrp.o -strtodtnrp: $(strtodtnrp) - $(CC) -o strtodtnrp $(strtodtnrp) - -# xQtest generates cp commands that depend on sizeof(long double). -# See the source for details. If you know better, create Q.out, -# x.out and xL.out by copying the relevant *.ou0 or *.ou1 files -# to the corresponding .out files. In short, the *.ou0 files are -# for long double == double; x.ou1 and xL.ou1 are for -# long double == extended (a la 80x87 and MC680x0), and Q.ou1 is -# for long double == quad. - -Q.out x.out xL.out: - $(CC) -o xQtest xQtest.c - ./xQtest | sh - rm -f xQtest xQtest.o - -## The rmdir below will fail if any test results differ. - -tests: Q.out x.out xL.out dt dItest ddtest dtest ftest Qtest xLtest xtest ddtestsi dItestsi strtodt strtodtnrp - mkdir bad - cat testnos testnos1 | ./dt $(INFFIX) >zap 2>&1 - cmp dtst.out zap || mv zap bad/dtst.out - ./dItest zap 2>&1 - cmp dI.out zap || mv zap bad/dI.out - ./dItestsi zap 2>&1 - cmp dIsi.out zap || mv zap bad/dIsi.out - ./ddtestsi zap 2>&1 - cmp ddsi.out zap || mv zap bad/ddsi.out - for i in dd d f x xL Q; do cat testnos rtestnos | \ - ./"$$i"test $(INFFIX) >zap 2>&1;\ - cmp $$i.out zap || mv zap bad/$$i.out; done - ./strtodt testnos3 >bad/strtodt.out && rm bad/strtodt.out || \ - cat bad/strtodt.out - ./strtodtnrp testnos3 >bad/strtodtnrp.out && rm bad/strtodtnrp.out || \ - cat bad/strtodtnrp.out - rmdir bad 2>/dev/null || \ - (cd bad; for i in *; do cmp -s $$i ../obad/$$i && rm $$i;done; cd ..; rmdir bad) - touch tests - -# To test Printf in ../gdtoa.a, "make pf_test" and perhaps "make pf_testLq" -# (if both long double and quad are desired and available). - -pf_test: pftest - ./pftest zap - cmp pftest.out zap && rm zap - -pf_testLq: pftest - ./pftest zap - cmp pftestLq.out zap && rm zap - -xs0 = README Q.ou0 Q.ou1 Qtest.c d.out dI.out dIsi.out dItest.c dd.out\ - ddsi.out ddtest.c dt.c dtest.c dtst.out f.out ftest.c\ - getround.c makefile pfLqtestnos pftest.c pftestQ.out\ - pftestx.out pftestLq.out pftestnos rtestnos strtoIdSI.c\ - strtoIddSI.c strtodISI.c strtodt.c strtopddSI.c strtorddSI.c\ - testnos testnos1 testnos3 x.ou0 x.ou1 xL.ou0 xL.ou1 xLtest.c\ - xQtest.c xtest.c - -# invoke "make -r xsum.out" -xsum.out: xsum0.out $(xs0) - xsum $(xs0) >xsum1.out - cmp xsum0.out xsum1.out && mv xsum1.out xsum.out || diff xsum[01].out - -clean: - rm -f *.[ao] dt *test *testsi pftest.out strtodt strtodtnrp xsum.out\ - xsum1.out tests zap x.out xL.out Q.out - rm -rf bad diff --git a/lib/libc/gdtoa/test/obad/strtodt.out b/lib/libc/gdtoa/test/obad/strtodt.out deleted file mode 100644 index 79516bfaa..000000000 --- a/lib/libc/gdtoa/test/obad/strtodt.out +++ /dev/null @@ -1,6 +0,0 @@ -Line 31 of testnos3: got 4585747a b143e354; expected 4585747a b143e353 -Line 46 of testnos3: got 64fdcf7d f8f573b8; expected 64fdcf7d f8f573b7 -Line 47 of testnos3: got 650dcf7d f8f573b8; expected 650dcf7d f8f573b7 -Line 72 of testnos3: got 3cc70385 6844bdbe; expected 3cc70385 6844bdbf -Line 73 of testnos3: got 3cb70385 6844bdbe; expected 3cb70385 6844bdbf -5 bad conversions diff --git a/lib/libc/gdtoa/test/obad/xL.out b/lib/libc/gdtoa/test/obad/xL.out deleted file mode 100644 index 19a7fd1c1..000000000 --- a/lib/libc/gdtoa/test/obad/xL.out +++ /dev/null @@ -1,1460 +0,0 @@ - -Input: 1.23 - -strtoxL consumes 4 bytes and returns 33 -with bits = #3fff0000 9d70a3d7 a3d70a4 -printf("%.21Lg") gives 7.73283722915781506499e-4933 -g_xLfmt(0) gives 4 bytes: "1.23" - -strtoIxL returns 33, consuming 4 bytes. -fI[0] = #3fff0000 9d70a3d7 a3d70a3 -= 7.73283722915781506134e-4933 -fI[1] = #3fff0000 9d70a3d7 a3d70a4 -= 7.73283722915781506499e-4933 -fI[1] == strtoxL - - -Input: 1.23e+20 - -strtoxL consumes 8 bytes and returns 1 -with bits = #40410000 d55ef90a 2da18000 -printf("%.21Lg") gives 2.24239113715721119512e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e+20" - -strtoIxL returns 1, consuming 8 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.23e-20 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3fbc0000 e857267b b3a984f2 -printf("%.21Lg") gives 2.74065070995958800375e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e-20" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3fbc0000 e857267b b3a984f2 -= 2.74065070995958800375e-4932 -fI[1] = #3fbc0000 e857267b b3a984f3 -= 2.74065070995958800411e-4932 -fI[0] == strtoxL - - -Input: 1.23456789 - -strtoxL consumes 10 bytes and returns 33 -with bits = #3fff0000 9e065214 1ef0dbf6 -printf("%.21Lg") gives 7.88641440242171807354e-4933 -g_xLfmt(0) gives 10 bytes: "1.23456789" - -strtoIxL returns 33, consuming 10 bytes. -fI[0] = #3fff0000 9e065214 1ef0dbf5 -= 7.8864144024217180699e-4933 -fI[1] = #3fff0000 9e065214 1ef0dbf6 -= 7.88641440242171807354e-4933 -fI[1] == strtoxL - - -Input: 1.23456589e+20 - -strtoxL consumes 14 bytes and returns 1 -with bits = #40410000 d629bd33 5ccba00 -printf("%.21Lg") gives 2.26319561227049478508e-4932 -g_xLfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIxL returns 1, consuming 14 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.23e+30 - -strtoxL consumes 8 bytes and returns 17 -with bits = #40620000 f8658274 7dbc824a -printf("%.21Lg") gives 3.16238691003557160385e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e+30" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #40620000 f8658274 7dbc824a -= 3.16238691003557160385e-4932 -fI[1] = #40620000 f8658274 7dbc824b -= 3.16238691003557160421e-4932 -fI[0] == strtoxL - - -Input: 1.23e-30 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3f9b0000 c794337a 808554eb -printf("%.21Lg") gives 1.88012249978407873966e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e-30" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3f9b0000 c794337a 808554eb -= 1.88012249978407873966e-4932 -fI[1] = #3f9b0000 c794337a 808554ec -= 1.88012249978407874003e-4932 -fI[0] == strtoxL - - -Input: 1.23456789e-20 - -strtoxL consumes 14 bytes and returns 17 -with bits = #3fbc0000 e9340a38 f3d6d352 -printf("%.21Lg") gives 2.76331470044569174626e-4932 -g_xLfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #3fbc0000 e9340a38 f3d6d352 -= 2.76331470044569174626e-4932 -fI[1] = #3fbc0000 e9340a38 f3d6d353 -= 2.76331470044569174663e-4932 -fI[0] == strtoxL - - -Input: 1.23456789e-30 - -strtoxL consumes 14 bytes and returns 17 -with bits = #3f9b0000 c851f19d decca8fc -printf("%.21Lg") gives 1.89959071937101288293e-4932 -g_xLfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #3f9b0000 c851f19d decca8fc -= 1.89959071937101288293e-4932 -fI[1] = #3f9b0000 c851f19d decca8fd -= 1.89959071937101288329e-4932 -fI[0] == strtoxL - - -Input: 1.234567890123456789 - -strtoxL consumes 20 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -printf("%.21Lg") gives 7.88641440657246265535e-4933 -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 20 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -= 7.88641440657246265535e-4933 -fI[1] = #3fff0000 9e065214 62cfdb8e -= 7.886414406572462659e-4933 -fI[0] == strtoxL - - -Input: 1.23456789012345678901234567890123456789 - -strtoxL consumes 40 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -printf("%.21Lg") gives 7.88641440657246265535e-4933 -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 40 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -= 7.88641440657246265535e-4933 -fI[1] = #3fff0000 9e065214 62cfdb8e -= 7.886414406572462659e-4933 -fI[0] == strtoxL - - -Input: 1.23e306 - -strtoxL consumes 8 bytes and returns 17 -with bits = #43f70000 e033b668 e30fa6d5 -printf("%.21Lg") gives 2.52688323155200052759e-4932 -g_xLfmt(0) gives 9 bytes: "1.23e+306" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #43f70000 e033b668 e30fa6d5 -= 2.52688323155200052759e-4932 -fI[1] = #43f70000 e033b668 e30fa6d6 -= 2.52688323155200052796e-4932 -fI[0] == strtoxL - - -Input: 1.23e-306 - -strtoxL consumes 9 bytes and returns 33 -with bits = #3c060000 dd1dc2ed 1cb73f25 -printf("%.21Lg") gives 2.44583168427704605801e-4932 -g_xLfmt(0) gives 9 bytes: "1.23e-306" - -strtoIxL returns 33, consuming 9 bytes. -fI[0] = #3c060000 dd1dc2ed 1cb73f24 -= 2.44583168427704605765e-4932 -fI[1] = #3c060000 dd1dc2ed 1cb73f25 -= 2.44583168427704605801e-4932 -fI[1] == strtoxL - - -Input: 1.23e-320 - -strtoxL consumes 9 bytes and returns 33 -with bits = #3bd80000 9b98c371 844c3f1a -printf("%.21Lg") gives 7.24867657578821329238e-4933 -g_xLfmt(0) gives 9 bytes: "1.23e-320" - -strtoIxL returns 33, consuming 9 bytes. -fI[0] = #3bd80000 9b98c371 844c3f19 -= 7.24867657578821328874e-4933 -fI[1] = #3bd80000 9b98c371 844c3f1a -= 7.24867657578821329238e-4933 -fI[1] == strtoxL - - -Input: 1.23e-20 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3fbc0000 e857267b b3a984f2 -printf("%.21Lg") gives 2.74065070995958800375e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e-20" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3fbc0000 e857267b b3a984f2 -= 2.74065070995958800375e-4932 -fI[1] = #3fbc0000 e857267b b3a984f3 -= 2.74065070995958800411e-4932 -fI[0] == strtoxL - - -Input: 1.23456789e307 - -strtoxL consumes 14 bytes and returns 17 -with bits = #43fb0000 8ca58a5e d766de75 -printf("%.21Lg") gives 3.32182163192682931854e-4933 -g_xLfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #43fb0000 8ca58a5e d766de75 -= 3.32182163192682931854e-4933 -fI[1] = #43fb0000 8ca58a5e d766de76 -= 3.32182163192682932219e-4933 -fI[0] == strtoxL - - -Input: 1.23456589e-307 - -strtoxL consumes 15 bytes and returns 17 -with bits = #3c030000 b18cb5dc c22fd369 -printf("%.21Lg") gives 1.30149245314004923345e-4932 -g_xLfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIxL returns 17, consuming 15 bytes. -fI[0] = #3c030000 b18cb5dc c22fd369 -= 1.30149245314004923345e-4932 -fI[1] = #3c030000 b18cb5dc c22fd36a -= 1.30149245314004923382e-4932 -fI[0] == strtoxL - - -Input: 1.234567890123456789 - -strtoxL consumes 20 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -printf("%.21Lg") gives 7.88641440657246265535e-4933 -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 20 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -= 7.88641440657246265535e-4933 -fI[1] = #3fff0000 9e065214 62cfdb8e -= 7.886414406572462659e-4933 -fI[0] == strtoxL - - -Input: 1.234567890123456789e301 - -strtoxL consumes 24 bytes and returns 33 -with bits = #43e70000 937a8baf ab20980c -printf("%.21Lg") gives 5.11635766619117643114e-4933 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIxL returns 33, consuming 24 bytes. -fI[0] = #43e70000 937a8baf ab20980b -= 5.1163576661911764275e-4933 -fI[1] = #43e70000 937a8baf ab20980c -= 5.11635766619117643114e-4933 -fI[1] == strtoxL - - -Input: 1.234567890123456789e-301 - -strtoxL consumes 25 bytes and returns 33 -with bits = #3c170000 a953271a 5d069ad9 -printf("%.21Lg") gives 1.08545540462853463561e-4932 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIxL returns 33, consuming 25 bytes. -fI[0] = #3c170000 a953271a 5d069ad8 -= 1.08545540462853463524e-4932 -fI[1] = #3c170000 a953271a 5d069ad9 -= 1.08545540462853463561e-4932 -fI[1] == strtoxL - - -Input: 1.234567890123456789e-321 - -strtoxL consumes 25 bytes and returns 33 -with bits = #3bd40000 f9e11b4c ea6dcce9 -printf("%.21Lg") gives 3.20133479952876185942e-4932 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-321" - -strtoIxL returns 33, consuming 25 bytes. -fI[0] = #3bd40000 f9e11b4c ea6dcce8 -= 3.20133479952876185905e-4932 -fI[1] = #3bd40000 f9e11b4c ea6dcce9 -= 3.20133479952876185942e-4932 -fI[1] == strtoxL - - -Input: 1e23 - -strtoxL consumes 4 bytes and returns 1 -with bits = #404b0000 a968163f a57b400 -printf("%.21Lg") gives 1.08760331670538037378e-4932 -g_xLfmt(0) gives 5 bytes: "1e+23" - -strtoIxL returns 1, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1e310 - -strtoxL consumes 5 bytes and returns 33 -with bits = #44040000 de81e40a 34bcf50 -printf("%.21Lg") gives 2.48237171106260601618e-4932 -g_xLfmt(0) gives 6 bytes: "1e+310" - -strtoIxL returns 33, consuming 5 bytes. -fI[0] = #44040000 de81e40a 34bcf4f -= 2.48237171106260601582e-4932 -fI[1] = #44040000 de81e40a 34bcf50 -= 2.48237171106260601618e-4932 -fI[1] == strtoxL - - -Input: 9.0259718793241475e-277 - -strtoxL consumes 23 bytes and returns 33 -with bits = #3c690000 ffffffff fffffcf7 -printf("%.21Lg") gives 3.36210314311209322303e-4932 -g_xLfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIxL returns 33, consuming 23 bytes. -fI[0] = #3c690000 ffffffff fffffcf6 -= 3.36210314311209322267e-4932 -fI[1] = #3c690000 ffffffff fffffcf7 -= 3.36210314311209322303e-4932 -fI[1] == strtoxL - - -Input: 9.025971879324147880346310405869e-277 - -strtoxL consumes 37 bytes and returns 17 -with bits = #3c6a0000 80000000 0 -printf("%.21Lg") gives 3.36210314311209350626e-4932 -g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIxL returns 17, consuming 37 bytes. -fI[0] = #3c6a0000 80000000 0 -= 3.36210314311209350626e-4932 -fI[1] = #3c6a0000 80000000 1 -= 3.64519953188247460253e-4951 -fI[0] == strtoxL - - -Input: 9.025971879324147880346310405868e-277 - -strtoxL consumes 37 bytes and returns 33 -with bits = #3c6a0000 80000000 0 -printf("%.21Lg") gives 3.36210314311209350626e-4932 -g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIxL returns 33, consuming 37 bytes. -fI[0] = #3c690000 ffffffff ffffffff -= 3.3621031431120935059e-4932 -fI[1] = #3c6a0000 80000000 0 -= 3.36210314311209350626e-4932 -fI[1] == strtoxL - - -Input: 2.2250738585072014e-308 - -strtoxL consumes 23 bytes and returns 17 -with bits = #3c010000 80000000 46 -printf("%.21Lg") gives 2.55163967231773222177e-4949 -g_xLfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIxL returns 17, consuming 23 bytes. -fI[0] = #3c010000 80000000 46 -= 2.55163967231773222177e-4949 -fI[1] = #3c010000 80000000 47 -= 2.5880916676365569678e-4949 -fI[0] == strtoxL - - -Input: 2.2250738585072013e-308 - -strtoxL consumes 23 bytes and returns 17 -with bits = #3c000000 ffffffff fffffd4f -printf("%.21Lg") gives 3.36210314311209325511e-4932 -g_xLfmt(0) gives 23 bytes: "2.2250738585072013e-308" - -strtoIxL returns 17, consuming 23 bytes. -fI[0] = #3c000000 ffffffff fffffd4f -= 3.36210314311209325511e-4932 -fI[1] = #3c000000 ffffffff fffffd50 -= 3.36210314311209325547e-4932 -fI[0] == strtoxL - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[0] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[0] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[0] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[0] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 3 bytes: "1.1" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 4 bytes: "-1.1" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[0] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 3 bytes: "1.2" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 4 bytes: "-1.2" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[0] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 3 bytes: "1.6" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 4 bytes: "-1.6" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[0] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 3 bytes: "1.7" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 4 bytes: "-1.7" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[0] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 3 bytes: "1.1" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 3 bytes: "1.2" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 a6666666 66666667 -printf("%.21Lg") gives 1.0086309429336280521e-4932 -g_xLfmt(0) gives 21 bytes: "1.3000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 b3333333 33333334 -printf("%.21Lg") gives 1.3448412572448374028e-4932 -g_xLfmt(0) gives 21 bytes: "1.4000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 3 bytes: "1.6" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 3 bytes: "1.7" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 e6666666 66666667 -printf("%.21Lg") gives 2.68968251448967480523e-4932 -g_xLfmt(0) gives 21 bytes: "1.8000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 f3333333 33333334 -printf("%.21Lg") gives 3.02589282880088415593e-4932 -g_xLfmt(0) gives 21 bytes: "1.9000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[0] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 4 bytes: "-1.1" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[0] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[0] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 4 bytes: "-1.2" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[0] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 a6666666 66666667 -printf("%.21Lg") gives 1.0086309429336280521e-4932 -g_xLfmt(0) gives 22 bytes: "-1.3000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[0] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 b3333333 33333334 -printf("%.21Lg") gives 1.3448412572448374028e-4932 -g_xLfmt(0) gives 22 bytes: "-1.4000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[0] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[0] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 4 bytes: "-1.6" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[0] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[0] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 4 bytes: "-1.7" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[0] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 e6666666 66666667 -printf("%.21Lg") gives 2.68968251448967480523e-4932 -g_xLfmt(0) gives 22 bytes: "-1.8000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[0] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 f3333333 33333334 -printf("%.21Lg") gives 3.02589282880088415593e-4932 -g_xLfmt(0) gives 22 bytes: "-1.9000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[0] == strtoxL - diff --git a/lib/libc/gdtoa/test/pfLqtestnos b/lib/libc/gdtoa/test/pfLqtestnos deleted file mode 100644 index 068092337..000000000 --- a/lib/libc/gdtoa/test/pfLqtestnos +++ /dev/null @@ -1,13 +0,0 @@ -%.8a 1.23 -%.7a -%.2a -%.La 1.23 -%.20Lqa 1.23 -%La 3e27 -%La 1.7e27 -%Lqa 3e48 -%Lqa 1e49 -1.5 -2.5 -4.5 -8.5 diff --git a/lib/libc/gdtoa/test/pftest.c b/lib/libc/gdtoa/test/pftest.c deleted file mode 100644 index 99d78ee45..000000000 --- a/lib/libc/gdtoa/test/pftest.c +++ /dev/null @@ -1,158 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 2009 by David M. Gay -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -source-code copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation. - -THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, INDIRECT OR -CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF -USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR -OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -PERFORMANCE OF THIS SOFTWARE. - -****************************************************************/ -#include "stdio1.h" -#include "gdtoa.h" -#include - -#undef allow_Quad -#undef want_Quad -#undef want_Ux -#define want_LD -typedef union Ud {double x; unsigned int u[2]; } Ud; -#ifdef __x86_64 /*{{*/ -#define want_Ux -#ifndef NO_GDTOA_i386_Quad /*{*/ -typedef union UQ {__float128 x; unsigned int u[4]; } UQ; -#define allow_Quad(x) x -#define want_Quad -#endif /*}*/ -#else /*}{*/ -#ifdef __i386 /*{{*/ -#define want_Ux -#else /*}{*/ -#ifdef __sparc /*{{*/ -typedef union UQ {long double x; unsigned int u[4]; } Ux; -#else /*}{*/ -#ifdef __INTEL_COMPILER /*{*/ -#undef want_Quad -#undef want_Ux -#undef want_LD -#endif /*}*/ -#endif /*}}*/ -#endif /*}}*/ -#endif /*}}*/ - -#ifndef allow_Quad -#define allow_Quad(x) /*nothing*/ -#endif - -#ifdef want_Ux /*{{*/ -typedef union Ux {long double x; unsigned short u[5]; } Ux; -#else /*}{*/ -#ifdef __sparc -#define want_Ux -#endif -#endif /*}}*/ - - int -main(void) -{ - Ud d; - allow_Quad(UQ q;) - char *b, buf[256], fmt[32], *s; -#ifdef want_Ux - Ux x; - x.x = 0.; -#endif - int k; - - k = 0; - strcpy(fmt, "%.g"); - d.x = 0.; - allow_Quad(q.x = 0.;) - while(fgets(buf, sizeof(buf), stdin)) { - for(b = buf; *b && *b != '\n'; ++b); - *b = 0; - if (b == buf) - continue; - b = buf; - if (*b == '%') { - for(k = 0; *b > ' '; ++b) -#ifdef want_LD /*{{*/ - switch(*b) { - case 'L': - k = 1; -#ifdef want_Quad - break; - case 'q': - if (k >= 1) - k = 2; -#endif - } -#else /*}{*/ - ; -#endif /*}}*/ - if (*b) - *b++ = 0; - if (b - buf < sizeof(fmt)) { - strcpy(fmt, buf); - } - } - if (*b) { - switch(k) { - case 0: - d.x = strtod(b,&s); - break; - case 1: -#ifdef want_Ux -#ifdef __sparc - strtopQ(b,&s,&x.x); -#else - strtopx(b,&s,&x.x); -#endif -#else - strtopQ(b,&s,&q.x); -#endif - break; - allow_Quad(case 2: strtopQ(b,&s,&q.x);) - } - if (*s) - printf("Ignoring \"%s\"\n", s); - } - switch(k) { - case 0: - printf("d.x = %.g = #%x %x; %s ==> ", d.x, d.u[1], d.u[0], fmt); - printf(fmt, d.x); - break; - case 1: -#ifdef __sparc - printf("x.x = %.Lg = #%x %x %x %x; %s ==> ", x.x, - x.u[0], x.u[1], x.u[2], x.u[3], fmt); -#else - printf("x.x = %.Lg = #%x %x %x %x %x; %s ==> ", x.x, - x.u[4], x.u[3], x.u[2], x.u[1], x.u[0], fmt); -#endif - printf(fmt, x.x); -#ifdef want_Quad - break; - case 2: - printf("q.x = %.Lqg = #%x %x %x %x; %s ==> ", q.x, - q.u[3], q.u[2], q.u[1], q.u[0], fmt); - printf(fmt, q.x); -#endif - } - putchar('\n'); - } - return 0; - } diff --git a/lib/libc/gdtoa/test/pftestLq.out b/lib/libc/gdtoa/test/pftestLq.out deleted file mode 100644 index 0bcec7461..000000000 --- a/lib/libc/gdtoa/test/pftestLq.out +++ /dev/null @@ -1,13 +0,0 @@ -d.x = 1.23 = #3ff3ae14 7ae147ae; %.8a ==> 0x1.3ae147aep+0 -d.x = 1.23 = #3ff3ae14 7ae147ae; %.7a ==> 0x1.3ae147bp+0 -d.x = 1.23 = #3ff3ae14 7ae147ae; %.2a ==> 0x1.3bp+0 -x.x = 1.23 = #3fff 9d70 a3d7 a3d 70a4; %.La ==> 0xap-3 -q.x = 1.23 = #3fff3ae1 47ae147a e147ae14 7ae147ae; %.20Lqa ==> 0x1.3ae147ae147ae147ae14p+0 -x.x = 3e+27 = #405a 9b18 ab5d f718 b6c; %La ==> 0x9.b18ab5df7180b6cp+88 -x.x = 1.7e+27 = #4059 afc6 a015 291b 4024; %La ==> 0xa.fc6a015291b4024p+87 -q.x = 3e+48 = #40a006be 53879565 60c1e1a9 9c13ee2; %Lqa ==> 0x1.06be5387956560c1e1a909c13ee2p+161 -q.x = 1e+49 = #40a1b5e7 e08ca3a8 f6987819 baecbe22; %Lqa ==> 0x1.b5e7e08ca3a8f6987819baecbe22p+162 -q.x = 1.5 = #3fff8000 0 0 0; %Lqa ==> 0x1.8p+0 -q.x = 2.5 = #40004000 0 0 0; %Lqa ==> 0x1.4p+1 -q.x = 4.5 = #40012000 0 0 0; %Lqa ==> 0x1.2p+2 -q.x = 8.5 = #40021000 0 0 0; %Lqa ==> 0x1.1p+3 diff --git a/lib/libc/gdtoa/test/pftestQ.out b/lib/libc/gdtoa/test/pftestQ.out deleted file mode 100644 index 8c42afe69..000000000 --- a/lib/libc/gdtoa/test/pftestQ.out +++ /dev/null @@ -1,15 +0,0 @@ -d.x = 1.23 = #7ae147ae 3ff3ae14; %.8a ==> 0x1.3ae147aep+0 -d.x = 1.23 = #7ae147ae 3ff3ae14; %.7a ==> 0x1.3ae147bp+0 -d.x = 1.23 = #7ae147ae 3ff3ae14; %.2a ==> 0x1.3bp+0 -x.x = 1.23 = #3fff3ae1 47ae147a e147ae14 7ae147ae; %.La ==> 0x1p+0 -x.x = 1.23 = #3fff3ae1 47ae147a e147ae14 7ae147ae; %.20La ==> 0x1.3ae147ae147ae147ae14p+0 -x.x = 3e+27 = #405a3631 56bbee30 16d70000 0; %La ==> 0x1.363156bbee3016d7p+91 -x.x = 1.7e+27 = #40595f8d 402a5236 80490000 0; %La ==> 0x1.5f8d402a52368049p+90 -d.x = 1.5 = #0 3ff80000; %a ==> 0x1.8p+0 -d.x = 2.5 = #0 40040000; %a ==> 0x1.4p+1 -d.x = 4.5 = #0 40120000; %a ==> 0x1.2p+2 -d.x = 8.5 = #0 40210000; %a ==> 0x1.1p+3 -x.x = 1.5 = #3fff8000 0 0 0; %La ==> 0x1.8p+0 -x.x = 2.5 = #40004000 0 0 0; %La ==> 0x1.4p+1 -x.x = 4.5 = #40012000 0 0 0; %La ==> 0x1.2p+2 -x.x = 8.5 = #40021000 0 0 0; %La ==> 0x1.1p+3 diff --git a/lib/libc/gdtoa/test/pftestnos b/lib/libc/gdtoa/test/pftestnos deleted file mode 100644 index 7b3010a8b..000000000 --- a/lib/libc/gdtoa/test/pftestnos +++ /dev/null @@ -1,15 +0,0 @@ -%.8a 1.23 -%.7a -%.2a -%.La 1.23 -%.20La 1.23 -%La 3e27 -%La 1.7e27 -%a 1.5 -2.5 -4.5 -8.5 -%La 1.5 -2.5 -4.5 -8.5 diff --git a/lib/libc/gdtoa/test/pftestx.out b/lib/libc/gdtoa/test/pftestx.out deleted file mode 100644 index 15a08d362..000000000 --- a/lib/libc/gdtoa/test/pftestx.out +++ /dev/null @@ -1,15 +0,0 @@ -d.x = 1.23 = #3ff3ae14 7ae147ae; %.8a ==> 0x1.3ae147aep+0 -d.x = 1.23 = #3ff3ae14 7ae147ae; %.7a ==> 0x1.3ae147bp+0 -d.x = 1.23 = #3ff3ae14 7ae147ae; %.2a ==> 0x1.3bp+0 -x.x = 1.23 = #3fff 9d70 a3d7 a3d 70a4; %.La ==> 0xap-3 -x.x = 1.23 = #3fff 9d70 a3d7 a3d 70a4; %.20La ==> 0x9.d70a3d70a3d70a4p-3 -x.x = 3e+27 = #405a 9b18 ab5d f718 b6c; %La ==> 0x9.b18ab5df7180b6cp+88 -x.x = 1.7e+27 = #4059 afc6 a015 291b 4024; %La ==> 0xa.fc6a015291b4024p+87 -d.x = 1.5 = #3ff80000 0; %a ==> 0x1.8p+0 -d.x = 2.5 = #40040000 0; %a ==> 0x1.4p+1 -d.x = 4.5 = #40120000 0; %a ==> 0x1.2p+2 -d.x = 8.5 = #40210000 0; %a ==> 0x1.1p+3 -x.x = 1.5 = #3fff c000 0 0 0; %La ==> 0xcp-3 -x.x = 2.5 = #4000 a000 0 0 0; %La ==> 0xap-2 -x.x = 4.5 = #4001 9000 0 0 0; %La ==> 0x9p-1 -x.x = 8.5 = #4002 8800 0 0 0; %La ==> 0x8.8p+0 diff --git a/lib/libc/gdtoa/test/rtestnos b/lib/libc/gdtoa/test/rtestnos deleted file mode 100644 index cde95b78a..000000000 --- a/lib/libc/gdtoa/test/rtestnos +++ /dev/null @@ -1,76 +0,0 @@ -r0 -1.1 --1.1 -1.2 --1.2 -1.3 --1.3 -1.4 --1.4 -1.5 --1.5 -1.6 --1.6 -1.7 --1.7 -1.8 --1.8 -1.9 --1.9 -r1 -1.1 --1.1 -1.2 --1.2 -1.3 --1.3 -1.4 --1.4 -1.5 --1.5 -1.6 --1.6 -1.7 --1.7 -1.8 --1.8 -1.9 --1.9 -r2 -1.1 --1.1 -1.2 --1.2 -1.3 --1.3 -1.4 --1.4 -1.5 --1.5 -1.6 --1.6 -1.7 --1.7 -1.8 --1.8 -1.9 --1.9 -r3 -1.1 --1.1 -1.2 --1.2 -1.3 --1.3 -1.4 --1.4 -1.5 --1.5 -1.6 --1.6 -1.7 --1.7 -1.8 --1.8 -1.9 --1.9 diff --git a/lib/libc/gdtoa/test/strtoIdSI.c b/lib/libc/gdtoa/test/strtoIdSI.c deleted file mode 100644 index c5342edfa..000000000 --- a/lib/libc/gdtoa/test/strtoIdSI.c +++ /dev/null @@ -1,2 +0,0 @@ -#define Sudden_Underflow -#include "../strtoId.c" diff --git a/lib/libc/gdtoa/test/strtoIddSI.c b/lib/libc/gdtoa/test/strtoIddSI.c deleted file mode 100644 index 2966259a8..000000000 --- a/lib/libc/gdtoa/test/strtoIddSI.c +++ /dev/null @@ -1,2 +0,0 @@ -#define Sudden_Underflow -#include "../strtoIdd.c" diff --git a/lib/libc/gdtoa/test/strtodISI.c b/lib/libc/gdtoa/test/strtodISI.c deleted file mode 100644 index 66d2addfe..000000000 --- a/lib/libc/gdtoa/test/strtodISI.c +++ /dev/null @@ -1,2 +0,0 @@ -#define Sudden_Underflow -#include "../strtodI.c" diff --git a/lib/libc/gdtoa/test/strtodt.c b/lib/libc/gdtoa/test/strtodt.c deleted file mode 100644 index 2983615c0..000000000 --- a/lib/libc/gdtoa/test/strtodt.c +++ /dev/null @@ -1,138 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test strtod. */ - -/* On stdin, read triples: d x y: - * d = decimal string - * x = high-order Hex value expected from strtod - * y = low-order Hex value - * Complain about errors. - */ - -#include "gdtoa.h" /* for ULong */ -#include -#include -#include - - static int W0, W1; - typedef union { - double d; - ULong L[2]; - } U; - -#define UL (unsigned long) - - static int -process(char *fname, FILE *f) -{ - U a, b; - char buf[2048]; - char *s, *s1, *se; - int line, n; - - line = n = 0; - - top: - while(fgets(s = buf, sizeof(buf), f)) { - line++; - while(*s <= ' ') - if (!*s++) - goto top; /* break 2 */ - if (*s == '#') - continue; - while(*s > ' ') - s++; - /* if (sscanf(s,"\t%lx\t%lx", &a.L[0], &a.L[1]) != 2) */ - if ((a.L[0] = (ULong)strtoul(s, &s1,16), s1 <= s) - || (a.L[1] = (ULong)strtoul(s1,&se,16), se <= s1)) { - printf("Badly formatted line %d of %s\n", - line, fname); - n++; - continue; - } - b.d = strtod(buf,0); - if (b.L[W0] != a.L[0] || b.L[W1] != a.L[1]) { - n++; - printf("Line %d of %s: got %lx %lx; expected %lx %lx\n", - line, fname, UL b.L[W0], UL b.L[W1], UL a.L[0], UL a.L[1]); - } - } - return n; - } - - int -main(int argc, char **argv) -{ - FILE *f; - char *prog, *s; - int n, rc; - U u; - - prog = argv[0]; - if (argc == 2 && !strcmp(argv[1],"-?")) { - fprintf(stderr, "Usage: %s [file [file...]]\n" - "\tto read data file(s) of tab-separated triples d x y with\n" - "\t\td decimal string\n" - "\t\tx = high-order Hex value expected from strtod\n" - "\t\ty = low-order Hex value\n" - "\tComplain about errors by strtod.\n" - "\tIf no files, read triples from stdin.\n", - prog); - return 0; - } - - /* determine endian-ness */ - - u.d = 1.; - W0 = u.L[0] == 0; - W1 = 1 - W0; - - /* test */ - - n = rc = 0; - if (argc <= 1) - n = process("", stdin); - else - while((s = *++argv)) - if ((f = fopen(s,"r"))) { - n += process(s, f); - fclose(f); - } - else { - rc = 2; - fprintf(stderr, "Cannot open %s\n", s); - } - printf("%d bad conversions\n", n); - if (n) - rc |= 1; - return rc; - } diff --git a/lib/libc/gdtoa/test/strtopddSI.c b/lib/libc/gdtoa/test/strtopddSI.c deleted file mode 100644 index d2004e5b7..000000000 --- a/lib/libc/gdtoa/test/strtopddSI.c +++ /dev/null @@ -1,2 +0,0 @@ -#define Sudden_Underflow -#include "../strtopdd.c" diff --git a/lib/libc/gdtoa/test/strtorddSI.c b/lib/libc/gdtoa/test/strtorddSI.c deleted file mode 100644 index dd6a3812e..000000000 --- a/lib/libc/gdtoa/test/strtorddSI.c +++ /dev/null @@ -1,2 +0,0 @@ -#define Sudden_Underflow -#include "../strtordd.c" diff --git a/lib/libc/gdtoa/test/testnos b/lib/libc/gdtoa/test/testnos deleted file mode 100644 index a36a98676..000000000 --- a/lib/libc/gdtoa/test/testnos +++ /dev/null @@ -1,28 +0,0 @@ -1.23 -1.23e+20 -1.23e-20 -1.23456789 -1.23456589e+20 -1.23e+30 -1.23e-30 -1.23456789e-20 -1.23456789e-30 -1.234567890123456789 -1.23456789012345678901234567890123456789 -1.23e306 -1.23e-306 -1.23e-320 -1.23e-20 -1.23456789e307 -1.23456589e-307 -1.234567890123456789 -1.234567890123456789e301 -1.234567890123456789e-301 -1.234567890123456789e-321 -1e23 -1e310 -9.0259718793241475e-277 -9.025971879324147880346310405869e-277 -9.025971879324147880346310405868e-277 -2.2250738585072014e-308 -2.2250738585072013e-308 diff --git a/lib/libc/gdtoa/test/testnos1 b/lib/libc/gdtoa/test/testnos1 deleted file mode 100644 index d734b35db..000000000 --- a/lib/libc/gdtoa/test/testnos1 +++ /dev/null @@ -1,20 +0,0 @@ -1.23:2 6 -1.23:4 6 -1.23e+20:2 6 -1.23e+20:4 6 -1.23e-20:2 6 -1.23e-20:4 6 -1.23456789:2 6 -1.23456789:4 6 -1.23456589e+20:2 6 -1.23456589e+20:4 6 -1.23456789e-20:2 6 -1.23456789e-20:4 6 -1234565:2 6 -1234565:4 6 -1.234565:2 6 -1.234565:4 6 -1.234565e+20:2 6 -1.234565e+20:4 6 -1.234565e-20:2 6 -1.234565e-20:4 6 diff --git a/lib/libc/gdtoa/test/testnos3 b/lib/libc/gdtoa/test/testnos3 deleted file mode 100644 index 2a7cf7944..000000000 --- a/lib/libc/gdtoa/test/testnos3 +++ /dev/null @@ -1,352 +0,0 @@ -# Test triples for strtodt, derived from Fred Tydeman's posting -# of 26 February 1996 to comp.arch.arithmetic. - -9e0306 7fa9a202 8368022e -4e-079 2fa7b6d7 1d20b96c -7e-261 9eb8d7e 32be6396 -6e-025 3ae7361c b863de62 -7e-161 1eaf7e0d b3799aa3 -7e0289 7c1cbb54 7777a285 -5e0079 507afcef 51f0fb5f -1e0080 508afcef 51f0fb5f -7e-303 1333391 31c46f8b -5e0152 5fa317e5 ef3ab327 -5e0125 5a07a2ec c414a03f -2e0126 5a27a2ec c414a03f -7e-141 22d5570f 59bd178c -4e-192 18323ff0 6eea847a -9e0043 49102498 ea6df0c4 -1e0303 7ed754e3 1cd072da -95e-089 2dde3cbc 9907fdc8 -85e0194 689d1c26 db7d0dae -69e0267 77c0b7cb 60c994da -97e-019 3c665dde 8e688ba6 -37e0046 49d033d7 eca0adef -74e0046 49e033d7 eca0adef -61e-099 2bc0ad83 6f269a17 -53e-208 151b39ae 1909c31b -93e-234 fc27b2e 4f210075 -79e-095 2c9a5db8 12948281 -87e-274 772d36c f48e7abd -83e0025 4585747a b143e353 -17e-036 38b698cc dc60015a -53e0033 47246a34 18629ef6 -51e-074 30ecd5be e57763e6 -63e-022 3bbdc03b 8fd7016a -839e0143 5e3ae03f 245703e2 -749e-182 1abf1472 7744c63e -999e-026 3b282782 afe1869e -345e0266 77b0b7cb 60c994da -914e-102 2b5ffc81 bc29f02b -829e0102 55b7221a 79cdd1d9 -307e0090 5322d6b1 83fe4b55 -859e0182 6654374d 8b87ac63 -283e0085 5216c309 24bab4b -589e0187 675526be 9c22eb17 -302e0176 64fdcf7d f8f573b7 -604e0176 650dcf7d f8f573b7 -761e-244 de03cea 3586452e -647e0230 7044d64d 4079150c -755e0174 64a7d931 93f78fc6 -255e-075 30dcd5be e57763e6 -3391e0055 4c159bd3 ad46e346 -4147e-015 3d923d1b 5eb1d778 -3996e-026 3b482782 afe1869e -1998e-026 3b382782 afe1869e -3338e-296 335519a c5142aab -1669e-296 325519a c5142aab -8699e-276 772d2df 246ecd2d -5311e0243 73284e91 f4aa0fdb -7903e-096 2cd07c2d 27a5b989 -7611e-226 11d19b87 44033457 -3257e0058 4cb444b3 4a6fb3eb -6514e0058 4cc444b3 4a6fb3eb -3571e0263 77462644 c61d41aa -7142e0263 77562644 c61d41aa -5311e0242 72f3720e 5d54d97c -1617e-063 3384c98f ce16152e -51881e0037 4897d295 dc76da4 -31441e-118 285ef890 f5de4c86 -30179e0079 5143e272 a77478e8 -60358e0079 5153e272 a77478e8 -63876e-020 3cc70385 6844bdbf -31938e-020 3cb70385 6844bdbf -46073e-032 3a42405b 773fbdf3 -32941e0051 4b757eb8 ad52a5c9 -82081e0041 49770105 df3d47cb -38701e-215 1440492a 4a8a37fd -62745e0047 4ab0c52f e6dc6a1b -12549e0048 4ac0c52f e6dc6a1b -64009e-183 1af099b3 93b84832 -89275e0261 77262644 c61d41aa -75859e0025 46232645 e1ba93f0 -57533e0287 7c8272ed 2307f56a -584169e0229 70ad6570 59dc79aa -940189e-112 29eb99d6 240c1a28 -416121e0197 6a00fd07 ed297f80 -832242e0197 6a10fd07 ed297f80 -584738e0076 50e8a85e b277e645 -933587e-140 241b2487 28b9c117 -252601e0121 5a2dda59 2e398dd7 -358423e0274 79f9463b 59b8f2bd -892771e-213 14f25818 c7294f27 -410405e0040 49670105 df3d47cb -928609e-261 afbe2dd 66200bef -302276e-254 c55a462 d91c6ab3 -920657e-023 3c653a99 85dbde6c -609019e-025 3bf1f99e 11ea0a24 -252601e0120 59f7e1e0 f1c7a4ac -654839e-060 34b00e7d b3b3f242 -8823691e0130 5c5e597c b94b7ae -2920845e0228 709d6570 59dc79aa -9210917e0080 51fda232 347e6032 -5800419e-303 26e58ff a48f4fce -6119898e-243 ee3ecf2 2ea07863 -3059949e-243 ed3ecf2 2ea07863 -2572231e0223 6f90f73b e1dff9ad -5444097e-021 3cf8849d d33c95af -5783893e-127 26f7e590 2ce0e151 -3865421e-225 1295d4fe 53afec65 -4590831e0156 61b4689b 4a5fa201 -9181662e0156 61c4689b 4a5fa201 -5906361e-027 3bbbe45a 312d08a0 -7315057e0235 7225f0d4 8362a72 -9088115e0106 5762e51a 84a3c6a0 -1817623e0107 5772e51a 84a3c6a0 -44118455e0129 5c4e597c b94b7ae -35282041e0293 7e5512d5 273e62e8 -31279898e-291 5129b01 b6885d36 -15639949e-291 5029b01 b6885d36 -27966061e0145 5f955bcf 72fd10f9 -55932122e0145 5fa55bcf 72fd10f9 -70176353e-053 36900683 a21de855 -40277543e-032 3adf29ca ff893b1 -50609263e0157 622193af f1f1c8e3 -66094077e0077 518b37c4 b7928317 -84863171e0114 59406e98 f5ec8f37 -89396333e0264 786526f0 61ca9053 -87575437e-309 16e0732 602056c -78693511e-044 3870bc7b 7603a2ca -90285923e-206 16d14700 83f89d48 -30155207e-030 3b423a4a d20748a2 -245540327e0121 5acc569e 968e0944 -263125459e0287 7d44997a 298b2f2e -566446538e-257 c64472b a9550e86 -283223269e-257 c54472b a9550e86 -245540327e0122 5b01b623 1e18c5cb -491080654e0122 5b11b623 1e18c5cb -971212611e-126 27a397d3 c9745d2f -229058583e0052 4c76ce94 febdc7a5 -325270231e0039 49cc7ccf 90c9f8ab -989648089e-035 3a8880a3 d515e849 -653777767e0273 7a720223 f2b3a881 -923091487e0209 6d30bc60 e6896717 -526250918e0288 7d89bfd8 b3edfafa -350301748e-309 18e0732 602056c -741111169e-203 17a14fe7 daf8f3ae -667284113e-240 ff09355 f8050c02 -1227701635e0120 5abc569e 968e0944 -9981396317e-182 1c38afe1 a2a66aa -5232604057e-298 41465b8 96c24520 -5572170023e-088 2fb08478 22f765b2 -1964322616e0122 5b31b623 1e18c5cb -3928645232e0122 5b41b623 1e18c5cb -8715380633e-058 35f4614c 3219891f -4856063055e-127 279397d3 c9745d2f -8336960483e-153 223a06a1 24b95e1 -1007046393e-155 21a01891 fc4717fd -5378822089e-176 1d695fd4 c88d4b1b -5981342308e-190 1a83db11 ac608107 -7214782613e-086 3020b552 d2edcdea -5458466829e0142 5f70acde 6a98eb4c -9078555839e-109 2b5fc575 867314ee -6418488827e0079 526021f1 4ed7b3fa -65325840981e0069 5081a151 ddbd3c4a -49573485983e0089 54a221bd 871d2cf4 -46275205733e0074 51830e6c 7d4e3480 -92550411466e0074 51930e6c 7d4e3480 -41129842097e-202 1832c3e7 2d179607 -93227267727e-049 380960fe 8d5847f -41297294357e0185 688c4943 7fccfadb -41534892987e-067 343a1266 6477886d -42333842451e0201 6be0189a 26df575f -78564021519e-227 13115551 5fd37265 -53587107423e-061 35800a19 a3ffd981 -53827010643e-200 18a32fa6 9a69bd6d -83356057653e0193 6a4544e6 daee2a18 -45256834646e-118 29a541ec dfd48694 -45392779195e-110 2b4fc575 867314ee -23934638219e0291 7e81deaf 40ead9a0 -995779191233e0113 59e2d44e dcc51304 -997422852243e-265 b676688 faee99bc -653532977297e-123 28d925a0 aabcdc68 -938885684947e0147 60f11894 b202e9f4 -619534293513e0124 5c210c20 303fe0f1 -539879452414e-042 39a5e66d c3d6bdb5 -742522891517e0259 782c1c35 2fc3c309 -254901016865e-022 3dbc06d3 66394441 -685763015669e0280 7c85fd7a a44d9477 -384865004907e-285 72aa65b 58639e69 -286556458711e0081 5321958b 36c5102b -573112917422e0081 5331958b 36c5102b -769525178383e-150 234253ec e161420 -416780288265e0192 6a3544e6 daee2a18 -226963895975e-111 2b3fc575 867314ee -665592809339e0063 4f778b65 16c2b478 -3891901811465e0217 6f99ab82 61990292 -4764593340755e0069 50e4177a 9915fbf8 -6336156586177e0269 7a7173f7 6c63b792 -8233559360849e0095 56566fee 5649a7a -3662265515198e-107 2c538e6e dd48f2a3 -1831132757599e-107 2c438e6e dd48f2a3 -7812878489261e-179 1d726dae 7bbeda75 -6363857920591e0145 60b28a61 cf9483b7 -8811915538555e0082 53a51f50 8b287ae7 -9997878507563e-195 1a253db2 fea1ea31 -9224786422069e-291 634ee5d 56b32957 -6284426329974e-294 58d3409 dfbca26f -9199302046091e-062 35c13597 2630774c -6070482281213e-122 29423fa9 e6fcf47e -2780161250963e-301 405acc2 53064c2 -8233559360849e0094 5621f324 d11d4862 -72027097041701e0206 6d946778 12d3a606 -97297545286625e0215 6f79ab82 61990292 -99021992302453e-025 3da5c671 4def374c -54104687080198e-022 3e373cdf 8db7a7bc -33519685743233e0089 5537f203 339c9629 -67039371486466e0089 5547f203 339c9629 -39064392446305e-180 1d626dae 7bbeda75 -17796979903653e0261 78e072f3 819c1321 -28921916763211e0038 4a9eebab e0957af3 -87605699161665e0155 6302920f 96e7f9ef -41921560615349e-067 34d9b2a5 c4041e4b -80527976643809e0061 4f7c7c5a ea080a49 -72335858886654e-159 21cce77c 2b3328fc -52656615219377e0102 57f561de f4a9ee32 -15400733123779e-072 33b8bf7e 7fa6f02a -77003665618895e-073 33a8bf7e 7fa6f02a -475603213226859e-042 3a42d730 88f4050a -972708181182949e0116 5b218a7f 36172332 -246411729980464e-071 342eef5e 1f90ac34 -123205864990232e-071 341eef5e 1f90ac34 -609610927149051e-255 e104273 b18918b1 -475603213226859e-041 3a778cfc ab31064d -672574798934795e0065 508226c6 84c87261 -134514959786959e0066 509226c6 84c87261 -294897574603217e-151 2395f2df 5e675a0f -723047919080275e0036 4a7eebab e0957af3 -660191429952702e-088 30bddc7e 975c5045 -330095714976351e-088 30addc7e 975c5045 -578686871093232e-159 21fce77c 2b3328fc -144671717773308e-159 21dce77c 2b3328fc -385018328094475e-074 3398bf7e 7fa6f02a -330095714976351e-089 3077e398 7916a69e -2215901545757777e-212 171a80a6 e566428c -1702061899637397e-276 9cacc46 749dccfe -1864950924021923e0213 6f53ae60 753af6ca -3729901848043846e0213 6f63ae60 753af6ca -7487252720986826e-165 20f8823a 57adbef9 -3743626360493413e-165 20e8823a 57adbef9 -4988915232824583e0119 5be5f6de 9d5d6b5b -3771476185376383e0277 7cae3c14 d6916ce9 -6182410494241627e-119 2a81b964 58445d07 -2572981889477453e0142 609dfc11 fbf46087 -7793560217139653e0051 4dd28046 1b856ec5 -9163942927285259e-202 194fe601 457dce4d -6353227084707473e0155 63650aff 653ffe8a -4431803091515554e-211 17609068 4f5fe998 -9324754620109615e0211 6f0f7d67 21f7f144 -8870461176410409e0263 79d90529 a37b7e22 -90372559027740405e0143 612491da ad0ba280 -18074511805548081e0146 61a011f2 d73116f4 -54897030182071313e0029 496ec556 66d8f9ec -76232626624829156e-032 3ccb7738 11e75fe -59898021767894608e-165 2128823a 57adbef9 -29949010883947304e-165 2118823a 57adbef9 -26153245263757307e0049 4d83de00 5bd620df -27176258005319167e-261 d27c074 7bd76fa1 -18074511805548081e0147 61d4166f 8cfd5cb1 -24691002732654881e-115 2b759a27 83ce70ab -58483921078398283e0057 4f408ce4 99519ce3 -64409240769861689e-159 22692238 f7987779 -94080055902682397e-242 11364981 e39e66ca -31766135423537365e0154 63550aff 653ffe8a -68985865317742005e0164 657a999d dec72aca -13797173063548401e0165 658a999d dec72aca -902042358290366539e-281 9522dc0 1ca1cb8c -238296178309629163e0272 7c038fd9 3f1f5342 -783308178698887621e0226 72925ae6 2cb346d8 -439176241456570504e0029 499ec556 66d8f9ec -899810892172646163e0283 7e6adf51 fa055e03 -926145344610700019e-225 14f307a6 7f1f69ff -653831131593932675e0047 4d63de00 5bd620df -130766226318786535e0048 4d73de00 5bd620df -557035730189854663e-294 693bfac 6bc4767b -902042358290366539e-280 986b930 23ca3e6f -272104041512242479e0200 6d13bbb4 bf05f087 -544208083024484958e0200 6d23bbb4 bf05f087 -680429695511221511e0192 6b808ebc 116f8a20 -308975121073410857e0236 7490db75 cc001072 -792644927852378159e0078 53d7bff3 36d8ff06 -783308178698887621e0223 71f2cbac 35f71140 -8396094300569779681e-252 f8ab223 efcee35a -3507665085003296281e-074 346b85c0 26a264e4 -7322325862592278999e0074 5336775b 6caa5ae0 -6014546754280072926e0209 6f396397 b06732a4 -7120190517612959703e0120 5cc3220d cd5899fd -3507665085003296281e-073 34a13398 18257f0f -4345544743100783551e-218 168a9c42 e5b6d89f -9778613303868468131e-090 313146fe 1075e1ef -7539204280836061195e-082 32d3d969 e3dbe723 -7862637540082247119e-202 19eaba32 62ee707b -2176832332097939832e0200 6d43bbb4 bf05f087 -8643988913946659879e0115 5bbe71ec 1ed0a4f9 -5529436763613147623e0138 6079c677 be6f236e -6764958008109694533e-173 1fed0669 2e6f5ef6 -6802601037806061975e0197 6cbf92ba cb3cb40c -1360520207561212395e0198 6ccf92ba cb3cb40c -62259110684423957791e0047 4dcd8f2c fc20d6e8 -88800290202542652011e-226 1526cec5 1a43f41a -41010852717673354694e-221 16201295 4b6aabba -20505426358836677347e-221 16101295 4b6aabba -66102447903809911604e0055 4f776206 8a24fd55 -35600952588064798515e0119 5cb3220d cd5899fd -14371240869903838702e0205 6e78d92d 2bcc7a81 -57500690832492901689e0043 4cf65d3e 2acd616b -23432630639573022093e-107 2dbdd54c 40a2f25f -62259110684423957791e0048 4e02797c 1d948651 -35620497849450218807e-306 475b220 82529425 -69658634627134074624e0200 6d93bbb4 bf05f087 -99440755792436956989e-062 37362d10 462a26f4 -55277197169490210673e0081 54d945bf a911e32a -36992084760177624177e-318 1f8c5f9 551c2f9a -30888265282878466443e-111 2cf01b8e f28251fc - -# examples of bugs introduced 20001113, fixed 20010207 -# first is 2^-1075 (half the smallest denormal) -2.4703282292062327208828439643411068618252990130716238221279284125033775363510437593264991818081799618989828234772285886546332835517796989819938739800539093906315035659515570226392290858392449105184435931802849936536152500319370457678249219365623669863658480757001585769269903706311928279558551332927834338409351978015531246597263579574622766465272827220056374006485499977096599470454020828166226237857393450736339007967761930577506740176324673600968951340535537458516661134223766678604162159680461914467291840300530057530849048765391711386591646239524912623653881879636239373280423891018672348497668235089863388587925628302755995657524455507255189313690836254779186948667994968324049705821028513185451396213837722826145437693412532098591327667236328125e-324 0 0 -2.47032822920623272e-324 0 0 - -# examples reported by Mark Dickinson of bugs in the bigcomp() logic introduced -# 20090316 in dtoa.c to speed handling of absurdly long input: -12579816049008305546974391768996369464963024663104e-357 90bbd 7412d19f -17489628565202117263145367596028389348922981857013e-357 c938e 9000492f -18487398785991994634182916638542680759613590482273e-357 d4b3a ee198863 -32002864200581033134358724675198044527469366773928e-358 24d1e ed8448e3 -99999999999999994487665465554760717039532578546e-47 3ff00000 0 -1.0000000000000000100000000000000000000001e44 4911efc6 59cf7d4c -1000000000000000000000000000000000000000e-16 44b52d02 c7e14af6 -10000000000000000000000000000000000000000e-17 44b52d02 c7e14af6 -10.900000000000000012345678912345678912345 4025cccc cccccccd -104308485241983990666713401708072175773165034278685682646111762292409330928739751702404658197872319129036519947435319418387839758990478549477777586673075945844895981012024387992135617064532141489278815239849108105951619997829153633535314849999674266169258928940692239684771590065027025835804863585454872499320500023126142553932654370362024104462255244034053203998964360882487378334860197725139151265590832887433736189468858614521708567646743455601905935595381852723723645799866672558576993978025033590728687206296379801363024094048327273913079612469982585674824156000783167963081616214710691759864332339239688734656548790656486646106983450809073750535624894296242072010195710276073042036425579852459556183541199012652571123898996574563824424330960027873516082763671875e-1075 78026 65fd9600 -99037485700245683102805043437346965248029601286431e-373 0 2 -99617639833743863161109961162881027406769510558457e-373 0 2 -98852915025769345295749278351563179840130565591462e-372 0 14 -99059944827693569659153042769690930905148015876788e-373 0 2 -98914979205069368270421829889078356254059760327101e-372 0 14 -0.999999999999999999999999999999999999999999999e23 44b52d02 c7e14af6 -991633793189150720000000000000000000000000000000000000000e-33 44ea3f92 6bad90c6 -37652435753827922121470370984740152789920e234 78f1667a c9e75d61 -999999999999999996790597280027956716285163e-42 3ff00000 0 -9483973038658180570348795755328802873667739881500874740826641664593613312413122937394311083577538394191754403820631172036846773125424639263833553383990195662207006139342261292777056851379062046720e0 68a03d69 82f2f936 -20209005503919489280000000000000000000000000000000000000000e-40 43bc0bae 57e880e6 diff --git a/lib/libc/gdtoa/test/x.ou0 b/lib/libc/gdtoa/test/x.ou0 deleted file mode 100644 index 6421bc7a1..000000000 --- a/lib/libc/gdtoa/test/x.ou0 +++ /dev/null @@ -1,1182 +0,0 @@ - -Input: 1.23 - -strtox consumes 4 bytes and returns 33 -with bits = #3fff 9d70 a3d7 a3d 70a4 -g_xfmt(0) gives 4 bytes: "1.23" - -strtoIx returns 33, consuming 4 bytes. -fI[0] = #3fff 9d70 a3d7 a3d 70a3 -fI[1] = #3fff 9d70 a3d7 a3d 70a4 -fI[1] == strtox - - -Input: 1.23e+20 - -strtox consumes 8 bytes and returns 1 -with bits = #4041 d55e f90a 2da1 8000 -g_xfmt(0) gives 8 bytes: "1.23e+20" - -strtoIx returns 1, consuming 8 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.23e-20 - -strtox consumes 8 bytes and returns 17 -with bits = #3fbc e857 267b b3a9 84f2 -g_xfmt(0) gives 8 bytes: "1.23e-20" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #3fbc e857 267b b3a9 84f2 -fI[1] = #3fbc e857 267b b3a9 84f3 -fI[0] == strtox - - -Input: 1.23456789 - -strtox consumes 10 bytes and returns 33 -with bits = #3fff 9e06 5214 1ef0 dbf6 -g_xfmt(0) gives 10 bytes: "1.23456789" - -strtoIx returns 33, consuming 10 bytes. -fI[0] = #3fff 9e06 5214 1ef0 dbf5 -fI[1] = #3fff 9e06 5214 1ef0 dbf6 -fI[1] == strtox - - -Input: 1.23456589e+20 - -strtox consumes 14 bytes and returns 1 -with bits = #4041 d629 bd33 5cc ba00 -g_xfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIx returns 1, consuming 14 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.23e+30 - -strtox consumes 8 bytes and returns 17 -with bits = #4062 f865 8274 7dbc 824a -g_xfmt(0) gives 8 bytes: "1.23e+30" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #4062 f865 8274 7dbc 824a -fI[1] = #4062 f865 8274 7dbc 824b -fI[0] == strtox - - -Input: 1.23e-30 - -strtox consumes 8 bytes and returns 17 -with bits = #3f9b c794 337a 8085 54eb -g_xfmt(0) gives 8 bytes: "1.23e-30" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #3f9b c794 337a 8085 54eb -fI[1] = #3f9b c794 337a 8085 54ec -fI[0] == strtox - - -Input: 1.23456789e-20 - -strtox consumes 14 bytes and returns 17 -with bits = #3fbc e934 a38 f3d6 d352 -g_xfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIx returns 17, consuming 14 bytes. -fI[0] = #3fbc e934 a38 f3d6 d352 -fI[1] = #3fbc e934 a38 f3d6 d353 -fI[0] == strtox - - -Input: 1.23456789e-30 - -strtox consumes 14 bytes and returns 17 -with bits = #3f9b c851 f19d decc a8fc -g_xfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIx returns 17, consuming 14 bytes. -fI[0] = #3f9b c851 f19d decc a8fc -fI[1] = #3f9b c851 f19d decc a8fd -fI[0] == strtox - - -Input: 1.234567890123456789 - -strtox consumes 20 bytes and returns 17 -with bits = #3fff 9e06 5214 62cf db8d -g_xfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIx returns 17, consuming 20 bytes. -fI[0] = #3fff 9e06 5214 62cf db8d -fI[1] = #3fff 9e06 5214 62cf db8e -fI[0] == strtox - - -Input: 1.23456789012345678901234567890123456789 - -strtox consumes 40 bytes and returns 17 -with bits = #3fff 9e06 5214 62cf db8d -g_xfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIx returns 17, consuming 40 bytes. -fI[0] = #3fff 9e06 5214 62cf db8d -fI[1] = #3fff 9e06 5214 62cf db8e -fI[0] == strtox - - -Input: 1.23e306 - -strtox consumes 8 bytes and returns 17 -with bits = #43f7 e033 b668 e30f a6d5 -g_xfmt(0) gives 9 bytes: "1.23e+306" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #43f7 e033 b668 e30f a6d5 -fI[1] = #43f7 e033 b668 e30f a6d6 -fI[0] == strtox - - -Input: 1.23e-306 - -strtox consumes 9 bytes and returns 33 -with bits = #3c06 dd1d c2ed 1cb7 3f25 -g_xfmt(0) gives 9 bytes: "1.23e-306" - -strtoIx returns 33, consuming 9 bytes. -fI[0] = #3c06 dd1d c2ed 1cb7 3f24 -fI[1] = #3c06 dd1d c2ed 1cb7 3f25 -fI[1] == strtox - - -Input: 1.23e-320 - -strtox consumes 9 bytes and returns 33 -with bits = #3bd8 9b98 c371 844c 3f1a -g_xfmt(0) gives 9 bytes: "1.23e-320" - -strtoIx returns 33, consuming 9 bytes. -fI[0] = #3bd8 9b98 c371 844c 3f19 -fI[1] = #3bd8 9b98 c371 844c 3f1a -fI[1] == strtox - - -Input: 1.23e-20 - -strtox consumes 8 bytes and returns 17 -with bits = #3fbc e857 267b b3a9 84f2 -g_xfmt(0) gives 8 bytes: "1.23e-20" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #3fbc e857 267b b3a9 84f2 -fI[1] = #3fbc e857 267b b3a9 84f3 -fI[0] == strtox - - -Input: 1.23456789e307 - -strtox consumes 14 bytes and returns 17 -with bits = #43fb 8ca5 8a5e d766 de75 -g_xfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIx returns 17, consuming 14 bytes. -fI[0] = #43fb 8ca5 8a5e d766 de75 -fI[1] = #43fb 8ca5 8a5e d766 de76 -fI[0] == strtox - - -Input: 1.23456589e-307 - -strtox consumes 15 bytes and returns 17 -with bits = #3c03 b18c b5dc c22f d369 -g_xfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIx returns 17, consuming 15 bytes. -fI[0] = #3c03 b18c b5dc c22f d369 -fI[1] = #3c03 b18c b5dc c22f d36a -fI[0] == strtox - - -Input: 1.234567890123456789 - -strtox consumes 20 bytes and returns 17 -with bits = #3fff 9e06 5214 62cf db8d -g_xfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIx returns 17, consuming 20 bytes. -fI[0] = #3fff 9e06 5214 62cf db8d -fI[1] = #3fff 9e06 5214 62cf db8e -fI[0] == strtox - - -Input: 1.234567890123456789e301 - -strtox consumes 24 bytes and returns 33 -with bits = #43e7 937a 8baf ab20 980c -g_xfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIx returns 33, consuming 24 bytes. -fI[0] = #43e7 937a 8baf ab20 980b -fI[1] = #43e7 937a 8baf ab20 980c -fI[1] == strtox - - -Input: 1.234567890123456789e-301 - -strtox consumes 25 bytes and returns 33 -with bits = #3c17 a953 271a 5d06 9ad9 -g_xfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIx returns 33, consuming 25 bytes. -fI[0] = #3c17 a953 271a 5d06 9ad8 -fI[1] = #3c17 a953 271a 5d06 9ad9 -fI[1] == strtox - - -Input: 1.234567890123456789e-321 - -strtox consumes 25 bytes and returns 33 -with bits = #3bd4 f9e1 1b4c ea6d cce9 -g_xfmt(0) gives 25 bytes: "1.234567890123456789e-321" - -strtoIx returns 33, consuming 25 bytes. -fI[0] = #3bd4 f9e1 1b4c ea6d cce8 -fI[1] = #3bd4 f9e1 1b4c ea6d cce9 -fI[1] == strtox - - -Input: 1e23 - -strtox consumes 4 bytes and returns 1 -with bits = #404b a968 163f a57 b400 -g_xfmt(0) gives 5 bytes: "1e+23" - -strtoIx returns 1, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1e310 - -strtox consumes 5 bytes and returns 33 -with bits = #4404 de81 e40a 34b cf50 -g_xfmt(0) gives 6 bytes: "1e+310" - -strtoIx returns 33, consuming 5 bytes. -fI[0] = #4404 de81 e40a 34b cf4f -fI[1] = #4404 de81 e40a 34b cf50 -fI[1] == strtox - - -Input: 9.0259718793241475e-277 - -strtox consumes 23 bytes and returns 33 -with bits = #3c69 ffff ffff ffff fcf7 -g_xfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIx returns 33, consuming 23 bytes. -fI[0] = #3c69 ffff ffff ffff fcf6 -fI[1] = #3c69 ffff ffff ffff fcf7 -fI[1] == strtox - - -Input: 9.025971879324147880346310405869e-277 - -strtox consumes 37 bytes and returns 17 -with bits = #3c6a 8000 0 0 0 -g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIx returns 17, consuming 37 bytes. -fI[0] = #3c6a 8000 0 0 0 -fI[1] = #3c6a 8000 0 0 1 -fI[0] == strtox - - -Input: 9.025971879324147880346310405868e-277 - -strtox consumes 37 bytes and returns 33 -with bits = #3c6a 8000 0 0 0 -g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIx returns 33, consuming 37 bytes. -fI[0] = #3c69 ffff ffff ffff ffff -fI[1] = #3c6a 8000 0 0 0 -fI[1] == strtox - - -Input: 2.2250738585072014e-308 - -strtox consumes 23 bytes and returns 17 -with bits = #3c01 8000 0 0 46 -g_xfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIx returns 17, consuming 23 bytes. -fI[0] = #3c01 8000 0 0 46 -fI[1] = #3c01 8000 0 0 47 -fI[0] == strtox - - -Input: 2.2250738585072013e-308 - -strtox consumes 23 bytes and returns 17 -with bits = #3c00 ffff ffff ffff fd4f -g_xfmt(0) gives 23 bytes: "2.2250738585072013e-308" - -strtoIx returns 17, consuming 23 bytes. -fI[0] = #3c00 ffff ffff ffff fd4f -fI[1] = #3c00 ffff ffff ffff fd50 -fI[0] == strtox - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 8ccc cccc cccc cccc -g_xfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -fI[1] = #3fff 8ccc cccc cccc cccd -fI[0] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 8ccc cccc cccc cccc -g_xfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -fI[1] = #bfff 8ccc cccc cccc cccc -fI[1] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 9999 9999 9999 9999 -g_xfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -fI[1] = #3fff 9999 9999 9999 999a -fI[0] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 9999 9999 9999 9999 -g_xfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -fI[1] = #bfff 9999 9999 9999 9999 -fI[1] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff a666 6666 6666 6666 -g_xfmt(0) gives 3 bytes: "1.3" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -fI[1] = #3fff a666 6666 6666 6667 -fI[0] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff a666 6666 6666 6666 -g_xfmt(0) gives 4 bytes: "-1.3" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -fI[1] = #bfff a666 6666 6666 6666 -fI[1] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff b333 3333 3333 3333 -g_xfmt(0) gives 3 bytes: "1.4" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -fI[1] = #3fff b333 3333 3333 3334 -fI[0] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff b333 3333 3333 3333 -g_xfmt(0) gives 4 bytes: "-1.4" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -fI[1] = #bfff b333 3333 3333 3333 -fI[1] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff cccc cccc cccc cccc -g_xfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -fI[1] = #3fff cccc cccc cccc cccd -fI[0] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff cccc cccc cccc cccc -g_xfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -fI[1] = #bfff cccc cccc cccc cccc -fI[1] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff d999 9999 9999 9999 -g_xfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -fI[1] = #3fff d999 9999 9999 999a -fI[0] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff d999 9999 9999 9999 -g_xfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -fI[1] = #bfff d999 9999 9999 9999 -fI[1] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff e666 6666 6666 6666 -g_xfmt(0) gives 3 bytes: "1.8" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -fI[1] = #3fff e666 6666 6666 6667 -fI[0] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff e666 6666 6666 6666 -g_xfmt(0) gives 4 bytes: "-1.8" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -fI[1] = #bfff e666 6666 6666 6666 -fI[1] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff f333 3333 3333 3333 -g_xfmt(0) gives 3 bytes: "1.9" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -fI[1] = #3fff f333 3333 3333 3334 -fI[0] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff f333 3333 3333 3333 -g_xfmt(0) gives 4 bytes: "-1.9" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -fI[1] = #bfff f333 3333 3333 3333 -fI[1] == strtox - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 8ccc cccc cccc cccd -g_xfmt(0) gives 3 bytes: "1.1" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -fI[1] = #3fff 8ccc cccc cccc cccd -fI[1] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 8ccc cccc cccc cccd -g_xfmt(0) gives 4 bytes: "-1.1" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -fI[1] = #bfff 8ccc cccc cccc cccc -fI[0] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 9999 9999 9999 999a -g_xfmt(0) gives 3 bytes: "1.2" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -fI[1] = #3fff 9999 9999 9999 999a -fI[1] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 9999 9999 9999 999a -g_xfmt(0) gives 4 bytes: "-1.2" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -fI[1] = #bfff 9999 9999 9999 9999 -fI[0] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff a666 6666 6666 6666 -g_xfmt(0) gives 3 bytes: "1.3" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -fI[1] = #3fff a666 6666 6666 6667 -fI[0] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff a666 6666 6666 6666 -g_xfmt(0) gives 4 bytes: "-1.3" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -fI[1] = #bfff a666 6666 6666 6666 -fI[1] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff b333 3333 3333 3333 -g_xfmt(0) gives 3 bytes: "1.4" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -fI[1] = #3fff b333 3333 3333 3334 -fI[0] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff b333 3333 3333 3333 -g_xfmt(0) gives 4 bytes: "-1.4" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -fI[1] = #bfff b333 3333 3333 3333 -fI[1] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff cccc cccc cccc cccd -g_xfmt(0) gives 3 bytes: "1.6" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -fI[1] = #3fff cccc cccc cccc cccd -fI[1] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff cccc cccc cccc cccd -g_xfmt(0) gives 4 bytes: "-1.6" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -fI[1] = #bfff cccc cccc cccc cccc -fI[0] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff d999 9999 9999 999a -g_xfmt(0) gives 3 bytes: "1.7" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -fI[1] = #3fff d999 9999 9999 999a -fI[1] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff d999 9999 9999 999a -g_xfmt(0) gives 4 bytes: "-1.7" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -fI[1] = #bfff d999 9999 9999 9999 -fI[0] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff e666 6666 6666 6666 -g_xfmt(0) gives 3 bytes: "1.8" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -fI[1] = #3fff e666 6666 6666 6667 -fI[0] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff e666 6666 6666 6666 -g_xfmt(0) gives 4 bytes: "-1.8" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -fI[1] = #bfff e666 6666 6666 6666 -fI[1] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff f333 3333 3333 3333 -g_xfmt(0) gives 3 bytes: "1.9" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -fI[1] = #3fff f333 3333 3333 3334 -fI[0] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff f333 3333 3333 3333 -g_xfmt(0) gives 4 bytes: "-1.9" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -fI[1] = #bfff f333 3333 3333 3333 -fI[1] == strtox - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 8ccc cccc cccc cccd -g_xfmt(0) gives 3 bytes: "1.1" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -fI[1] = #3fff 8ccc cccc cccc cccd -fI[1] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 8ccc cccc cccc cccc -g_xfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -fI[1] = #bfff 8ccc cccc cccc cccc -fI[1] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 9999 9999 9999 999a -g_xfmt(0) gives 3 bytes: "1.2" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -fI[1] = #3fff 9999 9999 9999 999a -fI[1] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 9999 9999 9999 9999 -g_xfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -fI[1] = #bfff 9999 9999 9999 9999 -fI[1] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff a666 6666 6666 6667 -g_xfmt(0) gives 21 bytes: "1.3000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -fI[1] = #3fff a666 6666 6666 6667 -fI[1] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff a666 6666 6666 6666 -g_xfmt(0) gives 4 bytes: "-1.3" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -fI[1] = #bfff a666 6666 6666 6666 -fI[1] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff b333 3333 3333 3334 -g_xfmt(0) gives 21 bytes: "1.4000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -fI[1] = #3fff b333 3333 3333 3334 -fI[1] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff b333 3333 3333 3333 -g_xfmt(0) gives 4 bytes: "-1.4" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -fI[1] = #bfff b333 3333 3333 3333 -fI[1] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff cccc cccc cccc cccd -g_xfmt(0) gives 3 bytes: "1.6" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -fI[1] = #3fff cccc cccc cccc cccd -fI[1] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff cccc cccc cccc cccc -g_xfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -fI[1] = #bfff cccc cccc cccc cccc -fI[1] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff d999 9999 9999 999a -g_xfmt(0) gives 3 bytes: "1.7" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -fI[1] = #3fff d999 9999 9999 999a -fI[1] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff d999 9999 9999 9999 -g_xfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -fI[1] = #bfff d999 9999 9999 9999 -fI[1] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff e666 6666 6666 6667 -g_xfmt(0) gives 21 bytes: "1.8000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -fI[1] = #3fff e666 6666 6666 6667 -fI[1] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff e666 6666 6666 6666 -g_xfmt(0) gives 4 bytes: "-1.8" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -fI[1] = #bfff e666 6666 6666 6666 -fI[1] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff f333 3333 3333 3334 -g_xfmt(0) gives 21 bytes: "1.9000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -fI[1] = #3fff f333 3333 3333 3334 -fI[1] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff f333 3333 3333 3333 -g_xfmt(0) gives 4 bytes: "-1.9" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -fI[1] = #bfff f333 3333 3333 3333 -fI[1] == strtox - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 8ccc cccc cccc cccc -g_xfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -fI[1] = #3fff 8ccc cccc cccc cccd -fI[0] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 8ccc cccc cccc cccd -g_xfmt(0) gives 4 bytes: "-1.1" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -fI[1] = #bfff 8ccc cccc cccc cccc -fI[0] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 9999 9999 9999 9999 -g_xfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -fI[1] = #3fff 9999 9999 9999 999a -fI[0] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 9999 9999 9999 999a -g_xfmt(0) gives 4 bytes: "-1.2" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -fI[1] = #bfff 9999 9999 9999 9999 -fI[0] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff a666 6666 6666 6666 -g_xfmt(0) gives 3 bytes: "1.3" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -fI[1] = #3fff a666 6666 6666 6667 -fI[0] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff a666 6666 6666 6667 -g_xfmt(0) gives 22 bytes: "-1.3000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -fI[1] = #bfff a666 6666 6666 6666 -fI[0] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff b333 3333 3333 3333 -g_xfmt(0) gives 3 bytes: "1.4" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -fI[1] = #3fff b333 3333 3333 3334 -fI[0] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff b333 3333 3333 3334 -g_xfmt(0) gives 22 bytes: "-1.4000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -fI[1] = #bfff b333 3333 3333 3333 -fI[0] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff cccc cccc cccc cccc -g_xfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -fI[1] = #3fff cccc cccc cccc cccd -fI[0] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff cccc cccc cccc cccd -g_xfmt(0) gives 4 bytes: "-1.6" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -fI[1] = #bfff cccc cccc cccc cccc -fI[0] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff d999 9999 9999 9999 -g_xfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -fI[1] = #3fff d999 9999 9999 999a -fI[0] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff d999 9999 9999 999a -g_xfmt(0) gives 4 bytes: "-1.7" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -fI[1] = #bfff d999 9999 9999 9999 -fI[0] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff e666 6666 6666 6666 -g_xfmt(0) gives 3 bytes: "1.8" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -fI[1] = #3fff e666 6666 6666 6667 -fI[0] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff e666 6666 6666 6667 -g_xfmt(0) gives 22 bytes: "-1.8000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -fI[1] = #bfff e666 6666 6666 6666 -fI[0] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff f333 3333 3333 3333 -g_xfmt(0) gives 3 bytes: "1.9" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -fI[1] = #3fff f333 3333 3333 3334 -fI[0] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff f333 3333 3333 3334 -g_xfmt(0) gives 22 bytes: "-1.9000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -fI[1] = #bfff f333 3333 3333 3333 -fI[0] == strtox - diff --git a/lib/libc/gdtoa/test/x.ou1 b/lib/libc/gdtoa/test/x.ou1 deleted file mode 100644 index 437783f71..000000000 --- a/lib/libc/gdtoa/test/x.ou1 +++ /dev/null @@ -1,1460 +0,0 @@ - -Input: 1.23 - -strtox consumes 4 bytes and returns 33 -with bits = #3fff 9d70 a3d7 a3d 70a4 -printf("%.21Lg") gives 1.23000000000000000002 -g_xfmt(0) gives 4 bytes: "1.23" - -strtoIx returns 33, consuming 4 bytes. -fI[0] = #3fff 9d70 a3d7 a3d 70a3 -= 1.22999999999999999991 -fI[1] = #3fff 9d70 a3d7 a3d 70a4 -= 1.23000000000000000002 -fI[1] == strtox - - -Input: 1.23e+20 - -strtox consumes 8 bytes and returns 1 -with bits = #4041 d55e f90a 2da1 8000 -printf("%.21Lg") gives 123000000000000000000 -g_xfmt(0) gives 8 bytes: "1.23e+20" - -strtoIx returns 1, consuming 8 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.23e-20 - -strtox consumes 8 bytes and returns 17 -with bits = #3fbc e857 267b b3a9 84f2 -printf("%.21Lg") gives 1.22999999999999999997e-20 -g_xfmt(0) gives 8 bytes: "1.23e-20" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #3fbc e857 267b b3a9 84f2 -= 1.22999999999999999997e-20 -fI[1] = #3fbc e857 267b b3a9 84f3 -= 1.23000000000000000004e-20 -fI[0] == strtox - - -Input: 1.23456789 - -strtox consumes 10 bytes and returns 33 -with bits = #3fff 9e06 5214 1ef0 dbf6 -printf("%.21Lg") gives 1.23456789000000000003 -g_xfmt(0) gives 10 bytes: "1.23456789" - -strtoIx returns 33, consuming 10 bytes. -fI[0] = #3fff 9e06 5214 1ef0 dbf5 -= 1.23456788999999999992 -fI[1] = #3fff 9e06 5214 1ef0 dbf6 -= 1.23456789000000000003 -fI[1] == strtox - - -Input: 1.23456589e+20 - -strtox consumes 14 bytes and returns 1 -with bits = #4041 d629 bd33 5cc ba00 -printf("%.21Lg") gives 123456589000000000000 -g_xfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIx returns 1, consuming 14 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.23e+30 - -strtox consumes 8 bytes and returns 17 -with bits = #4062 f865 8274 7dbc 824a -printf("%.21Lg") gives 1.22999999999999999999e+30 -g_xfmt(0) gives 8 bytes: "1.23e+30" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #4062 f865 8274 7dbc 824a -= 1.22999999999999999999e+30 -fI[1] = #4062 f865 8274 7dbc 824b -= 1.23000000000000000006e+30 -fI[0] == strtox - - -Input: 1.23e-30 - -strtox consumes 8 bytes and returns 17 -with bits = #3f9b c794 337a 8085 54eb -printf("%.21Lg") gives 1.22999999999999999999e-30 -g_xfmt(0) gives 8 bytes: "1.23e-30" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #3f9b c794 337a 8085 54eb -= 1.22999999999999999999e-30 -fI[1] = #3f9b c794 337a 8085 54ec -= 1.23000000000000000007e-30 -fI[0] == strtox - - -Input: 1.23456789e-20 - -strtox consumes 14 bytes and returns 17 -with bits = #3fbc e934 a38 f3d6 d352 -printf("%.21Lg") gives 1.23456788999999999998e-20 -g_xfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIx returns 17, consuming 14 bytes. -fI[0] = #3fbc e934 a38 f3d6 d352 -= 1.23456788999999999998e-20 -fI[1] = #3fbc e934 a38 f3d6 d353 -= 1.23456789000000000005e-20 -fI[0] == strtox - - -Input: 1.23456789e-30 - -strtox consumes 14 bytes and returns 17 -with bits = #3f9b c851 f19d decc a8fc -printf("%.21Lg") gives 1.23456788999999999999e-30 -g_xfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIx returns 17, consuming 14 bytes. -fI[0] = #3f9b c851 f19d decc a8fc -= 1.23456788999999999999e-30 -fI[1] = #3f9b c851 f19d decc a8fd -= 1.23456789000000000007e-30 -fI[0] == strtox - - -Input: 1.234567890123456789 - -strtox consumes 20 bytes and returns 17 -with bits = #3fff 9e06 5214 62cf db8d -printf("%.21Lg") gives 1.23456789012345678899 -g_xfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIx returns 17, consuming 20 bytes. -fI[0] = #3fff 9e06 5214 62cf db8d -= 1.23456789012345678899 -fI[1] = #3fff 9e06 5214 62cf db8e -= 1.23456789012345678909 -fI[0] == strtox - - -Input: 1.23456789012345678901234567890123456789 - -strtox consumes 40 bytes and returns 17 -with bits = #3fff 9e06 5214 62cf db8d -printf("%.21Lg") gives 1.23456789012345678899 -g_xfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIx returns 17, consuming 40 bytes. -fI[0] = #3fff 9e06 5214 62cf db8d -= 1.23456789012345678899 -fI[1] = #3fff 9e06 5214 62cf db8e -= 1.23456789012345678909 -fI[0] == strtox - - -Input: 1.23e306 - -strtox consumes 8 bytes and returns 17 -with bits = #43f7 e033 b668 e30f a6d5 -printf("%.21Lg") gives 1.22999999999999999997e+306 -g_xfmt(0) gives 9 bytes: "1.23e+306" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #43f7 e033 b668 e30f a6d5 -= 1.22999999999999999997e+306 -fI[1] = #43f7 e033 b668 e30f a6d6 -= 1.23000000000000000005e+306 -fI[0] == strtox - - -Input: 1.23e-306 - -strtox consumes 9 bytes and returns 33 -with bits = #3c06 dd1d c2ed 1cb7 3f25 -printf("%.21Lg") gives 1.23000000000000000002e-306 -g_xfmt(0) gives 9 bytes: "1.23e-306" - -strtoIx returns 33, consuming 9 bytes. -fI[0] = #3c06 dd1d c2ed 1cb7 3f24 -= 1.22999999999999999995e-306 -fI[1] = #3c06 dd1d c2ed 1cb7 3f25 -= 1.23000000000000000002e-306 -fI[1] == strtox - - -Input: 1.23e-320 - -strtox consumes 9 bytes and returns 33 -with bits = #3bd8 9b98 c371 844c 3f1a -printf("%.21Lg") gives 1.23000000000000000002e-320 -g_xfmt(0) gives 9 bytes: "1.23e-320" - -strtoIx returns 33, consuming 9 bytes. -fI[0] = #3bd8 9b98 c371 844c 3f19 -= 1.22999999999999999991e-320 -fI[1] = #3bd8 9b98 c371 844c 3f1a -= 1.23000000000000000002e-320 -fI[1] == strtox - - -Input: 1.23e-20 - -strtox consumes 8 bytes and returns 17 -with bits = #3fbc e857 267b b3a9 84f2 -printf("%.21Lg") gives 1.22999999999999999997e-20 -g_xfmt(0) gives 8 bytes: "1.23e-20" - -strtoIx returns 17, consuming 8 bytes. -fI[0] = #3fbc e857 267b b3a9 84f2 -= 1.22999999999999999997e-20 -fI[1] = #3fbc e857 267b b3a9 84f3 -= 1.23000000000000000004e-20 -fI[0] == strtox - - -Input: 1.23456789e307 - -strtox consumes 14 bytes and returns 17 -with bits = #43fb 8ca5 8a5e d766 de75 -printf("%.21Lg") gives 1.23456788999999999998e+307 -g_xfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIx returns 17, consuming 14 bytes. -fI[0] = #43fb 8ca5 8a5e d766 de75 -= 1.23456788999999999998e+307 -fI[1] = #43fb 8ca5 8a5e d766 de76 -= 1.23456789000000000011e+307 -fI[0] == strtox - - -Input: 1.23456589e-307 - -strtox consumes 15 bytes and returns 17 -with bits = #3c03 b18c b5dc c22f d369 -printf("%.21Lg") gives 1.23456588999999999999e-307 -g_xfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIx returns 17, consuming 15 bytes. -fI[0] = #3c03 b18c b5dc c22f d369 -= 1.23456588999999999999e-307 -fI[1] = #3c03 b18c b5dc c22f d36a -= 1.23456589000000000009e-307 -fI[0] == strtox - - -Input: 1.234567890123456789 - -strtox consumes 20 bytes and returns 17 -with bits = #3fff 9e06 5214 62cf db8d -printf("%.21Lg") gives 1.23456789012345678899 -g_xfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIx returns 17, consuming 20 bytes. -fI[0] = #3fff 9e06 5214 62cf db8d -= 1.23456789012345678899 -fI[1] = #3fff 9e06 5214 62cf db8e -= 1.23456789012345678909 -fI[0] == strtox - - -Input: 1.234567890123456789e301 - -strtox consumes 24 bytes and returns 33 -with bits = #43e7 937a 8baf ab20 980c -printf("%.21Lg") gives 1.234567890123456789e+301 -g_xfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIx returns 33, consuming 24 bytes. -fI[0] = #43e7 937a 8baf ab20 980b -= 1.23456789012345678889e+301 -fI[1] = #43e7 937a 8baf ab20 980c -= 1.234567890123456789e+301 -fI[1] == strtox - - -Input: 1.234567890123456789e-301 - -strtox consumes 25 bytes and returns 33 -with bits = #3c17 a953 271a 5d06 9ad9 -printf("%.21Lg") gives 1.23456789012345678902e-301 -g_xfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIx returns 33, consuming 25 bytes. -fI[0] = #3c17 a953 271a 5d06 9ad8 -= 1.23456789012345678892e-301 -fI[1] = #3c17 a953 271a 5d06 9ad9 -= 1.23456789012345678902e-301 -fI[1] == strtox - - -Input: 1.234567890123456789e-321 - -strtox consumes 25 bytes and returns 33 -with bits = #3bd4 f9e1 1b4c ea6d cce9 -printf("%.21Lg") gives 1.234567890123456789e-321 -g_xfmt(0) gives 25 bytes: "1.234567890123456789e-321" - -strtoIx returns 33, consuming 25 bytes. -fI[0] = #3bd4 f9e1 1b4c ea6d cce8 -= 1.23456789012345678893e-321 -fI[1] = #3bd4 f9e1 1b4c ea6d cce9 -= 1.234567890123456789e-321 -fI[1] == strtox - - -Input: 1e23 - -strtox consumes 4 bytes and returns 1 -with bits = #404b a968 163f a57 b400 -printf("%.21Lg") gives 1e+23 -g_xfmt(0) gives 5 bytes: "1e+23" - -strtoIx returns 1, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1e310 - -strtox consumes 5 bytes and returns 33 -with bits = #4404 de81 e40a 34b cf50 -printf("%.21Lg") gives 1e+310 -g_xfmt(0) gives 6 bytes: "1e+310" - -strtoIx returns 33, consuming 5 bytes. -fI[0] = #4404 de81 e40a 34b cf4f -= 9.9999999999999999994e+309 -fI[1] = #4404 de81 e40a 34b cf50 -= 1e+310 -fI[1] == strtox - - -Input: 9.0259718793241475e-277 - -strtox consumes 23 bytes and returns 33 -with bits = #3c69 ffff ffff ffff fcf7 -printf("%.21Lg") gives 9.02597187932414750016e-277 -g_xfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIx returns 33, consuming 23 bytes. -fI[0] = #3c69 ffff ffff ffff fcf6 -= 9.02597187932414749967e-277 -fI[1] = #3c69 ffff ffff ffff fcf7 -= 9.02597187932414750016e-277 -fI[1] == strtox - - -Input: 9.025971879324147880346310405869e-277 - -strtox consumes 37 bytes and returns 17 -with bits = #3c6a 8000 0 0 0 -printf("%.21Lg") gives 9.02597187932414788035e-277 -g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIx returns 17, consuming 37 bytes. -fI[0] = #3c6a 8000 0 0 0 -= 9.02597187932414788035e-277 -fI[1] = #3c6a 8000 0 0 1 -= 9.02597187932414788132e-277 -fI[0] == strtox - - -Input: 9.025971879324147880346310405868e-277 - -strtox consumes 37 bytes and returns 33 -with bits = #3c6a 8000 0 0 0 -printf("%.21Lg") gives 9.02597187932414788035e-277 -g_xfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIx returns 33, consuming 37 bytes. -fI[0] = #3c69 ffff ffff ffff ffff -= 9.02597187932414787986e-277 -fI[1] = #3c6a 8000 0 0 0 -= 9.02597187932414788035e-277 -fI[1] == strtox - - -Input: 2.2250738585072014e-308 - -strtox consumes 23 bytes and returns 17 -with bits = #3c01 8000 0 0 46 -printf("%.21Lg") gives 2.22507385850720139998e-308 -g_xfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIx returns 17, consuming 23 bytes. -fI[0] = #3c01 8000 0 0 46 -= 2.22507385850720139998e-308 -fI[1] = #3c01 8000 0 0 47 -= 2.22507385850720140022e-308 -fI[0] == strtox - - -Input: 2.2250738585072013e-308 - -strtox consumes 23 bytes and returns 17 -with bits = #3c00 ffff ffff ffff fd4f -printf("%.21Lg") gives 2.22507385850720129998e-308 -g_xfmt(0) gives 23 bytes: "2.2250738585072013e-308" - -strtoIx returns 17, consuming 23 bytes. -fI[0] = #3c00 ffff ffff ffff fd4f -= 2.22507385850720129998e-308 -fI[1] = #3c00 ffff ffff ffff fd50 -= 2.2250738585072013001e-308 -fI[0] == strtox - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 8ccc cccc cccc cccc -printf("%.21Lg") gives 1.09999999999999999991 -g_xfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -= 1.09999999999999999991 -fI[1] = #3fff 8ccc cccc cccc cccd -= 1.10000000000000000002 -fI[0] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 8ccc cccc cccc cccc -printf("%.21Lg") gives -1.09999999999999999991 -g_xfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -= -1.10000000000000000002 -fI[1] = #bfff 8ccc cccc cccc cccc -= -1.09999999999999999991 -fI[1] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 9999 9999 9999 9999 -printf("%.21Lg") gives 1.19999999999999999993 -g_xfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -= 1.19999999999999999993 -fI[1] = #3fff 9999 9999 9999 999a -= 1.20000000000000000004 -fI[0] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 9999 9999 9999 9999 -printf("%.21Lg") gives -1.19999999999999999993 -g_xfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -= -1.20000000000000000004 -fI[1] = #bfff 9999 9999 9999 9999 -= -1.19999999999999999993 -fI[1] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff a666 6666 6666 6666 -printf("%.21Lg") gives 1.29999999999999999996 -g_xfmt(0) gives 3 bytes: "1.3" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -= 1.29999999999999999996 -fI[1] = #3fff a666 6666 6666 6667 -= 1.30000000000000000007 -fI[0] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff a666 6666 6666 6666 -printf("%.21Lg") gives -1.29999999999999999996 -g_xfmt(0) gives 4 bytes: "-1.3" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -= -1.30000000000000000007 -fI[1] = #bfff a666 6666 6666 6666 -= -1.29999999999999999996 -fI[1] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff b333 3333 3333 3333 -printf("%.21Lg") gives 1.39999999999999999998 -g_xfmt(0) gives 3 bytes: "1.4" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -= 1.39999999999999999998 -fI[1] = #3fff b333 3333 3333 3334 -= 1.40000000000000000009 -fI[0] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff b333 3333 3333 3333 -printf("%.21Lg") gives -1.39999999999999999998 -g_xfmt(0) gives 4 bytes: "-1.4" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -= -1.40000000000000000009 -fI[1] = #bfff b333 3333 3333 3333 -= -1.39999999999999999998 -fI[1] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -printf("%.21Lg") gives 1.5 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -printf("%.21Lg") gives -1.5 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff cccc cccc cccc cccc -printf("%.21Lg") gives 1.59999999999999999991 -g_xfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -= 1.59999999999999999991 -fI[1] = #3fff cccc cccc cccc cccd -= 1.60000000000000000002 -fI[0] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff cccc cccc cccc cccc -printf("%.21Lg") gives -1.59999999999999999991 -g_xfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -= -1.60000000000000000002 -fI[1] = #bfff cccc cccc cccc cccc -= -1.59999999999999999991 -fI[1] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff d999 9999 9999 9999 -printf("%.21Lg") gives 1.69999999999999999993 -g_xfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -= 1.69999999999999999993 -fI[1] = #3fff d999 9999 9999 999a -= 1.70000000000000000004 -fI[0] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff d999 9999 9999 9999 -printf("%.21Lg") gives -1.69999999999999999993 -g_xfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -= -1.70000000000000000004 -fI[1] = #bfff d999 9999 9999 9999 -= -1.69999999999999999993 -fI[1] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff e666 6666 6666 6666 -printf("%.21Lg") gives 1.79999999999999999996 -g_xfmt(0) gives 3 bytes: "1.8" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -= 1.79999999999999999996 -fI[1] = #3fff e666 6666 6666 6667 -= 1.80000000000000000007 -fI[0] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff e666 6666 6666 6666 -printf("%.21Lg") gives -1.79999999999999999996 -g_xfmt(0) gives 4 bytes: "-1.8" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -= -1.80000000000000000007 -fI[1] = #bfff e666 6666 6666 6666 -= -1.79999999999999999996 -fI[1] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff f333 3333 3333 3333 -printf("%.21Lg") gives 1.89999999999999999998 -g_xfmt(0) gives 3 bytes: "1.9" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -= 1.89999999999999999998 -fI[1] = #3fff f333 3333 3333 3334 -= 1.90000000000000000009 -fI[0] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff f333 3333 3333 3333 -printf("%.21Lg") gives -1.89999999999999999998 -g_xfmt(0) gives 4 bytes: "-1.9" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -= -1.90000000000000000009 -fI[1] = #bfff f333 3333 3333 3333 -= -1.89999999999999999998 -fI[1] == strtox - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 8ccc cccc cccc cccd -printf("%.21Lg") gives 1.10000000000000000002 -g_xfmt(0) gives 3 bytes: "1.1" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -= 1.09999999999999999991 -fI[1] = #3fff 8ccc cccc cccc cccd -= 1.10000000000000000002 -fI[1] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 8ccc cccc cccc cccd -printf("%.21Lg") gives -1.10000000000000000002 -g_xfmt(0) gives 4 bytes: "-1.1" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -= -1.10000000000000000002 -fI[1] = #bfff 8ccc cccc cccc cccc -= -1.09999999999999999991 -fI[0] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 9999 9999 9999 999a -printf("%.21Lg") gives 1.20000000000000000004 -g_xfmt(0) gives 3 bytes: "1.2" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -= 1.19999999999999999993 -fI[1] = #3fff 9999 9999 9999 999a -= 1.20000000000000000004 -fI[1] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 9999 9999 9999 999a -printf("%.21Lg") gives -1.20000000000000000004 -g_xfmt(0) gives 4 bytes: "-1.2" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -= -1.20000000000000000004 -fI[1] = #bfff 9999 9999 9999 9999 -= -1.19999999999999999993 -fI[0] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff a666 6666 6666 6666 -printf("%.21Lg") gives 1.29999999999999999996 -g_xfmt(0) gives 3 bytes: "1.3" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -= 1.29999999999999999996 -fI[1] = #3fff a666 6666 6666 6667 -= 1.30000000000000000007 -fI[0] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff a666 6666 6666 6666 -printf("%.21Lg") gives -1.29999999999999999996 -g_xfmt(0) gives 4 bytes: "-1.3" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -= -1.30000000000000000007 -fI[1] = #bfff a666 6666 6666 6666 -= -1.29999999999999999996 -fI[1] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff b333 3333 3333 3333 -printf("%.21Lg") gives 1.39999999999999999998 -g_xfmt(0) gives 3 bytes: "1.4" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -= 1.39999999999999999998 -fI[1] = #3fff b333 3333 3333 3334 -= 1.40000000000000000009 -fI[0] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff b333 3333 3333 3333 -printf("%.21Lg") gives -1.39999999999999999998 -g_xfmt(0) gives 4 bytes: "-1.4" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -= -1.40000000000000000009 -fI[1] = #bfff b333 3333 3333 3333 -= -1.39999999999999999998 -fI[1] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -printf("%.21Lg") gives 1.5 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -printf("%.21Lg") gives -1.5 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff cccc cccc cccc cccd -printf("%.21Lg") gives 1.60000000000000000002 -g_xfmt(0) gives 3 bytes: "1.6" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -= 1.59999999999999999991 -fI[1] = #3fff cccc cccc cccc cccd -= 1.60000000000000000002 -fI[1] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff cccc cccc cccc cccd -printf("%.21Lg") gives -1.60000000000000000002 -g_xfmt(0) gives 4 bytes: "-1.6" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -= -1.60000000000000000002 -fI[1] = #bfff cccc cccc cccc cccc -= -1.59999999999999999991 -fI[0] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff d999 9999 9999 999a -printf("%.21Lg") gives 1.70000000000000000004 -g_xfmt(0) gives 3 bytes: "1.7" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -= 1.69999999999999999993 -fI[1] = #3fff d999 9999 9999 999a -= 1.70000000000000000004 -fI[1] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff d999 9999 9999 999a -printf("%.21Lg") gives -1.70000000000000000004 -g_xfmt(0) gives 4 bytes: "-1.7" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -= -1.70000000000000000004 -fI[1] = #bfff d999 9999 9999 9999 -= -1.69999999999999999993 -fI[0] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff e666 6666 6666 6666 -printf("%.21Lg") gives 1.79999999999999999996 -g_xfmt(0) gives 3 bytes: "1.8" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -= 1.79999999999999999996 -fI[1] = #3fff e666 6666 6666 6667 -= 1.80000000000000000007 -fI[0] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff e666 6666 6666 6666 -printf("%.21Lg") gives -1.79999999999999999996 -g_xfmt(0) gives 4 bytes: "-1.8" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -= -1.80000000000000000007 -fI[1] = #bfff e666 6666 6666 6666 -= -1.79999999999999999996 -fI[1] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff f333 3333 3333 3333 -printf("%.21Lg") gives 1.89999999999999999998 -g_xfmt(0) gives 3 bytes: "1.9" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -= 1.89999999999999999998 -fI[1] = #3fff f333 3333 3333 3334 -= 1.90000000000000000009 -fI[0] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff f333 3333 3333 3333 -printf("%.21Lg") gives -1.89999999999999999998 -g_xfmt(0) gives 4 bytes: "-1.9" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -= -1.90000000000000000009 -fI[1] = #bfff f333 3333 3333 3333 -= -1.89999999999999999998 -fI[1] == strtox - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 8ccc cccc cccc cccd -printf("%.21Lg") gives 1.10000000000000000002 -g_xfmt(0) gives 3 bytes: "1.1" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -= 1.09999999999999999991 -fI[1] = #3fff 8ccc cccc cccc cccd -= 1.10000000000000000002 -fI[1] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 8ccc cccc cccc cccc -printf("%.21Lg") gives -1.09999999999999999991 -g_xfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -= -1.10000000000000000002 -fI[1] = #bfff 8ccc cccc cccc cccc -= -1.09999999999999999991 -fI[1] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff 9999 9999 9999 999a -printf("%.21Lg") gives 1.20000000000000000004 -g_xfmt(0) gives 3 bytes: "1.2" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -= 1.19999999999999999993 -fI[1] = #3fff 9999 9999 9999 999a -= 1.20000000000000000004 -fI[1] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff 9999 9999 9999 9999 -printf("%.21Lg") gives -1.19999999999999999993 -g_xfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -= -1.20000000000000000004 -fI[1] = #bfff 9999 9999 9999 9999 -= -1.19999999999999999993 -fI[1] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff a666 6666 6666 6667 -printf("%.21Lg") gives 1.30000000000000000007 -g_xfmt(0) gives 21 bytes: "1.3000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -= 1.29999999999999999996 -fI[1] = #3fff a666 6666 6666 6667 -= 1.30000000000000000007 -fI[1] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff a666 6666 6666 6666 -printf("%.21Lg") gives -1.29999999999999999996 -g_xfmt(0) gives 4 bytes: "-1.3" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -= -1.30000000000000000007 -fI[1] = #bfff a666 6666 6666 6666 -= -1.29999999999999999996 -fI[1] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff b333 3333 3333 3334 -printf("%.21Lg") gives 1.40000000000000000009 -g_xfmt(0) gives 21 bytes: "1.4000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -= 1.39999999999999999998 -fI[1] = #3fff b333 3333 3333 3334 -= 1.40000000000000000009 -fI[1] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff b333 3333 3333 3333 -printf("%.21Lg") gives -1.39999999999999999998 -g_xfmt(0) gives 4 bytes: "-1.4" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -= -1.40000000000000000009 -fI[1] = #bfff b333 3333 3333 3333 -= -1.39999999999999999998 -fI[1] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -printf("%.21Lg") gives 1.5 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -printf("%.21Lg") gives -1.5 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff cccc cccc cccc cccd -printf("%.21Lg") gives 1.60000000000000000002 -g_xfmt(0) gives 3 bytes: "1.6" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -= 1.59999999999999999991 -fI[1] = #3fff cccc cccc cccc cccd -= 1.60000000000000000002 -fI[1] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff cccc cccc cccc cccc -printf("%.21Lg") gives -1.59999999999999999991 -g_xfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -= -1.60000000000000000002 -fI[1] = #bfff cccc cccc cccc cccc -= -1.59999999999999999991 -fI[1] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff d999 9999 9999 999a -printf("%.21Lg") gives 1.70000000000000000004 -g_xfmt(0) gives 3 bytes: "1.7" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -= 1.69999999999999999993 -fI[1] = #3fff d999 9999 9999 999a -= 1.70000000000000000004 -fI[1] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff d999 9999 9999 9999 -printf("%.21Lg") gives -1.69999999999999999993 -g_xfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -= -1.70000000000000000004 -fI[1] = #bfff d999 9999 9999 9999 -= -1.69999999999999999993 -fI[1] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff e666 6666 6666 6667 -printf("%.21Lg") gives 1.80000000000000000007 -g_xfmt(0) gives 21 bytes: "1.8000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -= 1.79999999999999999996 -fI[1] = #3fff e666 6666 6666 6667 -= 1.80000000000000000007 -fI[1] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff e666 6666 6666 6666 -printf("%.21Lg") gives -1.79999999999999999996 -g_xfmt(0) gives 4 bytes: "-1.8" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -= -1.80000000000000000007 -fI[1] = #bfff e666 6666 6666 6666 -= -1.79999999999999999996 -fI[1] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 33 -with bits = #3fff f333 3333 3333 3334 -printf("%.21Lg") gives 1.90000000000000000009 -g_xfmt(0) gives 21 bytes: "1.9000000000000000001" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -= 1.89999999999999999998 -fI[1] = #3fff f333 3333 3333 3334 -= 1.90000000000000000009 -fI[1] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 25 -with bits = #bfff f333 3333 3333 3333 -printf("%.21Lg") gives -1.89999999999999999998 -g_xfmt(0) gives 4 bytes: "-1.9" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -= -1.90000000000000000009 -fI[1] = #bfff f333 3333 3333 3333 -= -1.89999999999999999998 -fI[1] == strtox - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 8ccc cccc cccc cccc -printf("%.21Lg") gives 1.09999999999999999991 -g_xfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 8ccc cccc cccc cccc -= 1.09999999999999999991 -fI[1] = #3fff 8ccc cccc cccc cccd -= 1.10000000000000000002 -fI[0] == strtox - - -Input: -1.1 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 8ccc cccc cccc cccd -printf("%.21Lg") gives -1.10000000000000000002 -g_xfmt(0) gives 4 bytes: "-1.1" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 8ccc cccc cccc cccd -= -1.10000000000000000002 -fI[1] = #bfff 8ccc cccc cccc cccc -= -1.09999999999999999991 -fI[0] == strtox - - -Input: 1.2 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff 9999 9999 9999 9999 -printf("%.21Lg") gives 1.19999999999999999993 -g_xfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff 9999 9999 9999 9999 -= 1.19999999999999999993 -fI[1] = #3fff 9999 9999 9999 999a -= 1.20000000000000000004 -fI[0] == strtox - - -Input: -1.2 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff 9999 9999 9999 999a -printf("%.21Lg") gives -1.20000000000000000004 -g_xfmt(0) gives 4 bytes: "-1.2" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff 9999 9999 9999 999a -= -1.20000000000000000004 -fI[1] = #bfff 9999 9999 9999 9999 -= -1.19999999999999999993 -fI[0] == strtox - - -Input: 1.3 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff a666 6666 6666 6666 -printf("%.21Lg") gives 1.29999999999999999996 -g_xfmt(0) gives 3 bytes: "1.3" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff a666 6666 6666 6666 -= 1.29999999999999999996 -fI[1] = #3fff a666 6666 6666 6667 -= 1.30000000000000000007 -fI[0] == strtox - - -Input: -1.3 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff a666 6666 6666 6667 -printf("%.21Lg") gives -1.30000000000000000007 -g_xfmt(0) gives 22 bytes: "-1.3000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff a666 6666 6666 6667 -= -1.30000000000000000007 -fI[1] = #bfff a666 6666 6666 6666 -= -1.29999999999999999996 -fI[0] == strtox - - -Input: 1.4 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff b333 3333 3333 3333 -printf("%.21Lg") gives 1.39999999999999999998 -g_xfmt(0) gives 3 bytes: "1.4" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff b333 3333 3333 3333 -= 1.39999999999999999998 -fI[1] = #3fff b333 3333 3333 3334 -= 1.40000000000000000009 -fI[0] == strtox - - -Input: -1.4 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff b333 3333 3333 3334 -printf("%.21Lg") gives -1.40000000000000000009 -g_xfmt(0) gives 22 bytes: "-1.4000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff b333 3333 3333 3334 -= -1.40000000000000000009 -fI[1] = #bfff b333 3333 3333 3333 -= -1.39999999999999999998 -fI[0] == strtox - - -Input: 1.5 - -strtox consumes 3 bytes and returns 1 -with bits = #3fff c000 0 0 0 -printf("%.21Lg") gives 1.5 -g_xfmt(0) gives 3 bytes: "1.5" - -strtoIx returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtox - - -Input: -1.5 - -strtox consumes 4 bytes and returns 9 -with bits = #bfff c000 0 0 0 -printf("%.21Lg") gives -1.5 -g_xfmt(0) gives 4 bytes: "-1.5" - -strtoIx returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtox - - -Input: 1.6 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff cccc cccc cccc cccc -printf("%.21Lg") gives 1.59999999999999999991 -g_xfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff cccc cccc cccc cccc -= 1.59999999999999999991 -fI[1] = #3fff cccc cccc cccc cccd -= 1.60000000000000000002 -fI[0] == strtox - - -Input: -1.6 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff cccc cccc cccc cccd -printf("%.21Lg") gives -1.60000000000000000002 -g_xfmt(0) gives 4 bytes: "-1.6" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff cccc cccc cccc cccd -= -1.60000000000000000002 -fI[1] = #bfff cccc cccc cccc cccc -= -1.59999999999999999991 -fI[0] == strtox - - -Input: 1.7 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff d999 9999 9999 9999 -printf("%.21Lg") gives 1.69999999999999999993 -g_xfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIx returns 33, consuming 3 bytes. -fI[0] = #3fff d999 9999 9999 9999 -= 1.69999999999999999993 -fI[1] = #3fff d999 9999 9999 999a -= 1.70000000000000000004 -fI[0] == strtox - - -Input: -1.7 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff d999 9999 9999 999a -printf("%.21Lg") gives -1.70000000000000000004 -g_xfmt(0) gives 4 bytes: "-1.7" - -strtoIx returns 41, consuming 4 bytes. -fI[0] = #bfff d999 9999 9999 999a -= -1.70000000000000000004 -fI[1] = #bfff d999 9999 9999 9999 -= -1.69999999999999999993 -fI[0] == strtox - - -Input: 1.8 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff e666 6666 6666 6666 -printf("%.21Lg") gives 1.79999999999999999996 -g_xfmt(0) gives 3 bytes: "1.8" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff e666 6666 6666 6666 -= 1.79999999999999999996 -fI[1] = #3fff e666 6666 6666 6667 -= 1.80000000000000000007 -fI[0] == strtox - - -Input: -1.8 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff e666 6666 6666 6667 -printf("%.21Lg") gives -1.80000000000000000007 -g_xfmt(0) gives 22 bytes: "-1.8000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff e666 6666 6666 6667 -= -1.80000000000000000007 -fI[1] = #bfff e666 6666 6666 6666 -= -1.79999999999999999996 -fI[0] == strtox - - -Input: 1.9 - -strtox consumes 3 bytes and returns 17 -with bits = #3fff f333 3333 3333 3333 -printf("%.21Lg") gives 1.89999999999999999998 -g_xfmt(0) gives 3 bytes: "1.9" - -strtoIx returns 17, consuming 3 bytes. -fI[0] = #3fff f333 3333 3333 3333 -= 1.89999999999999999998 -fI[1] = #3fff f333 3333 3333 3334 -= 1.90000000000000000009 -fI[0] == strtox - - -Input: -1.9 - -strtox consumes 4 bytes and returns 41 -with bits = #bfff f333 3333 3333 3334 -printf("%.21Lg") gives -1.90000000000000000009 -g_xfmt(0) gives 22 bytes: "-1.9000000000000000001" - -strtoIx returns 25, consuming 4 bytes. -fI[0] = #bfff f333 3333 3333 3334 -= -1.90000000000000000009 -fI[1] = #bfff f333 3333 3333 3333 -= -1.89999999999999999998 -fI[0] == strtox - diff --git a/lib/libc/gdtoa/test/xL.ou0 b/lib/libc/gdtoa/test/xL.ou0 deleted file mode 100644 index dc75f9113..000000000 --- a/lib/libc/gdtoa/test/xL.ou0 +++ /dev/null @@ -1,1182 +0,0 @@ - -Input: 1.23 - -strtoxL consumes 4 bytes and returns 33 -with bits = #3fff0000 9d70a3d7 a3d70a4 -g_xLfmt(0) gives 4 bytes: "1.23" - -strtoIxL returns 33, consuming 4 bytes. -fI[0] = #3fff0000 9d70a3d7 a3d70a3 -fI[1] = #3fff0000 9d70a3d7 a3d70a4 -fI[1] == strtoxL - - -Input: 1.23e+20 - -strtoxL consumes 8 bytes and returns 1 -with bits = #40410000 d55ef90a 2da18000 -g_xLfmt(0) gives 8 bytes: "1.23e+20" - -strtoIxL returns 1, consuming 8 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.23e-20 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3fbc0000 e857267b b3a984f2 -g_xLfmt(0) gives 8 bytes: "1.23e-20" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3fbc0000 e857267b b3a984f2 -fI[1] = #3fbc0000 e857267b b3a984f3 -fI[0] == strtoxL - - -Input: 1.23456789 - -strtoxL consumes 10 bytes and returns 33 -with bits = #3fff0000 9e065214 1ef0dbf6 -g_xLfmt(0) gives 10 bytes: "1.23456789" - -strtoIxL returns 33, consuming 10 bytes. -fI[0] = #3fff0000 9e065214 1ef0dbf5 -fI[1] = #3fff0000 9e065214 1ef0dbf6 -fI[1] == strtoxL - - -Input: 1.23456589e+20 - -strtoxL consumes 14 bytes and returns 1 -with bits = #40410000 d629bd33 5ccba00 -g_xLfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIxL returns 1, consuming 14 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.23e+30 - -strtoxL consumes 8 bytes and returns 17 -with bits = #40620000 f8658274 7dbc824a -g_xLfmt(0) gives 8 bytes: "1.23e+30" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #40620000 f8658274 7dbc824a -fI[1] = #40620000 f8658274 7dbc824b -fI[0] == strtoxL - - -Input: 1.23e-30 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3f9b0000 c794337a 808554eb -g_xLfmt(0) gives 8 bytes: "1.23e-30" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3f9b0000 c794337a 808554eb -fI[1] = #3f9b0000 c794337a 808554ec -fI[0] == strtoxL - - -Input: 1.23456789e-20 - -strtoxL consumes 14 bytes and returns 17 -with bits = #3fbc0000 e9340a38 f3d6d352 -g_xLfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #3fbc0000 e9340a38 f3d6d352 -fI[1] = #3fbc0000 e9340a38 f3d6d353 -fI[0] == strtoxL - - -Input: 1.23456789e-30 - -strtoxL consumes 14 bytes and returns 17 -with bits = #3f9b0000 c851f19d decca8fc -g_xLfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #3f9b0000 c851f19d decca8fc -fI[1] = #3f9b0000 c851f19d decca8fd -fI[0] == strtoxL - - -Input: 1.234567890123456789 - -strtoxL consumes 20 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 20 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -fI[1] = #3fff0000 9e065214 62cfdb8e -fI[0] == strtoxL - - -Input: 1.23456789012345678901234567890123456789 - -strtoxL consumes 40 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 40 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -fI[1] = #3fff0000 9e065214 62cfdb8e -fI[0] == strtoxL - - -Input: 1.23e306 - -strtoxL consumes 8 bytes and returns 17 -with bits = #43f70000 e033b668 e30fa6d5 -g_xLfmt(0) gives 9 bytes: "1.23e+306" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #43f70000 e033b668 e30fa6d5 -fI[1] = #43f70000 e033b668 e30fa6d6 -fI[0] == strtoxL - - -Input: 1.23e-306 - -strtoxL consumes 9 bytes and returns 33 -with bits = #3c060000 dd1dc2ed 1cb73f25 -g_xLfmt(0) gives 9 bytes: "1.23e-306" - -strtoIxL returns 33, consuming 9 bytes. -fI[0] = #3c060000 dd1dc2ed 1cb73f24 -fI[1] = #3c060000 dd1dc2ed 1cb73f25 -fI[1] == strtoxL - - -Input: 1.23e-320 - -strtoxL consumes 9 bytes and returns 33 -with bits = #3bd80000 9b98c371 844c3f1a -g_xLfmt(0) gives 9 bytes: "1.23e-320" - -strtoIxL returns 33, consuming 9 bytes. -fI[0] = #3bd80000 9b98c371 844c3f19 -fI[1] = #3bd80000 9b98c371 844c3f1a -fI[1] == strtoxL - - -Input: 1.23e-20 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3fbc0000 e857267b b3a984f2 -g_xLfmt(0) gives 8 bytes: "1.23e-20" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3fbc0000 e857267b b3a984f2 -fI[1] = #3fbc0000 e857267b b3a984f3 -fI[0] == strtoxL - - -Input: 1.23456789e307 - -strtoxL consumes 14 bytes and returns 17 -with bits = #43fb0000 8ca58a5e d766de75 -g_xLfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #43fb0000 8ca58a5e d766de75 -fI[1] = #43fb0000 8ca58a5e d766de76 -fI[0] == strtoxL - - -Input: 1.23456589e-307 - -strtoxL consumes 15 bytes and returns 17 -with bits = #3c030000 b18cb5dc c22fd369 -g_xLfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIxL returns 17, consuming 15 bytes. -fI[0] = #3c030000 b18cb5dc c22fd369 -fI[1] = #3c030000 b18cb5dc c22fd36a -fI[0] == strtoxL - - -Input: 1.234567890123456789 - -strtoxL consumes 20 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 20 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -fI[1] = #3fff0000 9e065214 62cfdb8e -fI[0] == strtoxL - - -Input: 1.234567890123456789e301 - -strtoxL consumes 24 bytes and returns 33 -with bits = #43e70000 937a8baf ab20980c -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIxL returns 33, consuming 24 bytes. -fI[0] = #43e70000 937a8baf ab20980b -fI[1] = #43e70000 937a8baf ab20980c -fI[1] == strtoxL - - -Input: 1.234567890123456789e-301 - -strtoxL consumes 25 bytes and returns 33 -with bits = #3c170000 a953271a 5d069ad9 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIxL returns 33, consuming 25 bytes. -fI[0] = #3c170000 a953271a 5d069ad8 -fI[1] = #3c170000 a953271a 5d069ad9 -fI[1] == strtoxL - - -Input: 1.234567890123456789e-321 - -strtoxL consumes 25 bytes and returns 33 -with bits = #3bd40000 f9e11b4c ea6dcce9 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-321" - -strtoIxL returns 33, consuming 25 bytes. -fI[0] = #3bd40000 f9e11b4c ea6dcce8 -fI[1] = #3bd40000 f9e11b4c ea6dcce9 -fI[1] == strtoxL - - -Input: 1e23 - -strtoxL consumes 4 bytes and returns 1 -with bits = #404b0000 a968163f a57b400 -g_xLfmt(0) gives 5 bytes: "1e+23" - -strtoIxL returns 1, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1e310 - -strtoxL consumes 5 bytes and returns 33 -with bits = #44040000 de81e40a 34bcf50 -g_xLfmt(0) gives 6 bytes: "1e+310" - -strtoIxL returns 33, consuming 5 bytes. -fI[0] = #44040000 de81e40a 34bcf4f -fI[1] = #44040000 de81e40a 34bcf50 -fI[1] == strtoxL - - -Input: 9.0259718793241475e-277 - -strtoxL consumes 23 bytes and returns 33 -with bits = #3c690000 ffffffff fffffcf7 -g_xLfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIxL returns 33, consuming 23 bytes. -fI[0] = #3c690000 ffffffff fffffcf6 -fI[1] = #3c690000 ffffffff fffffcf7 -fI[1] == strtoxL - - -Input: 9.025971879324147880346310405869e-277 - -strtoxL consumes 37 bytes and returns 17 -with bits = #3c6a0000 80000000 0 -g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIxL returns 17, consuming 37 bytes. -fI[0] = #3c6a0000 80000000 0 -fI[1] = #3c6a0000 80000000 1 -fI[0] == strtoxL - - -Input: 9.025971879324147880346310405868e-277 - -strtoxL consumes 37 bytes and returns 33 -with bits = #3c6a0000 80000000 0 -g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIxL returns 33, consuming 37 bytes. -fI[0] = #3c690000 ffffffff ffffffff -fI[1] = #3c6a0000 80000000 0 -fI[1] == strtoxL - - -Input: 2.2250738585072014e-308 - -strtoxL consumes 23 bytes and returns 17 -with bits = #3c010000 80000000 46 -g_xLfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIxL returns 17, consuming 23 bytes. -fI[0] = #3c010000 80000000 46 -fI[1] = #3c010000 80000000 47 -fI[0] == strtoxL - - -Input: 2.2250738585072013e-308 - -strtoxL consumes 23 bytes and returns 17 -with bits = #3c000000 ffffffff fffffd4f -g_xLfmt(0) gives 23 bytes: "2.2250738585072013e-308" - -strtoIxL returns 17, consuming 23 bytes. -fI[0] = #3c000000 ffffffff fffffd4f -fI[1] = #3c000000 ffffffff fffffd50 -fI[0] == strtoxL - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 8ccccccc cccccccc -g_xLfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -fI[1] = #3fff0000 8ccccccc cccccccd -fI[0] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 8ccccccc cccccccc -g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -fI[1] = #bfff0000 8ccccccc cccccccc -fI[1] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 99999999 99999999 -g_xLfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -fI[1] = #3fff0000 99999999 9999999a -fI[0] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 99999999 99999999 -g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -fI[1] = #bfff0000 99999999 99999999 -fI[1] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -fI[1] = #3fff0000 a6666666 66666667 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -fI[1] = #bfff0000 a6666666 66666666 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -fI[1] = #3fff0000 b3333333 33333334 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -fI[1] = #bfff0000 b3333333 33333333 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 cccccccc cccccccc -g_xLfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -fI[1] = #3fff0000 cccccccc cccccccd -fI[0] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 cccccccc cccccccc -g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -fI[1] = #bfff0000 cccccccc cccccccc -fI[1] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 d9999999 99999999 -g_xLfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -fI[1] = #3fff0000 d9999999 9999999a -fI[0] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 d9999999 99999999 -g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -fI[1] = #bfff0000 d9999999 99999999 -fI[1] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -fI[1] = #3fff0000 e6666666 66666667 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -fI[1] = #bfff0000 e6666666 66666666 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -fI[1] = #3fff0000 f3333333 33333334 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -fI[1] = #bfff0000 f3333333 33333333 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 8ccccccc cccccccd -g_xLfmt(0) gives 3 bytes: "1.1" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -fI[1] = #3fff0000 8ccccccc cccccccd -fI[1] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 8ccccccc cccccccd -g_xLfmt(0) gives 4 bytes: "-1.1" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -fI[1] = #bfff0000 8ccccccc cccccccc -fI[0] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 99999999 9999999a -g_xLfmt(0) gives 3 bytes: "1.2" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -fI[1] = #3fff0000 99999999 9999999a -fI[1] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 99999999 9999999a -g_xLfmt(0) gives 4 bytes: "-1.2" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -fI[1] = #bfff0000 99999999 99999999 -fI[0] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -fI[1] = #3fff0000 a6666666 66666667 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -fI[1] = #bfff0000 a6666666 66666666 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -fI[1] = #3fff0000 b3333333 33333334 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -fI[1] = #bfff0000 b3333333 33333333 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 cccccccc cccccccd -g_xLfmt(0) gives 3 bytes: "1.6" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -fI[1] = #3fff0000 cccccccc cccccccd -fI[1] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 cccccccc cccccccd -g_xLfmt(0) gives 4 bytes: "-1.6" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -fI[1] = #bfff0000 cccccccc cccccccc -fI[0] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 d9999999 9999999a -g_xLfmt(0) gives 3 bytes: "1.7" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -fI[1] = #3fff0000 d9999999 9999999a -fI[1] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 d9999999 9999999a -g_xLfmt(0) gives 4 bytes: "-1.7" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -fI[1] = #bfff0000 d9999999 99999999 -fI[0] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -fI[1] = #3fff0000 e6666666 66666667 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -fI[1] = #bfff0000 e6666666 66666666 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -fI[1] = #3fff0000 f3333333 33333334 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -fI[1] = #bfff0000 f3333333 33333333 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 8ccccccc cccccccd -g_xLfmt(0) gives 3 bytes: "1.1" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -fI[1] = #3fff0000 8ccccccc cccccccd -fI[1] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 8ccccccc cccccccc -g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -fI[1] = #bfff0000 8ccccccc cccccccc -fI[1] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 99999999 9999999a -g_xLfmt(0) gives 3 bytes: "1.2" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -fI[1] = #3fff0000 99999999 9999999a -fI[1] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 99999999 99999999 -g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -fI[1] = #bfff0000 99999999 99999999 -fI[1] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 a6666666 66666667 -g_xLfmt(0) gives 21 bytes: "1.3000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -fI[1] = #3fff0000 a6666666 66666667 -fI[1] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -fI[1] = #bfff0000 a6666666 66666666 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 b3333333 33333334 -g_xLfmt(0) gives 21 bytes: "1.4000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -fI[1] = #3fff0000 b3333333 33333334 -fI[1] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -fI[1] = #bfff0000 b3333333 33333333 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 cccccccc cccccccd -g_xLfmt(0) gives 3 bytes: "1.6" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -fI[1] = #3fff0000 cccccccc cccccccd -fI[1] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 cccccccc cccccccc -g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -fI[1] = #bfff0000 cccccccc cccccccc -fI[1] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 d9999999 9999999a -g_xLfmt(0) gives 3 bytes: "1.7" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -fI[1] = #3fff0000 d9999999 9999999a -fI[1] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 d9999999 99999999 -g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -fI[1] = #bfff0000 d9999999 99999999 -fI[1] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 e6666666 66666667 -g_xLfmt(0) gives 21 bytes: "1.8000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -fI[1] = #3fff0000 e6666666 66666667 -fI[1] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -fI[1] = #bfff0000 e6666666 66666666 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 f3333333 33333334 -g_xLfmt(0) gives 21 bytes: "1.9000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -fI[1] = #3fff0000 f3333333 33333334 -fI[1] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -fI[1] = #bfff0000 f3333333 33333333 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 8ccccccc cccccccc -g_xLfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -fI[1] = #3fff0000 8ccccccc cccccccd -fI[0] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 8ccccccc cccccccd -g_xLfmt(0) gives 4 bytes: "-1.1" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -fI[1] = #bfff0000 8ccccccc cccccccc -fI[0] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 99999999 99999999 -g_xLfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -fI[1] = #3fff0000 99999999 9999999a -fI[0] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 99999999 9999999a -g_xLfmt(0) gives 4 bytes: "-1.2" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -fI[1] = #bfff0000 99999999 99999999 -fI[0] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -fI[1] = #3fff0000 a6666666 66666667 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 a6666666 66666667 -g_xLfmt(0) gives 22 bytes: "-1.3000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -fI[1] = #bfff0000 a6666666 66666666 -fI[0] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -fI[1] = #3fff0000 b3333333 33333334 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 b3333333 33333334 -g_xLfmt(0) gives 22 bytes: "-1.4000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -fI[1] = #bfff0000 b3333333 33333333 -fI[0] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 cccccccc cccccccc -g_xLfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -fI[1] = #3fff0000 cccccccc cccccccd -fI[0] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 cccccccc cccccccd -g_xLfmt(0) gives 4 bytes: "-1.6" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -fI[1] = #bfff0000 cccccccc cccccccc -fI[0] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 d9999999 99999999 -g_xLfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -fI[1] = #3fff0000 d9999999 9999999a -fI[0] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 d9999999 9999999a -g_xLfmt(0) gives 4 bytes: "-1.7" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -fI[1] = #bfff0000 d9999999 99999999 -fI[0] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -fI[1] = #3fff0000 e6666666 66666667 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 e6666666 66666667 -g_xLfmt(0) gives 22 bytes: "-1.8000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -fI[1] = #bfff0000 e6666666 66666666 -fI[0] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -fI[1] = #3fff0000 f3333333 33333334 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 f3333333 33333334 -g_xLfmt(0) gives 22 bytes: "-1.9000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -fI[1] = #bfff0000 f3333333 33333333 -fI[0] == strtoxL - diff --git a/lib/libc/gdtoa/test/xL.ou1 b/lib/libc/gdtoa/test/xL.ou1 deleted file mode 100644 index c22d0f418..000000000 --- a/lib/libc/gdtoa/test/xL.ou1 +++ /dev/null @@ -1,1462 +0,0 @@ -***** This file is not right. It needs to be generated on a -***** system with a Motorla 68881 or the equivalent. - -Input: 1.23 - -strtoxL consumes 4 bytes and returns 33 -with bits = #3fff0000 9d70a3d7 a3d70a4 -printf("%.21Lg") gives 7.73283722915781506499e-4933 -g_xLfmt(0) gives 4 bytes: "1.23" - -strtoIxL returns 33, consuming 4 bytes. -fI[0] = #3fff0000 9d70a3d7 a3d70a3 -= 7.73283722915781506134e-4933 -fI[1] = #3fff0000 9d70a3d7 a3d70a4 -= 7.73283722915781506499e-4933 -fI[1] == strtoxL - - -Input: 1.23e+20 - -strtoxL consumes 8 bytes and returns 1 -with bits = #40410000 d55ef90a 2da18000 -printf("%.21Lg") gives 2.24239113715721119512e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e+20" - -strtoIxL returns 1, consuming 8 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.23e-20 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3fbc0000 e857267b b3a984f2 -printf("%.21Lg") gives 2.74065070995958800375e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e-20" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3fbc0000 e857267b b3a984f2 -= 2.74065070995958800375e-4932 -fI[1] = #3fbc0000 e857267b b3a984f3 -= 2.74065070995958800411e-4932 -fI[0] == strtoxL - - -Input: 1.23456789 - -strtoxL consumes 10 bytes and returns 33 -with bits = #3fff0000 9e065214 1ef0dbf6 -printf("%.21Lg") gives 7.88641440242171807354e-4933 -g_xLfmt(0) gives 10 bytes: "1.23456789" - -strtoIxL returns 33, consuming 10 bytes. -fI[0] = #3fff0000 9e065214 1ef0dbf5 -= 7.8864144024217180699e-4933 -fI[1] = #3fff0000 9e065214 1ef0dbf6 -= 7.88641440242171807354e-4933 -fI[1] == strtoxL - - -Input: 1.23456589e+20 - -strtoxL consumes 14 bytes and returns 1 -with bits = #40410000 d629bd33 5ccba00 -printf("%.21Lg") gives 2.26319561227049478508e-4932 -g_xLfmt(0) gives 14 bytes: "1.23456589e+20" - -strtoIxL returns 1, consuming 14 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.23e+30 - -strtoxL consumes 8 bytes and returns 17 -with bits = #40620000 f8658274 7dbc824a -printf("%.21Lg") gives 3.16238691003557160385e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e+30" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #40620000 f8658274 7dbc824a -= 3.16238691003557160385e-4932 -fI[1] = #40620000 f8658274 7dbc824b -= 3.16238691003557160421e-4932 -fI[0] == strtoxL - - -Input: 1.23e-30 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3f9b0000 c794337a 808554eb -printf("%.21Lg") gives 1.88012249978407873966e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e-30" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3f9b0000 c794337a 808554eb -= 1.88012249978407873966e-4932 -fI[1] = #3f9b0000 c794337a 808554ec -= 1.88012249978407874003e-4932 -fI[0] == strtoxL - - -Input: 1.23456789e-20 - -strtoxL consumes 14 bytes and returns 17 -with bits = #3fbc0000 e9340a38 f3d6d352 -printf("%.21Lg") gives 2.76331470044569174626e-4932 -g_xLfmt(0) gives 14 bytes: "1.23456789e-20" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #3fbc0000 e9340a38 f3d6d352 -= 2.76331470044569174626e-4932 -fI[1] = #3fbc0000 e9340a38 f3d6d353 -= 2.76331470044569174663e-4932 -fI[0] == strtoxL - - -Input: 1.23456789e-30 - -strtoxL consumes 14 bytes and returns 17 -with bits = #3f9b0000 c851f19d decca8fc -printf("%.21Lg") gives 1.89959071937101288293e-4932 -g_xLfmt(0) gives 14 bytes: "1.23456789e-30" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #3f9b0000 c851f19d decca8fc -= 1.89959071937101288293e-4932 -fI[1] = #3f9b0000 c851f19d decca8fd -= 1.89959071937101288329e-4932 -fI[0] == strtoxL - - -Input: 1.234567890123456789 - -strtoxL consumes 20 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -printf("%.21Lg") gives 7.88641440657246265535e-4933 -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 20 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -= 7.88641440657246265535e-4933 -fI[1] = #3fff0000 9e065214 62cfdb8e -= 7.886414406572462659e-4933 -fI[0] == strtoxL - - -Input: 1.23456789012345678901234567890123456789 - -strtoxL consumes 40 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -printf("%.21Lg") gives 7.88641440657246265535e-4933 -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 40 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -= 7.88641440657246265535e-4933 -fI[1] = #3fff0000 9e065214 62cfdb8e -= 7.886414406572462659e-4933 -fI[0] == strtoxL - - -Input: 1.23e306 - -strtoxL consumes 8 bytes and returns 17 -with bits = #43f70000 e033b668 e30fa6d5 -printf("%.21Lg") gives 2.52688323155200052759e-4932 -g_xLfmt(0) gives 9 bytes: "1.23e+306" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #43f70000 e033b668 e30fa6d5 -= 2.52688323155200052759e-4932 -fI[1] = #43f70000 e033b668 e30fa6d6 -= 2.52688323155200052796e-4932 -fI[0] == strtoxL - - -Input: 1.23e-306 - -strtoxL consumes 9 bytes and returns 33 -with bits = #3c060000 dd1dc2ed 1cb73f25 -printf("%.21Lg") gives 2.44583168427704605801e-4932 -g_xLfmt(0) gives 9 bytes: "1.23e-306" - -strtoIxL returns 33, consuming 9 bytes. -fI[0] = #3c060000 dd1dc2ed 1cb73f24 -= 2.44583168427704605765e-4932 -fI[1] = #3c060000 dd1dc2ed 1cb73f25 -= 2.44583168427704605801e-4932 -fI[1] == strtoxL - - -Input: 1.23e-320 - -strtoxL consumes 9 bytes and returns 33 -with bits = #3bd80000 9b98c371 844c3f1a -printf("%.21Lg") gives 7.24867657578821329238e-4933 -g_xLfmt(0) gives 9 bytes: "1.23e-320" - -strtoIxL returns 33, consuming 9 bytes. -fI[0] = #3bd80000 9b98c371 844c3f19 -= 7.24867657578821328874e-4933 -fI[1] = #3bd80000 9b98c371 844c3f1a -= 7.24867657578821329238e-4933 -fI[1] == strtoxL - - -Input: 1.23e-20 - -strtoxL consumes 8 bytes and returns 17 -with bits = #3fbc0000 e857267b b3a984f2 -printf("%.21Lg") gives 2.74065070995958800375e-4932 -g_xLfmt(0) gives 8 bytes: "1.23e-20" - -strtoIxL returns 17, consuming 8 bytes. -fI[0] = #3fbc0000 e857267b b3a984f2 -= 2.74065070995958800375e-4932 -fI[1] = #3fbc0000 e857267b b3a984f3 -= 2.74065070995958800411e-4932 -fI[0] == strtoxL - - -Input: 1.23456789e307 - -strtoxL consumes 14 bytes and returns 17 -with bits = #43fb0000 8ca58a5e d766de75 -printf("%.21Lg") gives 3.32182163192682931854e-4933 -g_xLfmt(0) gives 15 bytes: "1.23456789e+307" - -strtoIxL returns 17, consuming 14 bytes. -fI[0] = #43fb0000 8ca58a5e d766de75 -= 3.32182163192682931854e-4933 -fI[1] = #43fb0000 8ca58a5e d766de76 -= 3.32182163192682932219e-4933 -fI[0] == strtoxL - - -Input: 1.23456589e-307 - -strtoxL consumes 15 bytes and returns 17 -with bits = #3c030000 b18cb5dc c22fd369 -printf("%.21Lg") gives 1.30149245314004923345e-4932 -g_xLfmt(0) gives 15 bytes: "1.23456589e-307" - -strtoIxL returns 17, consuming 15 bytes. -fI[0] = #3c030000 b18cb5dc c22fd369 -= 1.30149245314004923345e-4932 -fI[1] = #3c030000 b18cb5dc c22fd36a -= 1.30149245314004923382e-4932 -fI[0] == strtoxL - - -Input: 1.234567890123456789 - -strtoxL consumes 20 bytes and returns 17 -with bits = #3fff0000 9e065214 62cfdb8d -printf("%.21Lg") gives 7.88641440657246265535e-4933 -g_xLfmt(0) gives 20 bytes: "1.234567890123456789" - -strtoIxL returns 17, consuming 20 bytes. -fI[0] = #3fff0000 9e065214 62cfdb8d -= 7.88641440657246265535e-4933 -fI[1] = #3fff0000 9e065214 62cfdb8e -= 7.886414406572462659e-4933 -fI[0] == strtoxL - - -Input: 1.234567890123456789e301 - -strtoxL consumes 24 bytes and returns 33 -with bits = #43e70000 937a8baf ab20980c -printf("%.21Lg") gives 5.11635766619117643114e-4933 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e+301" - -strtoIxL returns 33, consuming 24 bytes. -fI[0] = #43e70000 937a8baf ab20980b -= 5.1163576661911764275e-4933 -fI[1] = #43e70000 937a8baf ab20980c -= 5.11635766619117643114e-4933 -fI[1] == strtoxL - - -Input: 1.234567890123456789e-301 - -strtoxL consumes 25 bytes and returns 33 -with bits = #3c170000 a953271a 5d069ad9 -printf("%.21Lg") gives 1.08545540462853463561e-4932 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-301" - -strtoIxL returns 33, consuming 25 bytes. -fI[0] = #3c170000 a953271a 5d069ad8 -= 1.08545540462853463524e-4932 -fI[1] = #3c170000 a953271a 5d069ad9 -= 1.08545540462853463561e-4932 -fI[1] == strtoxL - - -Input: 1.234567890123456789e-321 - -strtoxL consumes 25 bytes and returns 33 -with bits = #3bd40000 f9e11b4c ea6dcce9 -printf("%.21Lg") gives 3.20133479952876185942e-4932 -g_xLfmt(0) gives 25 bytes: "1.234567890123456789e-321" - -strtoIxL returns 33, consuming 25 bytes. -fI[0] = #3bd40000 f9e11b4c ea6dcce8 -= 3.20133479952876185905e-4932 -fI[1] = #3bd40000 f9e11b4c ea6dcce9 -= 3.20133479952876185942e-4932 -fI[1] == strtoxL - - -Input: 1e23 - -strtoxL consumes 4 bytes and returns 1 -with bits = #404b0000 a968163f a57b400 -printf("%.21Lg") gives 1.08760331670538037378e-4932 -g_xLfmt(0) gives 5 bytes: "1e+23" - -strtoIxL returns 1, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1e310 - -strtoxL consumes 5 bytes and returns 33 -with bits = #44040000 de81e40a 34bcf50 -printf("%.21Lg") gives 2.48237171106260601618e-4932 -g_xLfmt(0) gives 6 bytes: "1e+310" - -strtoIxL returns 33, consuming 5 bytes. -fI[0] = #44040000 de81e40a 34bcf4f -= 2.48237171106260601582e-4932 -fI[1] = #44040000 de81e40a 34bcf50 -= 2.48237171106260601618e-4932 -fI[1] == strtoxL - - -Input: 9.0259718793241475e-277 - -strtoxL consumes 23 bytes and returns 33 -with bits = #3c690000 ffffffff fffffcf7 -printf("%.21Lg") gives 3.36210314311209322303e-4932 -g_xLfmt(0) gives 23 bytes: "9.0259718793241475e-277" - -strtoIxL returns 33, consuming 23 bytes. -fI[0] = #3c690000 ffffffff fffffcf6 -= 3.36210314311209322267e-4932 -fI[1] = #3c690000 ffffffff fffffcf7 -= 3.36210314311209322303e-4932 -fI[1] == strtoxL - - -Input: 9.025971879324147880346310405869e-277 - -strtoxL consumes 37 bytes and returns 17 -with bits = #3c6a0000 80000000 0 -printf("%.21Lg") gives 3.36210314311209350626e-4932 -g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIxL returns 17, consuming 37 bytes. -fI[0] = #3c6a0000 80000000 0 -= 3.36210314311209350626e-4932 -fI[1] = #3c6a0000 80000000 1 -= 3.64519953188247460253e-4951 -fI[0] == strtoxL - - -Input: 9.025971879324147880346310405868e-277 - -strtoxL consumes 37 bytes and returns 33 -with bits = #3c6a0000 80000000 0 -printf("%.21Lg") gives 3.36210314311209350626e-4932 -g_xLfmt(0) gives 26 bytes: "9.0259718793241478803e-277" - -strtoIxL returns 33, consuming 37 bytes. -fI[0] = #3c690000 ffffffff ffffffff -= 3.3621031431120935059e-4932 -fI[1] = #3c6a0000 80000000 0 -= 3.36210314311209350626e-4932 -fI[1] == strtoxL - - -Input: 2.2250738585072014e-308 - -strtoxL consumes 23 bytes and returns 17 -with bits = #3c010000 80000000 46 -printf("%.21Lg") gives 2.55163967231773222177e-4949 -g_xLfmt(0) gives 23 bytes: "2.2250738585072014e-308" - -strtoIxL returns 17, consuming 23 bytes. -fI[0] = #3c010000 80000000 46 -= 2.55163967231773222177e-4949 -fI[1] = #3c010000 80000000 47 -= 2.5880916676365569678e-4949 -fI[0] == strtoxL - - -Input: 2.2250738585072013e-308 - -strtoxL consumes 23 bytes and returns 17 -with bits = #3c000000 ffffffff fffffd4f -printf("%.21Lg") gives 3.36210314311209325511e-4932 -g_xLfmt(0) gives 23 bytes: "2.2250738585072013e-308" - -strtoIxL returns 17, consuming 23 bytes. -fI[0] = #3c000000 ffffffff fffffd4f -= 3.36210314311209325511e-4932 -fI[1] = #3c000000 ffffffff fffffd50 -= 3.36210314311209325547e-4932 -fI[0] == strtoxL - -Rounding mode for strtor... changed from 1 (nearest) to 0 (toward zero) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[0] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[0] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[0] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[0] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 0 (toward zero) to 1 (nearest) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 3 bytes: "1.1" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 4 bytes: "-1.1" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[0] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 3 bytes: "1.2" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 4 bytes: "-1.2" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[0] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 3 bytes: "1.6" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 4 bytes: "-1.6" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[0] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 3 bytes: "1.7" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 4 bytes: "-1.7" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[0] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 1 (nearest) to 2 (toward +Infinity) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 3 bytes: "1.1" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 22 bytes: "-1.0999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 3 bytes: "1.2" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 22 bytes: "-1.1999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 a6666666 66666667 -printf("%.21Lg") gives 1.0086309429336280521e-4932 -g_xLfmt(0) gives 21 bytes: "1.3000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 4 bytes: "-1.3" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 b3333333 33333334 -printf("%.21Lg") gives 1.3448412572448374028e-4932 -g_xLfmt(0) gives 21 bytes: "1.4000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 4 bytes: "-1.4" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 3 bytes: "1.6" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 22 bytes: "-1.5999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 3 bytes: "1.7" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 22 bytes: "-1.6999999999999999999" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 e6666666 66666667 -printf("%.21Lg") gives 2.68968251448967480523e-4932 -g_xLfmt(0) gives 21 bytes: "1.8000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 4 bytes: "-1.8" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 33 -with bits = #3fff0000 f3333333 33333334 -printf("%.21Lg") gives 3.02589282880088415593e-4932 -g_xLfmt(0) gives 21 bytes: "1.9000000000000000001" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 25 -with bits = #bfff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 4 bytes: "-1.9" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] == strtoxL - -Rounding mode for strtor... changed from 2 (toward +Infinity) to 3 (toward -Infinity) - -Input: 1.1 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 8ccccccc cccccccc -printf("%.21Lg") gives 3.36210314311209350335e-4933 -g_xLfmt(0) gives 21 bytes: "1.0999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[1] = #3fff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[0] == strtoxL - - -Input: -1.1 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 8ccccccc cccccccd -printf("%.21Lg") gives 3.36210314311209350699e-4933 -g_xLfmt(0) gives 4 bytes: "-1.1" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 8ccccccc cccccccd -= 3.36210314311209350699e-4933 -fI[1] = #bfff0000 8ccccccc cccccccc -= 3.36210314311209350335e-4933 -fI[0] == strtoxL - - -Input: 1.2 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 99999999 99999999 -printf("%.21Lg") gives 6.72420628622418701034e-4933 -g_xLfmt(0) gives 21 bytes: "1.1999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[1] = #3fff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[0] == strtoxL - - -Input: -1.2 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 99999999 9999999a -printf("%.21Lg") gives 6.72420628622418701398e-4933 -g_xLfmt(0) gives 4 bytes: "-1.2" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 99999999 9999999a -= 6.72420628622418701398e-4933 -fI[1] = #bfff0000 99999999 99999999 -= 6.72420628622418701034e-4933 -fI[0] == strtoxL - - -Input: 1.3 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 a6666666 66666666 -printf("%.21Lg") gives 1.00863094293362805173e-4932 -g_xLfmt(0) gives 3 bytes: "1.3" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[1] = #3fff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[0] == strtoxL - - -Input: -1.3 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 a6666666 66666667 -printf("%.21Lg") gives 1.0086309429336280521e-4932 -g_xLfmt(0) gives 22 bytes: "-1.3000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 a6666666 66666667 -= 1.0086309429336280521e-4932 -fI[1] = #bfff0000 a6666666 66666666 -= 1.00863094293362805173e-4932 -fI[0] == strtoxL - - -Input: 1.4 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 b3333333 33333333 -printf("%.21Lg") gives 1.34484125724483740243e-4932 -g_xLfmt(0) gives 3 bytes: "1.4" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[1] = #3fff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[0] == strtoxL - - -Input: -1.4 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 b3333333 33333334 -printf("%.21Lg") gives 1.3448412572448374028e-4932 -g_xLfmt(0) gives 22 bytes: "-1.4000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 b3333333 33333334 -= 1.3448412572448374028e-4932 -fI[1] = #bfff0000 b3333333 33333333 -= 1.34484125724483740243e-4932 -fI[0] == strtoxL - - -Input: 1.5 - -strtoxL consumes 3 bytes and returns 1 -with bits = #3fff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 3 bytes: "1.5" - -strtoIxL returns 1, consuming 3 bytes. -fI[0] == fI[1] == strtoxL - - -Input: -1.5 - -strtoxL consumes 4 bytes and returns 9 -with bits = #bfff0000 c0000000 0 -printf("%.21Lg") gives 1.68105157155604675313e-4932 -g_xLfmt(0) gives 4 bytes: "-1.5" - -strtoIxL returns 9, consuming 4 bytes. -fI[0] == fI[1] == strtoxL - - -Input: 1.6 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 cccccccc cccccccc -printf("%.21Lg") gives 2.01726188586725610347e-4932 -g_xLfmt(0) gives 21 bytes: "1.5999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[1] = #3fff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[0] == strtoxL - - -Input: -1.6 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 cccccccc cccccccd -printf("%.21Lg") gives 2.01726188586725610383e-4932 -g_xLfmt(0) gives 4 bytes: "-1.6" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 cccccccc cccccccd -= 2.01726188586725610383e-4932 -fI[1] = #bfff0000 cccccccc cccccccc -= 2.01726188586725610347e-4932 -fI[0] == strtoxL - - -Input: 1.7 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 d9999999 99999999 -printf("%.21Lg") gives 2.35347220017846545417e-4932 -g_xLfmt(0) gives 21 bytes: "1.6999999999999999999" - -strtoIxL returns 33, consuming 3 bytes. -fI[0] = #3fff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[1] = #3fff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[0] == strtoxL - - -Input: -1.7 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 d9999999 9999999a -printf("%.21Lg") gives 2.35347220017846545453e-4932 -g_xLfmt(0) gives 4 bytes: "-1.7" - -strtoIxL returns 41, consuming 4 bytes. -fI[0] = #bfff0000 d9999999 9999999a -= 2.35347220017846545453e-4932 -fI[1] = #bfff0000 d9999999 99999999 -= 2.35347220017846545417e-4932 -fI[0] == strtoxL - - -Input: 1.8 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 e6666666 66666666 -printf("%.21Lg") gives 2.68968251448967480486e-4932 -g_xLfmt(0) gives 3 bytes: "1.8" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[1] = #3fff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[0] == strtoxL - - -Input: -1.8 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 e6666666 66666667 -printf("%.21Lg") gives 2.68968251448967480523e-4932 -g_xLfmt(0) gives 22 bytes: "-1.8000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 e6666666 66666667 -= 2.68968251448967480523e-4932 -fI[1] = #bfff0000 e6666666 66666666 -= 2.68968251448967480486e-4932 -fI[0] == strtoxL - - -Input: 1.9 - -strtoxL consumes 3 bytes and returns 17 -with bits = #3fff0000 f3333333 33333333 -printf("%.21Lg") gives 3.02589282880088415556e-4932 -g_xLfmt(0) gives 3 bytes: "1.9" - -strtoIxL returns 17, consuming 3 bytes. -fI[0] = #3fff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[1] = #3fff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[0] == strtoxL - - -Input: -1.9 - -strtoxL consumes 4 bytes and returns 41 -with bits = #bfff0000 f3333333 33333334 -printf("%.21Lg") gives 3.02589282880088415593e-4932 -g_xLfmt(0) gives 22 bytes: "-1.9000000000000000001" - -strtoIxL returns 25, consuming 4 bytes. -fI[0] = #bfff0000 f3333333 33333334 -= 3.02589282880088415593e-4932 -fI[1] = #bfff0000 f3333333 33333333 -= 3.02589282880088415556e-4932 -fI[0] == strtoxL - diff --git a/lib/libc/gdtoa/test/xLtest.c b/lib/libc/gdtoa/test/xLtest.c deleted file mode 100644 index cf348e2ed..000000000 --- a/lib/libc/gdtoa/test/xLtest.c +++ /dev/null @@ -1,169 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test program for g_xLfmt, strtoIxL, strtopxL, and strtorxL. - * - * Inputs (on stdin): - * r rounding_mode - * n ndig - * number - * #hex0 hex1 hex2 - * - * rounding_mode values: - * 0 = toward zero - * 1 = nearest - * 2 = toward +Infinity - * 3 = toward -Infinity - * - * where number is a decimal floating-point number, - * hex0 is a string of <= 8 Hex digits for the most significant - * word of the number, hex1 is a similar string for the next - * word, etc., and ndig is a parameters to g_xLfmt. - */ - -#include "gdtoa.h" -#include -#include -#include - - extern int getround ANSI((int,char*)); - - static char ibuf[2048], obuf[2048]; - -#define U (unsigned long) - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 2 -#define _1 1 -#define _2 0 -#endif - - int -main(Void) -{ - char *s, *s1, *se, *se1; - int dItry, i, ndig = 0, r = 1; - union { long double d; ULong bits[3]; } u, v[2]; - - while((s = fgets(ibuf, sizeof(ibuf), stdin))) { - while(*s <= ' ') - if (!*s++) - continue; - dItry = 0; - switch(*s) { - case 'r': - r = getround(r, s); - continue; - case 'n': - i = s[1]; - if (i <= ' ' || (i >= '0' && i <= '9')) { - ndig = atoi(s+1); - continue; - } - break; /* nan? */ - case '#': - /* sscanf(s+1, "%lx %lx %lx", &u.bits[_0], */ - /* &u.bits[_1], &u.bits[_2]); */ - u.bits[_0] = (ULong)strtoul(s1 = s+1, &se, 16); - if (se > s1) { - u.bits[_1] = (ULong)strtoul(s1=se, &se, 16); - if (se > s1) - u.bits[_2] = (ULong)strtoul(s1=se, &se, 16); - } - printf("\nInput: %s", ibuf); - printf(" --> f = #%lx %lx %lx\n", U u.bits[_0], - U u.bits[_1], U u.bits[_2]); - goto fmt_test; - } - dItry = 1; - printf("\nInput: %s", ibuf); - i = strtorxL(ibuf, &se, r, u.bits); - if (r == 1 && (i != strtopxL(ibuf, &se1, v[0].bits) || se1 != se - || memcmp(u.bits, v[0].bits, 12))) - printf("***strtoxL and strtorxL disagree!!\n:"); - printf("\nstrtoxL consumes %d bytes and returns %d\n", - (int)(se-ibuf), i); - printf("with bits = #%lx %lx %lx\n", - U u.bits[_0], U u.bits[_1], U u.bits[_2]); - if (sizeof(long double) == 12) - printf("printf(\"%%.21Lg\") gives %.21Lg\n", u.d); - fmt_test: - se = g_xLfmt(obuf, u.bits, ndig, sizeof(obuf)); - printf("g_xLfmt(%d) gives %d bytes: \"%s\"\n\n", - ndig, (int)(se-obuf), se ? obuf : ""); - if (!dItry) - continue; - printf("strtoIxL returns %d,", - strtoIxL(ibuf, &se, v[0].bits, v[1].bits)); - printf(" consuming %d bytes.\n", (int)(se-ibuf)); - if (!memcmp(v[0].bits, v[1].bits, 12)) { - if (!memcmp(u.bits, v[0].bits, 12)) - printf("fI[0] == fI[1] == strtoxL\n"); - else { - printf("fI[0] == fI[1] = #%lx %lx %lx\n", - U v[0].bits[_0], U v[0].bits[_1], - U v[0].bits[_2]); - if (sizeof(long double) == 12) - printf("= %.21Lg\n", v[0].d); - } - } - else { - printf("fI[0] = #%lx %lx %lx\n", - U v[0].bits[_0], U v[0].bits[_1], - U v[0].bits[_2]); - if (sizeof(long double) == 12) - printf("= %.21Lg\n", v[0].d); - printf("fI[1] = #%lx %lx %lx\n", - U v[1].bits[_0], U v[1].bits[_1], - U v[1].bits[_2]); - if (sizeof(long double) == 12) - printf("= %.21Lg\n", v[1].d); - if (!memcmp(v[0].bits, u.bits, 12)) - printf("fI[0] == strtoxL\n"); - else if (!memcmp(v[1].bits, u.bits, 12)) - printf("fI[1] == strtoxL\n"); - else - printf("**** Both differ from strtod ****\n"); - } - printf("\n"); - } - return 0; - } diff --git a/lib/libc/gdtoa/test/xQtest.c b/lib/libc/gdtoa/test/xQtest.c deleted file mode 100644 index 93bc4142f..000000000 --- a/lib/libc/gdtoa/test/xQtest.c +++ /dev/null @@ -1,58 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 2002 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -#include - - int -main(void) -{ - union { long double d; unsigned int bits[4]; } u, w; - switch(sizeof(long double)) { - case 16: - w.bits[0] = w.bits[3] = 0; - w.d = 1.; - u.d = 3.; - w.d = w.d / u.d; - if (w.bits[0] && w.bits[3]) - printf("cp x.ou0 x.out; cp xL.ou0 xL.out;" - " cp Q.ou1 Q.out; cp pftestQ.out pftest.out\n"); - else - printf("cp x.ou0 x.out; cp xL.ou0 xL.out;" - " cp Q.ou0 Q.out; cp pftestx.out pftest.out\n"); - break; - case 10: - case 12: - printf("cp x.ou1 x.out; cp xL.ou1 xL.out; cp Q.ou0 Q.out;" - " cp pftestx.out pftest.out\n"); - break; - default: - printf("cp x.ou0 x.out; cp xL.ou0 xL.out; cp Q.ou0 Q.out;" - " cp pftestx.out pftest.out\n"); - } - return 0; - } diff --git a/lib/libc/gdtoa/test/xsum0.out b/lib/libc/gdtoa/test/xsum0.out deleted file mode 100644 index 52b8a3e60..000000000 --- a/lib/libc/gdtoa/test/xsum0.out +++ /dev/null @@ -1,41 +0,0 @@ -README efba0d5d 3412 -Q.ou0 e4592b85 28742 -Q.ou1 ea0b344d 39572 -Qtest.c efe2b3f4 5116 -d.out f271efc9 28131 -dI.out d522eef 4369 -dIsi.out 1dd6d02f 4350 -dItest.c e33800ce 2371 -dd.out e262456e 40923 -ddsi.out 1f94bbe2 10251 -ddtest.c ef71cbf3 4986 -dt.c e562c302 6808 -dtest.c 9a5d01 4080 -dtst.out e284ac98 23711 -f.out 9013e91 21537 -ftest.c 1c824a88 4001 -getround.c ee95ed1 2502 -makefile f714a641 5634 -pfLqtestnos ffb9723 99 -pftest.c ea314d7f 3452 -pftestQ.out 198434fd 830 -pftestx.out 1ccea5dd 788 -pftestLq.out 1691dbfc 845 -pftestnos ecbc9be6 101 -rtestnos f94bcdf6 336 -strtoIdSI.c 7bfb88b 49 -strtoIddSI.c 72e8852 50 -strtodISI.c ed08b740 49 -strtodt.c f1aa53af 3374 -strtopddSI.c 13e7138d 50 -strtorddSI.c f7e4b1d5 50 -testnos e89999d6 485 -testnos1 7e16229 294 -testnos3 f5ae7ef3 14403 -x.ou0 1402f834 25372 -x.ou1 f1af5a00 34581 -xL.ou0 faa3a741 26363 -xL.ou1 e349e5c 37165 -xLtest.c ee11f673 4843 -xQtest.c efbe29be 1912 -xtest.c ec9f5deb 4834 diff --git a/lib/libc/gdtoa/test/xtest.c b/lib/libc/gdtoa/test/xtest.c deleted file mode 100644 index 6e7fa4696..000000000 --- a/lib/libc/gdtoa/test/xtest.c +++ /dev/null @@ -1,170 +0,0 @@ -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998-2001 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -/* Test program for g_xfmt, strtoIx, strtopx, and strtorx. - * - * Inputs (on stdin): - * r rounding_mode - * n ndig - * number - * #hex0 hex1 hex2 hex3 hex4 - * - * rounding_mode values: - * 0 = toward zero - * 1 = nearest - * 2 = toward +Infinity - * 3 = toward -Infinity - * - * where number is a decimal floating-point number, - * hex0 is a string of <= 4 Hex digits for the most significant - * half-word of the number, hex1 is a similar string for the next - * half-word, etc., and ndig is a parameters to g_xfmt. - */ - -#include "gdtoa.h" -#include -#include -#include - - extern int getround ANSI((int,char*)); - - static char ibuf[2048], obuf[2048]; - -#undef _0 -#undef _1 - -/* one or the other of IEEE_BIG_ENDIAN or IEEE_LITTLE_ENDIAN should be #defined */ - -#ifdef IEEE_BIG_ENDIAN -#define _0 0 -#define _1 1 -#define _2 2 -#define _3 3 -#define _4 4 -#endif -#ifdef IEEE_LITTLE_ENDIAN -#define _0 4 -#define _1 3 -#define _2 2 -#define _3 1 -#define _4 0 -#endif - - int -main(Void) -{ - char *s, *se, *se1; - int i, dItry, ndig = 0, r = 1; - union { long double d; UShort bits[5]; } u, v[2]; - - while((s = fgets(ibuf, sizeof(ibuf), stdin))) { - while(*s <= ' ') - if (!*s++) - continue; - dItry = 0; - switch(*s) { - case 'r': - r = getround(r, s); - continue; - case 'n': - i = s[1]; - if (i <= ' ' || (i >= '0' && i <= '9')) { - ndig = atoi(s+1); - continue; - } - break; /* nan? */ - case '#': - sscanf(s+1, "%hx %hx %hx %hx %hx", &u.bits[_0], - &u.bits[_1], &u.bits[_2], &u.bits[_3], - &u.bits[_4]); - printf("\nInput: %s", ibuf); - printf(" --> f = #%x %x %x %x %x\n", u.bits[_0], - u.bits[_1], u.bits[_2], u.bits[_3], u.bits[_4]); - goto fmt_test; - } - dItry = 1; - printf("\nInput: %s", ibuf); - i = strtorx(ibuf, &se, r, u.bits); - if (r == 1 && (i != strtopx(ibuf, &se1, v[0].bits) || se1 != se - || memcmp(u.bits, v[0].bits, 10))) - printf("***strtox and strtorx disagree!!\n:"); - printf("\nstrtox consumes %d bytes and returns %d\n", - (int)(se-ibuf), i); - printf("with bits = #%x %x %x %x %x\n", - u.bits[_0], u.bits[_1], u.bits[_2], - u.bits[_3], u.bits[_4]); - if (sizeof(long double) == 12) - printf("printf(\"%%.21Lg\") gives %.21Lg\n", u.d); - fmt_test: - se = g_xfmt(obuf, u.bits, ndig, sizeof(obuf)); - printf("g_xfmt(%d) gives %d bytes: \"%s\"\n\n", - ndig, (int)(se-obuf), se ? obuf : ""); - if (!dItry) - continue; - printf("strtoIx returns %d,", - strtoIx(ibuf, &se, v[0].bits, v[1].bits)); - printf(" consuming %d bytes.\n", (int)(se-ibuf)); - if (!memcmp(v[0].bits, v[1].bits, 10)) { - if (!memcmp(u.bits, v[0].bits, 10)) - printf("fI[0] == fI[1] == strtox\n"); - else { - printf("fI[0] == fI[1] = #%x %x %x %x %x\n", - v[0].bits[_0], v[0].bits[_1], - v[0].bits[_2], v[0].bits[_3], - v[0].bits[_4]); - if (sizeof(long double) == 12) - printf("= %.21Lg\n", v[0].d); - } - } - else { - printf("fI[0] = #%x %x %x %x %x\n", - v[0].bits[_0], v[0].bits[_1], - v[0].bits[_2], v[0].bits[_3], - v[0].bits[_4]); - if (sizeof(long double) == 12) - printf("= %.21Lg\n", v[0].d); - printf("fI[1] = #%x %x %x %x %x\n", - v[1].bits[_0], v[1].bits[_1], - v[1].bits[_2], v[1].bits[_3], - v[1].bits[_4]); - if (sizeof(long double) == 12) - printf("= %.21Lg\n", v[1].d); - if (!memcmp(v[0].bits, u.bits, 10)) - printf("fI[0] == strtox\n"); - else if (!memcmp(v[1].bits, u.bits, 10)) - printf("fI[1] == strtox\n"); - else - printf("**** Both differ from strtod ****\n"); - } - printf("\n"); - } - return 0; - } diff --git a/lib/libc/gdtoa/ulp.c b/lib/libc/gdtoa/ulp.c deleted file mode 100644 index 2da0c0336..000000000 --- a/lib/libc/gdtoa/ulp.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: ulp.c,v 1.3 2011/03/20 23:15:35 christos Exp $ */ - -/**************************************************************** - -The author of this software is David M. Gay. - -Copyright (C) 1998, 1999 by Lucent Technologies -All Rights Reserved - -Permission to use, copy, modify, and distribute this software and -its documentation for any purpose and without fee is hereby -granted, provided that the above copyright notice appear in all -copies and that both that the copyright notice and this -permission notice and warranty disclaimer appear in supporting -documentation, and that the name of Lucent or any of its entities -not be used in advertising or publicity pertaining to -distribution of the software without specific, written prior -permission. - -LUCENT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, -INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. -IN NO EVENT SHALL LUCENT OR ANY OF ITS ENTITIES BE LIABLE FOR ANY -SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER -IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, -ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF -THIS SOFTWARE. - -****************************************************************/ - -/* Please send bug reports to David M. Gay (dmg at acm dot org, - * with " at " changed at "@" and " dot " changed to "."). */ - -#include "gdtoaimp.h" - - double -ulp -#ifdef KR_headers - (x) U *x; -#else - (U *x) -#endif -{ - Long L; - U a; - - L = (word0(x) & Exp_mask) - (P-1)*Exp_msk1; -#ifndef Sudden_Underflow - if (L > 0) { -#endif -#ifdef IBM - L |= Exp_msk1 >> 4; -#endif - word0(&a) = L; - word1(&a) = 0; -#ifndef Sudden_Underflow - } - else { - L = (unsigned int)-L >> Exp_shift; - if (L < Exp_shift) { - word0(&a) = 0x80000 >> L; - word1(&a) = 0; - } - else { - word0(&a) = 0; - L -= Exp_shift; - word1(&a) = L >= 31 ? 1 : 1 << (31 - L); - } - } -#endif - return dval(&a); - } diff --git a/lib/libc/gdtoa/xsum0.out b/lib/libc/gdtoa/xsum0.out deleted file mode 100644 index e9c29bc23..000000000 --- a/lib/libc/gdtoa/xsum0.out +++ /dev/null @@ -1,52 +0,0 @@ -README 664d441 15750 -arithchk.c ebbe5bc7 4075 -dmisc.c c8daa18 4682 -dtoa.c f6ed7306 17542 -g_Qfmt.c f6aad16c 2926 -g__fmt.c e961947e 3401 -g_ddfmt.c 1f75ef12 4161 -g_dfmt.c 24be3a8 2629 -g_ffmt.c 197652f1 2516 -g_xLfmt.c 3fd29c5 2773 -g_xfmt.c f6a580a 2862 -gdtoa.c e4651ba8 17355 -gdtoa.h f966845d 4944 -gdtoa_fltrnds.h 1aaf5112 421 -gdtoaimp.h 395c83e 20044 -gethex.c 144ecbb4 7107 -gmisc.c 1859d016 2084 -hd_init.c efdbe921 1797 -hexnan.c 891b04e 3468 -makefile ffae86d0 3148 -misc.c 1d84f517 14416 -printf.c 15c97ab 158 -printf.c0 efece124 29696 -qnan.c efd33d64 3417 -smisc.c feb7290 3699 -stdio1.h e6e5dc11 2909 -strtoIQ.c 1809dfcf 1939 -strtoId.c f41ddac2 1931 -strtoIdd.c f13e3bc3 2105 -strtoIf.c f12c6af4 1875 -strtoIg.c fe47bc72 3591 -strtoIx.c e50f716d 1960 -strtoIxL.c ea0b821b 1931 -strtod.c 1dabf6 22744 -strtodI.c f1dbb0af 4004 -strtodg.c eacc7424 21188 -strtodnrp.c af895e9 2538 -strtof.c e1cb24dd 2161 -strtopQ.c f244b012 2645 -strtopd.c 1c3c9ce 1751 -strtopdd.c 177251c9 4640 -strtopf.c f305c6ea 2155 -strtopx.c 1529e1f5 2710 -strtopxL.c 69418e3 2469 -strtorQ.c 9360a0b 2885 -strtord.c af5c50e 2491 -strtordd.c e3d20ab 4992 -strtorf.c fbe2ea18 2402 -strtorx.c 168faee5 2957 -strtorxL.c 42c6cec 2718 -sum.c f525bad9 2494 -ulp.c edb56c0b 1866 diff --git a/lib/libc/gen/Lint___setjmp14.c b/lib/libc/gen/Lint___setjmp14.c deleted file mode 100644 index 1d4f47fa5..000000000 --- a/lib/libc/gen/Lint___setjmp14.c +++ /dev/null @@ -1,21 +0,0 @@ -/* $NetBSD: Lint___setjmp14.c,v 1.3 2005/04/09 12:48:58 dsl Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -int -__setjmp14(jmp_buf env) -{ - return 0; -} - -/*ARGSUSED*/ -void -__longjmp14(jmp_buf env, int val) -{ -} diff --git a/lib/libc/gen/Lint___sigsetjmp14.c b/lib/libc/gen/Lint___sigsetjmp14.c deleted file mode 100644 index 7bd3da5b5..000000000 --- a/lib/libc/gen/Lint___sigsetjmp14.c +++ /dev/null @@ -1,25 +0,0 @@ -/* $NetBSD: Lint___sigsetjmp14.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -int -__sigsetjmp14(env, savemask) - sigjmp_buf env; - int savemask; -{ - return (0); -} - -/*ARGSUSED*/ -void -__siglongjmp14(env, val) - sigjmp_buf env; - int val; -{ -} diff --git a/lib/libc/gen/Lint__setjmp.c b/lib/libc/gen/Lint__setjmp.c deleted file mode 100644 index f12a441bf..000000000 --- a/lib/libc/gen/Lint__setjmp.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: Lint__setjmp.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -int -_setjmp(env) - jmp_buf env; -{ - return (0); -} - -/*ARGSUSED*/ -void -_longjmp(env, val) - jmp_buf env; - int val; -{ -} diff --git a/lib/libc/gen/Lint_alloca.c b/lib/libc/gen/Lint_alloca.c deleted file mode 100644 index 66624414f..000000000 --- a/lib/libc/gen/Lint_alloca.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: Lint_alloca.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -void * -alloca(size) - size_t size; -{ - return (0); -} diff --git a/lib/libc/gen/Lint_bswap16.c b/lib/libc/gen/Lint_bswap16.c deleted file mode 100644 index 2842e6f70..000000000 --- a/lib/libc/gen/Lint_bswap16.c +++ /dev/null @@ -1,13 +0,0 @@ -/* $NetBSD: Lint_bswap16.c,v 1.3 2001/02/27 19:04:40 cgd Exp $ */ -/* Written by Manuel Bouyer. Public Domain */ - -#include - -/*ARGSUSED*/ -/*LINTED prototype mismatch */ -u_int16_t -bswap16(b16) - u_int16_t b16; -{ - return 0; -} diff --git a/lib/libc/gen/Lint_bswap32.c b/lib/libc/gen/Lint_bswap32.c deleted file mode 100644 index 3c7c4217d..000000000 --- a/lib/libc/gen/Lint_bswap32.c +++ /dev/null @@ -1,12 +0,0 @@ -/* $NetBSD: Lint_bswap32.c,v 1.2 2001/02/27 19:04:40 cgd Exp $ */ -/* Written by Manuel Bouyer. Public Domain */ - -#include - -/*ARGSUSED*/ -u_int32_t -bswap32(b32) - u_int32_t b32; -{ - return 0; -} diff --git a/lib/libc/gen/Lint_bswap64.c b/lib/libc/gen/Lint_bswap64.c deleted file mode 100644 index 77286d77d..000000000 --- a/lib/libc/gen/Lint_bswap64.c +++ /dev/null @@ -1,12 +0,0 @@ -/* $NetBSD: Lint_bswap64.c,v 1.2 2001/02/27 19:04:40 cgd Exp $ */ -/* Written by Manuel Bouyer. Public Domain */ - -#include - -/*ARGSUSED*/ -u_int64_t -bswap64(b64) - u_int64_t b64; -{ - return 0; -} diff --git a/lib/libc/gen/Lint_fabs.c b/lib/libc/gen/Lint_fabs.c deleted file mode 100644 index fe28e2e92..000000000 --- a/lib/libc/gen/Lint_fabs.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: Lint_fabs.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -double -fabs(x) - double x; -{ - return (0.0); -} diff --git a/lib/libc/gen/Lint_flt_rounds.c b/lib/libc/gen/Lint_flt_rounds.c deleted file mode 100644 index 0cff68679..000000000 --- a/lib/libc/gen/Lint_flt_rounds.c +++ /dev/null @@ -1,13 +0,0 @@ -/* $NetBSD: Lint_flt_rounds.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -/*ARGSUSED*/ -int -__flt_rounds(void) -{ - return (0); -} diff --git a/lib/libc/gen/Lint_fpgetmask.c b/lib/libc/gen/Lint_fpgetmask.c deleted file mode 100644 index 2d0f57b71..000000000 --- a/lib/libc/gen/Lint_fpgetmask.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_fpgetmask.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -fp_except -fpgetmask(void) -{ - fp_except rv = { 0 }; - - return (rv); -} diff --git a/lib/libc/gen/Lint_fpgetround.c b/lib/libc/gen/Lint_fpgetround.c deleted file mode 100644 index 44cfc63e3..000000000 --- a/lib/libc/gen/Lint_fpgetround.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_fpgetround.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -fp_rnd -fpgetround(void) -{ - fp_rnd rv = { 0 }; - - return (rv); -} diff --git a/lib/libc/gen/Lint_fpgetsticky.c b/lib/libc/gen/Lint_fpgetsticky.c deleted file mode 100644 index 64e8793b6..000000000 --- a/lib/libc/gen/Lint_fpgetsticky.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_fpgetsticky.c,v 1.3 2012/06/24 15:26:03 christos Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -fp_except -fpgetsticky(void) -{ - fp_except rv = { 0 }; - - return (rv); -} diff --git a/lib/libc/gen/Lint_fpsetmask.c b/lib/libc/gen/Lint_fpsetmask.c deleted file mode 100644 index f50fbba6c..000000000 --- a/lib/libc/gen/Lint_fpsetmask.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: Lint_fpsetmask.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -fp_except -fpsetmask(m) - fp_except m; -{ - fp_except rv = { 0 }; - - return (rv); -} diff --git a/lib/libc/gen/Lint_fpsetround.c b/lib/libc/gen/Lint_fpsetround.c deleted file mode 100644 index 9d7d216bf..000000000 --- a/lib/libc/gen/Lint_fpsetround.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: Lint_fpsetround.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -fp_rnd -fpsetround(r) - fp_rnd r; -{ - fp_rnd rv = { 0 }; - - return (rv); -} diff --git a/lib/libc/gen/Lint_fpsetsticky.c b/lib/libc/gen/Lint_fpsetsticky.c deleted file mode 100644 index 22fe09600..000000000 --- a/lib/libc/gen/Lint_fpsetsticky.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: Lint_fpsetsticky.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -fp_except -fpsetsticky(s) - fp_except s; -{ - fp_except rv = { 0 }; - - return (rv); -} diff --git a/lib/libc/gen/Lint_frexp.c b/lib/libc/gen/Lint_frexp.c deleted file mode 100644 index 3fb1c1472..000000000 --- a/lib/libc/gen/Lint_frexp.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_frexp.c,v 1.2 1998/12/02 09:47:20 christos Exp $ */ - -/* - * This file placed in the public domain. - * Matthias Pfaller, December 6, 1997. - */ - -#include - -/*ARGSUSED*/ -double -frexp(value, eptr) - double value; - int *eptr; -{ - return(0); -} diff --git a/lib/libc/gen/Lint_ldexp.c b/lib/libc/gen/Lint_ldexp.c deleted file mode 100644 index 3cb80c04a..000000000 --- a/lib/libc/gen/Lint_ldexp.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_ldexp.c,v 1.2 1998/12/02 09:47:20 christos Exp $ */ - -/* - * This file placed in the public domain. - * Matthias Pfaller, December 6, 1997. - */ - -#include - -/*ARGSUSED*/ -double -ldexp(val, exp) - double val; - int exp; -{ - return(0); -} diff --git a/lib/libc/gen/Lint_modf.c b/lib/libc/gen/Lint_modf.c deleted file mode 100644 index 1acf0ff7f..000000000 --- a/lib/libc/gen/Lint_modf.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: Lint_modf.c,v 1.2 2000/06/14 06:49:05 cgd Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include - -/*ARGSUSED*/ -double -modf(value, iptr) - double value, *iptr; -{ - return (0.0); -} diff --git a/lib/libc/gen/Lint_resumecontext.c b/lib/libc/gen/Lint_resumecontext.c deleted file mode 100644 index 4933908d9..000000000 --- a/lib/libc/gen/Lint_resumecontext.c +++ /dev/null @@ -1,14 +0,0 @@ -/* $NetBSD: Lint_resumecontext.c,v 1.3 2011/09/19 21:24:58 joerg Exp $ */ - -/* - * This file placed in the public domain. - * Klaus Klein, January 26, 1999. - */ - -#include - -/*ARGSUSED*/ -void -_resumecontext(void) -{ -} diff --git a/lib/libc/gen/Lint_swapcontext.c b/lib/libc/gen/Lint_swapcontext.c deleted file mode 100644 index 0e0b45e80..000000000 --- a/lib/libc/gen/Lint_swapcontext.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: Lint_swapcontext.c,v 1.2 2003/01/18 11:38:47 thorpej Exp $ */ - -/* - * This file placed in the public domain. - * Klaus Klein, November 29, 1998. - */ - -#include - -/*ARGSUSED*/ -int -swapcontext(oucp, ucp) - ucontext_t *oucp; - const ucontext_t *ucp; -{ - - return (0); -} diff --git a/lib/libc/gen/Makefile.inc b/lib/libc/gen/Makefile.inc deleted file mode 100644 index 68b161049..000000000 --- a/lib/libc/gen/Makefile.inc +++ /dev/null @@ -1,223 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.191 2015/01/20 17:28:00 christos Exp $ -# from: @(#)Makefile.inc 8.6 (Berkeley) 5/4/95 - -# gen sources -.if defined(__MINIX) -.PATH: ${NETBSDSRCDIR}/minix/lib/libc/gen - -CPPFLAGS.fslib.c+= -I${NETBSDSRCDIR}/minix/fs -CPPFLAGS.fsversion.c+= -I${NETBSDSRCDIR}/minix/fs - -SRCS+= fsversion.c gcov.c itoa.c read_tsc_64.c fslib.c - -.endif # defined(__MINIX) -.PATH: ${ARCHDIR}/gen ${.CURDIR}/gen - -.if ${RUMPRUN} != "yes" -SRCS+= _errno.c -.endif - -.if defined(__MINIX) -# Unsupported by Minix. -# closefrom.c confstr.c extattr.c \ -# pthread_atfork.c -# -# Not useful but portable -# disklabel.c - -SRCS+= alarm.c alphasort.c arc4random.c assert.c asysctl.c \ - basename.c clock.c closedir.c \ - ctermid.c ctype_.c daemon.c \ - dehumanize_number.c devname.c dirname.c err.c errx.c \ - errc.c errlist.c errno.c execl.c execle.c execlp.c execv.c execvp.c \ - fmtcheck.c fmtmsg.c fnmatch.c fstab.c ftok.c \ - fts.c ftw.c getbsize.c getcap.c getcwd.c \ - getdevmajor.c getdomainname.c getgrent.c \ - getgrouplist.c getgroupmembership.c gethostname.c \ - getloadavg.c getlogin.c getmntinfo.c \ - getnetgrent.c getpagesize.c \ - getpass.c getprogname.c getpwent.c getttyent.c \ - getusershell.c glob.c humanize_number.c initdir.c initgroups.c \ - isascii.c isatty.c isctype.c lockf.c nftw.c \ - nice.c nlist.c nlist_aout.c nlist_coff.c nlist_ecoff.c nlist_elf32.c \ - nlist_elf64.c opendir.c pause.c popen.c posix_spawn_sched.c \ - posix_spawn_fileactions.c posix_spawnp.c psignal.c \ - ptree.c pwcache.c pw_scan.c raise.c randomid.c rb.c readdir.c \ - rewinddir.c scandir.c seekdir.c setdomainname.c \ - sethostname.c setjmperr.c setmode.c setproctitle.c setprogname.c \ - shquote.c shquotev.c sighold.c sigignore.c siginterrupt.c \ - siglist.c signal.c signame.c sigrelse.c \ - sigset.c sigsetops.c sleep.c \ - stringlist.c sysconf.c sysctl.c sysctlbyname.c sysctlgetmibinfo.c \ - sysctlnametomib.c syslog.c telldir.c time.c \ - times.c toascii.c tolower_.c ttyname.c ttyslot.c toupper_.c ualarm.c \ - ulimit.c uname.c unvis.c usleep.c utime.c utimens.c utmp.c \ - utmpx.c valloc.c vis.c wait.c wait3.c waitpid.c warn.c warnx.c \ - warnc.c vwarn.c vwarnx.c vwarnc.c verr.c verrx.c verrc.c wordexp.c -.endif # defined(__MINIX) - -# uses alloca -COPTS.execvp.c = -Wno-stack-protector -COPTS.execl.c = -Wno-stack-protector -COPTS.execle.c = -Wno-stack-protector -COPTS.execlp.c = -Wno-stack-protector -COPTS.syslog.c = -Wno-format-nonliteral - -# machine-dependent gen sources -# m-d Makefile.inc must include sources for: -# _setjmp() bswap16() bswap32() bswap64() fabs() infinity -# isinf() setjmp() sigsetjmp() - -.include "${ARCHDIR}/gen/Makefile.inc" - -MAN+= alarm.3 arc4random.3 basename.3 bswap.3 clock.3 closefrom.3 \ - confstr.3 \ - cpuset.3 ctermid.3 ctype.3 daemon.3 devname.3 directory.3 dirname.3 \ - endutxent.3 err.3 exec.3 extattr_copy_file.3 extattr_namespace_to_string.3 \ - fmtcheck.3 fmtmsg.3 fnmatch.3 fpclassify.3 fpgetmask.3 \ - ftok.3 fts.3 ftw.3 \ - getbsize.3 cgetcap.3 getcwd.3 getdevmajor.3 \ - getdomainname.3 getdiskbyname.3 getfsent.3 \ - getgrent.3 getgrouplist.3 gethostname.3 getlastlogx.3 getloadavg.3 \ - getmntinfo.3 getnetgrent.3 getpagesize.3 getpass.3 \ - getprogname.3 getpwent.3 getttyent.3 getusershell.3 glob.3 \ - humanize_number.3 \ - initgroups.3 isalnum.3 isalpha.3 isascii.3 isblank.3 iscntrl.3 \ - isdigit.3 isfinite.3 isgraph.3 isgreater.3 isinf.3 islower.3 isnan.3 \ - isnormal.3 isprint.3 ispunct.3 isspace.3 isupper.3 isxdigit.3 \ - lockf.3 _lwp_makecontext.3 makecontext.3 \ - nice.3 nlist.3 \ - pause.3 popen.3 \ - posix_spawn.3 posix_spawn_file_actions_addopen.3 \ - posix_spawn_file_actions_init.3 posix_spawnattr_getflags.3 \ - posix_spawnattr_getpgroup.3 posix_spawnattr_getschedparam.3 \ - posix_spawnattr_getschedpolicy.3 posix_spawnattr_init.3 \ - posix_spawnattr_getsigdefault.3 posix_spawnattr_getsigmask.3 \ - psignal.3 pwcache.3 pthread_atfork.3 \ - raise.3 randomid.3 realpath.3 scandir.3 setjmp.3 setmode.3 \ - setproctitle.3 shquote.3 sighold.3 sigignore.3 siginterrupt.3 \ - signal.3 signbit.3 sigrelse.3 sigset.3 sigsetops.3 sleep.3 \ - stringlist.3 sysconf.3 sysctl.3 syslog.3 time.3 times.3 \ - timezone.3 toascii.3 tolower.3 toupper.3 ttyname.3 \ - ualarm.3 ulimit.3 uname.3 unvis.3 usleep.3 utime.3 valloc.3 vis.3 \ - wordexp.3 - -MLINKS+=bswap.3 bswap16.3 bswap.3 bswap32.3 bswap.3 bswap64.3 -MLINKS+=cpuset.3 cpuset_create.3 cpuset.3 cpuset_destroy.3 \ - cpuset.3 cpuset_zero.3 cpuset.3 cpuset_set.3 cpuset.3 cpuset_clr.3 \ - cpuset.3 cpuset_isset.3 cpuset.3 cpuset_size.3 -MLINKS+=directory.3 closedir.3 directory.3 dirfd.3 directory.3 opendir.3 \ - directory.3 readdir.3 directory.3 readdir_r.3 directory.3 \ - rewinddir.3 directory.3 seekdir.3 directory.3 telldir.3 \ - directory.3 fdopendir.3 -MLINKS+=endutxent.3 getutxent.3 endutxent.3 getutxid.3 \ - endutxent.3 getutxline.3 endutxent.3 pututxline.3 \ - endutxent.3 setutxent.3 -MLINKS+=err.3 verr.3 err.3 errx.3 err.3 verrx.3 err.3 warn.3 err.3 vwarn.3 \ - err.3 warnx.3 err.3 vwarnx.3 err.3 errc.3 err.3 verrc.3 err.3 warnc.3 \ - err.3 vwarnc.3 -MLINKS+=exec.3 execl.3 exec.3 execle.3 exec.3 execlp.3 exec.3 execlpe.3 \ - exec.3 execv.3 exec.3 execvp.3 exec.3 execvpe.3 exec.3 exect.3 -MLINKS+=extattr_namespace_to_string.3 extattr_string_to_namespace.3 \ - extattr_copy_file.3 extattr_copy_fd.3 \ - extattr_copy_file.3 extattr_copy_link.3 \ - extattr_copy_file.3 cpxattr.3 \ - extattr_copy_file.3 fcpxattr.3 \ - extattr_copy_file.3 lcpxattr.3 -MLINKS+=fpgetmask.3 fpgetround.3 fpgetmask.3 fpgetsticky.3 \ - fpgetmask.3 fpsetmask.3 fpgetmask.3 fpsetround.3 \ - fpgetmask.3 fpsetsticky.3 fpgetmask.3 fpgetprec.3 \ - fpgetmask.3 fpsetprec.3 -MLINKS+=fts.3 fts_open.3 fts.3 fts_read.3 fts.3 fts_children.3 \ - fts.3 fts_set.3 fts.3 fts_close.3 -MLINKS+=ftw.3 nftw.3 -MLINKS+=cgetcap.3 cgetclose.3 cgetcap.3 cgetent.3 \ - cgetcap.3 cgetfirst.3 cgetcap.3 cgetmatch.3 cgetcap.3 cgetnext.3 \ - cgetcap.3 cgetnum.3 cgetcap.3 cgetset.3 cgetcap.3 cgetstr.3 \ - cgetcap.3 cgetustr.3 -MLINKS+=getcwd.3 getwd.3 -MLINKS+=getpass.3 getpass_r.3 -MLINKS+=getpass.3 getpassfd.3 -MLINKS+=getdiskbyname.3 setdisktab.3 -MLINKS+=getdomainname.3 setdomainname.3 -MLINKS+=getfsent.3 endfsent.3 getfsent.3 getfsfile.3 getfsent.3 getfsspec.3 \ - getfsent.3 setfsent.3 -MLINKS+=getgrent.3 endgrent.3 getgrent.3 setgroupent.3 getgrent.3 getgrgid.3 \ - getgrent.3 getgrnam.3 getgrent.3 setgrent.3 -MLINKS+=getgrent.3 getgrgid_r.3 getgrent.3 getgrnam_r.3 getgrent.3 getgrent_r.3 -MLINKS+=getgrouplist.3 getgroupmembership.3 -MLINKS+=gethostname.3 sethostname.3 -MLINKS+=getlastlogx.3 getutmp.3 getlastlogx.3 getutmpx.3 -MLINKS+=getlastlogx.3 updlastlogx.3 getlastlogx.3 updwtmpx.3 -MLINKS+=getlastlogx.3 utmpxname.3 -MLINKS+=getnetgrent.3 endnetgrent.3 getnetgrent.3 innetgr.3 \ - getnetgrent.3 setnetgrent.3 -MLINKS+=getprogname.3 setprogname.3 -MLINKS+=getpwent.3 endpwent.3 getpwent.3 setpassent.3 getpwent.3 getpwnam.3 \ - getpwent.3 getpwuid.3 getpwent.3 setpwent.3 -MLINKS+=getpwent.3 getpwnam_r.3 getpwent.3 getpwuid_r.3 getpwent.3 getpwent_r.3 -# getpwent.3 setpwfile.3 - deprecated -MLINKS+=getttyent.3 endttyent.3 getttyent.3 getttynam.3 \ - getttyent.3 setttyent.3 getttyent.3 setttyentpath.3 -MLINKS+=getusershell.3 endusershell.3 getusershell.3 setusershell.3 -MLINKS+=glob.3 globfree.3 -MLINKS+=glob.3 glob_pattern_p.3 -MLINKS+=humanize_number.3 dehumanize_number.3 -MLINKS+=makecontext.3 swapcontext.3 -MLINKS+=popen.3 pclose.3 -MLINKS+=popen.3 popenve.3 -MLINKS+=posix_spawn.3 posix_spawnp.3 \ - posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_addclose.3 \ - posix_spawn_file_actions_addopen.3 posix_spawn_file_actions_adddup2.3 \ - posix_spawn_file_actions_init.3 posix_spawn_file_actions_destroy.3 \ - posix_spawnattr_getflags.3 posix_spawnattr_setflags.3 \ - posix_spawnattr_getpgroup.3 posix_spawnattr_setpgroup.3 \ - posix_spawnattr_getschedparam.3 posix_spawnattr_setschedparam.3 \ - posix_spawnattr_getschedpolicy.3 posix_spawnattr_setschedpolicy.3 \ - posix_spawnattr_getsigdefault.3 posix_spawnattr_setsigdefault.3 \ - posix_spawnattr_getsigmask.3 posix_spawnattr_setsigmask.3 \ - posix_spawnattr_init.3 posix_spawnattr_destroy.3 -MLINKS+=psignal.3 sys_siglist.3 psignal.3 sys_signame.3 psignal.3 psiginfo.3 -MLINKS+=pwcache.3 user_from_uid.3 pwcache.3 group_from_gid.3 -MLINKS+=pwcache.3 uid_from_user.3 pwcache.3 gid_from_group.3 -MLINKS+=pwcache.3 pwcache_userdb.3 pwcache.3 pwcache_groupdb.3 -MLINKS+=randomid.3 randomid_new.3 randomid.3 randomid_delete.3 -MLINKS+=scandir.3 alphasort.3 -MLINKS+=setjmp.3 _longjmp.3 setjmp.3 _setjmp.3 setjmp.3 longjmp.3 \ - setjmp.3 longjmperror.3 setjmp.3 sigsetjmp.3 setjmp.3 siglongjmp.3 -MLINKS+=setmode.3 getmode.3 -MLINKS+=shquote.3 shquotev.3 -MLINKS+=sigsetops.3 sigemptyset.3 sigsetops.3 sigfillset.3 \ - sigsetops.3 sigaddset.3 sigsetops.3 sigdelset.3 \ - sigsetops.3 sigismember.3 -MLINKS+=stringlist.3 sl_init.3 stringlist.3 sl_free.3 stringlist.3 sl_add.3 \ - stringlist.3 sl_find.3 -MLINKS+=sysctl.3 sysctlbyname.3 sysctl.3 sysctlgetmibinfo.3 \ - sysctl.3 sysctlnametomib.3 -MLINKS+=syslog.3 closelog.3 syslog.3 openlog.3 syslog.3 setlogmask.3 \ - syslog.3 vsyslog.3 -MLINKS+=syslog.3 closelog_r.3 syslog.3 openlog_r.3 syslog.3 setlogmask_r.3 \ - syslog.3 syslog_r.3 syslog.3 vsyslog_r.3 -MLINKS+=syslog.3 syslogp.3 syslog.3 syslogp_r.3 \ - syslog.3 vsyslogp.3 syslog.3 vsyslogp_r.3 -MLINKS+=ttyname.3 isatty.3 ttyname.3 ttyslot.3 ttyname.3 ttyname_r.3 -MLINKS+=unvis.3 strunvis.3 unvis.3 strunvisx.3 -MLINKS+=unvis.3 strnunvis.3 unvis.3 strnunvisx.3 -MLINKS+=vis.3 svis.3 vis.3 strvis.3 vis.3 strvisx.3 vis.3 strsvis.3 \ - vis.3 strsvisx.3 vis.3 nvis.3 -MLINKS+=vis.3 snvis.3 vis.3 strnvis.3 vis.3 strnvisx.3 vis.3 strsnvis.3 \ - vis.3 strsnvisx.3 - -CPPFLAGS.ctype_.c+= -I${LIBCDIR}/locale -CPPFLAGS.isctype.c+= -I${LIBCDIR}/locale -CPPFLAGS.tolower_.c+= -I${LIBCDIR}/locale -CPPFLAGS.toupper_.c+= -I${LIBCDIR}/locale - -errlist.c: errlist.awk ${NETBSDSRCDIR}/sys/sys/errno.h -.if defined(__MINIX) - ${TOOL_CAT} ${NETBSDSRCDIR}/sys/sys/errno.h | ${TOOL_SED} 's/(_SIGN//' | ${TOOL_AWK} -f ${NETBSDSRCDIR}/lib/libc/gen/errlist.awk > ${.TARGET} -.else - ${TOOL_AWK} -f ${.ALLSRC} > ${.TARGET} -.endif - -CLEANFILES+= errlist.c diff --git a/lib/libc/gen/_errno.c b/lib/libc/gen/_errno.c deleted file mode 100644 index 257900d1e..000000000 --- a/lib/libc/gen/_errno.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: _errno.c,v 1.13 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _errno.c,v 1.13 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "reentrant.h" -#include -#include - -#undef errno -extern int errno; - -int * -__errno(void) -{ -#ifdef _REENTRANT - if (__isthreaded == 0) - return &errno; - - return thr_errno(); -#else - return &errno; -#endif -} diff --git a/lib/libc/gen/_lwp_makecontext.3 b/lib/libc/gen/_lwp_makecontext.3 deleted file mode 100644 index 9994c98d1..000000000 --- a/lib/libc/gen/_lwp_makecontext.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" $NetBSD: _lwp_makecontext.3,v 1.4 2008/04/30 13:10:50 martin Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Jason R. Thorpe of Wasabi Systems, Inc. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd January 16, 2003 -.Dt _LWP_MAKECONTEXT 3 -.Os -.Sh NAME -.Nm _lwp_makecontext -.Nd create a new initial light-weight process execution context -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In lwp.h -.Ft void -.Fn _lwp_makecontext "ucontext_t *context" "void (*start_routine)(void *)" \ - "void *arg" "void *private" "caddr_t stack_base" "size_t stack_size" -.Sh DESCRIPTION -.Fn _lwp_makecontext -initializes the context structure pointed to by -.Fa context -in a manner suitable for using with -.Xr _lwp_create 2 . -The LWP will begin execution at the function specified by -.Fa start_routine -which will be passed a single argument -.Fa arg . -The LWP private data pointer will be set to -.Fa private . -The stack region for the new LWP is specified by the -.Fa stack_base -and -.Fa stack_size -arguments. -.Pp -The signal mask in the context structure is not initialized by -.Fn _lwp_makecontext . -.Sh SEE ALSO -.Xr _lwp_create 2 , -.Xr _lwp_getprivate 2 -.Sh HISTORY -The -.Fn _lwp_create -system call first appeared in -.Nx 2.0 . -.Sh BUGS -The LWP private data pointer is not initialized by the current -implementation of -.Fn _lwp_makecontext . diff --git a/lib/libc/gen/alarm.3 b/lib/libc/gen/alarm.3 deleted file mode 100644 index 4eba88342..000000000 --- a/lib/libc/gen/alarm.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" $NetBSD: alarm.3,v 1.22 2003/08/07 16:42:45 agc Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)alarm.3 8.2 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt ALARM 3 -.Os -.Sh NAME -.Nm alarm -.Nd set signal timer alarm -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft unsigned int -.Fn alarm "unsigned int seconds" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by -.Xr setitimer 2 . -.Ef -.Pp -The -.Fn alarm -function sets a timer to deliver the signal -.Dv SIGALRM -to the calling process -.Ar seconds -after the call to -.Fn alarm . -If an alarm has already been set with -.Fn alarm -but has not been delivered, another call to -.Fn alarm -will supersede the prior call. -The request -.Fn alarm "0" -voids the current -alarm and the signal SIGALRM will not be delivered. -The maximum number of -.Ar seconds -allowed -is 2147483647. -.Pp -The return value of -.Fn alarm -is the amount of time left on the timer from a previous call to -.Fn alarm . -If no alarm is currently set, the return value is 0. -If there is an error setting the timer, -.Fn alarm -returns ((unsigned int) -1). -.Sh SEE ALSO -.Xr setitimer 2 , -.Xr sigaction 2 , -.Xr sigsuspend 2 , -.Xr signal 3 , -.Xr sigvec 3 , -.Xr sleep 3 , -.Xr ualarm 3 , -.Xr usleep 3 -.Sh STANDARDS -The -.Fn alarm -function conforms to -.St -p1003.1-90 . -.Sh HISTORY -An -.Fn alarm -function appeared in -.At v7 . diff --git a/lib/libc/gen/alarm.c b/lib/libc/gen/alarm.c deleted file mode 100644 index 6d8f2d8f3..000000000 --- a/lib/libc/gen/alarm.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: alarm.c,v 1.11 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)alarm.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: alarm.c,v 1.11 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * Backwards compatible alarm. - */ -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(alarm,_alarm) -#endif - -unsigned int -alarm(unsigned int secs) -{ - struct itimerval it, oitv; - struct itimerval *itp = ⁢ - - timerclear(&itp->it_interval); - itp->it_value.tv_sec = secs; - itp->it_value.tv_usec = 0; - if (setitimer(ITIMER_REAL, itp, &oitv) == -1) - return (unsigned int) -1; - if (oitv.it_value.tv_usec) - oitv.it_value.tv_sec++; - return (unsigned int)oitv.it_value.tv_sec; -} diff --git a/lib/libc/gen/alphasort.c b/lib/libc/gen/alphasort.c deleted file mode 100644 index c8310d425..000000000 --- a/lib/libc/gen/alphasort.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: alphasort.c,v 1.2 2009/03/01 19:59:55 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94"; -#else -__RCSID("$NetBSD: alphasort.c,v 1.2 2009/03/01 19:59:55 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -/* - * Alphabetic order comparison routine for those who want it. - */ -int -alphasort(const void *d1, const void *d2) -{ - - _DIAGASSERT(d1 != NULL); - _DIAGASSERT(d2 != NULL); - - return (strcmp((*(const struct dirent *const *)d1)->d_name, - (*(const struct dirent *const *)d2)->d_name)); -} diff --git a/lib/libc/gen/arc4random.3 b/lib/libc/gen/arc4random.3 deleted file mode 100644 index 29dbe9afc..000000000 --- a/lib/libc/gen/arc4random.3 +++ /dev/null @@ -1,317 +0,0 @@ -.\" $NetBSD: arc4random.3,v 1.19 2014/11/17 18:41:29 riastradh Exp $ -.\" -.\" Copyright (c) 2014 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Taylor R. 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. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd November 16, 2014 -.Dt ARC4RANDOM 3 -.Os -.Sh NAME -.Nm arc4random , -.Nm arc4random_uniform , -.Nm arc4random_buf , -.Nm arc4random_stir , -.Nm arc4random_addrandom -.Nd random number generator -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft uint32_t -.Fn arc4random "void" -.Ft uint32_t -.Fn arc4random_uniform "uint32_t bound" -.Ft void -.Fn arc4random_buf "void *buf" "size_t len" -.Ft void -.Fn arc4random_stir "void" -.Ft void -.Fn arc4random_addrandom "unsigned char *buf" "int len" -.Sh DESCRIPTION -The -.Nm -family of functions provides a cryptographic pseudorandom number -generator automatically seeded from the system entropy pool and safe to -use from multiple threads. -.Nm -is designed to prevent an adversary from guessing outputs, -unlike -.Xr rand 3 -and -.Xr random 3 , -and is faster and more convenient than reading from -.Pa /dev/urandom -directly. -.Pp -.Fn arc4random -returns an integer in [0, 2^32) chosen independently with uniform -distribution. -.Pp -.Fn arc4random_uniform -returns an integer in [0, -.Fa bound ) -chosen independently with uniform distribution. -.Pp -.Fn arc4random_buf -stores -.Fa len -bytes into the memory pointed to by -.Fa buf , -each byte chosen independently from [0, 256) with uniform -distribution. -.Pp -.Fn arc4random_stir -draws entropy from the operating system and incorporates it into the -library's PRNG state to influence future outputs. -.Pp -.Fn arc4random_addrandom -incorporates -.Fa len -bytes, which must be nonnegative, from the buffer -.Fa buf , -into the library's PRNG state to influence future outputs. -.Pp -It is not necessary for an application to call -.Fn arc4random_stir -or -.Fn arc4random_addrandom -before calling other -.Nm -functions. -The first call to any -.Nm -function will initialize the PRNG state unpredictably from the system -entropy pool. -.Sh SECURITY MODEL -The -.Nm -functions provide the following security properties against three -different classes of attackers, assuming enough entropy is provided by -the operating system: -.Bl -bullet -offset abcd -.It -An attacker who has seen some outputs of any of the -.Nm -functions cannot predict past or future unseen outputs. -.It -An attacker who has seen the library's PRNG state in memory cannot -predict past outputs. -.It -An attacker who has seen one process's PRNG state cannot predict past -or future outputs in other processes, particularly its parent or -siblings. -.El -.Pp -One -.Sq output -means the result of any single request to an -.Nm -function, no matter how short it is. -.Sh IMPLEMENTATION NOTES -The -.Nm -functions are currently implemented using the ChaCha20 pseudorandom -function family. -For any 32-byte string -.Fa s , -.Pf ChaCha20_ Fa s -is a function from 16-byte strings to 64-byte strings. -It is conjectured that if -.Fa s -is chosen with uniform distribution, then the distribution on -.Pf ChaCha20_ Fa s -is indistinguishable to a computationally bounded adversary from a -uniform distribution on all functions from 16-byte strings to 64-byte -strings. -.Pp -The PRNG state is a 32-byte ChaCha20 key -.Fa s . -Each request to -an -.Nm -function -.Bl -bullet -offset abcd -compact -.It -computes the 64-byte quantity -.Fa x -= -.Pf ChaCha20_ Fa s Ns (0), -.It -splits -.Fa x -into two 32-byte quantities -.Fa s' -and -.Fa k , -.It -replaces -.Fa s -by -.Fa s' , -and -.It -uses -.Fa k -as output. -.El -.Pp -.Fn arc4random -yields the first four bytes of -.Fa k -as output directly. -.Fn arc4random_buf -either yields up to 32 bytes of -.Fa k -as output directly, or, for longer -requests, uses -.Fa k -as a ChaCha20 key and yields the concatenation -.Pf ChaCha20_ Fa k Ns (0) -|| -.Pf ChaCha20_ Fa k Ns (1) -|| ... as output. -.Fn arc4random_uniform -repeats -.Fn arc4random -until it obtains an integer in [2^32 % -.Fa bound , -2^32), and reduces that modulo -.Fa bound . -.Pp -The PRNG state is per-thread, unless memory allocation fails inside the -library, in which case some threads may share global PRNG state with a -mutex. -The global PRNG state is zeroed on fork in the parent via -.Xr pthread_atfork 3 , -and the per-thread PRNG state is zeroed on fork in the child via -.Xr minherit 2 -with -.Dv MAP_INHERIT_ZERO , -so that the child cannot reuse or see the parent's PRNG state. -The PRNG state is reseeded automatically from the system entropy pool -on the first use of an -.Nm -function after zeroing. -.Pp -The first use of an -.Nm -function may abort the process in the highly unlikely event that -library initialization necessary to implement the security model fails. -Additionally, -.Fn arc4random_stir -and -.Fn arc4random_addrandom -may abort the process in the highly unlikely event that the operating -system fails to provide entropy. -.Sh SEE ALSO -.Xr rand 3 , -.Xr random 3 , -.Xr rnd 4 , -.Xr cprng 9 -.Rs -.%A Daniel J. Bernstein -.%T ChaCha, a variant of Salsa20 -.%D 2008-01-28 -.%O Document ID: 4027b5256e17b9796842e6d0f68b0b5e -.%U http://cr.yp.to/papers.html#chacha -.Re -.Sh BUGS -There is no way to get deterministic, reproducible results out of -.Nm -for testing purposes. -.Pp -The name -.Sq arc4random -was chosen for hysterical raisins -- it was originally implemented -using the RC4 stream cipher, which has been known since shortly after -it was published in 1994 to have observable biases in the output, and -is now known to be broken badly enough to admit practical attacks in -the real world. -.\" Bob Jenkins, sci.crypt post dated 1994-09-16, message-id -.\" <359qjg$55v$1@mhadg.production.compuserve.com>, -.\" https://groups.google.com/d/msg/sci.crypt/JsO3xEATGFA/-wO4ttv7BCYJ -.\" -.\" Andrew Roos, `A Class of Weak Keys in the RC4 Stream Cipher', -.\" sci.crypt posts dated 1995-09-22, message-ids -.\" <43u1eh$1j3@hermes.is.co.za> and <44ebge$llf@hermes.is.co.za>. -.\" -.\" Paul Crowley, `Small bias in RC4 experimentally verified', March -.\" 1998, http://www.ciphergoth.org/crypto/rc4/ -Unfortunately, the library found widespread adoption and the name stuck -before anyone recognized that it was silly. -.Pp -The signature of -.Fn arc4random_addrandom -is silly. -There is no reason to require casts or accept negative lengths: -it should take a -.Vt void * -buffer and a -.Vt size_t -length. -But it's too late to change that now. -.Pp -.Fn arc4random_uniform -does not help to choose integers in [0, -.Fa n ) -uniformly at random when -.Fa n -> 2^32. -.Pp -The security model of -.Nm -is stronger than many applications need, and stronger than other -operating systems provide. -For example, applications encrypting messages with random, but not -secret, initialization vectors need only prevent an adversary from -guessing future outputs, since past outputs will have been published -already. -.Pp -On the one hand, -.Nm -could be marginally faster if it were not necessary to prevent an -adversary who sees the state from predicting past outputs. -On the other hand, there are applications in the wild that use -.Nm -to generate key material, such as OpenSSH, so for the sake of -.Nx -users it would be imprudent to weaken the security model. -On the third hand, relying on the security model of -.Nm -in -.Nx -may lead you to an unpleasant surprise on another operating system -whose implementation of -.Nm -has a weaker security model. -.Pp -One may be tempted to create new APIs to accommodate different -security models and performance constraints without unpleasant -surprises on different operating systems. -This should not be done lightly, though, because there are already too -many different choices, and too many opportunities for programmers to -reach for one and pick the wrong one. diff --git a/lib/libc/gen/arc4random.c b/lib/libc/gen/arc4random.c deleted file mode 100644 index adead46f7..000000000 --- a/lib/libc/gen/arc4random.c +++ /dev/null @@ -1,802 +0,0 @@ -/* $NetBSD: arc4random.c,v 1.30 2015/05/13 23:15:57 justin Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Taylor R. 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. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Legacy arc4random(3) API from OpenBSD reimplemented using the - * ChaCha20 PRF, with per-thread state. - * - * Security model: - * - An attacker who sees some outputs cannot predict past or future - * outputs. - * - An attacker who sees the PRNG state cannot predict past outputs. - * - An attacker who sees a child's PRNG state cannot predict past or - * future outputs in the parent, or in other children. - * - * The arc4random(3) API may abort the process if: - * - * (a) the crypto self-test fails, - * (b) pthread_atfork or thr_keycreate fail, or - * (c) sysctl(KERN_ARND) fails when reseeding the PRNG. - * - * The crypto self-test, pthread_atfork, and thr_keycreate occur only - * once, on the first use of any of the arc4random(3) API. KERN_ARND - * is unlikely to fail later unless the kernel is seriously broken. - */ - -#include -__RCSID("$NetBSD: arc4random.c,v 1.30 2015/05/13 23:15:57 justin Exp $"); - -#include "namespace.h" -#include "reentrant.h" - -#include -#include -#include -#if defined(__minix) -#include -#endif -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(arc4random,_arc4random) -__weak_alias(arc4random_addrandom,_arc4random_addrandom) -__weak_alias(arc4random_buf,_arc4random_buf) -__weak_alias(arc4random_stir,_arc4random_stir) -__weak_alias(arc4random_uniform,_arc4random_uniform) -#endif - -/* - * For standard ChaCha, use le32dec/le32enc. We don't need that for - * the purposes of a nondeterministic random number generator -- we - * don't need to be bit-for-bit compatible over any wire. - */ - -static inline uint32_t -crypto_le32dec(const void *p) -{ - uint32_t v; - - (void)memcpy(&v, p, sizeof v); - - return v; -} - -static inline void -crypto_le32enc(void *p, uint32_t v) -{ - - (void)memcpy(p, &v, sizeof v); -} - -/* ChaCha core */ - -#define crypto_core_OUTPUTBYTES 64 -#define crypto_core_INPUTBYTES 16 -#define crypto_core_KEYBYTES 32 -#define crypto_core_CONSTBYTES 16 - -#define crypto_core_ROUNDS 20 - -static uint32_t -rotate(uint32_t u, unsigned c) -{ - - return (u << c) | (u >> (32 - c)); -} - -#define QUARTERROUND(a, b, c, d) do { \ - (a) += (b); (d) ^= (a); (d) = rotate((d), 16); \ - (c) += (d); (b) ^= (c); (b) = rotate((b), 12); \ - (a) += (b); (d) ^= (a); (d) = rotate((d), 8); \ - (c) += (d); (b) ^= (c); (b) = rotate((b), 7); \ -} while (/*CONSTCOND*/0) - -const uint8_t crypto_core_constant32[16] = "expand 32-byte k"; - -static void -crypto_core(uint8_t *out, const uint8_t *in, const uint8_t *k, - const uint8_t *c) -{ - uint32_t x0,x1,x2,x3,x4,x5,x6,x7,x8,x9,x10,x11,x12,x13,x14,x15; - uint32_t j0,j1,j2,j3,j4,j5,j6,j7,j8,j9,j10,j11,j12,j13,j14,j15; - int i; - - j0 = x0 = crypto_le32dec(c + 0); - j1 = x1 = crypto_le32dec(c + 4); - j2 = x2 = crypto_le32dec(c + 8); - j3 = x3 = crypto_le32dec(c + 12); - j4 = x4 = crypto_le32dec(k + 0); - j5 = x5 = crypto_le32dec(k + 4); - j6 = x6 = crypto_le32dec(k + 8); - j7 = x7 = crypto_le32dec(k + 12); - j8 = x8 = crypto_le32dec(k + 16); - j9 = x9 = crypto_le32dec(k + 20); - j10 = x10 = crypto_le32dec(k + 24); - j11 = x11 = crypto_le32dec(k + 28); - j12 = x12 = crypto_le32dec(in + 0); - j13 = x13 = crypto_le32dec(in + 4); - j14 = x14 = crypto_le32dec(in + 8); - j15 = x15 = crypto_le32dec(in + 12); - - for (i = crypto_core_ROUNDS; i > 0; i -= 2) { - QUARTERROUND( x0, x4, x8,x12); - QUARTERROUND( x1, x5, x9,x13); - QUARTERROUND( x2, x6,x10,x14); - QUARTERROUND( x3, x7,x11,x15); - QUARTERROUND( x0, x5,x10,x15); - QUARTERROUND( x1, x6,x11,x12); - QUARTERROUND( x2, x7, x8,x13); - QUARTERROUND( x3, x4, x9,x14); - } - - crypto_le32enc(out + 0, x0 + j0); - crypto_le32enc(out + 4, x1 + j1); - crypto_le32enc(out + 8, x2 + j2); - crypto_le32enc(out + 12, x3 + j3); - crypto_le32enc(out + 16, x4 + j4); - crypto_le32enc(out + 20, x5 + j5); - crypto_le32enc(out + 24, x6 + j6); - crypto_le32enc(out + 28, x7 + j7); - crypto_le32enc(out + 32, x8 + j8); - crypto_le32enc(out + 36, x9 + j9); - crypto_le32enc(out + 40, x10 + j10); - crypto_le32enc(out + 44, x11 + j11); - crypto_le32enc(out + 48, x12 + j12); - crypto_le32enc(out + 52, x13 + j13); - crypto_le32enc(out + 56, x14 + j14); - crypto_le32enc(out + 60, x15 + j15); -} - -/* ChaCha self-test */ - -#ifdef _DIAGNOSTIC - -/* - * Test vector for ChaCha20 from - * , - * test vectors for ChaCha12 and ChaCha8 and for big-endian machines - * generated by the same crypto_core code with crypto_core_ROUNDS and - * crypto_le32enc/dec varied. - */ - -static const uint8_t crypto_core_selftest_vector[64] = { -#if _BYTE_ORDER == _LITTLE_ENDIAN -# if crypto_core_ROUNDS == 8 - 0x3e,0x00,0xef,0x2f,0x89,0x5f,0x40,0xd6, - 0x7f,0x5b,0xb8,0xe8,0x1f,0x09,0xa5,0xa1, - 0x2c,0x84,0x0e,0xc3,0xce,0x9a,0x7f,0x3b, - 0x18,0x1b,0xe1,0x88,0xef,0x71,0x1a,0x1e, - 0x98,0x4c,0xe1,0x72,0xb9,0x21,0x6f,0x41, - 0x9f,0x44,0x53,0x67,0x45,0x6d,0x56,0x19, - 0x31,0x4a,0x42,0xa3,0xda,0x86,0xb0,0x01, - 0x38,0x7b,0xfd,0xb8,0x0e,0x0c,0xfe,0x42, -# elif crypto_core_ROUNDS == 12 - 0x9b,0xf4,0x9a,0x6a,0x07,0x55,0xf9,0x53, - 0x81,0x1f,0xce,0x12,0x5f,0x26,0x83,0xd5, - 0x04,0x29,0xc3,0xbb,0x49,0xe0,0x74,0x14, - 0x7e,0x00,0x89,0xa5,0x2e,0xae,0x15,0x5f, - 0x05,0x64,0xf8,0x79,0xd2,0x7a,0xe3,0xc0, - 0x2c,0xe8,0x28,0x34,0xac,0xfa,0x8c,0x79, - 0x3a,0x62,0x9f,0x2c,0xa0,0xde,0x69,0x19, - 0x61,0x0b,0xe8,0x2f,0x41,0x13,0x26,0xbe, -# elif crypto_core_ROUNDS == 20 - 0x76,0xb8,0xe0,0xad,0xa0,0xf1,0x3d,0x90, - 0x40,0x5d,0x6a,0xe5,0x53,0x86,0xbd,0x28, - 0xbd,0xd2,0x19,0xb8,0xa0,0x8d,0xed,0x1a, - 0xa8,0x36,0xef,0xcc,0x8b,0x77,0x0d,0xc7, - 0xda,0x41,0x59,0x7c,0x51,0x57,0x48,0x8d, - 0x77,0x24,0xe0,0x3f,0xb8,0xd8,0x4a,0x37, - 0x6a,0x43,0xb8,0xf4,0x15,0x18,0xa1,0x1c, - 0xc3,0x87,0xb6,0x69,0xb2,0xee,0x65,0x86, -# else -# error crypto_core_ROUNDS must be 8, 12, or 20. -# endif -#elif _BYTE_ORDER == _BIG_ENDIAN -# if crypto_core_ROUNDS == 8 - 0x9a,0x13,0x07,0xe3,0x38,0x18,0x9e,0x99, - 0x15,0x37,0x16,0x4d,0x04,0xe6,0x48,0x9a, - 0x07,0xd6,0xe8,0x7a,0x02,0xf9,0xf5,0xc7, - 0x3f,0xa9,0xc2,0x0a,0xe1,0xc6,0x62,0xea, - 0x80,0xaf,0xb6,0x51,0xca,0x52,0x43,0x87, - 0xe3,0xa6,0xa6,0x61,0x11,0xf5,0xe6,0xcf, - 0x09,0x0f,0xdc,0x9d,0xc3,0xc3,0xbb,0x43, - 0xd7,0xfa,0x70,0x42,0xbf,0xa5,0xee,0xa2, -# elif crypto_core_ROUNDS == 12 - 0xcf,0x6c,0x16,0x48,0xbf,0xf4,0xba,0x85, - 0x32,0x69,0xd3,0x98,0xc8,0x7d,0xcd,0x3f, - 0xdc,0x76,0x6b,0xa2,0x7b,0xcb,0x17,0x4d, - 0x05,0xda,0xdd,0xd8,0x62,0x54,0xbf,0xe0, - 0x65,0xed,0x0e,0xf4,0x01,0x7e,0x3c,0x05, - 0x35,0xb2,0x7a,0x60,0xf3,0x8f,0x12,0x33, - 0x24,0x60,0xcd,0x85,0xfe,0x4c,0xf3,0x39, - 0xb1,0x0e,0x3e,0xe0,0xba,0xa6,0x2f,0xa9, -# elif crypto_core_ROUNDS == 20 - 0x83,0x8b,0xf8,0x75,0xf7,0xde,0x9d,0x8c, - 0x33,0x14,0x72,0x28,0xd1,0xbe,0x88,0xe5, - 0x94,0xb5,0xed,0xb8,0x56,0xb5,0x9e,0x0c, - 0x64,0x6a,0xaf,0xd9,0xa7,0x49,0x10,0x59, - 0xba,0x3a,0x82,0xf8,0x4a,0x70,0x9c,0x00, - 0x82,0x2c,0xae,0xc6,0xd7,0x1c,0x2e,0xda, - 0x2a,0xfb,0x61,0x70,0x2b,0xd1,0xbf,0x8b, - 0x95,0xbc,0x23,0xb6,0x4b,0x60,0x02,0xec, -# else -# error crypto_core_ROUNDS must be 8, 12, or 20. -# endif -#else -# error Byte order must be little-endian or big-endian. -#endif -}; - -static int -crypto_core_selftest(void) -{ - const uint8_t nonce[crypto_core_INPUTBYTES] = {0}; - const uint8_t key[crypto_core_KEYBYTES] = {0}; - uint8_t block[64]; - unsigned i; - - crypto_core(block, nonce, key, crypto_core_constant32); - for (i = 0; i < 64; i++) { - if (block[i] != crypto_core_selftest_vector[i]) - return EIO; - } - - return 0; -} - -#else /* !_DIAGNOSTIC */ - -static int -crypto_core_selftest(void) -{ - - return 0; -} - -#endif - -/* PRNG */ - -/* - * For a state s, rather than use ChaCha20 as a stream cipher to - * generate the concatenation ChaCha20_s(0) || ChaCha20_s(1) || ..., we - * split ChaCha20_s(0) into s' || x and yield x for the first request, - * split ChaCha20_s'(0) into s'' || y and yield y for the second - * request, &c. This provides backtracking resistance: an attacker who - * finds s'' can't recover s' or x. - */ - -#define crypto_prng_SEEDBYTES crypto_core_KEYBYTES -#define crypto_prng_MAXOUTPUTBYTES \ - (crypto_core_OUTPUTBYTES - crypto_prng_SEEDBYTES) - -struct crypto_prng { - uint8_t state[crypto_prng_SEEDBYTES]; -}; - -static void -crypto_prng_seed(struct crypto_prng *prng, const void *seed) -{ - - (void)memcpy(prng->state, seed, crypto_prng_SEEDBYTES); -} - -static void -crypto_prng_buf(struct crypto_prng *prng, void *buf, size_t n) -{ - const uint8_t nonce[crypto_core_INPUTBYTES] = {0}; - uint8_t output[crypto_core_OUTPUTBYTES]; - - _DIAGASSERT(n <= crypto_prng_MAXOUTPUTBYTES); - __CTASSERT(sizeof prng->state + crypto_prng_MAXOUTPUTBYTES - <= sizeof output); - - crypto_core(output, nonce, prng->state, crypto_core_constant32); - (void)memcpy(prng->state, output, sizeof prng->state); - (void)memcpy(buf, output + sizeof prng->state, n); - (void)explicit_memset(output, 0, sizeof output); -} - -/* One-time stream: expand short single-use secret into long secret */ - -#define crypto_onetimestream_SEEDBYTES crypto_core_KEYBYTES - -static void -crypto_onetimestream(const void *seed, void *buf, size_t n) -{ - uint32_t nonce[crypto_core_INPUTBYTES / sizeof(uint32_t)] = {0}; - uint8_t block[crypto_core_OUTPUTBYTES]; - uint8_t *p8, *p32; - const uint8_t *nonce8 = (const uint8_t *)(void *)nonce; - size_t ni, nb, nf; - - /* - * Guarantee we can generate up to n bytes. We have - * 2^(8*INPUTBYTES) possible inputs yielding output of - * OUTPUTBYTES*2^(8*INPUTBYTES) bytes. It suffices to require - * that sizeof n > (1/CHAR_BIT) log_2 n be less than - * (1/CHAR_BIT) log_2 of the total output stream length. We - * have - * - * log_2 (o 2^(8 i)) = log_2 o + log_2 2^(8 i) - * = log_2 o + 8 i. - */ - __CTASSERT(CHAR_BIT * sizeof n <= - (/*LINTED*/ilog2(crypto_core_OUTPUTBYTES) + 8 * crypto_core_INPUTBYTES)); - - p8 = buf; - p32 = (uint8_t *)roundup2((uintptr_t)p8, 4); - ni = p32 - p8; - if (n < ni) - ni = n; - nb = (n - ni) / sizeof block; - nf = (n - ni) % sizeof block; - - _DIAGASSERT(((uintptr_t)p32 & 3) == 0); - _DIAGASSERT(ni <= n); - _DIAGASSERT(nb <= (n / sizeof block)); - _DIAGASSERT(nf <= n); - _DIAGASSERT(n == (ni + (nb * sizeof block) + nf)); - _DIAGASSERT(ni < 4); - _DIAGASSERT(nf < sizeof block); - - if (ni) { - crypto_core(block, nonce8, seed, crypto_core_constant32); - nonce[0]++; - (void)memcpy(p8, block, ni); - } - while (nb--) { - crypto_core(p32, nonce8, seed, crypto_core_constant32); - if (++nonce[0] == 0) - nonce[1]++; - p32 += crypto_core_OUTPUTBYTES; - } - if (nf) { - crypto_core(block, nonce8, seed, crypto_core_constant32); - if (++nonce[0] == 0) - nonce[1]++; - (void)memcpy(p32, block, nf); - } - - if (ni | nf) - (void)explicit_memset(block, 0, sizeof block); -} - -/* arc4random state: per-thread, per-process (zeroed in child on fork) */ - -struct arc4random_prng { - struct crypto_prng arc4_prng; - bool arc4_seeded; -}; - -static void -arc4random_prng_addrandom(struct arc4random_prng *prng, const void *data, - size_t datalen) -{ -#if !defined(__minix) - const int mib[] = { CTL_KERN, KERN_ARND }; -#endif /* !defined(__minix) */ - SHA256_CTX ctx; - uint8_t buf[crypto_prng_SEEDBYTES]; - size_t buflen = sizeof buf; - - __CTASSERT(sizeof buf == SHA256_DIGEST_LENGTH); - - SHA256_Init(&ctx); - - crypto_prng_buf(&prng->arc4_prng, buf, sizeof buf); - SHA256_Update(&ctx, buf, sizeof buf); - -#if defined(__minix) - /* LSC: We do not have a compatibility layer for the - * KERN_ARND call, so do it the old way... */ - int fd; - - fd = open("/dev/urandom", O_RDONLY); - if (fd != -1) { - (void)read(fd, buf, buflen); - close(fd); - } - - /* fd < 0 or failed sysctl ? Ah, what the heck. We'll just take - * whatever was on the stack... */ -#else - if (sysctl(mib, (u_int)__arraycount(mib), buf, &buflen, NULL, 0) == -1) - abort(); -#endif /* !defined(__minix) */ - if (buflen != sizeof buf) - abort(); - SHA256_Update(&ctx, buf, sizeof buf); - - if (data != NULL) - SHA256_Update(&ctx, data, datalen); - - SHA256_Final(buf, &ctx); - (void)explicit_memset(&ctx, 0, sizeof ctx); - - /* reseed(SHA256(prng() || sysctl(KERN_ARND) || data)) */ - crypto_prng_seed(&prng->arc4_prng, buf); - (void)explicit_memset(buf, 0, sizeof buf); - prng->arc4_seeded = true; -} - -#ifdef _REENTRANT -static struct arc4random_prng * -arc4random_prng_create(void) -{ - struct arc4random_prng *prng; - const size_t size = roundup(sizeof(*prng), sysconf(_SC_PAGESIZE)); - - prng = mmap(NULL, size, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANON, -1, 0); - if (prng == MAP_FAILED) - goto fail0; - if (minherit(prng, size, MAP_INHERIT_ZERO) == -1) - goto fail1; - - return prng; - -fail1: (void)munmap(prng, size); -fail0: return NULL; -} -#endif - -#ifdef _REENTRANT -static void -arc4random_prng_destroy(struct arc4random_prng *prng) -{ - const size_t size = roundup(sizeof(*prng), sysconf(_SC_PAGESIZE)); - - (void)explicit_memset(prng, 0, sizeof(*prng)); - (void)munmap(prng, size); -} -#endif - -/* Library state */ - -static struct arc4random_global { -#ifdef _REENTRANT - mutex_t lock; - thread_key_t thread_key; -#endif - struct arc4random_prng prng; - bool initialized; -} arc4random_global = { -#ifdef _REENTRANT - .lock = MUTEX_INITIALIZER, -#endif - .initialized = false, -}; - -static void -arc4random_atfork_prepare(void) -{ - - mutex_lock(&arc4random_global.lock); - (void)explicit_memset(&arc4random_global.prng, 0, - sizeof arc4random_global.prng); -} - -static void -arc4random_atfork_parent(void) -{ - - mutex_unlock(&arc4random_global.lock); -} - -static void -arc4random_atfork_child(void) -{ - - mutex_unlock(&arc4random_global.lock); -} - -#ifdef _REENTRANT -static void -arc4random_tsd_destructor(void *p) -{ - struct arc4random_prng *const prng = p; - - arc4random_prng_destroy(prng); -} -#endif - -static void -arc4random_initialize(void) -{ - - mutex_lock(&arc4random_global.lock); - if (!arc4random_global.initialized) { - if (crypto_core_selftest() != 0) - abort(); -#if !defined(__minix) - if (pthread_atfork(&arc4random_atfork_prepare, - &arc4random_atfork_parent, &arc4random_atfork_child) - != 0) - abort(); -#endif /* !defined(__minix) */ -#ifdef _REENTRANT - if (thr_keycreate(&arc4random_global.thread_key, - &arc4random_tsd_destructor) != 0) - abort(); -#endif - arc4random_global.initialized = true; - } - mutex_unlock(&arc4random_global.lock); -} - -static struct arc4random_prng * -arc4random_prng_get(void) -{ - struct arc4random_prng *prng = NULL; - - /* Make sure the library is initialized. */ - if (__predict_false(!arc4random_global.initialized)) - arc4random_initialize(); - -#ifdef _REENTRANT - /* Get or create the per-thread PRNG state. */ - prng = thr_getspecific(arc4random_global.thread_key); - if (__predict_false(prng == NULL)) { - prng = arc4random_prng_create(); - thr_setspecific(arc4random_global.thread_key, prng); - } -#endif - - /* If we can't create it, fall back to the global PRNG. */ - if (__predict_false(prng == NULL)) { - mutex_lock(&arc4random_global.lock); - prng = &arc4random_global.prng; - } - - /* Guarantee the PRNG is seeded. */ - if (__predict_false(!prng->arc4_seeded)) - arc4random_prng_addrandom(prng, NULL, 0); - - return prng; -} - -static void -arc4random_prng_put(struct arc4random_prng *prng) -{ - - /* If we had fallen back to the global PRNG, unlock it. */ - if (__predict_false(prng == &arc4random_global.prng)) - mutex_unlock(&arc4random_global.lock); -} - -/* Public API */ - -uint32_t -arc4random(void) -{ - struct arc4random_prng *prng; - uint32_t v; - - prng = arc4random_prng_get(); - crypto_prng_buf(&prng->arc4_prng, &v, sizeof v); - arc4random_prng_put(prng); - - return v; -} - -void -arc4random_buf(void *buf, size_t len) -{ - struct arc4random_prng *prng; - - if (len <= crypto_prng_MAXOUTPUTBYTES) { - prng = arc4random_prng_get(); - crypto_prng_buf(&prng->arc4_prng, buf, len); - arc4random_prng_put(prng); - } else { - uint8_t seed[crypto_onetimestream_SEEDBYTES]; - - prng = arc4random_prng_get(); - crypto_prng_buf(&prng->arc4_prng, seed, sizeof seed); - arc4random_prng_put(prng); - - crypto_onetimestream(seed, buf, len); - (void)explicit_memset(seed, 0, sizeof seed); - } -} - -uint32_t -arc4random_uniform(uint32_t bound) -{ - struct arc4random_prng *prng; - uint32_t minimum, r; - - /* - * We want a uniform random choice in [0, n), and arc4random() - * makes a uniform random choice in [0, 2^32). If we reduce - * that modulo n, values in [0, 2^32 mod n) will be represented - * slightly more than values in [2^32 mod n, n). Instead we - * choose only from [2^32 mod n, 2^32) by rejecting samples in - * [0, 2^32 mod n), to avoid counting the extra representative - * of [0, 2^32 mod n). To compute 2^32 mod n, note that - * - * 2^32 mod n = 2^32 mod n - 0 - * = 2^32 mod n - n mod n - * = (2^32 - n) mod n, - * - * the last of which is what we compute in 32-bit arithmetic. - */ - minimum = (-bound % bound); - - prng = arc4random_prng_get(); - do crypto_prng_buf(&prng->arc4_prng, &r, sizeof r); - while (__predict_false(r < minimum)); - arc4random_prng_put(prng); - - return (r % bound); -} - -void -arc4random_stir(void) -{ - struct arc4random_prng *prng; - - prng = arc4random_prng_get(); - arc4random_prng_addrandom(prng, NULL, 0); - arc4random_prng_put(prng); -} - -/* - * Silly signature here is for hysterical raisins. Should instead be - * const void *data and size_t datalen. - */ -void -arc4random_addrandom(u_char *data, int datalen) -{ - struct arc4random_prng *prng; - - _DIAGASSERT(0 <= datalen); - - prng = arc4random_prng_get(); - arc4random_prng_addrandom(prng, data, datalen); - arc4random_prng_put(prng); -} - -#ifdef _ARC4RANDOM_TEST - -#include - -#include -#include - -int -main(int argc __unused, char **argv __unused) -{ - unsigned char gubbish[] = "random gubbish"; - const uint8_t zero64[64] = {0}; - uint8_t buf[2048]; - unsigned i, a, n; - - /* Test arc4random: should not be deterministic. */ - if (printf("arc4random: %08"PRIx32"\n", arc4random()) < 0) - err(1, "printf"); - - /* Test stirring: should definitely not be deterministic. */ - arc4random_stir(); - - /* Test small buffer. */ - arc4random_buf(buf, 8); - if (printf("arc4randombuf small:") < 0) - err(1, "printf"); - for (i = 0; i < 8; i++) - if (printf(" %02x", buf[i]) < 0) - err(1, "printf"); - if (printf("\n") < 0) - err(1, "printf"); - - /* Test addrandom: should not make the rest deterministic. */ - arc4random_addrandom(gubbish, sizeof gubbish); - - /* Test large buffer. */ - arc4random_buf(buf, sizeof buf); - if (printf("arc4randombuf_large:") < 0) - err(1, "printf"); - for (i = 0; i < sizeof buf; i++) - if (printf(" %02x", buf[i]) < 0) - err(1, "printf"); - if (printf("\n") < 0) - err(1, "printf"); - - /* Test misaligned small and large. */ - for (a = 0; a < 64; a++) { - for (n = a; n < sizeof buf; n++) { - (void)memset(buf, 0, sizeof buf); - arc4random_buf(buf, n - a); - if (memcmp(buf + n - a, zero64, a) != 0) - errx(1, "arc4random buffer overflow 0"); - - (void)memset(buf, 0, sizeof buf); - arc4random_buf(buf + a, n - a); - if (memcmp(buf, zero64, a) != 0) - errx(1, "arc4random buffer overflow 1"); - - if ((2*a) <= n) { - (void)memset(buf, 0, sizeof buf); - arc4random_buf(buf + a, n - a - a); - if (memcmp(buf + n - a, zero64, a) != 0) - errx(1, - "arc4random buffer overflow 2"); - } - } - } - - /* Test fork-safety. */ - { - pid_t pid, rpid; - int status; - - pid = fork(); - switch (pid) { - case -1: - err(1, "fork"); - case 0: - _exit(arc4random_prng_get()->arc4_seeded); - default: - rpid = waitpid(pid, &status, 0); - if (rpid == -1) - err(1, "waitpid"); - if (rpid != pid) - errx(1, "waitpid returned wrong pid" - ": %"PRIdMAX" != %"PRIdMAX, - (intmax_t)rpid, - (intmax_t)pid); - if (WIFEXITED(status)) { - if (WEXITSTATUS(status) != 0) - errx(1, "child exited with %d", - WEXITSTATUS(status)); - } else if (WIFSIGNALED(status)) { - errx(1, "child terminated on signal %d", - WTERMSIG(status)); - } else { - errx(1, "child died mysteriously: %d", status); - } - } - } - - /* XXX Test multithreaded fork safety...? */ - - return 0; -} -#endif diff --git a/lib/libc/gen/assert.c b/lib/libc/gen/assert.c deleted file mode 100644 index 3197671b8..000000000 --- a/lib/libc/gen/assert.c +++ /dev/null @@ -1,135 +0,0 @@ -/* $NetBSD: assert.c,v 1.17 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)assert.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: assert.c,v 1.17 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include - -void -__assert13(const char *file, int line, const char *function, - const char *failedexpr) -{ - - (void)fprintf(stderr, - "assertion \"%s\" failed: file \"%s\", line %d%s%s%s\n", - failedexpr, file, line, - function ? ", function \"" : "", - function ? function : "", - function ? "\"" : ""); - abort(); - /* NOTREACHED */ -} - -void -__assert(const char *file, int line, const char *failedexpr) -{ - - __assert13(file, line, NULL, failedexpr); - /* NOTREACHED */ -} - - -enum { - DIAGASSERT_ABORT = 1<<0, - DIAGASSERT_STDERR = 1<<1, - DIAGASSERT_SYSLOG = 1<<2 -}; - -static int diagassert_flags = -1; - -void -__diagassert13(const char *file, int line, const char *function, - const char *failedexpr) -{ - char buf[1024]; - - if (diagassert_flags == -1) { - char *p; - - diagassert_flags = DIAGASSERT_SYSLOG; - - for (p = getenv("LIBC_DIAGASSERT"); p && *p; p++) { - switch (*p) { - case 'a': - diagassert_flags |= DIAGASSERT_ABORT; - break; - case 'A': - diagassert_flags &= ~DIAGASSERT_ABORT; - break; - case 'e': - diagassert_flags |= DIAGASSERT_STDERR; - break; - case 'E': - diagassert_flags &= ~DIAGASSERT_STDERR; - break; - case 'l': - diagassert_flags |= DIAGASSERT_SYSLOG; - break; - case 'L': - diagassert_flags &= ~DIAGASSERT_SYSLOG; - break; - } - } - } - - snprintf(buf, sizeof(buf), - "assertion \"%s\" failed: file \"%s\", line %d%s%s%s", - failedexpr, file, line, - function ? ", function \"" : "", - function ? function : "", - function ? "\"" : ""); - if (diagassert_flags & DIAGASSERT_STDERR) - (void)fprintf(stderr, "%s: %s\n", getprogname(), buf); - if (diagassert_flags & DIAGASSERT_SYSLOG) - syslog(LOG_DEBUG | LOG_USER, "%s", buf); - if (diagassert_flags & DIAGASSERT_ABORT) - abort(); -} - -void -__diagassert(const char *file, int line, const char *failedexpr) -{ - - __diagassert13(file, line, NULL, failedexpr); -} diff --git a/lib/libc/gen/asysctl.c b/lib/libc/gen/asysctl.c deleted file mode 100644 index c5201c699..000000000 --- a/lib/libc/gen/asysctl.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: asysctl.c,v 1.1 2014/06/13 15:45:05 joerg Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Joerg Sonnenberger. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__RCSID("$NetBSD: asysctl.c,v 1.1 2014/06/13 15:45:05 joerg Exp $"); - -#include "namespace.h" -#include -#include -#include -#include - -__weak_alias(asysctl,_asysctl) -__weak_alias(asysctlbyname,_asysctlbyname) - -void * -asysctl(const int *oids, size_t oidlen, size_t *len) -{ - void *data; - - *len = 0; - data = NULL; - - for (;;) { - if (sysctl(oids, oidlen, data, len, NULL, 0) == 0) { - if (*len == 0) { - free(data); - return NULL; - } - if (data != NULL) - return data; - errno = ENOMEM; - } - free(data); - if (errno == ENOMEM && *len != SIZE_MAX) { - if (*len > SIZE_MAX / 2) - *len = SIZE_MAX; - else - *len *= 2; - data = malloc(*len); - if (data == NULL) { - *len = SIZE_MAX; - return NULL; - } - continue; - } - *len = SIZE_MAX; - return NULL; - } -} - -void * -asysctlbyname(const char *gname, size_t *len) -{ - int name[CTL_MAXNAME]; - u_int namelen; - - if (sysctlgetmibinfo(gname, &name[0], &namelen, NULL, NULL, NULL, - SYSCTL_VERSION)) { - *len = SIZE_MAX; - return NULL; - } - return asysctl(&name[0], namelen, len); -} diff --git a/lib/libc/gen/basename.3 b/lib/libc/gen/basename.3 deleted file mode 100644 index 7fe1e96d1..000000000 --- a/lib/libc/gen/basename.3 +++ /dev/null @@ -1,95 +0,0 @@ -.\" $NetBSD: basename.3,v 1.14 2008/05/10 22:39:40 christos Exp $ -.\" -.\" Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein and Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd May 10, 2008 -.Dt BASENAME 3 -.Os -.Sh NAME -.Nm basename -.Nd return the last component of a pathname -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In libgen.h -.Ft char * -.Fn basename "char *path" -.Sh DESCRIPTION -The -.Fn basename -function takes the pathname pointed to by -.Ar path -and returns a pointer to the final component of the pathname, -deleting any trailing -.Sq / -characters. -.Pp -If -.Ar path -consists entirely of -.Sq / -characters, -.Fn basename -returns a pointer to the string -.Dq / . -.Pp -If -.Ar path -is a null pointer or points to an empty string, -.Fn basename -returns a pointer to the string -.Dq \&. . -.Sh RETURN VALUES -The -.Fn basename -function returns a pointer to the final component of -.Ar path . -.Sh SEE ALSO -.Xr basename 1 , -.Xr dirname 3 -.Sh STANDARDS -.Bl -bullet -compact -.It -.St -xpg4.2 -.It -.St -p1003.1-2001 -.El -.Sh BUGS -If the length of the result is longer than -.Dv PATH_MAX -bytes -.Pq including the terminating nul , -the result will be truncated. -.Pp -The -.Fn basename -function returns a pointer to static storage that may be overwritten -by subsequent calls to -.Fn basename . -This is not strictly a bug; it is explicitly allowed by -.St -p1003.1-2001 . diff --git a/lib/libc/gen/basename.c b/lib/libc/gen/basename.c deleted file mode 100644 index 03eeba4aa..000000000 --- a/lib/libc/gen/basename.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $NetBSD: basename.c,v 1.11 2014/07/16 10:52:26 christos Exp $ */ - -/*- - * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein and Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: basename.c,v 1.11 2014/07/16 10:52:26 christos Exp $"); -#endif /* !LIBC_SCCS && !lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(basename,_basename) -#endif - -static size_t -xbasename_r(const char *path, char *buf, size_t buflen) -{ - const char *startp, *endp; - size_t len; - - /* - * If `path' is a null pointer or points to an empty string, - * return a pointer to the string ".". - */ - if (path == NULL || *path == '\0') { - startp = "."; - len = 1; - goto out; - } - - /* Strip trailing slashes, if any. */ - endp = path + strlen(path) - 1; - while (endp != path && *endp == '/') - endp--; - - /* Only slashes -> "/" */ - if (endp == path && *endp == '/') { - startp = "/"; - len = 1; - goto out; - } - - /* Now find the beginning of this (final) component. */ - for (startp = endp; startp > path && *(startp - 1) != '/'; startp--) - continue; - - /* ...and copy the result into the result buffer. */ - len = (endp - startp) + 1 /* last char */; -out: - if (buf != NULL && buflen != 0) { - buflen = MIN(len, buflen - 1); - memcpy(buf, startp, buflen); - buf[buflen] = '\0'; - } - return len; -} - -#if !HAVE_BASENAME - -char * -basename(char *path) { - static char result[PATH_MAX]; - - (void)xbasename_r(path, result, sizeof(result)); - return result; -} - -#endif diff --git a/lib/libc/gen/bswap.3 b/lib/libc/gen/bswap.3 deleted file mode 100644 index cb8d03f0e..000000000 --- a/lib/libc/gen/bswap.3 +++ /dev/null @@ -1,54 +0,0 @@ -.\" $NetBSD: bswap.3,v 1.11 2009/10/22 21:50:01 bouyer Exp $ -.\" -.\" Copyright (c) 1998 Manuel Bouyer. -.\" -.\" 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 ``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. -.\" -.Dd March 17, 1998 -.Dt BSWAP 3 -.Os -.Sh NAME -.Nm bswap16 , -.Nm bswap32 , -.Nm bswap64 -.Nd byte-order swapping functions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In machine/bswap.h -.Ft uint16_t -.Fn bswap16 "uint16_t" -.Ft uint32_t -.Fn bswap32 "uint32_t" -.Ft uint64_t -.Fn bswap64 "uint64_t" -.Sh DESCRIPTION -The -.Fn bswap16 , -.Fn bswap32 , -and -.Fn bswap64 -functions return the value of their argument with the bytes inverted. -They can be used to convert 16, 32 or 64 bits integers from little to big -endian, or vice-versa. -.Sh SEE ALSO -.Xr byteorder 3 diff --git a/lib/libc/gen/cgetcap.3 b/lib/libc/gen/cgetcap.3 deleted file mode 100644 index 5854c1d26..000000000 --- a/lib/libc/gen/cgetcap.3 +++ /dev/null @@ -1,373 +0,0 @@ -.\" $NetBSD: cgetcap.3,v 1.8 2012/04/22 10:13:52 wiz Exp $ -.\" -.\" Copyright (c) 1992, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Casey Leedom of Lawrence Livermore National Laboratory. -.\" -.\" 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. -.\" -.\" @(#)getcap.3 8.4 (Berkeley) 5/13/94 -.\" -.Dd April 5, 2012 -.Dt CGETCAP 3 -.Os -.Sh NAME -.Nm cgetent , -.Nm cgetset , -.Nm cgetmatch , -.Nm cgetcap , -.Nm cgetnum , -.Nm cgetstr , -.Nm cgetustr , -.Nm cgetfirst , -.Nm cgetnext , -.Nm cgetclose , -.Nm cexpandtc -.Nd capability database access routines -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft int -.Fn cgetent "char **buf" "const char * const *db_array" "const char *name" -.Ft int -.Fn cgetset "const char *ent" -.Ft int -.Fn cgetmatch "const char *buf" "const char *name" -.Ft char * -.Fn cgetcap "char *buf" "const char *cap" "int type" -.Ft int -.Fn cgetnum "char *buf" "const char *cap" "long *num" -.Ft int -.Fn cgetstr "char *buf" "const char *cap" "char **str" -.Ft int -.Fn cgetustr "char *buf" "const char *cap" "char **str" -.Ft int -.Fn cgetfirst "char **buf" "const char * const *db_array" -.Ft int -.Fn cgetnext "char **buf" "const char * const *db_array" -.Ft int -.Fn cgetclose "void" -.Ft void -.Fn csetexpandtc "int expandtc" -.Sh DESCRIPTION -.Fn cgetent -extracts the capability -.Fa name -from the database specified by the -.Dv NULL -terminated file array -.Fa db_array -and returns a pointer to a -.Xr malloc 3 Ap d -copy of it in -.Fa buf . -.Fn cgetent -will first look for files ending in -.Pa .db -(see -.Xr cap_mkdb 1 ) -before accessing the -.Tn ASCII -file. -.Pp -.Fa buf -must be retained through all subsequent calls to -.Fn cgetmatch , -.Fn cgetcap , -.Fn cgetnum , -.Fn cgetstr , -and -.Fn cgetustr , -but may then be -.Xr free 3 Ap d . -.Pp -On success 0 is returned, 1 if the returned record contains an unresolved -.Qq tc -expansion, \-1 if the requested record couldn't be found, \-2 if -a system error was encountered (couldn't open/read a file, etc.) -also setting -.Va errno , -and \-3 if a potential reference loop is detected (see -.Qq tc=name -comments below). -.Pp -.Fn cgetset -enables the addition of a character buffer containing a single capability -record entry to the capability database. -Conceptually, the entry is added as the first -.Dq file -in the database, and -is therefore searched first on the call to -.Fn cgetent . -The entry is passed in -.Fa ent . -If -.Fa ent -is -.Dv NULL , -the current entry is removed from the database. -.Pp -.Fn cgetset -must precede the database traversal. -It must be called before the -.Fn cgetent -call. -If a sequential access is being performed (see below), it must be called -before the first sequential access call -.Po -.Fn cgetfirst -or -.Fn cgetnext -.Pc , -or be directly preceded by a -.Fn cgetclose -call. -On success 0 is returned and \-1 on failure. -.Pp -.Fn cgetmatch -will return 0 if -.Fa name -is one of the names of the capability record -.Fa buf , -\-1 if not. -.Pp -.Fn cgetcap -searches the capability record -.Fa buf -for the capability -.Fa cap -with type -.Fa type . -A -.Fa type -is specified using any single character. -If a colon -.Pq Sq \&: -is used, an untyped capability will be searched -for (see below for explanation of types). -A pointer to the value of -.Fa cap -in -.Fa buf -is returned on success, -.Dv NULL -if the requested capability couldn't be found. -The end of the capability value is signaled by a -.Sq \&: . -See -.Xr capfile 5 -for a description of the capability syntax. -.Pp -.Fn cgetnum -retrieves the value of the numeric capability -.Fa cap -from the capability record pointed to by -.Fa buf . -The numeric value is returned in the -.Ft long -pointed to by -.Fa num . -0 is returned on success, -\-1 if the requested numeric capability couldn't be found. -.Pp -.Fn cgetstr -retrieves the value of the string capability -.Fa cap -from the capability record pointed to by -.Fa buf . -A pointer to a decoded, -.Dv NUL -terminated, -.Xr malloc 3 Ap d -copy of the string is returned in the -.Ft char * -pointed to by -.Fa str . -The number of characters in the decoded string not including the trailing -.Dv NUL -is returned on success, \-1 if the requested string capability couldn't -be found, \-2 if a system error was encountered (storage allocation -failure). -.Pp -.Fn cgetustr -is identical to -.Fn cgetstr -except that it does not expand special characters, but rather returns each -character of the capability string literally. -.Pp -.Fn cgetfirst , -.Fn cgetnext , -comprise a function group that provides for sequential access of the -.Dv NULL -pointer terminated array of file names, -.Fa db_array . -.Fn cgetfirst -returns the first record in the database and resets the access -to the first record. -.Fn cgetnext -returns the next record in the database with respect to the -record returned by the previous -.Fn cgetfirst -or -.Fn cgetnext -call. -If there is no such previous call, -the first record in the database is returned. -Each record is returned in a -.Xr malloc 3 Ap d -copy pointed to by -.Fa buf . -.Qq tc -expansion is done (see -.Qq tc=name -comments below). -.Pp -Upon completion of the database 0 is returned, 1 is returned upon successful -return of record with possibly more remaining (we haven't reached the end of -the database yet), 2 is returned if the record contains an unresolved -.Qq tc -expansion, \-1 is returned if an system error occurred, and \-2 -is returned if a potential reference loop is detected (see -.Qq tc=name -comments below). -Upon completion of database (0 return) the database is closed. -.Pp -.Fn cgetclose -closes the sequential access and frees any memory and file descriptors -being used. -Note that it does not erase the buffer pushed by a call to -.Fn cgetset . -.Sh CAPABILITY DATABASE SEMANTICS -Capability records describe a set of (name, value) bindings. -Names may have multiple values bound to them. -Different values for a name are distinguished by their -.Fa types . -.Fn cgetcap -will return a pointer to a value of a name given the capability name and -the type of the value. -.Pp -The types -.Sq # -and -.Sq = -are conventionally used to denote numeric and -string typed values, but no restriction on those types is enforced. -The functions -.Fn cgetnum -and -.Fn cgetstr -can be used to implement the traditional syntax and semantics of -.Sq # -and -.Sq = . -Typeless capabilities are typically used to denote boolean objects with -presence or absence indicating truth and false values respectively. -This interpretation is conveniently represented by: -.Pp -.Dl "(getcap(buf, name, ':') != NULL)" -.Pp -A special capability, -.Qq tc=name , -is used to indicate that the record specified by -.Fa name -should be substituted for the -.Qq tc -capability. -.Qq tc -capabilities may interpolate records which also contain -.Qq tc -capabilities and more than one -.Qq tc -capability may be used in a record. -A -.Qq tc -expansion scope (i.e. where the argument is searched for) contains the -file in which the -.Qq tc -is declared and all subsequent files in the file array. -.Pp -.Fn csetexpandtc -can be used to control if -.Qq tc -expansion is performed or not. -.Sh DIAGNOSTICS -.Fn cgetent , -.Fn cgetset , -.Fn cgetmatch , -.Fn cgetnum , -.Fn cgetstr , -.Fn cgetustr , -.Fn cgetfirst , -and -.Fn cgetnext -return a value greater than or equal to 0 on success and a value less -than 0 on failure. -.Fn cgetcap -returns a character pointer on success and a -.Dv NULL -on failure. -.Pp -.Fn cgetclose , -.Fn cgetent , -.Fn cgetfirst , -and -.Fn cgetnext -may fail and set -.Va errno -for any of the errors specified for the library functions: -.Xr fopen 3 , -.Xr fclose 3 , -.Xr open 2 , -and -.Xr close 2 . -.Pp -.Fn cgetent , -.Fn cgetset , -.Fn cgetstr , -and -.Fn cgetustr -may fail and set -.Va errno -as follows: -.Bl -tag -width Er -.It Bq Er ENOMEM -No memory to allocate. -.El -.Sh SEE ALSO -.Xr cap_mkdb 1 , -.Xr malloc 3 , -.Xr capfile 5 -.Sh BUGS -There are no checks for -.Qq tc=name -loops in -.Fn cgetent . -.Pp -The buffer added to the database by a call to -.Fn cgetset -is not unique to the database but is rather prepended to any database used. diff --git a/lib/libc/gen/clock.3 b/lib/libc/gen/clock.3 deleted file mode 100644 index 678e7ac9d..000000000 --- a/lib/libc/gen/clock.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" $NetBSD: clock.3,v 1.10 2003/08/07 16:42:46 agc Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)clock.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt CLOCK 3 -.Os -.Sh NAME -.Nm clock -.Nd determine processor time used -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In time.h -.Ft clock_t -.Fn clock void -.Sh DESCRIPTION -The -.Fn clock -function -determines the amount of processor time used since the invocation of the -calling process, measured in -.Dv CLOCKS_PER_SEC Ns s . -.Sh RETURN VALUES -The -.Fn clock -function returns the amount of time used unless an error occurs, in which -case the return value is \-1. -.Sh SEE ALSO -.Xr getrusage 2 -.Sh STANDARDS -The -.Fn clock -function conforms to -.St -ansiC . diff --git a/lib/libc/gen/clock.c b/lib/libc/gen/clock.c deleted file mode 100644 index a50e9d430..000000000 --- a/lib/libc/gen/clock.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: clock.c,v 1.10 2009/01/11 02:46:27 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)clock.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: clock.c,v 1.10 2009/01/11 02:46:27 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include - -/* - * This code is all rather silly because the kernel counts actual - * execution time (to usec accuracy) then splits it into user, system and - * interrupt based on when clock ticks happen. getrusage apportions the - * time based on the number of ticks, and here we are trying to generate - * a number which was, traditionally, the number of ticks! - * - * Due to the way the time is apportioned, this code (and indeed getrusage - * itself) are not guaranteed monotonic. - */ - -clock_t -clock(void) -{ - struct rusage ru; - clock_t hz = CLOCKS_PER_SEC; - - if (getrusage(RUSAGE_SELF, &ru)) - return ((clock_t) -1); - return (clock_t)((ru.ru_utime.tv_sec + ru.ru_stime.tv_sec) * hz + - (ru.ru_utime.tv_usec + ru.ru_stime.tv_usec + 50) - / 100 * hz / 10000); -} diff --git a/lib/libc/gen/closedir.c b/lib/libc/gen/closedir.c deleted file mode 100644 index 432019792..000000000 --- a/lib/libc/gen/closedir.c +++ /dev/null @@ -1,85 +0,0 @@ -/* $NetBSD: closedir.c,v 1.16 2010/09/26 02:26:59 yamt Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)closedir.c 8.1 (Berkeley) 6/10/93"; -#else -__RCSID("$NetBSD: closedir.c,v 1.16 2010/09/26 02:26:59 yamt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include "extern.h" -#include - -#include -#include -#include -#include -#include - -#include "dirent_private.h" - -#ifdef __weak_alias -__weak_alias(closedir,_closedir) -#endif - -/* - * close a directory. - */ -int -closedir(DIR *dirp) -{ - int fd; - - _DIAGASSERT(dirp != NULL); - -#ifdef _REENTRANT - if (__isthreaded) - mutex_lock((mutex_t *)dirp->dd_lock); -#endif - fd = dirp->dd_fd; - dirp->dd_fd = -1; - _finidir(dirp); - -#ifdef _REENTRANT - if (__isthreaded) { - mutex_unlock((mutex_t *)dirp->dd_lock); - mutex_destroy((mutex_t *)dirp->dd_lock); - free(dirp->dd_lock); - } -#endif - free((void *)dirp); - return(close(fd)); -} diff --git a/lib/libc/gen/closefrom.3 b/lib/libc/gen/closefrom.3 deleted file mode 100644 index 82368a094..000000000 --- a/lib/libc/gen/closefrom.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" $NetBSD: closefrom.3,v 1.5 2004/06/01 16:12:51 kleink Exp $ -.\" $OpenBSD: closefrom.2,v 1.2 2004/01/12 20:52:09 jmc Exp $ -.\" -.\" Copyright (c) 2004 Ted Unangst. 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. -.Dd June 1, 2004 -.Dt CLOSEFROM 3 -.Os -.Sh NAME -.Nm closefrom -.Nd delete many descriptors -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn closefrom "int fd" -.Sh DESCRIPTION -The -.Fn closefrom -call deletes all descriptors numbered -.Fa fd -and higher from the per-process file descriptor table. -It is effectively the same as calling -.Xr close 2 -on each descriptor. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, a value of \-1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn closefrom -will fail if: -.Bl -tag -width Er -.It Bq Er EBADF -.Fa fd -is invalid. -.It Bq Er EINTR -An interrupt was received. -.El -.Sh SEE ALSO -.Xr close 2 diff --git a/lib/libc/gen/closefrom.c b/lib/libc/gen/closefrom.c deleted file mode 100644 index 4d84c0997..000000000 --- a/lib/libc/gen/closefrom.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: closefrom.c,v 1.2 2004/06/22 13:49:43 atatat Exp $ */ - -/* - * Copyright (C) 2004 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: closefrom.c,v 1.2 2004/06/22 13:49:43 atatat Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -closefrom(int fd) -{ - - return (fcntl(fd, F_CLOSEM)); -} diff --git a/lib/libc/gen/confstr.3 b/lib/libc/gen/confstr.3 deleted file mode 100644 index 17c5a5e57..000000000 --- a/lib/libc/gen/confstr.3 +++ /dev/null @@ -1,134 +0,0 @@ -.\" $NetBSD: confstr.3,v 1.20 2010/04/22 08:00:34 jruoho Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)confstr.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 22, 2010 -.Dt CONFSTR 3 -.Os -.Sh NAME -.Nm confstr -.Nd get string-valued configurable variables -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft size_t -.Fn confstr "int name" "char *buf" "size_t len" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by -.Xr sysctl 3 . -.Ef -.Pp -The -.Fn confstr -function provides a method for applications to get configuration -defined string values. -.Pp -The -.Fa name -argument specifies the system variable to be queried. -Symbolic constants for each name value are found in the -.In unistd.h -header. -The -.Fa len -argument specifies the size of the buffer referenced by the -argument -.Fa buf . -If -.Fa len -is non-zero, -.Fa buf -is a non-null pointer, and -.Fa name -has a value, up to -.Fa len -\- 1 bytes of the value are copied into the buffer -.Fa buf . -The copied value is always null terminated. -.Pp -The available values are as follows: -.Pp -.Bl -tag -width "123456" -.It Li _CS_PATH -Return a value for the -.Ev PATH -environment variable that finds all the standard utilities. -.El -.Sh RETURN VALUES -If the call to -.Nm confstr -is not successful, 0 is returned and -.Va errno -is set appropriately. -Otherwise, if the variable does not have a configuration defined value, -0 is returned and -.Va errno -is not modified. -Otherwise, the buffer size needed to hold the entire configuration-defined -value is returned. -If this size is greater than the argument -.Fa len , -the string in -.Fa buf -was truncated. -.Sh ERRORS -The -.Nm confstr -function may fail and set -.Va error -for any of the errors specified for the library functions -.Xr malloc 3 -and -.Xr sysctl 3 . -.Pp -In addition, the following errors may be reported: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of the -.Fa name -argument is invalid. -.El -.Sh SEE ALSO -.Xr sysctl 3 -.Sh STANDARDS -The -.Nm confstr -function conforms to -.St -p1003.2-92 . -.Sh HISTORY -The -.Nm confstr -function first appeared in -.Bx 4.4 . -.Sh BUGS -The standards require us to return 0 both on errors, and when the value -is not set. diff --git a/lib/libc/gen/confstr.c b/lib/libc/gen/confstr.c deleted file mode 100644 index 1160908c6..000000000 --- a/lib/libc/gen/confstr.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: confstr.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)confstr.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: confstr.c,v 1.13 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(confstr,_confstr) -#endif - -size_t -confstr(int name, char *buf, size_t len) -{ - size_t tlen; - int mib[2], sverrno; - char *p; - - /* - * POSIX 1003.2 requires errors to return 0 -- - * that is *really* useful. - */ - switch (name) { - case _CS_PATH: - mib[0] = CTL_USER; - mib[1] = USER_CS_PATH; - if (sysctl(mib, 2, NULL, &tlen, NULL, 0) == -1) - return 0; - if (len != 0 && buf != NULL) { - if ((p = malloc(tlen)) == NULL) - return 0; - if (sysctl(mib, 2, p, &tlen, NULL, 0) == -1) { - sverrno = errno; - free(p); - errno = sverrno; - return 0; - } - /* - * POSIX 1003.2 requires partial return of - * the string -- that is even more useful. - */ - (void)strncpy(buf, p, len - 1); - buf[len - 1] = '\0'; - free(p); - } - return tlen + 1; - default: - errno = EINVAL; - return 0; - } - /* NOTREACHED */ -} diff --git a/lib/libc/gen/cpuset.3 b/lib/libc/gen/cpuset.3 deleted file mode 100644 index 8a3298377..000000000 --- a/lib/libc/gen/cpuset.3 +++ /dev/null @@ -1,119 +0,0 @@ -.\" $NetBSD: cpuset.3,v 1.6 2011/11/02 20:25:20 wiz Exp $ -.\" -.\" Copyright (c) 2008 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Mindaugas Rasiukevicius . -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd November 2, 2011 -.Dt CPUSET 3 -.Os -.Sh NAME -.Nm cpuset_create , -.Nm cpuset_destroy , -.Nm cpuset_zero , -.Nm cpuset_set , -.Nm cpuset_clr , -.Nm cpuset_isset , -.Nm cpuset_size -.Nd dynamic CPU sets -.Sh SYNOPSIS -.In sched.h -.Ft cpuset_t * -.Fn cpuset_create "void" -.Ft void -.Fn cpuset_destroy "cpuset_t *set" -.Ft void -.Fn cpuset_zero "cpuset_t *set" -.Ft int -.Fn cpuset_set "cpuid_t cpu" "cpuset_t *set" -.Ft int -.Fn cpuset_clr "cpuid_t cpu" "cpuset_t *set" -.Ft int -.Fn cpuset_isset "cpuid_t cpu" "const cpuset_t *set" -.Ft size_t -.Fn cpuset_size "const cpuset_t *set" -.Sh DESCRIPTION -This section describes the functions used to create, set, use and destroy -the dynamic CPU sets. -.Pp -This API can be used with the POSIX threads, see -.Xr pthread 3 -and -.Xr affinity 3 . -.Pp -The ID of the primary CPU in the system is 0. -.Sh FUNCTIONS -.Bl -tag -width compact -.It Fn cpuset_create -Allocates and initializes a clean CPU-set. -Returns the pointer to the CPU-set, or -.Dv NULL -on failure. -.It Fn cpuset_destroy set -Destroy the CPU-set specified by -.Fa set . -.It Fn cpuset_zero set -Makes the CPU-set specified by -.Fa set -clean, that is, memory is initialized to zero bytes, and none of -the CPUs set. -.It Fn cpuset_set cpu set -Sets the CPU specified by -.Fa cpu -in -.Fa set . -Returns zero on success, and \-1 if -.Fa cpu -is invalid. -.It Fn cpuset_clr cpu set -Clears the CPU specified by -.Fa cpu -in the CPU-set -.Fa set . -Returns zero on success, and \-1 if -.Fa cpu -is invalid. -.It Fn cpuset_isset cpu set -Checks if CPU specified by -.Fa cpu -is set in the CPU-set -.Fa set . -Returns the positive number if set, zero if not set, and \-1 if -.Fa cpu -is invalid. -.It Fn cpuset_size set -Returns the size in bytes of CPU-set specified by -.Fa set . -.El -.Sh SEE ALSO -.Xr affinity 3 , -.Xr pset 3 , -.Xr sched 3 , -.Xr schedctl 8 , -.Xr kcpuset 9 -.Sh HISTORY -The dynamic CPU sets appeared in -.Nx 5.0 . diff --git a/lib/libc/gen/ctermid.3 b/lib/libc/gen/ctermid.3 deleted file mode 100644 index b167392b2..000000000 --- a/lib/libc/gen/ctermid.3 +++ /dev/null @@ -1,90 +0,0 @@ -.\" $NetBSD: ctermid.3,v 1.11 2010/03/22 19:30:53 joerg Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ctermid.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt CTERMID 3 -.Os -.Sh NAME -.Nm ctermid -.Nd generate terminal pathname -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdio.h -.Ft char * -.Fn ctermid "char *buf" -.Sh DESCRIPTION -The -.Fn ctermid -function generates a string, that, when used as a pathname, refers to -the current controlling terminal of the calling process. -.Pp -If -.Ar buf -is the -.Dv NULL -pointer, a pointer to a static area is returned. -Otherwise, the pathname is copied into the memory referenced by -.Ar buf . -The argument -.Ar buf -is assumed to point to an array at least -.Dv L_ctermid -bytes long (as defined in the include file -.In stdio.h ) . -.Pp -The current implementation simply returns -.Ql /dev/tty . -.Sh RETURN VALUES -Upon successful completion, a -.Pf non- Dv NULL -pointer is returned. -Otherwise, a -.Dv NULL -pointer is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -The current implementation detects no error conditions. -.Sh SEE ALSO -.Xr ttyname 3 -.Sh STANDARDS -The -.Fn ctermid -function conforms to -.St -p1003.1-90 . -.Sh BUGS -By default the -.Fn ctermid -function writes all information to an internal static object. -Subsequent calls to -.Fn ctermid -will modify the same object. diff --git a/lib/libc/gen/ctermid.c b/lib/libc/gen/ctermid.c deleted file mode 100644 index 21ace8a6b..000000000 --- a/lib/libc/gen/ctermid.c +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: ctermid.c,v 1.11 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ctermid.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: ctermid.c,v 1.11 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(ctermid,_ctermid) -#endif - -char * -ctermid(char *s) -{ - static char def[] = _PATH_TTY; - - if (s) { - (void)strncpy(s, def, L_ctermid); - return (s); - } - return (def); -} diff --git a/lib/libc/gen/ctype.3 b/lib/libc/gen/ctype.3 deleted file mode 100644 index 5bbf90540..000000000 --- a/lib/libc/gen/ctype.3 +++ /dev/null @@ -1,151 +0,0 @@ -.\" $NetBSD: ctype.3,v 1.22 2015/02/25 16:23:40 wiz Exp $ -.\" -.\" Copyright (c) 1991 Regents of the University of California. -.\" All rights reserved. -.\" -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ctype.3 6.5 (Berkeley) 4/19/91 -.\" -.Dd February 25, 2015 -.Dt CTYPE 3 -.Os -.Sh NAME -.Nm isalpha , -.Nm isupper , -.Nm islower , -.Nm isdigit , -.Nm isxdigit , -.Nm isalnum , -.Nm isspace , -.Nm ispunct , -.Nm isprint , -.Nm isgraph , -.Nm iscntrl , -.Nm isblank , -.Nm toupper , -.Nm tolower , -.Nd character classification and mapping functions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Fn isalpha "int c" -.Fn isupper "int c" -.Fn islower "int c" -.Fn isdigit "int c" -.Fn isxdigit "int c" -.Fn isalnum "int c" -.Fn isspace "int c" -.Fn ispunct "int c" -.Fn isprint "int c" -.Fn isgraph "int c" -.Fn iscntrl "int c" -.Fn isblank "int c" -.Fn toupper "int c" -.Fn tolower "int c" -.Sh DESCRIPTION -The above functions perform character tests and conversions on the integer -.Ar c . -.Pp -See the specific manual pages for information about the -test or conversion performed by each function. -.Sh EXAMPLES -To print an upper-case version of a string to stdout, -the following code can be used: -.Bd -literal -offset indent -const char *s = "xyz"; - -while (*s != '\e0') { - putchar(toupper((unsigned char)*s)); - s++; -} -.Ed -.Sh SEE ALSO -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -These functions, with the exception of -.Fn isblank , -conform to -.St -ansiC . -All described functions, including -.Fn isblank , -also conform to -.St -p1003.1-2001 . -.Sh CAVEATS -The first argument of these functions is of type -.Vt int , -but only a very restricted subset of values are actually valid. -The argument must either be the value of the macro -.Dv EOF -(which has a negative value), -or must be a non-negative value within the range representable as -.Vt unsigned char . -Passing invalid values leads to undefined behavior. -.Pp -Values of type -.Vt int -that were returned by -.Xr getc 3 , -.Xr fgetc 3 , -and similar functions or macros -are already in the correct range, and may be safely passed to these -.Nm ctype -functions without any casts. -.Pp -Values of type -.Vt char -or -.Vt signed char -must first be cast to -.Vt unsigned char , -to ensure that the values are within the correct range. -Casting a negative-valued -.Vt char -or -.Vt signed char -directly to -.Vt int -will produce a negative-valued -.Vt int , -which will be outside the range of allowed values -(unless it happens to be equal to -.Dv EOF , -but even that would not give the desired result). diff --git a/lib/libc/gen/ctype_.c b/lib/libc/gen/ctype_.c deleted file mode 100644 index b12c41a17..000000000 --- a/lib/libc/gen/ctype_.c +++ /dev/null @@ -1,160 +0,0 @@ -/* $NetBSD: ctype_.c,v 1.20 2013/04/13 10:21:20 joerg Exp $ */ - -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -/*static char *sccsid = "from: @(#)ctype_.c 5.6 (Berkeley) 6/1/90";*/ -#else -__RCSID("$NetBSD: ctype_.c,v 1.20 2013/04/13 10:21:20 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include "ctype_local.h" - -#if EOF != -1 -#error "EOF != -1" -#endif - -#ifdef __BUILD_LEGACY -#define _C _COMPAT_C -#define _S _COMPAT_S -#define _U _COMPAT_U -#define _X _COMPAT_X -#define _L _COMPAT_L -#define _P _COMPAT_P -#define _B _COMPAT_B -#define _N _COMPAT_N - -const unsigned char _C_compat_bsdctype[1 + _CTYPE_NUM_CHARS] = { - 0, - _C, _C, _C, _C, _C, _C, _C, _C, - _C, _C|_S, _C|_S, _C|_S, _C|_S, _C|_S, _C, _C, - _C, _C, _C, _C, _C, _C, _C, _C, - _C, _C, _C, _C, _C, _C, _C, _C, - _S|_B, _P, _P, _P, _P, _P, _P, _P, - _P, _P, _P, _P, _P, _P, _P, _P, - _N, _N, _N, _N, _N, _N, _N, _N, - _N, _N, _P, _P, _P, _P, _P, _P, - _P, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U|_X, _U, - _U, _U, _U, _U, _U, _U, _U, _U, - _U, _U, _U, _U, _U, _U, _U, _U, - _U, _U, _U, _P, _P, _P, _P, _P, - _P, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L|_X, _L, - _L, _L, _L, _L, _L, _L, _L, _L, - _L, _L, _L, _L, _L, _L, _L, _L, - _L, _L, _L, _P, _P, _P, _P, _C -}; - -#undef _C -#undef _S -#undef _U -#undef _X -#undef _L -#undef _P -#undef _B -#undef _N - -#ifdef __weak_alias -__weak_alias(_C_ctype_, _C_compat_bsdctype) -#endif - -const unsigned char *_ctype_ = &_C_compat_bsdctype[0]; -#endif /* __BUILD_LEGACY */ - -#define _A _CTYPE_A -#define _BL _CTYPE_BL -#define _C _CTYPE_C -#define _D _CTYPE_D -#define _G _CTYPE_G -#define _L _CTYPE_L -#define _P _CTYPE_P -#define _R _CTYPE_R -#define _S _CTYPE_S -#define _U _CTYPE_U -#define _X _CTYPE_X - -const unsigned short _C_ctype_tab_[1 + _CTYPE_NUM_CHARS] = { - 0, - _C, _C, _C, _C, - _C, _C, _C, _C, - _C, _BL|_C|_S, _C|_S, _C|_S, - _C|_S, _C|_S, _C, _C, - _C, _C, _C, _C, - _C, _C, _C, _C, - _C, _C, _C, _C, - _C, _C, _C, _C, - _BL|_R|_S, _G|_R|_P, _G|_R|_P, _G|_R|_P, - _G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P, - _G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P, - _G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P, - _D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X, - _D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X, _D|_G|_R|_X, - _D|_G|_R|_X, _D|_G|_R|_X, _G|_R|_P, _G|_R|_P, - _G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P, - _G|_R|_P, _A|_G|_R|_U|_X, _A|_G|_R|_U|_X, _A|_G|_R|_U|_X, - _A|_G|_R|_U|_X, _A|_G|_R|_U|_X, _A|_G|_R|_U|_X, _A|_G|_R|_U, - _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, - _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, - _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, - _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, - _A|_G|_R|_U, _A|_G|_R|_U, _A|_G|_R|_U, _G|_R|_P, - _G|_R|_P, _G|_R|_P, _G|_R|_P, _G|_R|_P, - _G|_R|_P, _A|_G|_L|_R|_X, _A|_G|_L|_R|_X, _A|_G|_L|_R|_X, - _A|_G|_L|_R|_X, _A|_G|_L|_R|_X, _A|_G|_L|_R|_X, _A|_G|_L|_R, - _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, - _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, - _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, - _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, - _A|_G|_L|_R, _A|_G|_L|_R, _A|_G|_L|_R, _G|_R|_P, - _G|_R|_P, _G|_R|_P, _G|_R|_P, _C, -}; - -#undef _A -#undef _BL -#undef _C -#undef _D -#undef _G -#undef _L -#undef _P -#undef _R -#undef _S -#undef _U -#undef _X - -const unsigned short *_ctype_tab_ = &_C_ctype_tab_[0]; diff --git a/lib/libc/gen/daemon.3 b/lib/libc/gen/daemon.3 deleted file mode 100644 index 47f3f5790..000000000 --- a/lib/libc/gen/daemon.3 +++ /dev/null @@ -1,114 +0,0 @@ -.\" $NetBSD: daemon.3,v 1.15 2003/08/07 16:42:46 agc Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)daemon.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd September 3, 1999 -.Dt DAEMON 3 -.Os -.Sh NAME -.Nm daemon -.Nd run in the background -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft int -.Fn daemon "int nochdir" "int noclose" -.Sh DESCRIPTION -The -.Fn daemon -function is for programs wishing to detach themselves from the -controlling terminal and run in the background as system daemons. -.Pp -Unless the argument -.Fa nochdir -is non-zero, -.Fn daemon -changes the current working directory to the root -.Pq Pa / . -.Pp -Unless the argument -.Fa noclose -is non-zero, -.Fn daemon -will redirect standard input, standard output and standard error -to -.Pa /dev/null . -.Sh RETURN VALUES -On return 0 indicates success with \-1 indicating error. -.Sh ERRORS -The function -.Fn daemon -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr fork 2 -and -.Xr setsid 2 . -.Sh SEE ALSO -.Xr fork 2 , -.Xr setsid 2 -.Sh HISTORY -The -.Fn daemon -function first appeared in -.Bx 4.4 . -.Sh CAVEATS -Unless the -.Ar noclose -argument is non-zero, -.Fn daemon -will close the first three file descriptors and redirect them to -.Pa /dev/null . -Normally, these correspond to standard input, standard output and -standard error. -However, if any of those file descriptors refer to something else they -will still be closed, resulting in incorrect behavior of the calling program. -This can happen if any of standard input, standard output or standard error -have been closed before the program was run. -Programs using -.Fn daemon -should therefore make sure to either call -.Fn daemon -before opening any files or sockets or, alternately, verifying that -any file descriptors obtained have a value greater than 2. -.Sh BUGS -.Fn daemon -uses -.Fn fork -as part of its tty detachment mechanism. -Consequently the process id changes when -.Fn daemon -is invoked. -Processes employing -.Fn daemon -can not be reliably waited upon until -.Fn daemon -has been invoked. diff --git a/lib/libc/gen/daemon.c b/lib/libc/gen/daemon.c deleted file mode 100644 index 1cec204fc..000000000 --- a/lib/libc/gen/daemon.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: daemon.c,v 1.10 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)daemon.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: daemon.c,v 1.10 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(daemon,_daemon) -#endif - -int -daemon(int nochdir, int noclose) -{ - int fd; - - switch (fork()) { - case -1: - return (-1); - case 0: - break; - default: - _exit(0); - } - - if (setsid() == -1) - return (-1); - - if (!nochdir) - (void)chdir("/"); - - if (!noclose && (fd = open(_PATH_DEVNULL, O_RDWR, 0)) != -1) { - (void)dup2(fd, STDIN_FILENO); - (void)dup2(fd, STDOUT_FILENO); - (void)dup2(fd, STDERR_FILENO); - if (fd > STDERR_FILENO) - (void)close(fd); - } - return (0); -} diff --git a/lib/libc/gen/dehumanize_number.c b/lib/libc/gen/dehumanize_number.c deleted file mode 100644 index c416f0515..000000000 --- a/lib/libc/gen/dehumanize_number.c +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $ */ - -/* - * Copyright (c) 2005, 2006 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Julio M. Merino Vidal, developed as part of Google's Summer of Code - * 2005 program. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifdef HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif /* HAVE_NBTOOL_CONFIG_H */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dehumanize_number.c,v 1.7 2014/10/01 13:53:04 apb Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -/* - * Converts the number given in 'str', which may be given in a humanized - * form (as described in humanize_number(3), but with some limitations), - * to an int64_t without units. - * In case of success, 0 is returned and *size holds the value. - * Otherwise, -1 is returned and *size is untouched. - * - * TODO: Internationalization, SI units. - */ -int -dehumanize_number(const char *str, int64_t *size) -{ - char *ep, unit; - const char *delimit; - long multiplier; - long long tmp, tmp2; - size_t len; - - len = strlen(str); - if (len == 0) { - errno = EINVAL; - return -1; - } - - multiplier = 1; - - unit = str[len - 1]; - if (isalpha((unsigned char)unit)) { - switch (tolower((unsigned char)unit)) { - case 'b': - multiplier = 1; - break; - - case 'k': - multiplier = 1024; - break; - - case 'm': - multiplier = 1024 * 1024; - break; - - case 'g': - multiplier = 1024 * 1024 * 1024; - break; - - default: - errno = EINVAL; - return -1; /* Invalid suffix. */ - } - - delimit = &str[len - 1]; - } else - delimit = NULL; - - errno = 0; - tmp = strtoll(str, &ep, 10); - if (str[0] == '\0' || (ep != delimit && *ep != '\0')) - return -1; /* Not a number. */ - else if (errno == ERANGE && (tmp == LLONG_MAX || tmp == LLONG_MIN)) - return -1; /* Out of range. */ - - tmp2 = tmp * multiplier; - tmp2 = tmp2 / multiplier; - if (tmp != tmp2) { - errno = ERANGE; - return -1; /* Out of range. */ - } - tmp *= multiplier; -#ifdef _DIAGASSERT - _DIAGASSERT(__type_fit(int64_t, tmp)); -#endif - *size = (int64_t)tmp; - - return 0; -} diff --git a/lib/libc/gen/devname.3 b/lib/libc/gen/devname.3 deleted file mode 100644 index 6ab0318d1..000000000 --- a/lib/libc/gen/devname.3 +++ /dev/null @@ -1,76 +0,0 @@ -.\" $NetBSD: devname.3,v 1.12 2012/06/03 21:42:46 joerg Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)devname.3 8.2 (Berkeley) 4/29/95 -.\" -.Dd June 3, 2012 -.Dt DEVNAME 3 -.Os -.Sh NAME -.Nm devname -.Nd get device name -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.In sys/stat.h -.Ft char * -.Fn devname "dev_t dev" "mode_t type" -.Sh DESCRIPTION -The -.Fn devname -function returns a pointer to the name of the block or character -device in -.Dq Pa /dev -with a device number of -.Fa dev , -and a file type matching the one encoded in -.Fa type -which must be one of S_IFBLK or S_IFCHR. -If no device matches the specified values, or no information is -available, -.Dv NULL -is returned. -.Pp -The traditional display for applications when no device is -found is the string -.Dq ?? . -.Sh FILES -.Bl -tag -width /var/run/dev.cdb -compact -.It Pa /var/run/dev.cdb -Device database file. -.El -.Sh SEE ALSO -.Xr stat 2 , -.Xr dev_mkdb 8 -.Sh HISTORY -The -.Nm devname -function call appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/devname.c b/lib/libc/gen/devname.c deleted file mode 100644 index 988d3cfd1..000000000 --- a/lib/libc/gen/devname.c +++ /dev/null @@ -1,183 +0,0 @@ -/* $NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Simon Burge. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__RCSID("$NetBSD: devname.c,v 1.22 2012/06/03 21:42:46 joerg Exp $"); - -#include "namespace.h" -#include "reentrant.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __minix -#include /* for UNIX98_MINOR */ -#endif /* __minix */ - -#ifdef __weak_alias -__weak_alias(devname_r,_devname_r) -#endif - -static once_t db_opened = ONCE_INITIALIZER; -static struct cdbr *db; -static devmajor_t pts; - -static void -devname_dbopen(void) -{ - db = cdbr_open(_PATH_DEVCDB, CDBR_DEFAULT); - pts = getdevmajor("pts", S_IFCHR); -} - -__CTASSERT(sizeof(dev_t) == 8); - -static int -devname_dblookup(dev_t dev, mode_t type, char *path, size_t len) -{ - const void *data; - size_t datalen; - uint8_t key[10]; - - le64enc(key, dev); - le16enc(key + 8, type); - if (cdbr_find(db, key, sizeof(key), &data, &datalen) != 0) - return ENOENT; - if (datalen <= sizeof(key)) - return ENOENT; - if (memcmp(key, data, sizeof(key)) != 0) - return ENOENT; - data = (const char *)data + sizeof(key); - datalen -= sizeof(key); - if (memchr(data, '\0', datalen) != (const char *)data + datalen - 1) - return ENOENT; - if (datalen > len) - return ERANGE; - memcpy(path, data, datalen); - return 0; -} - -static int -devname_ptslookup(dev_t dev, mode_t type, char *path, size_t len) -{ - int rv; - - if (type != S_IFCHR || pts == NODEVMAJOR || major(dev) != pts) - return ENOENT; -#ifdef __minix - /* - * MINIX3 does not use an identity mapping for /dev/pts, because the - * same major number is also used for PTY masters and legacy PTYs. - */ - if (minor(dev) < UNIX98_MINOR || !(minor(dev) & 1)) - return ENOENT; -#endif /* __minix */ - - rv = snprintf(path, len, "%s%d", _PATH_DEV_PTS + sizeof(_PATH_DEV) - 1, -#ifndef __minix - minor(dev)); -#else /* __minix */ - (minor(dev) - UNIX98_MINOR) >> 1); -#endif /* __minix */ - if (rv < 0 || (size_t)rv >= len) - return ERANGE; - return 0; -} - -static int -devname_fts(dev_t dev, mode_t type, char *path, size_t len) -{ - FTS *ftsp; - FTSENT *fe; - static const char path_dev[] = _PATH_DEV; - static char * const dirs[2] = { __UNCONST(path_dev), NULL }; - const size_t len_dev = strlen(path_dev); - int rv; - - if ((ftsp = fts_open(dirs, FTS_NOCHDIR | FTS_PHYSICAL, NULL)) == NULL) - return ENOENT; - - rv = ENOENT; - while ((fe = fts_read(ftsp)) != NULL) { - if (fe->fts_info != FTS_DEFAULT) - continue; - if (fe->fts_statp->st_rdev != dev) - continue; - if ((type & S_IFMT) != (fe->fts_statp->st_mode & S_IFMT)) - continue; - if (strncmp(fe->fts_path, path_dev, len_dev)) - continue; - if (strlcpy(path, fe->fts_path + len_dev, len) < len) { - rv = 0; - break; - } - } - - fts_close(ftsp); - return rv; -} - -int -devname_r(dev_t dev, mode_t type, char *path, size_t len) -{ - int rv; - - thr_once(&db_opened, devname_dbopen); - - if (db != NULL) { - rv = devname_dblookup(dev, type, path, len); - if (rv == 0 || rv == ERANGE) - return rv; - } - - rv = devname_ptslookup(dev, type, path, len); - if (rv == 0 || rv == ERANGE) - return rv; - - if (db != NULL) - return ENOENT; - rv = devname_fts(dev, type, path, len); - return rv; -} - -char * -devname(dev_t dev, mode_t type) -{ - static char path[PATH_MAX]; - - return devname_r(dev, type, path, sizeof(path)) == 0 ? path : NULL; -} diff --git a/lib/libc/gen/directory.3 b/lib/libc/gen/directory.3 deleted file mode 100644 index 7b7392587..000000000 --- a/lib/libc/gen/directory.3 +++ /dev/null @@ -1,399 +0,0 @@ -.\" $NetBSD: directory.3,v 1.38 2012/10/08 18:15:09 njoly Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)directory.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd October 15, 2011 -.Dt DIRECTORY 3 -.Os -.Sh NAME -.Nm fdopendir , -.Nm opendir , -.Nm readdir , -.Nm readdir_r , -.Nm telldir , -.Nm seekdir , -.Nm rewinddir , -.Nm closedir , -.Nm dirfd -.Nd directory operations -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In dirent.h -.Ft DIR * -.Fn opendir "const char *filename" -.Ft DIR * -.Fn fdopendir "int fd" -.Ft struct dirent * -.Fn readdir "DIR *dirp" -.Ft int -.Fn readdir_r "DIR * restrict dirp" "struct dirent * restrict entry" "struct dirent ** restrict result" -.Ft long -.Fn telldir "DIR *dirp" -.Ft void -.Fn seekdir "DIR *dirp" "long loc" -.Ft void -.Fn rewinddir "DIR *dirp" -.Ft int -.Fn closedir "DIR *dirp" -.Ft int -.Fn dirfd "DIR *dirp" -.Sh DESCRIPTION -The type -.Vt DIR -represents a directory stream; -an ordered sequence of all directory entries in a particular directory. -The purpose of the -.Vt DIR -structure is similar to that of the -.Vt FILE -structure maintained by the -.Xr stdio 3 -library functions. -.Sh FUNCTIONS -The following standard directory operations are defined. -.Bl -tag -width XXX -.It Fn opendir "filename" -The -.Fn opendir -function opens the directory named by -.Fa filename -and associates a directory stream with it. -The directory stream is positioned at the first entry. -Upon successful completion, a pointer to -.Vt DIR -type is returned. -Otherwise, -.Fn opendir -returns -.Dv NULL . -.It Fn fdopendir "fd" -The -.Fn fdopendir -function associates a directory stream with the directory file descriptor -.Fa fd . -The file offset associated with -.Fa fd -at the time of the call determines which entries are returned. -.Pp -Upon failure, -.Fn fdopendir -returns -.Dv NULL . -Otherwise the file descriptor is under the control of the system, -and if any attempt is made to close the file descriptor, -or to modify the state of the associated description, -other than by means of -.Fn closedir , -.Fn readdir , -.Fn readdir_r , -.Fn rewinddir , -the behavior is undefined. -The file descriptor can be closed by calling -.Fn closedir . -.It Fn readdir "dirp" -The -.Fn readdir -function returns a pointer to the directory entry at the current position -in the directory stream specified by -.Fa dirp , -and positions the directory stream at the next entry. -It returns -.Dv NULL -upon reaching the end of the directory or detecting an invalid -.Fn seekdir -operation. -The returned structure is described in -.Xr dirent 3 . -.Pp -The returned pointer to the -.Em dirent -structure points to data which may be overwritten by another call to -.Fn readdir -on the same directory stream. -This data is not however overwritten by another call to -.Fn readdir -on a different directory stream. -.It Fn readdir_r "dirp" "entry" "result" -The -.Fn readdir_r -function -provides the same functionality as -.Fn readdir , -but the caller must provide a directory -.Fa entry -buffer to store the results in. -If the read succeeds, -.Fa result -is pointed at the -.Fa entry ; -upon reaching the end of the directory -.Fa result -is set to -.Dv NULL . -The -.Fn readdir_r -function -returns 0 on success or an error number to indicate failure. -.Pp -Like -.Fn readdir , -the -.Fn readdir_r -function may buffer several directory entries per actual read operation. -Both functions mark for update the -.Em st_atime -field (see -.Xr stat 2 ) -of the directory each time the directory is actually read. -.It Fn telldir "dirp" -The -.Fn telldir -function returns the current location associated -with the directory stream specified by -.Fa dirp . -.Pp -If the most recent operation on the particular directory stream was a -.Fn seekdir , -the directory position returned from -.Fn telldir -is the same as -.Fa loc -supplied as an argument to the -.Fn seekdir -call. -.It Fn seekdir "dirp" "loc" -The -.Fn seekdir -function sets the position of the next -.Fn readdir -operation on the directory stream specified by -.Fa dirp . -The value of -.Fa loc -should come from a previous call to -.Fn telldir -using the same directory stream. -.Pp -The new position reverts to the one associated -with the directory stream when the -.Fn telldir -operation was performed. -Values returned by -.Fn telldir -are good only for the lifetime of the -.Vt DIR -pointer, -.Fa dirp , -from which they are derived. -If the directory is closed and then reopened, the -.Fn telldir -value cannot be re-used. -.It Fn rewinddir "dirp" -The -.Fn rewinddir -function resets the position of the named directory -stream to the beginning of the directory. -It also causes the directory stream to refer to the -current state of the corresponding directory, as if a call to -.Fn opendir -would have been made. -.Pp -If -.Fa dirp -does not refer to a valid directory stream, the behavior is undefined. -.It Fn closedir "dirp" -The -.Fn closedir -function closes the directory stream -and frees the structure associated with the -.Fa dirp -pointer, -returning 0 on success and \-1 on failure. -.It Fn dirfd "dirp" -The -.Fn dirfd -function returns the integer file descriptor -associated with the directory stream specified by -.Fa dirp . -Upon failure, -.Fn dirfd -returns \-1. -The returned file descriptor should be closed by -.Fn closedir -instead of -.Xr close 2 . -.Pp -The rationale of -.Fn dirfd -is to provide a mechanism by which a file descriptor -can be obtained for the use of the -.Xr fchdir 2 -function. -.El -.Sh EXAMPLES -Sample code which searches a directory for entry -.Dq name -is: -.Bd -literal -offset indent -len = strlen(name); -dirp = opendir("."); -if (dirp != NULL) { - while ((dp = readdir(dirp)) != NULL) - if (dp-\*[Gt]d_namlen == len \*[Am]\*[Am] - !strcmp(dp-\*[Gt]d_name, name)) { - (void)closedir(dirp); - return (FOUND); - } - (void)closedir(dirp); -} -return (NOT_FOUND); -.Ed -.Sh COMPATIBILITY -The described directory operations have traditionally been problematic -in terms of portability. -A good example is the semantics around -.Sq \&. -(dot) and -.Sq \&.. -(dot-dot). -Based on historical implementations, -the rules about file descriptors apply to directory streams as well. -The -.St -p1003.1-2008 -standard does not however any more mandate that directory streams -are necessarily implemented by using file descriptors. -.Pp -The following additional remarks can be noted from the -.St -p1003.1-2008 -standard. -.Bl -bullet -offset 2n -.It -If the type -.Vt DIR -is implemented using a file descriptor, -like in -.Nx , -applications should be able to open only -.Dv OPEN_MAX -files and directories. -Otherwise the limit is left as unspecified. -.It -When a file descriptor is used to implement the directory stream, the -.Fn closedir -function behaves as if the -.Dv FD_CLOEXEC -had been set for the file descriptor. -In another words, it is mandatory that -.Fn closedir -deallocates the file descriptor. -.It -If directory streams are not implemented by using file descriptors, -functions such as -.Fn dirfd -may fail with -.Er ENOTSUP . -.It -If a file is removed from or added to the directory -after the most recent call to -.Fn opendir -or -.Fn rewinddir , -it is unspecified whether a subsequent call to -.Fn readdir -returns an entry for that file. -.It -When using the function -.Fn seekdir , -note that if the value of -.Fa loc -was not obtained from an earlier call to -.Fn telldir , -or if a call to -.Fn rewinddir -occurred between the calls to -.Fn telldir -and -.Fn seekdir , -any subsequent call to -.Fn readdir -is unspecified, possibly resulting undefined behavior. -.It -After a call to -.Xr fork 2 , -either the parent or child (but not both) can continue processing the -directory stream using -.Fn readdir , -.Fn rewinddir , -or -.Fn seekdir . -However, if both the parent and child processes use these functions, -the result is undefined. -.El -.Sh ERRORS -.\" -.\" XXX: The errors should be enumerated. -.\" -All described functions may set -.Vt errno -to indicate the error. -.Sh SEE ALSO -.Xr close 2 , -.Xr lseek 2 , -.Xr open 2 , -.Xr read 2 , -.Xr dirent 3 -.Sh STANDARDS -The -.Fn opendir , -.Fn readdir , -.Fn rewinddir -and -.Fn closedir -functions conform to -.St -p1003.1-90 . -The other functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn opendir , -.Fn readdir , -.Fn telldir , -.Fn seekdir , -.Fn rewinddir , -.Fn closedir , -and -.Fn dirfd -functions appeared in -.Bx 4.2 . -The -.Fn fdopendir -function appeared in -.Nx 6.0 . diff --git a/lib/libc/gen/dirent_private.h b/lib/libc/gen/dirent_private.h deleted file mode 100644 index 77d2d56fc..000000000 --- a/lib/libc/gen/dirent_private.h +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: dirent_private.h,v 1.4 2010/09/26 02:26:59 yamt Exp $ */ - -/* - * One struct _dirpos is malloced to describe the current directory - * position each time telldir is called. It records the current magic - * cookie returned by getdents and the offset within the buffer associated - * with that return value. - */ -struct dirpos { - struct dirpos *dp_next; /* next structure in list */ - off_t dp_seek; /* magic cookie returned by getdents */ - long dp_loc; /* offset of entry in buffer */ -}; - -struct _dirdesc; -void _seekdir_unlocked(struct _dirdesc *, long); -long _telldir_unlocked(struct _dirdesc *); -int _initdir(DIR *, int, const char *); -void _finidir(DIR *); -#ifndef __LIBC12_SOURCE__ -struct dirent; -struct dirent *_readdir_unlocked(struct _dirdesc *, int) - __RENAME(___readdir_unlocked50); -#endif diff --git a/lib/libc/gen/dirname.3 b/lib/libc/gen/dirname.3 deleted file mode 100644 index 216631833..000000000 --- a/lib/libc/gen/dirname.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" $NetBSD: dirname.3,v 1.14 2008/05/10 22:39:40 christos Exp $ -.\" -.\" Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein and Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd May 10, 2008 -.Dt DIRNAME 3 -.Os -.Sh NAME -.Nm dirname -.Nd report the parent directory name of a file pathname -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In libgen.h -.Ft char * -.Fn dirname "char *path" -.Sh DESCRIPTION -The -.Fn dirname -function takes a pointer to a character string that contains a pathname, -.Ar path , -and returns a pointer to a string that is a pathname of the parent directory of -.Ar path . -Trailing -.Sq / -characters in -.Ar path -are not counted as part of the path. -.Pp -If -.Ar path -does not contain a -.Sq / , -then -.Fn dirname -returns a pointer to the string -.Dq \&. . -.Pp -If -.Ar path -is a null pointer or points to an empty string, -.Fn dirname -returns a pointer to the string -.Dq \&. . -.Sh RETURN VALUES -The -.Fn dirname -function returns a pointer to a string that is the parent directory of -.Ar path . -.Sh SEE ALSO -.Xr dirname 1 , -.Xr basename 3 -.Sh STANDARDS -.Bl -bullet -compact -.It -.St -xpg4.2 -.It -.St -p1003.1-2001 -.El -.Sh BUGS -If the length of the result is longer than -.Dv PATH_MAX -bytes -.Pq including the terminating nul , -the result will be truncated. -.Pp -The -.Fn dirname -function returns a pointer to static storage that may be overwritten -by subsequent calls to -.Fn dirname . -This is not strictly a bug; it is explicitly allowed by -.St -p1003.1-2001 . diff --git a/lib/libc/gen/dirname.c b/lib/libc/gen/dirname.c deleted file mode 100644 index 5fae7c1f2..000000000 --- a/lib/libc/gen/dirname.c +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $ */ - -/*- - * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein and Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dirname.c,v 1.13 2014/07/16 10:52:26 christos Exp $"); -#endif /* !LIBC_SCCS && !lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(dirname,_dirname) -#endif - -static size_t -xdirname_r(const char *path, char *buf, size_t buflen) -{ - const char *endp; - size_t len; - - /* - * If `path' is a null pointer or points to an empty string, - * return a pointer to the string ".". - */ - if (path == NULL || *path == '\0') { - path = "."; - len = 1; - goto out; - } - - /* Strip trailing slashes, if any. */ - endp = path + strlen(path) - 1; - while (endp != path && *endp == '/') - endp--; - - /* Find the start of the dir */ - while (endp > path && *endp != '/') - endp--; - - if (endp == path) { - path = *endp == '/' ? "/" : "."; - len = 1; - goto out; - } - - do - endp--; - while (endp > path && *endp == '/'); - - len = endp - path + 1; -out: - if (buf != NULL && buflen != 0) { - buflen = MIN(len, buflen - 1); - memcpy(buf, path, buflen); - buf[buflen] = '\0'; - } - return len; -} - -#if !HAVE_DIRNAME -char * -dirname(char *path) -{ - static char result[PATH_MAX]; - (void)xdirname_r(path, result, sizeof(result)); - return result; -} -#endif diff --git a/lib/libc/gen/disklabel.c b/lib/libc/gen/disklabel.c deleted file mode 100644 index 591de811c..000000000 --- a/lib/libc/gen/disklabel.c +++ /dev/null @@ -1,238 +0,0 @@ -/* $NetBSD: disklabel.c,v 1.37 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1983, 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)disklabel.c 8.2 (Berkeley) 5/3/95"; -#else -__RCSID("$NetBSD: disklabel.c,v 1.37 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#define DKTYPENAMES -#define FSTYPENAMES -#include -#include - -#if HAVE_NBTOOL_CONFIG_H -#include -#include -#else -#include -#include -#endif /* HAVE_NBTOOL_CONFIG_H */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getdiskbyname,_getdiskbyname) -#endif - -#if 0 -static void error(int); -#endif -static int gettype(char *, const char *const *); - -static const char *db_array[2] = { _PATH_DISKTAB, 0 }; - -int -setdisktab(const char *name) -{ - if (!name || !*name) - return -1; - - db_array[0] = name; - return 0; -} - - -struct disklabel * -getdiskbyname(const char *name) -{ - static struct disklabel disk; - struct disklabel *dp = &disk; - struct partition *pp; - char *buf; - char *cp, *cq; /* can't be */ - char p, max, psize[3], pbsize[3], - pfsize[3], poffset[3], ptype[3]; - u_int32_t *dx; - long f; - - _DIAGASSERT(name != NULL); - - if (cgetent(&buf, db_array, name) < 0) - return NULL; - - memset(&disk, 0, sizeof(disk)); - /* - * typename - */ - cq = dp->d_typename; - cp = buf; - while (cq < dp->d_typename + sizeof(dp->d_typename) - 1 && - (*cq = *cp) && *cq != '|' && *cq != ':') - cq++, cp++; - *cq = '\0'; - /* - * boot name (optional) xxboot, bootxx - */ - cgetstr(buf, "b0", &dp->d_boot0); - cgetstr(buf, "b1", &dp->d_boot1); - - if (cgetstr(buf, "ty", &cq) >= 0) { - if (strcmp(cq, "removable") == 0) - dp->d_flags |= D_REMOVABLE; - else if (strcmp(cq, "simulated") == 0) - dp->d_flags |= D_RAMDISK; - free(cq); - } - if (cgetcap(buf, "sf", ':') != NULL) - dp->d_flags |= D_BADSECT; - -#define getnumdflt(field, dname, dflt) \ - (field) = ((cgetnum(buf, dname, &f) == -1) ? (dflt) : (u_int32_t) f) -#define getnum(field, dname) \ - if (cgetnum(buf, dname, &f) != -1) field = (u_int32_t)f - - getnumdflt(dp->d_secsize, "se", DEV_BSIZE); - getnum(dp->d_ntracks, "nt"); - getnum(dp->d_nsectors, "ns"); - getnum(dp->d_ncylinders, "nc"); - - if (cgetstr(buf, "dt", &cq) >= 0) { - dp->d_type = gettype(cq, dktypenames); - free(cq); - } else - getnumdflt(dp->d_type, "dt", 0); - getnumdflt(dp->d_secpercyl, "sc", dp->d_nsectors * dp->d_ntracks); - getnumdflt(dp->d_secperunit, "su", dp->d_secpercyl * dp->d_ncylinders); - getnumdflt(dp->d_rpm, "rm", 3600); - getnumdflt(dp->d_interleave, "il", 1); - getnumdflt(dp->d_trackskew, "sk", 0); - getnumdflt(dp->d_cylskew, "cs", 0); - getnumdflt(dp->d_headswitch, "hs", 0); - getnumdflt(dp->d_trkseek, "ts", 0); - getnumdflt(dp->d_bbsize, "bs", BBSIZE); - getnumdflt(dp->d_sbsize, "sb", SBLOCKSIZE); - strcpy(psize, "px"); /* XXX: strcpy is safe */ - strcpy(pbsize, "bx"); /* XXX: strcpy is safe */ - strcpy(pfsize, "fx"); /* XXX: strcpy is safe */ - strcpy(poffset, "ox"); /* XXX: strcpy is safe */ - strcpy(ptype, "tx"); /* XXX: strcpy is safe */ - max = 'a' - 1; - pp = &dp->d_partitions[0]; - for (p = 'a'; p < 'a' + MAXPARTITIONS; p++, pp++) { - long ff; - - psize[1] = pbsize[1] = pfsize[1] = poffset[1] = ptype[1] = p; - if (cgetnum(buf, psize, &ff) == -1) - pp->p_size = 0; - else { - pp->p_size = (u_int32_t)ff; - getnum(pp->p_offset, poffset); - getnumdflt(pp->p_fsize, pfsize, 0); - if (pp->p_fsize) { - long bsize; - - if (cgetnum(buf, pbsize, &bsize) == -1) - pp->p_frag = 8; - else - pp->p_frag = - (u_int8_t)(bsize / pp->p_fsize); - } - getnumdflt(pp->p_fstype, ptype, 0); - if (pp->p_fstype == 0) - if (cgetstr(buf, ptype, &cq) >= 0) { - pp->p_fstype = gettype(cq, fstypenames); - free(cq); - } - max = p; - } - } - dp->d_npartitions = max + 1 - 'a'; - strcpy(psize, "dx"); /* XXX: strcpy is safe */ - dx = dp->d_drivedata; - for (p = '0'; p < '0' + NDDATA; p++, dx++) { - psize[1] = p; - getnumdflt(*dx, psize, 0); - } - dp->d_magic = DISKMAGIC; - dp->d_magic2 = DISKMAGIC; - free(buf); - return (dp); -} - -static int -gettype(char *t, const char *const *names) -{ - const char *const *nm; - - _DIAGASSERT(t != NULL); - _DIAGASSERT(names != NULL); - - for (nm = names; *nm; nm++) - if (strcasecmp(t, *nm) == 0) - return (int)(nm - names); - if (isdigit((unsigned char) *t)) - return (atoi(t)); - return (0); -} - -#if 0 -static void -error(err) - int err; -{ - char *p; - - (void)write(STDERR_FILENO, "disktab: ", 9); - (void)write(STDERR_FILENO, _PATH_DISKTAB, sizeof(_PATH_DISKTAB) - 1); - (void)write(STDERR_FILENO, ": ", 2); - p = strerror(err); - (void)write(STDERR_FILENO, p, strlen(p)); - (void)write(STDERR_FILENO, "\n", 1); -} -#endif diff --git a/lib/libc/gen/endutxent.3 b/lib/libc/gen/endutxent.3 deleted file mode 100644 index 06a443345..000000000 --- a/lib/libc/gen/endutxent.3 +++ /dev/null @@ -1,202 +0,0 @@ -.\" $NetBSD: endutxent.3,v 1.5 2008/04/30 13:10:50 martin Exp $ -.\" -.\" Copyright (c) 2002 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Thomas Klausner. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd September 26, 2002 -.Dt ENDUTXENT 3 -.Os -.Sh NAME -.Nm endutxent , -.Nm getutxent , -.Nm getutxid , -.Nm getutxline , -.Nm pututxline , -.Nm setutxent -.Nd user accounting database functions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In utmpx.h -.Ft void -.Fn endutxent void -.Ft struct utmpx * -.Fn getutxent void -.Ft struct utmpx * -.Fn getutxid "const struct utmpx *" -.Ft struct utmpx * -.Fn getutxline "const struct utmpx *" -.Ft struct utmpx * -.Fn pututxline "const struct utmpx *" -.Ft void -.Fn setutxent void -.Sh DESCRIPTION -These functions provide access to the -.Xr utmpx 5 -user accounting database. -.Pp -.Fn getutxent -reads the next entry from the database; -if the database was not yet open, it also opens it. -.Fn setutxent -resets the database, so that the next -.Fn getutxent -call will get the first entry. -.Fn endutxent -closes the database. -.Pp -.Fn getutxid -returns the next entry of the type specified in its argument's -.Va ut_type -field, or -.Dv NULL -if none is found. -.Fn getutxline -returns the next -.Dv LOGIN_PROCESS -or -.Dv USER_PROCESS -entry which has the same name as specified in the -.Va ut_line -field, or -.Dv NULL -if no match is found. -.Pp -.Fn pututxline -adds the argument -.Xr utmpx 5 -entry line to the accounting database, replacing a previous entry for -the same user if it exists. -.Ss The utmpx structure -The -.Nm utmpx -structure has the following definition: -.Pp -.Bd -literal -struct utmpx { - char ut_name[_UTX_USERSIZE]; /* login name */ - char ut_id[_UTX_IDSIZE]; /* inittab id */ - char ut_line[_UTX_LINESIZE]; /* tty name */ - char ut_host[_UTX_HOSTSIZE]; /* host name */ - uint16_t ut_session; /* session id used for windowing */ - uint16_t ut_type; /* type of this entry */ - pid_t ut_pid; /* process id creating the entry */ - struct { - uint16_t e_termination; /* process termination signal */ - uint16_t e_exit; /* process exit status */ - } ut_exit; - struct sockaddr_storage ut_ss; /* address where entry was made from */ - struct timeval ut_tv; /* time entry was created */ - uint32_t ut_pad[10]; /* reserved for future use */ -}; -.Ed -.Pp -Valid entries for -.Fa ut_type -are: -.Bl -tag -width LOGIN_PROCESSXX -compact -offset indent -.It Dv BOOT_TIME -Time of a system boot. -.It Dv DEAD_PROCESS -A session leader exited. -.It Dv EMPTY -No valid user accounting information. -.It Dv INIT_PROCESS -A process spawned by -.Xr init 8 . -.It Dv LOGIN_PROCESS -The session leader of a logged-in user. -.It Dv NEW_TIME -Time after system clock change. -.It Dv OLD_TIME -Time before system clock change. -.It Dv RUN_LVL -Run level. -Provided for compatibility, not used on -.Nx . -.It Dv USER_PROCESS -A user process. -.El -.Sh RETURN VALUES -.Fn getutxent -returns the next entry, or -.Dv NULL -on failure (end of database or problems reading from the database). -.Fn getutxid -and -.Fn getutxline -return the matching structure on success, or -.Dv NULL -if no match was found. -.Fn pututxline -returns the structure that was successfully written, or -.Dv NULL . -.Sh SEE ALSO -.Xr logwtmpx 3 , -.Xr utmpx 5 -.Sh STANDARDS -The -.Fn endutxent , -.Fn getutxent , -.Fn getutxid , -.Fn getutxline , -.Fn pututxline , -.Fn setutxent -all conform to -.St -p1003.1-2001 -(XSI extension), and previously to -.St -xpg4.2 . -The fields -.Fa ut_user , -.Fa ut_id , -.Fa ut_line , -.Fa ut_pid , -.Fa ut_type , -and -.Fa ut_tv -conform to -.St -p1003.1-2001 -(XSI extension), and previously to -.St -xpg4.2 . -.\" .Fa ut_host , -.\" .Fa ut_session , -.\" .Fa ut_exit , -.\" and -.\" .Fa ut_ss -.\" are from -.\" SVR3/4? -.\" .Dv RUN_LVL -.\" is for compatibility with -.\" what exactly? -.\" .Sh HISTORY -.\" The -.\" .Nm utmpx , -.\" .Nm wtmpx , -.\" and -.\" .Nm lastlogx -.\" files first appeared in -.\" SVR3? 4? diff --git a/lib/libc/gen/err.3 b/lib/libc/gen/err.3 deleted file mode 100644 index b52ba962a..000000000 --- a/lib/libc/gen/err.3 +++ /dev/null @@ -1,205 +0,0 @@ -.\" $NetBSD: err.3,v 1.21 2014/01/16 17:21:38 christos Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)err.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd January 16, 2014 -.Dt ERR 3 -.Os -.Sh NAME -.Nm err , -.Nm verr , -.Nm errx , -.Nm verrx , -.Nm errc , -.Nm verrc , -.Nm warn , -.Nm vwarn , -.Nm warnx , -.Nm vwarnx , -.Nm warnc , -.Nm vwarnc -.Nd formatted error messages -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In err.h -.Ft void -.Fn err "int status" "const char *fmt" "..." -.Ft void -.Fn verr "int status" "const char *fmt" "va_list args" -.Ft void -.Fn errx "int status" "const char *fmt" "..." -.Ft void -.Fn verrx "int status" "const char *fmt" "va_list args" -.Ft void -.Fn errc "int status" "int code" "const char *fmt" "..." -.Ft void -.Fn verrc "int status" "int code" "const char *fmt" "va_list args" -.Ft void -.Fn warn "const char *fmt" "..." -.Ft void -.Fn vwarn "const char *fmt" "va_list args" -.Ft void -.Fn warnx "const char *fmt" "..." -.Ft void -.Fn vwarnx "const char *fmt" "va_list args" -.Ft void -.Fn warnc "int code" "const char *fmt" "..." -.Ft void -.Fn vwarnc "int code" "const char *fmt" "va_list args" -.Sh DESCRIPTION -The -.Fn err -and -.Fn warn -family of functions display a formatted error message on the standard -error output. -In all cases, the last component of the program name, a colon character, -and a space are output. -If the -.Fa fmt -argument is not -.Dv NULL , -the formatted error message is output. -In the case of the -.Fn err , -.Fn verr , -.Fn warn , -and -.Fn vwarn -functions, the error message string affiliated with the current value of -the global variable -.Va errno -is output next, preceded by a colon character and a space if -.Fa fmt -is not -.Dv NULL . -In all cases, the output is followed by a newline character. -The -.Fn errc , -.Fn verrc , -.Fn warnc , -and -.Fn vwarnc -functions take an additional -.Ar code -argument to be used as the error number instead of using the global -.Va errno -variable. -The -.Fn errx , -.Fn verrx , -.Fn warnx , -and -.Fn vwarnx -functions will not output this error message string. -.Pp -The -.Fn err , -.Fn verr , -.Fn errx , -and -.Fn verrx -functions do not return, but instead cause the program to terminate -with the status value given by the argument -.Fa status . -It is often appropriate to use the value -.Dv EXIT_FAILURE , -defined in -.In stdlib.h , -as the -.Fa status -argument given to these functions. -.Sh EXAMPLES -Display the current -.Va errno -information string and terminate with status indicating failure: -.Bd -literal -offset indent -if ((p = malloc(size)) == NULL) - err(EXIT_FAILURE, NULL); -if ((fd = open(file_name, O_RDONLY, 0)) == -1) - err(EXIT_FAILURE, "%s", file_name); -.Ed -.Pp -Display an error message and terminate with status indicating failure: -.Bd -literal -offset indent -if (tm.tm_hour \*[Lt] START_TIME) - errx(EXIT_FAILURE, "too early, wait until %s", - start_time_string); -.Ed -.Pp -Warn of an error: -.Bd -literal -offset indent -if ((fd = open(raw_device, O_RDONLY, 0)) == -1) - warnx("%s: %s: trying the block device", - raw_device, strerror(errno)); -if ((fd = open(block_device, O_RDONLY, 0)) == -1) - warn("%s", block_device); -.Ed -.Sh SEE ALSO -.Xr exit 3 , -.Xr getprogname 3 , -.Xr strerror 3 -.Sh HISTORY -The -.Fn err -and -.Fn warn -functions first appeared in -.Bx 4.4 . -The -.Fn errc -and -.Fn warnc -functions first appeared in -.Fx 3.0 -and -.Nx 7.0 . -.Sh CAVEATS -It is important never to pass a string with user-supplied data as a -format without using -.Ql %s . -An attacker can put format specifiers in the string to mangle your stack, -leading to a possible security hole. -This holds true even if you have built the string -.Dq by hand -using a function like -.Fn snprintf , -as the resulting string may still contain user-supplied conversion specifiers -for later interpolation by the -.Fn err -and -.Fn warn -functions. -.Pp -Always be sure to use the proper secure idiom: -.Bd -literal -offset indent -err(1, "%s", string); -.Ed diff --git a/lib/libc/gen/err.c b/lib/libc/gen/err.c deleted file mode 100644 index 9bd01b070..000000000 --- a/lib/libc/gen/err.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: err.c,v 1.26 2007/06/18 14:13:54 ginsbach Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: err.c,v 1.26 2007/06/18 14:13:54 ginsbach Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(err, _err) -#endif - -#if !HAVE_ERR_H -__dead void -err(int eval, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - verr(eval, fmt, ap); - va_end(ap); -} -#endif diff --git a/lib/libc/gen/errc.c b/lib/libc/gen/errc.c deleted file mode 100644 index 54665166f..000000000 --- a/lib/libc/gen/errc.c +++ /dev/null @@ -1,59 +0,0 @@ -/* $NetBSD: errc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: errc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(errc, _errc) -#endif - -#if !HAVE_ERR_H || !HAVE_DECL_ERRC -__dead void -errc(int eval, int code, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - verrc(eval, code, fmt, ap); - va_end(ap); -} -#endif diff --git a/lib/libc/gen/errlist.awk b/lib/libc/gen/errlist.awk deleted file mode 100644 index ead74a148..000000000 --- a/lib/libc/gen/errlist.awk +++ /dev/null @@ -1,120 +0,0 @@ -#! /usr/bin/awk -f -# $NetBSD: errlist.awk,v 1.4 2010/12/16 22:52:32 joerg Exp $ -# -# Copyright (c) 2010 The NetBSD Foundation, Inc. -# All rights reserved. -# -# This code is derived from software contributed to The NetBSD Foundation -# by Christos Zoulas. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions -# are met: -# 1. Redistributions of source code must retain the above copyright -# notice, this list of conditions and the following disclaimer. -# 2. Redistributions in binary form must reproduce the above copyright -# notice, this list of conditions and the following disclaimer in the -# documentation and/or other materials provided with the distribution. -# 3. All advertising materials mentioning features or use of this software -# must display the following acknowledgement: -# This product includes software developed by the NetBSD -# Foundation, Inc. and its contributors. -# 4. Neither the name of The NetBSD Foundation nor the names of its -# contributors may be used to endorse or promote products derived -# from this software without specific prior written permission. -# -# THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -# ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# -function tabs(desc) { - l = length(desc) + 3; - if (concat) - l++ - if (l < 16) - return "\t\t\t\t"; - else if (l < 24) - return "\t\t\t"; - else if (l < 32) - return "\t\t"; - else if (l < 40) - return "\t"; - else - return ""; -} -function perror(name, number, desc) -{ - if (!concat) { - printf("\t\"%s\",%s/* %d - %s */\n", desc, tabs(desc), number, name); - } else { - offsets[number] = offset; - offset += length(desc) + 1; - printf("\t\"%s\\0\"%s/* %d - %s */\n", desc, tabs(desc), number, name); - } -} -BEGIN { - printf("/* Automatically generated file; do not edit */\n"); - printf("#include \n"); - printf("__RCSID(\"$NetBSD: errlist.awk,v 1.4 2010/12/16 22:52:32 joerg Exp $\");\n"); - printf("#include \n"); - if (!concat) { - printf("static const char *const errlist[] = {\n"); - } else { - printf("static const char concat_errlist[] = {\n"); - offset = 0; - } - perror("ENOERROR", 0, "Undefined error: 0"); - errno = 1; -} -/^#define/ { - name = $2; - if (name == "ELAST") - next; - number = $3; - if (number < 0 || number == "EAGAIN") - next; - desc = $0; - i1 = index(desc, "/*") + 3; - l = length(desc); - desc = substr(desc, i1, l - i1 - 2); - #__MINIX: We have more error numbers... - if (number < errno) { - printf("error number mismatch %d != %d\n", number, errno) > "/dev/stderr"; - exit(1); - } - #__MINIX:start - while(errno < number) { - perror("UNDEFINED", errno, "Undefined error: " errno); - errno++; - } - #__MINIX:end - perror(name, number, desc); - errno++; -} -END { - printf("};\n\n"); - if (!concat) { - printf("const int sys_nerr = sizeof(errlist) / sizeof(errlist[0]);\n"); - printf("const char * const *sys_errlist = errlist;\n"); - } else { - printf("static const int concat_nerr = %d;\n", errno); - printf("static const unsigned short concat_offset[] = {\n"); - offsets[errno++] = offset; - for (j = 0; j < errno; j++) { - printf("\t%d,\n", offsets[j]); - } - printf("};\n"); - if (offset > 65535) { - printf("Total errlist size doesn't fit into 16bit\n") > "/dev/stderr"; - exit(1); - } - } -} diff --git a/lib/libc/gen/errno.c b/lib/libc/gen/errno.c deleted file mode 100644 index ca8b2acf8..000000000 --- a/lib/libc/gen/errno.c +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: errno.c,v 1.5 2005/06/12 05:21:27 lukem Exp $ */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: errno.c,v 1.5 2005/06/12 05:21:27 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -int errno; diff --git a/lib/libc/gen/errx.c b/lib/libc/gen/errx.c deleted file mode 100644 index 004fdd6b1..000000000 --- a/lib/libc/gen/errx.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: errx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: errx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(errx, _errx) -#endif - -#if !HAVE_ERR_H -__dead void -errx(int eval, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - verrx(eval, fmt, ap); - va_end(ap); -} -#endif diff --git a/lib/libc/gen/exec.3 b/lib/libc/gen/exec.3 deleted file mode 100644 index 75a8c4cf4..000000000 --- a/lib/libc/gen/exec.3 +++ /dev/null @@ -1,288 +0,0 @@ -.\" $NetBSD: exec.3,v 1.26 2014/09/27 16:42:07 wiz Exp $ -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)exec.3 8.3 (Berkeley) 1/24/94 -.\" -.Dd September 26, 2014 -.Dt EXEC 3 -.Os -.Sh NAME -.Nm execl , -.Nm execlp , -.Nm execle , -.Nm exect , -.Nm execv , -.Nm execvp -.Nd execute a file -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Vt extern char **environ; -.Ft int -.Fn execl "const char *path" "const char *arg" ... -.Ft int -.Fn execlp "const char *file" "const char *arg" ... -.Ft int -.Fn execlpe "const char *path" "const char *arg" ... "char *const envp[]" -.Ft int -.Fn execle "const char *path" "const char *arg" ... "char *const envp[]" -.Ft int -.Fn exect "const char *path" "char *const argv[]" "char *const envp[]" -.Ft int -.Fn execv "const char *path" "char *const argv[]" -.Ft int -.Fn execvp "const char *file" "char *const argv[]" -.Ft int -.Fn execvpe "const char *file" "char *const argv[]" "char *const envp[]" -.Sh DESCRIPTION -The -.Fn exec -family of functions replaces the current process image with a -new process image. -The functions described in this manual page are front-ends for the function -.Xr execve 2 . -(See the manual page for -.Xr execve 2 -for detailed information about the replacement of the current process. -The -.Xr script 7 -manual page provides detailed information about the execution of -interpreter scripts.) -.Pp -The initial argument for these functions is the pathname of a file which -is to be executed. -.Pp -The -.Fa "const char *arg" -and subsequent ellipses in the -.Fn execl , -.Fn execlp , -.Fn execlpe , -and -.Fn execle -functions can be thought of as -.Em arg0 , -.Em arg1 , -\&..., -.Em argn . -Together they describe a list of one or more pointers to NUL-terminated -strings that represent the argument list available to the executed program. -The first argument, by convention, should point to the file name associated -with the file being executed. -The list of arguments -.Em must -be terminated by a -.Dv NULL -pointer. -.Pp -The -.Fn exect , -.Fn execv , -.Fn execvp , -and -.Fn execvpe -functions provide an array of pointers to NUL-terminated strings that -represent the argument list available to the new program. -The first argument, by convention, should point to the file name associated -with the file being executed. -The array of pointers -.Sy must -be terminated by a -.Dv NULL -pointer. -.Pp -The -.Fn execle , -.Fn execlpe , -.Fn exect , -and -.Fn execvpe -functions also specify the environment of the executed process by following -the -.Dv NULL -pointer that terminates the list of arguments in the parameter list -or the pointer to the argv array with an additional parameter. -This additional parameter is an array of pointers to NUL-terminated strings -and -.Em must -be terminated by a -.Dv NULL -pointer. -The other functions take the environment for the new process image from the -external variable -.Va environ -in the current process. -.Pp -Some of these functions have special semantics. -.Pp -The functions -.Fn execlp , -.Fn execlpe , -.Fn execvp , -and -.Fn execvpe -will duplicate the actions of the shell in searching for an executable file -if the specified file name does not contain a slash -.Dq Li \&/ -character. -The search path is the path specified in the environment by the -.Ev PATH -variable. -If this variable isn't specified, -.Va _PATH_DEFPATH -from -.In paths.h -is used instead, its value being: -.Pa /usr/bin:/bin:/usr/pkg/bin:/usr/local/bin . -In addition, certain errors are treated specially. -.Pp -If permission is denied for a file (the attempted -.Xr execve 2 -returned -.Er EACCES ) , -these functions will continue searching the rest of -the search path. -If no other file is found, however, they will return with the global variable -.Va errno -set to -.Er EACCES . -.Pp -If the header of a file isn't recognized (the attempted -.Xr execve 2 -returned -.Er ENOEXEC ) , -these functions will execute the shell with the path of -the file as its first argument. -(If this attempt fails, no further searching is done.) -.Pp -If the file is currently busy (the attempted -.Xr execve 2 -returned -.Er ETXTBUSY ) , -these functions will sleep for several seconds, -periodically re-attempting to execute the file. -.Pp -The function -.Fn exect -executes a file with the program tracing facilities enabled (see -.Xr ptrace 2 ) . -.Sh RETURN VALUES -If any of the -.Fn exec -functions returns, an error will have occurred. -The return value is \-1, and the global variable -.Va errno -will be set to indicate the error. -.Sh FILES -.Bl -tag -width /bin/sh -compact -.It Pa /bin/sh -The shell. -.El -.Sh COMPATIBILITY -Historically, the default path for the -.Fn execlp -.Fn execlpe , -.Fn execvp , -and -.Fn execvpe -functions was -.Dq Pa :/bin:/usr/bin . -This was changed to improve security and behaviour. -.Pp -The behavior of -.Fn execlp , -.Fn execlpe , -.Fn execvp , -and -.Fn execvpe -when errors occur while attempting to execute the file is historic -practice, but has not traditionally been documented and is not specified -by the -.Tn POSIX -standard. -.Pp -Traditionally, the functions -.Fn execlp , -.Fn execlpe , -.Fn execvp , -and -.Fn execvpe -ignored all errors except for the ones described above and -.Er ENOMEM -and -.Er E2BIG , -upon which they returned. -They now return if any error other than the ones described above occurs. -.Sh ERRORS -.Fn execl , -.Fn execle , -.Fn execlp , -.Fn execlpe , -.Fn execvp , -and -.Fn execvpe -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr execve 2 -and -.Xr malloc 3 . -.Pp -.Fn exect -and -.Fn execv -may fail and set -.Va errno -for any of the errors specified for the library function -.Xr execve 2 . -.Sh SEE ALSO -.Xr sh 1 , -.Xr execve 2 , -.Xr fork 2 , -.Xr ptrace 2 , -.Xr environ 7 , -.Xr script 7 -.Sh STANDARDS -.Fn execl , -.Fn execv , -.Fn execle , -.Fn execlp , -and -.Fn execvp -conform to -.St -p1003.1-90 . -.Pp -The -.Fn execlpe -function appeared first in QNX and the -.Fn execvpe -function exists on both -.Lx -and QNX. diff --git a/lib/libc/gen/execl.c b/lib/libc/gen/execl.c deleted file mode 100644 index cdc45ffac..000000000 --- a/lib/libc/gen/execl.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: execl.c,v 1.17 2011/06/30 19:46:07 joerg Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: execl.c,v 1.17 2011/06/30 19:46:07 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include "reentrant.h" - -#ifdef __weak_alias -__weak_alias(execl,_execl) -#endif - - -extern char **environ; - -int -execl(const char *name, const char *arg, ...) -{ - int r; - va_list ap; - char **argv; - int i; - - va_start(ap, arg); - for (i = 2; va_arg(ap, char *) != NULL; i++) - continue; - va_end(ap); - - if ((argv = alloca(i * sizeof (char *))) == NULL) { - errno = ENOMEM; - return -1; - } - - va_start(ap, arg); - argv[0] = __UNCONST(arg); - for (i = 1; (argv[i] = va_arg(ap, char *)) != NULL; i++) - continue; - va_end(ap); - - r = execve(name, argv, environ); - return r; -} diff --git a/lib/libc/gen/execle.c b/lib/libc/gen/execle.c deleted file mode 100644 index 9c91b88fe..000000000 --- a/lib/libc/gen/execle.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: execle.c,v 1.12 2011/06/30 19:46:07 joerg Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: execle.c,v 1.12 2011/06/30 19:46:07 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(execle,_execle) -#endif - -int -execle(const char *name, const char *arg, ...) -{ - va_list ap; - char **argv, **envp; - int i; - - va_start(ap, arg); - for (i = 2; va_arg(ap, char *) != NULL; i++) - continue; - va_end(ap); - - argv = alloca(i * sizeof (char *)); - - va_start(ap, arg); - argv[0] = __UNCONST(arg); - for (i = 1; (argv[i] = va_arg(ap, char *)) != NULL; i++) - continue; - envp = va_arg(ap, char **); - va_end(ap); - - return execve(name, argv, envp); -} diff --git a/lib/libc/gen/execlp.c b/lib/libc/gen/execlp.c deleted file mode 100644 index 61ca3c777..000000000 --- a/lib/libc/gen/execlp.c +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: execlp.c,v 1.13 2014/09/26 19:28:03 christos Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: execlp.c,v 1.13 2014/09/26 19:28:03 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(execlp,_execlp) -__weak_alias(execlpe,_execlpe) -#endif - -int -execlp(const char *name, const char *arg, ...) -{ - va_list ap; - char **argv; - size_t i; - - va_start(ap, arg); - for (i = 2; va_arg(ap, char *) != NULL; i++) - continue; - va_end(ap); - - argv = alloca(i * sizeof (char *)); - - va_start(ap, arg); - argv[0] = __UNCONST(arg); - for (i = 1; (argv[i] = va_arg(ap, char *)) != NULL; i++) - continue; - va_end(ap); - - return execvp(name, argv); -} - -int -execlpe(const char *name, const char *arg, ...) -{ - va_list ap; - char **argv, **envp; - size_t i; - - va_start(ap, arg); - for (i = 2; va_arg(ap, char *) != NULL; i++) - continue; - va_end(ap); - - argv = alloca(i * sizeof (char *)); - - va_start(ap, arg); - argv[0] = __UNCONST(arg); - for (i = 1; (argv[i] = va_arg(ap, char *)) != NULL; i++) - continue; - envp = va_arg(ap, char **); - va_end(ap); - - return execvpe(name, argv, envp); -} diff --git a/lib/libc/gen/execv.c b/lib/libc/gen/execv.c deleted file mode 100644 index 148b4c2b2..000000000 --- a/lib/libc/gen/execv.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: execv.c,v 1.10 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: execv.c,v 1.10 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include "reentrant.h" - -#ifdef __weak_alias -__weak_alias(execv,_execv) -#endif - -extern char **environ; - -int -execv(const char *name, char * const *argv) -{ - return execve(name, argv, environ); -} diff --git a/lib/libc/gen/execvp.c b/lib/libc/gen/execvp.c deleted file mode 100644 index 216a097ae..000000000 --- a/lib/libc/gen/execvp.c +++ /dev/null @@ -1,162 +0,0 @@ -/* $NetBSD: execvp.c,v 1.31 2014/09/26 19:28:03 christos Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)exec.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: execvp.c,v 1.31 2014/09/26 19:28:03 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include "reentrant.h" - -#ifdef __weak_alias -__weak_alias(execvp,_execvp) -__weak_alias(execvpe,_execvpe) -#endif - -int -execvpe(const char *name, char * const *argv, char * const * envp) -{ - const char **memp; - int cnt; - size_t lp, ln; - int eacces = 0; - unsigned int etxtbsy = 0; - char buf[PATH_MAX]; - const char *bp, *path, *p; - - _DIAGASSERT(name != NULL); - - /* "" is not a valid filename; check this before traversing PATH. */ - if (name[0] == '\0') { - errno = ENOENT; - goto done; - } - ln = strlen(name); - /* If it's an absolute or relative path name, it's easy. */ - if (strchr(name, '/')) { - bp = name; - path = ""; - goto retry; - } - bp = buf; - - /* Get the path we're searching. */ - if (!(path = getenv("PATH"))) - path = _PATH_DEFPATH; - - do { - /* Find the end of this path element. */ - for (p = path; *path != 0 && *path != ':'; path++) - continue; - /* - * It's a SHELL path -- double, leading and trailing colons - * mean the current directory. - */ - if (p == path) { - p = "."; - lp = 1; - } else - lp = path - p; - - /* - * If the path is too long complain. This is a possible - * security issue; given a way to make the path too long - * the user may execute the wrong program. - */ - if (lp + ln + 2 > sizeof(buf)) { - (void)write(STDERR_FILENO, "execvp: ", 8); - (void)write(STDERR_FILENO, p, lp); - (void)write(STDERR_FILENO, ": path too long\n", 16); - continue; - } - memcpy(buf, p, lp); - buf[lp] = '/'; - memcpy(buf + lp + 1, name, ln); - buf[lp + ln + 1] = '\0'; - -retry: (void)execve(bp, argv, envp); - switch (errno) { - case EACCES: - eacces = 1; - break; - case ENOTDIR: - case ENOENT: - break; - case ENOEXEC: - for (cnt = 0; argv[cnt] != NULL; ++cnt) - continue; - /* - * we can't use malloc here because, if we are doing - * vfork+exec, it leaks memory in the parent. - */ - if ((memp = alloca((cnt + 2) * sizeof(*memp))) == NULL) - goto done; - memp[0] = _PATH_BSHELL; - memp[1] = bp; - (void)memcpy(&memp[2], &argv[1], cnt * sizeof(*memp)); - (void)execve(_PATH_BSHELL, __UNCONST(memp), envp); - goto done; - case ETXTBSY: - if (etxtbsy < 3) - (void)sleep(++etxtbsy); - goto retry; - default: - goto done; - } - } while (*path++ == ':'); /* Otherwise, *path was NUL */ - if (eacces) - errno = EACCES; - else if (!errno) - errno = ENOENT; -done: - return (-1); -} - -extern char **environ; - -int -execvp(const char *name, char * const *argv) -{ - return execvpe(name, argv, environ); -} diff --git a/lib/libc/gen/extattr.c b/lib/libc/gen/extattr.c deleted file mode 100644 index 5499b912c..000000000 --- a/lib/libc/gen/extattr.c +++ /dev/null @@ -1,381 +0,0 @@ -/* $NetBSD: extattr.c,v 1.4 2012/03/13 21:13:34 christos Exp $ */ - -/*- - * Copyright (c) 2001 Robert N. M. Watson - * 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. - */ - -/* - * TrustedBSD: Utility functions for extended attributes. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: extattr.c,v 1.4 2012/03/13 21:13:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include -#include - -const int extattr_namespaces[] = { - EXTATTR_NAMESPACE_USER, - EXTATTR_NAMESPACE_SYSTEM, - 0, -}; - -int -extattr_namespace_to_string(int attrnamespace, char **string) -{ - - switch(attrnamespace) { - case EXTATTR_NAMESPACE_USER: - if (string != NULL) { - if ((*string = - strdup(EXTATTR_NAMESPACE_USER_STRING)) == NULL) - return (-1); - } - return (0); - - case EXTATTR_NAMESPACE_SYSTEM: - if (string != NULL) - if ((*string = - strdup(EXTATTR_NAMESPACE_SYSTEM_STRING)) == NULL) - return (-1); - return (0); - - default: - errno = EINVAL; - return (-1); - } -} - -int -extattr_string_to_namespace(const char *string, int *attrnamespace) -{ - - if (strcmp(string, EXTATTR_NAMESPACE_USER_STRING) == 0) { - if (attrnamespace != NULL) - *attrnamespace = EXTATTR_NAMESPACE_USER; - return (0); - } else if (strcmp(string, EXTATTR_NAMESPACE_SYSTEM_STRING) == 0) { - if (attrnamespace != NULL) - *attrnamespace = EXTATTR_NAMESPACE_SYSTEM; - return (0); - } else { - errno = EINVAL; - return (-1); - } -} - - -int -extattr_copy_fd(int from_fd, int to_fd, int namespace) -{ - ssize_t llen, vlen, maxvlen; - size_t alen; - void *alist = NULL; - void *aval = NULL; - size_t i; - int error = -1; - - llen = extattr_list_fd(from_fd, namespace, NULL, 0); - if (llen == -1) { - /* Silently ignore when EA are not supported */ - if (errno == EOPNOTSUPP) - error = 0; - goto out; - } - - if (llen == 0) { - error = 0; - goto out; - } - - if ((alist = malloc((size_t)llen)) == NULL) - goto out; - - llen = extattr_list_fd(from_fd, namespace, alist, (size_t)llen); - if (llen == -1) - goto out; - - maxvlen = 1024; - if ((aval = malloc((size_t)maxvlen)) == NULL) - goto out; - - for (i = 0; i < (size_t)llen; i += alen + 1) { - char aname[NAME_MAX + 1]; - char *ap; - - alen = ((uint8_t *)alist)[i]; - ap = ((char *)alist) + i + 1; - (void)memcpy(aname, ap, alen); - aname[alen] = '\0'; - - vlen = extattr_get_fd(from_fd, namespace, aname, NULL, 0); - if (vlen == -1) - goto out; - - if (vlen > maxvlen) { - if ((aval = realloc(aval, (size_t)vlen)) == NULL) - goto out; - maxvlen = vlen; - } - - if ((vlen = extattr_get_fd(from_fd, namespace, aname, - aval, (size_t)vlen)) == -1) - goto out; - - if (extattr_set_fd(to_fd, namespace, aname, - aval, (size_t)vlen) != vlen) - goto out; - } - - error = 0; -out: - if (aval != NULL) - free(aval); - - if (alist != NULL) - free(alist); - - return error; -} - -int -extattr_copy_file(const char *from, const char *to, int namespace) -{ - ssize_t llen, vlen, maxvlen; - size_t alen; - void *alist = NULL; - void *aval = NULL; - size_t i; - int error = -1; - - llen = extattr_list_file(from, namespace, NULL, 0); - if (llen == -1) { - /* Silently ignore when EA are not supported */ - if (errno == EOPNOTSUPP) - error = 0; - goto out; - } - - if (llen == 0) { - error = 0; - goto out; - } - - if ((alist = malloc((size_t)llen)) == NULL) - goto out; - - llen = extattr_list_file(from, namespace, alist, (size_t)llen); - if (llen == -1) - goto out; - - maxvlen = 1024; - if ((aval = malloc((size_t)maxvlen)) == NULL) - goto out; - - for (i = 0; i < (size_t)llen; i += alen + 1) { - char aname[NAME_MAX + 1]; - char *ap; - - alen = ((uint8_t *)alist)[i]; - ap = ((char *)alist) + i + 1; - (void)memcpy(aname, ap, alen); - aname[alen] = '\0'; - - vlen = extattr_get_file(from, namespace, aname, NULL, 0); - if (vlen == -1) - goto out; - - if (vlen > maxvlen) { - if ((aval = realloc(aval, (size_t)vlen)) == NULL) - goto out; - maxvlen = vlen; - } - - if ((vlen = extattr_get_file(from, namespace, aname, aval, (size_t)vlen)) == -1) - goto out; - - if (extattr_set_file(to, namespace, aname, - aval, (size_t)vlen) != vlen) - goto out; - } - - error = 0; -out: - if (aval != NULL) - free(aval); - - if (alist != NULL) - free(alist); - - return error; -} - -int -extattr_copy_link(const char *from, const char *to, int namespace) -{ - ssize_t llen, vlen, maxvlen; - size_t alen; - void *alist = NULL; - void *aval = NULL; - size_t i; - int error = -1; - - llen = extattr_list_link(from, namespace, NULL, 0); - if (llen == -1) { - /* Silently ignore when EA are not supported */ - if (errno == EOPNOTSUPP) - error = 0; - goto out; - } - - if (llen == 0) { - error = 0; - goto out; - } - - if ((alist = malloc((size_t)llen)) == NULL) - goto out; - - llen = extattr_list_link(from, namespace, alist, (size_t)llen); - if (llen == -1) - goto out; - - maxvlen = 1024; - if ((aval = malloc((size_t)maxvlen)) == NULL) - goto out; - - for (i = 0; i < (size_t)llen; i += alen + 1) { - char aname[NAME_MAX + 1]; - char *ap; - - alen = ((uint8_t *)alist)[i]; - ap = ((char *)alist) + i + 1; - (void)memcpy(aname, ap, alen); - aname[alen] = '\0'; - - vlen = extattr_get_link(from, namespace, aname, NULL, 0); - if (vlen == -1) - goto out; - - if (vlen > maxvlen) { - if ((aval = realloc(aval, (size_t)vlen)) == NULL) - goto out; - maxvlen = vlen; - } - - if ((vlen = extattr_get_link(from, namespace, aname, - aval, (size_t)vlen)) == -1) - goto out; - - if (extattr_set_link(to, namespace, aname, - aval, (size_t)vlen) != vlen) - goto out; - } - - error = 0; -out: - if (aval != NULL) - free(aval); - - if (alist != NULL) - free(alist); - - return error; -} - -static int -extattr_namespace_access(int namespace, int mode) -{ - switch (namespace) { - case EXTATTR_NAMESPACE_SYSTEM: - if ((mode & (R_OK|W_OK)) && getuid() != 0) - return -1; - break; - default: - break; - } - - return 0; -} - -int -fcpxattr(int from_fd, int to_fd) -{ - const int *ns; - int error; - - for (ns = extattr_namespaces; *ns; ns++) { - if (extattr_namespace_access(*ns, R_OK|W_OK) != 0) - continue; - - if ((error = extattr_copy_fd(from_fd, to_fd, *ns)) != 0) - return error; - } - - return 0; -} - -int -cpxattr(const char *from, const char *to) -{ - const int *ns; - int error; - - for (ns = extattr_namespaces; *ns; ns++) { - if (extattr_namespace_access(*ns, R_OK|W_OK) != 0) - continue; - - if ((error = extattr_copy_file(from, to, *ns)) != 0) - return error; - } - - return 0; -} - -int -lcpxattr(const char *from, const char *to) -{ - const int *ns; - int error; - - for (ns = extattr_namespaces; *ns; ns++) { - if (extattr_namespace_access(*ns, R_OK|W_OK) != 0) - continue; - - if ((error = extattr_copy_link(from, to, *ns)) != 0) - return error; - } - - return 0; -} diff --git a/lib/libc/gen/extattr_copy_file.3 b/lib/libc/gen/extattr_copy_file.3 deleted file mode 100644 index 9f9a2a00d..000000000 --- a/lib/libc/gen/extattr_copy_file.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" $NetBSD: extattr_copy_file.3,v 1.2 2011/12/16 15:21:13 manu Exp $ -.\" -.\" Copyright (c) 2001 Dima Dorfman -.\" Copyright (c) 2011 Emmanuel Dreyfus -.\" 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: src/lib/libc/posix1e/extattr.3,v 1.5 2002/12/12 17:25:53 ru Exp -.\" -.Dd December 16, 2011 -.Dt EXTATTR_COPY_FILE 3 -.Os -.Sh NAME -.Nm extattr_copy_file , -.Nm extattr_copy_fd , -.Nm extattr_copy_link , -.Nm cpxattr , -.Nm fcpxattr , -.Nm lcpxattr -.Nd copy extended attributes from a file to another one -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/extattr.h -.Ft int -.Fn extattr_copy_file "const char *from" "const char *to" "int namespace" -.Ft int -.Fn extattr_copy_fd "int from_fd" "int to_fd" "int namespace" -.Ft int -.Fn extattr_copy_link "const char *from" "const char *to" "int namespace" -.Ft int -.Fn cpxattr "const char *from" "const char *to" -.Ft int -.Fn fcpxattr "int from_fd" "int to_fd" -.Ft int -.Fn lcpxattr "const char *from" "const char *to" -.Sh DESCRIPTION -.Fn extattr_copy_file -copies extended attributes of namespace -.Ar namespace -from a file to another one. -.Fn extattr_copy_fd -does the same using open file descriptors, and -.Fn extattr_copy_link -does the same as -.Fn extattr_copy_file -but operates on symbolic links themselves instead of their targets. -.Pp -.Fn cpxattr , -.Fn fcpxattr , -and -.Fn lcpxattr -respectively work the same was as -.Fn extattr_copy_file , -.Fn extattr_copy_fd , -and -.Fn extattr_copy_link , -but will copy extended attributes from all namespaces accessible to the user, -silently skiping unaccessible namespaces. -.Pp -Please note that none of the extended attribute copying functions are atomic. -.Sh RETURN VALUES -If any of the calls are unsuccessful, the value \-1 is returned -and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -Extended attribute copying functions may raise errors produced by -.Xr extattr_list_file 2 -and -.Xr extattr_get_file 2 . -.Sh SEE ALSO -.Xr getextattr 1 , -.Xr extattr_get_file 2 , -.Xr extattr_namespace_to_string 3 , -.Xr extattr 9 -.Sh HISTORY -Extended attribute support was developed as part of the -.Tn TrustedBSD -Project, and introduced in -.Fx 5.0 -and -.Nx 3.0 . -It was developed to support security extensions requiring additional labels -to be associated with each file or directory. diff --git a/lib/libc/gen/extattr_namespace_to_string.3 b/lib/libc/gen/extattr_namespace_to_string.3 deleted file mode 100644 index 6df4b11d4..000000000 --- a/lib/libc/gen/extattr_namespace_to_string.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" $NetBSD: extattr_namespace_to_string.3,v 1.1 2011/12/16 12:46:00 wiz Exp $ -.\" -.\" Copyright (c) 2001 Dima Dorfman -.\" Copyright (c) 2011 Emmanuel Dreyfus -.\" 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: src/lib/libc/posix1e/extattr.3,v 1.5 2002/12/12 17:25:53 ru Exp -.\" -.Dd December 16, 2011 -.Dt EXTATTR_NAMESPACE_TO_STRING 3 -.Os -.Sh NAME -.Nm extattr_namespace_to_string , -.Nm extattr_string_to_namespace -.Nd convert an extended attribute namespace identifier to a string and vice versa -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/extattr.h -.Ft int -.Fn extattr_namespace_to_string "int attrnamespace" "char **string" -.Ft int -.Fn extattr_string_to_namespace "const char *string" "int *attrnamespace" -.Sh DESCRIPTION -The -.Fn extattr_namespace_to_string -function converts a VFS extended attribute identifier to a human-readable -string. -The -.Fn extattr_string_to_namespace -converts a human-readable string representing a namespace to a -namespace identifier. -Although a file system may implement arbitrary namespaces, -these functions only support the -.Dv EXTATTR_NAMESPACE_USER -.Pq Dq user -and -.Dv EXTATTR_NAMESPACE_SYSTEM -.Pq Dq system -namespaces, -which are defined in -.Xr extattr 9 . -.Pp -These functions are meant to be used in error reporting and other -interactive tasks. -For example, -instead of printing the integer identifying an extended attribute in -an error message, -a program might use -.Fn extattr_namespace_to_string -to obtain a human-readable representation. -Likewise, -instead of requiring a user to enter the integer representing a namespace, -an interactive program might ask for a name and use -.Fn extattr_string_to_namespace -to get the desired identifier. -.Sh RETURN VALUES -If any of the calls are unsuccessful, the value \-1 is returned -and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width Er -.It Bq Er EINVAL -The requested namespace could not be identified. -.El -.Sh SEE ALSO -.Xr getextattr 1 , -.Xr extattr_get_file 2 , -.Xr extattr_copy_file 3 , -.Xr extattr 9 -.Sh HISTORY -Extended attribute support was developed as part of the -.Tn TrustedBSD -Project, and introduced in -.Fx 5.0 -and -.Nx 3.0 . -It was developed to support security extensions requiring additional labels -to be associated with each file or directory. diff --git a/lib/libc/gen/fabs_ieee754.c b/lib/libc/gen/fabs_ieee754.c deleted file mode 100644 index b10a6ec07..000000000 --- a/lib/libc/gen/fabs_ieee754.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: fabs_ieee754.c,v 1.3 2013/11/29 22:15:26 joerg Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fabs_ieee754.c,v 1.3 2013/11/29 22:15:26 joerg Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 fabs - return the absolute value of the argument - * IEEE 754 double-precision version - */ -#ifndef __HAVE_LONG_DOUBLE -__strong_alias(fabsl, fabs) -#endif - -double -fabs(double x) -{ - union ieee_double_u u; - - u.dblu_d = x; - - u.dblu_dbl.dbl_sign = 0; - - return u.dblu_d; -} diff --git a/lib/libc/gen/fixunsdfsi_ieee754.c b/lib/libc/gen/fixunsdfsi_ieee754.c deleted file mode 100644 index 550089c3b..000000000 --- a/lib/libc/gen/fixunsdfsi_ieee754.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: fixunsdfsi_ieee754.c,v 1.3 2013/04/30 01:44:07 matt Exp $ */ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunsdfsi_ieee754.c,v 1.3 2013/04/30 01:44:07 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -uint32_t __fixunsgen32(int, bool, size_t, size_t, const uint32_t *); - -uint32_t __fixunsdfsi(double); - -/* - * Convert double to (unsigned) int. All operations are done module 2^32. - */ -uint32_t -__fixunsdfsi(double x) -{ - const union ieee_double_u dblu = { .dblu_d = x }; - const uint32_t frac[(DBL_FRACBITS + 31)/32 + 1] = { - [0] = 0, - [1] = dblu.dblu_dbl.dbl_fracl, - [2] = dblu.dblu_dbl.dbl_frach, - }; - - return __fixunsgen32( - dblu.dblu_dbl.dbl_exp - DBL_EXP_BIAS, - dblu.dblu_dbl.dbl_sign != 0, - DBL_MANT_DIG, - DBL_FRACHBITS, - &frac[__arraycount(frac)-1]); -} diff --git a/lib/libc/gen/fixunsgen64_ieee754.c b/lib/libc/gen/fixunsgen64_ieee754.c deleted file mode 100644 index bb3417090..000000000 --- a/lib/libc/gen/fixunsgen64_ieee754.c +++ /dev/null @@ -1,45 +0,0 @@ -/* $NetBSD: fixunsgen64_ieee754.c,v 1.1 2011/07/09 02:30:27 matt Exp $ */ - -/*- - * 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. - * 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 - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunsgen64_ieee754.c,v 1.1 2011/07/09 02:30:27 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define FIXUNSNAME(n) n##64 -#define UINTXX_T uint64_t - -#include "fixunsgen_ieee754.c" diff --git a/lib/libc/gen/fixunsgen_ieee754.c b/lib/libc/gen/fixunsgen_ieee754.c deleted file mode 100644 index d10fd7a79..000000000 --- a/lib/libc/gen/fixunsgen_ieee754.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $NetBSD: fixunsgen_ieee754.c,v 1.3 2012/03/25 19:53:41 christos Exp $ */ - -/*- - * 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. - * 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 - -#if !defined(FIXUNSNAME) && defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunsgen_ieee754.c,v 1.3 2012/03/25 19:53:41 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#ifndef FIXUNSNAME -#define FIXUNSNAME(n) n##32 -#define UINTXX_T uint32_t -#endif - -__dso_hidden UINTXX_T - FIXUNSNAME(__fixunsgen)(int, bool, size_t, size_t, const uint32_t *); - -/* - * Convert double to (unsigned) int. All operations are done module 2^32. - */ -UINTXX_T -FIXUNSNAME(__fixunsgen)(int exp, bool sign, size_t mant_dig, size_t fracbits, - const uint32_t *frac) -{ - UINTXX_T tmp; - - /* - * If it's less than 1 (negative exponent), it's going to round - * to zero. If the exponent is so large that it is a multiple of - * 2^N, then x module 2^N will be 0. (we use the fact treating a - * negative value as unsigned will be greater than nonnegative value) - */ - if (__predict_false((size_t)exp >= mant_dig + sizeof(UINTXX_T)*8)) - return 0; - - /* - * This is simplier than it seems. Basically we are constructing - * fixed binary representation of the floating point number tossing - * away bits that wont be in the modulis we return. - */ - tmp = 1; - for (size_t ebits = exp;;) { - if (ebits <= fracbits) { - /* - * The current fraction has more bits than we need. - * Shift the current value over and insert the bits - * we want. We're done. - */ - tmp <<= (unsigned int)ebits; - tmp |= *frac >> (fracbits - ebits); - break; - } - if (fracbits == sizeof(tmp)*4) { - /* - * Shifts must be < sizeof(type). If it's going to be - * sizeof(type), just replace the value. - */ - tmp = *frac--; - } else { - tmp <<= (unsigned int)fracbits; - tmp |= *frac--; - } - ebits -= fracbits; - fracbits = sizeof(frac[0]) * 4; - } - - /* - * If the input was negative, make tmp negative module 2^32. - */ - if (sign) - tmp = -tmp; - - return tmp; -} diff --git a/lib/libc/gen/fixunssfsi_ieee754.c b/lib/libc/gen/fixunssfsi_ieee754.c deleted file mode 100644 index 41de76694..000000000 --- a/lib/libc/gen/fixunssfsi_ieee754.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: fixunssfsi_ieee754.c,v 1.3 2013/04/30 01:44:07 matt Exp $ */ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunssfsi_ieee754.c,v 1.3 2013/04/30 01:44:07 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -uint32_t __fixunsgen32(int, bool, size_t, size_t, const uint32_t *); - -uint32_t __fixunssfsi(float); - -/* - * Convert float to (unsigned) int. All operations are done module 2^32. - */ -uint32_t -__fixunssfsi(float x) -{ - const union ieee_single_u sngu = { .sngu_f = x }; - const uint32_t frac[(SNG_FRACBITS + 31)/32 + 1] = { - [0] = 0, - [1] = sngu.sngu_sng.sng_frac, - }; - - return __fixunsgen32( - sngu.sngu_sng.sng_exp - SNG_EXP_BIAS, - sngu.sngu_sng.sng_sign != 0, - FLT_MANT_DIG, - SNG_FRACBITS, - &frac[__arraycount(frac)-1]); -} diff --git a/lib/libc/gen/fixunstfdi_ieee754.c b/lib/libc/gen/fixunstfdi_ieee754.c deleted file mode 100644 index 9c906cfb9..000000000 --- a/lib/libc/gen/fixunstfdi_ieee754.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: fixunstfdi_ieee754.c,v 1.1 2011/07/09 02:30:27 matt Exp $ */ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunstfdi_ieee754.c,v 1.1 2011/07/09 02:30:27 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#if defined(__x86_64__) || defined(__i486__) -#define FIXUNS __fixunsxfdi -#else -#define FIXUNS __fixunstfdi -#endif - -uint64_t __fixunsgen64(int, bool, size_t, size_t, const uint32_t *); - -uint64_t FIXUNS(long double); - -/* - * Convert long double to uint64_t. All operations are done module 2^64. - */ -uint64_t -FIXUNS(long double x) -{ - const union ieee_ext_u extu = { .extu_ld = x }; - uint32_t frac[(EXT_FRACBITS + 31)/32 + 2]; - - frac[0] = 0; - frac[1] = 0; - - EXT_TO_ARRAY32(extu, &frac[2]); - - return __fixunsgen64( - extu.extu_ext.ext_exp - EXT_EXP_BIAS, - extu.extu_ext.ext_sign != 0, - LDBL_MANT_DIG, - EXT_FRACHBITS, - &frac[__arraycount(frac)-1]); -} diff --git a/lib/libc/gen/fixunstfsi_ieee754.c b/lib/libc/gen/fixunstfsi_ieee754.c deleted file mode 100644 index d055ce709..000000000 --- a/lib/libc/gen/fixunstfsi_ieee754.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: fixunstfsi_ieee754.c,v 1.2 2012/08/05 04:28:58 matt Exp $ */ -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunstfsi_ieee754.c,v 1.2 2012/08/05 04:28:58 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -#ifdef SOFTFLOAT -#include "softfloat/softfloat-for-gcc.h" -#endif - -#if defined(__x86_64__) || defined(__i486__) -#define FIXUNS __fixunsxfsi -#else -#define FIXUNS __fixunstfsi -#endif - -uint32_t __fixunsgen32(int, bool, size_t, size_t, const uint32_t *); - -uint32_t FIXUNS(long double); - -/* - * Convert long double to (unsigned) int. All operations are done module 2^32. - */ -uint32_t -FIXUNS(long double x) -{ - const union ieee_ext_u extu = { .extu_ld = x }; - uint32_t frac[(EXT_FRACBITS + 31)/32 + 1]; - - frac[0] = 0; - - EXT_TO_ARRAY32(extu, &frac[1]); - - return __fixunsgen32( - extu.extu_ext.ext_exp - EXT_EXP_BIAS, - extu.extu_ext.ext_sign != 0, - LDBL_MANT_DIG, - EXT_FRACHBITS, - &frac[__arraycount(frac)-1]); -} diff --git a/lib/libc/gen/floatunditf_ieee754.c b/lib/libc/gen/floatunditf_ieee754.c deleted file mode 100644 index 38f2f4023..000000000 --- a/lib/libc/gen/floatunditf_ieee754.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: floatunditf_ieee754.c,v 1.1 2014/01/30 15:06:18 joerg Exp $ */ - -/*- - * Copyright (c) 2014 Joerg Sonnenberger . - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS 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 - * COPYRIGHT HOLDERS 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 -__RCSID("$NetBSD: floatunditf_ieee754.c,v 1.1 2014/01/30 15:06:18 joerg Exp $"); - -#include -#include -#include - -#ifdef __HAVE_LONG_DOUBLE - -long double __floatunditf(uint64_t x); - -/* - * Convert uint64_t to long double. - */ -long double -__floatunditf(uint64_t x) -{ - int exponent, zeros; - union ieee_ext_u ux; - - /* Use the easier conversion routine for uint32_t if possible. */ - if (x <= UINT32_MAX) - return (long double)(uint32_t)x; - - zeros = __builtin_clzll(x); -#ifdef LDBL_IMPLICIT_NBIT - exponent = 64 - zeros; - x <<= zeros + 1; -#else - exponent = 63 - zeros; - x <<= zeros; -#endif - - ux.extu_exp = EXT_EXP_BIAS + exponent; - ux.extu_frach = (x >> (64 - EXT_FRACHBITS)); - x <<= EXT_FRACHBITS; -#ifdef EXT_FRACHMBITS - ux.extu_frachm = (x >> (64 - EXT_FRACHMBITS)); - x <<= EXT_FRACHMBITS; -#endif -#ifdef EXT_FRACLMBITS - ux.extu_fraclm = (x >> (64 - EXT_FRACLMBITS)); - x <<= EXT_FRACLMBITS; -#endif - ux.extu_fracl = (x >> (64 - EXT_FRACLBITS)); - ux.extu_sign = 0; - - return ux.extu_ld; -} -#endif /* __HAVE_LONG_DOUBLE */ diff --git a/lib/libc/gen/floatunsidf_ieee754.c b/lib/libc/gen/floatunsidf_ieee754.c deleted file mode 100644 index 03b40e1a2..000000000 --- a/lib/libc/gen/floatunsidf_ieee754.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: floatunsidf_ieee754.c,v 1.1 2013/08/23 16:01:35 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: floatunsidf_ieee754.c,v 1.1 2013/08/23 16:01:35 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include - -double __floatunsidf(uint32_t); - -/* - * Convert (unsigned) int to double. - */ -double -__floatunsidf(uint32_t x) -{ - union ieee_double_u u; - - if (x == 0) - return 0.0; - if (x == 1) - return 1.0; - - u_int l = __builtin_clz(x); - x <<= (l + 1); /* clear implicit bit */ - - u.dblu_sign = 0; - u.dblu_exp = DBL_EXP_BIAS + 31 - l; - u.dblu_frach = x >> (32 - DBL_FRACHBITS); - u.dblu_fracl = x << (32 - DBL_FRACHBITS); - - return u.dblu_d; -} diff --git a/lib/libc/gen/floatunsisf_ieee754.c b/lib/libc/gen/floatunsisf_ieee754.c deleted file mode 100644 index 40174b557..000000000 --- a/lib/libc/gen/floatunsisf_ieee754.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: floatunsisf_ieee754.c,v 1.1 2013/08/23 16:01:35 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: floatunsisf_ieee754.c,v 1.1 2013/08/23 16:01:35 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include - -float __floatunsisf(uint32_t); - -/* - * Convert (unsigned) int to float. - */ -float -__floatunsisf(uint32_t x) -{ - union ieee_single_u u; - - if (x == 0) - return 0.0; - if (x == 1) - return 1.0; - - u_int l = __builtin_clz(x); - x <<= (l + 1); /* clear implicit bit */ - - u.sngu_sign = 0; - u.sngu_exp = SNG_EXP_BIAS + 31 - l; - u.sngu_frac = x >> (32 - SNG_FRACBITS); - - return u.sngu_f; -} diff --git a/lib/libc/gen/fmtcheck.3 b/lib/libc/gen/fmtcheck.3 deleted file mode 100644 index 8907521c3..000000000 --- a/lib/libc/gen/fmtcheck.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" $NetBSD: fmtcheck.3,v 1.8 2014/06/14 08:18:24 apb Exp $ -.\" -.\" Copyright (c) 2000 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This file was contributed to The NetBSD Foundation by Allen Briggs. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd June 14, 2014 -.Dt FMTCHECK 3 -.Os -.Sh NAME -.Nm fmtcheck -.Nd sanitizes user-supplied printf(3)-style format string -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdio.h -.Ft const char * -.Fn fmtcheck "const char *fmt_suspect" "const char *fmt_default" -.Sh DESCRIPTION -The -.Nm -function scans -.Fa fmt_suspect -and -.Fa fmt_default -to determine if -.Fa fmt_suspect -will consume the same argument types as -.Fa fmt_default -and to ensure that -.Fa fmt_suspect -is a valid format string. -.Pp -The -.Xr printf 3 -family of functions can not verify the types of arguments that they are -passed at run-time. -In some cases, like -.Xr catgets 3 , -it is useful or necessary to use a user-supplied format string with no -guarantee that the format string matches the specified parameters. -.Pp -The -.Nm -function was designed to be used in these cases, as in: -.Bd -literal -offset indent -printf(fmtcheck(user_format, standard_format), arg1, arg2); -.Ed -.Pp -In the check, field widths, fillers, precisions, etc. are ignored (unless -the field width or precision is an asterisk -.Ql * -instead of a digit string). -Also, any text other than the format specifiers is completely ignored. -.Pp -Note that the formats may be quite different as long as they accept the -same parameters. -For example, "%ld %o %30s %#llx %-10.*e %n" is -compatible with "This number %lu %d%% and string %s has %qd numbers -and %.*g floats (%n)." -However, "%o" is not equivalent to "%lx" because -the first requires an integer and the second requires a long, -and "%p" is not equivalent to "%lu" because -the first requires a pointer and the second requires a long. -.Sh RETURN VALUES -If -.Fa fmt_suspect -is a valid format and consumes the same argument types as -.Fa fmt_default , -then the -.Nm -function will return -.Fa fmt_suspect . -Otherwise, it will return -.Fa fmt_default . -.Sh SEE ALSO -.Xr printf 3 diff --git a/lib/libc/gen/fmtcheck.c b/lib/libc/gen/fmtcheck.c deleted file mode 100644 index 8d2653425..000000000 --- a/lib/libc/gen/fmtcheck.c +++ /dev/null @@ -1,244 +0,0 @@ -/* $NetBSD: fmtcheck.c,v 1.9 2014/06/14 08:18:24 apb Exp $ */ - -/*- - * Copyright (c) 2000 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code was contributed to The NetBSD Foundation by Allen Briggs. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtcheck.c,v 1.9 2014/06/14 08:18:24 apb Exp $"); -#endif - -#include "namespace.h" - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fmtcheck,__fmtcheck) -#endif - -enum __e_fmtcheck_types { - FMTCHECK_START, - FMTCHECK_SHORT, - FMTCHECK_INT, - FMTCHECK_LONG, - FMTCHECK_QUAD, - FMTCHECK_POINTER, - FMTCHECK_SHORTPOINTER, - FMTCHECK_INTPOINTER, - FMTCHECK_LONGPOINTER, - FMTCHECK_QUADPOINTER, - FMTCHECK_DOUBLE, - FMTCHECK_LONGDOUBLE, - FMTCHECK_STRING, - FMTCHECK_WIDTH, - FMTCHECK_PRECISION, - FMTCHECK_DONE, - FMTCHECK_UNKNOWN -}; -typedef enum __e_fmtcheck_types EFT; - -#define RETURN(pf,f,r) do { \ - *(pf) = (f); \ - return r; \ - } /*NOTREACHED*/ /*CONSTCOND*/ while (0) - -static EFT -get_next_format_from_precision(const char **pf) -{ - int sh, lg, quad, longdouble; - const char *f; - - sh = lg = quad = longdouble = 0; - - f = *pf; - switch (*f) { - case 'h': - f++; - sh = 1; - break; - case 'l': - f++; - if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); - if (*f == 'l') { - f++; - quad = 1; - } else { - lg = 1; - } - break; - case 'q': - f++; - quad = 1; - break; - case 'L': - f++; - longdouble = 1; - break; - default: - break; - } - if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); - if (strchr("diouxX", *f)) { - if (longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - if (lg) - RETURN(pf,f,FMTCHECK_LONG); - if (quad) - RETURN(pf,f,FMTCHECK_QUAD); - RETURN(pf,f,FMTCHECK_INT); - } - if (*f == 'n') { - if (longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - if (sh) - RETURN(pf,f,FMTCHECK_SHORTPOINTER); - if (lg) - RETURN(pf,f,FMTCHECK_LONGPOINTER); - if (quad) - RETURN(pf,f,FMTCHECK_QUADPOINTER); - RETURN(pf,f,FMTCHECK_INTPOINTER); - } - if (strchr("DOU", *f)) { - if (sh + lg + quad + longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - RETURN(pf,f,FMTCHECK_LONG); - } - if (strchr("eEfg", *f)) { - if (longdouble) - RETURN(pf,f,FMTCHECK_LONGDOUBLE); - if (sh + lg + quad) - RETURN(pf,f,FMTCHECK_UNKNOWN); - RETURN(pf,f,FMTCHECK_DOUBLE); - } - if (*f == 'c') { - if (sh + lg + quad + longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - RETURN(pf,f,FMTCHECK_INT); - } - if (*f == 's') { - if (sh + lg + quad + longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - RETURN(pf,f,FMTCHECK_STRING); - } - if (*f == 'p') { - if (sh + lg + quad + longdouble) - RETURN(pf,f,FMTCHECK_UNKNOWN); - RETURN(pf,f,FMTCHECK_POINTER); - } - RETURN(pf,f,FMTCHECK_UNKNOWN); - /*NOTREACHED*/ -} - -static EFT -get_next_format_from_width(const char **pf) -{ - const char *f; - - f = *pf; - if (*f == '.') { - f++; - if (*f == '*') { - RETURN(pf,f,FMTCHECK_PRECISION); - } - /* eat any precision (empty is allowed) */ - while (isdigit((unsigned char)*f)) f++; - if (!*f) RETURN(pf,f,FMTCHECK_UNKNOWN); - } - RETURN(pf,f,get_next_format_from_precision(pf)); - /*NOTREACHED*/ -} - -static EFT -get_next_format(const char **pf, EFT eft) -{ - int infmt; - const char *f; - - if (eft == FMTCHECK_WIDTH) { - (*pf)++; - return get_next_format_from_width(pf); - } else if (eft == FMTCHECK_PRECISION) { - (*pf)++; - return get_next_format_from_precision(pf); - } - - f = *pf; - infmt = 0; - while (!infmt) { - f = strchr(f, '%'); - if (f == NULL) - RETURN(pf,f,FMTCHECK_DONE); - f++; - if (!*f) - RETURN(pf,f,FMTCHECK_UNKNOWN); - if (*f != '%') - infmt = 1; - else - f++; - } - - /* Eat any of the flags */ - while (*f && (strchr("#0- +", *f))) - f++; - - if (*f == '*') { - RETURN(pf,f,FMTCHECK_WIDTH); - } - /* eat any width */ - while (isdigit((unsigned char)*f)) f++; - if (!*f) { - RETURN(pf,f,FMTCHECK_UNKNOWN); - } - - RETURN(pf,f,get_next_format_from_width(pf)); - /*NOTREACHED*/ -} - -const char * -fmtcheck(const char *f1, const char *f2) -{ - const char *f1p, *f2p; - EFT f1t, f2t; - - if (!f1) return f2; - - f1p = f1; - f1t = FMTCHECK_START; - f2p = f2; - f2t = FMTCHECK_START; - while ((f1t = get_next_format(&f1p, f1t)) != FMTCHECK_DONE) { - if (f1t == FMTCHECK_UNKNOWN) - return f2; - f2t = get_next_format(&f2p, f2t); - if (f1t != f2t) - return f2; - } - return f1; -} diff --git a/lib/libc/gen/fmtmsg.3 b/lib/libc/gen/fmtmsg.3 deleted file mode 100644 index 09a27083b..000000000 --- a/lib/libc/gen/fmtmsg.3 +++ /dev/null @@ -1,220 +0,0 @@ -.\" $NetBSD: fmtmsg.3,v 1.7 2011/04/11 05:59:11 jruoho Exp $ -.\" -.\" Copyright (c) 1999 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 11, 2011 -.Dt FMTMSG 3 -.Os -.Sh NAME -.Nm fmtmsg -.Nd format and display a message -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In fmtmsg.h -.Ft int -.Fn fmtmsg "long classification" "const char *label" "int severity" "const char *text" "const char *action" "const char *tag" -.Sh DESCRIPTION -The -.Fn fmtmsg -function can be used to display messages in the specified format. -Messages may be written either to standard error, to the console, or both. -.Pp -A formatted message consists of up to five components specified in -.Fa label , -.Fa severity , -.Fa text , -.Fa action -and -.Fa tag . -Further information such as the origin of the message, the recoverability -from the condition causing the message and where to display the message -is specified in -.Fa classification . -.Ss Classification -The -.Fa classification -argument consists of a major classification and several sub-classifications. -It has no effect on the content of the message displayed. -With the exception of the display sub-classification, only a single identifier -may be specified for each (sub-)classification. -The following classifications -are available: -.Bl -tag -width "XXX" -.It Em Major classifications -The source of the condition. -Available identifiers are: -.Dv MM_HARD -(hardware), -.Dv MM_SOFT -(software), and -.Dv MM_FIRM -(firmware). -.It Em Message source sub-classifications -The type of software detecting the condition. -Available identifiers are: -.Dv MM_APPL -(application), -.Dv MM_UTIL -(utility), and -.Dv MM_OPSYS -(operating system). -.It Em Display sub-classifications -The displays the formatted messages is to be written to. -Available identifiers are: -.Dv MM_PRINT -(standard error stream) and -.Dv MM_CONSOLE -(system console). -.It Em Status sub-classifications -The capability of the calling software to recover from the condition. -Available identifiers are: -.Dv MM_RECOVER -(recoverable) and -.Dv MM_NRECOV -(non-recoverable). -.El -.Pp -If no -.Fa classification -is to be supplied, -.Dv MM_NULLMC -must be specified. -.Ss Label -The -.Fa label -argument identifies the source of the message. -It consists of two fields separated by a colon (:). -The first field is up to 10 characters, the second is up to 14 characters. -.Pp -If no -.Fa label -is to be supplied, -.Dv MM_NULLLBL -must be specified. -.Ss Severity -The seriousness of the condition causing the message. -The following -.Fa severity -levels are available: -.Bl -tag -width MM_WARNING -offset indent -.It Dv MM_HALT -The software has encountered a severe fault and is halting. -.It Dv MM_ERROR -The software has encountered a fault. -.It Dv MM_WARNING -The software has encountered an unusual non-fault condition. -.It Dv MM_INFO -The software informs about a non-error condition. -.El -.Pp -If no -.Fa severity -level is to be supplied, -.Dv MM_NOSEV -must be specified. -.Ss Text -The description of the condition the software encountered. -The character -string is not limited to a specific size. -.Pp -If no -.Fa text -is to be supplied, -.Dv MM_NOTXT -must be specified. -.Ss Action -The first step to be taken to recover from the condition the software -encountered; it will be preceded by the prefix -.Dq TO FIX: . -The character string is not limited to a specific size. -.Pp -If no -.Fa action -is to be supplied, -.Dv MM_NOACT -must be specified. -.Ss Tag -The on-line documentation which provides further information about the -condition and the message, such as -.Dq Xr fmtmsg 3 . -The character string is not limited to a specific size. -.Pp -If no -.Fa tag -is to be supplied, -.Dv MM_NOTAG -must be specified. -.Pp -Further effect on the formatting of the message as displayed on the -standard error stream (but not on the system console!) may be taken by -setting the -.Ev MSGVERB -environment variable, which selects the subset of message components -to be printed. -It consists of a colon-separated list of the optional keywords -.Fa label , -.Fa severity , -.Fa text , -.Fa action , -and -.Fa tag , -which correspond to the arguments to -.Fn fmtmsg -with the same names. -If -.Ev MSGVERB -is either not set or malformed (containing empty or unknown keywords), -its content is ignored an all message components will be selected. -.Pp -Note that displaying a message on the system console may fail due to -inappropriate privileges or a non-permissive file mode of the console device. -.Sh RETURN VALUES -The -.Fn fmtmsg -function returns one of the following values: -.Bl -tag -width MM_NOTOKXXX -.It Dv MM_OK -The function succeeded. -.It Dv MM_NOTOK -The function failed completely. -.It Dv MM_NOMSG -The function was unable to generate a message on standard error, -but otherwise succeeded. -.It Dv MM_NOCOM -The function was unable to generate a message on the console, -but otherwise succeeded. -.El -.Sh SEE ALSO -.Xr printf 3 , -.Xr syslog 3 -.Sh STANDARDS -The -.Fn fmtmsg -function conforms to -.St -xsh5 . diff --git a/lib/libc/gen/fmtmsg.c b/lib/libc/gen/fmtmsg.c deleted file mode 100644 index 1fd683b37..000000000 --- a/lib/libc/gen/fmtmsg.c +++ /dev/null @@ -1,234 +0,0 @@ -/* $NetBSD: fmtmsg.c,v 1.6 2014/09/18 13:58:20 christos Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fmtmsg.c,v 1.6 2014/09/18 13:58:20 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include - -static unsigned int msgverb(const char *); -static const char * severity2str(int); -static int writeit(FILE *, unsigned int, const char *, - const char *, const char *, const char *, - const char *); - -#define MM_VERBLABEL 0x01U -#define MM_VERBSEVERITY 0x02U -#define MM_VERBTEXT 0x04U -#define MM_VERBACTION 0x08U -#define MM_VERBTAG 0x10U -#define MM_VERBALL \ - (MM_VERBLABEL | MM_VERBSEVERITY | MM_VERBTEXT | MM_VERBACTION | \ - MM_VERBTAG) - -static const struct keyword { - size_t len; /* strlen(keyword) */ - const char * const keyword; -} keywords[] = { - { 5, "label" }, /* log2(MM_VERBLABEL) */ - { 8, "severity" }, /* ... */ - { 4, "text" }, - { 6, "action" }, - { 3, "tag" } /* log2(MM_VERBTAG) */ -}; - -static const size_t nkeywords = sizeof (keywords) / sizeof (keywords[0]); - -/* - * Convert a colon-separated list of known keywords to a set of MM_VERB* - * flags, defaulting to `all' if not set, empty, or in presence of unknown - * keywords. - */ -static unsigned int -msgverb(const char *str) -{ - u_int i; - unsigned int result; - - if (str == NULL) - return (MM_VERBALL); - - result = 0; - while (*str != '\0') { - for (i = 0; i < nkeywords; i++) { - if (memcmp(str, keywords[i].keyword, keywords[i].len) - == 0 && - (*(str + keywords[i].len) == ':' || - *(str + keywords[i].len) == '\0')) - break; - } - if (i == nkeywords) { - result = MM_VERBALL; - break; - } - - result |= (1 << i); - if (*(str += keywords[i].len) == ':') - str++; /* Advance */ - } - if (result == 0) - result = MM_VERBALL; - - return (result); -} - -static const char severities[][8] = { - "", /* MM_NONE */ - "HALT", - "ERROR", - "WARNING", - "INFO" -}; - -static const size_t nseverities = sizeof (severities) / sizeof (severities[0]); - -/* - * Returns the string representation associated with the numerical severity - * value, defaulting to NULL for an unknown value. - */ -static const char * -severity2str(int severity) -{ - const char *result; - - if (severity >= 0 && - (u_int) severity < nseverities) - result = severities[severity]; - else - result = NULL; - - return (result); -} - -/* - * Format and write the message to the given stream, selecting those - * components displayed from msgverb, returning the number of characters - * written, or a negative value in case of an error. - */ -static int -writeit(FILE *stream, unsigned int which, const char *label, - const char *sevstr, const char *text, const char *action, - const char *tag) -{ - int nwritten; - - nwritten = fprintf(stream, "%s%s%s%s%s%s%s%s%s%s%s", - ((which & MM_VERBLABEL) && label != MM_NULLLBL) ? - label : "", - ((which & MM_VERBLABEL) && label != MM_NULLLBL) ? - ": " : "", - (which & MM_VERBSEVERITY) ? - sevstr : "", - (which & MM_VERBSEVERITY) ? - ": " : "", - ((which & MM_VERBTEXT) && text != MM_NULLTXT) ? - text : "", - ((which & MM_VERBLABEL) && label != MM_NULLLBL) || - ((which & MM_VERBSEVERITY)) || - ((which & MM_VERBTEXT) && text != MM_NULLTXT) ? - "\n" : "", - ((which & MM_VERBACTION) && action != MM_NULLACT) ? - "TO FIX: " : "", - ((which & MM_VERBACTION) && action != MM_NULLACT) ? - action : "", - ((which & MM_VERBACTION) && label != MM_NULLACT) ? - " " : "", - ((which & MM_VERBTAG) && tag != MM_NULLTAG) ? - tag : "", - ((which & MM_VERBACTION) && action != MM_NULLACT) || - ((which & MM_VERBTAG) && tag != MM_NULLTAG) ? - "\n" : ""); - - return (nwritten); -} - -int -fmtmsg(long classification, const char *label, int severity, - const char *text, const char *action, const char *tag) -{ - FILE *console; - const char *p, *sevstr; - int result; - - /* Validate label constraints, if not null. */ - if (label != MM_NULLLBL) { - /* - * Two fields, separated by a colon. The first field is up to - * 10 bytes, the second is up to 14 bytes. - */ - p = strchr(label, ':'); - if (p == NULL || p - label > 10 || strlen(p + 1) > 14) - return (MM_NOTOK); - } - /* Validate severity argument. */ - if ((sevstr = severity2str(severity)) == NULL) - return (MM_NOTOK); - - /* - * Fact in search for a better place: XSH5 does not define any - * functionality for `classification' bits other than the display - * subclassification. - */ - - result = 0; - - if (classification & MM_PRINT) { - if (writeit(stderr, msgverb(getenv("MSGVERB")), - label, sevstr, text, action, tag) < 0) - result |= MM_NOMSG; - } - /* Similar to MM_PRINT but ignoring $MSGVERB. */ - if (classification & MM_CONSOLE) { - if ((console = fopen(_PATH_CONSOLE, "we")) != NULL) { - if (writeit(console, MM_VERBALL, - label, sevstr, text, action, tag) < 0) - result |= MM_NOCON; - /* - * Ignore result: does not constitute ``generate a - * console message.'' - */ - (void)fclose(console); - } else { - result |= MM_NOCON; - } - } - - if (result == (MM_NOMSG | MM_NOCON)) - result = MM_NOTOK; - - return (result == 0 ? MM_OK : result); -} diff --git a/lib/libc/gen/fnmatch.3 b/lib/libc/gen/fnmatch.3 deleted file mode 100644 index e14688691..000000000 --- a/lib/libc/gen/fnmatch.3 +++ /dev/null @@ -1,140 +0,0 @@ -.\" $NetBSD: fnmatch.3,v 1.22 2010/11/30 21:03:07 jruoho Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Guido van Rossum. -.\" 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. -.\" -.\" @(#)fnmatch.3 8.3 (Berkeley) 4/28/95 -.\" -.Dd November 30, 2010 -.Dt FNMATCH 3 -.Os -.Sh NAME -.Nm fnmatch -.Nd match filename or pathname using shell glob rules -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In fnmatch.h -.Ft int -.Fn fnmatch "const char *pattern" "const char *string" "int flags" -.Sh DESCRIPTION -The -.Fn fnmatch -function -matches patterns according to the globbing rules used by the shell. -It checks the string specified by the -.Fa string -argument to see if it matches the pattern specified by the -.Fa pattern -argument. -.Pp -The -.Fa flags -argument modifies the interpretation of -.Fa pattern -and -.Fa string . -The value of -.Fa flags -is the bitwise inclusive -.Tn OR -of any of the following -constants, which are defined in the include file -.Pa fnmatch.h . -.Bl -tag -width FNM_LEADING_DIRXX -.It Dv FNM_NOESCAPE -Normally, every occurrence of a backslash -.Pq Ql \e -followed by a character in -.Fa pattern -is replaced by that character. -This is done to negate any special meaning for the character. -If the -.Dv FNM_NOESCAPE -flag is set, a backslash character is treated as an ordinary character. -.It Dv FNM_PATHNAME -Slash characters in -.Fa string -must be explicitly matched by slashes in -.Fa pattern . -If this flag is not set, then slashes are treated as regular characters. -.It Dv FNM_PERIOD -Leading periods in strings match periods in patterns. -The definition of ``leading'' is related to the specification of -.Dv FNM_PATHNAME . -A period is always ``leading'' if it is the first character in -.Ar string . -Additionally, if -.Dv FNM_PATHNAME -is set, -a period is ``leading'' if it immediately follows a slash. -.It Dv FNM_LEADING_DIR -Ignore -.Dq /* -rest after successful -.Fa pattern -matching. -.It Dv FNM_CASEFOLD -The pattern is matched in a case-insensitive fashion. -.El -.Sh RETURN VALUES -The -.Fn fnmatch -function returns zero if -.Fa string -matches the pattern specified by -.Fa pattern , -otherwise, it returns the value -.Dv FNM_NOMATCH . -.Sh SEE ALSO -.Xr sh 1 , -.Xr glob 3 , -.Xr regex 3 , -.Xr glob 7 -.Sh STANDARDS -The -.Fn fnmatch -function conforms to -.St -p1003.2-92 . -The -.Dv FNM_CASEFOLD -flag is a -.Nx -extension. -.Sh HISTORY -The -.Fn fnmatch -function first appeared in -.Bx 4.4 . -.Sh BUGS -The pattern -.Ql * -matches the empty string, even if -.Dv FNM_PATHNAME -is specified. diff --git a/lib/libc/gen/fnmatch.c b/lib/libc/gen/fnmatch.c deleted file mode 100644 index 0b878bd7d..000000000 --- a/lib/libc/gen/fnmatch.c +++ /dev/null @@ -1,222 +0,0 @@ -/* $NetBSD: fnmatch.c,v 1.26 2014/10/12 22:32:33 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fnmatch.c 8.2 (Berkeley) 4/16/94"; -#else -__RCSID("$NetBSD: fnmatch.c,v 1.26 2014/10/12 22:32:33 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * Function fnmatch() as specified in POSIX 1003.2-1992, section B.6. - * Compares a filename or pathname to a pattern. - */ - -#include "namespace.h" - -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(fnmatch,_fnmatch) -#endif - -#define EOS '\0' - -static inline int -foldcase(int ch, int flags) -{ - - if ((flags & FNM_CASEFOLD) != 0 && isupper(ch)) - return tolower(ch); - return ch; -} - -#define FOLDCASE(ch, flags) foldcase((unsigned char)(ch), (flags)) - -static const char * -rangematch(const char *pattern, int test, int flags) -{ - int negate, ok, need; - char c, c2; - - _DIAGASSERT(pattern != NULL); - - /* - * A bracket expression starting with an unquoted circumflex - * character produces unspecified results (IEEE 1003.2-1992, - * 3.13.2). This implementation treats it like '!', for - * consistency with the regular expression syntax. - * J.T. Conklin (conklin@ngai.kaleida.com) - */ - if ((negate = (*pattern == '!' || *pattern == '^')) != 0) - ++pattern; - - need = 1; - for (ok = 0; (c = FOLDCASE(*pattern++, flags)) != ']' || need;) { - need = 0; - if (c == '/') - return (void *)-1; - if (c == '\\' && !(flags & FNM_NOESCAPE)) - c = FOLDCASE(*pattern++, flags); - if (c == EOS) - return NULL; - if (*pattern == '-' - && (c2 = FOLDCASE(*(pattern + 1), flags)) != EOS && - c2 != ']') { - pattern += 2; - if (c2 == '\\' && !(flags & FNM_NOESCAPE)) - c2 = FOLDCASE(*pattern++, flags); - if (c2 == EOS) - return NULL; - if (c <= test && test <= c2) - ok = 1; - } else if (c == test) - ok = 1; - } - return ok == negate ? NULL : pattern; -} - - -static int -fnmatchx(const char *pattern, const char *string, int flags, size_t recursion) -{ - const char *stringstart, *r; - char c, test; - - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(string != NULL); - - if (recursion-- == 0) - return FNM_NORES; - - for (stringstart = string;;) { - switch (c = FOLDCASE(*pattern++, flags)) { - case EOS: - if ((flags & FNM_LEADING_DIR) && *string == '/') - return 0; - return *string == EOS ? 0 : FNM_NOMATCH; - case '?': - if (*string == EOS) - return FNM_NOMATCH; - if (*string == '/' && (flags & FNM_PATHNAME)) - return FNM_NOMATCH; - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return FNM_NOMATCH; - ++string; - break; - case '*': - c = FOLDCASE(*pattern, flags); - /* Collapse multiple stars. */ - while (c == '*') - c = FOLDCASE(*++pattern, flags); - - if (*string == '.' && (flags & FNM_PERIOD) && - (string == stringstart || - ((flags & FNM_PATHNAME) && *(string - 1) == '/'))) - return FNM_NOMATCH; - - /* Optimize for pattern with * at end or before /. */ - if (c == EOS) { - if (flags & FNM_PATHNAME) - return (flags & FNM_LEADING_DIR) || - strchr(string, '/') == NULL ? - 0 : FNM_NOMATCH; - else - return 0; - } else if (c == '/' && flags & FNM_PATHNAME) { - if ((string = strchr(string, '/')) == NULL) - return FNM_NOMATCH; - break; - } - - /* General case, use recursion. */ - while ((test = FOLDCASE(*string, flags)) != EOS) { - int e; - switch ((e = fnmatchx(pattern, string, - flags & ~FNM_PERIOD, recursion))) { - case FNM_NOMATCH: - break; - default: - return e; - } - if (test == '/' && flags & FNM_PATHNAME) - break; - ++string; - } - return FNM_NOMATCH; - case '[': - if (*string == EOS) - return FNM_NOMATCH; - if (*string == '/' && flags & FNM_PATHNAME) - return FNM_NOMATCH; - if ((r = rangematch(pattern, - FOLDCASE(*string, flags), flags)) == NULL) - return FNM_NOMATCH; - if (r == (void *)-1) { - if (*string != '[') - return FNM_NOMATCH; - } else - pattern = r; - ++string; - break; - case '\\': - if (!(flags & FNM_NOESCAPE)) { - if ((c = FOLDCASE(*pattern++, flags)) == EOS) { - c = '\0'; - --pattern; - } - } - /* FALLTHROUGH */ - default: - if (c != FOLDCASE(*string++, flags)) - return FNM_NOMATCH; - break; - } - } - /* NOTREACHED */ -} - -int -fnmatch(const char *pattern, const char *string, int flags) -{ - return fnmatchx(pattern, string, flags, 64); -} diff --git a/lib/libc/gen/fpclassify.3 b/lib/libc/gen/fpclassify.3 deleted file mode 100644 index c8dcc1ba5..000000000 --- a/lib/libc/gen/fpclassify.3 +++ /dev/null @@ -1,94 +0,0 @@ -.\" $NetBSD: fpclassify.3,v 1.3 2008/04/30 13:10:50 martin Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd January 14, 2004 -.Dt FPCLASSIFY 3 -.Os -.Sh NAME -.Nm fpclassify -.Nd classify real floating type -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In math.h -.Ft int -.Fn fpclassify "real-floating x" -.Sh DESCRIPTION -The -.Fn fpclassify -macro performs classification of its argument -.Fa x . -An argument represented in a format wider than its semantic type is -converted to its semantic type first. -The classification is then based on the type of the argument. -.Ss IEEE 754 -.Bl -tag -width "FP_SUBNORMALXXX" -compact -offset indent -.It Dv FP_INFINITE -infinity, either positive or negative -.It Dv FP_NAN -not-a-number -.Pq Dq NaN -.It Dv FP_NORMAL -normal -.It Dv FP_SUBNORMAL -subnormal -.It Dv FP_ZERO -zero -.El -.Ss VAX -.Bl -tag -width "FP_DIRTYZEROXXX" -compact -offset indent -.It Dv FP_ROP -reserved operand -.Pq Dq ROP -.It Dv FP_DIRTYZERO -dirty zero -.It Dv FP_NORMAL -finite -.It Dv FP_ZERO -true zero -.El -.Sh RETURN VALUES -The -.Fn fpclassify -macro returns the value of the number classification macro appropriate -to its argument -.Fa x -as described above. -.Sh ERRORS -No errors are defined. -.Sh SEE ALSO -.Xr isfinite 3 , -.Xr isnormal 3 , -.Xr math 3 , -.Xr signbit 3 -.Sh STANDARDS -The -.Fn fpclassify -macro conforms to -.St -isoC-99 . diff --git a/lib/libc/gen/fpclassifyd_ieee754.c b/lib/libc/gen/fpclassifyd_ieee754.c deleted file mode 100644 index ecce33194..000000000 --- a/lib/libc/gen/fpclassifyd_ieee754.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: fpclassifyd_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyd_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * IEEE 754 double-precision version - */ -int -__fpclassifyd(double x) -{ - union ieee_double_u u; - - u.dblu_d = x; - - if (u.dblu_dbl.dbl_exp == 0) { - if (u.dblu_dbl.dbl_frach == 0 && u.dblu_dbl.dbl_fracl == 0) - return FP_ZERO; - else - return FP_SUBNORMAL; - } else if (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN) { - if (u.dblu_dbl.dbl_frach == 0 && u.dblu_dbl.dbl_fracl == 0) - return FP_INFINITE; - else - return FP_NAN; - } - - return FP_NORMAL; -} diff --git a/lib/libc/gen/fpclassifyf_ieee754.c b/lib/libc/gen/fpclassifyf_ieee754.c deleted file mode 100644 index 2e522d5f1..000000000 --- a/lib/libc/gen/fpclassifyf_ieee754.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: fpclassifyf_ieee754.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyf_ieee754.c,v 1.3 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.1 fpclassify - classify real floating type - * IEEE 754 single-precision version - */ -int -__fpclassifyf(float x) -{ - union ieee_single_u u; - - u.sngu_f = x; - - if (u.sngu_sng.sng_exp == 0) { - if (u.sngu_sng.sng_frac == 0) - return FP_ZERO; - else - return FP_SUBNORMAL; - } else if (u.sngu_sng.sng_exp == SNG_EXP_INFNAN) { - if (u.sngu_sng.sng_frac == 0) - return FP_INFINITE; - else - return FP_NAN; - } - - return FP_NORMAL; -} diff --git a/lib/libc/gen/fpclassifyl_ieee754.c b/lib/libc/gen/fpclassifyl_ieee754.c deleted file mode 100644 index 2aa6fc2aa..000000000 --- a/lib/libc/gen/fpclassifyl_ieee754.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $NetBSD: fpclassifyl_ieee754.c,v 1.3 2013/11/23 11:40:56 martin Exp $ */ - -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fpclassifyl_ieee754.c,v 1.3 2013/11/23 11:40:56 martin Exp $"); -#endif - -#include -#include - -#ifdef __HAVE_LONG_DOUBLE -/* - * 7.12.3.1 fpclassify - classify real floating type - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__fpclassifyl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - if (u.extu_ext.ext_exp == 0) { - if (u.extu_ext.ext_frach == 0 -#if EXT_FRACHMBITS - && u.extu_ext.ext_frachm == 0 -#endif -#if EXT_FRACLMBITS - && u.extu_ext.ext_fraclm == 0 -#endif - && u.extu_ext.ext_fracl == 0) - return FP_ZERO; - else - return FP_SUBNORMAL; - } else if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) { - if (u.extu_ext.ext_frach == 0 -#if EXT_FRACHMBITS - && u.extu_ext.ext_frachm == 0 -#endif -#if EXT_FRACLMBITS - && u.extu_ext.ext_fraclm == 0 -#endif - && u.extu_ext.ext_fracl == 0) - return FP_INFINITE; - else - return FP_NAN; - } - - return FP_NORMAL; -} -#endif /* __HAVE_LONG_DOUBLE */ diff --git a/lib/libc/gen/fpgetmask.3 b/lib/libc/gen/fpgetmask.3 deleted file mode 100644 index 9ca8aa6b4..000000000 --- a/lib/libc/gen/fpgetmask.3 +++ /dev/null @@ -1,172 +0,0 @@ -.\" $NetBSD: fpgetmask.3,v 1.12 2011/03/27 22:55:07 wiz Exp $ -.\" -.\" Copyright (c) 1999 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Ross Harvey. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd March 26, 2011 -.Dt FPGETMASK 3 -.Os -.Sh NAME -.Nm fpgetmask , -.Nm fpgetprec , -.Nm fpgetround , -.Nm fpgetsticky , -.Nm fpsetmask , -.Nm fpsetprec , -.Nm fpsetround , -.Nm fpsetsticky -.Nd IEEE FP mode control -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ieeefp.h -.Ft fp_except_t -.Fn fpgetmask void -.Ft fp_prec_t -.Fn fpgetprec void -.Ft fp_rnd_t -.Fn fpgetround void -.Ft fp_except_t -.Fn fpgetsticky void -.Ft fp_except_t -.Fn fpsetmask "fp_except_t mask" -.Ft fp_prec_t -.Fn fpsetprec "fp_prec_t prec" -.Ft fp_rnd_t -.Fn fpsetround "fp_rnd_t rnd_dir" -.Ft fp_except_t -.Fn fpsetsticky "fp_except_t sticky" -.Sh DESCRIPTION -A rounding mode -.Ft fp_rnd_t -is one of: -.Bl -column -offset indent FP_RZ -.It Dv FP_RZ Ta rounding towards Em zero -.It Dv FP_RM Ta rounding down to Pq Em Minus infinity -.It Dv FP_RN Ta rounding to Em nearest -.It Dv FP_RP Ta rounding down to Pq Em Plus infinity -.El -The default mode is -.Dv FP_RN . -.Pp -An -.Ft fp_except_t -value is a bitmask specifying an exception type and containing any of -the values listed below. -.Bl -column -offset indent FP_X_UFLxx -.It Dv FP_X_INV Ta Invalid\ Operation -.It Dv FP_X_DZ Ta Division\ by\ zero -.It Dv FP_X_OFL Ta Overflow -.It Dv FP_X_UFL Ta Underflow -.It Dv FP_X_IMP Ta Imprecision (inexact) -.It Dv FP_X_IOV Ta Integer\ Overflow -.El -.Pp -An -.Ft fp_prec_t -specifies the precision of the floating point operations listed below. -.Bl -column -offset indent FP_RPS -.It Dv FP_PS Ta Dv 24 bit (single-precision) -.It Dv FP_PRS Ta reserved -.It Dv FP_PD Ta Dv 53 bit (double-precision) -.It Dv FP_PE Ta Dv 64 bit (extended-precision) -.El -.Pp -The -.Fn fpsetmask -function will set the current exception mask, i.e., it will cause -future operations with the specified result status to raise the -.Dv SIGFPE -exception. -The -.Fn fpgetmask -function will return the current exception mask. -.Pp -The -.Fn fpgetprec -function will return the current floating point precision. -The -.Fn fpsetprec -function will set the floating point precision and will return -the previous precision. -.Pp -The -.Fn fpsetround -function will cause future operations to use the specified dynamic -rounding mode. -The -.Fn fpgetround -function will return the current rounding mode. -.Bl -tag -width Note:x -.It Em Note : -On some architectures, instructions can optionally specify static -rounding modes and exception enables that will supersede the specified -dynamic mode. -On other architectures, these features may not be fully supported. -.El -.Pp -A -.Dq sticky -status word may be maintained in which a bit is set every time an -exceptional floating point condition is encountered, whether or not a -.Dv SIGFPE -is generated. -The -.Fn fpsetsticky -function will set or clear the specified exception history bits. -The -.Fn fpgetsticky -function will return the exception history bits. -.Sh RETURN VALUES -The -.Fn fpgetround -and -.Fn fpsetround -functions return the -.Pq previous -rounding mode. -The -.Fn fpgetmask , -.Fn fpsetmask , -.Fn fpgetsticky , -and -.Fn fpsetsticky -functions return the -.Pq previous -exception mask and exception history bits. -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr fenv 3 -.Sh BUGS -There is no way to return an unsupported value. -Not all processors support all the modes. -These interfaces are deprecated and the ones -in -.Xr fenv 3 -should be used, although the interfaces in -.Xr fenv 3 -don't support getting or setting the precision. diff --git a/lib/libc/gen/fstab.c b/lib/libc/gen/fstab.c deleted file mode 100644 index 908055561..000000000 --- a/lib/libc/gen/fstab.c +++ /dev/null @@ -1,231 +0,0 @@ -/* $NetBSD: fstab.c,v 1.31 2012/03/13 21:13:34 christos Exp $ */ - -/* - * Copyright (c) 1980, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fstab.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: fstab.c,v 1.31 2012/03/13 21:13:34 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(endfsent,_endfsent) -__weak_alias(getfsent,_getfsent) -__weak_alias(getfsfile,_getfsfile) -__weak_alias(getfsspec,_getfsspec) -__weak_alias(setfsent,_setfsent) -#endif - -static FILE *_fs_fp; -static size_t _fs_lineno = 0; -static const char *_fs_file = _PATH_FSTAB; -static struct fstab _fs_fstab; - -static char *nextfld(char **, const char *); -static int fstabscan(void); - - -static char * -nextfld(char **str, const char *sep) -{ - char *ret; - - _DIAGASSERT(str != NULL); - _DIAGASSERT(sep != NULL); - - while ((ret = stresep(str, sep, '\\')) != NULL && *ret == '\0') - continue; - return ret; -} - - -static int -fstabscan(void) -{ - char *cp, *lp, *sp; -#define MAXLINELENGTH 1024 - static char line[MAXLINELENGTH]; - char subline[MAXLINELENGTH]; - static const char sep[] = ":\n"; - static const char ws[] = " \t\n"; - static const char *fstab_type[] = { - FSTAB_RW, FSTAB_RQ, FSTAB_RO, FSTAB_SW, FSTAB_DP, FSTAB_XX, NULL - }; - - (void)memset(&_fs_fstab, 0, sizeof(_fs_fstab)); - for (;;) { - if (!(lp = fgets(line, (int)sizeof(line), _fs_fp))) - return 0; - _fs_lineno++; -/* OLD_STYLE_FSTAB */ - if (!strpbrk(lp, " \t")) { - _fs_fstab.fs_spec = nextfld(&lp, sep); - if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') - continue; - _fs_fstab.fs_file = nextfld(&lp, sep); - _fs_fstab.fs_type = nextfld(&lp, sep); - if (_fs_fstab.fs_type) { - if (!strcmp(_fs_fstab.fs_type, FSTAB_XX)) - continue; - _fs_fstab.fs_mntops = _fs_fstab.fs_type; - _fs_fstab.fs_vfstype = - __UNCONST( - strcmp(_fs_fstab.fs_type, FSTAB_SW) ? - "ufs" : "swap"); - if ((cp = nextfld(&lp, sep)) != NULL) { - _fs_fstab.fs_freq = atoi(cp); - if ((cp = nextfld(&lp, sep)) != NULL) { - _fs_fstab.fs_passno = atoi(cp); - return 1; - } - } - } - goto bad; - } -/* OLD_STYLE_FSTAB */ - _fs_fstab.fs_spec = nextfld(&lp, ws); - if (!_fs_fstab.fs_spec || *_fs_fstab.fs_spec == '#') - continue; - _fs_fstab.fs_file = nextfld(&lp, ws); - _fs_fstab.fs_vfstype = nextfld(&lp, ws); - _fs_fstab.fs_mntops = nextfld(&lp, ws); - if (_fs_fstab.fs_mntops == NULL) - goto bad; - _fs_fstab.fs_freq = 0; - _fs_fstab.fs_passno = 0; - if ((cp = nextfld(&lp, ws)) != NULL) { - _fs_fstab.fs_freq = atoi(cp); - if ((cp = nextfld(&lp, ws)) != NULL) - _fs_fstab.fs_passno = atoi(cp); - } - - /* subline truncated iff line truncated */ - (void)strlcpy(subline, _fs_fstab.fs_mntops, sizeof(subline)); - sp = subline; - - while ((cp = nextfld(&sp, ",")) != NULL) { - const char **tp; - - if (strlen(cp) != 2) - continue; - - for (tp = fstab_type; *tp; tp++) - if (strcmp(cp, *tp) == 0) { - _fs_fstab.fs_type = __UNCONST(*tp); - break; - } - if (*tp) - break; - } - if (_fs_fstab.fs_type == NULL) - goto bad; - if (strcmp(_fs_fstab.fs_type, FSTAB_XX) == 0) - continue; - if (cp != NULL) - return 1; - -bad: - warnx("%s, %lu: Missing fields", _fs_file, (u_long)_fs_lineno); - } - /* NOTREACHED */ -} - -struct fstab * -getfsent(void) -{ - if ((!_fs_fp && !setfsent()) || !fstabscan()) - return NULL; - return &_fs_fstab; -} - -struct fstab * -getfsspec(const char *name) -{ - - _DIAGASSERT(name != NULL); - - if (setfsent()) - while (fstabscan()) - if (!strcmp(_fs_fstab.fs_spec, name)) - return &_fs_fstab; - return NULL; -} - -struct fstab * -getfsfile(const char *name) -{ - - _DIAGASSERT(name != NULL); - - if (setfsent()) - while (fstabscan()) - if (!strcmp(_fs_fstab.fs_file, name)) - return &_fs_fstab; - return NULL; -} - -int -setfsent(void) -{ - _fs_lineno = 0; - if (_fs_fp) { - rewind(_fs_fp); - return 1; - } - if ((_fs_fp = fopen(_PATH_FSTAB, "re")) == NULL) { - warn("Cannot open `%s'", _PATH_FSTAB); - return 0; - } - return 1; -} - -void -endfsent(void) -{ - if (_fs_fp) { - (void)fclose(_fs_fp); - _fs_fp = NULL; - } -} diff --git a/lib/libc/gen/ftok.3 b/lib/libc/gen/ftok.3 deleted file mode 100644 index f465707bd..000000000 --- a/lib/libc/gen/ftok.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $NetBSD: ftok.3,v 1.18 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 1994 SigmaSoft, Th. Lockert -.\" 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 ``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. -.\" -.Dd April 27, 2010 -.Dt FTOK 3 -.Os -.Sh NAME -.Nm ftok -.Nd create IPC identifier from path name -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/ipc.h -.Ft key_t -.Fn ftok "const char *path" "int id" -.Sh DESCRIPTION -The -.Fn ftok -function attempts to create a unique key suitable for use with the -.Xr msgget 2 , -.Xr semget 2 -and -.Xr shmget 2 -functions given the -.Fa path -of an existing file and a user-selectable -.Fa id . -.Pp -The specified -.Fa path -must specify an existing file that is accessible to the calling process -or the call will fail. -Also, note that links to files will return the same key, given the same -.Fa id . -.Pp -Only the 8 least significant bits of -.Fa id -are used in the key generation; the rest of the bits are ignored. -.Sh RETURN VALUES -The -.Fn ftok -function will return ((key_t)-1) if -.Fa path -does not exist or if it cannot be accessed by the calling process. -.Sh SEE ALSO -.Xr msgget 2 , -.Xr semget 2 , -.Xr shmget 2 -.Sh STANDARDS -The -.Fn ftok -function conforms to -.St -p1003.1 . -.Sh HISTORY -The -.Fn ftok -function originated with System V and is typically used by programs -that use the System V IPC routines. -.Sh AUTHORS -.An Thorsten Lockert Aq Mt tholo@sigmasoft.com -.Sh BUGS -The returned key is computed based on the device and inode of the -specified -.Fa path -in combination with the given -.Fa id . -Thus it is quite possible for the routine to return duplicate keys -given that those fields are not 8- and 16-bit quantities like they -were on System V based systems where this library routine's ancestor -were originally created. diff --git a/lib/libc/gen/ftok.c b/lib/libc/gen/ftok.c deleted file mode 100644 index b50c3d486..000000000 --- a/lib/libc/gen/ftok.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: ftok.c,v 1.11 2012/03/20 16:36:05 matt Exp $ */ - -/* - * Copyright (c) 1994 SigmaSoft, Th. Lockert - * 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ftok.c,v 1.11 2012/03/20 16:36:05 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include - -#ifdef __weak_alias -__weak_alias(ftok,_ftok) -#endif - -key_t -ftok(const char *path, int id) -{ - struct stat st; - - _DIAGASSERT(path != NULL); - - if (stat(path, &st) < 0) - return (key_t)-1; - - return (key_t) - (id << 24 | (st.st_dev & 0xff) << 16 | (st.st_ino & 0xffff)); -} diff --git a/lib/libc/gen/fts.3 b/lib/libc/gen/fts.3 deleted file mode 100644 index d8968193b..000000000 --- a/lib/libc/gen/fts.3 +++ /dev/null @@ -1,773 +0,0 @@ -.\" $NetBSD: fts.3,v 1.31 2013/06/30 19:19:12 wiz Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)fts.3 8.5 (Berkeley) 4/16/94 -.\" -.Dd March 30, 2011 -.Dt FTS 3 -.Os -.Sh NAME -.Nm fts , -.Nm fts_open , -.Nm fts_read , -.Nm fts_children , -.Nm fts_set , -.Nm fts_close -.Nd traverse a file hierarchy -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/stat.h -.In fts.h -.Ft FTS * -.Fo fts_open -.Fa "char * const *path_argv" -.Fa "int options" -.Fa "int (*compar)(const FTSENT **, const FTSENT **)" -.Fc -.Ft FTSENT * -.Fn fts_read "FTS *ftsp" -.Ft FTSENT * -.Fn fts_children "FTS *ftsp" "int options" -.Ft int -.Fn fts_set "FTS *ftsp" "FTSENT *f" "int options" -.Ft int -.Fn fts_close "FTS *ftsp" -.Sh DESCRIPTION -The -.Nm -functions are provided for traversing -.Ux -file hierarchies. -A simple overview is that the -.Fn fts_open -function returns a -.Dq handle -on a file hierarchy, which is then supplied to -the other -.Nm -functions. -The function -.Fn fts_read -returns a pointer to a structure describing one of the files in the file -hierarchy. -The function -.Fn fts_children -returns a pointer to a linked list of structures, each of which describes -one of the files contained in a directory in the hierarchy. -In general, directories are visited two distinguishable times; in pre-order -(before any of their descendants are visited) and in post-order (after all -of their descendants have been visited). -Files are visited once. -It is possible to walk the hierarchy -.Dq logically -(ignoring symbolic links) -or physically (visiting symbolic links), order the walk of the hierarchy or -prune and/or re-visit portions of the hierarchy. -.Pp -Two structures are defined (and typedef'd) in the include file -.In fts.h . -The first is -.Fa FTS , -the structure that represents the file hierarchy itself. -The second is -.Fa FTSENT , -the structure that represents a file in the file -hierarchy. -Normally, an -.Fa FTSENT -structure is returned for every file in the file -hierarchy. -In this manual page, -.Dq file -and -.Dq Fa FTSENT No structure -are generally -interchangeable. -The -.Fa FTSENT -structure contains at least the following fields, which are -described in greater detail below: -.Bd -literal -offset 2n -typedef struct _ftsent { - u_short fts_info; /* flags for FTSENT structure */ - char *fts_accpath; /* access path */ - char *fts_path; /* root path */ - short fts_pathlen; /* strlen(fts_path) */ - char *fts_name; /* file name */ - short fts_namelen; /* strlen(fts_name) */ - short fts_level; /* depth (\-1 to N) */ - int fts_errno; /* file errno */ - long fts_number; /* local numeric value */ - void *fts_pointer; /* local address value */ - struct ftsent *fts_parent; /* parent directory */ - struct ftsent *fts_link; /* next file structure */ - struct ftsent *fts_cycle; /* cycle structure */ - struct stat *fts_statp; /* stat(2) information */ -} FTSENT; -.Ed -.Pp -These fields are defined as follows: -.Bl -tag -width "fts_namelen" -.It Fa fts_info -One of the following flags describing the returned -.Fa FTSENT -structure and -the file it represents. -With the exception of directories without errors -.Pq Dv FTS_D , -all of these -entries are terminal, that is, they will not be revisited, nor will any -of their descendants be visited. -.Bl -tag -width FTS_DEFAULT -.It Dv FTS_D -A directory being visited in pre-order. -.It Dv FTS_DC -A directory that causes a cycle in the tree. -(The -.Fa fts_cycle -field of the -.Fa FTSENT -structure will be filled in as well). -.It Dv FTS_DEFAULT -Any -.Fa FTSENT -structure that represents a file type not explicitly described -by one of the other -.Fa fts_info -values. -.It Dv FTS_DNR -A directory which cannot be read. -This is an error return, and the -.Fa fts_errno -field will be set to indicate what caused the error. -.It Dv FTS_DOT -A file named -.Ql \&. -or -.Ql .. -which was not specified as a file name to -.Fn fts_open -(see -.Dv FTS_SEEDOT ) . -.It Dv FTS_DP -A directory being visited in post-order. -The contents of the -.Fa FTSENT -structure will be unchanged from when -it was returned in pre-order, i.e., with the -.Fa fts_info -field set to -.Dv FTS_D . -.It Dv FTS_ERR -This is an error return, and the -.Fa fts_errno -field will be set to indicate what caused the error. -.It Dv FTS_F -A regular file. -.It Dv FTS_NS -A file for which no -.Xr stat 2 -information was available. -The contents of the -.Fa fts_statp -field are undefined. -This is an error return, and the -.Fa fts_errno -field will be set to indicate what caused the error. -.It Dv FTS_NSOK -A file for which no -.Xr stat 2 -information was requested. -The contents of the -.Fa fts_statp -field are undefined. -.It Dv FTS_SL -A symbolic link. -.It Dv FTS_SLNONE -A symbolic link with a non-existent target. -The contents of the -.Fa fts_statp -field reference the file characteristic information for the symbolic link -itself. -.It Dv FTS_W -A whiteout object. -.El -.It Fa fts_accpath -A path for accessing the file from the current directory. -.It Fa fts_path -The path for the file relative to the root of the traversal. -This path contains the path specified to -.Fn fts_open -as a prefix. -.It Fa fts_pathlen -The length of the string referenced by -.Fa fts_path . -.It Fa fts_name -The name of the file. -.It Fa fts_namelen -The length of the string referenced by -.Fa fts_name . -.It Fa fts_level -The depth of the traversal, numbered from \-1 to N, where this file -was found. -The -.Fa FTSENT -structure representing the parent of the starting point (or root) -of the traversal is numbered \-1, and the -.Fa FTSENT -structure for the root -itself is numbered 0. -.It Fa fts_errno -Upon return of a -.Fa FTSENT -structure from the -.Fn fts_children -or -.Fn fts_read -functions, with its -.Fa fts_info -field set to -.Dv FTS_DNR , -.Dv FTS_ERR -or -.Dv FTS_NS , -the -.Fa fts_errno -field contains the value of the external variable -.Va errno -specifying the cause of the error. -Otherwise, the contents of the -.Fa fts_errno -field are undefined. -.It Fa fts_number -This field is provided for the use of the application program and is -not modified by the -.Nm -functions. -It is initialized to 0. -.It Fa fts_pointer -This field is provided for the use of the application program and is -not modified by the -.Nm -functions. -It is initialized to -.Dv NULL . -.It Fa fts_parent -A pointer to the -.Fa FTSENT -structure referencing the file in the hierarchy -immediately above the current file, i.e., the directory of which this -file is a member. -A parent structure for the initial entry point is provided as well, -however, only the -.Fa fts_level , -.Fa fts_number -and -.Fa fts_pointer -fields are guaranteed to be initialized. -.It Fa fts_link -Upon return from the -.Fn fts_children -function, the -.Fa fts_link -field points to the next structure in the -.Dv NULL Ns -terminated -linked list of directory members. -Otherwise, the contents of the -.Fa fts_link -field are undefined. -.It Fa fts_cycle -If a directory causes a cycle in the hierarchy (see -.Dv FTS_DC ) , -either because -of a hard link between two directories, or a symbolic link pointing to a -directory, the -.Fa fts_cycle -field of the structure will point to the -.Fa FTSENT -structure in the hierarchy that references the same file as the current -.Fa FTSENT -structure. -Otherwise, the contents of the -.Fa fts_cycle -field are undefined. -.It Fa fts_statp -A pointer to -.Xr stat 2 -information for the file. -.El -.Pp -A single buffer is used for all of the paths of all of the files in the -file hierarchy. -Therefore, the -.Fa fts_path -and -.Fa fts_accpath -fields are guaranteed to be -.Dv NUL Ns -terminated -.Em only -for the file most recently returned by -.Fn fts_read . -To use these fields to reference any files represented by other -.Fa FTSENT -structures will require that the path buffer be modified using the -information contained in that -.Fa FTSENT -structure's -.Fa fts_pathlen -field. -Any such modifications should be undone before further calls to -.Fn fts_read -are attempted. -The -.Fa fts_name -field is always -.Dv NUL Ns -terminated . -.Sh FTS_OPEN -The -.Fn fts_open -function takes a pointer to an array of character pointers naming one -or more paths which make up a logical file hierarchy to be traversed. -The array must be terminated by a -.Dv NULL -pointer. -.Pp -There are -a number of options, at least one of which (either -.Dv FTS_LOGICAL -or -.Dv FTS_PHYSICAL ) -must be specified. -The options are selected by -.Em or Ns 'ing -the following values: -.Bl -tag -width "FTS_COMFOLLOW " -.It Dv FTS_COMFOLLOW -This option causes any symbolic link specified as a root path to be -followed immediately whether or not -.Dv FTS_LOGICAL -is also specified. -.It Dv FTS_LOGICAL -This option causes the -.Nm -routines to return -.Fa FTSENT -structures for the targets of symbolic links -instead of the symbolic links themselves. -If this option is set, the only symbolic links for which -.Fa FTSENT -structures -are returned to the application are those referencing non-existent files. -Either -.Dv FTS_LOGICAL -or -.Dv FTS_PHYSICAL -.Em must -be provided to the -.Fn fts_open -function. -.It Dv FTS_NOCHDIR -As a performance optimization, the -.Nm -functions change directories as they walk the file hierarchy. -This has the side-effect that an application cannot rely on being -in any particular directory during the traversal. -The -.Dv FTS_NOCHDIR -option turns off this optimization, and the -.Nm -functions will not change the current directory. -Note that applications should not themselves change their current directory -and try to access files unless -.Dv FTS_NOCHDIR -is specified and absolute -pathnames were provided as arguments to -.Fn fts_open . -.It Dv FTS_NOSTAT -By default, returned -.Fa FTSENT -structures reference file characteristic information (the -.Fa statp -field) for each file visited. -This option relaxes that requirement as a performance optimization, -allowing the -.Nm -functions to set the -.Fa fts_info -field to -.Dv FTS_NSOK -and leave the contents of the -.Fa statp -field undefined. -.It Dv FTS_PHYSICAL -This option causes the -.Nm -routines to return -.Fa FTSENT -structures for symbolic links themselves instead -of the target files they point to. -If this option is set, -.Fa FTSENT -structures for all symbolic links in the -hierarchy are returned to the application. -Either -.Dv FTS_LOGICAL -or -.Dv FTS_PHYSICAL -.Em must -be provided to the -.Fn fts_open -function. -.It Dv FTS_SEEDOT -By default, unless they are specified as path arguments to -.Fn fts_open , -any files named -.Ql \&. -or -.Ql .. -encountered in the file hierarchy are ignored. -This option causes the -.Nm -routines to return -.Fa FTSENT -structures for them. -.It Dv FTS_WHITEOUT -Return whiteout entries, which are normally hidden. -.It Dv FTS_XDEV -This option prevents -.Nm -from descending into directories that have a different device number -than the file from which the descent began. -.El -.Pp -The argument -.Fn compar -specifies a user-defined function which may be used to order the traversal -of the hierarchy. -It -takes two pointers to pointers to -.Fa FTSENT -structures as arguments and -should return a negative value, zero, or a positive value to indicate -if the file referenced by its first argument comes before, in any order -with respect to, or after, the file referenced by its second argument. -The -.Fa fts_accpath , -.Fa fts_path -and -.Fa fts_pathlen -fields of the -.Fa FTSENT -structures may -.Em never -be used in this comparison. -If the -.Fa fts_info -field is set to -.Dv FTS_NS -or -.Dv FTS_NSOK , -the -.Fa fts_statp -field may not either. -If the -.Fn compar -argument is -.Dv NULL , -the directory traversal order is in the order listed in -.Fa path_argv -for the root paths, and in the order listed in the directory for -everything else. -.Sh FTS_READ -The -.Fn fts_read -function returns a pointer to an -.Fa FTSENT -structure describing a file in -the hierarchy. -Directories (that are readable and do not cause cycles) are visited at -least twice, once in pre-order and once in post-order. -All other files are visited at least once. -(Hard links between directories that do not cause cycles or symbolic -links to symbolic links may cause files to be visited more than once, -or directories more than twice.) -.Pp -If all the members of the hierarchy have been returned, -.Fn fts_read -returns -.Dv NULL -and sets the external variable -.Va errno -to 0. -If an error unrelated to a file in the hierarchy occurs, -.Fn fts_read -returns -.Dv NULL -and sets -.Va errno -appropriately. -If an error related to a returned file occurs, a pointer to an -.Fa FTSENT -structure is returned, and -.Va errno -may or may not have been set (see -.Fa fts_info ) . -.Pp -The -.Fa FTSENT -structures returned by -.Fn fts_read -may be overwritten after a call to -.Fn fts_close -on the same file hierarchy stream, or, after a call to -.Fn fts_read -on the same file hierarchy stream unless they represent a file of type -directory, in which case they will not be overwritten until after a call to -.Fn fts_read -after the -.Fa FTSENT -structure has been returned by the function -.Fn fts_read -in post-order. -.Sh FTS_CHILDREN -The -.Fn fts_children -function returns a pointer to an -.Fa FTSENT -structure describing the first entry in a -.Dv NULL Ns -terminated -linked list of the files in the directory represented by the -.Fa FTSENT -structure most recently returned by -.Fn fts_read . -The list is linked through the -.Fa fts_link -field of the -.Fa FTSENT -structure, and is ordered by the user-specified comparison function, if any. -Repeated calls to -.Fn fts_children -will recreate this linked list. -.Pp -As a special case, if -.Fn fts_read -has not yet been called for a hierarchy, -.Fn fts_children -will return a pointer to the files in the logical directory specified to -.Fn fts_open , -i.e., the arguments specified to -.Fn fts_open . -Otherwise, if the -.Fa FTSENT -structure most recently returned by -.Fn fts_read -is not a directory being visited in pre-order, -or the directory does not contain any files, -.Fn fts_children -returns -.Dv NULL -and sets -.Va errno -to zero. -If an error occurs, -.Fn fts_children -returns -.Dv NULL -and sets -.Va errno -appropriately. -.Pp -The -.Fa FTSENT -structures returned by -.Fn fts_children -may be overwritten after a call to -.Fn fts_children , -.Fn fts_close -or -.Fn fts_read -on the same file hierarchy stream. -.Pp -.Em Option -may be set to the following value: -.Bl -tag -width "FTS_COMFOLLOW " -.It Dv FTS_NAMEONLY -Only the names of the files are needed. -The contents of all the fields in the returned linked list of structures -are undefined with the exception of the -.Fa fts_name -and -.Fa fts_namelen -fields. -.El -.Sh FTS_SET -The function -.Fn fts_set -allows the user application to determine further processing for the -file -.Fa f -of the stream -.Fa ftsp . -The -.Fn fts_set -function -returns 0 on success, and \-1 if an error occurs. -.Em Option -must be set to one of the following values: -.Bl -tag -width "FTS_COMFOLLOW " -.It Dv FTS_AGAIN -Re-visit the file; any file type may be re-visited. -The next call to -.Fn fts_read -will return the referenced file. -The -.Fa fts_stat -and -.Fa fts_info -fields of the structure will be reinitialized at that time, -but no other fields will have been changed. -This option is meaningful only for the most recently returned -file from -.Fn fts_read . -Normal use is for post-order directory visits, where it causes the -directory to be re-visited (in both pre and post-order) as well as all -of its descendants. -.It Dv FTS_FOLLOW -The referenced file must be a symbolic link. -If the referenced file is the one most recently returned by -.Fn fts_read , -the next call to -.Fn fts_read -returns the file with the -.Fa fts_info -and -.Fa fts_statp -fields reinitialized to reflect the target of the symbolic link instead -of the symbolic link itself. -If the file is one of those most recently returned by -.Fn fts_children , -the -.Fa fts_info -and -.Fa fts_statp -fields of the structure, when returned by -.Fn fts_read , -will reflect the target of the symbolic link instead of the symbolic link -itself. -In either case, if the target of the symbolic link does not exist the -fields of the returned structure will be unchanged and the -.Fa fts_info -field will be set to -.Dv FTS_SLNONE . -.Pp -If the target of the link is a directory, the pre-order return, followed -by the return of all of its descendants, followed by a post-order return, -is done. -.It Dv FTS_SKIP -No descendants of this file are visited. -The file may be one of those most recently returned by either -.Fn fts_children -or -.Fn fts_read . -.El -.Sh FTS_CLOSE -The -.Fn fts_close -function closes a file hierarchy stream -.Fa ftsp -and restores the current directory to the directory from which -.Fn fts_open -was called to open -.Fa ftsp . -The -.Fn fts_close -function -returns 0 on success, and \-1 if an error occurs. -.Sh ERRORS -The function -.Fn fts_open -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr open 2 -and -.Xr malloc 3 . -.Pp -The function -.Fn fts_close -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr chdir 2 -and -.Xr close 2 . -.Pp -The functions -.Fn fts_read -and -.Fn fts_children -may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr chdir 2 , -.Xr malloc 3 , -.Xr opendir 3 , -.Xr readdir 3 -and -.Xr stat 2 . -.Pp -In addition, -.Fn fts_children , -.Fn fts_open -and -.Fn fts_set -may fail and set -.Va errno -as follows: -.Bl -tag -width Er -.It Bq Er EINVAL -The options were invalid. -.El -.Sh SEE ALSO -.Xr find 1 , -.Xr chdir 2 , -.Xr stat 2 , -.Xr qsort 3 , -.Xr symlink 7 -.Sh STANDARDS -The -.Nm -utility was expected to be included in the -.St -p1003.1-88 -revision. -But twenty years later, it still was not included in the -.St -p1003.1-2008 -revision. diff --git a/lib/libc/gen/fts.c b/lib/libc/gen/fts.c deleted file mode 100644 index 256b4baa9..000000000 --- a/lib/libc/gen/fts.c +++ /dev/null @@ -1,1268 +0,0 @@ -/* $NetBSD: fts.c,v 1.48 2015/01/29 15:55:21 manu Exp $ */ - -/*- - * Copyright (c) 1990, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fts.c 8.6 (Berkeley) 8/14/94"; -#else -__RCSID("$NetBSD: fts.c,v 1.48 2015/01/29 15:55:21 manu Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#if ! HAVE_NBTOOL_CONFIG_H -#define HAVE_STRUCT_DIRENT_D_NAMLEN -#endif - -static FTSENT *fts_alloc(FTS *, const char *, size_t); -static FTSENT *fts_build(FTS *, int); -static void fts_free(FTSENT *); -static void fts_lfree(FTSENT *); -static void fts_load(FTS *, FTSENT *); -static size_t fts_maxarglen(char * const *); -static size_t fts_pow2(size_t); -static int fts_palloc(FTS *, size_t); -static void fts_padjust(FTS *, FTSENT *); -static FTSENT *fts_sort(FTS *, FTSENT *, size_t); -static unsigned short fts_stat(FTS *, FTSENT *, int); -static int fts_safe_changedir(const FTS *, const FTSENT *, int, - const char *); - -#if defined(ALIGNBYTES) && defined(ALIGN) -#define FTS_ALLOC_ALIGNED 1 -#else -#undef FTS_ALLOC_ALIGNED -#endif - -#ifndef ftsent_namelen_truncate -#define ftsent_namelen_truncate(a) \ - ((a) > UINT_MAX ? UINT_MAX : (unsigned int)(a)) -#endif -#ifndef ftsent_pathlen_truncate -#define ftsent_pathlen_truncate(a) \ - ((a) > UINT_MAX ? UINT_MAX : (unsigned int)(a)) -#endif -#ifndef fts_pathlen_truncate -#define fts_pathlen_truncate(a) \ - ((a) > UINT_MAX ? UINT_MAX : (unsigned int)(a)) -#endif -#ifndef fts_nitems_truncate -#define fts_nitems_truncate(a) \ - ((a) > UINT_MAX ? UINT_MAX : (unsigned int)(a)) -#endif - -#define ISDOT(a) (a[0] == '.' && (!a[1] || (a[1] == '.' && !a[2]))) - -#define CLR(opt) (sp->fts_options &= ~(opt)) -#define ISSET(opt) (sp->fts_options & (opt)) -#define SET(opt) (sp->fts_options |= (opt)) - -#define CHDIR(sp, path) (!ISSET(FTS_NOCHDIR) && chdir(path)) -#define FCHDIR(sp, fd) (!ISSET(FTS_NOCHDIR) && fchdir(fd)) - -/* fts_build flags */ -#define BCHILD 1 /* fts_children */ -#define BNAMES 2 /* fts_children, names only */ -#define BREAD 3 /* fts_read */ - -#ifndef DTF_HIDEW -#undef FTS_WHITEOUT -#endif - -FTS * -fts_open(char * const *argv, int options, - int (*compar)(const FTSENT **, const FTSENT **)) -{ - FTS *sp; - FTSENT *p, *root; - size_t nitems; - FTSENT *parent, *tmp = NULL; /* pacify gcc */ - size_t len; - - _DIAGASSERT(argv != NULL); - - /* Options check. */ - if (options & ~FTS_OPTIONMASK) { - errno = EINVAL; - return (NULL); - } - - /* Allocate/initialize the stream */ - if ((sp = malloc(sizeof(FTS))) == NULL) - return (NULL); - memset(sp, 0, sizeof(FTS)); - sp->fts_compar = compar; - sp->fts_options = options; - - /* Logical walks turn on NOCHDIR; symbolic links are too hard. */ - if (ISSET(FTS_LOGICAL)) - SET(FTS_NOCHDIR); - - /* - * Start out with 1K of path space, and enough, in any case, - * to hold the user's paths. - */ - if (fts_palloc(sp, MAX(fts_maxarglen(argv), MAXPATHLEN))) - goto mem1; - - /* Allocate/initialize root's parent. */ - if ((parent = fts_alloc(sp, "", 0)) == NULL) - goto mem2; - parent->fts_level = FTS_ROOTPARENTLEVEL; - - /* Allocate/initialize root(s). */ - for (root = NULL, nitems = 0; *argv; ++argv, ++nitems) { - /* Don't allow zero-length paths. */ - if ((len = strlen(*argv)) == 0) { - errno = ENOENT; - goto mem3; - } - - if ((p = fts_alloc(sp, *argv, len)) == NULL) - goto mem3; - p->fts_level = FTS_ROOTLEVEL; - p->fts_parent = parent; - p->fts_accpath = p->fts_name; - p->fts_info = fts_stat(sp, p, ISSET(FTS_COMFOLLOW)); - - /* Command-line "." and ".." are real directories. */ - if (p->fts_info == FTS_DOT) - p->fts_info = FTS_D; - - /* - * If comparison routine supplied, traverse in sorted - * order; otherwise traverse in the order specified. - */ - if (compar) { - p->fts_link = root; - root = p; - } else { - p->fts_link = NULL; - if (root == NULL) - tmp = root = p; - else { - tmp->fts_link = p; - tmp = p; - } - } - } - if (compar && nitems > 1) - root = fts_sort(sp, root, nitems); - - /* - * Allocate a dummy pointer and make fts_read think that we've just - * finished the node before the root(s); set p->fts_info to FTS_INIT - * so that everything about the "current" node is ignored. - */ - if ((sp->fts_cur = fts_alloc(sp, "", 0)) == NULL) - goto mem3; - sp->fts_cur->fts_link = root; - sp->fts_cur->fts_info = FTS_INIT; - - /* - * If using chdir(2), grab a file descriptor pointing to dot to ensure - * that we can get back here; this could be avoided for some paths, - * but almost certainly not worth the effort. Slashes, symbolic links, - * and ".." are all fairly nasty problems. Note, if we can't get the - * descriptor we run anyway, just more slowly. - */ -#ifndef O_CLOEXEC -#define O_CLOEXEC 0 -#endif - if (!ISSET(FTS_NOCHDIR)) { - if ((sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1) - SET(FTS_NOCHDIR); - } - - if (nitems == 0) - fts_free(parent); - - return (sp); - -mem3: fts_lfree(root); - fts_free(parent); -mem2: free(sp->fts_path); -mem1: free(sp); - return (NULL); -} - -static void -fts_load(FTS *sp, FTSENT *p) -{ - size_t len; - char *cp; - - _DIAGASSERT(sp != NULL); - _DIAGASSERT(p != NULL); - - /* - * Load the stream structure for the next traversal. Since we don't - * actually enter the directory until after the preorder visit, set - * the fts_accpath field specially so the chdir gets done to the right - * place and the user can access the first node. From fts_open it's - * known that the path will fit. - */ - len = p->fts_pathlen = p->fts_namelen; - memmove(sp->fts_path, p->fts_name, len + 1); - if ((cp = strrchr(p->fts_name, '/')) && (cp != p->fts_name || cp[1])) { - len = strlen(++cp); - memmove(p->fts_name, cp, len + 1); - p->fts_namelen = ftsent_namelen_truncate(len); - } - p->fts_accpath = p->fts_path = sp->fts_path; - sp->fts_dev = p->fts_dev; -} - -int -fts_close(FTS *sp) -{ - FTSENT *freep, *p; - int saved_errno = 0; - - _DIAGASSERT(sp != NULL); - - /* - * This still works if we haven't read anything -- the dummy structure - * points to the root list, so we step through to the end of the root - * list which has a valid parent pointer. - */ - if (sp->fts_cur) { - if (sp->fts_cur->fts_flags & FTS_SYMFOLLOW) - (void)close(sp->fts_cur->fts_symfd); - for (p = sp->fts_cur; p->fts_level >= FTS_ROOTLEVEL;) { - freep = p; - p = p->fts_link ? p->fts_link : p->fts_parent; - fts_free(freep); - } - fts_free(p); - } - - /* Free up child linked list, sort array, path buffer. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - if (sp->fts_array) - free(sp->fts_array); - free(sp->fts_path); - - /* Return to original directory, save errno if necessary. */ - if (!ISSET(FTS_NOCHDIR)) { - if (fchdir(sp->fts_rfd) == -1) - saved_errno = errno; - (void)close(sp->fts_rfd); - } - - /* Free up the stream pointer. */ - free(sp); - if (saved_errno) { - errno = saved_errno; - return -1; - } - - return 0; -} - -#if !defined(__FTS_COMPAT_TAILINGSLASH) - -/* - * Special case of "/" at the end of the path so that slashes aren't - * appended which would cause paths to be written as "....//foo". - */ -#define NAPPEND(p) \ - (p->fts_path[p->fts_pathlen - 1] == '/' \ - ? p->fts_pathlen - 1 : p->fts_pathlen) - -#else /* !defined(__FTS_COMPAT_TAILINGSLASH) */ - -/* - * compatibility with the old behaviour. - * - * Special case a root of "/" so that slashes aren't appended which would - * cause paths to be written as "//foo". - */ - -#define NAPPEND(p) \ - (p->fts_level == FTS_ROOTLEVEL && p->fts_pathlen == 1 && \ - p->fts_path[0] == '/' ? 0 : p->fts_pathlen) - -#endif /* !defined(__FTS_COMPAT_TAILINGSLASH) */ - -FTSENT * -fts_read(FTS *sp) -{ - FTSENT *p, *tmp; - int instr; - char *t; - int saved_errno; - - _DIAGASSERT(sp != NULL); - - /* If finished or unrecoverable error, return NULL. */ - if (sp->fts_cur == NULL || ISSET(FTS_STOP)) - return (NULL); - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* Save and zero out user instructions. */ - instr = p->fts_instr; - p->fts_instr = FTS_NOINSTR; - - /* Any type of file may be re-visited; re-stat and re-turn. */ - if (instr == FTS_AGAIN) { - p->fts_info = fts_stat(sp, p, 0); - return (p); - } - - /* - * Following a symlink -- SLNONE test allows application to see - * SLNONE and recover. If indirecting through a symlink, have - * keep a pointer to current location. If unable to get that - * pointer, follow fails. - */ - if (instr == FTS_FOLLOW && - (p->fts_info == FTS_SL || p->fts_info == FTS_SLNONE)) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = open(".", O_RDONLY | O_CLOEXEC, 0)) - == -1) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - return (p); - } - - /* Directory in pre-order. */ - if (p->fts_info == FTS_D) { - /* If skipped or crossed mount point, do post-order visit. */ - if (instr == FTS_SKIP || - (ISSET(FTS_XDEV) && p->fts_dev != sp->fts_dev)) { - if (p->fts_flags & FTS_SYMFOLLOW) - (void)close(p->fts_symfd); - if (sp->fts_child) { - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - p->fts_info = FTS_DP; - return (p); - } - - /* Rebuild if only read the names and now traversing. */ - if (sp->fts_child && ISSET(FTS_NAMEONLY)) { - CLR(FTS_NAMEONLY); - fts_lfree(sp->fts_child); - sp->fts_child = NULL; - } - - /* - * Cd to the subdirectory. - * - * If have already read and now fail to chdir, whack the list - * to make the names come out right, and set the parent errno - * so the application will eventually get an error condition. - * Set the FTS_DONTCHDIR flag so that when we logically change - * directories back to the parent we don't do a chdir. - * - * If haven't read do so. If the read fails, fts_build sets - * FTS_STOP or the fts_info field of the node. - */ - if (sp->fts_child) { - if (fts_safe_changedir(sp, p, -1, p->fts_accpath)) { - p->fts_errno = errno; - p->fts_flags |= FTS_DONTCHDIR; - for (p = sp->fts_child; p; p = p->fts_link) - p->fts_accpath = - p->fts_parent->fts_accpath; - } - } else if ((sp->fts_child = fts_build(sp, BREAD)) == NULL) { - if (ISSET(FTS_STOP)) - return (NULL); - return (p); - } - p = sp->fts_child; - sp->fts_child = NULL; - goto name; - } - -next: - /* Move to the next node on this level. */ - tmp = p; - - /* - * We are going to free sp->fts_cur, set it to NULL so - * that fts_close() does not attempt to free it again - * if we exit without setting it to a new value because - * FCHDIR() failed below. - */ - assert(tmp == sp->fts_cur); - sp->fts_cur = NULL; - - if ((p = p->fts_link) != NULL) { - fts_free(tmp); - - /* - * If reached the top, return to the original directory, and - * load the paths for the next root. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - fts_load(sp, p); - return (sp->fts_cur = p); - } - - /* - * User may have called fts_set on the node. If skipped, - * ignore. If followed, get a file descriptor so we can - * get back if necessary. - */ - if (p->fts_instr == FTS_SKIP) - goto next; - if (p->fts_instr == FTS_FOLLOW) { - p->fts_info = fts_stat(sp, p, 1); - if (p->fts_info == FTS_D && !ISSET(FTS_NOCHDIR)) { - if ((p->fts_symfd = - open(".", O_RDONLY | O_CLOEXEC, 0)) == -1) { - p->fts_errno = errno; - p->fts_info = FTS_ERR; - } else - p->fts_flags |= FTS_SYMFOLLOW; - } - p->fts_instr = FTS_NOINSTR; - } - -name: t = sp->fts_path + NAPPEND(p->fts_parent); - *t++ = '/'; - memmove(t, p->fts_name, (size_t)(p->fts_namelen + 1)); - return (sp->fts_cur = p); - } - - /* Move up to the parent node. */ - p = tmp->fts_parent; - fts_free(tmp); - - if (p->fts_level == FTS_ROOTPARENTLEVEL) { - /* - * Done; free everything up and set errno to 0 so the user - * can distinguish between error and EOF. - */ - fts_free(p); - errno = 0; - return (sp->fts_cur = NULL); - } - - /* NUL terminate the pathname. */ - sp->fts_path[p->fts_pathlen] = '\0'; - - /* - * Return to the parent directory. If at a root node or came through - * a symlink, go back through the file descriptor. Otherwise, cd up - * one directory. - */ - if (p->fts_level == FTS_ROOTLEVEL) { - if (FCHDIR(sp, sp->fts_rfd)) { - SET(FTS_STOP); - return (NULL); - } - } else if (p->fts_flags & FTS_SYMFOLLOW) { - if (FCHDIR(sp, p->fts_symfd)) { - saved_errno = errno; - (void)close(p->fts_symfd); - errno = saved_errno; - SET(FTS_STOP); - return (NULL); - } - (void)close(p->fts_symfd); - } else if (!(p->fts_flags & FTS_DONTCHDIR) && - fts_safe_changedir(sp, p->fts_parent, -1, "..")) { - SET(FTS_STOP); - return (NULL); - } - p->fts_info = p->fts_errno ? FTS_ERR : FTS_DP; - return (sp->fts_cur = p); -} - -/* - * Fts_set takes the stream as an argument although it's not used in this - * implementation; it would be necessary if anyone wanted to add global - * semantics to fts using fts_set. An error return is allowed for similar - * reasons. - */ -/* ARGSUSED */ -int -fts_set(FTS *sp, FTSENT *p, int instr) -{ - - _DIAGASSERT(sp != NULL); - _DIAGASSERT(p != NULL); - - if (instr && instr != FTS_AGAIN && instr != FTS_FOLLOW && - instr != FTS_NOINSTR && instr != FTS_SKIP) { - errno = EINVAL; - return (1); - } - p->fts_instr = instr; - return (0); -} - -FTSENT * -fts_children(FTS *sp, int instr) -{ - FTSENT *p; - int fd; - - _DIAGASSERT(sp != NULL); - - if (instr && instr != FTS_NAMEONLY) { - errno = EINVAL; - return (NULL); - } - - /* Set current node pointer. */ - p = sp->fts_cur; - - /* - * Errno set to 0 so user can distinguish empty directory from - * an error. - */ - errno = 0; - - /* Fatal errors stop here. */ - if (ISSET(FTS_STOP)) - return (NULL); - - /* Return logical hierarchy of user's arguments. */ - if (p->fts_info == FTS_INIT) - return (p->fts_link); - - /* - * If not a directory being visited in pre-order, stop here. Could - * allow FTS_DNR, assuming the user has fixed the problem, but the - * same effect is available with FTS_AGAIN. - */ - if (p->fts_info != FTS_D /* && p->fts_info != FTS_DNR */) - return (NULL); - - /* Free up any previous child list. */ - if (sp->fts_child) - fts_lfree(sp->fts_child); - - if (instr == FTS_NAMEONLY) { - SET(FTS_NAMEONLY); - instr = BNAMES; - } else - instr = BCHILD; - - /* - * If using chdir on a relative path and called BEFORE fts_read does - * its chdir to the root of a traversal, we can lose -- we need to - * chdir into the subdirectory, and we don't know where the current - * directory is, so we can't get back so that the upcoming chdir by - * fts_read will work. - */ - if (p->fts_level != FTS_ROOTLEVEL || p->fts_accpath[0] == '/' || - ISSET(FTS_NOCHDIR)) - return (sp->fts_child = fts_build(sp, instr)); - - if ((fd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1) - return (sp->fts_child = NULL); - sp->fts_child = fts_build(sp, instr); - if (fchdir(fd)) { - (void)close(fd); - return (NULL); - } - (void)close(fd); - return (sp->fts_child); -} - -/* - * This is the tricky part -- do not casually change *anything* in here. The - * idea is to build the linked list of entries that are used by fts_children - * and fts_read. There are lots of special cases. - * - * The real slowdown in walking the tree is the stat calls. If FTS_NOSTAT is - * set and it's a physical walk (so that symbolic links can't be directories), - * we can do things quickly. First, if it's a 4.4BSD file system, the type - * of the file is in the directory entry. Otherwise, we assume that the number - * of subdirectories in a node is equal to the number of links to the parent. - * The former skips all stat calls. The latter skips stat calls in any leaf - * directories and for any files after the subdirectories in the directory have - * been found, cutting the stat calls by about 2/3. - */ -static FTSENT * -fts_build(FTS *sp, int type) -{ - struct dirent *dp; - FTSENT *p, *head; - size_t nitems; - FTSENT *cur, *tail; - DIR *dirp; - void *oldaddr; - size_t dnamlen; - int cderrno, descend, level, nlinks, saved_errno, nostat, doadjust; - size_t len, maxlen; -#ifdef FTS_WHITEOUT - int oflag; -#endif - char *cp = NULL; /* pacify gcc */ - - _DIAGASSERT(sp != NULL); - - /* Set current node pointer. */ - cur = sp->fts_cur; - - /* - * Open the directory for reading. If this fails, we're done. - * If being called from fts_read, set the fts_info field. - */ -#ifdef FTS_WHITEOUT - if (ISSET(FTS_WHITEOUT)) - oflag = DTF_NODUP|DTF_REWIND; - else - oflag = DTF_HIDEW|DTF_NODUP|DTF_REWIND; -#else -#define __opendir2(path, flag) opendir(path) -#endif - if ((dirp = __opendir2(cur->fts_accpath, oflag)) == NULL) { - if (type == BREAD) { - cur->fts_info = FTS_DNR; - cur->fts_errno = errno; - } - return (NULL); - } - - /* - * Nlinks is the number of possible entries of type directory in the - * directory if we're cheating on stat calls, 0 if we're not doing - * any stat calls at all, -1 if we're doing stats on everything. - */ - if (type == BNAMES) { - nlinks = 0; - nostat = 1; - } else if (ISSET(FTS_NOSTAT) && ISSET(FTS_PHYSICAL)) { - nlinks = cur->fts_nlink - (ISSET(FTS_SEEDOT) ? 0 : 2); - nostat = 1; - } else { - nlinks = -1; - nostat = 0; - } - -#ifdef notdef - (void)printf("nlinks == %d (cur: %d)\n", nlinks, cur->fts_nlink); - (void)printf("NOSTAT %d PHYSICAL %d SEEDOT %d\n", - ISSET(FTS_NOSTAT), ISSET(FTS_PHYSICAL), ISSET(FTS_SEEDOT)); -#endif - /* - * If we're going to need to stat anything or we want to descend - * and stay in the directory, chdir. If this fails we keep going, - * but set a flag so we don't chdir after the post-order visit. - * We won't be able to stat anything, but we can still return the - * names themselves. Note, that since fts_read won't be able to - * chdir into the directory, it will have to return different path - * names than before, i.e. "a/b" instead of "b". Since the node - * has already been visited in pre-order, have to wait until the - * post-order visit to return the error. There is a special case - * here, if there was nothing to stat then it's not an error to - * not be able to stat. This is all fairly nasty. If a program - * needed sorted entries or stat information, they had better be - * checking FTS_NS on the returned nodes. - */ - cderrno = 0; - if (nlinks || type == BREAD) { - if (fts_safe_changedir(sp, cur, dirfd(dirp), NULL)) { - if (nlinks && type == BREAD) - cur->fts_errno = errno; - cur->fts_flags |= FTS_DONTCHDIR; - descend = 0; - cderrno = errno; - } else - descend = 1; - } else - descend = 0; - - /* - * Figure out the max file name length that can be stored in the - * current path -- the inner loop allocates more path as necessary. - * We really wouldn't have to do the maxlen calculations here, we - * could do them in fts_read before returning the path, but it's a - * lot easier here since the length is part of the dirent structure. - * - * If not changing directories set a pointer so that can just append - * each new name into the path. - */ - len = NAPPEND(cur); - if (ISSET(FTS_NOCHDIR)) { - cp = sp->fts_path + len; - *cp++ = '/'; - } - len++; - maxlen = sp->fts_pathlen - len; - -#if defined(__FTS_COMPAT_LEVEL) - if (cur->fts_level == SHRT_MAX) { - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = ENAMETOOLONG; - return (NULL); - } -#endif - - level = cur->fts_level + 1; - - /* Read the directory, attaching each entry to the `link' pointer. */ - doadjust = 0; - for (head = tail = NULL, nitems = 0; (dp = readdir(dirp)) != NULL;) { - - if (!ISSET(FTS_SEEDOT) && ISDOT(dp->d_name)) - continue; - -#if defined(HAVE_STRUCT_DIRENT_D_NAMLEN) - dnamlen = dp->d_namlen; -#else - dnamlen = strlen(dp->d_name); -#endif - if ((p = fts_alloc(sp, dp->d_name, dnamlen)) == NULL) - goto mem1; - if (dnamlen >= maxlen) { /* include space for NUL */ - oldaddr = sp->fts_path; - if (fts_palloc(sp, dnamlen + len + 1)) { - /* - * No more memory for path or structures. Save - * errno, free up the current structure and the - * structures already allocated. - */ -mem1: saved_errno = errno; - if (p) - fts_free(p); - fts_lfree(head); - (void)closedir(dirp); - errno = saved_errno; - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - return (NULL); - } - /* Did realloc() change the pointer? */ - if (oldaddr != sp->fts_path) { - doadjust = 1; - if (ISSET(FTS_NOCHDIR)) - cp = sp->fts_path + len; - } - maxlen = sp->fts_pathlen - len; - } - -#if defined(__FTS_COMPAT_LENGTH) - if (len + dnamlen >= USHRT_MAX) { - /* - * In an FTSENT, fts_pathlen is an unsigned short - * so it is possible to wraparound here. - * If we do, free up the current structure and the - * structures already allocated, then error out - * with ENAMETOOLONG. - */ - fts_free(p); - fts_lfree(head); - (void)closedir(dirp); - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - errno = ENAMETOOLONG; - return (NULL); - } -#endif - p->fts_level = level; - p->fts_pathlen = ftsent_pathlen_truncate(len + dnamlen); - p->fts_parent = sp->fts_cur; - -#ifdef FTS_WHITEOUT - if (dp->d_type == DT_WHT) - p->fts_flags |= FTS_ISW; -#endif - - if (cderrno) { - if (nlinks) { - p->fts_info = FTS_NS; - p->fts_errno = cderrno; - } else - p->fts_info = FTS_NSOK; - p->fts_accpath = cur->fts_accpath; - } else if (nlinks == 0 -#ifdef DT_DIR - || (nostat && - dp->d_type != DT_DIR && dp->d_type != DT_UNKNOWN) -#endif - ) { - p->fts_accpath = - ISSET(FTS_NOCHDIR) ? p->fts_path : p->fts_name; - p->fts_info = FTS_NSOK; - } else { - /* Build a file name for fts_stat to stat. */ - if (ISSET(FTS_NOCHDIR)) { - p->fts_accpath = p->fts_path; - memmove(cp, p->fts_name, - (size_t)(p->fts_namelen + 1)); - } else - p->fts_accpath = p->fts_name; - /* Stat it. */ - p->fts_info = fts_stat(sp, p, 0); - - /* Decrement link count if applicable. */ - if (nlinks > 0 && (p->fts_info == FTS_D || - p->fts_info == FTS_DC || p->fts_info == FTS_DOT)) - --nlinks; - } - - /* We walk in directory order so "ls -f" doesn't get upset. */ - p->fts_link = NULL; - if (head == NULL) - head = tail = p; - else { - tail->fts_link = p; - tail = p; - } - ++nitems; - } - (void)closedir(dirp); - - /* - * If had to realloc the path, adjust the addresses for the rest - * of the tree. - */ - if (doadjust) - fts_padjust(sp, head); - - /* - * If not changing directories, reset the path back to original - * state. - */ - if (ISSET(FTS_NOCHDIR)) { - if (len == sp->fts_pathlen || nitems == 0) - --cp; - *cp = '\0'; - } - - /* - * If descended after called from fts_children or after called from - * fts_read and nothing found, get back. At the root level we use - * the saved fd; if one of fts_open()'s arguments is a relative path - * to an empty directory, we wind up here with no other way back. If - * can't get back, we're done. - */ - if (descend && (type == BCHILD || !nitems) && - (cur->fts_level == FTS_ROOTLEVEL ? - FCHDIR(sp, sp->fts_rfd) : - fts_safe_changedir(sp, cur->fts_parent, -1, ".."))) { - cur->fts_info = FTS_ERR; - SET(FTS_STOP); - return (NULL); - } - - /* If didn't find anything, return NULL. */ - if (!nitems) { - if (type == BREAD) - cur->fts_info = FTS_DP; - return (NULL); - } - - /* Sort the entries. */ - if (sp->fts_compar && nitems > 1) - head = fts_sort(sp, head, nitems); - return (head); -} - -static unsigned short -fts_stat(FTS *sp, FTSENT *p, int follow) -{ - FTSENT *t; - dev_t dev; - __fts_ino_t ino; - __fts_stat_t *sbp, sb; - int saved_errno; - - _DIAGASSERT(sp != NULL); - _DIAGASSERT(p != NULL); - - /* If user needs stat info, stat buffer already allocated. */ - sbp = ISSET(FTS_NOSTAT) ? &sb : p->fts_statp; - -#ifdef FTS_WHITEOUT - /* check for whiteout */ - if (p->fts_flags & FTS_ISW) { - if (sbp != &sb) { - memset(sbp, '\0', sizeof (*sbp)); - sbp->st_mode = S_IFWHT; - } - return (FTS_W); - } -#endif - - /* - * If doing a logical walk, or application requested FTS_FOLLOW, do - * a stat(2). If that fails, check for a non-existent symlink. If - * fail, set the errno from the stat call. - */ - if (ISSET(FTS_LOGICAL) || follow) { - if (stat(p->fts_accpath, sbp)) { - saved_errno = errno; - if (!lstat(p->fts_accpath, sbp)) { - errno = 0; - return (FTS_SLNONE); - } - p->fts_errno = saved_errno; - goto err; - } - } else if (lstat(p->fts_accpath, sbp)) { - p->fts_errno = errno; -err: memset(sbp, 0, sizeof(*sbp)); - return (FTS_NS); - } - - if (S_ISDIR(sbp->st_mode)) { - /* - * Set the device/inode. Used to find cycles and check for - * crossing mount points. Also remember the link count, used - * in fts_build to limit the number of stat calls. It is - * understood that these fields are only referenced if fts_info - * is set to FTS_D. - */ - dev = p->fts_dev = sbp->st_dev; - ino = p->fts_ino = sbp->st_ino; - p->fts_nlink = sbp->st_nlink; - - if (ISDOT(p->fts_name)) - return (FTS_DOT); - - /* - * Cycle detection is done by brute force when the directory - * is first encountered. If the tree gets deep enough or the - * number of symbolic links to directories is high enough, - * something faster might be worthwhile. - */ - for (t = p->fts_parent; - t->fts_level >= FTS_ROOTLEVEL; t = t->fts_parent) - if (ino == t->fts_ino && dev == t->fts_dev) { - p->fts_cycle = t; - return (FTS_DC); - } - return (FTS_D); - } - if (S_ISLNK(sbp->st_mode)) - return (FTS_SL); - if (S_ISREG(sbp->st_mode)) - return (FTS_F); - return (FTS_DEFAULT); -} - -static FTSENT * -fts_sort(FTS *sp, FTSENT *head, size_t nitems) -{ - FTSENT **ap, *p; - - _DIAGASSERT(sp != NULL); - _DIAGASSERT(head != NULL); - - /* - * Construct an array of pointers to the structures and call qsort(3). - * Reassemble the array in the order returned by qsort. If unable to - * sort for memory reasons, return the directory entries in their - * current order. Allocate enough space for the current needs plus - * 40 so don't realloc one entry at a time. - */ - if (nitems > sp->fts_nitems) { - FTSENT **new; - - new = realloc(sp->fts_array, sizeof(FTSENT *) * (nitems + 40)); - if (new == 0) - return (head); - sp->fts_array = new; - sp->fts_nitems = fts_nitems_truncate(nitems + 40); - } - for (ap = sp->fts_array, p = head; p; p = p->fts_link) - *ap++ = p; - qsort((void *)sp->fts_array, nitems, sizeof(FTSENT *), - (int (*)(const void *, const void *))sp->fts_compar); - for (head = *(ap = sp->fts_array); --nitems; ++ap) - ap[0]->fts_link = ap[1]; - ap[0]->fts_link = NULL; - return (head); -} - -static FTSENT * -fts_alloc(FTS *sp, const char *name, size_t namelen) -{ - FTSENT *p; -#if defined(FTS_ALLOC_ALIGNED) - size_t len; -#endif - - _DIAGASSERT(sp != NULL); - _DIAGASSERT(name != NULL); - -#if defined(FTS_ALLOC_ALIGNED) - /* - * The file name is a variable length array and no stat structure is - * necessary if the user has set the nostat bit. Allocate the FTSENT - * structure, the file name and the stat structure in one chunk, but - * be careful that the stat structure is reasonably aligned. Since the - * fts_name field is declared to be of size 1, the fts_name pointer is - * namelen + 2 before the first possible address of the stat structure. - */ - len = sizeof(FTSENT) + namelen; - if (!ISSET(FTS_NOSTAT)) - len += sizeof(*(p->fts_statp)) + ALIGNBYTES; - if ((p = malloc(len)) == NULL) - return (NULL); - - if (!ISSET(FTS_NOSTAT)) - p->fts_statp = (__fts_stat_t *)ALIGN( - (unsigned long)(p->fts_name + namelen + 2)); -#else - if ((p = malloc(sizeof(FTSENT) + namelen)) == NULL) - return (NULL); - - if (!ISSET(FTS_NOSTAT)) - if ((p->fts_statp = malloc(sizeof(*(p->fts_statp)))) == NULL) { - free(p); - return (NULL); - } -#endif - - if (ISSET(FTS_NOSTAT)) - p->fts_statp = NULL; - - /* Copy the name plus the trailing NULL. */ - memmove(p->fts_name, name, namelen + 1); - - p->fts_namelen = ftsent_namelen_truncate(namelen); - p->fts_path = sp->fts_path; - p->fts_errno = 0; - p->fts_flags = 0; - p->fts_instr = FTS_NOINSTR; - p->fts_number = 0; - p->fts_pointer = NULL; - return (p); -} - -static void -fts_free(FTSENT *p) -{ -#if !defined(FTS_ALLOC_ALIGNED) - if (p->fts_statp) - free(p->fts_statp); -#endif - free(p); -} - -static void -fts_lfree(FTSENT *head) -{ - FTSENT *p; - - /* XXX: head may be NULL ? */ - - /* Free a linked list of structures. */ - while ((p = head) != NULL) { - head = head->fts_link; - fts_free(p); - } -} - -static size_t -fts_pow2(size_t x) -{ - - x--; - x |= x>>1; - x |= x>>2; - x |= x>>4; - x |= x>>8; - x |= x>>16; -#if LONG_BIT > 32 - x |= x>>32; -#endif -#if LONG_BIT > 64 - x |= x>>64; -#endif - x++; - return (x); -} - -/* - * Allow essentially unlimited paths; find, rm, ls should all work on any tree. - * Most systems will allow creation of paths much longer than MAXPATHLEN, even - * though the kernel won't resolve them. Round up the new size to a power of 2, - * so we don't realloc the path 2 bytes at a time. - */ -static int -fts_palloc(FTS *sp, size_t size) -{ - char *new; - - _DIAGASSERT(sp != NULL); - -#ifdef __FTS_COMPAT_LENGTH - /* Protect against fts_pathlen overflow. */ - if (size > USHRT_MAX + 1) { - errno = ENAMETOOLONG; - return (1); - } -#endif - size = fts_pow2(size); - new = realloc(sp->fts_path, size); - if (new == 0) - return (1); - sp->fts_path = new; - sp->fts_pathlen = fts_pathlen_truncate(size); - return (0); -} - -/* - * When the path is realloc'd, have to fix all of the pointers in structures - * already returned. - */ -static void -fts_padjust(FTS *sp, FTSENT *head) -{ - FTSENT *p; - char *addr; - - _DIAGASSERT(sp != NULL); - -#define ADJUST(p) do { \ - if ((p)->fts_accpath != (p)->fts_name) \ - (p)->fts_accpath = \ - addr + ((p)->fts_accpath - (p)->fts_path); \ - (p)->fts_path = addr; \ -} while (/*CONSTCOND*/0) - - addr = sp->fts_path; - - /* Adjust the current set of children. */ - for (p = sp->fts_child; p; p = p->fts_link) - ADJUST(p); - - /* Adjust the rest of the tree, including the current level. */ - for (p = head; p->fts_level >= FTS_ROOTLEVEL;) { - ADJUST(p); - p = p->fts_link ? p->fts_link : p->fts_parent; - } -} - -static size_t -fts_maxarglen(char * const *argv) -{ - size_t len, max; - - _DIAGASSERT(argv != NULL); - - for (max = 0; *argv; ++argv) - if ((len = strlen(*argv)) > max) - max = len; - return (max + 1); -} - -#if defined(__minix) -#if ! HAVE_NBTOOL_CONFIG_H -#include -#else -#define NONE_MAJOR 0 -#endif -#endif /* defined(__minix) */ - -/* - * Change to dir specified by fd or p->fts_accpath without getting - * tricked by someone changing the world out from underneath us. - * Assumes p->fts_dev and p->fts_ino are filled in. - */ -static int -fts_safe_changedir(const FTS *sp, const FTSENT *p, int fd, const char *path) -{ - int oldfd = fd, ret = -1; - __fts_stat_t sb; - - if (ISSET(FTS_NOCHDIR)) - return 0; - - if (oldfd < 0 && (fd = open(path, O_RDONLY | O_CLOEXEC)) == -1) - return -1; - - if (fstat(fd, &sb) == -1) - goto bail; - -#if defined(__minix) - /* - * Skip the safety check on file systems where inodes are not static. - * On such file systems, a file may legitimately be assigned a new - * inode number due to being deleted and regenerated while we are - * running. This behavior is not POSIX compliant, but necessary for - * certain types of file systems. Currently, we assume that this - * applies to all (and only) file systems that are not device backed. - * In the future, we may have to obtain an appropriate flag through - * statvfs(3) instead. - */ - if ((sb.st_ino != p->fts_ino || sb.st_dev != p->fts_dev) - && major(sb.st_dev) != NONE_MAJOR) { -#else - if (sb.st_ino != p->fts_ino || sb.st_dev != p->fts_dev) { -#endif /* defined(__minix) */ - errno = ENOENT; - goto bail; - } - - ret = fchdir(fd); - -bail: - if (oldfd < 0) { - int save_errno = errno; - (void)close(fd); - errno = save_errno; - } - return ret; -} diff --git a/lib/libc/gen/ftw.3 b/lib/libc/gen/ftw.3 deleted file mode 100644 index 4343823ac..000000000 --- a/lib/libc/gen/ftw.3 +++ /dev/null @@ -1,214 +0,0 @@ -.\" $NetBSD: ftw.3,v 1.5 2010/04/30 04:39:16 jruoho Exp $ -.\" -.\" From OpenBSD: ftw.3,v 1.4 2003/10/30 18:52:58 jmc Exp -.\" -.\" Copyright (c) 2003 Todd C. Miller -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Sponsored in part by the Defense Advanced Research Projects -.\" Agency (DARPA) and Air Force Research Laboratory, Air Force -.\" Materiel Command, USAF, under agreement number F39502-99-1-0512. -.\" -.Dd April 30, 2010 -.Dt FTW 3 -.Os -.Sh NAME -.Nm ftw, nftw -.Nd traverse (walk) a file tree -.Sh SYNOPSIS -.In ftw.h -.Ft int -.Fo ftw -.Fa "const char *path" -.Fa "int (*fn)(const char *, const struct stat *, int)" -.Fa "int maxfds" -.Fc -.Ft int -.Fo nftw -.Fa "const char *path" -.Fa "int (*fn)(const\ char\ *, const\ struct\ stat\ *, int, struct\ FTW\ *)" -.Fa "int maxfds" -.Fa "int flags" -.Fc -.Sh DESCRIPTION -.Bf -symbolic -These functions are provided for compatibility with legacy code. -New code should use the -.Xr fts 3 -functions. -.Ef -.Pp -The -.Fn ftw -and -.Fn nftw -functions traverse (walk) the directory hierarchy rooted in -.Fa path . -For each object in the hierarchy, these functions call the function -pointed to by -.Fa fn . -The -.Fn ftw -function passes this function a pointer to a NUL-terminated string containing -the name of the object, a pointer to a stat structure corresponding to the -object, and an integer flag. -The -.Fn nftw -function passes the aforementioned arguments plus a pointer to a -.Dv FTW -structure as defined by -.In ftw.h -(shown below): -.Bd -literal -struct FTW { - int base; /* offset of basename into pathname */ - int level; /* directory depth relative to starting point */ -}; -.Ed -.Pp -Possible values for the flag passed to -.Fa fn -are: -.Bl -tag -width FTW_DNR -.It Dv FTW_F -A regular file. -.It Dv FTW_D -A directory being visited in pre-order. -.It Dv FTW_DNR -A directory which cannot be read. -The directory will not be descended into. -.It Dv FTW_DP -A directory being visited in post-order -.Pq Fn nftw No only . -.It Dv FTW_NS -A file for which no -.Xr stat 2 -information was available. -The contents of the stat structure are undefined. -.It Dv FTW_SL -A symbolic link. -.It Dv FTW_SLN -A symbolic link with a non-existent target -.Pq Fn nftw No only . -.El -.Pp -The -.Fn ftw -function traverses the tree in pre-order. -That is, it processes the directory before the directory's contents. -.Pp -The -.Fa maxfds -argument specifies the maximum number of file descriptors -to keep open while traversing the tree. -It has no effect in this implementation. -.Pp -The -.Fn nftw -function has an additional -.Fa flags -argument with the following possible values: -.Bl -tag -width FTW_MOUNT -.It Dv FTW_PHYS -Physical walk, don't follow symbolic links. -.It Dv FTW_MOUNT -The walk will not cross a mount point. -.It FTW_DEPTH -Process directories in post-order. -Contents of a directory are visited before the directory itself. -By default, -.Fn nftw -traverses the tree in pre-order. -.It FTW_CHDIR -Change to a directory before reading it. -By default, -.Fn nftw -will change its starting directory. -The current working directory will be restored to its original value before -.Fn nftw -returns. -.El -.Sh RETURN VALUES -If the tree was traversed successfully, the -.Fn ftw -and -.Fn nftw -functions return 0. -If the function pointed to by -.Fa fn -returns a non-zero value, -.Fn ftw -and -.Fn nftw -will stop processing the tree and return the value from -.Fa fn . -Both functions return \-1 if an error is detected. -.Sh ERRORS -The -.Fn ftw -and -.Fn nftw -functions may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr close 2 , -.Xr open 2 , -.Xr stat 2 , -.Xr malloc 3 , -.Xr opendir 3 , -and -.Xr readdir 3 . -If the -.Dv FGTW_CHDIR -flag is set, the -.Fn nftw -function may fail and set -.Va errno -for any of the errors specified for -.Xr chdir 2 . -In addition, either function may fail and set -.Va errno -as follows: -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa maxfds -argument is less than 1 or greater than -.Dv OPEN_MAX . -.El -.Sh SEE ALSO -.Xr chdir 2 , -.Xr close 2 , -.Xr open 2 , -.Xr stat 2 , -.Xr fts 3 , -.Xr malloc 3 , -.Xr opendir 3 , -.Xr readdir 3 -.Sh STANDARDS -The -.Fn ftw -and -.Fn nftw -functions conform to -.St -p1003.1-2001 . -The -.St -p1003.1-2008 -revision marked the function -.Fn ftw -as obsolete. -.Sh BUGS -The -.Fa maxfds -argument is currently ignored. diff --git a/lib/libc/gen/ftw.c b/lib/libc/gen/ftw.c deleted file mode 100644 index a7f6bbdb6..000000000 --- a/lib/libc/gen/ftw.c +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: ftw.c,v 1.1 2005/12/30 23:07:32 agc Exp $ */ - -/* From OpenBSD: ftw.c,v 1.2 2003/07/21 21:15:32 millert Exp */ - -/* - * Copyright (c) 2003 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ -#include - -#ifndef lint -__RCSID("$NetBSD: ftw.c,v 1.1 2005/12/30 23:07:32 agc Exp $"); -#endif - -#include -#include -#include -#include -#include -#include - -int -ftw(const char *path, int (*fn)(const char *, const struct stat *, int), - int nfds) -{ - /* LINTED */ - char * const paths[2] = { __UNCONST(path), NULL }; - FTSENT *cur; - FTS *ftsp; - int fnflag, error, sverrno; - - /* XXX - nfds is currently unused */ - if (nfds < 1 || nfds > OPEN_MAX) { - errno = EINVAL; - return (-1); - } - - ftsp = fts_open(paths, FTS_COMFOLLOW | FTS_NOCHDIR, NULL); - if (ftsp == NULL) - return (-1); - error = 0; - while ((cur = fts_read(ftsp)) != NULL) { - switch (cur->fts_info) { - case FTS_D: - fnflag = FTW_D; - break; - case FTS_DNR: - fnflag = FTW_DNR; - break; - case FTS_DP: - /* we only visit in preorder */ - continue; - case FTS_F: - case FTS_DEFAULT: - fnflag = FTW_F; - break; - case FTS_NS: - case FTS_NSOK: - case FTS_SLNONE: - fnflag = FTW_NS; - break; - case FTS_SL: - fnflag = FTW_SL; - break; - case FTS_DC: - errno = ELOOP; - /* FALLTHROUGH */ - default: - error = -1; - goto done; - } - error = fn(cur->fts_path, cur->fts_statp, fnflag); - if (error != 0) - break; - } -done: - sverrno = errno; - if (fts_close(ftsp) != 0 && error == 0) - error = -1; - else - errno = sverrno; - return (error); -} diff --git a/lib/libc/gen/getbsize.3 b/lib/libc/gen/getbsize.3 deleted file mode 100644 index b3c100208..000000000 --- a/lib/libc/gen/getbsize.3 +++ /dev/null @@ -1,90 +0,0 @@ -.\" $NetBSD: getbsize.3,v 1.9 2003/08/07 16:42:48 agc Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getbsize.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd May 30, 2003 -.Dt GETBSIZE 3 -.Os -.Sh NAME -.Nm getbsize -.Nd get user block size -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft char * -.Fn getbsize "int *headerlenp" "long *blocksizep" -.Sh DESCRIPTION -The -.Nm getbsize -function determines the user's preferred block size based on the value of the -.Dq BLOCKSIZE -environment variable; see -.Xr environ 7 -for details on its use and format. -.Pp -The -.Nm getbsize -function returns a pointer to a -.Dv NUL -terminated string describing -the block size, something like -.Dq 1K-blocks . -If the -.Fa headerlenp -parameter is not -.Dv NULL -the memory referenced by -.Fa headerlenp -is filled in with the length of the string (not including the -terminating -.Dv NUL ) . -If the -.Fa blocksizep -parameter is not -.Dv NULL -the memory referenced by -.Fa blocksizep -is filled in with block size, in bytes. -.Pp -If the user's block size is unreasonable, a warning message is -written to standard error and the returned information reflects -a block size of 512 bytes. -.Sh SEE ALSO -.Xr df 1 , -.Xr du 1 , -.Xr ls 1 , -.Xr systat 1 , -.Xr environ 7 -.Sh HISTORY -The -.Nm getbsize -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/getbsize.c b/lib/libc/gen/getbsize.c deleted file mode 100644 index a9ce2c14e..000000000 --- a/lib/libc/gen/getbsize.c +++ /dev/null @@ -1,118 +0,0 @@ -/* $NetBSD: getbsize.c,v 1.17 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1991, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getbsize.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getbsize.c,v 1.17 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getbsize,_getbsize) -#endif - -char * -getbsize(int *headerlenp, long *blocksizep) -{ - static char header[20]; - long n, max, mul, blocksize; - char *ep, *p; - const char *form; - -#define KB (1024L) -#define MB (1024L * 1024L) -#define GB (1024L * 1024L * 1024L) -#define MAXB GB /* No tera, peta, nor exa. */ - form = ""; - if ((p = getenv("BLOCKSIZE")) != NULL && *p != '\0') { - if ((n = strtol(p, &ep, 10)) < 0) - goto underflow; - if (n == 0) - n = 1; - if (*ep && ep[1]) - goto fmterr; - switch (*ep) { - case 'G': case 'g': - form = "G"; - max = MAXB / GB; - mul = GB; - break; - case 'K': case 'k': - form = "K"; - max = MAXB / KB; - mul = KB; - break; - case 'M': case 'm': - form = "M"; - max = MAXB / MB; - mul = MB; - break; - case '\0': - max = MAXB; - mul = 1; - break; - default: -fmterr: warnx("%s: unknown blocksize", p); - n = 512; - mul = 1; - max = 0; - break; - } - if (n > max) { - warnx("maximum blocksize is %ldG", MAXB / GB); - n = max; - } - if ((blocksize = n * mul) < 512) { -underflow: warnx("%s: minimum blocksize is 512", p); - form = ""; - blocksize = n = 512; - } - } else - blocksize = n = 512; - - if (headerlenp) - *headerlenp = - snprintf(header, sizeof(header), "%ld%s-blocks", n, form); - if (blocksizep) - *blocksizep = blocksize; - return (header); -} diff --git a/lib/libc/gen/getcap.c b/lib/libc/gen/getcap.c deleted file mode 100644 index 9b78276c6..000000000 --- a/lib/libc/gen/getcap.c +++ /dev/null @@ -1,1212 +0,0 @@ -/* $NetBSD: getcap.c,v 1.56 2014/09/24 13:18:52 christos Exp $ */ - -/*- - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Casey Leedom of Lawrence Livermore National Laboratory. - * - * 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. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getcap.c 8.3 (Berkeley) 3/25/94"; -#else -__RCSID("$NetBSD: getcap.c,v 1.56 2014/09/24 13:18:52 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifndef SMALL -#include "namespace.h" -#endif -#include -#include - -#include -#include -#include -#ifndef SMALL -#include -#endif -#include -#include -#include -#include -#include -#include -#include - -#if defined(__weak_alias) && !defined(SMALL) -__weak_alias(cgetcap,_cgetcap) -__weak_alias(cgetclose,_cgetclose) -__weak_alias(cgetent,_cgetent) -__weak_alias(cgetfirst,_cgetfirst) -__weak_alias(cgetmatch,_cgetmatch) -__weak_alias(cgetnext,_cgetnext) -__weak_alias(cgetnum,_cgetnum) -__weak_alias(cgetset,_cgetset) -__weak_alias(cgetstr,_cgetstr) -__weak_alias(cgetustr,_cgetustr) -__weak_alias(csetexpandtc,_csetexpandtc) -#endif - -#define BFRAG 1024 -#define BSIZE 1024 -#define ESC ('[' & 037) /* ASCII ESC */ -#define MAX_RECURSION 32 /* maximum getent recursion */ -#define SFRAG 100 /* cgetstr mallocs in SFRAG chunks */ - -#define RECOK (char)0 -#define TCERR (char)1 -#define SHADOW (char)2 - -static size_t topreclen; /* toprec length */ -static char *toprec; /* Additional record specified by cgetset() */ -static int gottoprec; /* Flag indicating retrieval of toprecord */ -static int expandtc = 1; /* flag to expand tc= or not */ - -#ifndef SMALL -static int cdbget(DB *, char **, const char *); -#endif -static int getent(char **, size_t *, const char * const *, int, - const char *, int, char *); -static int nfcmp(char *, char *); - -/* - * Cgetset() allows the addition of a user specified buffer to be added - * to the database array, in effect "pushing" the buffer on top of the - * virtual database. 0 is returned on success, -1 on failure. - */ -int -cgetset(const char *ent) -{ - const char *source, *check; - char *dest; - - if (ent == NULL) { - if (toprec != NULL) - free(toprec); - toprec = NULL; - topreclen = 0; - return 0; - } - topreclen = strlen(ent); - if ((toprec = malloc(topreclen + 1)) == NULL) { - errno = ENOMEM; - return -1; - } - gottoprec = 0; - - source = ent; - dest = toprec; - while (*source != '\0') { /* Strip whitespace */ - *dest++ = *source++; /* Do not check first field */ - while (*source == ':') { - check = source + 1; - while (*check && (isspace((unsigned char)*check) || - (*check=='\\' && isspace((unsigned char)check[1])))) - ++check; - if (*check == ':') - source = check; - else - break; - - } - } - *dest = 0; - - return 0; -} - -/* - * Cgetcap searches the capability record buf for the capability cap with - * type `type'. A pointer to the value of cap is returned on success, NULL - * if the requested capability couldn't be found. - * - * Specifying a type of ':' means that nothing should follow cap (:cap:). - * In this case a pointer to the terminating ':' or NUL will be returned if - * cap is found. - * - * If (cap, '@') or (cap, terminator, '@') is found before (cap, terminator) - * return NULL. - */ -char * -cgetcap(char *buf, const char *cap, int type) -{ - char *bp; - const char *cp; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(cap != NULL); - - bp = buf; - for (;;) { - /* - * Skip past the current capability field - it's either the - * name field if this is the first time through the loop, or - * the remainder of a field whose name failed to match cap. - */ - for (;;) - if (*bp == '\0') - return NULL; - else if (*bp++ == ':') - break; - - /* - * Try to match (cap, type) in buf. - */ - for (cp = cap; *cp == *bp && *bp != '\0'; cp++, bp++) - continue; - if (*cp != '\0') - continue; - if (*bp == '@') - return NULL; - if (type == ':') { - if (*bp != '\0' && *bp != ':') - continue; - return bp; - } - if (*bp != type) - continue; - bp++; - return *bp == '@' ? NULL : bp; - } - /* NOTREACHED */ -} - -/* - * Cgetent extracts the capability record name from the NULL terminated file - * array db_array and returns a pointer to a malloc'd copy of it in buf. - * Buf must be retained through all subsequent calls to cgetcap, cgetnum, - * cgetflag, and cgetstr, but may then be free'd. 0 is returned on success, - * -1 if the requested record couldn't be found, -2 if a system error was - * encountered (couldn't open/read a file, etc.), and -3 if a potential - * reference loop is detected. - */ -/* coverity[+alloc : arg-*0] */ -int -cgetent(char **buf, const char * const *db_array, const char *name) -{ - size_t dummy; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(db_array != NULL); - _DIAGASSERT(name != NULL); - - return getent(buf, &dummy, db_array, -1, name, 0, NULL); -} - -void -csetexpandtc(int etc) -{ - expandtc = etc; -} - -/* - * Getent implements the functions of cgetent. If fd is non-negative, - * *db_array has already been opened and fd is the open file descriptor. We - * do this to save time and avoid using up file descriptors for tc= - * recursions. - * - * Getent returns the same success/failure codes as cgetent. On success, a - * pointer to a malloc'ed capability record with all tc= capabilities fully - * expanded and its length (not including trailing ASCII NUL) are left in - * *cap and *len. - * - * Basic algorithm: - * + Allocate memory incrementally as needed in chunks of size BFRAG - * for capability buffer. - * + Recurse for each tc=name and interpolate result. Stop when all - * names interpolated, a name can't be found, or depth exceeds - * MAX_RECURSION. - */ -/* coverity[+alloc : arg-*0] */ -static int -getent(char **cap, size_t *len, const char * const *db_array, int fd, - const char *name, int depth, char *nfield) -{ - char *record, *newrecord; - char *r_end, *rp; /* pacify gcc */ - const char * const *db_p; - int myfd, eof, foundit; - int tc_not_resolved; - - _DIAGASSERT(cap != NULL); - _DIAGASSERT(len != NULL); - _DIAGASSERT(db_array != NULL); - /* fd may be -1 */ - _DIAGASSERT(name != NULL); - /* nfield may be NULL */ - - myfd = 0; - rp = NULL; - - /* - * Return with ``loop detected'' error if we've recursed more than - * MAX_RECURSION times. - */ - if (depth > MAX_RECURSION) - return -3; - - /* - * Check if we have a top record from cgetset(). - */ - if (depth == 0 && toprec != NULL && cgetmatch(toprec, name) == 0) { - if ((record = malloc(topreclen + BFRAG)) == NULL) { - errno = ENOMEM; - return -2; - } - (void)strcpy(record, toprec); /* XXX: strcpy is safe */ - db_p = db_array; - rp = record + topreclen + 1; - r_end = rp + BFRAG; - goto tc_exp; - } - /* - * Allocate first chunk of memory. - */ - if ((record = malloc(BFRAG)) == NULL) { - errno = ENOMEM; - return -2; - } - r_end = record + BFRAG; - foundit = 0; - /* - * Loop through database array until finding the record. - */ - - for (db_p = db_array; *db_p != NULL; db_p++) { - eof = 0; - - /* - * Open database if not already open. - */ - - if (fd >= 0) { - (void)lseek(fd, (off_t)0, SEEK_SET); - } else { -#ifndef SMALL - DB *capdbp; - char pbuf[MAXPATHLEN]; - char *cbuf; - int retval; - size_t clen; - - (void)snprintf(pbuf, sizeof(pbuf), "%s.db", *db_p); - if ((capdbp = dbopen(pbuf, O_RDONLY | O_CLOEXEC, 0, - DB_HASH, 0)) != NULL) { - free(record); - retval = cdbget(capdbp, &record, name); - if (retval < 0) { - /* no record available */ - (void)capdbp->close(capdbp); - return retval; - } - /* save the data; close frees it */ - clen = strlen(record); - if ((cbuf = malloc(clen + 1)) == NULL) { - (void)capdbp->close(capdbp); - errno = ENOMEM; - return -2; - } - memmove(cbuf, record, clen + 1); - if (capdbp->close(capdbp) < 0) { - int serrno = errno; - - free(cbuf); - errno = serrno; - return -2; - } - *len = clen; - *cap = cbuf; - return retval; - } else -#endif - { - fd = open(*db_p, O_RDONLY | O_CLOEXEC, 0); - if (fd < 0) { - /* No error on unfound file. */ - continue; - } - myfd = 1; - } - } - /* - * Find the requested capability record ... - */ - { - char buf[BUFSIZ]; - char *b_end, *bp, *cp; - int c, slash; - - /* - * Loop invariants: - * There is always room for one more character in record. - * R_end always points just past end of record. - * Rp always points just past last character in record. - * B_end always points just past last character in buf. - * Bp always points at next character in buf. - * Cp remembers where the last colon was. - */ - b_end = buf; - bp = buf; - cp = NULL; - slash = 0; - for (;;) { - /* - * Read in a line implementing (\, newline) - * line continuation. - */ - rp = record; - for (;;) { - if (bp >= b_end) { - ssize_t n; - - n = read(fd, buf, sizeof(buf)); - if (n <= 0) { - if (myfd) - (void)close(fd); - if (n < 0) { - int serrno = errno; - - free(record); - errno = serrno; - return -2; - } else { - fd = -1; - eof = 1; - break; - } - } - b_end = buf+n; - bp = buf; - } - - c = *bp++; - if (c == '\n') { - if (slash) { - slash = 0; - rp--; - continue; - } else - break; - } - if (slash) { - slash = 0; - cp = 0; - } - if (c == ':') { - /* - * If the field was `empty' (i.e. - * contained only white space), back up - * to the colon (eliminating the - * field). - */ - if (cp != NULL) - rp = cp; - else - cp = rp; - } else if (c == '\\') { - slash = 1; - } else if (c != ' ' && c != '\t') { - /* - * Forget where the colon was, as this - * is not an empty field. - */ - cp = 0; - } - *rp++ = c; - - /* - * Enforce loop invariant: if no room - * left in record buffer, try to get - * some more. - */ - if (rp >= r_end) { - ptrdiff_t pos; - size_t newsize; - - pos = rp - record; - newsize = r_end - record + BFRAG; - newrecord = realloc(record, newsize); - if (newrecord == NULL) { - free(record); - if (myfd) - (void)close(fd); - errno = ENOMEM; - return -2; - } - record = newrecord; - r_end = record + newsize; - rp = record + pos; - } - } - /* Eliminate any white space after the last colon. */ - if (cp) - rp = cp + 1; - /* Loop invariant lets us do this. */ - *rp++ = '\0'; - - /* - * If encountered eof check next file. - */ - if (eof) - break; - - /* - * Toss blank lines and comments. - */ - if (*record == '\0' || *record == '#') - continue; - - /* - * See if this is the record we want ... - */ - if (cgetmatch(record, name) == 0) - if (nfield == NULL || !nfcmp(nfield, record)) { - foundit = 1; - break; /* found it! */ - } - } - } - if (foundit) - break; - } - - if (!foundit) - return -1; - - /* - * Got the capability record, but now we have to expand all tc=name - * references in it ... - */ -tc_exp: - tc_not_resolved = 0; - if (expandtc) { - char *newicap, *s; - size_t ilen, newilen; - int iret; - ptrdiff_t diff, tclen; - char *icap, *scan, *tc, *tcstart, *tcend; - - /* - * Loop invariants: - * There is room for one more character in record. - * R_end points just past end of record. - * Rp points just past last character in record. - * Scan points at remainder of record that needs to be - * scanned for tc=name constructs. - */ - scan = record; - for (;;) { - if ((tc = cgetcap(scan, "tc", '=')) == NULL) - break; - - /* - * Find end of tc=name and stomp on the trailing `:' - * (if present) so we can use it to call ourselves. - */ - s = tc; - for (;;) - if (*s == '\0') - break; - else - if (*s++ == ':') { - *(s - 1) = '\0'; - break; - } - tcstart = tc - 3; - tclen = s - tcstart; - tcend = s; - - iret = getent(&icap, &ilen, db_p, fd, tc, depth+1, - NULL); - newicap = icap; /* Put into a register. */ - newilen = ilen; - if (iret != 0) { - /* an error */ - if (iret < -1) { - if (myfd) - (void)close(fd); - free(record); - return iret; - } - if (iret == 1) - tc_not_resolved = 1; - /* couldn't resolve tc */ - if (iret == -1) { - *(s - 1) = ':'; - scan = s - 1; - tc_not_resolved = 1; - continue; - - } - } - /* not interested in name field of tc'ed record */ - s = newicap; - for (;;) - if (*s == '\0') - break; - else if (*s++ == ':') - break; - newilen -= s - newicap; - newicap = s; - - /* make sure interpolated record is `:'-terminated */ - s += newilen; - if (*(s - 1) != ':') { - *s = ':'; /* overwrite NUL with : */ - newilen++; - } - - /* - * Make sure there's enough room to insert the - * new record. - */ - diff = newilen - tclen; - if (diff >= r_end - rp) { - ptrdiff_t pos, tcpos, tcposend; - size_t newsize; - - pos = rp - record; - newsize = r_end - record + diff + BFRAG; - tcpos = tcstart - record; - tcposend = tcend - record; - newrecord = realloc(record, newsize); - if (newrecord == NULL) { - free(record); - if (myfd) - (void)close(fd); - free(icap); - errno = ENOMEM; - return -2; - } - record = newrecord; - r_end = record + newsize; - rp = record + pos; - tcstart = record + tcpos; - tcend = record + tcposend; - } - - /* - * Insert tc'ed record into our record. - */ - s = tcstart + newilen; - memmove(s, tcend, (size_t)(rp - tcend)); - memmove(tcstart, newicap, newilen); - rp += diff; - free(icap); - - /* - * Start scan on `:' so next cgetcap works properly - * (cgetcap always skips first field). - */ - scan = s - 1; - } - - } - /* - * Close file (if we opened it), give back any extra memory, and - * return capability, length and success. - */ - if (myfd) - (void)close(fd); - *len = rp - record - 1; /* don't count NUL */ - if (r_end > rp) { - if ((newrecord = - realloc(record, (size_t)(rp - record))) == NULL) { - free(record); - errno = ENOMEM; - return -2; - } - record = newrecord; - } - - *cap = record; - if (tc_not_resolved) - return 1; - return 0; -} - -#ifndef SMALL -static int -cdbget(DB *capdbp, char **bp, const char *name) -{ - DBT key; - DBT data; - - _DIAGASSERT(capdbp != NULL); - _DIAGASSERT(bp != NULL); - _DIAGASSERT(name != NULL); - - key.data = __UNCONST(name); - key.size = strlen(name); - - for (;;) { - /* Get the reference. */ - switch(capdbp->get(capdbp, &key, &data, 0)) { - case -1: - return -2; - case 1: - return -1; - } - - /* If not an index to another record, leave. */ - if (((char *)data.data)[0] != SHADOW) - break; - - key.data = (char *)data.data + 1; - key.size = data.size - 1; - } - - *bp = (char *)data.data + 1; - return ((char *)(data.data))[0] == TCERR ? 1 : 0; -} -#endif - -/* - * Cgetmatch will return 0 if name is one of the names of the capability - * record buf, -1 if not. - */ -int -cgetmatch(const char *buf, const char *name) -{ - const char *np, *bp; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(name != NULL); - - /* - * Start search at beginning of record. - */ - bp = buf; - for (;;) { - /* - * Try to match a record name. - */ - np = name; - for (;;) - if (*np == '\0') { - if (*bp == '|' || *bp == ':' || *bp == '\0') - return 0; - else - break; - } else if (*bp++ != *np++) - break; - - /* - * Match failed, skip to next name in record. - */ - if (bp > buf) - bp--; /* a '|' or ':' may have stopped the match */ - else - return -1; - for (;;) - if (*bp == '\0' || *bp == ':') - return -1; /* match failed totally */ - else if (*bp++ == '|') - break; /* found next name */ - } -} - -int -cgetfirst(char **buf, const char * const *db_array) -{ - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(db_array != NULL); - - (void)cgetclose(); - return cgetnext(buf, db_array); -} - -static FILE *pfp; -static int slash; -static const char * const *dbp; - -int -cgetclose(void) -{ - if (pfp != NULL) { - (void)fclose(pfp); - pfp = NULL; - } - dbp = NULL; - gottoprec = 0; - slash = 0; - return 0; -} - -/* - * Cgetnext() gets either the first or next entry in the logical database - * specified by db_array. It returns 0 upon completion of the database, 1 - * upon returning an entry with more remaining, and -1 if an error occurs. - */ -/* coverity[+alloc : arg-*0] */ -int -cgetnext(char **bp, const char * const *db_array) -{ - size_t len = 0; - int status, done; - char *cp, *line, *rp, *np, buf[BSIZE], nbuf[BSIZE]; - size_t dummy; - - _DIAGASSERT(bp != NULL); - _DIAGASSERT(db_array != NULL); - - if (dbp == NULL) - dbp = db_array; - - if (pfp == NULL && (pfp = fopen(*dbp, "re")) == NULL) { - (void)cgetclose(); - return -1; - } - for (;;) { - if (toprec != NULL && !gottoprec) { - gottoprec = 1; - line = toprec; - } else { - line = fgetln(pfp, &len); - if (line == NULL) { - if (pfp == NULL) - return -1; - if (ferror(pfp)) { - (void)cgetclose(); - return -1; - } else { - (void)fclose(pfp); - pfp = NULL; - if (*++dbp == NULL) { - (void)cgetclose(); - return 0; - } else if ((pfp = - fopen(*dbp, "re")) == NULL) { - (void)cgetclose(); - return -1; - } else - continue; - } - } else - line[len - 1] = '\0'; - if (len == 1) { - slash = 0; - continue; - } - if (isspace((unsigned char)*line) || - *line == ':' || *line == '#' || slash) { - if (line[len - 2] == '\\') - slash = 1; - else - slash = 0; - continue; - } - if (line[len - 2] == '\\') - slash = 1; - else - slash = 0; - } - - - /* - * Line points to a name line. - */ - if (len > sizeof(nbuf)) - return -1; - done = 0; - np = nbuf; - for (;;) { - for (cp = line; *cp != '\0'; cp++) { - if (*cp == ':') { - *np++ = ':'; - done = 1; - break; - } - if (*cp == '\\') - break; - *np++ = *cp; - } - if (done) { - *np = '\0'; - break; - } else { /* name field extends beyond the line */ - line = fgetln(pfp, &len); - if (line == NULL && pfp) { - if (ferror(pfp)) { - (void)cgetclose(); - return -1; - } - (void)fclose(pfp); - pfp = NULL; - *np = '\0'; - break; - } else - line[len - 1] = '\0'; - } - } - if (len > sizeof(buf)) - return -1; - rp = buf; - for (cp = nbuf; *cp != '\0'; cp++) - if (*cp == '|' || *cp == ':') - break; - else - *rp++ = *cp; - - *rp = '\0'; - /* - * XXX - * Last argument of getent here should be nbuf if we want true - * sequential access in the case of duplicates. - * With NULL, getent will return the first entry found - * rather than the duplicate entry record. This is a - * matter of semantics that should be resolved. - */ - status = getent(bp, &dummy, db_array, -1, buf, 0, NULL); - if (status == -2 || status == -3) - (void)cgetclose(); - - return status + 1; - } - /* NOTREACHED */ -} - -/* - * Cgetstr retrieves the value of the string capability cap from the - * capability record pointed to by buf. A pointer to a decoded, NUL - * terminated, malloc'd copy of the string is returned in the char * - * pointed to by str. The length of the string not including the trailing - * NUL is returned on success, -1 if the requested string capability - * couldn't be found, -2 if a system error was encountered (storage - * allocation failure). - */ -int -cgetstr(char *buf, const char *cap, char **str) -{ - u_int m_room; - const char *bp; - char *mp; - ptrdiff_t len; - char *mem, *newmem; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(cap != NULL); - _DIAGASSERT(str != NULL); - - /* - * Find string capability cap - */ - bp = cgetcap(buf, cap, '='); - if (bp == NULL) - return -1; - - /* - * Conversion / storage allocation loop ... Allocate memory in - * chunks SFRAG in size. - */ - if ((mem = malloc(SFRAG)) == NULL) { - errno = ENOMEM; - return -2; /* couldn't even allocate the first fragment */ - } - m_room = SFRAG; - mp = mem; - - while (*bp != ':' && *bp != '\0') { - /* - * Loop invariants: - * There is always room for one more character in mem. - * Mp always points just past last character in mem. - * Bp always points at next character in buf. - */ - if (*bp == '^') { - bp++; - if (*bp == ':' || *bp == '\0') - break; /* drop unfinished escape */ - *mp++ = *bp++ & 037; - } else if (*bp == '\\') { - bp++; - if (*bp == ':' || *bp == '\0') - break; /* drop unfinished escape */ - if ('0' <= *bp && *bp <= '7') { - int n, i; - - n = 0; - i = 3; /* maximum of three octal digits */ - do { - n = n * 8 + (*bp++ - '0'); - } while (--i && '0' <= *bp && *bp <= '7'); - *mp++ = n; - } - else switch (*bp++) { - case 'b': case 'B': - *mp++ = '\b'; - break; - case 't': case 'T': - *mp++ = '\t'; - break; - case 'n': case 'N': - *mp++ = '\n'; - break; - case 'f': case 'F': - *mp++ = '\f'; - break; - case 'r': case 'R': - *mp++ = '\r'; - break; - case 'e': case 'E': - *mp++ = ESC; - break; - case 'c': case 'C': - *mp++ = ':'; - break; - default: - /* - * Catches '\', '^', and - * everything else. - */ - *mp++ = *(bp-1); - break; - } - } else - *mp++ = *bp++; - m_room--; - - /* - * Enforce loop invariant: if no room left in current - * buffer, try to get some more. - */ - if (m_room == 0) { - size_t size = mp - mem; - - if ((newmem = realloc(mem, size + SFRAG)) == NULL) { - free(mem); - return -2; - } - mem = newmem; - m_room = SFRAG; - mp = mem + size; - } - } - *mp++ = '\0'; /* loop invariant let's us do this */ - m_room--; - len = mp - mem - 1; - - /* - * Give back any extra memory and return value and success. - */ - if (m_room != 0) { - if ((newmem = realloc(mem, (size_t)(mp - mem))) == NULL) { - free(mem); - return -2; - } - mem = newmem; - } - *str = mem; - _DIAGASSERT(__type_fit(int, len)); - return (int)len; -} - -/* - * Cgetustr retrieves the value of the string capability cap from the - * capability record pointed to by buf. The difference between cgetustr() - * and cgetstr() is that cgetustr does not decode escapes but rather treats - * all characters literally. A pointer to a NUL terminated malloc'd - * copy of the string is returned in the char pointed to by str. The - * length of the string not including the trailing NUL is returned on success, - * -1 if the requested string capability couldn't be found, -2 if a system - * error was encountered (storage allocation failure). - */ -int -cgetustr(char *buf, const char *cap, char **str) -{ - u_int m_room; - const char *bp; - char *mp; - size_t len; - char *mem, *newmem; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(cap != NULL); - _DIAGASSERT(str != NULL); - - /* - * Find string capability cap - */ - if ((bp = cgetcap(buf, cap, '=')) == NULL) - return -1; - - /* - * Conversion / storage allocation loop ... Allocate memory in - * chunks SFRAG in size. - */ - if ((mem = malloc(SFRAG)) == NULL) { - errno = ENOMEM; - return -2; /* couldn't even allocate the first fragment */ - } - m_room = SFRAG; - mp = mem; - - while (*bp != ':' && *bp != '\0') { - /* - * Loop invariants: - * There is always room for one more character in mem. - * Mp always points just past last character in mem. - * Bp always points at next character in buf. - */ - *mp++ = *bp++; - m_room--; - - /* - * Enforce loop invariant: if no room left in current - * buffer, try to get some more. - */ - if (m_room == 0) { - size_t size = mp - mem; - - if ((newmem = realloc(mem, size + SFRAG)) == NULL) { - free(mem); - return -2; - } - mem = newmem; - m_room = SFRAG; - mp = mem + size; - } - } - *mp++ = '\0'; /* loop invariant let's us do this */ - m_room--; - len = mp - mem - 1; - - /* - * Give back any extra memory and return value and success. - */ - if (m_room != 0) { - if ((newmem = realloc(mem, (size_t)(mp - mem))) == NULL) { - free(mem); - return -2; - } - mem = newmem; - } - *str = mem; - _DIAGASSERT(__type_fit(int, len)); - return (int)len; -} - -/* - * Cgetnum retrieves the value of the numeric capability cap from the - * capability record pointed to by buf. The numeric value is returned in - * the long pointed to by num. 0 is returned on success, -1 if the requested - * numeric capability couldn't be found. - */ -int -cgetnum(char *buf, const char *cap, long *num) -{ - long n; - int base, digit; - const char *bp; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(cap != NULL); - _DIAGASSERT(num != NULL); - - /* - * Find numeric capability cap - */ - bp = cgetcap(buf, cap, '#'); - if (bp == NULL) - return -1; - - /* - * Look at value and determine numeric base: - * 0x... or 0X... hexadecimal, - * else 0... octal, - * else decimal. - */ - if (*bp == '0') { - bp++; - if (*bp == 'x' || *bp == 'X') { - bp++; - base = 16; - } else - base = 8; - } else - base = 10; - - /* - * Conversion loop ... - */ - n = 0; - for (;;) { - if ('0' <= *bp && *bp <= '9') - digit = *bp - '0'; - else if ('a' <= *bp && *bp <= 'f') - digit = 10 + *bp - 'a'; - else if ('A' <= *bp && *bp <= 'F') - digit = 10 + *bp - 'A'; - else - break; - - if (digit >= base) - break; - - n = n * base + digit; - bp++; - } - - /* - * Return value and success. - */ - *num = n; - return 0; -} - - -/* - * Compare name field of record. - */ -static int -nfcmp(char *nf, char *rec) -{ - char *cp, tmp; - int ret; - - _DIAGASSERT(nf != NULL); - _DIAGASSERT(rec != NULL); - - for (cp = rec; *cp != ':'; cp++) - continue; - - tmp = *(cp + 1); - *(cp + 1) = '\0'; - ret = strcmp(nf, rec); - *(cp + 1) = tmp; - - return ret; -} diff --git a/lib/libc/gen/getcwd.3 b/lib/libc/gen/getcwd.3 deleted file mode 100644 index 712d5a94a..000000000 --- a/lib/libc/gen/getcwd.3 +++ /dev/null @@ -1,172 +0,0 @@ -.\" $NetBSD: getcwd.3,v 1.18 2010/04/29 06:54:26 jruoho Exp $ -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getcwd.3 8.2 (Berkeley) 12/11/93 -.\" -.Dd April 29, 2010 -.Dt GETCWD 3 -.Os -.Sh NAME -.Nm getcwd , -.Nm getwd -.Nd get working directory pathname -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft char * -.Fn getcwd "char *buf" "size_t size" -.Ft char * -.Fn getwd "char *buf" -.Sh DESCRIPTION -The -.Fn getcwd -function copies the absolute pathname of the current working directory -into the memory referenced by -.Fa buf -and returns a pointer to -.Fa buf . -The -.Fa size -argument is the size, in bytes, of the array referenced by -.Fa buf . -.Pp -If -.Fa buf -is -.Dv NULL , -space is allocated as necessary to store the pathname. -This space may later be -.Xr free 3 Ns 'd . -.Pp -The function -.Fn getwd -is a compatibility routine which calls -.Fn getcwd -with its -.Fa buf -argument and a size of -.Dv MAXPATHLEN -(as defined in the include -file -.In sys/param.h ) . -Obviously, -.Fa buf -should be at least -.Dv MAXPATHLEN -bytes in length. -.Pp -These routines have traditionally been used by programs to save the -name of a working directory for the purpose of returning to it. -A much faster and less error-prone method of accomplishing this is to -open the current directory -.Pq Ql \&. -and use the -.Xr fchdir 2 -function to return. -.Sh RETURN VALUES -Upon successful completion, a pointer to the pathname is returned. -Otherwise a -.Dv NULL -pointer is returned and the global variable -.Va errno -is set to indicate the error. -In addition, -.Fn getwd -copies the error message associated with -.Va errno -into the memory referenced by -.Fa buf . -.Sh ERRORS -The -.Fn getcwd -function -will fail if: -.Bl -tag -width Er -.It Bq Er EACCES -Read or search permission was denied for a component of the pathname. -.It Bq Er EINVAL -The -.Fa size -argument is zero. -.It Bq Er ENOENT -A component of the pathname no longer exists. -.It Bq Er ENOMEM -Insufficient memory is available. -.It Bq Er ERANGE -The -.Fa size -argument is greater than zero but smaller than the length of the pathname -plus 1. -.El -.Sh SEE ALSO -.Xr chdir 2 , -.Xr fchdir 2 , -.Xr malloc 3 , -.Xr strerror 3 -.Sh STANDARDS -The -.Fn getwd -and -.Fn getcwd -functions conform to -.St -p1003.1-90 . -The -.St -p1003.1-2004 -revision marked -.Fn getwd -as legacy and recommended the use of -.Fn getcwd -instead. -The -.St -p1003.1-2008 -revision removed -.Fn getwd -from the specification. -.Pp -The ability to specify a -.Dv NULL -pointer and have -.Fn getcwd -allocate memory as necessary is an extension. -.Sh HISTORY -The -.Fn getwd -function appeared in -.Bx 4.0 . -.Sh SECURITY CONSIDERATIONS -As -.Fn getwd -does not know the length of the supplied buffer, it is possible -for a long (but valid) path to overflow the buffer and provide -a means for an attacker to exploit the caller. -.Fn getcwd -should be used in place of -.Fn getwd -(the latter is only provided for compatibility purposes). diff --git a/lib/libc/gen/getcwd.c b/lib/libc/gen/getcwd.c deleted file mode 100644 index a0763a6e0..000000000 --- a/lib/libc/gen/getcwd.c +++ /dev/null @@ -1,253 +0,0 @@ -/* $NetBSD: getcwd.c,v 1.53 2012/06/21 23:29:23 enami Exp $ */ - -/* - * Copyright (c) 1989, 1991, 1993, 1995 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Jan-Simon Pendry. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getcwd.c 8.5 (Berkeley) 2/7/95"; -#else -__RCSID("$NetBSD: getcwd.c,v 1.53 2012/06/21 23:29:23 enami Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "extern.h" - -#ifdef __weak_alias -__weak_alias(getcwd,_getcwd) -__weak_alias(_sys_getcwd,_getcwd) -__weak_alias(realpath,_realpath) -#endif - -/* - * char *realpath(const char *path, char *resolved); - * - * Find the real name of path, by removing all ".", ".." and symlink - * components. Returns (resolved) on success, or (NULL) on failure, - * in which case the path which caused trouble is left in (resolved). - */ -char * -realpath(const char * __restrict path, char * __restrict resolved) -{ - struct stat sb; - int idx = 0, nlnk = 0; - const char *q; - char *p, wbuf[2][MAXPATHLEN], *fres; - size_t len; - ssize_t n; - - /* POSIX sez we must test for this */ - if (path == NULL) { - errno = EINVAL; - return NULL; - } - - if (resolved == NULL) { - fres = resolved = malloc(MAXPATHLEN); - if (resolved == NULL) - return NULL; - } else - fres = NULL; - - - /* - * Build real path one by one with paying an attention to ., - * .. and symbolic link. - */ - - /* - * `p' is where we'll put a new component with prepending - * a delimiter. - */ - p = resolved; - - if (*path == '\0') { - *p = '\0'; - errno = ENOENT; - goto out; - } - - /* If relative path, start from current working directory. */ - if (*path != '/') { - /* check for resolved pointer to appease coverity */ - if (resolved && getcwd(resolved, MAXPATHLEN) == NULL) { - p[0] = '.'; - p[1] = '\0'; - goto out; - } - len = strlen(resolved); - if (len > 1) - p += len; - } - -loop: - /* Skip any slash. */ - while (*path == '/') - path++; - - if (*path == '\0') { - if (p == resolved) - *p++ = '/'; - *p = '\0'; - return resolved; - } - - /* Find the end of this component. */ - q = path; - do - q++; - while (*q != '/' && *q != '\0'); - - /* Test . or .. */ - if (path[0] == '.') { - if (q - path == 1) { - path = q; - goto loop; - } - if (path[1] == '.' && q - path == 2) { - /* Trim the last component. */ - if (p != resolved) - while (*--p != '/') - continue; - path = q; - goto loop; - } - } - - /* Append this component. */ - if (p - resolved + 1 + q - path + 1 > MAXPATHLEN) { - errno = ENAMETOOLONG; - if (p == resolved) - *p++ = '/'; - *p = '\0'; - goto out; - } - p[0] = '/'; - memcpy(&p[1], path, - /* LINTED We know q > path. */ - q - path); - p[1 + q - path] = '\0'; - - /* - * If this component is a symlink, toss it and prepend link - * target to unresolved path. - */ - if (lstat(resolved, &sb) == -1) - goto out; - - if (S_ISLNK(sb.st_mode)) { - if (nlnk++ >= MAXSYMLINKS) { - errno = ELOOP; - goto out; - } - n = readlink(resolved, wbuf[idx], sizeof(wbuf[0]) - 1); - if (n < 0) - goto out; - if (n == 0) { - errno = ENOENT; - goto out; - } - - /* Append unresolved path to link target and switch to it. */ - if (n + (len = strlen(q)) + 1 > sizeof(wbuf[0])) { - errno = ENAMETOOLONG; - goto out; - } - memcpy(&wbuf[idx][n], q, len + 1); - path = wbuf[idx]; - idx ^= 1; - - /* If absolute symlink, start from root. */ - if (*path == '/') - p = resolved; - goto loop; - } - if (*q == '/' && !S_ISDIR(sb.st_mode)) { - errno = ENOTDIR; - goto out; - } - - /* Advance both resolved and unresolved path. */ - p += 1 + q - path; - path = q; - goto loop; -out: - free(fres); - return NULL; -} - -char * -__ssp_real(getcwd)(char *pt, size_t size) -{ - char *npt; - - /* - * If a buffer is specified, the size has to be non-zero. - */ - if (pt != NULL) { - if (size == 0) { - /* __getcwd(pt, 0) results ERANGE. */ - errno = EINVAL; - return (NULL); - } - if (__getcwd(pt, size) >= 0) - return (pt); - return (NULL); - } - - /* - * If no buffer specified by the user, allocate one as necessary. - */ - size = 1024 >> 1; - do { - if ((npt = realloc(pt, size <<= 1)) == NULL) - break; - pt = npt; - if (__getcwd(pt, size) >= 0) - return (pt); - } while (size <= MAXPATHLEN * 4 && errno == ERANGE); - - free(pt); - return (NULL); -} diff --git a/lib/libc/gen/getdevmajor.3 b/lib/libc/gen/getdevmajor.3 deleted file mode 100644 index 97db9b0e5..000000000 --- a/lib/libc/gen/getdevmajor.3 +++ /dev/null @@ -1,118 +0,0 @@ -.\" $NetBSD: getdevmajor.3,v 1.5 2009/03/24 22:34:54 drochner Exp $ -.\" -.\" Copyright (c) 2004 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Andrew Brown. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd January 20, 2009 -.Dt GETDEVMAJOR 3 -.Os -.Sh NAME -.Nm getdevmajor -.Nd get block or character device major number -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.In sys/stat.h -.Ft devmajor_t -.Fn getdevmajor "const char *name" "mode_t type" -.Sh DESCRIPTION -The -.Fn getdevmajor -function returns the major device number of the block or character -device specified by -.Ar name -and a file type matching the one encoded in -.Fa type -which must be one of -.Dv S_IFBLK -or -.Dv S_IFCHR . -.Sh RETURN VALUES -If no device matches the specified values, no information is -available, or an error occurs, -.Dv NODEVMAJOR -is returned and -.Va errno -is set to indicate the error. -.Sh EXAMPLES -To retrieve the major number for -.Xr pty 4 -slave devices (aka pts devices): -.Bd -literal -offset indent -#include \*[Lt]stdlib.h\*[Gt] -#include \*[Lt]sys/stat.h\*[Gt] -.sp -devmajor_t pts; -pts = getdevmajor("pts", S_IFCHR); -.Ed -.Pp -To retrieve the major numbers for the block and character -.Xr wd 4 -devices: -.Bd -literal -offset indent -#include \*[Lt]stdlib.h\*[Gt] -#include \*[Lt]sys/stat.h\*[Gt] -.sp -devmajor_t c, b; -c = getdevmajor("wd", S_IFCHR); -b = getdevmajor("wd", S_IFBLK); -.Ed -.Sh ERRORS -The -.Fn getdevmajor -function may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr malloc 3 -and -.Xr sysctlbyname 3 . -In addition, the following errors may be reported: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of the -.Fa type -argument is not -.Dv S_IFCHR -or -.Dv S_IFBLK . -.It Bq Er ENOENT -The named device is not found. -.El -.Sh SEE ALSO -.Xr stat 2 , -.Xr devname 3 , -.Xr malloc 3 , -.Xr sysctlbyname 3 -.Sh HISTORY -The -.Fn getdevmajor -function call appeared in -.Nx 3.0 . diff --git a/lib/libc/gen/getdevmajor.c b/lib/libc/gen/getdevmajor.c deleted file mode 100644 index 95cb7ca00..000000000 --- a/lib/libc/gen/getdevmajor.c +++ /dev/null @@ -1,110 +0,0 @@ -/* $NetBSD: getdevmajor.c,v 1.6 2012/03/13 21:13:35 christos Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Brown. - * - * 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 NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getdevmajor.c,v 1.6 2012/03/13 21:13:35 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getdevmajor,_getdevmajor) -#endif - -/* - * XXX temporary alias because getdevmajor() was renamed - * in -current for some time - */ -dev_t __getdevmajor50(const char *, mode_t); -dev_t -__getdevmajor50(const char *name, mode_t type) -{ - - return (dev_t)getdevmajor(name, type); -} - -devmajor_t -getdevmajor(const char *name, mode_t type) -{ - struct kinfo_drivers kd[200], *kdp = &kd[0]; - size_t i, sz = sizeof(kd); - int rc; - devmajor_t n = NODEVMAJOR; - - if (type != S_IFCHR && type != S_IFBLK) { - errno = EINVAL; - return n; - } - - do { - rc = sysctlbyname("kern.drivers", kdp, &sz, NULL, 0); - if (rc == -1) { - if (errno != ENOMEM) - goto out; - if (kdp != &kd[0]) - free(kdp); - if ((kdp = malloc(sz)) == NULL) - return n; - } - } while (rc == -1); - - sz /= sizeof(*kdp); - - for (i = 0; i < sz; i++) { - if (strcmp(name, kdp[i].d_name) == 0) { - if (type == S_IFCHR) - n = kdp[i].d_cmajor; - else - n = kdp[i].d_bmajor; - break; - } - } - if (i >= sz) - errno = ENOENT; - - out: - if (kdp != &kd[0]) - free(kdp); - - return n; -} diff --git a/lib/libc/gen/getdiskbyname.3 b/lib/libc/gen/getdiskbyname.3 deleted file mode 100644 index 93c01e428..000000000 --- a/lib/libc/gen/getdiskbyname.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" $NetBSD: getdiskbyname.3,v 1.13 2009/08/19 15:47:39 joerg Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)getdiskbyname.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt GETDISKBYNAME 3 -.Os -.Sh NAME -.Nm getdiskbyname , -.Nm setdisktab -.Nd get generic disk description by its name -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/disklabel.h -.In disktab.h -.Ft int -.Fn setdisktab "char *name" -.Ft struct disklabel * -.Fn getdiskbyname "const char *name" -.Sh DESCRIPTION -The -.Fn getdiskbyname -function -takes a disk name (e.g. -.Ql rm03 ) -and returns a prototype disk label -describing its geometry information and the standard -disk partition tables. -All information is obtained from the -.Xr disktab 5 -file. -.Pp -The -.Fn setdisktab -function changes the default -.Sy disktab -file name from -.Pa /etc/disktab -.Pq aka Dv _PATH_DISKTAB -to -.Fa name . -.Sh RETURN VALUES -.Fn getdiskbyname -returns a null pointer if the entry is not found in the current -.Pa disktab -file. -.Pp -.Fn setdisktab -returns 0 on success and \-1 if -.Fa name -is a null pointer or points to an empty string. -.Sh FILES -.Bl -tag -width /etc/disktab -compact -.It Pa /etc/disktab -the default database of disk types. -.El -.Sh SEE ALSO -.Xr disklabel 5 , -.Xr disktab 5 , -.Xr disklabel 8 -.Sh HISTORY -The -.Fn getdiskbyname -function appeared in -.Bx 4.3 . -.Pp -The -.Fn setdisktab -function appeared in -.Nx 1.4 . -.Sh BUGS -The -.Fn getdiskbyname -function leaves its results in an internal static object and returns a -pointer to that object. -Subsequent calls will modify the same object. diff --git a/lib/libc/gen/getdomainname.3 b/lib/libc/gen/getdomainname.3 deleted file mode 100644 index 44f6244f3..000000000 --- a/lib/libc/gen/getdomainname.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" $NetBSD: getdomainname.3,v 1.16 2015/02/06 17:35:46 ginsbach Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd May 6, 1994 -.Dt GETDOMAINNAME 3 -.Os -.Sh NAME -.Nm getdomainname , -.Nm setdomainname -.Nd get/set domain name of current host -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn getdomainname "char *name" "size_t namelen" -.Ft int -.Fn setdomainname "const char *name" "size_t namelen" -.Sh DESCRIPTION -.Fn getdomainname -returns the standard domain name for the current host, as -previously set by -.Fn setdomainname . -The parameter -.Fa namelen -specifies the size of the -.Fa name -array. -The returned name is null-terminated unless insufficient -space is provided. -.Pp -.Fn setdomainname -sets the domain name of the host machine to be -.Fa name , -which has length -.Fa namelen . -This call is restricted to the super-user and -is normally used only when the system is bootstrapped. -.Sh RETURN VALUES -If the call succeeds a value of 0 is returned. -If the call fails, a value of \-1 is returned and an error code is -placed in the global location -.Va errno . -.Sh ERRORS -The following errors may be returned by these calls: -.Bl -tag -width Er -.It Bq Er EFAULT -The -.Fa name -or -.Fa namelen -parameter gave an -invalid address. -.It Bq Er EPERM -The caller tried to set the domain name and was not the super-user. -.El -.Sh SEE ALSO -.Xr gethostid 3 , -.Xr gethostname 3 , -.Xr sysctl 3 -.Sh HISTORY -The -.Nm -function call appeared in -.Bx 4.2 . -.Sh BUGS -Domain names are limited to -.Dv MAXHOSTNAMELEN -(from -.Ao Pa sys/param.h Ac ) -characters including null-termination, currently 256. diff --git a/lib/libc/gen/getdomainname.c b/lib/libc/gen/getdomainname.c deleted file mode 100644 index cd58c7788..000000000 --- a/lib/libc/gen/getdomainname.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: getdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getdomainname,_getdomainname) -#endif - -int -getdomainname(char *name, size_t namelen) -{ - int mib[2]; - size_t size; - int olderrno; - - _DIAGASSERT(name != NULL); - - mib[0] = CTL_KERN; - mib[1] = KERN_DOMAINNAME; - size = namelen; - olderrno = errno; - if (sysctl(mib, 2, name, &size, NULL, 0) == -1) { - if (errno == ENOMEM) { - errno = olderrno; - return (0); - } - return (-1); - } - - return (0); -} diff --git a/lib/libc/gen/getfsent.3 b/lib/libc/gen/getfsent.3 deleted file mode 100644 index abfecfefd..000000000 --- a/lib/libc/gen/getfsent.3 +++ /dev/null @@ -1,149 +0,0 @@ -.\" $NetBSD: getfsent.3,v 1.12 2012/04/07 03:47:30 christos Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)getfsent.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd March 6, 2012 -.Dt GETFSENT 3 -.Os -.Sh NAME -.Nm getfsent , -.Nm getfsspec , -.Nm getfsfile , -.Nm setfsent , -.Nm endfsent -.Nd get file system descriptor file entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In fstab.h -.Ft struct fstab * -.Fn getfsent void -.Ft struct fstab * -.Fn getfsspec "const char *spec" -.Ft struct fstab * -.Fn getfsfile "const char *file" -.Ft int -.Fn setfsent void -.Ft void -.Fn endfsent void -.Sh DESCRIPTION -The -.Fn getfsent , -.Fn getfsspec , -and -.Fn getfsfile -functions -each return a pointer to an object with the following structure -containing the broken-out fields of a line in the file system -description file, -.In fstab.h . -.Bd -literal -offset indent -struct fstab { - char *fs_spec; /* block special device name */ - char *fs_file; /* file system path prefix */ - char *fs_vfstype; /* type of file system */ - char *fs_mntops; /* comma separated mount options */ - char *fs_type; /* rw, ro, sw, or xx */ - int fs_freq; /* dump frequency, in days */ - int fs_passno; /* pass number on parallel dump */ -}; -.Ed -.Pp -The fields have meanings described in -.Xr fstab 5 . -.Pp -The -.Fn setfsent -function -opens the file (closing any previously opened file) or rewinds it -if it is already open. -.Pp -The -.Fn endfsent -function -closes the file. -.Pp -The -.Fn getfsspec -and -.Fn getfsfile -functions -search the entire file (opening it if necessary) for a matching special -file name or file system file name. -.Pp -For programs wishing to read the entire database, -.Fn getfsent -reads the next entry (opening the file if necessary). -.Pp -All entries in the file with a type field equivalent to -.Dv FSTAB_XX -are ignored. -.Sh RETURN VALUES -The -.Fn getfsent , -.Fn getfsspec , -and -.Fn getfsfile -functions -return a null pointer (0) on -.Dv EOF -or error. -The -.Fn setfsent -function -returns 0 on failure, 1 on success. -The -.Fn endfsent -function -returns nothing. -.Sh FILES -.Bl -tag -width /etc/fstab -compact -.It Pa /etc/fstab -.El -.Sh SEE ALSO -.Xr getfsspecname 3 , -.Xr fstab 5 -.Sh HISTORY -The -.Fn getfsent -function appeared in -.Bx 4.0 ; -the -.Fn endfsent , -.Fn getfsfile , -.Fn getfsspec , -and -.Fn setfsent -functions appeared in -.Bx 4.3 . -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. diff --git a/lib/libc/gen/getgrent.3 b/lib/libc/gen/getgrent.3 deleted file mode 100644 index 9e89befe2..000000000 --- a/lib/libc/gen/getgrent.3 +++ /dev/null @@ -1,344 +0,0 @@ -.\" $NetBSD: getgrent.3,v 1.31 2011/04/28 16:34:01 wiz Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getgrent.3 8.2 (Berkeley) 4/19/94 -.\" -.Dd April 30, 2008 -.Dt GETGRENT 3 -.Os -.Sh NAME -.Nm getgrent , -.Nm getgrent_r , -.Nm getgrgid , -.Nm getgrgid_r , -.Nm getgrnam , -.Nm getgrnam_r , -.Nm setgroupent , -.\" .Nm setgrfile , -.Nm setgrent , -.Nm endgrent -.Nd group database operations -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In grp.h -.Ft struct group * -.Fn getgrent void -.Ft int -.Fo getgrent_r -.Fa "struct group *grp" -.Fa "char *buffer" -.Fa "size_t buflen" -.Fa "struct group **result" -.Fc -.Ft struct group * -.Fn getgrgid "gid_t gid" -.Ft int -.Fo getgrgid_r -.Fa "gid_t gid" -.Fa "struct group *grp" -.Fa "char *buffer" -.Fa "size_t buflen" -.Fa "struct group **result" -.Fc -.Ft struct group * -.Fn getgrnam "const char *name" -.Ft int -.Fo getgrnam_r -.Fa "const char *name" -.Fa "struct group *grp" -.Fa "char *buffer" -.Fa "size_t buflen" -.Fa "struct group **result" -.Fc -.Ft int -.Fn setgroupent "int stayopen" -.\" .Ft void -.\" .Fn setgrfile "const char *name" -.Ft void -.Fn setgrent void -.Ft void -.Fn endgrent void -.Sh DESCRIPTION -These functions operate on the group database which is described in -.Xr group 5 . -Each line of the database is defined by the structure -.Ar group -found in the include -file -.In grp.h : -.Bd -literal -offset indent -struct group { - char *gr_name; /* group name */ - char *gr_passwd; /* group password */ - gid_t gr_gid; /* group id */ - char **gr_mem; /* group members */ -}; -.Ed -.Pp -The functions -.Fn getgrnam -and -.Fn getgrgid -search the group database for the given group name pointed to by -.Ar name -or the group id pointed to by -.Ar gid , -respectively, returning the first one encountered. -Identical group names or group ids may result in undefined behavior. -.Pp -The -.Fn getgrent -function sequentially reads the group database and is intended for programs -that wish to step through the complete list of groups. -.Pp -All three functions will open the group file for reading, if necessary. -.Pp -The functions -.Fn getgrnam_r , -.Fn getgrgid_r , -and -.Fn getgrent_r -act like their non re-entrant counterparts -respectively, updating the contents of -.Ar grp -and storing a pointer to that in -.Ar result , -and returning -.Dv 0 . -Storage used by -.Ar grp -is allocated from -.Ar buffer , -which is -.Ar buflen -bytes in size. -If the requested entry cannot be found, -.Ar result -will point to -.Dv NULL -and -.Dv 0 -will be returned. -If an error occurs, -a non-zero error number will be returned and -.Ar result -will point to -.Dv NULL . -Calling -.Fn getgrent_r -from multiple threads will result in each thread reading a disjoint portion -of the group database. -.Pp -The -.Fn setgroupent -function opens the file, or rewinds it if it is already open. -If -.Fa stayopen -is non-zero, file descriptors are left open, significantly speeding -functions subsequent calls. -This functionality is unnecessary for -.Fn getgrent -as it doesn't close its file descriptors by default. -It should also be noted that it is dangerous for long-running -programs to use this functionality as the group file may be updated. -.Pp -The -.Fn setgrent -function is equivalent to -.Fn setgroupent -with an argument of zero. -.Pp -The -.Fn endgrent -function closes any open files. -.Sh RETURN VALUES -The functions -.Fn getgrgid , -.Fn getgrnam , -and -.Fn getgrent -return a valid pointer to a group structure on success -and a -.Dv NULL -pointer if the entry was not found or an error occured. -If an error occured, the global variable -.Dv errno -is set to indicate the nature of the failure. -.Pp -The functions -.Fn getgrgid_r , -.Fn getgrnam_r , -and -.Fn getgrent_r -return -.Dv 0 -on success or entry not found, and non-zero on failure, setting the global -variable -.Dv errno -to indicate the nature of the failure. -.Pp -The -.Fn setgroupent -function returns the value 1 if successful, otherwise the value -0 is returned, setting the global variable -.Dv errno -to indicate the nature of the failure. -.Pp -The -.Fn endgrent -and -.Fn setgrent -functions have no return value. -.Sh FILES -.Bl -tag -width /etc/group -compact -.It Pa /etc/group -group database file -.El -.Sh COMPATIBILITY -The historic function -.Fn setgrfile , -which allowed the specification of alternative group databases, has -been deprecated and is no longer available. -.Sh ERRORS -The following error codes may be set in -.Va errno -for -.Nm getgrent , -.Nm getgrent_r , -.Nm getgrnam , -.Nm getgrnam_r , -.Nm getgrgid , -.Nm getgrgid_r , -and -.Nm setgroupent : -.Bl -tag -width Er -.It Bq Er EINTR -A signal was caught during the database search. -.It Bq Er EIO -An I/O error has occurred. -.It Bq Er EMFILE -The limit on open files for this process has been reached. -.It Bq Er ENFILE -The system limit on open files has been reached. -.El -.Pp -The following error code may be set in -.Va errno -for -.Nm getgrent_r , -.Nm getgrnam_r , -and -.Nm getgrgid_r : -.Bl -tag -width Er -.It Bq Er ERANGE -The resulting -.Ft struct group -does not fit in the space defined by -.Dv buffer -and -.Dv buflen -.El -.Pp -Other -.Dv errno -values may be set depending on the specific database backends. -.Sh SEE ALSO -.Xr getpwent 3 , -.Xr group 5 , -.Xr nsswitch.conf 5 -.Sh STANDARDS -The -.Fn getgrgid -and -.Fn getgrnam -functions conform to -.St -p1003.1-90 . -The -.Fn getgrgid_r -and -.Fn getgrnam_r -functions conform to -.St -p1003.1c-95 . -The -.Fn endgrent , -.Fn getgrent , -and -.Fn setgrent -functions conform to -.St -xpg4.2 -and -.St -p1003.1-2004 -(XSI extension). -.Sh HISTORY -The functions -.Fn endgrent , -.Fn getgrent , -.Fn getgrgid , -.Fn getgrnam , -and -.Fn setgrent -appeared in -.At v7 . -The functions -.Fn setgrfile -and -.Fn setgroupent -appeared in -.Bx 4.3 Reno . -The functions -.Fn getgrgid_r -and -.Fn getgrnam_r -appeared in -.Nx 3.0 . -.Sh BUGS -The functions -.Fn getgrent , -.Fn getgrgid , -.Fn getgrnam , -.Fn setgroupent -and -.Fn setgrent -leave their results in an internal static object and return -a pointer to that object. -Subsequent calls to the same function will modify the same object. -.Pp -The functions -.Fn getgrent , -.Fn endgrent , -.Fn setgroupent , -and -.Fn setgrent -are fairly useless in a networked environment and should be -avoided, if possible. -.Fn getgrent -makes no attempt to suppress duplicate information if multiple -sources are specified in -.Xr nsswitch.conf 5 diff --git a/lib/libc/gen/getgrent.c b/lib/libc/gen/getgrent.c deleted file mode 100644 index 783446528..000000000 --- a/lib/libc/gen/getgrent.c +++ /dev/null @@ -1,1954 +0,0 @@ -/* $NetBSD: getgrent.c,v 1.67 2012/08/29 18:50:35 dholland Exp $ */ - -/*- - * Copyright (c) 1999-2000, 2004-2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Portions Copyright (c) 1994, Jason Downs. All Rights Reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getgrent.c 8.2 (Berkeley) 3/21/94"; -#else -__RCSID("$NetBSD: getgrent.c,v 1.67 2012/08/29 18:50:35 dholland Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HESIOD -#include -#endif - -#ifdef YP -#include -#include -#include -#endif - -#include "gr_private.h" - -#ifdef __weak_alias -__weak_alias(endgrent,_endgrent) -__weak_alias(getgrent,_getgrent) -__weak_alias(getgrent_r,_getgrent_r) -__weak_alias(getgrgid,_getgrgid) -__weak_alias(getgrgid_r,_getgrgid_r) -__weak_alias(getgrnam,_getgrnam) -__weak_alias(getgrnam_r,_getgrnam_r) -__weak_alias(setgrent,_setgrent) -__weak_alias(setgroupent,_setgroupent) -#endif - -#ifdef _REENTRANT -mutex_t __grmutex = MUTEX_INITIALIZER; -#endif - -/* - * _gr_memfrombuf - * Obtain want bytes from buffer (of size buflen) and return a pointer - * to the available memory after adjusting buffer/buflen. - * Returns NULL if there is insufficient space. - */ -static char * -_gr_memfrombuf(size_t want, char **buffer, size_t *buflen) -{ - char *rv; - - if (want > *buflen) { - errno = ERANGE; - return NULL; - } - rv = *buffer; - *buffer += want; - *buflen -= want; - return rv; -} - -/* - * _gr_parse - * Parses entry as a line per group(5) (without the trailing \n) - * and fills in grp with corresponding values; memory for strings - * and arrays will be allocated from buf (of size buflen). - * Returns 1 if parsed successfully, 0 on parse failure. - */ -static int -_gr_parse(const char *entry, struct group *grp, char *buf, size_t buflen) -{ - unsigned long id; - const char *bp; - char *ep; - size_t count; - int memc; - - _DIAGASSERT(entry != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buf != NULL); - -#define COPYTOBUF(to) \ - do { \ - (to) = _gr_memfrombuf(count+1, &buf, &buflen); \ - if ((to) == NULL) \ - return 0; \ - memmove((to), entry, count); \ - to[count] = '\0'; \ - } while (0) /* LINTED */ - -#if 0 - if (*entry == '+') /* fail on compat `+' token */ - return 0; -#endif - - count = strcspn(entry, ":"); /* parse gr_name */ - if (entry[count] == '\0') - return 0; - COPYTOBUF(grp->gr_name); - entry += count + 1; - - count = strcspn(entry, ":"); /* parse gr_passwd */ - if (entry[count] == '\0') - return 0; - COPYTOBUF(grp->gr_passwd); - entry += count + 1; - - count = strcspn(entry, ":"); /* parse gr_gid */ - if (entry[count] == '\0') - return 0; - id = strtoul(entry, &ep, 10); - if (id > GID_MAX || *ep != ':') - return 0; - grp->gr_gid = (gid_t)id; - entry += count + 1; - - memc = 1; /* for final NULL */ - if (*entry != '\0') - memc++; /* for first item */ - for (bp = entry; *bp != '\0'; bp++) { - if (*bp == ',') - memc++; - } - /* grab ALIGNed char **gr_mem from buf */ - ep = _gr_memfrombuf(memc * sizeof(char *) + ALIGNBYTES, &buf, &buflen); - if (ep == NULL) - return 0; - grp->gr_mem = (char **)ALIGN(ep); - - for (memc = 0; *entry != '\0'; memc++) { - count = strcspn(entry, ","); /* parse member */ - COPYTOBUF(grp->gr_mem[memc]); - entry += count; - if (*entry == ',') - entry++; - } - -#undef COPYTOBUF - - grp->gr_mem[memc] = NULL; - return 1; -} - -/* - * _gr_copy - * Copy the contents of fromgrp to grp; memory for strings - * and arrays will be allocated from buf (of size buflen). - * Returns 1 if copied successfully, 0 on copy failure. - * NOTE: fromgrp must not use buf for its own pointers. - */ -static int -_gr_copy(struct group *fromgrp, struct group *grp, char *buf, size_t buflen) -{ - char *ep; - int memc; - - _DIAGASSERT(fromgrp != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buf != NULL); - -#define COPYSTR(to, from) \ - do { \ - size_t count = strlen((from)); \ - (to) = _gr_memfrombuf(count+1, &buf, &buflen); \ - if ((to) == NULL) \ - return 0; \ - memmove((to), (from), count); \ - to[count] = '\0'; \ - } while (0) /* LINTED */ - - COPYSTR(grp->gr_name, fromgrp->gr_name); - COPYSTR(grp->gr_passwd, fromgrp->gr_passwd); - grp->gr_gid = fromgrp->gr_gid; - - if (fromgrp->gr_mem == NULL) - return 0; - - for (memc = 0; fromgrp->gr_mem[memc]; memc++) - continue; - memc++; /* for final NULL */ - - /* grab ALIGNed char **gr_mem from buf */ - ep = _gr_memfrombuf(memc * sizeof(char *) + ALIGNBYTES, &buf, &buflen); - grp->gr_mem = (char **)ALIGN(ep); - if (grp->gr_mem == NULL) - return 0; - - for (memc = 0; fromgrp->gr_mem[memc]; memc++) { - COPYSTR(grp->gr_mem[memc], fromgrp->gr_mem[memc]); - } - -#undef COPYSTR - - grp->gr_mem[memc] = NULL; - return 1; -} - - /* - * files methods - */ - -int -__grstart_files(struct __grstate_files *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->fp == NULL) { - state->fp = fopen(_PATH_GROUP, "re"); - if (state->fp == NULL) - return NS_UNAVAIL; - } else { - rewind(state->fp); - } - return NS_SUCCESS; -} - -int -__grend_files(struct __grstate_files *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->fp) { - (void) fclose(state->fp); - state->fp = NULL; - } - return NS_SUCCESS; -} - -/* - * __grscan_files - * Scan state->fp for the next desired entry. - * If search is zero, return the next entry. - * If search is non-zero, look for a specific name (if name != NULL), - * or a specific gid (if name == NULL). - * Sets *retval to the errno if the result is not NS_SUCCESS - * or NS_NOTFOUND. - */ -int -__grscan_files(int *retval, struct group *grp, char *buffer, size_t buflen, - struct __grstate_files *state, int search, const char *name, gid_t gid) -{ - int rv; - char filebuf[_GETGR_R_SIZE_MAX], *ep; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - /* name is NULL to indicate searching for gid */ - - *retval = 0; - - if (state->fp == NULL) { /* only start if file not open yet */ - rv = __grstart_files(state); - if (rv != NS_SUCCESS) - goto filesgrscan_out; - } - - rv = NS_NOTFOUND; - - /* scan line by line */ - while (fgets(filebuf, (int)sizeof(filebuf), state->fp) != NULL) { - ep = strchr(filebuf, '\n'); - if (ep == NULL) { /* skip lines that are too big */ - int ch; - - while ((ch = getc(state->fp)) != '\n' && ch != EOF) - continue; - continue; - } - *ep = '\0'; /* clear trailing \n */ - - if (filebuf[0] == '+') /* skip compat line */ - continue; - - /* validate line */ - if (! _gr_parse(filebuf, grp, buffer, buflen)) { - continue; /* skip bad lines */ - } - if (! search) { /* just want this one */ - rv = NS_SUCCESS; - break; - } - /* want specific */ - if ((name && strcmp(name, grp->gr_name) == 0) || - (!name && gid == grp->gr_gid)) { - rv = NS_SUCCESS; - break; - } - } - - filesgrscan_out: - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - return rv; -} - - -static struct __grstate_files _files_state; - /* storage for non _r functions */ -static struct group _files_group; -static char _files_groupbuf[_GETGR_R_SIZE_MAX]; - -/*ARGSUSED*/ -static int -_files_setgrent(void *nsrv, void *nscb, va_list ap) -{ - - _files_state.stayopen = 0; - return __grstart_files(&_files_state); -} - -/*ARGSUSED*/ -static int -_files_setgroupent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - _files_state.stayopen = stayopen; - rv = __grstart_files(&_files_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_files_endgrent(void *nsrv, void *nscb, va_list ap) -{ - - _files_state.stayopen = 0; - return __grend_files(&_files_state); -} - -/*ARGSUSED*/ -static int -_files_getgrent(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grscan_files(&rerror, &_files_group, - _files_groupbuf, sizeof(_files_groupbuf), - &_files_state, 0, NULL, 0); - if (rv == NS_SUCCESS) - *retval = &_files_group; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getgrent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - rv = __grscan_files(retval, grp, buffer, buflen, - &_files_state, 0, NULL, 0); - if (rv == NS_SUCCESS) - *result = grp; - else - *result = NULL; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getgrgid(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - gid_t gid = va_arg(ap, gid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_files(&_files_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_files(&rerror, &_files_group, - _files_groupbuf, sizeof(_files_groupbuf), - &_files_state, 1, NULL, gid); - if (!_files_state.stayopen) - __grend_files(&_files_state); - if (rv == NS_SUCCESS) - *retval = &_files_group; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getgrgid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - gid_t gid = va_arg(ap, gid_t); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_files state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = __grscan_files(retval, grp, buffer, buflen, &state, 1, NULL, gid); - __grend_files(&state); - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getgrnam(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_files(&_files_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_files(&rerror, &_files_group, - _files_groupbuf, sizeof(_files_groupbuf), - &_files_state, 1, name, 0); - if (!_files_state.stayopen) - __grend_files(&_files_state); - if (rv == NS_SUCCESS) - *retval = &_files_group; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getgrnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_files state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = __grscan_files(retval, grp, buffer, buflen, &state, 1, name, 0); - __grend_files(&state); - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - - -#ifdef HESIOD - /* - * dns methods - */ - -int -__grstart_dns(struct __grstate_dns *state) -{ - - _DIAGASSERT(state != NULL); - - state->num = 0; - if (state->context == NULL) { /* setup Hesiod */ - if (hesiod_init(&state->context) == -1) - return NS_UNAVAIL; - } - - return NS_SUCCESS; -} - -int -__grend_dns(struct __grstate_dns *state) -{ - - _DIAGASSERT(state != NULL); - - state->num = 0; - if (state->context) { - hesiod_end(state->context); - state->context = NULL; - } - return NS_SUCCESS; -} - -/* - * __grscan_dns - * Search Hesiod for the next desired entry. - * If search is zero, return the next entry. - * If search is non-zero, look for a specific name (if name != NULL), - * or a specific gid (if name == NULL). - */ -int -__grscan_dns(int *retval, struct group *grp, char *buffer, size_t buflen, - struct __grstate_dns *state, int search, const char *name, gid_t gid) -{ - const char **curzone; - char **hp, *ep; - int rv; - - static const char *zones_gid_group[] = { - "gid", - "group", - NULL - }; - - static const char *zones_group[] = { - "group", - NULL - }; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - /* name is NULL to indicate searching for gid */ - - *retval = 0; - - if (state->context == NULL) { /* only start if Hesiod not setup */ - rv = __grstart_dns(state); - if (rv != NS_SUCCESS) - return rv; - } - - next_dns_entry: - hp = NULL; - rv = NS_NOTFOUND; - - if (! search) { /* find next entry */ - if (state->num == -1) /* exhausted search */ - return NS_NOTFOUND; - /* find group-NNN */ - snprintf(buffer, buflen, "group-%u", state->num); - state->num++; - curzone = zones_group; - } else if (name) { /* find group name */ - snprintf(buffer, buflen, "%s", name); - curzone = zones_group; - } else { /* find gid */ - snprintf(buffer, buflen, "%u", (unsigned int)gid); - curzone = zones_gid_group; - } - - for (; *curzone; curzone++) { /* search zones */ - hp = hesiod_resolve(state->context, buffer, *curzone); - if (hp != NULL) - break; - if (errno != ENOENT) { - rv = NS_UNAVAIL; - goto dnsgrscan_out; - } - } - if (*curzone == NULL) { - if (! search) - state->num = -1; - goto dnsgrscan_out; - } - - if ((ep = strchr(hp[0], '\n')) != NULL) - *ep = '\0'; /* clear trailing \n */ - if (_gr_parse(hp[0], grp, buffer, buflen)) { /* validate line */ - if (! search) { /* just want this one */ - rv = NS_SUCCESS; - } else if ((name && strcmp(name, grp->gr_name) == 0) || - (!name && gid == grp->gr_gid)) { /* want specific */ - rv = NS_SUCCESS; - } - } else { /* dodgy entry */ - if (!search) { /* try again if ! searching */ - hesiod_free_list(state->context, hp); - goto next_dns_entry; - } - } - - dnsgrscan_out: - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - if (hp) - hesiod_free_list(state->context, hp); - return rv; -} - -static struct __grstate_dns _dns_state; - /* storage for non _r functions */ -static struct group _dns_group; -static char _dns_groupbuf[_GETGR_R_SIZE_MAX]; - -/*ARGSUSED*/ -static int -_dns_setgrent(void *nsrv, void *nscb, va_list ap) -{ - - _dns_state.stayopen = 0; - return __grstart_dns(&_dns_state); -} - -/*ARGSUSED*/ -static int -_dns_setgroupent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - _dns_state.stayopen = stayopen; - rv = __grstart_dns(&_dns_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_dns_endgrent(void *nsrv, void *nscb, va_list ap) -{ - - _dns_state.stayopen = 0; - return __grend_dns(&_dns_state); -} - -/*ARGSUSED*/ -static int -_dns_getgrent(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grscan_dns(&rerror, &_dns_group, - _dns_groupbuf, sizeof(_dns_groupbuf), &_dns_state, 0, NULL, 0); - if (rv == NS_SUCCESS) - *retval = &_dns_group; - return rv; -} - -/*ARGSUSED*/ -static int -_dns_getgrent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - rv = __grscan_dns(retval, grp, buffer, buflen, - &_dns_state, 0, NULL, 0); - if (rv == NS_SUCCESS) - *result = grp; - else - *result = NULL; - return rv; -} -/*ARGSUSED*/ -static int -_dns_getgrgid(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - gid_t gid = va_arg(ap, gid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_dns(&_dns_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_dns(&rerror, &_dns_group, - _dns_groupbuf, sizeof(_dns_groupbuf), &_dns_state, 1, NULL, gid); - if (!_dns_state.stayopen) - __grend_dns(&_dns_state); - if (rv == NS_SUCCESS) - *retval = &_dns_group; - return rv; -} - -/*ARGSUSED*/ -static int -_dns_getgrgid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - gid_t gid = va_arg(ap, gid_t); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_dns state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = __grscan_dns(retval, grp, buffer, buflen, &state, 1, NULL, gid); - __grend_dns(&state); - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - -/*ARGSUSED*/ -static int -_dns_getgrnam(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_dns(&_dns_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_dns(&rerror, &_dns_group, - _dns_groupbuf, sizeof(_dns_groupbuf), &_dns_state, 1, name, 0); - if (!_dns_state.stayopen) - __grend_dns(&_dns_state); - if (rv == NS_SUCCESS) - *retval = &_dns_group; - return rv; -} - -/*ARGSUSED*/ -static int -_dns_getgrnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_dns state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = __grscan_dns(retval, grp, buffer, buflen, &state, 1, name, 0); - __grend_dns(&state); - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - -#endif /* HESIOD */ - - -#ifdef YP - /* - * nis methods - */ - -int -__grstart_nis(struct __grstate_nis *state) -{ - - _DIAGASSERT(state != NULL); - - state->done = 0; - if (state->current) { - free(state->current); - state->current = NULL; - } - if (state->domain == NULL) { /* setup NIS */ - switch (yp_get_default_domain(&state->domain)) { - case 0: - break; - case YPERR_RESRC: - return NS_TRYAGAIN; - default: - return NS_UNAVAIL; - } - } - return NS_SUCCESS; -} - -int -__grend_nis(struct __grstate_nis *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->domain) { - state->domain = NULL; - } - state->done = 0; - if (state->current) { - free(state->current); - state->current = NULL; - } - return NS_SUCCESS; -} - -/* - * __grscan_nis - * Search NIS for the next desired entry. - * If search is zero, return the next entry. - * If search is non-zero, look for a specific name (if name != NULL), - * or a specific gid (if name == NULL). - */ -int -__grscan_nis(int *retval, struct group *grp, char *buffer, size_t buflen, - struct __grstate_nis *state, int search, const char *name, gid_t gid) -{ - const char *map; - char *key, *data; - int nisr, rv, keylen, datalen; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - /* name is NULL to indicate searching for gid */ - - *retval = 0; - - if (state->domain == NULL) { /* only start if NIS not setup */ - rv = __grstart_nis(state); - if (rv != NS_SUCCESS) - return rv; - } - - next_nis_entry: - key = NULL; - data = NULL; - rv = NS_SUCCESS; - - if (! search) { /* find next entry */ - if (state->done) /* exhausted search */ - return NS_NOTFOUND; - map = "group.byname"; - if (state->current) { /* already searching */ - nisr = yp_next(state->domain, map, - state->current, state->currentlen, - &key, &keylen, &data, &datalen); - free(state->current); - state->current = NULL; - switch (nisr) { - case 0: - state->current = key; - state->currentlen = keylen; - key = NULL; - break; - case YPERR_NOMORE: - rv = NS_NOTFOUND; - state->done = 1; - break; - default: - rv = NS_UNAVAIL; - break; - } - } else { /* new search */ - if (yp_first(state->domain, map, - &state->current, &state->currentlen, - &data, &datalen)) { - rv = NS_UNAVAIL; - } - } - } else { /* search for specific item */ - if (name) { /* find group name */ - snprintf(buffer, buflen, "%s", name); - map = "group.byname"; - } else { /* find gid */ - snprintf(buffer, buflen, "%u", (unsigned int)gid); - map = "group.bygid"; - } - nisr = yp_match(state->domain, map, buffer, (int)strlen(buffer), - &data, &datalen); - switch (nisr) { - case 0: - break; - case YPERR_KEY: - rv = NS_NOTFOUND; - break; - default: - rv = NS_UNAVAIL; - break; - } - } - if (rv == NS_SUCCESS) { /* validate data */ - data[datalen] = '\0'; /* clear trailing \n */ - if (_gr_parse(data, grp, buffer, buflen)) { - if (! search) { /* just want this one */ - rv = NS_SUCCESS; - } else if ((name && strcmp(name, grp->gr_name) == 0) || - (!name && gid == grp->gr_gid)) { - /* want specific */ - rv = NS_SUCCESS; - } - } else { /* dodgy entry */ - if (!search) { /* try again if ! searching */ - free(data); - goto next_nis_entry; - } - } - } - - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - if (key) - free(key); - if (data) - free(data); - return rv; -} - -static struct __grstate_nis _nis_state; - /* storage for non _r functions */ -static struct group _nis_group; -static char _nis_groupbuf[_GETGR_R_SIZE_MAX]; - -/*ARGSUSED*/ -static int -_nis_setgrent(void *nsrv, void *nscb, va_list ap) -{ - - _nis_state.stayopen = 0; - return __grstart_nis(&_nis_state); -} - -/*ARGSUSED*/ -static int -_nis_setgroupent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - _nis_state.stayopen = stayopen; - rv = __grstart_nis(&_nis_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_nis_endgrent(void *nsrv, void *nscb, va_list ap) -{ - - return __grend_nis(&_nis_state); -} - -/*ARGSUSED*/ -static int -_nis_getgrent(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grscan_nis(&rerror, &_nis_group, - _nis_groupbuf, sizeof(_nis_groupbuf), &_nis_state, 0, NULL, 0); - if (rv == NS_SUCCESS) - *retval = &_nis_group; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getgrent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - rv = __grscan_nis(retval, grp, buffer, buflen, - &_nis_state, 0, NULL, 0); - if (rv == NS_SUCCESS) - *result = grp; - else - *result = NULL; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getgrgid(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - gid_t gid = va_arg(ap, gid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_nis(&_nis_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_nis(&rerror, &_nis_group, - _nis_groupbuf, sizeof(_nis_groupbuf), &_nis_state, 1, NULL, gid); - if (!_nis_state.stayopen) - __grend_nis(&_nis_state); - if (rv == NS_SUCCESS) - *retval = &_nis_group; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getgrgid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - gid_t gid = va_arg(ap, gid_t); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_nis state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; -/* remark: we run under a global mutex inside of this module ... */ - if (_nis_state.stayopen) - { /* use global state only if stayopen is set - otherwiese we would blow up getgrent_r() ... */ - rv = __grscan_nis(retval, grp, buffer, buflen, &_nis_state, 1, NULL, gid); - } - else - { - memset(&state, 0, sizeof(state)); - rv = __grscan_nis(retval, grp, buffer, buflen, &state, 1, NULL, gid); - __grend_nis(&state); - } - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getgrnam(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_nis(&_nis_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_nis(&rerror, &_nis_group, - _nis_groupbuf, sizeof(_nis_groupbuf), &_nis_state, 1, name, 0); - if (!_nis_state.stayopen) - __grend_nis(&_nis_state); - if (rv == NS_SUCCESS) - *retval = &_nis_group; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getgrnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_nis state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; -/* remark: we run under a global mutex inside of this module ... */ - if (_nis_state.stayopen) - { /* use global state only if stayopen is set - otherwiese we would blow up getgrent_r() ... */ - rv = __grscan_nis(retval, grp, buffer, buflen, &_nis_state, 1, name, 0); - } - else - { - memset(&state, 0, sizeof(state)); - rv = __grscan_nis(retval, grp, buffer, buflen, &state, 1, name, 0); - __grend_nis(&state); - } - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - -#endif /* YP */ - - -#ifdef _GROUP_COMPAT - /* - * compat methods - */ - -int -__grstart_compat(struct __grstate_compat *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->fp == NULL) { - state->fp = fopen(_PATH_GROUP, "re"); - if (state->fp == NULL) - return NS_UNAVAIL; - } else { - rewind(state->fp); - } - return NS_SUCCESS; -} - -int -__grend_compat(struct __grstate_compat *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->name) { - free(state->name); - state->name = NULL; - } - if (state->fp) { - (void) fclose(state->fp); - state->fp = NULL; - } - return NS_SUCCESS; -} - - -/* - * __grbad_compat - * log an error if "files" or "compat" is specified in - * group_compat database - */ -/*ARGSUSED*/ -int -__grbad_compat(void *nsrv, void *nscb, va_list ap) -{ - static int warned; - - _DIAGASSERT(nsrv != NULL); - _DIAGASSERT(nscb != NULL); - - if (!warned) { - syslog(LOG_ERR, - "nsswitch.conf group_compat database can't use '%s'", - (const char *)nscb); - } - warned = 1; - return NS_UNAVAIL; -} - -/* - * __grscan_compat - * Scan state->fp for the next desired entry. - * If search is zero, return the next entry. - * If search is non-zero, look for a specific name (if name != NULL), - * or a specific gid (if name == NULL). - * Sets *retval to the errno if the result is not NS_SUCCESS or - * NS_NOTFOUND. - * - * searchfunc is invoked when a compat "+" lookup is required; - * searchcookie is passed as the first argument to searchfunc, - * the second argument is the group result. - * This should return NS_NOTFOUND when "no more groups" from compat src. - * If searchfunc is NULL then nsdispatch of getgrent is used. - * This is primarily intended for getgroupmembership(3)'s compat backend. - */ -int -__grscan_compat(int *retval, struct group *grp, char *buffer, size_t buflen, - struct __grstate_compat *state, int search, const char *name, gid_t gid, - int (*searchfunc)(void *, struct group **), void *searchcookie) -{ - int rv; - char filebuf[_GETGR_R_SIZE_MAX], *ep; - - static const ns_dtab compatentdtab[] = { - NS_FILES_CB(__grbad_compat, "files") - NS_DNS_CB(_dns_getgrent_r, NULL) - NS_NIS_CB(_nis_getgrent_r, NULL) - NS_COMPAT_CB(__grbad_compat, "compat") - NS_NULL_CB - }; - static const ns_dtab compatgiddtab[] = { - NS_FILES_CB(__grbad_compat, "files") - NS_DNS_CB(_dns_getgrgid_r, NULL) - NS_NIS_CB(_nis_getgrgid_r, NULL) - NS_COMPAT_CB(__grbad_compat, "compat") - NS_NULL_CB - }; - static const ns_dtab compatnamdtab[] = { - NS_FILES_CB(__grbad_compat, "files") - NS_DNS_CB(_dns_getgrnam_r, NULL) - NS_NIS_CB(_nis_getgrnam_r, NULL) - NS_COMPAT_CB(__grbad_compat, "compat") - NS_NULL_CB - }; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - /* name is NULL to indicate searching for gid */ - - *retval = 0; - - if (state->fp == NULL) { /* only start if file not open yet */ - rv = __grstart_compat(state); - if (rv != NS_SUCCESS) - goto compatgrscan_out; - } - rv = NS_NOTFOUND; - - for (;;) { /* loop through file */ - if (state->name != NULL) { - /* processing compat entry */ - int crv, cretval; - struct group cgrp, *cgrpres; - - if (state->name[0]) { /* specific +group: */ - crv = nsdispatch(NULL, compatnamdtab, - NSDB_GROUP_COMPAT, "getgrnam_r", - __nsdefaultnis, - &cretval, state->name, - &cgrp, filebuf, sizeof(filebuf), &cgrpres); - free(state->name); /* (only check 1 grp) */ - state->name = NULL; - } else if (!search) { /* any group */ - if (searchfunc) { - crv = searchfunc(searchcookie, - &cgrpres); - } else { - crv = nsdispatch(NULL, compatentdtab, - NSDB_GROUP_COMPAT, "getgrent_r", - __nsdefaultnis, - &cretval, &cgrp, filebuf, - sizeof(filebuf), &cgrpres); - } - } else if (name) { /* specific group */ - crv = nsdispatch(NULL, compatnamdtab, - NSDB_GROUP_COMPAT, "getgrnam_r", - __nsdefaultnis, - &cretval, name, - &cgrp, filebuf, sizeof(filebuf), &cgrpres); - } else { /* specific gid */ - crv = nsdispatch(NULL, compatgiddtab, - NSDB_GROUP_COMPAT, "getgrgid_r", - __nsdefaultnis, - &cretval, gid, - &cgrp, filebuf, sizeof(filebuf), &cgrpres); - } - if (crv != NS_SUCCESS) { /* not found */ - free(state->name); - state->name = NULL; - continue; /* try next line */ - } - if (!_gr_copy(cgrpres, grp, buffer, buflen)) { - rv = NS_UNAVAIL; - break; - } - goto compatgrscan_cmpgrp; /* skip to grp test */ - } - - /* get next file line */ - if (fgets(filebuf, (int)sizeof(filebuf), state->fp) == NULL) - break; - - ep = strchr(filebuf, '\n'); - if (ep == NULL) { /* skip lines that are too big */ - int ch; - - while ((ch = getc(state->fp)) != '\n' && ch != EOF) - continue; - continue; - } - *ep = '\0'; /* clear trailing \n */ - - if (filebuf[0] == '+') { /* parse compat line */ - if (state->name) - free(state->name); - state->name = NULL; - switch(filebuf[1]) { - case ':': - case '\0': - state->name = strdup(""); - break; - default: - ep = strchr(filebuf + 1, ':'); - if (ep == NULL) - break; - *ep = '\0'; - state->name = strdup(filebuf + 1); - break; - } - if (state->name == NULL) { - rv = NS_UNAVAIL; - break; - } - continue; - } - - /* validate line */ - if (! _gr_parse(filebuf, grp, buffer, buflen)) { - continue; /* skip bad lines */ - } - - compatgrscan_cmpgrp: - if (! search) { /* just want this one */ - rv = NS_SUCCESS; - break; - } - /* want specific */ - if ((name && strcmp(name, grp->gr_name) == 0) || - (!name && gid == grp->gr_gid)) { - rv = NS_SUCCESS; - break; - } - - } - - compatgrscan_out: - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - return rv; -} - -static struct __grstate_compat _compat_state; - /* storage for non _r functions */ -static struct group _compat_group; -static char _compat_groupbuf[_GETGR_R_SIZE_MAX]; - -/*ARGSUSED*/ -static int -_compat_setgrent(void *nsrv, void *nscb, va_list ap) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(__grbad_compat, "files") - NS_DNS_CB(_dns_setgrent, NULL) - NS_NIS_CB(_nis_setgrent, NULL) - NS_COMPAT_CB(__grbad_compat, "compat") - NS_NULL_CB - }; - - /* force group_compat setgrent() */ - (void) nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgrent", - __nsdefaultnis_forceall); - - /* reset state, keep fp open */ - _compat_state.stayopen = 0; - return __grstart_compat(&_compat_state); -} - -/*ARGSUSED*/ -static int -_compat_setgroupent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - static const ns_dtab dtab[] = { - NS_FILES_CB(__grbad_compat, "files") - NS_DNS_CB(_dns_setgroupent, NULL) - NS_NIS_CB(_nis_setgroupent, NULL) - NS_COMPAT_CB(__grbad_compat, "compat") - NS_NULL_CB - }; - - /* force group_compat setgroupent() */ - (void) nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "setgroupent", - __nsdefaultnis_forceall, &rv, stayopen); - - _compat_state.stayopen = stayopen; - rv = __grstart_compat(&_compat_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_compat_endgrent(void *nsrv, void *nscb, va_list ap) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(__grbad_compat, "files") - NS_DNS_CB(_dns_endgrent, NULL) - NS_NIS_CB(_nis_endgrent, NULL) - NS_COMPAT_CB(__grbad_compat, "compat") - NS_NULL_CB - }; - - /* force group_compat endgrent() */ - (void) nsdispatch(NULL, dtab, NSDB_GROUP_COMPAT, "endgrent", - __nsdefaultnis_forceall); - - /* reset state, close fp */ - _compat_state.stayopen = 0; - return __grend_compat(&_compat_state); -} - -/*ARGSUSED*/ -static int -_compat_getgrent(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grscan_compat(&rerror, &_compat_group, - _compat_groupbuf, sizeof(_compat_groupbuf), - &_compat_state, 0, NULL, 0, NULL, NULL); - if (rv == NS_SUCCESS) - *retval = &_compat_group; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getgrent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - rv = __grscan_compat(retval, grp, buffer, buflen, - &_compat_state, 0, NULL, 0, NULL, NULL); - if (rv == NS_SUCCESS) - *result = grp; - else - *result = NULL; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getgrgid(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - gid_t gid = va_arg(ap, gid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_compat(&_compat_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_compat(&rerror, &_compat_group, - _compat_groupbuf, sizeof(_compat_groupbuf), - &_compat_state, 1, NULL, gid, NULL, NULL); - if (!_compat_state.stayopen) - __grend_compat(&_compat_state); - if (rv == NS_SUCCESS) - *retval = &_compat_group; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getgrgid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - gid_t gid = va_arg(ap, gid_t); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_compat state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = __grscan_compat(retval, grp, buffer, buflen, &state, - 1, NULL, gid, NULL, NULL); - __grend_compat(&state); - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getgrnam(void *nsrv, void *nscb, va_list ap) -{ - struct group **retval = va_arg(ap, struct group **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = __grstart_compat(&_compat_state); - if (rv != NS_SUCCESS) - return rv; - rv = __grscan_compat(&rerror, &_compat_group, - _compat_groupbuf, sizeof(_compat_groupbuf), - &_compat_state, 1, name, 0, NULL, NULL); - if (!_compat_state.stayopen) - __grend_compat(&_compat_state); - if (rv == NS_SUCCESS) - *retval = &_compat_group; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getgrnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct group *grp = va_arg(ap, struct group *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct group **result = va_arg(ap, struct group **); - - struct __grstate_compat state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = __grscan_compat(retval, grp, buffer, buflen, &state, - 1, name, 0, NULL, NULL); - __grend_compat(&state); - if (rv == NS_SUCCESS) - *result = grp; - return rv; -} - -#endif /* _GROUP_COMPAT */ - - - /* - * public functions - */ - -struct group * -getgrent(void) -{ - int rv; - struct group *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getgrent, NULL) - NS_DNS_CB(_dns_getgrent, NULL) - NS_NIS_CB(_nis_getgrent, NULL) - NS_COMPAT_CB(_compat_getgrent, NULL) - NS_NULL_CB - }; - - mutex_lock(&__grmutex); - rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent", __nsdefaultcompat, - &retval); - mutex_unlock(&__grmutex); - return (rv == NS_SUCCESS) ? retval : NULL; -} - -int -getgrent_r(struct group *grp, char *buffer, size_t buflen, - struct group **result) -{ - int rv, retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getgrent_r, NULL) - NS_DNS_CB(_dns_getgrent_r, NULL) - NS_NIS_CB(_nis_getgrent_r, NULL) - NS_COMPAT_CB(_compat_getgrent_r, NULL) - NS_NULL_CB - }; - - mutex_lock(&__grmutex); - rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrent_r", __nsdefaultcompat, - &retval, grp, buffer, buflen, result); - mutex_unlock(&__grmutex); - switch (rv) { - case NS_SUCCESS: - case NS_NOTFOUND: - return 0; - default: - return retval; - } -} - - -struct group * -getgrgid(gid_t gid) -{ - int rv; - struct group *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getgrgid, NULL) - NS_DNS_CB(_dns_getgrgid, NULL) - NS_NIS_CB(_nis_getgrgid, NULL) - NS_COMPAT_CB(_compat_getgrgid, NULL) - NS_NULL_CB - }; - - mutex_lock(&__grmutex); - rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid", __nsdefaultcompat, - &retval, gid); - mutex_unlock(&__grmutex); - return (rv == NS_SUCCESS) ? retval : NULL; -} - -int -getgrgid_r(gid_t gid, struct group *grp, char *buffer, size_t buflen, - struct group **result) -{ - int rv, retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getgrgid_r, NULL) - NS_DNS_CB(_dns_getgrgid_r, NULL) - NS_NIS_CB(_nis_getgrgid_r, NULL) - NS_COMPAT_CB(_compat_getgrgid_r, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - retval = 0; - mutex_lock(&__grmutex); - rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrgid_r", __nsdefaultcompat, - &retval, gid, grp, buffer, buflen, result); - mutex_unlock(&__grmutex); - switch (rv) { - case NS_SUCCESS: - case NS_NOTFOUND: - return 0; - default: - return retval; - } -} - -struct group * -getgrnam(const char *name) -{ - int rv; - struct group *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getgrnam, NULL) - NS_DNS_CB(_dns_getgrnam, NULL) - NS_NIS_CB(_nis_getgrnam, NULL) - NS_COMPAT_CB(_compat_getgrnam, NULL) - NS_NULL_CB - }; - - mutex_lock(&__grmutex); - rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrnam", __nsdefaultcompat, - &retval, name); - mutex_unlock(&__grmutex); - return (rv == NS_SUCCESS) ? retval : NULL; -} - -int -getgrnam_r(const char *name, struct group *grp, char *buffer, size_t buflen, - struct group **result) -{ - int rv, retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getgrnam_r, NULL) - NS_DNS_CB(_dns_getgrnam_r, NULL) - NS_NIS_CB(_nis_getgrnam_r, NULL) - NS_COMPAT_CB(_compat_getgrnam_r, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(grp != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - retval = 0; - mutex_lock(&__grmutex); - rv = nsdispatch(NULL, dtab, NSDB_GROUP, "getgrnam_r", __nsdefaultcompat, - &retval, name, grp, buffer, buflen, result); - mutex_unlock(&__grmutex); - switch (rv) { - case NS_SUCCESS: - case NS_NOTFOUND: - return 0; - default: - return retval; - } -} - -void -endgrent(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_endgrent, NULL) - NS_DNS_CB(_dns_endgrent, NULL) - NS_NIS_CB(_nis_endgrent, NULL) - NS_COMPAT_CB(_compat_endgrent, NULL) - NS_NULL_CB - }; - - mutex_lock(&__grmutex); - /* force all endgrent() methods */ - (void) nsdispatch(NULL, dtab, NSDB_GROUP, "endgrent", - __nsdefaultcompat_forceall); - mutex_unlock(&__grmutex); -} - -int -setgroupent(int stayopen) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_setgroupent, NULL) - NS_DNS_CB(_dns_setgroupent, NULL) - NS_NIS_CB(_nis_setgroupent, NULL) - NS_COMPAT_CB(_compat_setgroupent, NULL) - NS_NULL_CB - }; - int rv, retval; - - mutex_lock(&__grmutex); - /* force all setgroupent() methods */ - rv = nsdispatch(NULL, dtab, NSDB_GROUP, "setgroupent", - __nsdefaultcompat_forceall, &retval, stayopen); - mutex_unlock(&__grmutex); - return (rv == NS_SUCCESS) ? retval : 0; -} - -void -setgrent(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_setgrent, NULL) - NS_DNS_CB(_dns_setgrent, NULL) - NS_NIS_CB(_nis_setgrent, NULL) - NS_COMPAT_CB(_compat_setgrent, NULL) - NS_NULL_CB - }; - - mutex_lock(&__grmutex); - /* force all setgrent() methods */ - (void) nsdispatch(NULL, dtab, NSDB_GROUP, "setgrent", - __nsdefaultcompat_forceall); - mutex_unlock(&__grmutex); -} diff --git a/lib/libc/gen/getgrouplist.3 b/lib/libc/gen/getgrouplist.3 deleted file mode 100644 index 7638ab027..000000000 --- a/lib/libc/gen/getgrouplist.3 +++ /dev/null @@ -1,152 +0,0 @@ -.\" $NetBSD: getgrouplist.3,v 1.14 2008/05/02 18:11:04 martin Exp $ -.\" -.\" Copyright (c) 2005 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Luke Mewburn. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getgrouplist.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd January 6, 2005 -.Dt GETGROUPLIST 3 -.Os -.Sh NAME -.Nm getgrouplist , -.Nm getgroupmembership , -.Nd calculate group access list -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn getgrouplist "const char *name" "gid_t basegid" "gid_t *groups" "int *ngroups" -.Ft int -.Fn getgroupmembership "const char *name" "gid_t basegid" "gid_t *groups" "int maxgrp" "int *ngroups" -.Sh DESCRIPTION -The -.Fn getgrouplist -and -.Fn getgroupmembership -functions read through the group database and calculate -the group access list for the user specified in -.Fa name . -The -.Fa basegid -is automatically included in the groups list. -Typically this value is given as -the group number from the password database. -.Pp -The resulting group list is returned in the integer array pointed to by -.Fa groups . -.Pp -For -.Fn getgrouplist , -the caller specifies the size of the -.Fa groups -array in the integer pointed to by -.Fa ngroups . -.Pp -For -.Fn getgroupmembership , -the caller specifies the size of the -.Fa groups -array in -.Fa maxgrp . -.Pp -The actual number of groups found is returned in -.Fa ngroups . -.Pp -Duplicate group ids will be suppressed from the result. -.Sh RETURN VALUES -The -.Fn getgrouplist -and -.Fn getgroupmembership -functions -return 0 if successful, and -return \-1 if the size of the group list is too small to -hold all the user's groups. -In the latter case, the -.Fa groups -array will be filled with as many groups as will fit and -.Fa ngroups -will contain the total number of groups found. -.Sh FILES -.Bl -tag -width /etc/group -compact -.It Pa /etc/group -group membership list -.El -.Sh SEE ALSO -.Xr setgroups 2 , -.Xr initgroups 3 , -.Xr group 5 -.Sh HISTORY -The -.Fn getgrouplist -function first appeared in -.Bx 4.4 . -The -.Fn getgroupmembership -function first appeared in -.Nx 3.0 -to address an API deficiency in -.Fn getgrouplist . -.Sh BUGS -The -.Fn getgrouplist -function -uses the routines based on -.Xr getgrent 3 . -If the invoking program uses any of these routines, -the group structure will -be overwritten in the call to -.Fn getgrouplist . diff --git a/lib/libc/gen/getgrouplist.c b/lib/libc/gen/getgrouplist.c deleted file mode 100644 index cd152ec7d..000000000 --- a/lib/libc/gen/getgrouplist.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: getgrouplist.c,v 1.22 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2004-2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getgrouplist.c 8.2 (Berkeley) 12/8/94"; -#else -__RCSID("$NetBSD: getgrouplist.c,v 1.22 2008/04/28 20:22:59 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * calculate group access list - */ - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getgrouplist,_getgrouplist) -#endif - -int -getgrouplist(const char *uname, gid_t agroup, gid_t *groups, int *grpcnt) -{ - int rv, groupc; - - _DIAGASSERT(uname != NULL); - /* groups may be NULL if just sizing when invoked with *grpcnt = 0 */ - _DIAGASSERT(grpcnt != NULL); - - groupc = 0; - rv = getgroupmembership(uname, agroup, groups, *grpcnt, &groupc); - *grpcnt = groupc; /* set groupc to the actual # of groups */ - return rv; -} diff --git a/lib/libc/gen/getgroupmembership.c b/lib/libc/gen/getgroupmembership.c deleted file mode 100644 index 78687c0a5..000000000 --- a/lib/libc/gen/getgroupmembership.c +++ /dev/null @@ -1,405 +0,0 @@ -/* $NetBSD: getgroupmembership.c,v 1.4 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2004-2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getgroupmembership.c,v 1.4 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -/* - * calculate group access list - */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HESIOD -#include -#endif - -#include "gr_private.h" - -#ifdef __weak_alias -__weak_alias(getgroupmembership,_getgroupmembership) -#endif - -/* - * __gr_addgid - * Add gid to the groups array (of maxgrp size) at the position - * indicated by *groupc, unless it already exists or *groupc is - * past &groups[maxgrp]. - * Returns 1 upon success (including duplicate suppression), 0 otherwise. - */ -static int -__gr_addgid(gid_t gid, gid_t *groups, int maxgrp, int *groupc) -{ - int ret, dupc; - - _DIAGASSERT(groupc != NULL); - _DIAGASSERT(groups != NULL); - - /* skip duplicates */ - for (dupc = 0; dupc < MIN(maxgrp, *groupc); dupc++) { - if (groups[dupc] == gid) - return 1; - } - - ret = 1; - if (*groupc < maxgrp) /* add this gid */ - groups[*groupc] = gid; - else - ret = 0; - (*groupc)++; - return ret; -} - - -/*ARGSUSED*/ -static int -_files_getgroupmembership(void *retval, void *cb_data, va_list ap) -{ - int *result = va_arg(ap, int *); - const char *uname = va_arg(ap, const char *); - gid_t agroup = va_arg(ap, gid_t); - gid_t *groups = va_arg(ap, gid_t *); - int maxgrp = va_arg(ap, int); - int *groupc = va_arg(ap, int *); - - struct __grstate_files state; - struct group grp; - char grpbuf[_GETGR_R_SIZE_MAX]; - int rv, i; - - _DIAGASSERT(result != NULL); - _DIAGASSERT(uname != NULL); - /* groups may be NULL if just sizing when invoked with maxgrp = 0 */ - _DIAGASSERT(groupc != NULL); - - /* install primary group */ - (void) __gr_addgid(agroup, groups, maxgrp, groupc); - - memset(&state, 0, sizeof(state)); - while (__grscan_files(&rv, &grp, grpbuf, sizeof(grpbuf), &state, - 0, NULL, 0) == NS_SUCCESS) { - /* scan members */ - for (i = 0; grp.gr_mem[i]; i++) { - if (strcmp(grp.gr_mem[i], uname) != 0) - continue; - if (! __gr_addgid(grp.gr_gid, groups, maxgrp, groupc)) - *result = -1; - break; - } - } - __grend_files(&state); - return NS_NOTFOUND; -} - - -#ifdef HESIOD - -/*ARGSUSED*/ -static int -_dns_getgroupmembership(void *retval, void *cb_data, va_list ap) -{ - int *result = va_arg(ap, int *); - const char *uname = va_arg(ap, const char *); - gid_t agroup = va_arg(ap, gid_t); - gid_t *groups = va_arg(ap, gid_t *); - int maxgrp = va_arg(ap, int); - int *groupc = va_arg(ap, int *); - - struct __grstate_dns state; - struct group grp; - char grpbuf[_GETGR_R_SIZE_MAX]; - unsigned long id; - void *context; - char **hp, *cp, *ep; - int rv, i; - - _DIAGASSERT(result != NULL); - _DIAGASSERT(uname != NULL); - /* groups may be NULL if just sizing when invoked with maxgrp = 0 */ - _DIAGASSERT(groupc != NULL); - - /* install primary group */ - (void) __gr_addgid(agroup, groups, maxgrp, groupc); - - hp = NULL; - rv = NS_NOTFOUND; - - if (hesiod_init(&context) == -1) /* setup hesiod */ - return NS_UNAVAIL; - - hp = hesiod_resolve(context, uname, "grplist"); /* find grplist */ - if (hp == NULL) { - if (errno != ENOENT) { /* wasn't "not found"*/ - rv = NS_UNAVAIL; - goto dnsgroupmembers_out; - } - /* grplist not found, fallback to _dns_grscan */ - memset(&state, 0, sizeof(state)); - while (__grscan_dns(&rv, &grp, grpbuf, sizeof(grpbuf), &state, - 0, NULL, 0) == NS_SUCCESS) { - /* scan members */ - for (i = 0; grp.gr_mem[i]; i++) { - if (strcmp(grp.gr_mem[i], uname) != 0) - continue; - if (! __gr_addgid(grp.gr_gid, groups, maxgrp, - groupc)) - *result = -1; - break; - } - } - __grend_dns(&state); - rv = NS_NOTFOUND; - goto dnsgroupmembers_out; - } - - if ((ep = strchr(hp[0], '\n')) != NULL) - *ep = '\0'; /* clear trailing \n */ - - for (cp = hp[0]; *cp != '\0'; ) { /* parse grplist */ - if ((cp = strchr(cp, ':')) == NULL) /* skip grpname */ - break; - cp++; - id = strtoul(cp, &ep, 10); /* parse gid */ - if (id > GID_MAX || (*ep != ':' && *ep != '\0')) { - rv = NS_UNAVAIL; - goto dnsgroupmembers_out; - } - cp = ep; - if (*cp == ':') - cp++; - - /* add gid */ - if (! __gr_addgid((gid_t)id, groups, maxgrp, groupc)) - *result = -1; - } - - rv = NS_NOTFOUND; - - dnsgroupmembers_out: - if (hp) - hesiod_free_list(context, hp); - hesiod_end(context); - return rv; -} - -#endif /* HESIOD */ - - -#ifdef YP - -/*ARGSUSED*/ -static int -_nis_getgroupmembership(void *retval, void *cb_data, va_list ap) -{ - int *result = va_arg(ap, int *); - const char *uname = va_arg(ap, const char *); - gid_t agroup = va_arg(ap, gid_t); - gid_t *groups = va_arg(ap, gid_t *); - int maxgrp = va_arg(ap, int); - int *groupc = va_arg(ap, int *); - - struct __grstate_nis state; - struct group grp; - char grpbuf[_GETGR_R_SIZE_MAX]; - int rv, i; - - _DIAGASSERT(result != NULL); - _DIAGASSERT(uname != NULL); - /* groups may be NULL if just sizing when invoked with maxgrp = 0 */ - _DIAGASSERT(groupc != NULL); - - /* install primary group */ - (void) __gr_addgid(agroup, groups, maxgrp, groupc); - - memset(&state, 0, sizeof(state)); - while (__grscan_nis(&rv, &grp, grpbuf, sizeof(grpbuf), &state, - 0, NULL, 0) == NS_SUCCESS) { - /* scan members */ - for (i = 0; grp.gr_mem[i]; i++) { - if (strcmp(grp.gr_mem[i], uname) != 0) - continue; - if (! __gr_addgid(grp.gr_gid, groups, maxgrp, groupc)) - *result = -1; - break; - } - } - __grend_nis(&state); - - return NS_NOTFOUND; -} - -#endif /* YP */ - - -#ifdef _GROUP_COMPAT - -struct __compatggm { - const char *uname; /* user to search for */ - gid_t *groups; - gid_t agroup; - int maxgrp; - int *groupc; -}; - -static int -_compat_ggm_search(void *cookie, struct group **groupres) -{ - struct __compatggm *cp; - int rerror, crv; - - static const ns_dtab dtab[] = { - NS_FILES_CB(__grbad_compat, "files") - NS_DNS_CB(_dns_getgroupmembership, NULL) - NS_NIS_CB(_nis_getgroupmembership, NULL) - NS_COMPAT_CB(__grbad_compat, "compat") - NS_NULL_CB - }; - - *groupres = NULL; /* we don't care about this */ - cp = (struct __compatggm *)cookie; - - crv = nsdispatch(NULL, dtab, - NSDB_GROUP_COMPAT, "getgroupmembership", - __nsdefaultnis, - &rerror, cp->uname, cp->agroup, cp->groups, cp->maxgrp, cp->groupc); - - if (crv == NS_SUCCESS) - crv = NS_NOTFOUND; /* indicate "no more +: entries" */ - - return crv; -} - -/* ARGSUSED */ -static int -_compat_getgroupmembership(void *retval, void *cb_data, va_list ap) -{ - int *result = va_arg(ap, int *); - const char *uname = va_arg(ap, const char *); - gid_t agroup = va_arg(ap, gid_t); - gid_t *groups = va_arg(ap, gid_t *); - int maxgrp = va_arg(ap, int); - int *groupc = va_arg(ap, int *); - - struct __grstate_compat state; - struct __compatggm ggmstate; - struct group grp; - char grpbuf[_GETGR_R_SIZE_MAX]; - int rv, i; - - _DIAGASSERT(result != NULL); - _DIAGASSERT(uname != NULL); - /* groups may be NULL if just sizing when invoked with maxgrp = 0 */ - _DIAGASSERT(groupc != NULL); - - /* install primary group */ - (void) __gr_addgid(agroup, groups, maxgrp, groupc); - - memset(&state, 0, sizeof(state)); - memset(&ggmstate, 0, sizeof(ggmstate)); - ggmstate.uname = uname; - ggmstate.groups = groups; - ggmstate.agroup = agroup; - ggmstate.maxgrp = maxgrp; - ggmstate.groupc = groupc; - - while (__grscan_compat(&rv, &grp, grpbuf, sizeof(grpbuf), &state, - 0, NULL, 0, _compat_ggm_search, &ggmstate) - == NS_SUCCESS) { - /* scan members */ - for (i = 0; grp.gr_mem[i]; i++) { - if (strcmp(grp.gr_mem[i], uname) != 0) - continue; - if (! __gr_addgid(grp.gr_gid, groups, maxgrp, groupc)) - *result = -1; - break; - } - } - - __grend_compat(&state); - return NS_NOTFOUND; -} - -#endif /* _GROUP_COMPAT */ - - -int -getgroupmembership(const char *uname, gid_t agroup, - gid_t *groups, int maxgrp, int *groupc) -{ - int rerror; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getgroupmembership, NULL) - NS_DNS_CB(_dns_getgroupmembership, NULL) - NS_NIS_CB(_nis_getgroupmembership, NULL) - NS_COMPAT_CB(_compat_getgroupmembership, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(uname != NULL); - /* groups may be NULL if just sizing when invoked with maxgrp = 0 */ - _DIAGASSERT(groupc != NULL); - - *groupc = 0; - - mutex_lock(&__grmutex); - /* - * Call each backend. - * For compatibility with getgrent(3) semantics, - * a backend should return NS_NOTFOUND even upon - * completion, to allow result merging to occur. - */ - (void) nsdispatch(NULL, dtab, NSDB_GROUP, "getgroupmembership", - __nsdefaultcompat, - &rerror, uname, agroup, groups, maxgrp, groupc); - mutex_unlock(&__grmutex); - - if (*groupc > maxgrp) /* too many groups found */ - return -1; - else - return 0; -} diff --git a/lib/libc/gen/gethostname.3 b/lib/libc/gen/gethostname.3 deleted file mode 100644 index 610b1a8a5..000000000 --- a/lib/libc/gen/gethostname.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" $NetBSD: gethostname.3,v 1.18 2015/09/03 04:05:38 jnemeth Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)gethostname.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd September 2, 2015 -.Dt GETHOSTNAME 3 -.Os -.Sh NAME -.Nm gethostname , -.Nm sethostname -.Nd get/set name of current host -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn gethostname "char *name" "size_t namelen" -.Ft int -.Fn sethostname "const char *name" "size_t namelen" -.Sh DESCRIPTION -.Fn gethostname -returns the standard host name for the current machine, as -previously set by -.Fn sethostname . -The parameter -.Fa namelen -specifies the size of the -.Fa name -array. -The returned name is null-terminated unless insufficient -space is provided. -.Pp -.Fn sethostname -sets the name of the host machine to be -.Fa name , -which has length -.Fa namelen . -This call is restricted to the super-user and -is normally used only when the system is bootstrapped. -.Sh RETURN VALUES -If the call succeeds a value of 0 is returned. -If the call fails, a value of \-1 is returned and an error code is -placed in the global location -.Va errno . -.Sh ERRORS -If the -.Fn gethostname -or -.Fn sethostname -functions fail, -they will set -.Va errno -for any of the errors specified for the routine -.Xr sysctl 3 . -.Sh SEE ALSO -.Xr gethostid 3 , -.Xr sysctl 3 , -.Xr sysctl 8 -.Sh STANDARDS -The -.Fn gethostname -function conforms to -.St -xpg4.2 . -.Sh HISTORY -The -.Nm -function call appeared in -.Bx 4.2 . -.Sh BUGS -Host names are limited to -.Dv MAXHOSTNAMELEN -(from -.Ao Pa sys/param.h Ac ) -characters including null-termination, currently 256. diff --git a/lib/libc/gen/gethostname.c b/lib/libc/gen/gethostname.c deleted file mode 100644 index 8d1eed6ca..000000000 --- a/lib/libc/gen/gethostname.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: gethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)gethostname.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: gethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(gethostname,_gethostname) -#endif - -int -gethostname(char *name, size_t namelen) -{ - int mib[2]; - size_t size; - - _DIAGASSERT(name != NULL); - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - size = namelen; - if (sysctl(mib, 2, name, &size, NULL, 0) == -1) - return (-1); - - return (0); -} diff --git a/lib/libc/gen/getlastlogx.3 b/lib/libc/gen/getlastlogx.3 deleted file mode 100644 index cb7404c31..000000000 --- a/lib/libc/gen/getlastlogx.3 +++ /dev/null @@ -1,173 +0,0 @@ -.\" $NetBSD: getlastlogx.3,v 1.2 2008/04/30 13:10:50 martin Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Thomas Klausner. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd August 26, 2003 -.Dt GETLASTLOGX 3 -.Os -.Sh NAME -.Nm getlastlogx , -.Nm getutmp , -.Nm getutmpx , -.Nm updlastlogx , -.Nm updwtmpx , -.Nm utmpxname -.Nd user accounting database functions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In utmpx.h -.Ft struct lastlogx * -.Fn getlastlogx "const char *fname" "uid_t uid" "struct lastlogx *ll" -.Ft void -.Fn getutmp "const struct utmpx *ux" "struct utmp *u" -.Ft void -.Fn getutmpx "const struct utmp *u" "struct utmpx *ux" -.Ft int -.Fn updlastlogx "const char *fname" "uid_t uid" "struct lastlogx *ll" -.Ft int -.Fn updwtmpx "const char *file" "const struct utmpx *utx" -.Ft int -.Fn utmpxname "const char *fname" -.Sh DESCRIPTION -The -.Fn getlastlogx -function looks up the entry for the user with user id -.Fa uid -in the -.Xr lastlogx 5 -file given by -.Fa fname -and returns it in -.Fa \&ll . -If the provided -.Fa \&ll -is -.Dv NULL , -the necessary space will be allocated by -.Fn getlastlogx -and should be -.Fn free Ns d -by the caller. -.Pp -The -.Fn getutmp -function fills out the entries in the struct utmp -.Fa u -with the data provided in the struct utmpx -.Fa ux . -.Fn getutmpx -does the opposite, filling out the entries in the struct utmpx -.Fa ux -with the data provided in the struct utmp -.Fa u , -and initializing all the unknown fields to 0. -The sole exception is the -.Fa ut_type -field, which will be initialized to -.Dv USER_PROCESS . -.Pp -The -.Fn updlastlogx -function tries to update the information for the user with the user id -.Fa uid -in the -.Xr lastlogx 5 -file given by -.Fa fname -with the data supplied in -.Fa \&ll . -A -.Ft struct lastlogx -is defined like this: -.Bd -literal -struct lastlogx { - struct timeval ll_tv; /* time entry was created */ - char ll_line[_UTX_LINESIZE]; /* tty name */ - char ll_host[_UTX_HOSTSIZE]; /* host name */ - struct sockaddr_storage ll_ss; /* address where entry was made from */ -}; -.Ed -All the fields should be filled out by the caller. -.Pp -The -.Fn updwtmpx -function updates the -.Xr wtmpx 5 -file -.Fa file -with the -.Xr utmpx 5 -entry -.Fa utx . -.Pp -The -.Fn utmpxname -function sets the default -.Xr utmpx 5 -database file name to -.Fa fname . -.Sh RETURN VALUES -.Fn getlastlogx -returns the found entry on success, or -.Dv NULL -if it could not open the database, could not find an entry matching -.Fa uid -in there, or could not allocate the necessary space (in case -.Fa \&ll -was -.Dv NULL ) . -.Pp -.Fn utmpxname -returns 1 on success, or 0 if the supplied file name was too long or -did not end with -.Sq x . -.Pp -.Fn updlastlogx -and -.Fn updwtmpx -return 0 on success, or \-1 in case the database or file respectively -could not be opened or the data not written into it. -.Sh SEE ALSO -.Xr endutxent 3 , -.Xr loginx 3 , -.Xr utmpx 5 -.Sh HISTORY -The functions -.Fn getutmp , -.Fn getutmpx , -.Fn updwtmpx , -and -.Fn utmpxname -first appeared in -.Tn Solaris . -.Nm getlastlogx -and -.Nm updlastlogx -first appeared in -.Nx 2.0 . diff --git a/lib/libc/gen/getloadavg.3 b/lib/libc/gen/getloadavg.3 deleted file mode 100644 index 7f879b00a..000000000 --- a/lib/libc/gen/getloadavg.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" $NetBSD: getloadavg.3,v 1.15 2011/04/12 04:55:05 jruoho Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getloadavg.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 12, 2011 -.Dt GETLOADAVG 3 -.Os -.Sh NAME -.Nm getloadavg -.Nd get system load averages -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft int -.Fn getloadavg "double loadavg[]" "int nelem" -.Sh DESCRIPTION -The -.Fn getloadavg -function returns the number of processes in the system run queue -averaged over various periods of time. -Up to -.Fa nelem -samples are retrieved and assigned to successive elements of -.Fa loadavg Ns Bq . -The system imposes a maximum of 3 samples, representing averages -over the last 1, 5, and 15 minutes, respectively. -.Sh RETURN VALUES -If the load average was unobtainable, \-1 is returned; otherwise, -the number of samples actually retrieved is returned. -.Sh SEE ALSO -.Xr uptime 1 , -.Xr kvm_getloadavg 3 , -.Xr sysctl 3 -.Sh HISTORY -The -.Fn getloadavg -function appeared in -.Bx 4.3 Reno . diff --git a/lib/libc/gen/getloadavg.c b/lib/libc/gen/getloadavg.c deleted file mode 100644 index f548c42d9..000000000 --- a/lib/libc/gen/getloadavg.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: getloadavg.c,v 1.14 2012/03/13 21:13:36 christos Exp $ */ - -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getloadavg.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getloadavg.c,v 1.14 2012/03/13 21:13:36 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getloadavg,_getloadavg) -#endif - -/* - * getloadavg() -- Get system load averages. - * - * Put `nelem' samples into `loadavg' array. - * Return number of samples retrieved, or -1 on error. - */ -int -getloadavg(double loadavg[], int nelem) -{ - struct loadavg loadinfo; - static const int mib[] = { CTL_VM, VM_LOADAVG }; - size_t size, i; - - _DIAGASSERT(loadavg != NULL); - _DIAGASSERT(nelem >= 0); - - size = sizeof(loadinfo); - if (sysctl(mib, (u_int)__arraycount(mib), &loadinfo, &size, NULL, 0) - == -1) - return -1; - - size = MIN((size_t)nelem, __arraycount(loadinfo.ldavg)); - for (i = 0; i < size; i++) - loadavg[i] = (double) loadinfo.ldavg[i] / loadinfo.fscale; - return nelem; -} diff --git a/lib/libc/gen/getlogin.c b/lib/libc/gen/getlogin.c deleted file mode 100644 index 3821f66e5..000000000 --- a/lib/libc/gen/getlogin.c +++ /dev/null @@ -1,150 +0,0 @@ -/* $NetBSD: getlogin.c,v 1.15 2009/01/11 02:46:27 christos Exp $ */ - -/*- - * Copyright (c) 2008 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getlogin.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getlogin.c,v 1.15 2009/01/11 02:46:27 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include "reentrant.h" -#include "extern.h" - -#ifdef __weak_alias -__weak_alias(getlogin,_getlogin) -__weak_alias(getlogin_r,_getlogin_r) -#if !defined(__minix) -__weak_alias(setlogin,_setlogin) -#endif /* !defined(__minix) */ -#endif - -int __logname_valid; /* known to setlogin() */ -static char logname[MAXLOGNAME + 1]; - -#ifdef _REENTRANT -static mutex_t logname_mutex = MUTEX_INITIALIZER; -#endif - -char * -getlogin(void) -{ - char *rv; - - mutex_lock(&logname_mutex); - if (__logname_valid == 0) { - if (__getlogin(logname, sizeof(logname) - 1) < 0) { - mutex_unlock(&logname_mutex); - return ((char *)NULL); - } - __logname_valid = 1; - } - rv = (*logname ? logname : (char *)NULL); - mutex_unlock(&logname_mutex); - - return rv; -} - -int -getlogin_r(char *name, size_t namelen) -{ - size_t len; - int rv; - - mutex_lock(&logname_mutex); - if (__logname_valid == 0) { - if (__getlogin(logname, sizeof(logname) - 1) < 0) { - rv = errno; - mutex_unlock(&logname_mutex); - return (rv); - } - __logname_valid = 1; - } - len = strlen(logname) + 1; - if (len > namelen) { - rv = ERANGE; - } else { - strncpy(name, logname, len); - rv = 0; - } - mutex_unlock(&logname_mutex); - - return (rv); -} - -#if !defined(__minix) -int -setlogin(const char *name) -{ - int retval; - - retval = __setlogin(name); - __logname_valid = 0; - - return (retval); -} -#endif /* !defined(__minix) */ diff --git a/lib/libc/gen/getmntinfo.3 b/lib/libc/gen/getmntinfo.3 deleted file mode 100644 index 1b2227b99..000000000 --- a/lib/libc/gen/getmntinfo.3 +++ /dev/null @@ -1,115 +0,0 @@ -.\" $NetBSD: getmntinfo.3,v 1.15 2004/05/05 08:48:36 jdolecek Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getmntinfo.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd April 14, 2004 -.Dt GETMNTINFO 3 -.Os -.Sh NAME -.Nm getmntinfo -.Nd get information about mounted file systems -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/statvfs.h -.Ft int -.Fn getmntinfo "struct statvfs **mntbufp" "int flags" -.Sh DESCRIPTION -The -.Fn getmntinfo -function returns an array of -.Em statvfs -structures describing each currently mounted file system (see -.Xr statvfs 2 ) . -.Pp -The -.Fn getmntinfo -function -passes its -.Fa flags -parameter transparently to -.Xr getvfsstat 2 . -.Sh RETURN VALUES -On successful completion, -.Fn getmntinfo -returns a count of the number of elements in the array. -The pointer to the array is stored into -.Fa mntbufp . -.Pp -If an error occurs, zero is returned and the external variable -.Va errno -is set to indicate the error. -Although the pointer -.Fa mntbufp -will be unmodified, any information previously returned by -.Fn getmntinfo -will be lost. -.Sh ERRORS -The -.Fn getmntinfo -function -may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr getvfsstat 2 -or -.Xr malloc 3 . -.Sh SEE ALSO -.Xr getvfsstat 2 , -.Xr mount 2 , -.Xr statvfs 2 , -.Xr mount 8 -.Sh HISTORY -The -.Fn getmntinfo -function first appeared in -.Bx 4.4 . -It was converted from using -.Xr getfsstat 2 -to -.Xr getvfsstat 2 -in -.Nx 3.0 . -.Sh BUGS -The -.Fn getmntinfo -function writes the array of structures to an internal static object -and returns -a pointer to that object. -Subsequent calls to -.Fn getmntinfo -will modify the same object. -.Pp -The memory allocated by -.Fn getmntinfo -cannot be -.Xr free 3 Ns 'd -by the application. diff --git a/lib/libc/gen/getmntinfo.c b/lib/libc/gen/getmntinfo.c deleted file mode 100644 index a8615c6a7..000000000 --- a/lib/libc/gen/getmntinfo.c +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: getmntinfo.c,v 1.17 2012/03/20 16:36:05 matt Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getmntinfo.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getmntinfo.c,v 1.17 2012/03/20 16:36:05 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include - -/* - * Return information about mounted filesystems. - */ -int -getmntinfo(struct statvfs **mntbufp, int flags) -{ - static struct statvfs *mntbuf; - static int mntsize; - static size_t bufsize; - - _DIAGASSERT(mntbufp != NULL); - - if (mntsize <= 0 && - (mntsize = getvfsstat(NULL, (size_t)0, MNT_NOWAIT)) == -1) - return (0); - if (bufsize > 0 && - (mntsize = getvfsstat(mntbuf, bufsize, flags)) == -1) - return (0); - while (bufsize <= mntsize * sizeof(struct statvfs)) { - if (mntbuf) - free(mntbuf); - bufsize = (mntsize + 1) * sizeof(struct statvfs); - if ((mntbuf = malloc(bufsize)) == NULL) - return (0); - if ((mntsize = getvfsstat(mntbuf, bufsize, flags)) == -1) - return (0); - } - *mntbufp = mntbuf; - return (mntsize); -} diff --git a/lib/libc/gen/getnetgrent.3 b/lib/libc/gen/getnetgrent.3 deleted file mode 100644 index 7e456937e..000000000 --- a/lib/libc/gen/getnetgrent.3 +++ /dev/null @@ -1,124 +0,0 @@ -.\" $NetBSD: getnetgrent.3,v 1.12 2003/08/07 16:42:50 agc Exp $ -.\" -.\" Copyright (c) 1992, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getnetgrent.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd January 16, 1999 -.Dt GETNETGRENT 3 -.Os -.Sh NAME -.Nm getnetgrent , -.Nm innetgr , -.Nm setnetgrent , -.Nm endnetgrent -.Nd netgroup database operations -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In netgroup.h -.Ft int -.Fn getnetgrent "const char **host" "const char **user" "const char **domain" -.Ft int -.Fn innetgr "const char *netgroup" "const char *host" "const char *user" "const char *domain" -.Ft void -.Fn setnetgrent "const char *netgroup" -.Ft void -.Fn endnetgrent void -.Sh DESCRIPTION -These functions operate on the netgroup database file which is described in -.Xr netgroup 5 . -.Pp -The database defines a set of netgroups, each made up of one or more triples: -.Bd -literal -offset indent -(host, user, domain) -.Ed -.Pp -that defines a combination of host, user and domain. -Any of the three fields may be specified as ``wildcards'' that match any -string. -.Pp -The function -.Fn getnetgrent -sets the three pointer arguments to the strings of the next member of the -current netgroup. -If any of the string pointers are -.Dv NULL -that field is considered a wildcard. -.Pp -The functions -.Fn setnetgrent -and -.Fn endnetgrent -set the current netgroup and terminate the current netgroup respectively. -If -.Fn setnetgrent -is called with a different netgroup than the previous call, an implicit -.Fn endnetgrent -is implied. -.Fn setnetgrent -also sets the offset to the first member of the netgroup. -.Pp -The function -.Fn innetgr -searches for a match of all fields within the specified group. -If any of the -.Sy host , -.Sy user , -or -.Sy domain -arguments are -.Dv NULL -those fields will match any string value in the netgroup member. -.Sh RETURN VALUES -The function -.Fn getnetgrent -returns 0 for ``no more netgroup members'' and 1 otherwise. -The function -.Fn innetgr -returns 1 for a successful match and 0 otherwise. -The functions -.Fn setnetgrent -and -.Fn endnetgrent -have no return value. -.Sh FILES -.Bl -tag -width /etc/netgroup -compact -.It Pa /etc/netgroup -netgroup database file -.El -.Sh SEE ALSO -.Xr netgroup 5 , -.Xr nsswitch.conf 5 -.Sh BUGS -The function -.Fn getnetgrent -returns pointers to dynamically allocated data areas that are free'd when -the function -.Fn endnetgrent -is called. diff --git a/lib/libc/gen/getnetgrent.c b/lib/libc/gen/getnetgrent.c deleted file mode 100644 index 410ef1c7b..000000000 --- a/lib/libc/gen/getnetgrent.c +++ /dev/null @@ -1,990 +0,0 @@ -/* $NetBSD: getnetgrent.c,v 1.42 2012/03/20 16:36:05 matt Exp $ */ - -/* - * Copyright (c) 1994 Christos Zoulas - * 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 ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getnetgrent.c,v 1.42 2012/03/20 16:36:05 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#define _NETGROUP_PRIVATE -#include -#include -#include -#include -#include -#include -#include - -#ifdef YP -#include -#include -#include -#endif - -#ifdef __weak_alias -__weak_alias(endnetgrent,_endnetgrent) -__weak_alias(getnetgrent,_getnetgrent) -__weak_alias(innetgr,_innetgr) -__weak_alias(setnetgrent,_setnetgrent) -#endif - -#define _NG_STAR(s) (((s) == NULL || *(s) == '\0') ? _ngstar : s) -#define _NG_EMPTY(s) ((s) == NULL ? "" : s) -#define _NG_ISSPACE(p) (isspace((unsigned char) (p)) || (p) == '\n') - -static const char _ngstar[] = "*"; -static struct netgroup *_nghead = NULL; -static struct netgroup *_nglist = NULL; -static DB *_ng_db; - -static int getstring(char **, int, __aconst char **); -static struct netgroup *getnetgroup(char **); -static int lookup(char *, char **, int); -static int addgroup(StringList *, char *); -static int in_check(const char *, const char *, const char *, - struct netgroup *); -static int in_find(StringList *, char *, const char *, const char *, - const char *); -static char *in_lookup1(const char *, const char *, int); -static int in_lookup(const char *, const char *, const char *, int); - -#ifdef NSSRC_FILES -static const ns_src default_files_nis[] = { - { NSSRC_FILES, NS_SUCCESS | NS_NOTFOUND }, -#ifdef YP - { NSSRC_NIS, NS_SUCCESS }, -#endif - { 0, 0 }, -}; -#endif - -/* - * getstring(): Get a string delimited by the character, skipping leading and - * trailing blanks and advancing the pointer - */ -static int -getstring(char **pp, int del, char __aconst **str) -{ - size_t len; - char *sp, *ep, *dp; - - _DIAGASSERT(pp != NULL); - _DIAGASSERT(str != NULL); - - /* skip leading blanks */ - for (sp = *pp; *sp && _NG_ISSPACE(*sp); sp++) - continue; - - /* accumulate till delimiter or space */ - for (ep = sp; *ep && *ep != del && !_NG_ISSPACE(*ep); ep++) - continue; - - /* hunt for the delimiter */ - for (dp = ep; *dp && *dp != del && _NG_ISSPACE(*dp); dp++) - continue; - - if (*dp != del) { - *str = NULL; - return 0; - } - - *pp = ++dp; - - len = (ep - sp) + 1; - if (len > 1) { - dp = malloc(len); - if (dp == NULL) - return 0; - (void)memcpy(dp, sp, len); - dp[len - 1] = '\0'; - } else - dp = NULL; - - *str = dp; - return 1; -} - - -/* - * getnetgroup(): Parse a netgroup, and advance the pointer - */ -static struct netgroup * -getnetgroup(char **pp) -{ - struct netgroup *ng; - - _DIAGASSERT(pp != NULL); - _DIAGASSERT(*pp != NULL); - - ng = malloc(sizeof(struct netgroup)); - if (ng == NULL) - return NULL; - - (*pp)++; /* skip '(' */ - if (!getstring(pp, ',', &ng->ng_host)) - goto badhost; - - if (!getstring(pp, ',', &ng->ng_user)) - goto baduser; - - if (!getstring(pp, ')', &ng->ng_domain)) - goto baddomain; - -#ifdef DEBUG_NG - { - char buf[1024]; - (void) fprintf(stderr, "netgroup %s\n", - _ng_print(buf, sizeof(buf), ng)); - } -#endif - return ng; - -baddomain: - if (ng->ng_user) - free(ng->ng_user); -baduser: - if (ng->ng_host) - free(ng->ng_host); -badhost: - free(ng); - return NULL; -} - -void -_ng_cycle(const char *grp, const StringList *sl) -{ - size_t i; - warnx("netgroup: Cycle in group `%s'", grp); - (void)fprintf(stderr, "groups: "); - for (i = 0; i < sl->sl_cur; i++) - (void)fprintf(stderr, "%s ", sl->sl_str[i]); - (void)fprintf(stderr, "\n"); -} - -static int _local_lookup(void *, void *, va_list); - -/*ARGSUSED*/ -static int -_local_lookup(void *rv, void *cb_data, va_list ap) -{ - char *name = va_arg(ap, char *); - char **line = va_arg(ap, char **); - int bywhat = va_arg(ap, int); - - DBT key, data; - size_t len; - char *ks; - int r; - - if (_ng_db == NULL) - return NS_UNAVAIL; - - len = strlen(name) + 2; - ks = malloc(len); - if (ks == NULL) - return NS_UNAVAIL; - - ks[0] = bywhat; - (void)memcpy(&ks[1], name, len - 1); - - key.data = (u_char *)ks; - key.size = len; - - r = (*_ng_db->get)(_ng_db, &key, &data, 0); - free(ks); - switch (r) { - case 0: - break; - case 1: - return NS_NOTFOUND; - case -1: - /* XXX: call endnetgrent() here ? */ - return NS_UNAVAIL; - } - - *line = strdup(data.data); - if (*line == NULL) - return NS_UNAVAIL; - return NS_SUCCESS; -} - -#ifdef YP -static int _nis_lookup(void *, void *, va_list); - -/*ARGSUSED*/ -static int -_nis_lookup(void *rv, void *cb_data, va_list ap) -{ - char *name = va_arg(ap, char *); - char **line = va_arg(ap, char **); - int bywhat = va_arg(ap, int); - - static char *__ypdomain; - int i; - const char *map = NULL; - - if(__ypdomain == NULL) { - switch (yp_get_default_domain(&__ypdomain)) { - case 0: - break; - case YPERR_RESRC: - return NS_TRYAGAIN; - default: - return NS_UNAVAIL; - } - } - - switch (bywhat) { - case _NG_KEYBYNAME: - map = "netgroup"; - break; - - case _NG_KEYBYUSER: - map = "netgroup.byuser"; - break; - - case _NG_KEYBYHOST: - map = "netgroup.byhost"; - break; - - default: - abort(); - } - - *line = NULL; - switch (yp_match(__ypdomain, map, name, (int)strlen(name), line, &i)) { - case 0: - return NS_SUCCESS; - case YPERR_KEY: - if (*line) - free(*line); - return NS_NOTFOUND; - default: - if (*line) - free(*line); - return NS_UNAVAIL; - } - /* NOTREACHED */ -} -#endif - -#ifdef NSSRC_FILES -/* - * lookup(): Find the given key in the database or yp, and return its value - * in *line; returns 1 if key was found, 0 otherwise - */ -static int -lookup(char *name, char **line, int bywhat) -{ - int r; - static const ns_dtab dtab[] = { - NS_FILES_CB(_local_lookup, NULL) - NS_NIS_CB(_nis_lookup, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(line != NULL); - - r = nsdispatch(NULL, dtab, NSDB_NETGROUP, "lookup", default_files_nis, - name, line, bywhat); - return (r == NS_SUCCESS) ? 1 : 0; -} -#else -static int -_local_lookupv(int *rv, void *cbdata, ...) -{ - int e; - va_list ap; - va_start(ap, cbdata); - e = _local_lookup(rv, cbdata, ap); - va_end(ap); - return e; -} - -static int -lookup(name, line, bywhat) - char *name; - char **line; - int bywhat; -{ - return _local_lookupv(NULL, NULL, name, line, bywhat) == NS_SUCCESS; -} -#endif - -/* - * _ng_parse(): Parse a line and return: _NG_ERROR: Syntax Error _NG_NONE: - * line was empty or a comment _NG_GROUP: line had a netgroup definition, - * returned in ng _NG_NAME: line had a netgroup name, returned in name - * - * Public since used by netgroup_mkdb - */ -int -_ng_parse(char **p, char **name, struct netgroup **ng) -{ - - _DIAGASSERT(p != NULL); - _DIAGASSERT(*p != NULL); - _DIAGASSERT(name != NULL); - _DIAGASSERT(ng != NULL); - - while (**p) { - if (**p == '#') - /* comment */ - return _NG_NONE; - - while (**p && _NG_ISSPACE(**p)) - /* skipblank */ - (*p)++; - - if (**p == '(') { - if ((*ng = getnetgroup(p)) == NULL) - return _NG_ERROR; - return _NG_GROUP; - } else { - char *np; - size_t i; - - for (np = *p; **p && !_NG_ISSPACE(**p); (*p)++) - continue; - if (np != *p) { - i = (*p - np) + 1; - *name = malloc(i); - if (*name == NULL) - return _NG_ERROR; - (void)memcpy(*name, np, i); - (*name)[i - 1] = '\0'; - return _NG_NAME; - } - } - } - return _NG_NONE; -} - - -/* - * addgroup(): Recursively add all the members of the netgroup to this group. - * returns 0 upon failure, nonzero upon success. - * grp is not a valid pointer after return (either free(3)ed or allocated - * to a stringlist). in either case, it shouldn't be used again. - */ -static int -addgroup(StringList *sl, char *grp) -{ - char *line, *p; - struct netgroup *ng; - char *name; - - _DIAGASSERT(sl != NULL); - _DIAGASSERT(grp != NULL); - -#ifdef DEBUG_NG - (void)fprintf(stderr, "addgroup(%s)\n", grp); -#endif - /* check for cycles */ - if (sl_find(sl, grp) != NULL) { - _ng_cycle(grp, sl); - free(grp); - return 0; - } - if (sl_add(sl, grp) == -1) { - free(grp); - return 0; - } - - /* Lookup this netgroup */ - line = NULL; - if (!lookup(grp, &line, _NG_KEYBYNAME)) { - if (line) - free(line); - return 0; - } - - p = line; - - for (;;) { - switch (_ng_parse(&p, &name, &ng)) { - case _NG_NONE: - /* Done with the line */ - free(line); - return 1; - - case _NG_GROUP: - /* new netgroup */ - /* add to the list */ - ng->ng_next = _nglist; - _nglist = ng; - break; - - case _NG_NAME: - /* netgroup name */ - if (!addgroup(sl, name)) - return 0; - break; - - case _NG_ERROR: - return 0; - - default: - abort(); - } - } -} - - -/* - * in_check(): Compare the spec with the netgroup - */ -static int -in_check(const char *host, const char *user, const char *domain, - struct netgroup *ng) -{ - - /* host may be NULL */ - /* user may be NULL */ - /* domain may be NULL */ - _DIAGASSERT(ng != NULL); - - if ((host != NULL) && (ng->ng_host != NULL) - && strcmp(ng->ng_host, host) != 0) - return 0; - - if ((user != NULL) && (ng->ng_user != NULL) - && strcmp(ng->ng_user, user) != 0) - return 0; - - if ((domain != NULL) && (ng->ng_domain != NULL) - && strcmp(ng->ng_domain, domain) != 0) - return 0; - - return 1; -} - - -/* - * in_find(): Find a match for the host, user, domain spec. - * grp is not a valid pointer after return (either free(3)ed or allocated - * to a stringlist). in either case, it shouldn't be used again. - */ -static int -in_find(StringList *sl, char *grp, const char *host, const char *user, - const char *domain) -{ - char *line, *p; - int i; - struct netgroup *ng; - char *name; - - _DIAGASSERT(sl != NULL); - _DIAGASSERT(grp != NULL); - /* host may be NULL */ - /* user may be NULL */ - /* domain may be NULL */ - -#ifdef DEBUG_NG - (void)fprintf(stderr, "in_find(%s)\n", grp); -#endif - /* check for cycles */ - if (sl_find(sl, grp) != NULL) { - _ng_cycle(grp, sl); - free(grp); - return 0; - } - if (sl_add(sl, grp) == -1) { - free(grp); - return 0; - } - - /* Lookup this netgroup */ - line = NULL; - if (!lookup(grp, &line, _NG_KEYBYNAME)) { - if (line) - free(line); - return 0; - } - - p = line; - - for (;;) { - switch (_ng_parse(&p, &name, &ng)) { - case _NG_NONE: - /* Done with the line */ - free(line); - return 0; - - case _NG_GROUP: - /* new netgroup */ - i = in_check(host, user, domain, ng); - if (ng->ng_host != NULL) - free(ng->ng_host); - if (ng->ng_user != NULL) - free(ng->ng_user); - if (ng->ng_domain != NULL) - free(ng->ng_domain); - free(ng); - if (i) { - free(line); - return 1; - } - break; - - case _NG_NAME: - /* netgroup name */ - if (in_find(sl, name, host, user, domain)) { - free(line); - return 1; - } - break; - - case _NG_ERROR: - free(line); - return 0; - - default: - abort(); - } - } -} - -/* - * _ng_makekey(): Make a key from the two names given. The key is of the form - * . Names strings are replaced with * if they are empty; - * Returns NULL if there's a problem. - */ -char * -_ng_makekey(const char *s1, const char *s2, size_t len) -{ - char *buf; - - /* s1 may be NULL */ - /* s2 may be NULL */ - - buf = malloc(len); - if (buf != NULL) - (void)snprintf(buf, len, "%s.%s", _NG_STAR(s1), _NG_STAR(s2)); - return buf; -} - -void -_ng_print(char *buf, size_t len, const struct netgroup *ng) -{ - _DIAGASSERT(buf != NULL); - _DIAGASSERT(ng != NULL); - - (void)snprintf(buf, len, "(%s,%s,%s)", _NG_EMPTY(ng->ng_host), - _NG_EMPTY(ng->ng_user), _NG_EMPTY(ng->ng_domain)); -} - - -/* - * in_lookup1(): Fast lookup for a key in the appropriate map - */ -static char * -in_lookup1(const char *key, const char *domain, int map) -{ - char *line; - size_t len; - char *ptr; - int res; - - /* key may be NULL */ - /* domain may be NULL */ - - len = (key ? strlen(key) : 1) + (domain ? strlen(domain) : 1) + 2; - ptr = _ng_makekey(key, domain, len); - if (ptr == NULL) - return NULL; - res = lookup(ptr, &line, map); - free(ptr); - return res ? line : NULL; -} - - -/* - * in_lookup(): Fast lookup for a key in the appropriate map - */ -static int -in_lookup(const char *group, const char *key, const char *domain, int map) -{ - size_t len; - char *ptr, *line; - - _DIAGASSERT(group != NULL); - /* key may be NULL */ - /* domain may be NULL */ - - if (domain != NULL) { - /* Domain specified; look in "group.domain" and "*.domain" */ - if ((line = in_lookup1(key, domain, map)) == NULL) - line = in_lookup1(NULL, domain, map); - } else - line = NULL; - - if (line == NULL) { - /* - * domain not specified or domain lookup failed; look in - * "group.*" and "*.*" - */ - if (((line = in_lookup1(key, NULL, map)) == NULL) && - ((line = in_lookup1(NULL, NULL, map)) == NULL)) - return 0; - } - - len = strlen(group); - - for (ptr = line; (ptr = strstr(ptr, group)) != NULL;) - /* Make sure we did not find a substring */ - if ((ptr != line && ptr[-1] != ',') || - (ptr[len] != '\0' && strchr("\n\t ,", ptr[len]) == NULL)) - ptr++; - else { - free(line); - return 1; - } - - free(line); - return 0; -} - -/*ARGSUSED*/ -static int -_local_endnetgrent(void *rv, void *cb_data, va_list ap) -{ - for (_nglist = _nghead; _nglist != NULL; _nglist = _nghead) { - _nghead = _nglist->ng_next; - if (_nglist->ng_host != NULL) - free(_nglist->ng_host); - if (_nglist->ng_user != NULL) - free(_nglist->ng_user); - if (_nglist->ng_domain != NULL) - free(_nglist->ng_domain); - free(_nglist); - } - - if (_ng_db) { - (void)(*_ng_db->close)(_ng_db); - _ng_db = NULL; - } - - return NS_SUCCESS; -} - -/*ARGSUSED*/ -static int -_local_setnetgrent(void *rv, void *cb_data, va_list ap) -{ - const char *ng = va_arg(ap, const char *); - StringList *sl; - char *ng_copy; - - _DIAGASSERT(ng != NULL); - - sl = sl_init(); - if (sl == NULL) - return NS_TRYAGAIN; - - /* Cleanup any previous storage */ - if (_nghead != NULL) - endnetgrent(); - - if (_ng_db == NULL) - _ng_db = dbopen(_PATH_NETGROUP_DB, O_RDONLY, 0, DB_HASH, NULL); - - ng_copy = strdup(ng); - if (ng_copy != NULL) - addgroup(sl, ng_copy); - _nghead = _nglist; - sl_free(sl, 1); - - return NS_SUCCESS; -} - -/*ARGSUSED*/ -static int -_local_getnetgrent(void *rv, void *cb_data, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char **host = va_arg(ap, const char **); - const char **user = va_arg(ap, const char **); - const char **domain = va_arg(ap, const char **); - - _DIAGASSERT(host != NULL); - _DIAGASSERT(user != NULL); - _DIAGASSERT(domain != NULL); - - *retval = 0; - - if (_nglist == NULL) - return NS_TRYAGAIN; - - *host = _nglist->ng_host; - *user = _nglist->ng_user; - *domain = _nglist->ng_domain; - - _nglist = _nglist->ng_next; - - *retval = 1; - - return NS_SUCCESS; -} - -/*ARGSUSED*/ -static int -_local_innetgr(void *rv, void *cb_data, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *grp = va_arg(ap, const char *); - const char *host = va_arg(ap, const char *); - const char *user = va_arg(ap, const char *); - const char *domain = va_arg(ap, const char *); - - int found; - StringList *sl; - char *grcpy; - - _DIAGASSERT(grp != NULL); - /* host may be NULL */ - /* user may be NULL */ - /* domain may be NULL */ - - if (_ng_db == NULL) - _ng_db = dbopen(_PATH_NETGROUP_DB, O_RDONLY, 0, DB_HASH, NULL); - - /* Try the fast lookup first */ - if (host != NULL && user == NULL) { - if (in_lookup(grp, host, domain, _NG_KEYBYHOST)) { - *retval = 1; - return NS_SUCCESS; - } - } else if (host == NULL && user != NULL) { - if (in_lookup(grp, user, domain, _NG_KEYBYUSER)) { - *retval = 1; - return NS_SUCCESS; - } - } - /* If a domainname is given, we would have found a match */ - if (domain != NULL) { - *retval = 0; - return NS_SUCCESS; - } - - /* Too bad need the slow recursive way */ - sl = sl_init(); - if (sl == NULL) { - *retval = 0; - return NS_SUCCESS; - } - if ((grcpy = strdup(grp)) == NULL) { - sl_free(sl, 1); - *retval = 0; - return NS_SUCCESS; - } - found = in_find(sl, grcpy, host, user, domain); - sl_free(sl, 1); - - *retval = found; - return NS_SUCCESS; -} - -#ifdef YP - -/*ARGSUSED*/ -static int -_nis_endnetgrent(void *rv, void *cb_data, va_list ap) -{ - return _local_endnetgrent(rv, cb_data, ap); -} - -/*ARGSUSED*/ -static int -_nis_setnetgrent(void *rv, void *cb_data, va_list ap) -{ - return _local_setnetgrent(rv, cb_data, ap); -} - -/*ARGSUSED*/ -static int -_nis_getnetgrent(void *rv, void *cb_data, va_list ap) -{ - return _local_getnetgrent(rv, cb_data, ap); -} - -/*ARGSUSED*/ -static int -_nis_innetgr(void *rv, void *cb_data, va_list ap) -{ - return _local_innetgr(rv, cb_data, ap); -} - -#endif - - -#ifdef NSSRC_FILES -void -endnetgrent(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_local_endnetgrent, NULL) - NS_NIS_CB(_nis_endnetgrent, NULL) - NS_NULL_CB - }; - - (void) nsdispatch(NULL, dtab, NSDB_NETGROUP, "endnetgrent", - __nsdefaultcompat); -} -#else -static int -_local_endnetgrentv(int *rv, void *cbdata, ...) -{ - int e; - va_list ap; - va_start(ap, cbdata); - e = _local_endnetgrent(rv, cbdata, ap); - va_end(ap); - return e; -} - -void -endnetgrent(void) -{ - (void)_local_endnetgrentv(NULL, NULL, NULL); -} -#endif - -#ifdef NSSRC_FILES -void -setnetgrent(const char *ng) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_local_setnetgrent, NULL) - NS_NIS_CB(_nis_setnetgrent, NULL) - NS_NULL_CB - }; - - (void) nsdispatch(NULL, dtab, NSDB_NETGROUP, "setnetgrent", - __nsdefaultnis, ng); -} -#else -static int -_local_setnetgrentv(int *rv, void *cbdata, ...) -{ - int e; - va_list ap; - va_start(ap, cbdata); - e = _local_setnetgrent(rv, cbdata, ap); - va_end(ap); - return e; -} - -void -setnetgrent(const char *ng) -{ - (void) _local_setnetgrentv(NULL, NULL,ng); -} - -#endif - -#ifdef NSSRC_FILES -int -getnetgrent(const char **host, const char **user, const char **domain) -{ - int r, retval; - static const ns_dtab dtab[] = { - NS_FILES_CB(_local_getnetgrent, NULL) - NS_NIS_CB(_nis_getnetgrent, NULL) - NS_NULL_CB - }; - - r = nsdispatch(NULL, dtab, NSDB_NETGROUP, "getnetgrent", - __nsdefaultnis, &retval, host, user, domain); - - return (r == NS_SUCCESS) ? retval : 0; -} -#else -static int -_local_getnetgrentv(int *rv, void *cbdata, ...) -{ - int e; - va_list ap; - va_start(ap, cbdata); - e = _local_getnetgrent(rv, cbdata, ap); - va_end(ap); - return e; -} - -int -getnetgrent(const char **host, const char **user, const char **domain) -{ - return _local_getnetgrentv(NULL, NULL, host, user, domain) == NS_SUCCESS; -} -#endif - -#ifdef NSSRC_FILES -int -innetgr(const char *grp, const char *host, const char *user, - const char *domain) -{ - int r, retval; - static const ns_dtab dtab[] = { - NS_FILES_CB(_local_innetgr, NULL) - NS_NIS_CB(_nis_innetgr, NULL) - NS_NULL_CB - }; - - r = nsdispatch(NULL, dtab, NSDB_NETGROUP, "innetgr", - __nsdefaultnis, &retval, grp, host, user, domain); - - return (r == NS_SUCCESS) ? retval : 0; -} -#else -static int -_local_innetgrv(int *rv, void *cbdata, ...) -{ - int e; - va_list ap; - va_start(ap, cbdata); - e = _local_innetgr(rv, cbdata, ap); - va_end(ap); - return e; -} - -int -innetgr(const char *grp, const char *host, const char *user, - const char *domain) -{ - return _local_innetgrv(NULL, NULL, grp, host, user, domain) == NS_SUCCESS; -} -#endif diff --git a/lib/libc/gen/getpagesize.3 b/lib/libc/gen/getpagesize.3 deleted file mode 100644 index 51b68e664..000000000 --- a/lib/libc/gen/getpagesize.3 +++ /dev/null @@ -1,66 +0,0 @@ -.\" $NetBSD: getpagesize.3,v 1.12 2003/08/07 16:42:50 agc Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)getpagesize.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt GETPAGESIZE 3 -.Os -.Sh NAME -.Nm getpagesize -.Nd get system page size -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn getpagesize void -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by -.Xr sysconf 3 . -.Ef -.Pp -.Fn getpagesize -returns the number of bytes in a page. -Page granularity is the granularity of many of the memory management calls. -.Pp -The page size is a -.Em system -page size and may not be the same as the underlying -hardware page size. -.Sh SEE ALSO -.Xr pagesize 1 , -.Xr sbrk 2 , -.Xr sysconf 3 -.Sh HISTORY -The -.Nm -function call appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/getpagesize.c b/lib/libc/gen/getpagesize.c deleted file mode 100644 index 8353788e4..000000000 --- a/lib/libc/gen/getpagesize.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: getpagesize.c,v 1.11 2012/06/24 15:26:03 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getpagesize.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getpagesize.c,v 1.11 2012/06/24 15:26:03 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getpagesize,_getpagesize) -#endif - -int -getpagesize(void) -{ - static int pagsz; - - if (pagsz == 0) { - int mib[2]; - size_t size; - - mib[0] = CTL_HW; - mib[1] = HW_PAGESIZE; - size = sizeof pagsz; - if (sysctl(mib, 2, &pagsz, &size, NULL, 0) == -1) - return (-1); - _DIAGASSERT(pagsz); - } - return (pagsz); -} diff --git a/lib/libc/gen/getpass.3 b/lib/libc/gen/getpass.3 deleted file mode 100644 index da8d19694..000000000 --- a/lib/libc/gen/getpass.3 +++ /dev/null @@ -1,200 +0,0 @@ -.\" $NetBSD: getpass.3,v 1.22 2012/04/14 10:34:29 wiz Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getpass.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 13, 2012 -.Dt GETPASS 3 -.Os -.Sh NAME -.Nm getpass -.Nd get a password -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft char * -.Fn getpass "const char *prompt" -.Ft char * -.Fn getpass_r "const char *prompt" "char *buf" "size_t buflen" -.Ft char * -.Fn getpassfd "const char *prompt" "char *buf" "size_t buflen" "int *fd" "int flags" "int timeout" -.Sh DESCRIPTION -The -.Fn getpass -function displays a prompt to, and reads in a password from, -.Pa /dev/tty . -If this file is not accessible, -.Fn getpass -displays the prompt on the standard error output and reads from the standard -input. -.Pp -The password may be up to -.Xr sysconf 3 -.Dv _SC_PASS_MAX -characters in length. -Any additional -characters and the terminating newline character are discarded. -.Pp -.Fn getpass -turns off character echoing while reading the password. -.Pp -.Fn getpass_r -is similar to -.Fn getpass -only it puts its result in -.Fa buf -for up to -.Fa buflen -characters. -If the -.Fa buf -argument is -.Dv NULL , -then a buffer will be dynamically allocated. -.Pp -The -.Fn getpassfd -function allows one to specify the three file descriptors corresponding to -.Dv stdin , -.Dv stdout , -and -.Dv stderr -in the -.Fa fd -argument, or if -.Fa fd -is -.Dv NULL , -.Fn getpassfd -first attempts to open -.Pa /dev/tty -and if that fails, defaults to -.Dv STDIN_FILENO -for input and -.Dv STDERR_FILENO -for output. -.Pp -The behavior of -.Fn getpassfd -is controlled by the -.Fa flags -argument: -.Bl -tag -width GETPASS_FORCE_UPPER -.It Dv GETPASS_NEED_TTY -Fail if we are unable to set the tty modes like we want. -.It Dv GETPASS_FAIL_EOF -Fail if we get the end-of-file character instead of returning the result so far. -.It Dv GETPASS_BUF_LIMIT -Beep when the buffer limit is reached, instead of silently absorbing it. -.It Dv GETPASS_NO_SIGNAL -Don't make ttychars send signals. -.It Dv GETPASS_NO_BEEP -Don't beep if we erase past the beginning of the buffer or we try to enter past -the end. -.It Dv GETPASS_ECHO_STAR -Echo a -.Sq * -for each character entered. -.It Dv GETPASS_ECHO -Echo characters as they are typed. -.It Dv GETPASS_ECHO_NL -Echoes a newline if successful. -.It Dv GETPASS_7BIT -Mask the high bit for each entered character. -.It Dv GETPASS_FORCE_LOWER -Lowercase each entered character. -.It Dv GETPASS_FORCE_UPPER -Uppercase each entered character. -.El -.Pp -Finally if the -.Fa timeout -argument is non zero, -.Fn getpassfd -will wait for -.Fa timeout -seconds for input after each character before returning an error, instead of -waiting forever. -.Sh RETURN VALUES -The -.Fn getpass -function returns a pointer to the NUL terminated password, or an empty -string on error. -The -.Fn getpass_r -and -.Fn getpassfd -functions return a pointer to the NUL terminated password, or -.Dv NULL -on error. -.Sh FILES -.Bl -tag -width /dev/tty -compact -.It Pa /dev/tty -.El -.Sh SEE ALSO -.Xr crypt 3 -.Sh STANDARDS -The -.Fn getpass -function appeared in -.St -susv2 , -but it was already marked as legacy. -The function was removed in the -.St -p1003.1-2001 -standard. -.Sh HISTORY -A -.Fn getpass -function appeared in -.At v7 . -The -.Fn getpass_r -and -.Fn getpassfd -functions appeared in -.Nx 7.0 . -.Sh BUGS -The -.Fn getpass -function leaves its result in an internal static object and returns -a pointer to that object. -Subsequent calls to -.Fn getpass -will modify the same object. -.Sh SECURITY CONSIDERATIONS -The calling process should zero the password as soon as possible to -avoid leaving the cleartext password visible in the process's address -space. -.Pp -Historically -.Nm -accepted and returned a password if it could not modify the terminal -settings to turn echo off (or if the input was not a terminal). -In this implementation, only terminal input is accepted. diff --git a/lib/libc/gen/getpass.c b/lib/libc/gen/getpass.c deleted file mode 100644 index 173d2860b..000000000 --- a/lib/libc/gen/getpass.c +++ /dev/null @@ -1,361 +0,0 @@ -/* $NetBSD: getpass.c,v 1.29 2014/09/18 13:58:20 christos Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getpass.c,v 1.29 2014/09/18 13:58:20 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#ifdef TEST -#include -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(getpassfd,_getpassfd) -__weak_alias(getpass_r,_getpass_r) -__weak_alias(getpass,_getpass) -#endif - -/* - * Notes: - * - There is no getpass_r in POSIX - * - Historically EOF is documented to be treated as EOL, we provide a - * tunable for that GETPASS_FAIL_EOF to disable this. - * - Historically getpass ate extra characters silently, we provide - * a tunable for that GETPASS_BUF_LIMIT to disable this. - * - Historically getpass "worked" by echoing characters when turning - * off echo failed, we provide a tunable GETPASS_NEED_TTY to - * disable this. - * - Some implementations say that on interrupt the program shall - * receive an interrupt signal before the function returns. We - * send all the tty signals before we return, but we don't expect - * suspend to do something useful unless the caller calls us again. - * We also provide a tunable to disable signal delivery - * GETPASS_NO_SIGNAL. - * - GETPASS_NO_BEEP disables beeping. - * - GETPASS_ECHO_STAR will echo '*' for each character of the password - * - GETPASS_ECHO will echo the password (as pam likes it) - * - GETPASS_7BIT strips the 8th bit - * - GETPASS_FORCE_UPPER forces to uppercase - * - GETPASS_FORCE_LOWER forces to uppercase - * - GETPASS_ECHO_NL echo's a new line on success if echo was off. - */ -char * -/*ARGSUSED*/ -getpassfd(const char *prompt, char *buf, size_t len, int *fd, int flags, - int tout) -{ - struct termios gt; - char c; - int sig; - bool lnext, havetty, allocated, opentty, good; - int fdc[3]; - - _DIAGASSERT(prompt != NULL); - - if (buf != NULL && len == 0) { - errno = EINVAL; - return NULL; - } - - good = false; - opentty = false; - if (fd == NULL) { - /* - * Try to use /dev/tty if possible; otherwise read from stdin - * and write to stderr. - */ - fd = fdc; - if ((fd[0] = fd[1] = fd[2] = open(_PATH_TTY, - O_RDWR | O_CLOEXEC)) == -1) { - fd[0] = STDIN_FILENO; - fd[1] = fd[2] = STDERR_FILENO; - } else - opentty = true; - } - - sig = 0; - allocated = buf == NULL; - if (tcgetattr(fd[0], >) == -1) { - havetty = false; - if (flags & GETPASS_NEED_TTY) - goto out; - memset(>, -1, sizeof(gt)); - } else - havetty = true; - - if (havetty) { - struct termios st = gt; - - st.c_lflag &= ~(ECHO|ECHOK|ECHOE|ECHOKE|ECHOCTL|ISIG|ICANON); - st.c_cc[VMIN] = 1; - st.c_cc[VTIME] = 0; - if (tcsetattr(fd[0], TCSAFLUSH|TCSASOFT, &st) == -1) - goto out; - } - - if (prompt != NULL) { - size_t plen = strlen(prompt); - (void)write(fd[1], prompt, plen); - } - - if (allocated) { - len = 1024; - if ((buf = malloc(len)) == NULL) - goto restore; - } - - c = '\1'; - lnext = false; - for (size_t l = 0; c != '\0'; ) { - if (tout) { - struct pollfd pfd; - pfd.fd = fd[0]; - pfd.events = POLLIN|POLLRDNORM; - pfd.revents = 0; - switch (poll(&pfd, 1, tout * 1000)) { - case 0: - errno = ETIMEDOUT; - /*FALLTHROUGH*/ - case -1: - goto restore; - default: - break; - } - } - if (read(fd[0], &c, 1) != 1) - goto restore; - -#define beep() \ - do \ - if (flags & GETPASS_NO_BEEP) \ - (void)write(fd[2], "\a", 1); \ - while (/*CONSTCOND*/ 0) -#define erase() (void)write(fd[1], "\b \b", 3) -/* - * We test for both _POSIX_VDISABLE and NUL here because _POSIX_VDISABLE - * propagation does not seem to be very consistent on multiple daemon hops - * between different OS's. Perhaps we should not even bother with - * _POSIX_VDISABLE and use ~0 and 0 directly. - */ -#define C(a, b) ((gt.c_cc[(a)] == _POSIX_VDISABLE || gt.c_cc[(a)] == '\0') ? \ - (b) : gt.c_cc[(a)]) - if (lnext) { - lnext = false; - goto add; - } - - /* Ignored */ - if (c == C(VREPRINT, CTRL('r')) || c == C(VSTART, CTRL('q')) || - c == C(VSTOP, CTRL('s')) || c == C(VSTATUS, CTRL('t')) || - c == C(VDISCARD, CTRL('o'))) - continue; - - /* Literal next */ - if (c == C(VLNEXT, CTRL('v'))) { - lnext = true; - continue; - } - - /* Line or word kill, treat as reset */ - if (c == C(VKILL, CTRL('u')) || c == C(VWERASE, CTRL('w'))) { - if (flags & (GETPASS_ECHO | GETPASS_ECHO_STAR)) { - while (l--) - erase(); - } - l = 0; - continue; - } - - /* Character erase */ - if (c == C(VERASE, CTRL('h'))) { - if (l == 0) - beep(); - else { - l--; - if (flags & (GETPASS_ECHO | GETPASS_ECHO_STAR)) - erase(); - } - continue; - } - - /* tty signal characters */ - if (c == C(VINTR, CTRL('c'))) { - sig = SIGINT; - goto out; - } - if (c == C(VQUIT, CTRL('\\'))) { - sig = SIGQUIT; - goto out; - } - if (c == C(VSUSP, CTRL('z')) || c == C(VDSUSP, CTRL('y'))) { - sig = SIGTSTP; - goto out; - } - - /* EOF */ - if (c == C(VEOF, CTRL('d'))) { - if (flags & GETPASS_FAIL_EOF) { - errno = ENODATA; - goto out; - } else { - c = '\0'; - goto add; - } - } - - /* End of line */ - if (c == C(VEOL, CTRL('j')) || c == C(VEOL2, CTRL('m'))) - c = '\0'; -add: - if (l >= len) { - if (allocated) { - size_t nlen = len + 1024; - char *nbuf = realloc(buf, nlen); - if (nbuf == NULL) - goto restore; - buf = nbuf; - len = nlen; - } else { - if (flags & GETPASS_BUF_LIMIT) { - beep(); - continue; - } - if (c == '\0' && l > 0) - l--; - else - continue; - } - } - - if (flags & GETPASS_7BIT) - c &= 0x7f; - if ((flags & GETPASS_FORCE_LOWER) && isupper((unsigned char)c)) - c = tolower((unsigned char)c); - if ((flags & GETPASS_FORCE_UPPER) && islower((unsigned char)c)) - c = toupper((unsigned char)c); - - buf[l++] = c; - if (c) { - if (flags & GETPASS_ECHO_STAR) - (void)write(fd[1], "*", 1); - else if (flags & GETPASS_ECHO) - (void)write(fd[1], isprint((unsigned char)c) ? - &c : "?", 1); - } - } - good = true; - -restore: - if (havetty) { - c = errno; - (void)tcsetattr(fd[0], TCSAFLUSH|TCSASOFT, >); - errno = c; - } -out: - if (good && (flags & GETPASS_ECHO_NL)) - (void)write(fd[1], "\n", 1); - - if (opentty) { - c = errno; - (void)close(fd[0]); - errno = c; - } - - if (good) - return buf; - - if (sig) { - if ((flags & GETPASS_NO_SIGNAL) == 0) - (void)raise(sig); - errno = EINTR; - } - memset(buf, 0, len); - if (allocated) - free(buf); - return NULL; -} - -char * -getpass_r(const char *prompt, char *buf, size_t len) -{ - return getpassfd(prompt, buf, len, NULL, GETPASS_ECHO_NL, 0); -} - -char * -getpass(const char *prompt) -{ - static char e[] = ""; - static char *buf; - static long bufsiz; - char *rv; - - /* - * Strictly speaking we could double allocate here, if we get - * called at the same time, but this function is not re-entrant - * anyway and it is not supposed to work if called concurrently. - */ - if (buf == NULL) { - if ((bufsiz = sysconf(_SC_PASS_MAX)) == -1) - return e; - if ((buf = malloc((size_t)bufsiz)) == NULL) - return e; - } - - if ((rv = getpass_r(prompt, buf, (size_t)bufsiz)) == NULL) - return e; - - return rv; -} - -#ifdef TEST -int -main(int argc, char *argv[]) -{ - char buf[28]; - printf("[%s]\n", getpassfd("foo>", buf, sizeof(buf), NULL, - GETPASS_ECHO_STAR|GETPASS_ECHO_NL, 2)); - return 0; -} -#endif diff --git a/lib/libc/gen/getprogname.3 b/lib/libc/gen/getprogname.3 deleted file mode 100644 index 3dfc42480..000000000 --- a/lib/libc/gen/getprogname.3 +++ /dev/null @@ -1,117 +0,0 @@ -.\" $NetBSD: getprogname.3,v 1.8 2011/05/21 19:06:44 dholland Exp $ -.\" -.\" Copyright (c) 2001 Christopher G. Demetriou -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed for the -.\" NetBSD Project. See http://www.NetBSD.org/ for -.\" information about NetBSD. -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" 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. -.\" -.\" <> -.\" -.Dd May 21, 2011 -.Dt GETPROGNAME 3 -.Os -.Sh NAME -.Nm getprogname , -.Nm setprogname -.Nd get/set the name of the current program -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft const char * -.Fn getprogname "void" -.Ft void -.Fn setprogname "const char *name" -.Sh DESCRIPTION -These utility functions get and set the current program's name -as used by various error-reporting functions. -.Pp -.Fn getprogname -returns the name of the current program. -This function is typically useful when generating error messages -or other diagnostic output. -If the program name has not been set, -.Fn getprogname -will return -.Dv NULL . -.Pp -.Fn setprogname -sets the name of the current program to be the last pathname -component of the -.Fa name -argument. -It should be invoked at the start of the program, using the -.Fa argv[0] -passed into the program's -.Fn main -function. -A pointer into the string pointed to by the -.Fa name -argument is kept as the program name. -Therefore, the string pointed to by -.Fa name -should not be modified during the rest of the program's operation. -.Pp -A program's name can only be set once, and in -.Nx -that is actually -done by program start-up code that is run before -.Fn main -is called. -Therefore, in -.Nx , -calling -.Fn setprogname -explicitly has no effect. -However, portable programs that wish to use -.Fn getprogname -should call -.Fn setprogname -from -.Fn main . -On operating systems where -.Fn getprogname -and -.Fn setprogname -are implemented via a portability library, this call is needed to -make the name available. -.Sh SEE ALSO -.Xr err 3 , -.Xr setproctitle 3 -.Sh HISTORY -The -.Nm getprogname -and -.Nm setprogname -function calls appeared in -.Nx 1.6 . -.Sh RESTRICTIONS -The string returned by -.Fn getprogname -is supplied by the invoking process and should not be trusted by -setuid or setgid programs. diff --git a/lib/libc/gen/getprogname.c b/lib/libc/gen/getprogname.c deleted file mode 100644 index 6904fad6f..000000000 --- a/lib/libc/gen/getprogname.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: getprogname.c,v 1.4 2011/10/06 20:31:41 christos Exp $ */ - -/* - * Copyright (c) 2001 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getprogname.c,v 1.4 2011/10/06 20:31:41 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#ifdef __weak_alias -__weak_alias(getprogname,_getprogname) -#endif - -const char *__progname; - -const char * -getprogname(void) -{ - - return (__progname); -} diff --git a/lib/libc/gen/getpwent.3 b/lib/libc/gen/getpwent.3 deleted file mode 100644 index 5d55919cf..000000000 --- a/lib/libc/gen/getpwent.3 +++ /dev/null @@ -1,370 +0,0 @@ -.\" $NetBSD: getpwent.3,v 1.38 2011/04/28 16:35:05 wiz Exp $ -.\" -.\" Copyright (c) 1988, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getpwent.3 8.2 (Berkeley) 12/11/93 -.\" -.Dd April 30, 2008 -.Dt GETPWENT 3 -.Os -.Sh NAME -.Nm getpwent , -.Nm getpwent_r , -.Nm getpwnam , -.Nm getpwnam_r , -.Nm getpwuid , -.Nm getpwuid_r , -.Nm setpassent , -.Nm setpwent , -.Nm endpwent -.Nd password database operations -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In pwd.h -.Ft struct passwd * -.Fn getpwent void -.Ft int -.Fo getpwent_r -.Fa "struct passwd *pw" -.Fa "char *buffer" -.Fa "size_t buflen" -.Fa "struct passwd **result" -.Fc -.Ft struct passwd * -.Fn getpwnam "const char *name" -.Ft int -.Fo getpwnam_r -.Fa "const char *name" -.Fa "struct passwd *pw" -.Fa "char *buffer" -.Fa "size_t buflen" -.Fa "struct passwd **result" -.Fc -.Ft struct passwd * -.Fn getpwuid "uid_t uid" -.Ft int -.Fo getpwuid_r -.Fa "uid_t uid" -.Fa "struct passwd *pw" -.Fa "char *buffer" -.Fa "size_t buflen" -.Fa "struct passwd **result" -.Fc -.Ft int -.Fn setpassent "int stayopen" -.Ft void -.Fn setpwent void -.Ft void -.Fn endpwent void -.Sh DESCRIPTION -These functions -operate on the password database -which is described -in -.Xr passwd 5 . -Each entry in the database is defined by the structure -.Ar passwd -found in the include -file -.In pwd.h : -.Bd -literal -offset indent -struct passwd { - char *pw_name; /* user name */ - char *pw_passwd; /* encrypted password */ - uid_t pw_uid; /* user uid */ - gid_t pw_gid; /* user gid */ - time_t pw_change; /* password change time */ - char *pw_class; /* user login class */ - char *pw_gecos; /* general information */ - char *pw_dir; /* home directory */ - char *pw_shell; /* default shell */ - time_t pw_expire; /* account expiration */ -}; -.Ed -.Pp -The functions -.Fn getpwnam -and -.Fn getpwuid -search the password database for the given user name pointed to by -.Ar name -or user id pointed to by -.Ar uid -respectively, always returning the first one encountered. -Identical user names or user ids may result in undefined behavior. -.Pp -The -.Fn getpwent -function -sequentially reads the password database and is intended for programs -that wish to process the complete list of users. -.Pp -The functions -.Fn getpwnam_r , -.Fn getpwuid_r , -and -.Fn getpwent_r -act like their non re-entrant counterparts, updating the contents of -.Ar pw -and storing a pointer to that in -.Ar result , -and returning -.Dv 0 . -Storage used by -.Ar pw -is allocated from -.Ar buffer , -which is -.Ar buflen -bytes in size. -If the requested entry cannot be found, -.Ar result -will point to -.Dv NULL -and -.Dv 0 -will be returned. -If an error occurs, -a non-zero error number will be returned and -.Ar result -will point to -.Dv NULL . -Calling -.Fn getpwent_r -from multiple threads will result in each thread reading a disjoint portion -of the password database. -.Pp -The -.Fn setpassent -function -accomplishes two purposes. -First, it causes -.Fn getpwent -to -.Dq rewind -to the beginning of the database. -Additionally, if -.Fa stayopen -is non-zero, file descriptors are left open, significantly speeding -up subsequent accesses for all of the functions. -(This latter functionality is unnecessary for -.Fn getpwent -as it doesn't close its file descriptors by default.) -.Pp -It is dangerous for long-running programs to keep the file descriptors -open as the database will become out of date if it is updated while the -program is running. -.Pp -The -.Fn setpwent -function -is equivalent to -.Fn setpassent -with an argument of zero. -.Pp -The -.Fn endpwent -function -closes any open files. -.Pp -These functions have been written to -.Dq shadow -the password file, e.g. allow only certain programs to have access -to the encrypted password. -If the process which calls them has an effective uid of 0, the encrypted -password will be returned, otherwise, the password field of the returned -structure will point to the string -.Ql * . -.Sh RETURN VALUES -The functions -.Fn getpwent , -.Fn getpwnam , -and -.Fn getpwuid , -return a valid pointer to a passwd structure on success -and a -.Dv NULL -pointer if the entry was not found or an error occured. -If an error occured, the global variable -.Dv errno -is set to indicate the nature of the failure. -The -.Fn setpassent -function returns 0 on failure, setting the global variable -.Dv errno -to indicate the nature of the failure, and 1 on success. -The -.Fn endpwent -and -.Fn setpwent -functions -have no return value. -The functions -.Fn getpwnam_r , -.Fn getpwuid_r , -and -.Fn getpwent_r -return -.Dv 0 -on success or entry not found, and non-zero on failure, setting the global -variable -.Dv errno -to indicate the nature of the failure. -.Sh FILES -.Bl -tag -width /etc/master.passwd -compact -.It Pa /etc/pwd.db -The insecure password database file -.It Pa /etc/spwd.db -The secure password database file -.It Pa /etc/master.passwd -The current password file -.It Pa /etc/passwd -A Version 7 format password file -.El -.Sh COMPATIBILITY -The historic function -.Fn setpwfile -which allowed the specification of alternative password databases, -has been deprecated and is no longer available. -.Sh ERRORS -The following error codes may be set in -.Va errno -for -.Nm getpwent , -.Nm getpwent_r , -.Nm getpwnam , -.Nm getpwnam_r , -.Nm getpwuid , -.Nm getpwuid_r , -and -.Nm setpassent : -.Bl -tag -width Er -.It Bq Er EINTR -A signal was caught during the database search. -.It Bq Er EIO -An I/O error has occurred. -.It Bq Er EMFILE -The limit on open files for this process has been reached. -.It Bq Er ENFILE -The system limit on open files has been reached. -.El -.Pp -The following error code may be set in -.Va errno -for -.Nm getpwent_r , -.Nm getpwnam_r , -and -.Nm getpwuid_r : -.Bl -tag -width Er -.It Bq Er ERANGE -The resulting -.Ft struct passwd -does not fit in the space defined by -.Dv buffer -and -.Dv buflen -.El -.Pp -Other -.Dv errno -values may be set depending on the specific database backends. -.Sh SEE ALSO -.Xr getlogin 2 , -.Xr getgrent 3 , -.Xr nsswitch.conf 5 , -.Xr passwd 5 , -.Xr passwd.conf 5 , -.Xr pwd_mkdb 8 , -.Xr vipw 8 -.Sh STANDARDS -The -.Fn getpwnam -and -.Fn getpwuid , -functions conform to -.St -p1003.1-90 . -The -.Fn getpwnam_r -and -.Fn getpwuid_r -functions conform to -.St -p1003.1c-95 . -The -.Fn endpwent , -.Fn getpwent , -and -.Fn setpwent -functions conform to -.St -xpg4.2 -and -.St -p1003.1-2004 -(XSI extension). -.Sh HISTORY -The -.Nm getpwent , -.Nm getpwnam , -.Nm getpwuid , -.Nm setpwent , -and -.Nm endpwent -functions appeared in -.At v7 . -The -.Nm setpassent -function appeared in -.Bx 4.3 Reno . -The functions -.Fn getpwnam_r -and -.Fn getpwuid_r -appeared in -.Nx 3.0 . -.Sh BUGS -The functions -.Fn getpwent , -.Fn getpwnam , -and -.Fn getpwuid , -leave their results in an internal static object and return -a pointer to that object. -Subsequent calls to any of these functions will modify the same object. -.Pp -The functions -.Fn getpwent , -.Fn endpwent , -.Fn setpassent , -and -.Fn setpwent -are fairly useless in a networked environment and should be -avoided, if possible. -.Fn getpwent -makes no attempt to suppress duplicate information if multiple -sources are specified in -.Xr nsswitch.conf 5 . diff --git a/lib/libc/gen/getpwent.c b/lib/libc/gen/getpwent.c deleted file mode 100644 index eda173cf6..000000000 --- a/lib/libc/gen/getpwent.c +++ /dev/null @@ -1,2605 +0,0 @@ -/* $NetBSD: getpwent.c,v 1.81 2012/09/08 15:15:06 dholland Exp $ */ - -/*- - * Copyright (c) 1997-2000, 2004-2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Portions Copyright (c) 1994, 1995, Jason Downs. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS - * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, - * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR - * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER - * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getpwent.c 8.2 (Berkeley) 4/27/95"; -#else -__RCSID("$NetBSD: getpwent.c,v 1.81 2012/09/08 15:15:06 dholland Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HESIOD -#include -#endif - -#ifdef YP -#include -#include -#include -#include -#endif - -#include "pw_private.h" - -#define _PASSWD_COMPAT /* "passwd" defaults to compat, so always provide it */ - -#ifdef __weak_alias -__weak_alias(endpwent,_endpwent) -__weak_alias(setpassent,_setpassent) -__weak_alias(setpwent,_setpwent) -#endif - -#ifdef _REENTRANT -static mutex_t _pwmutex = MUTEX_INITIALIZER; -#endif - -const char __yp_token[] = "__YP!"; /* Let pwd_mkdb pull this in. */ - - -/* - * The pwd.db lookup techniques and data extraction code here must be kept - * in sync with that in `pwd_mkdb'. - */ - -#if defined(YP) || defined(HESIOD) -/* - * _pw_parse - * Parses entry using pw_scan(3) (without the trailing \n) - * after copying to buf, and fills in pw with corresponding values. - * If old is non-zero, entry is in _PASSWORD_OLDFMT. - * Returns 1 if parsed successfully, 0 on parse failure. - */ -static int -_pw_parse(const char *entry, struct passwd *pw, char *buf, size_t buflen, - int old) -{ - int flags; - - _DIAGASSERT(entry != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buf != NULL); - - if (strlcpy(buf, entry, buflen) >= buflen) - return 0; - flags = _PASSWORD_NOWARN; - if (old) - flags |= _PASSWORD_OLDFMT; - return __pw_scan(buf, pw, &flags); -} -#endif /* YP || HESIOD */ - -/* - * _pw_opendb - * if *db is NULL, dbopen(3) /etc/spwd.db or /etc/pwd.db (depending - * upon permissions, etc) - */ -static int -_pw_opendb(DB **db, int *version) -{ - static int warned; - DBT key; - DBT value; - - const char *dbfile = NULL; - - _DIAGASSERT(db != NULL); - _DIAGASSERT(version != NULL); - if (*db != NULL) /* open *db */ - return NS_SUCCESS; - - if (geteuid() == 0) { - dbfile = _PATH_SMP_DB; - *db = dbopen(dbfile, O_RDONLY, 0, DB_HASH, NULL); - } - if (*db == NULL) { - dbfile = _PATH_MP_DB; - *db = dbopen(dbfile, O_RDONLY, 0, DB_HASH, NULL); - } - if (*db == NULL) { - if (!warned) { - int serrno = errno; - syslog(LOG_ERR, "%s: %m", dbfile); - errno = serrno; - } - warned = 1; - return NS_UNAVAIL; - } - key.data = __UNCONST("VERSION"); - key.size = strlen((char *)key.data) + 1; - switch ((*(*db)->get)(*db, &key, &value, 0)) { - case 0: - if (sizeof(*version) != value.size) - return NS_UNAVAIL; - (void)memcpy(version, value.data, value.size); - break; /* found */ - case 1: - *version = 0; /* not found */ - break; - case -1: - return NS_UNAVAIL; /* error in db routines */ - default: - abort(); - } - return NS_SUCCESS; -} - -/* - * _pw_getkey - * Lookup key in *db, filling in pw - * with the result, allocating memory from buffer (size buflen). - * (The caller may point key.data to buffer on entry; the contents - * of key.data will be invalid on exit.) - */ -static int -_pw_getkey(DB *db, DBT *key, - struct passwd *pw, char *buffer, size_t buflen, int *pwflags, - int version) -{ - char *p, *t; - DBT data; - - _DIAGASSERT(db != NULL); - _DIAGASSERT(key != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - /* pwflags may be NULL (if we don't care about them */ - - if (db == NULL) /* this shouldn't happen */ - return NS_UNAVAIL; - - switch ((db->get)(db, key, &data, 0)) { - case 0: - break; /* found */ - case 1: - return NS_NOTFOUND; /* not found */ - case -1: - return NS_UNAVAIL; /* error in db routines */ - default: - abort(); - } - - p = (char *)data.data; - if (data.size > buflen) { - errno = ERANGE; - return NS_UNAVAIL; - } - - /* - * THE DECODING BELOW MUST MATCH THAT IN pwd_mkdb. - */ - t = buffer; -#define MACRO(a) do { a } while (/*CONSTCOND*/0) -#define EXPAND(e) MACRO(e = t; while ((*t++ = *p++));) -#define SCALAR(v) MACRO(memmove(&(v), p, sizeof v); p += sizeof v;) - EXPAND(pw->pw_name); - EXPAND(pw->pw_passwd); - SCALAR(pw->pw_uid); - SCALAR(pw->pw_gid); - if (version == 0) { - int32_t tmp; - SCALAR(tmp); - pw->pw_change = tmp; - } else - SCALAR(pw->pw_change); - EXPAND(pw->pw_class); - EXPAND(pw->pw_gecos); - EXPAND(pw->pw_dir); - EXPAND(pw->pw_shell); - if (version == 0) { - int32_t tmp; - SCALAR(tmp); - pw->pw_expire = tmp; - } else - SCALAR(pw->pw_expire); - if (pwflags) { - /* See if there's any data left. If so, read in flags. */ - if (data.size > (size_t) (p - (char *)data.data)) { - SCALAR(*pwflags); - } else { /* default */ - *pwflags = _PASSWORD_NOUID|_PASSWORD_NOGID; - } - } - - return NS_SUCCESS; -} - -/* - * _pw_memfrombuf - * Obtain want bytes from buffer (of size buflen) and return a pointer - * to the available memory after adjusting buffer/buflen. - * Returns NULL if there is insufficient space. - */ -static char * -_pw_memfrombuf(size_t want, char **buffer, size_t *buflen) -{ - char *rv; - - if (want > *buflen) { - errno = ERANGE; - return NULL; - } - rv = *buffer; - *buffer += want; - *buflen -= want; - return rv; -} - -/* - * _pw_copy - * Copy the contents of frompw to pw; memory for strings - * and arrays will be allocated from buf (of size buflen). - * If proto != NULL, use various fields in proto in preference to frompw. - * Returns 1 if copied successfully, 0 on copy failure. - * NOTE: frompw must not use buf for its own pointers. - */ -static int -_pw_copy(const struct passwd *frompw, struct passwd *pw, - char *buf, size_t buflen, const struct passwd *protopw, int protoflags) -{ - size_t count; - int useproto; - - _DIAGASSERT(frompw != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buf != NULL); - /* protopw may be NULL */ - - useproto = protopw && protopw->pw_name; - -#define COPYSTR(to, from) \ - do { \ - count = strlen((from)); \ - (to) = _pw_memfrombuf(count+1, &buf, &buflen); \ - if ((to) == NULL) \ - return 0; \ - memmove((to), (from), count); \ - to[count] = '\0'; \ - } while (0) /* LINTED */ - -#define COPYFIELD(field) COPYSTR(pw->field, frompw->field) - -#define COPYPROTOFIELD(field) COPYSTR(pw->field, \ - (useproto && *protopw->field ? protopw->field : frompw->field)) - - COPYFIELD(pw_name); - -#ifdef PW_OVERRIDE_PASSWD - COPYPROTOFIELD(pw_passwd); -#else - COPYFIELD(pw_passwd); -#endif - - if (useproto && !(protoflags & _PASSWORD_NOUID)) - pw->pw_uid = protopw->pw_uid; - else - pw->pw_uid = frompw->pw_uid; - - if (useproto && !(protoflags & _PASSWORD_NOGID)) - pw->pw_gid = protopw->pw_gid; - else - pw->pw_gid = frompw->pw_gid; - - pw->pw_change = frompw->pw_change; - COPYFIELD(pw_class); - COPYPROTOFIELD(pw_gecos); - COPYPROTOFIELD(pw_dir); - COPYPROTOFIELD(pw_shell); - -#undef COPYSTR -#undef COPYFIELD -#undef COPYPROTOFIELD - - return 1; -} - - - /* - * files methods - */ - - /* state shared between files methods */ -struct files_state { - int stayopen; /* see getpassent(3) */ - DB *db; /* passwd file handle */ - int keynum; /* key counter, -1 if no more */ - int version; -}; - -static struct files_state _files_state; - /* storage for non _r functions */ -static struct passwd _files_passwd; -static char _files_passwdbuf[_GETPW_R_SIZE_MAX]; - -static int -_files_start(struct files_state *state) -{ - int rv; - - _DIAGASSERT(state != NULL); - - state->keynum = 0; - rv = _pw_opendb(&state->db, &state->version); - if (rv != NS_SUCCESS) - return rv; - return NS_SUCCESS; -} - -static int -_files_end(struct files_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->keynum = 0; - if (state->db) { - (void)(state->db->close)(state->db); - state->db = NULL; - } - return NS_SUCCESS; -} - -/* - * _files_pwscan - * Search state->db for the next desired entry. - * If search is _PW_KEYBYNUM, look for state->keynum. - * If search is _PW_KEYBYNAME, look for name. - * If search is _PW_KEYBYUID, look for uid. - * Sets *retval to the errno if the result is not NS_SUCCESS - * or NS_NOTFOUND. - */ -static int -_files_pwscan(int *retval, struct passwd *pw, char *buffer, size_t buflen, - struct files_state *state, int search, const char *name, uid_t uid) -{ - const void *from; - size_t fromlen; - DBT key; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - /* name is NULL to indicate searching for uid */ - - *retval = 0; - - if (state->db == NULL) { /* only start if file not open yet */ - rv = _files_start(state); - if (rv != NS_SUCCESS) - goto filespwscan_out; - } - - for (;;) { /* search for a match */ - switch (search) { - case _PW_KEYBYNUM: - if (state->keynum == -1) - return NS_NOTFOUND; /* no more records */ - state->keynum++; - from = &state->keynum; - fromlen = sizeof(state->keynum); - break; - case _PW_KEYBYNAME: - from = name; - fromlen = strlen(name); - break; - case _PW_KEYBYUID: - from = &uid; - fromlen = sizeof(uid); - break; - default: - abort(); - } - - if (buflen <= fromlen) { /* buffer too small */ - *retval = ERANGE; - return NS_UNAVAIL; - } - buffer[0] = search; /* setup key */ - memmove(buffer + 1, from, fromlen); - key.size = fromlen + 1; - key.data = (u_char *)buffer; - - /* search for key */ - rv = _pw_getkey(state->db, &key, pw, buffer, buflen, NULL, - state->version); - if (rv != NS_SUCCESS) /* no match */ - break; - if (pw->pw_name[0] == '+' || pw->pw_name[0] == '-') { - /* if a compat line */ - if (search == _PW_KEYBYNUM) - continue; /* read next if pwent */ - rv = NS_NOTFOUND; /* don't match if pw{nam,uid} */ - break; - } - break; - } - - if (rv == NS_NOTFOUND && search == _PW_KEYBYNUM) - state->keynum = -1; /* flag `no more records' */ - - if (rv == NS_SUCCESS) { - if ((search == _PW_KEYBYUID && pw->pw_uid != uid) || - (search == _PW_KEYBYNAME && strcmp(pw->pw_name, name) != 0)) - rv = NS_NOTFOUND; - } - - filespwscan_out: - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - return rv; -} - -/*ARGSUSED*/ -static int -_files_setpwent(void *nsrv, void *nscb, va_list ap) -{ - - _files_state.stayopen = 0; - return _files_start(&_files_state); -} - -/*ARGSUSED*/ -static int -_files_setpassent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - _files_state.stayopen = stayopen; - rv = _files_start(&_files_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_files_endpwent(void *nsrv, void *nscb, va_list ap) -{ - - _files_state.stayopen = 0; - return _files_end(&_files_state); -} - -/*ARGSUSED*/ -static int -_files_getpwent(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _files_pwscan(&rerror, &_files_passwd, - _files_passwdbuf, sizeof(_files_passwdbuf), - &_files_state, _PW_KEYBYNUM, NULL, 0); - if (rv == NS_SUCCESS) - *retval = &_files_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getpwent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - rv = _files_pwscan(retval, pw, buffer, buflen, &_files_state, - _PW_KEYBYNUM, NULL, 0); - if (rv == NS_SUCCESS) - *result = pw; - else - *result = NULL; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getpwnam(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _files_start(&_files_state); - if (rv != NS_SUCCESS) - return rv; - rv = _files_pwscan(&rerror, &_files_passwd, - _files_passwdbuf, sizeof(_files_passwdbuf), - &_files_state, _PW_KEYBYNAME, name, 0); - if (!_files_state.stayopen) - _files_end(&_files_state); - if (rv == NS_SUCCESS) - *retval = &_files_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getpwnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct files_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = _files_pwscan(retval, pw, buffer, buflen, &state, - _PW_KEYBYNAME, name, 0); - _files_end(&state); - if (rv == NS_SUCCESS) - *result = pw; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getpwuid(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - uid_t uid = va_arg(ap, uid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _files_start(&_files_state); - if (rv != NS_SUCCESS) - return rv; - rv = _files_pwscan(&rerror, &_files_passwd, - _files_passwdbuf, sizeof(_files_passwdbuf), - &_files_state, _PW_KEYBYUID, NULL, uid); - if (!_files_state.stayopen) - _files_end(&_files_state); - if (rv == NS_SUCCESS) - *retval = &_files_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_files_getpwuid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - uid_t uid = va_arg(ap, uid_t); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct files_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = _files_pwscan(retval, pw, buffer, buflen, &state, - _PW_KEYBYUID, NULL, uid); - _files_end(&state); - if (rv == NS_SUCCESS) - *result = pw; - return rv; -} - - -#ifdef HESIOD - /* - * dns methods - */ - - /* state shared between dns methods */ -struct dns_state { - int stayopen; /* see getpassent(3) */ - void *context; /* Hesiod context */ - int num; /* passwd index, -1 if no more */ -}; - -static struct dns_state _dns_state; - /* storage for non _r functions */ -static struct passwd _dns_passwd; -static char _dns_passwdbuf[_GETPW_R_SIZE_MAX]; - -static int -_dns_start(struct dns_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->num = 0; - if (state->context == NULL) { /* setup Hesiod */ - if (hesiod_init(&state->context) == -1) - return NS_UNAVAIL; - } - - return NS_SUCCESS; -} - -static int -_dns_end(struct dns_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->num = 0; - if (state->context) { - hesiod_end(state->context); - state->context = NULL; - } - return NS_SUCCESS; -} - -/* - * _dns_pwscan - * Look for the Hesiod name provided in buffer in the NULL-terminated - * list of zones, - * and decode into pw/buffer/buflen. - */ -static int -_dns_pwscan(int *retval, struct passwd *pw, char *buffer, size_t buflen, - struct dns_state *state, const char **zones) -{ - const char **curzone; - char **hp, *ep; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - _DIAGASSERT(zones != NULL); - - *retval = 0; - - if (state->context == NULL) { /* only start if Hesiod not setup */ - rv = _dns_start(state); - if (rv != NS_SUCCESS) - return rv; - } - - hp = NULL; - rv = NS_NOTFOUND; - - for (curzone = zones; *curzone; curzone++) { /* search zones */ - hp = hesiod_resolve(state->context, buffer, *curzone); - if (hp != NULL) - break; - if (errno != ENOENT) { - rv = NS_UNAVAIL; - goto dnspwscan_out; - } - } - if (*curzone == NULL) - goto dnspwscan_out; - - if ((ep = strchr(hp[0], '\n')) != NULL) - *ep = '\0'; /* clear trailing \n */ - if (_pw_parse(hp[0], pw, buffer, buflen, 1)) /* validate line */ - rv = NS_SUCCESS; - else - rv = NS_UNAVAIL; - - dnspwscan_out: - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - if (hp) - hesiod_free_list(state->context, hp); - return rv; -} - -/*ARGSUSED*/ -static int -_dns_setpwent(void *nsrv, void *nscb, va_list ap) -{ - - _dns_state.stayopen = 0; - return _dns_start(&_dns_state); -} - -/*ARGSUSED*/ -static int -_dns_setpassent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - _dns_state.stayopen = stayopen; - rv = _dns_start(&_dns_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_dns_endpwent(void *nsrv, void *nscb, va_list ap) -{ - - _dns_state.stayopen = 0; - return _dns_end(&_dns_state); -} - -/*ARGSUSED*/ -static int -_dns_getpwent(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - - char **hp, *ep; - int rv; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - - if (_dns_state.num == -1) /* exhausted search */ - return NS_NOTFOUND; - - if (_dns_state.context == NULL) { - /* only start if Hesiod not setup */ - rv = _dns_start(&_dns_state); - if (rv != NS_SUCCESS) - return rv; - } - - next_dns_entry: - hp = NULL; - rv = NS_NOTFOUND; - - /* find passwd-NNN */ - snprintf(_dns_passwdbuf, sizeof(_dns_passwdbuf), - "passwd-%u", _dns_state.num); - _dns_state.num++; - - hp = hesiod_resolve(_dns_state.context, _dns_passwdbuf, "passwd"); - if (hp == NULL) { - if (errno == ENOENT) - _dns_state.num = -1; - else - rv = NS_UNAVAIL; - } else { - if ((ep = strchr(hp[0], '\n')) != NULL) - *ep = '\0'; /* clear trailing \n */ - /* validate line */ - if (_pw_parse(hp[0], &_dns_passwd, - _dns_passwdbuf, sizeof(_dns_passwdbuf), 1)) - rv = NS_SUCCESS; - else { /* dodgy entry, try again */ - hesiod_free_list(_dns_state.context, hp); - goto next_dns_entry; - } - } - - if (hp) - hesiod_free_list(_dns_state.context, hp); - if (rv == NS_SUCCESS) - *retval = &_dns_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_dns_getpwent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - char **hp, *ep; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *retval = 0; - - if (_dns_state.num == -1) /* exhausted search */ - return NS_NOTFOUND; - - if (_dns_state.context == NULL) { - /* only start if Hesiod not setup */ - rv = _dns_start(&_dns_state); - if (rv != NS_SUCCESS) - return rv; - } - - next_dns_entry: - hp = NULL; - rv = NS_NOTFOUND; - - /* find passwd-NNN */ - snprintf(buffer, buflen, "passwd-%u", _dns_state.num); - _dns_state.num++; - - hp = hesiod_resolve(_dns_state.context, buffer, "passwd"); - if (hp == NULL) { - if (errno == ENOENT) - _dns_state.num = -1; - else - rv = NS_UNAVAIL; - } else { - if ((ep = strchr(hp[0], '\n')) != NULL) - *ep = '\0'; /* clear trailing \n */ - /* validate line */ - if (_pw_parse(hp[0], pw, buffer, buflen, 1)) - rv = NS_SUCCESS; - else { /* dodgy entry, try again */ - hesiod_free_list(_dns_state.context, hp); - goto next_dns_entry; - } - } - - if (hp) - hesiod_free_list(_dns_state.context, hp); - if (rv == NS_SUCCESS) - *result = pw; - else - *result = NULL; - return rv; -} - -static const char *_dns_uid_zones[] = { - "uid", - "passwd", - NULL -}; - -/*ARGSUSED*/ -static int -_dns_getpwuid(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - uid_t uid = va_arg(ap, uid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _dns_start(&_dns_state); - if (rv != NS_SUCCESS) - return rv; - snprintf(_dns_passwdbuf, sizeof(_dns_passwdbuf), - "%u", (unsigned int)uid); - rv = _dns_pwscan(&rerror, &_dns_passwd, - _dns_passwdbuf, sizeof(_dns_passwdbuf), - &_dns_state, _dns_uid_zones); - if (!_dns_state.stayopen) - _dns_end(&_dns_state); - if (rv == NS_SUCCESS && uid == _dns_passwd.pw_uid) - *retval = &_dns_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_dns_getpwuid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - uid_t uid = va_arg(ap, uid_t); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct dns_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - snprintf(buffer, buflen, "%u", (unsigned int)uid); - rv = _dns_pwscan(retval, pw, buffer, buflen, &state, _dns_uid_zones); - _dns_end(&state); - if (rv != NS_SUCCESS) - return rv; - if (uid == pw->pw_uid) { - *result = pw; - return NS_SUCCESS; - } else - return NS_NOTFOUND; -} - -static const char *_dns_nam_zones[] = { - "passwd", - NULL -}; - -/*ARGSUSED*/ -static int -_dns_getpwnam(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _dns_start(&_dns_state); - if (rv != NS_SUCCESS) - return rv; - snprintf(_dns_passwdbuf, sizeof(_dns_passwdbuf), "%s", name); - rv = _dns_pwscan(&rerror, &_dns_passwd, - _dns_passwdbuf, sizeof(_dns_passwdbuf), - &_dns_state, _dns_nam_zones); - if (!_dns_state.stayopen) - _dns_end(&_dns_state); - if (rv == NS_SUCCESS && strcmp(name, _dns_passwd.pw_name) == 0) - *retval = &_dns_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_dns_getpwnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct dns_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - snprintf(buffer, buflen, "%s", name); - rv = _dns_pwscan(retval, pw, buffer, buflen, &state, _dns_nam_zones); - _dns_end(&state); - if (rv != NS_SUCCESS) - return rv; - if (strcmp(name, pw->pw_name) == 0) { - *result = pw; - return NS_SUCCESS; - } else - return NS_NOTFOUND; -} - -#endif /* HESIOD */ - - -#ifdef YP - /* - * nis methods - */ - /* state shared between nis methods */ -struct nis_state { - int stayopen; /* see getpassent(3) */ - char *domain; /* NIS domain */ - int done; /* non-zero if search exhausted */ - char *current; /* current first/next match */ - int currentlen; /* length of _nis_current */ - enum { /* shadow map type */ - NISMAP_UNKNOWN = 0, /* unknown ... */ - NISMAP_NONE, /* none: use "passwd.by*" */ - NISMAP_ADJUNCT, /* pw_passwd from "passwd.adjunct.*" */ - NISMAP_MASTER /* all from "master.passwd.by*" */ - } maptype; -}; - -static struct nis_state _nis_state; - /* storage for non _r functions */ -static struct passwd _nis_passwd; -static char _nis_passwdbuf[_GETPW_R_SIZE_MAX]; - -static const char __nis_pw_n_1[] = "master.passwd.byname"; -static const char __nis_pw_n_2[] = "passwd.byname"; -static const char __nis_pw_u_1[] = "master.passwd.byuid"; -static const char __nis_pw_u_2[] = "passwd.byuid"; - -static const char * const __nis_pw_n_map[4] = { __nis_pw_n_2, __nis_pw_n_2, __nis_pw_n_2, __nis_pw_n_1 }; -static const char * const __nis_pw_u_map[4] = { __nis_pw_u_2, __nis_pw_u_2, __nis_pw_u_2, __nis_pw_u_1 }; - - /* macros for deciding which NIS maps to use. */ -#define PASSWD_BYNAME(x) ((x)->maptype == NISMAP_MASTER ? __nis_pw_n_1 : __nis_pw_n_2) -#define PASSWD_BYUID(x) ((x)->maptype == NISMAP_MASTER ? __nis_pw_u_1 : __nis_pw_u_2) - -static int -_nis_start(struct nis_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->done = 0; - if (state->current) { - free(state->current); - state->current = NULL; - } - if (state->domain == NULL) { /* setup NIS */ - switch (yp_get_default_domain(&state->domain)) { - case 0: - break; - case YPERR_RESRC: - return NS_TRYAGAIN; - default: - return NS_UNAVAIL; - } - } - - /* determine where to get pw_passwd from */ - if (state->maptype == NISMAP_UNKNOWN) { - int r, order; - - state->maptype = NISMAP_NONE; /* default to no adjunct */ - if (geteuid() != 0) /* non-root can't use adjunct */ - return NS_SUCCESS; - - /* look for "master.passwd.*" */ - r = yp_order(state->domain, "master.passwd.byname", &order); - if (r == 0) { - state->maptype = NISMAP_MASTER; - return NS_SUCCESS; - } - - /* master.passwd doesn't exist, try passwd.adjunct */ - if (r == YPERR_MAP) { - r = yp_order(state->domain, "passwd.adjunct.byname", - &order); - if (r == 0) - state->maptype = NISMAP_ADJUNCT; - } - } - return NS_SUCCESS; -} - -static int -_nis_end(struct nis_state *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->domain) - state->domain = NULL; - state->done = 0; - if (state->current) - free(state->current); - state->current = NULL; - state->maptype = NISMAP_UNKNOWN; - return NS_SUCCESS; -} - -/* - * nis_parse - * wrapper to _pw_parse that obtains the real password from the - * "passwd.adjunct.byname" NIS map if the maptype is NISMAP_ADJUNCT. - */ -static int -_nis_parse(const char *entry, struct passwd *pw, char *buf, size_t buflen, - struct nis_state *state) -{ - size_t elen; - - _DIAGASSERT(entry != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buf != NULL); - _DIAGASSERT(state != NULL); - - elen = strlen(entry) + 1; - if (elen >= buflen) - return 0; - if (! _pw_parse(entry, pw, buf, buflen, - !(state->maptype == NISMAP_MASTER))) - return 0; - - if ((state->maptype == NISMAP_ADJUNCT) && - (strstr(pw->pw_passwd, "##") != NULL)) { - char *data; - int datalen; - - if (yp_match(state->domain, "passwd.adjunct.byname", - pw->pw_name, (int)strlen(pw->pw_name), - &data, &datalen) == 0) { - char *bp, *ep; - /* skip name to get password */ - ep = data; - if (strsep(&ep, ":") != NULL && - (bp = strsep(&ep, ":")) != NULL) { - /* store new pw_passwd after entry */ - if (strlcpy(buf + elen, bp, buflen - elen) >= - buflen - elen) { - free(data); - return 0; - } - pw->pw_passwd = &buf[elen]; - } - free(data); - } - } - - return 1; -} - - -/* - * _nis_pwscan - * Look for the yp key provided in buffer from map, - * and decode into pw/buffer/buflen. - */ -static int -_nis_pwscan(int *retval, struct passwd *pw, char *buffer, size_t buflen, - struct nis_state *state, const char * const *map_arr, size_t nmaps) -{ - char *data; - int nisr, rv, datalen; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - _DIAGASSERT(map_arr != NULL); - - *retval = 0; - - if (state->domain == NULL) { /* only start if NIS not setup */ - rv = _nis_start(state); - if (rv != NS_SUCCESS) - return rv; - } - - data = NULL; - rv = NS_NOTFOUND; - _DIAGASSERT(state->maptype != NISMAP_UNKNOWN && - (unsigned)state->maptype < nmaps); - - /* search map */ - nisr = yp_match(state->domain, map_arr[state->maptype], buffer, (int)strlen(buffer), - &data, &datalen); - switch (nisr) { - case 0: - data[datalen] = '\0'; /* clear trailing \n */ - if (_nis_parse(data, pw, buffer, buflen, state)) - rv = NS_SUCCESS; /* validate line */ - else - rv = NS_UNAVAIL; - break; - case YPERR_KEY: - break; - default: - rv = NS_UNAVAIL; - break; - } - - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - if (data) - free(data); - return rv; -} - -/*ARGSUSED*/ -static int -_nis_setpwent(void *nsrv, void *nscb, va_list ap) -{ - - _nis_state.stayopen = 0; - return _nis_start(&_nis_state); -} - -/*ARGSUSED*/ -static int -_nis_setpassent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - _nis_state.stayopen = stayopen; - rv = _nis_start(&_nis_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_nis_endpwent(void *nsrv, void *nscb, va_list ap) -{ - - return _nis_end(&_nis_state); -} - - -/*ARGSUSED*/ -static int -_nis_getpwent(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - - char *key, *data; - int keylen, datalen, rv, nisr; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - - if (_nis_state.done) /* exhausted search */ - return NS_NOTFOUND; - if (_nis_state.domain == NULL) { - /* only start if NIS not setup */ - rv = _nis_start(&_nis_state); - if (rv != NS_SUCCESS) - return rv; - } - - next_nis_entry: - key = NULL; - data = NULL; - rv = NS_NOTFOUND; - - if (_nis_state.current) { /* already searching */ - nisr = yp_next(_nis_state.domain, PASSWD_BYNAME(&_nis_state), - _nis_state.current, _nis_state.currentlen, - &key, &keylen, &data, &datalen); - free(_nis_state.current); - _nis_state.current = NULL; - switch (nisr) { - case 0: - _nis_state.current = key; - _nis_state.currentlen = keylen; - key = NULL; - break; - case YPERR_NOMORE: - _nis_state.done = 1; - goto nisent_out; - default: - rv = NS_UNAVAIL; - goto nisent_out; - } - } else { /* new search */ - if (yp_first(_nis_state.domain, PASSWD_BYNAME(&_nis_state), - &_nis_state.current, &_nis_state.currentlen, - &data, &datalen)) { - rv = NS_UNAVAIL; - goto nisent_out; - } - } - - data[datalen] = '\0'; /* clear trailing \n */ - /* validate line */ - if (_nis_parse(data, &_nis_passwd, - _nis_passwdbuf, sizeof(_nis_passwdbuf), &_nis_state)) - rv = NS_SUCCESS; - else { /* dodgy entry, try again */ - free(data); - goto next_nis_entry; - } - - nisent_out: - if (key) - free(key); - if (data) - free(data); - if (rv == NS_SUCCESS) - *retval = &_nis_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getpwent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - char *key, *data; - int keylen, datalen, rv, nisr; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *retval = 0; - - if (_nis_state.done) /* exhausted search */ - return NS_NOTFOUND; - if (_nis_state.domain == NULL) { - /* only start if NIS not setup */ - rv = _nis_start(&_nis_state); - if (rv != NS_SUCCESS) - return rv; - } - - next_nis_entry: - key = NULL; - data = NULL; - rv = NS_NOTFOUND; - - if (_nis_state.current) { /* already searching */ - nisr = yp_next(_nis_state.domain, PASSWD_BYNAME(&_nis_state), - _nis_state.current, _nis_state.currentlen, - &key, &keylen, &data, &datalen); - free(_nis_state.current); - _nis_state.current = NULL; - switch (nisr) { - case 0: - _nis_state.current = key; - _nis_state.currentlen = keylen; - key = NULL; - break; - case YPERR_NOMORE: - _nis_state.done = 1; - goto nisent_out; - default: - rv = NS_UNAVAIL; - goto nisent_out; - } - } else { /* new search */ - if (yp_first(_nis_state.domain, PASSWD_BYNAME(&_nis_state), - &_nis_state.current, &_nis_state.currentlen, - &data, &datalen)) { - rv = NS_UNAVAIL; - goto nisent_out; - } - } - - data[datalen] = '\0'; /* clear trailing \n */ - /* validate line */ - if (_nis_parse(data, pw, buffer, buflen, &_nis_state)) - rv = NS_SUCCESS; - else { /* dodgy entry, try again */ - if (key) - free(key); - free(data); - goto next_nis_entry; - } - - nisent_out: - if (key) - free(key); - if (data) - free(data); - if (rv == NS_SUCCESS) - *result = pw; - else - *result = NULL; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getpwuid(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - uid_t uid = va_arg(ap, uid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _nis_start(&_nis_state); - if (rv != NS_SUCCESS) - return rv; - snprintf(_nis_passwdbuf, sizeof(_nis_passwdbuf), "%u", (unsigned int)uid); - rv = _nis_pwscan(&rerror, &_nis_passwd, - _nis_passwdbuf, sizeof(_nis_passwdbuf), - &_nis_state, __nis_pw_u_map, __arraycount(__nis_pw_u_map)); - if (!_nis_state.stayopen) - _nis_end(&_nis_state); - if (rv == NS_SUCCESS && uid == _nis_passwd.pw_uid) - *retval = &_nis_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getpwuid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - uid_t uid = va_arg(ap, uid_t); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct nis_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - snprintf(buffer, buflen, "%u", (unsigned int)uid); -/* remark: we run under a global mutex inside of this module ... */ - if (_nis_state.stayopen) - { /* use global state only if stayopen is set - otherwise we would blow up getpwent_r() ... */ - rv = _nis_pwscan(retval, pw, buffer, buflen, - &_nis_state, __nis_pw_u_map, __arraycount(__nis_pw_u_map)); - } - else - { /* keep old semantic if no stayopen set - no need to call _nis_start() here - _nis_pwscan() will do it for us ... */ - /* use same way as in getgrent.c ... */ - memset(&state, 0, sizeof(state)); - rv = _nis_pwscan(retval, pw, buffer, buflen, - &state, __nis_pw_u_map, __arraycount(__nis_pw_u_map)); - _nis_end(&state); - } - if (rv != NS_SUCCESS) - return rv; - if (uid == pw->pw_uid) { - *result = pw; - return NS_SUCCESS; - } else - return NS_NOTFOUND; -} - -/*ARGSUSED*/ -static int -_nis_getpwnam(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _nis_start(&_nis_state); - if (rv != NS_SUCCESS) - return rv; - snprintf(_nis_passwdbuf, sizeof(_nis_passwdbuf), "%s", name); - rv = _nis_pwscan(&rerror, &_nis_passwd, - _nis_passwdbuf, sizeof(_nis_passwdbuf), - &_nis_state, __nis_pw_n_map, __arraycount(__nis_pw_n_map)); - if (!_nis_state.stayopen) - _nis_end(&_nis_state); - if (rv == NS_SUCCESS && strcmp(name, _nis_passwd.pw_name) == 0) - *retval = &_nis_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_nis_getpwnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct nis_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - snprintf(buffer, buflen, "%s", name); -/* remark: we run under a global mutex inside of this module ... */ - if (_nis_state.stayopen) - { /* use global state only if stayopen is set - otherwise we would blow up getpwent_r() ... */ - rv = _nis_pwscan(retval, pw, buffer, buflen, - &_nis_state, __nis_pw_n_map, __arraycount(__nis_pw_n_map)); - } - else - { /* keep old semantic if no stayopen set - no need to call _nis_start() here - _nis_pwscan() will do it for us ... */ - /* use same way as in getgrent.c ... */ - memset(&state, 0, sizeof(state)); - rv = _nis_pwscan(retval, pw, buffer, buflen, - &state, __nis_pw_n_map, __arraycount(__nis_pw_n_map)); - _nis_end(&state); - } - if (rv != NS_SUCCESS) - return rv; - if (strcmp(name, pw->pw_name) == 0) { - *result = pw; - return NS_SUCCESS; - } else - return NS_NOTFOUND; -} - -#endif /* YP */ - - -#ifdef _PASSWD_COMPAT - /* - * compat methods - */ - - /* state shared between compat methods */ - -struct compat_state { - int stayopen; /* see getpassent(3) */ - DB *db; /* passwd DB */ - int keynum; /* key counter, -1 if no more */ - enum { /* current compat mode */ - COMPAT_NOTOKEN = 0, /* no compat token present */ - COMPAT_NONE, /* parsing normal pwd.db line */ - COMPAT_FULL, /* parsing `+' entries */ - COMPAT_USER, /* parsing `+name' entries */ - COMPAT_NETGROUP /* parsing `+@netgroup' entries */ - } mode; - char *user; /* COMPAT_USER "+name" */ - DB *exclude; /* compat exclude DB */ - struct passwd proto; /* proto passwd entry */ - char protobuf[_GETPW_R_SIZE_MAX]; - /* buffer for proto ptrs */ - int protoflags; /* proto passwd flags */ - int version; -}; - -static struct compat_state _compat_state; - /* storage for non _r functions */ -static struct passwd _compat_passwd; -static char _compat_passwdbuf[_GETPW_R_SIZE_MAX]; - -static int -_compat_start(struct compat_state *state) -{ - int rv; - - _DIAGASSERT(state != NULL); - - state->keynum = 0; - if (state->db == NULL) { /* not open yet */ - DBT key, data; - DBT pkey, pdata; - char bf[MAXLOGNAME]; - - rv = _pw_opendb(&state->db, &state->version); - if (rv != NS_SUCCESS) - return rv; - - state->mode = COMPAT_NOTOKEN; - - /* - * Determine if the "compat" token is present in pwd.db; - * either "__YP!" or PW_KEYBYNAME+"+". - * Only works if pwd_mkdb installs the token. - */ - key.data = (u_char *)__UNCONST(__yp_token); - key.size = strlen(__yp_token); - - bf[0] = _PW_KEYBYNAME; /* Pre-token database support. */ - bf[1] = '+'; - pkey.data = (u_char *)bf; - pkey.size = 2; - - if ((state->db->get)(state->db, &key, &data, 0) == 0 - || (state->db->get)(state->db, &pkey, &pdata, 0) == 0) - state->mode = COMPAT_NONE; - } - return NS_SUCCESS; -} - -static int -_compat_end(struct compat_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->keynum = 0; - if (state->db) { - (void)(state->db->close)(state->db); - state->db = NULL; - } - state->mode = COMPAT_NOTOKEN; - if (state->user) - free(state->user); - state->user = NULL; - if (state->exclude != NULL) - (void)(state->exclude->close)(state->exclude); - state->exclude = NULL; - state->proto.pw_name = NULL; - state->protoflags = 0; - return NS_SUCCESS; -} - -/* - * _compat_add_exclude - * add the name to the exclude list in state->exclude. - */ -static int -_compat_add_exclude(struct compat_state *state, const char *name) -{ - DBT key, data; - - _DIAGASSERT(state != NULL); - _DIAGASSERT(name != NULL); - - /* initialize the exclusion table if needed */ - if (state->exclude == NULL) { - state->exclude = dbopen(NULL, O_RDWR, 600, DB_HASH, NULL); - if (state->exclude == NULL) - return 0; - } - - key.size = strlen(name); /* set up the key */ - key.data = (u_char *)__UNCONST(name); - - data.data = NULL; /* data is nothing */ - data.size = 0; - - /* store it */ - if ((state->exclude->put)(state->exclude, &key, &data, 0) == -1) - return 0; - - return 1; -} - -/* - * _compat_is_excluded - * test if a name is on the compat mode exclude list - */ -static int -_compat_is_excluded(struct compat_state *state, const char *name) -{ - DBT key, data; - - _DIAGASSERT(state != NULL); - _DIAGASSERT(name != NULL); - - if (state->exclude == NULL) - return 0; /* nothing excluded */ - - key.size = strlen(name); /* set up the key */ - key.data = (u_char *)__UNCONST(name); - - if ((state->exclude->get)(state->exclude, &key, &data, 0) == 0) - return 1; /* is excluded */ - - return 0; -} - - -/* - * _passwdcompat_bad - * log an error if "files" or "compat" is specified in - * passwd_compat database - */ -/*ARGSUSED*/ -static int -_passwdcompat_bad(void *nsrv, void *nscb, va_list ap) -{ - static int warned; - - _DIAGASSERT(nsrv != NULL); - _DIAGASSERT(nscb != NULL); - - if (!warned) { - syslog(LOG_ERR, - "nsswitch.conf passwd_compat database can't use '%s'", - (char *)nscb); - } - warned = 1; - return NS_UNAVAIL; -} - -/* - * _passwdcompat_setpassent - * Call setpassent for all passwd_compat sources. - */ -static int -_passwdcompat_setpassent(int stayopen) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_passwdcompat_bad, "files") - NS_DNS_CB(_dns_setpassent, NULL) - NS_NIS_CB(_nis_setpassent, NULL) - NS_COMPAT_CB(_passwdcompat_bad, "compat") - NS_NULL_CB - }; - - int rv, result; - - rv = nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "setpassent", - __nsdefaultnis_forceall, &result, stayopen); - return rv; -} - -/* - * _passwdcompat_endpwent - * Call endpwent for all passwd_compat sources. - */ -static int -_passwdcompat_endpwent(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_passwdcompat_bad, "files") - NS_DNS_CB(_dns_endpwent, NULL) - NS_NIS_CB(_nis_endpwent, NULL) - NS_COMPAT_CB(_passwdcompat_bad, "compat") - NS_NULL_CB - }; - - return nsdispatch(NULL, dtab, NSDB_PASSWD_COMPAT, "endpwent", - __nsdefaultnis_forceall); -} - -/* - * _passwdcompat_pwscan - * When a name lookup in compat mode is required (e.g., `+name', or a - * name in `+@netgroup'), look it up in the 'passwd_compat' nsswitch - * database. - * Fail if passwd_compat contains files or compat. - */ -static int -_passwdcompat_pwscan(struct passwd *pw, char *buffer, size_t buflen, - int search, const char *name, uid_t uid) -{ - static const ns_dtab compatentdtab[] = { - NS_FILES_CB(_passwdcompat_bad, "files") - NS_DNS_CB(_dns_getpwent_r, NULL) - NS_NIS_CB(_nis_getpwent_r, NULL) - NS_COMPAT_CB(_passwdcompat_bad, "compat") - NS_NULL_CB - }; - static const ns_dtab compatuiddtab[] = { - NS_FILES_CB(_passwdcompat_bad, "files") - NS_DNS_CB(_dns_getpwuid_r, NULL) - NS_NIS_CB(_nis_getpwuid_r, NULL) - NS_COMPAT_CB(_passwdcompat_bad, "compat") - NS_NULL_CB - }; - static const ns_dtab compatnamdtab[] = { - NS_FILES_CB(_passwdcompat_bad, "files") - NS_DNS_CB(_dns_getpwnam_r, NULL) - NS_NIS_CB(_nis_getpwnam_r, NULL) - NS_COMPAT_CB(_passwdcompat_bad, "compat") - NS_NULL_CB - }; - - int rv, crv; - struct passwd *cpw; - - switch (search) { - case _PW_KEYBYNUM: - rv = nsdispatch(NULL, compatentdtab, - NSDB_PASSWD_COMPAT, "getpwent_r", __nsdefaultnis, - &crv, pw, buffer, buflen, &cpw); - break; - case _PW_KEYBYNAME: - _DIAGASSERT(name != NULL); - rv = nsdispatch(NULL, compatnamdtab, - NSDB_PASSWD_COMPAT, "getpwnam_r", __nsdefaultnis, - &crv, name, pw, buffer, buflen, &cpw); - break; - case _PW_KEYBYUID: - rv = nsdispatch(NULL, compatuiddtab, - NSDB_PASSWD_COMPAT, "getpwuid_r", __nsdefaultnis, - &crv, uid, pw, buffer, buflen, &cpw); - break; - default: - abort(); - /*NOTREACHED*/ - } - return rv; -} - -/* - * _compat_pwscan - * Search state->db for the next desired entry. - * If search is _PW_KEYBYNUM, look for state->keynum. - * If search is _PW_KEYBYNAME, look for name. - * If search is _PW_KEYBYUID, look for uid. - * Sets *retval to the errno if the result is not NS_SUCCESS - * or NS_NOTFOUND. - */ -static int -_compat_pwscan(int *retval, struct passwd *pw, char *buffer, size_t buflen, - struct compat_state *state, int search, const char *name, uid_t uid) -{ - DBT key; - int rv, r, pwflags; - const char *user, *host, *dom; - const void *from; - size_t fromlen; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(state != NULL); - /* name may be NULL */ - - *retval = 0; - - if (state->db == NULL) { - rv = _compat_start(state); - if (rv != NS_SUCCESS) - return rv; - } - if (buflen <= 1) { /* buffer too small */ - *retval = ERANGE; - return NS_UNAVAIL; - } - - for (;;) { /* loop over pwd.db */ - rv = NS_NOTFOUND; - if (state->mode != COMPAT_NOTOKEN && - state->mode != COMPAT_NONE) { - /* doing a compat lookup */ - struct passwd cpw; - char cbuf[_GETPW_R_SIZE_MAX]; - - switch (state->mode) { - - case COMPAT_FULL: - /* get next user or lookup by key */ - rv = _passwdcompat_pwscan(&cpw, - cbuf, sizeof(cbuf), search, name, uid); - if (rv != NS_SUCCESS) - state->mode = COMPAT_NONE; - break; - - case COMPAT_NETGROUP: -/* XXXREENTRANT: getnetgrent is not thread safe */ - /* get next user from netgroup */ - r = getnetgrent(&host, &user, &dom); - if (r == 0) { /* end of group */ - endnetgrent(); - state->mode = COMPAT_NONE; - break; - } - if (!user || !*user) - break; - rv = _passwdcompat_pwscan(&cpw, - cbuf, sizeof(cbuf), - _PW_KEYBYNAME, user, 0); - break; - - case COMPAT_USER: - /* get specific user */ - if (state->user == NULL) { - state->mode = COMPAT_NONE; - break; - } - rv = _passwdcompat_pwscan(&cpw, - cbuf, sizeof(cbuf), - _PW_KEYBYNAME, state->user, 0); - free(state->user); - state->user = NULL; - state->mode = COMPAT_NONE; - break; - - case COMPAT_NOTOKEN: - case COMPAT_NONE: - abort(); - - } - if (rv != NS_SUCCESS) /* if not matched, next loop */ - continue; - - /* copy cpw to pw, applying prototype */ - if (! _pw_copy(&cpw, pw, buffer, buflen, - &state->proto, state->protoflags)) { - rv = NS_UNAVAIL; - break; - } - - if (_compat_is_excluded(state, pw->pw_name)) - continue; /* excluded; next loop */ - - if ((search == _PW_KEYBYNAME - && strcmp(pw->pw_name, name) != 0) - || (search == _PW_KEYBYUID && pw->pw_uid != uid)) { - continue; /* not specific; next loop */ - } - - break; /* exit loop if found */ - } else { /* not a compat line */ - state->proto.pw_name = NULL; - /* clear prototype */ - } - - if (state->mode == COMPAT_NOTOKEN) { - /* no compat token; do direct lookup */ - switch (search) { - case _PW_KEYBYNUM: - if (state->keynum == -1) /* no more records */ - return NS_NOTFOUND; - state->keynum++; - from = &state->keynum; - fromlen = sizeof(state->keynum); - break; - case _PW_KEYBYNAME: - from = name; - fromlen = strlen(name); - break; - case _PW_KEYBYUID: - from = &uid; - fromlen = sizeof(uid); - break; - default: - abort(); - } - buffer[0] = search; - } else { - /* compat token; do line by line */ - if (state->keynum == -1) /* no more records */ - return NS_NOTFOUND; - state->keynum++; - from = &state->keynum; - fromlen = sizeof(state->keynum); - buffer[0] = _PW_KEYBYNUM; - } - - if (buflen <= fromlen) { /* buffer too small */ - *retval = ERANGE; - return NS_UNAVAIL; - } - memmove(buffer + 1, from, fromlen); /* setup key */ - key.size = fromlen + 1; - key.data = (u_char *)buffer; - - rv = _pw_getkey(state->db, &key, pw, buffer, buflen, &pwflags, - state->version); - if (rv != NS_SUCCESS) /* stop on error */ - break; - - if (state->mode == COMPAT_NOTOKEN) - break; /* stop if no compat token */ - - if (pw->pw_name[0] == '+') { - /* compat inclusion */ - switch(pw->pw_name[1]) { - case '\0': /* `+' */ - state->mode = COMPAT_FULL; - /* reset passwd_compat search */ -/* XXXREENTRANT: setpassent is not thread safe ? */ - (void) _passwdcompat_setpassent(_compat_state.stayopen); - break; - case '@': /* `+@netgroup' */ - state->mode = COMPAT_NETGROUP; - /* reset netgroup search */ -/* XXXREENTRANT: setnetgrent is not thread safe */ - setnetgrent(pw->pw_name + 2); - break; - default: /* `+name' */ - state->mode = COMPAT_USER; - if (state->user) - free(state->user); - state->user = strdup(pw->pw_name + 1); - break; - } - /* save the prototype */ - state->protoflags = pwflags; - if (! _pw_copy(pw, &state->proto, state->protobuf, - sizeof(state->protobuf), NULL, 0)) { - rv = NS_UNAVAIL; - break; - } - continue; /* loop again after inclusion */ - } else if (pw->pw_name[0] == '-') { - /* compat exclusion */ - rv = NS_SUCCESS; - switch(pw->pw_name[1]) { - case '\0': /* `-' */ - break; - case '@': /* `-@netgroup' */ -/* XXXREENTRANT: {set,get,end}netgrent is not thread safe */ - setnetgrent(pw->pw_name + 2); - while (getnetgrent(&host, &user, &dom)) { - if (!user || !*user) - continue; - if (! _compat_add_exclude(state,user)) { - rv = NS_UNAVAIL; - break; - } - } - endnetgrent(); - break; - default: /* `-name' */ - if (! _compat_add_exclude(state, - pw->pw_name + 1)) { - rv = NS_UNAVAIL; - } - break; - } - if (rv != NS_SUCCESS) /* exclusion failure */ - break; - continue; /* loop again after exclusion */ - } - if (search == _PW_KEYBYNUM || - (search == _PW_KEYBYUID && pw->pw_uid == uid) || - (search == _PW_KEYBYNAME && strcmp(pw->pw_name, name) == 0)) - break; /* token mode match found */ - } - - if (rv == NS_NOTFOUND && - (search == _PW_KEYBYNUM || state->mode != COMPAT_NOTOKEN)) - state->keynum = -1; /* flag `no more records' */ - - if (rv == NS_SUCCESS) { - if ((search == _PW_KEYBYNAME && strcmp(pw->pw_name, name) != 0) - || (search == _PW_KEYBYUID && pw->pw_uid != uid)) - rv = NS_NOTFOUND; - } - - if (rv != NS_SUCCESS && rv != NS_NOTFOUND) - *retval = errno; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_setpwent(void *nsrv, void *nscb, va_list ap) -{ - - /* force passwd_compat setpwent() */ - (void) _passwdcompat_setpassent(0); - - /* reset state, keep db open */ - _compat_state.stayopen = 0; - return _compat_start(&_compat_state); -} - -/*ARGSUSED*/ -static int -_compat_setpassent(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - int stayopen = va_arg(ap, int); - - int rv; - - /* force passwd_compat setpassent() */ - (void) _passwdcompat_setpassent(stayopen); - - _compat_state.stayopen = stayopen; - rv = _compat_start(&_compat_state); - *retval = (rv == NS_SUCCESS); - return rv; -} - -/*ARGSUSED*/ -static int -_compat_endpwent(void *nsrv, void *nscb, va_list ap) -{ - - /* force passwd_compat endpwent() */ - (void) _passwdcompat_endpwent(); - - /* reset state, close db */ - _compat_state.stayopen = 0; - return _compat_end(&_compat_state); -} - - -/*ARGSUSED*/ -static int -_compat_getpwent(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _compat_pwscan(&rerror, &_compat_passwd, - _compat_passwdbuf, sizeof(_compat_passwdbuf), - &_compat_state, _PW_KEYBYNUM, NULL, 0); - if (rv == NS_SUCCESS) - *retval = &_compat_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getpwent_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - rv = _compat_pwscan(retval, pw, buffer, buflen, &_compat_state, - _PW_KEYBYNUM, NULL, 0); - if (rv == NS_SUCCESS) - *result = pw; - else - *result = NULL; - return rv; -} - - -/*ARGSUSED*/ -static int -_compat_getpwnam(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - const char *name = va_arg(ap, const char *); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _compat_start(&_compat_state); - if (rv != NS_SUCCESS) - return rv; - rv = _compat_pwscan(&rerror, &_compat_passwd, - _compat_passwdbuf, sizeof(_compat_passwdbuf), - &_compat_state, _PW_KEYBYNAME, name, 0); - if (!_compat_state.stayopen) - _compat_end(&_compat_state); - if (rv == NS_SUCCESS) - *retval = &_compat_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getpwnam_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - const char *name = va_arg(ap, const char *); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct compat_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = _compat_pwscan(retval, pw, buffer, buflen, &state, - _PW_KEYBYNAME, name, 0); - _compat_end(&state); - if (rv == NS_SUCCESS) - *result = pw; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getpwuid(void *nsrv, void *nscb, va_list ap) -{ - struct passwd **retval = va_arg(ap, struct passwd **); - uid_t uid = va_arg(ap, uid_t); - - int rv, rerror; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - rv = _compat_start(&_compat_state); - if (rv != NS_SUCCESS) - return rv; - rv = _compat_pwscan(&rerror, &_compat_passwd, - _compat_passwdbuf, sizeof(_compat_passwdbuf), - &_compat_state, _PW_KEYBYUID, NULL, uid); - if (!_compat_state.stayopen) - _compat_end(&_compat_state); - if (rv == NS_SUCCESS) - *retval = &_compat_passwd; - return rv; -} - -/*ARGSUSED*/ -static int -_compat_getpwuid_r(void *nsrv, void *nscb, va_list ap) -{ - int *retval = va_arg(ap, int *); - uid_t uid = va_arg(ap, uid_t); - struct passwd *pw = va_arg(ap, struct passwd *); - char *buffer = va_arg(ap, char *); - size_t buflen = va_arg(ap, size_t); - struct passwd **result = va_arg(ap, struct passwd **); - - struct compat_state state; - int rv; - - _DIAGASSERT(retval != NULL); - _DIAGASSERT(pw != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - memset(&state, 0, sizeof(state)); - rv = _compat_pwscan(retval, pw, buffer, buflen, &state, - _PW_KEYBYUID, NULL, uid); - _compat_end(&state); - if (rv == NS_SUCCESS) - *result = pw; - return rv; -} - -#endif /* _PASSWD_COMPAT */ - - - /* - * public functions - */ - -struct passwd * -getpwent(void) -{ - int r; - struct passwd *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getpwent, NULL) - NS_DNS_CB(_dns_getpwent, NULL) - NS_NIS_CB(_nis_getpwent, NULL) - NS_COMPAT_CB(_compat_getpwent, NULL) - NS_NULL_CB - }; - - mutex_lock(&_pwmutex); - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwent", __nsdefaultcompat, - &retval); - mutex_unlock(&_pwmutex); - return (r == NS_SUCCESS) ? retval : NULL; -} - -int -getpwent_r(struct passwd *pwd, char *buffer, size_t buflen, - struct passwd **result) -{ - int r, retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getpwent_r, NULL) - NS_DNS_CB(_dns_getpwent_r, NULL) - NS_NIS_CB(_nis_getpwent_r, NULL) - NS_COMPAT_CB(_compat_getpwent_r, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(pwd != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - retval = 0; - mutex_lock(&_pwmutex); - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwent_r", __nsdefaultcompat, - &retval, pwd, buffer, buflen, result); - mutex_unlock(&_pwmutex); - switch (r) { - case NS_SUCCESS: - case NS_NOTFOUND: - return 0; - default: - return retval; - } -} - - -struct passwd * -getpwnam(const char *name) -{ - int rv; - struct passwd *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getpwnam, NULL) - NS_DNS_CB(_dns_getpwnam, NULL) - NS_NIS_CB(_nis_getpwnam, NULL) - NS_COMPAT_CB(_compat_getpwnam, NULL) - NS_NULL_CB - }; - - mutex_lock(&_pwmutex); - rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam", __nsdefaultcompat, - &retval, name); - mutex_unlock(&_pwmutex); - return (rv == NS_SUCCESS) ? retval : NULL; -} - -int -getpwnam_r(const char *name, struct passwd *pwd, char *buffer, size_t buflen, - struct passwd **result) -{ - int r, retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getpwnam_r, NULL) - NS_DNS_CB(_dns_getpwnam_r, NULL) - NS_NIS_CB(_nis_getpwnam_r, NULL) - NS_COMPAT_CB(_compat_getpwnam_r, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(pwd != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - retval = 0; - mutex_lock(&_pwmutex); - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwnam_r", __nsdefaultcompat, - &retval, name, pwd, buffer, buflen, result); - mutex_unlock(&_pwmutex); - switch (r) { - case NS_SUCCESS: - case NS_NOTFOUND: - return 0; - default: - return retval; - } -} - -struct passwd * -getpwuid(uid_t uid) -{ - int rv; - struct passwd *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getpwuid, NULL) - NS_DNS_CB(_dns_getpwuid, NULL) - NS_NIS_CB(_nis_getpwuid, NULL) - NS_COMPAT_CB(_compat_getpwuid, NULL) - NS_NULL_CB - }; - - mutex_lock(&_pwmutex); - rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid", __nsdefaultcompat, - &retval, uid); - mutex_unlock(&_pwmutex); - return (rv == NS_SUCCESS) ? retval : NULL; -} - -int -getpwuid_r(uid_t uid, struct passwd *pwd, char *buffer, size_t buflen, - struct passwd **result) -{ - int r, retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getpwuid_r, NULL) - NS_DNS_CB(_dns_getpwuid_r, NULL) - NS_NIS_CB(_nis_getpwuid_r, NULL) - NS_COMPAT_CB(_compat_getpwuid_r, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(pwd != NULL); - _DIAGASSERT(buffer != NULL); - _DIAGASSERT(result != NULL); - - *result = NULL; - retval = 0; - mutex_lock(&_pwmutex); - r = nsdispatch(NULL, dtab, NSDB_PASSWD, "getpwuid_r", __nsdefaultcompat, - &retval, uid, pwd, buffer, buflen, result); - mutex_unlock(&_pwmutex); - switch (r) { - case NS_SUCCESS: - case NS_NOTFOUND: - return 0; - default: - return retval; - } -} - -void -endpwent(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_endpwent, NULL) - NS_DNS_CB(_dns_endpwent, NULL) - NS_NIS_CB(_nis_endpwent, NULL) - NS_COMPAT_CB(_compat_endpwent, NULL) - NS_NULL_CB - }; - - mutex_lock(&_pwmutex); - /* force all endpwent() methods */ - (void) nsdispatch(NULL, dtab, NSDB_PASSWD, "endpwent", - __nsdefaultcompat_forceall); - mutex_unlock(&_pwmutex); -} - -/*ARGSUSED*/ -int -setpassent(int stayopen) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_setpassent, NULL) - NS_DNS_CB(_dns_setpassent, NULL) - NS_NIS_CB(_nis_setpassent, NULL) - NS_COMPAT_CB(_compat_setpassent, NULL) - NS_NULL_CB - }; - int rv, retval; - - mutex_lock(&_pwmutex); - /* force all setpassent() methods */ - rv = nsdispatch(NULL, dtab, NSDB_PASSWD, "setpassent", - __nsdefaultcompat_forceall, &retval, stayopen); - mutex_unlock(&_pwmutex); - return (rv == NS_SUCCESS) ? retval : 0; -} - -void -setpwent(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_setpwent, NULL) - NS_DNS_CB(_dns_setpwent, NULL) - NS_NIS_CB(_nis_setpwent, NULL) - NS_COMPAT_CB(_compat_setpwent, NULL) - NS_NULL_CB - }; - - mutex_lock(&_pwmutex); - /* force all setpwent() methods */ - (void) nsdispatch(NULL, dtab, NSDB_PASSWD, "setpwent", - __nsdefaultcompat_forceall); - mutex_unlock(&_pwmutex); -} diff --git a/lib/libc/gen/getttyent.3 b/lib/libc/gen/getttyent.3 deleted file mode 100644 index bb7aacda1..000000000 --- a/lib/libc/gen/getttyent.3 +++ /dev/null @@ -1,219 +0,0 @@ -.\" $NetBSD: getttyent.3,v 1.21 2014/02/07 20:20:56 christos Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getttyent.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd February 7, 2014 -.Dt GETTTYENT 3 -.Os -.Sh NAME -.Nm getttyent , -.Nm getttynam , -.Nm setttyent , -.Nm setttyentpath , -.Nm endttyent -.Nd get ttys file entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ttyent.h -.Ft struct ttyent * -.Fn getttyent void -.Ft struct ttyent * -.Fn getttynam "const char *name" -.Ft int -.Fn setttyent void -.Ft int -.Fn setttyentpath "const char *path" -.Ft int -.Fn endttyent void -.Sh DESCRIPTION -The -.Fn getttyent , -and -.Fn getttynam -functions -each return a pointer to an object, with the following structure, -containing the broken-out fields of a line from the tty description -file. -.Bd -literal -struct ttyent { - char *ty_name; /* terminal device name */ - char *ty_getty; /* command to execute */ - char *ty_type; /* terminal type */ -#define TTY_ON 0x01 /* enable logins */ -#define TTY_SECURE 0x02 /* allow uid of 0 to login */ -#define TTY_LOCAL 0x04 /* set 'CLOCAL' on open (dev. specific) */ -#define TTY_RTSCTS 0x08 /* set 'CRTSCTS' on open (dev. specific) */ -#define TTY_SOFTCAR 0x10 /* ignore hardware carrier (dev. spec.) */ -#define TTY_MDMBUF 0x20 /* set 'MDMBUF' on open (dev. specific) */ -#define TTY_DTRCTS 0x40 /* set 'CDTRCTS' on open (dev. specific) */ - int ty_status; /* flag values */ - char *ty_window; /* command for window manager */ - char *ty_comment; /* comment field */ - char *ty_class; /* category of tty usage */ -}; -.Ed -.Pp -The fields are as follows: -.Bl -tag -width ty_comment -.It Fa ty_name -The name of the character-special file. -.It Fa ty_getty -The name of the command invoked by -.Xr init 8 -to initialize tty line characteristics. -.It Fa ty_type -The name of the default terminal type connected to this tty line. -.It Fa ty_status -A mask of bit fields which indicate various actions allowed on this -tty line. -The possible flags are as follows: -.Bl -tag -width TTY_SOFTCAR -.It Dv TTY_ON -Enables logins (i.e., -.Xr init 8 -will start the command referenced by -.Fa ty_getty -on this entry). -.It Dv TTY_SECURE -Allow users with a uid of 0 to login on this terminal. -.It Dv TTY_LOCAL -If the terminal port's driver supports it, cause the line -to be treated as ``local.'' -.It Dv TTY_MDMBUF -If the terminal port's driver supports it, use -DTR/DCD hardware flow control on the line by default. -.It Dv TTY_RTSCTS -If the terminal port's driver supports it, use -full-duplex RTS/CTS hardware flow control on the line -by default. -.It Dv TTY_SOFTCAR -If the terminal port's driver supports it, ignore hardware -carrier on the line. -.El -.It Fa ty_window -The command to execute for a window system associated with the line. -.It Fa ty_comment -Any trailing comment field, with any leading hash marks (``#'') or -whitespace removed. -.It Fa ty_class -A key indexing into a capfile style database (/etc/ttyclasses) -of attributes for this class of tty. -No attributes are currently defined or used, -so there are currently no functions to retrieve them. -.El -.Pp -If any of the fields pointing to character strings are unspecified, -they are returned as null pointers. -The field -.Fa ty_status -will be zero if no flag values are specified. -.Pp -See -.Xr ttys 5 -for a more complete discussion of the meaning and usage of the -fields. -.Pp -The -.Fn getttyent -function -reads the next line from the ttys file, opening the file if necessary. -The -.Fn setttyent -function -rewinds the file if open, or opens the file if it is unopened. -The -.Fn setttyentpath -function -is equivalent to -.Fn setttyent -but accepts an additional argument to read the ttys information from -an alternate file instead of the default location -.Pq defined in Dv _PATH_TTYS . -The -.Fn endttyent -function -closes any open files. -.Pp -The -.Fn getttynam -function -searches from the beginning of the file until a matching -.Fa name -is found -(or until -.Dv EOF -is encountered). -.Sh RETURN VALUES -The routines -.Fn getttyent -and -.Fn getttynam -return a null pointer on -.Dv EOF -or error. -The -.Fn setttyent -and -.Fn setttyentpath -functions -and -.Fn endttyent -return 0 on failure and 1 on success. -.Sh FILES -.Bl -tag -width /etc/ttys -compact -.It Pa /etc/ttys -.El -.Sh SEE ALSO -.Xr login 1 , -.Xr ttyslot 3 , -.Xr capfile 5 , -.Xr gettytab 5 , -.Xr ttys 5 , -.Xr getty 8 , -.Xr init 8 , -.Xr ttyflags 8 -.Sh HISTORY -The -.Fn getttyent , -.Fn getttynam , -.Fn setttyent , -and -.Fn endttyent -functions appeared in -.Bx 4.3 . -The -.Fn setttyentpath -function appeared in -.Nx 4.0 . -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. diff --git a/lib/libc/gen/getttyent.c b/lib/libc/gen/getttyent.c deleted file mode 100644 index 6585ebefa..000000000 --- a/lib/libc/gen/getttyent.c +++ /dev/null @@ -1,271 +0,0 @@ -/* $NetBSD: getttyent.c,v 1.26 2013/06/30 10:07:43 martin Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getttyent.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getttyent.c,v 1.26 2013/06/30 10:07:43 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#ifdef __weak_alias -__weak_alias(endttyent,_endttyent) -__weak_alias(getttyent,_getttyent) -__weak_alias(getttynam,_getttynam) -__weak_alias(setttyent,_setttyent) -__weak_alias(setttyentpath,_setttyentpath) -#endif - -static FILE *tf; -static size_t lineno = 0; -static char *skip(char *, char *); -static char *value(char *); - -struct ttyent * -getttynam(const char *tty) -{ - struct ttyent *t; - - _DIAGASSERT(tty != NULL); - - setttyent(); - while ((t = getttyent()) != NULL) - if (!strcmp(tty, t->ty_name)) - break; - endttyent(); - return (t); -} - -struct ttyent * -getttyent(void) -{ - static struct ttyent tty; - int c; - char *p; - size_t len; - static char *line = NULL; - char zapchar; - - if (line) - free(line); - - if (!tf && !setttyent()) - return NULL; - - for (;;) { - errno = 0; - line = fparseln(tf, &len, &lineno, NULL, FPARSELN_UNESCALL); - if (line == NULL) { - if (errno != 0) - warn(__func__); - return NULL; - } - for (p = line; *p && isspace((unsigned char)*p); p++) - continue; - if (*p && *p != '#') - break; - free(line); - } - - tty.ty_name = p; - p = skip(p, &zapchar); - if (*(tty.ty_getty = p) == '\0') - tty.ty_getty = tty.ty_type = NULL; - else { - p = skip(p, &zapchar); - if (*(tty.ty_type = p) == '\0') - tty.ty_type = NULL; - else - p = skip(p, &zapchar); - } - tty.ty_status = 0; - tty.ty_window = NULL; - tty.ty_class = NULL; - -#define scmp(e) !strncmp(p, e, sizeof(e) - 1) && (isspace((unsigned char) p[sizeof(e) - 1]) || p[sizeof(e) - 1] == '\0') -#define vcmp(e) !strncmp(p, e, sizeof(e) - 1) && p[sizeof(e) - 1] == '=' - for (; *p; p = skip(p, &zapchar)) { - if (scmp(_TTYS_OFF)) - tty.ty_status &= ~TTY_ON; - else if (scmp(_TTYS_ON)) - tty.ty_status |= TTY_ON; - else if (scmp(_TTYS_SECURE)) - tty.ty_status |= TTY_SECURE; - else if (scmp(_TTYS_LOCAL)) - tty.ty_status |= TTY_LOCAL; - else if (scmp(_TTYS_RTSCTS)) - tty.ty_status |= TTY_RTSCTS; - else if (scmp(_TTYS_DTRCTS)) - tty.ty_status |= TTY_DTRCTS; - else if (scmp(_TTYS_SOFTCAR)) - tty.ty_status |= TTY_SOFTCAR; - else if (scmp(_TTYS_MDMBUF)) - tty.ty_status |= TTY_MDMBUF; - else if (vcmp(_TTYS_WINDOW)) - tty.ty_window = value(p); - else if (vcmp(_TTYS_CLASS)) - tty.ty_class = value(p); - else - warnx("%s: %s, %lu: unknown option `%s'", - __func__, _PATH_TTYS, (unsigned long)lineno, p); - } - - if (zapchar == '#' || *p == '#') - while ((c = *++p) == ' ' || c == '\t') - continue; - tty.ty_comment = p; - if (*p == '\0') - tty.ty_comment = NULL; - if ((p = strchr(p, '\n')) != NULL) - *p = '\0'; - return &tty; -} - -#define QUOTED 1 - -/* - * Skip over the current field, removing quotes, and return a pointer to - * the next field. - */ -static char * -skip(char *p, char *zapchar) -{ - char *t; - int c, q; - - _DIAGASSERT(p != NULL); - *zapchar = '\0'; - - for (q = 0, t = p; (c = *p) != '\0'; p++) { - if (c == '"') { - q ^= QUOTED; /* obscure, but nice */ - continue; - } - if (q == QUOTED && *p == '\\' && *(p+1) == '"') - p++; - *t++ = *p; - if (q == QUOTED) - continue; - if (c == '#') { - *zapchar = c; - *p = '\0'; - *--t = '\0'; - return p; - } - if (c == '\t' || c == ' ' || c == '\n') { - *zapchar = c; - *p++ = '\0'; - while ((c = *p) == '\t' || c == ' ' || c == '\n') - p++; - *--t = '\0'; - return p; - } - } - if (t != p) - *t = '\0'; - return p; -} - -static char * -value(char *p) -{ - - _DIAGASSERT(p != NULL); - - return (p = strchr(p, '=')) != NULL ? ++p : NULL; -} - -int -setttyentpath(const char *path) -{ - lineno = 0; - if (tf) { - rewind(tf); - return 1; - } - - /* - * Try .$MACHINE (e.g. etc/ttys.amd64) - */ - { - char machine[_SYS_NMLN]; - const int mib[] = { [0] = CTL_HW, [1] = HW_MACHINE, }; - size_t len = sizeof(machine); - - if (sysctl(mib, (u_int)__arraycount(mib), machine, &len, - NULL, 0) != -1) { - char npath[PATH_MAX]; - (void)snprintf(npath, sizeof(npath), "%s.%s", path, - machine); - if ((tf = fopen(npath, "re")) != NULL) - return 1; - } - } - - if ((tf = fopen(path, "re")) != NULL) - return 1; - return 0; -} - -int -setttyent(void) -{ - return setttyentpath(_PATH_TTYS); -} - -int -endttyent(void) -{ - int rval; - - if (tf) { - rval = !(fclose(tf) == EOF); - tf = NULL; - return rval; - } - return 1; -} diff --git a/lib/libc/gen/getusershell.3 b/lib/libc/gen/getusershell.3 deleted file mode 100644 index 1b36738ee..000000000 --- a/lib/libc/gen/getusershell.3 +++ /dev/null @@ -1,98 +0,0 @@ -.\" $NetBSD: getusershell.3,v 1.10 2004/11/23 04:38:19 lukem Exp $ -.\" -.\" Copyright (c) 1985, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)getusershell.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd November 23, 2004 -.Dt GETUSERSHELL 3 -.Os -.Sh NAME -.Nm getusershell , -.Nm setusershell , -.Nm endusershell -.Nd get valid user shells -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft char * -.Fn getusershell void -.Ft void -.Fn setusershell void -.Ft void -.Fn endusershell void -.Sh DESCRIPTION -The -.Fn getusershell -function -returns a pointer to a valid user shell as defined by the -system manager in the shells database as described in -.Xr shells 5 . -If the shells database is not available, -.Fn getusershell -behaves as if -.Pa /bin/sh -and -.Pa /bin/csh -were listed. -.Pp -The -.Fn getusershell -function -reads the next -line (opening the file if necessary); -.Fn setusershell -rewinds the file; -.Fn endusershell -closes it. -.Sh FILES -.Bl -tag -width /etc/shells -compact -.It Pa /etc/shells -.El -.Sh DIAGNOSTICS -The routine -.Fn getusershell -returns a null pointer (0) on -.Dv EOF . -.Sh SEE ALSO -.Xr nsswitch.conf 5 , -.Xr shells 5 -.Sh HISTORY -The -.Fn getusershell -function appeared in -.Bx 4.3 . -.Sh BUGS -The -.Fn getusershell -function leaves its result in an internal static object and returns -a pointer to that object. -Subsequent calls to -.Fn getusershell -will modify the same object. diff --git a/lib/libc/gen/getusershell.c b/lib/libc/gen/getusershell.c deleted file mode 100644 index c7f5c2895..000000000 --- a/lib/libc/gen/getusershell.c +++ /dev/null @@ -1,547 +0,0 @@ -/* $NetBSD: getusershell.c,v 1.29 2012/03/13 21:13:36 christos Exp $ */ - -/*- - * Copyright (c) 1999, 2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getusershell.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getusershell.c,v 1.29 2012/03/13 21:13:36 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HESIOD -#include -#endif -#ifdef YP -#include -#include -#include -#endif - -#ifdef __weak_alias -__weak_alias(endusershell,_endusershell) -__weak_alias(getusershell,_getusershell) -__weak_alias(setusershell,_setusershell) -#endif - -/* - * Local shells should NOT be added here. - * They should be added in /etc/shells. - */ -static const char *const okshells[] = { _PATH_BSHELL, _PATH_CSHELL, NULL }; - -#ifdef _REENTRANT -static mutex_t __shellmutex = MUTEX_INITIALIZER; -#endif - -static char curshell[MAXPATHLEN + 2]; - -static const char *const *curokshell = okshells; -static int shellsfound = 0; - - /* - * files methods - */ - - /* state shared between files methods */ -struct files_state { - FILE *fp; -}; - -static struct files_state _files_state; - - -static int -_files_start(struct files_state *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->fp == NULL) { - state->fp = fopen(_PATH_SHELLS, "re"); - if (state->fp == NULL) - return NS_UNAVAIL; - } else { - rewind(state->fp); - } - return NS_SUCCESS; -} - -static int -_files_end(struct files_state *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->fp) { - (void) fclose(state->fp); - state->fp = NULL; - } - return NS_SUCCESS; -} - -/*ARGSUSED*/ -static int -_files_setusershell(void *nsrv, void *nscb, va_list ap) -{ - - return _files_start(&_files_state); -} - -/*ARGSUSED*/ -static int -_files_endusershell(void *nsrv, void *nscb, va_list ap) -{ - - return _files_end(&_files_state); -} - -/*ARGSUSED*/ -static int -_files_getusershell(void *nsrv, void *nscb, va_list ap) -{ - char **retval = va_arg(ap, char **); - - char *sp, *cp; - int rv; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - if (_files_state.fp == NULL) { /* only start if file not open yet */ - rv = _files_start(&_files_state); - if (rv != NS_SUCCESS) - return rv; - } - - while (fgets(curshell, (int)sizeof(curshell) - 1, _files_state.fp) - != NULL) { - sp = cp = curshell; - while (*cp != '#' && *cp != '/' && *cp != '\0') - cp++; - if (*cp == '#' || *cp == '\0') - continue; - sp = cp; - while (!isspace((unsigned char) *cp) && *cp != '#' - && *cp != '\0') - cp++; - *cp++ = '\0'; - *retval = sp; - return NS_SUCCESS; - } - - return NS_NOTFOUND; -} - - -#ifdef HESIOD - /* - * dns methods - */ - - /* state shared between dns methods */ -struct dns_state { - void *context; /* Hesiod context */ - int num; /* shell index, -1 if no more */ -}; - -static struct dns_state _dns_state; - -static int -_dns_start(struct dns_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->num = 0; - if (state->context == NULL) { /* setup Hesiod */ - if (hesiod_init(&state->context) == -1) - return NS_UNAVAIL; - } - - return NS_SUCCESS; -} - -static int -_dns_end(struct dns_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->num = 0; - if (state->context) { - hesiod_end(state->context); - state->context = NULL; - } - return NS_SUCCESS; -} - -/*ARGSUSED*/ -static int -_dns_setusershell(void *nsrv, void *nscb, va_list ap) -{ - - return _dns_start(&_dns_state); -} - -/*ARGSUSED*/ -static int -_dns_endusershell(void *nsrv, void *nscb, va_list ap) -{ - - return _dns_end(&_dns_state); -} - -/*ARGSUSED*/ -static int -_dns_getusershell(void *nsrv, void *nscb, va_list ap) -{ - char **retval = va_arg(ap, char **); - - char shellname[] = "shells-NNNNNNNNNN"; - char **hp, *ep; - int rv; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - - if (_dns_state.num == -1) /* exhausted search */ - return NS_NOTFOUND; - - if (_dns_state.context == NULL) { - /* only start if Hesiod not setup */ - rv = _dns_start(&_dns_state); - if (rv != NS_SUCCESS) - return rv; - } - - hp = NULL; - rv = NS_NOTFOUND; - - /* find shells-NNN */ - snprintf(shellname, sizeof(shellname), "shells-%d", _dns_state.num); - _dns_state.num++; - - hp = hesiod_resolve(_dns_state.context, shellname, "shells"); - if (hp == NULL) { - if (errno == ENOENT) - rv = NS_NOTFOUND; - else - rv = NS_UNAVAIL; - } else { - if ((ep = strchr(hp[0], '\n')) != NULL) - *ep = '\0'; /* clear trailing \n */ - /* only use first result */ - strlcpy(curshell, hp[0], sizeof(curshell)); - *retval = curshell; - rv = NS_SUCCESS; - } - - if (hp) - hesiod_free_list(_dns_state.context, hp); - if (rv != NS_SUCCESS) - _dns_state.num = -1; /* any failure halts search */ - return rv; -} - -#endif /* HESIOD */ - - -#ifdef YP - /* - * nis methods - */ - /* state shared between nis methods */ -struct nis_state { - char *domain; /* NIS domain */ - int done; /* non-zero if search exhausted */ - char *current; /* current first/next match */ - int currentlen; /* length of _nis_current */ -}; - -static struct nis_state _nis_state; - -static int -_nis_start(struct nis_state *state) -{ - - _DIAGASSERT(state != NULL); - - state->done = 0; - if (state->current) { - free(state->current); - state->current = NULL; - } - if (state->domain == NULL) { /* setup NIS */ - switch (yp_get_default_domain(&state->domain)) { - case 0: - break; - case YPERR_RESRC: - return NS_TRYAGAIN; - default: - return NS_UNAVAIL; - } - } - return NS_SUCCESS; -} - -static int -_nis_end(struct nis_state *state) -{ - - _DIAGASSERT(state != NULL); - - if (state->domain) - state->domain = NULL; - state->done = 0; - if (state->current) - free(state->current); - state->current = NULL; - return NS_SUCCESS; -} - -/*ARGSUSED*/ -static int -_nis_setusershell(void *nsrv, void *nscb, va_list ap) -{ - - return _nis_start(&_nis_state); -} - -/*ARGSUSED*/ -static int -_nis_endusershell(void *nsrv, void *nscb, va_list ap) -{ - - return _nis_end(&_nis_state); -} - -/*ARGSUSED*/ -static int -_nis_getusershell(void *nsrv, void *nscb, va_list ap) -{ - char **retval = va_arg(ap, char **); - - char *key, *data; - int keylen, datalen, rv, nisr; - - _DIAGASSERT(retval != NULL); - - *retval = NULL; - - if (_nis_state.done) /* exhausted search */ - return NS_NOTFOUND; - if (_nis_state.domain == NULL) { - /* only start if NIS not setup */ - rv = _nis_start(&_nis_state); - if (rv != NS_SUCCESS) - return rv; - } - - key = NULL; - data = NULL; - rv = NS_NOTFOUND; - - if (_nis_state.current) { /* already searching */ - nisr = yp_next(_nis_state.domain, "shells", - _nis_state.current, _nis_state.currentlen, - &key, &keylen, &data, &datalen); - free(_nis_state.current); - _nis_state.current = NULL; - switch (nisr) { - case 0: - _nis_state.current = key; - _nis_state.currentlen = keylen; - key = NULL; - break; - case YPERR_NOMORE: - rv = NS_NOTFOUND; - goto nisent_out; - default: - rv = NS_UNAVAIL; - goto nisent_out; - } - } else { /* new search */ - if (yp_first(_nis_state.domain, "shells", - &_nis_state.current, &_nis_state.currentlen, - &data, &datalen)) { - rv = NS_UNAVAIL; - goto nisent_out; - } - } - - data[datalen] = '\0'; /* clear trailing \n */ - strlcpy(curshell, data, sizeof(curshell)); - *retval = curshell; - rv = NS_SUCCESS; - - nisent_out: - if (key) - free(key); - if (data) - free(data); - if (rv != NS_SUCCESS) /* any failure halts search */ - _nis_state.done = 1; - return rv; -} - -#endif /* YP */ - - - /* - * public functions - */ - -void -endusershell(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_endusershell, NULL) - NS_DNS_CB(_dns_endusershell, NULL) - NS_NIS_CB(_nis_endusershell, NULL) - NS_NULL_CB - }; - - mutex_lock(&__shellmutex); - - curokshell = okshells; /* reset okshells fallback state */ - shellsfound = 0; - - /* force all endusershell() methods */ - (void) nsdispatch(NULL, dtab, NSDB_SHELLS, "endusershell", - __nsdefaultfiles_forceall); - mutex_unlock(&__shellmutex); -} - -__aconst char * -getusershell(void) -{ - int rv; - __aconst char *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getusershell, NULL) - NS_DNS_CB(_dns_getusershell, NULL) - NS_NIS_CB(_nis_getusershell, NULL) - NS_NULL_CB - }; - - mutex_lock(&__shellmutex); - - retval = NULL; - do { - rv = nsdispatch(NULL, dtab, NSDB_SHELLS, "getusershell", - __nsdefaultsrc, &retval); - /* loop until failure or non-blank result */ - } while (rv == NS_SUCCESS && retval[0] == '\0'); - - if (rv == NS_SUCCESS) { - shellsfound++; - } else if (shellsfound == 0) { /* no shells; fall back to okshells */ - if (curokshell != NULL) { - retval = __UNCONST(*curokshell); - curokshell++; - rv = NS_SUCCESS; - } - } - - mutex_unlock(&__shellmutex); - return (rv == NS_SUCCESS) ? retval : NULL; -} - -void -setusershell(void) -{ - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_setusershell, NULL) - NS_DNS_CB(_dns_setusershell, NULL) - NS_NIS_CB(_nis_setusershell, NULL) - NS_NULL_CB - }; - - mutex_lock(&__shellmutex); - - curokshell = okshells; /* reset okshells fallback state */ - shellsfound = 0; - - /* force all setusershell() methods */ - (void) nsdispatch(NULL, dtab, NSDB_SHELLS, "setusershell", - __nsdefaultfiles_forceall); - mutex_unlock(&__shellmutex); -} diff --git a/lib/libc/gen/glob.3 b/lib/libc/gen/glob.3 deleted file mode 100644 index 0c3598ffb..000000000 --- a/lib/libc/gen/glob.3 +++ /dev/null @@ -1,531 +0,0 @@ -.\" $NetBSD: glob.3,v 1.42 2012/12/27 21:17:47 christos Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Guido van Rossum. -.\" 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. -.\" -.\" @(#)glob.3 8.3 (Berkeley) 4/16/94 -.\" -.Dd December 27, 2012 -.Dt GLOB 3 -.Os -.Sh NAME -.Nm glob , -.Nm globfree , -.Nm glob_pattern_p -.Nd generate pathnames matching a pattern -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In glob.h -.Ft int -.Fn glob "const char * restrict pattern" "int flags" "int (*errfunc)(const char *, int)" "glob_t * restrict pglob" -.Ft void -.Fn globfree "glob_t *pglob" -.Ft int -.Fn glob_pattern_p "const char *pattern" "int quote" -.Sh DESCRIPTION -The -.Fn glob -function -is a pathname generator that implements the rules for file name pattern -matching used by the shell. -.Pp -The include file -.Pa glob.h -defines the structure type -.Fa glob_t , -which contains at least the following fields: -.Bd -literal -typedef struct { - size_t gl_pathc; /* count of total paths so far */ - size_t gl_matchc; /* count of paths matching pattern */ - size_t gl_offs; /* reserved at beginning of gl_pathv */ - int gl_flags; /* returned flags */ - char **gl_pathv; /* list of paths matching pattern */ -} glob_t; -.Ed -.Pp -The argument -.Fa pattern -is a pointer to a pathname pattern to be expanded. -The -.Fn glob -argument -matches all accessible pathnames against the pattern and creates -a list of the pathnames that match. -In order to have access to a pathname, -.Fn glob -requires search permission on every component of a path except the last -and read permission on each directory of any filename component of -.Fa pattern -that contains any of the special characters -.Ql * , -.Ql \&? -or -.Ql \&[ . -.Pp -The -.Fn glob -argument -stores the number of matched pathnames into the -.Fa gl_pathc -field, and a pointer to a list of pointers to pathnames into the -.Fa gl_pathv -field. -The first pointer after the last pathname is -.Dv NULL . -If the pattern does not match any pathnames, the returned number of -matched paths is set to zero. -.Pp -It is the caller's responsibility to create the structure pointed to by -.Fa pglob . -The -.Fn glob -function allocates other space as needed, including the memory pointed -to by -.Fa gl_pathv . -.Pp -The argument -.Fa flags -is used to modify the behavior of -.Fn glob . -The value of -.Fa flags -is the bitwise inclusive -.Tn OR -of any of the following -values defined in -.Pa glob.h : -.Bl -tag -width GLOB_ALTDIRFUNC -.It Dv GLOB_APPEND -Append pathnames generated to the ones from a previous call (or calls) -to -.Fn glob . -The value of -.Fa gl_pathc -will be the total matches found by this call and the previous call(s). -The pathnames are appended to, not merged with the pathnames returned by -the previous call(s). -Between calls, the caller must not change the setting of the -.Dv GLOB_DOOFFS -flag, nor change the value of -.Fa gl_offs -when -.Dv GLOB_DOOFFS -is set, nor (obviously) call -.Fn globfree -for -.Fa pglob . -.It Dv GLOB_DOOFFS -Make use of the -.Fa gl_offs -field. -If this flag is set, -.Fa gl_offs -is used to specify how many -.Dv NULL -pointers to prepend to the beginning -of the -.Fa gl_pathv -field. -In other words, -.Fa gl_pathv -will point to -.Fa gl_offs -.Dv NULL -pointers, -followed by -.Fa gl_pathc -pathname pointers, followed by a -.Dv NULL -pointer. -.It Dv GLOB_ERR -Causes -.Fn glob -to return when it encounters a directory that it cannot open or read. -Ordinarily, -.Fn glob -continues to find matches. -.It Dv GLOB_MARK -Each pathname that is a directory that matches -.Fa pattern -has a slash -appended. -.It Dv GLOB_NOCHECK -If -.Fa pattern -does not match any pathname, then -.Fn glob -returns a list -consisting of only -.Fa pattern , -with one level of backslash escapes removed, -the number of total pathnames set to 1, and the number of matched -pathnames set to 0. -.It Dv GLOB_NOSORT -By default, the pathnames are sorted in ascending -.Tn ASCII -order; -this flag prevents that sorting (speeding up -.Fn glob ) . -.El -.Pp -The following values may also be included in -.Fa flags , -however, they are non-standard extensions to -.St -p1003.2 . -.Bl -tag -width GLOB_ALTDIRFUNC -.It Dv GLOB_ALTDIRFUNC -The following additional fields in the pglob structure have been -initialized with alternate functions for glob to use to open, read, -and close directories and to get stat information on names found -in those directories. -.Bd -literal - void *(*gl_opendir)(const char * name); - struct dirent *(*gl_readdir)(void *); - void (*gl_closedir)(void *); - int (*gl_lstat)(const char *name, struct stat *st); - int (*gl_stat)(const char *name, struct stat *st); -.Ed -.Pp -This extension is provided to allow programs such as -.Xr restore 8 -to provide globbing from directories stored on tape. -.It Dv GLOB_BRACE -Pre-process the pattern string to expand -.Ql {pat,pat,...} -strings like -.Xr csh 1 . -The pattern -.Ql {} -is left unexpanded for historical reasons -.Po -.Xr csh 1 -does the same thing to ease typing of -.Xr find 1 -patterns -.Pc . -.It Dv GLOB_LIMIT -Limit the amount of memory used to store matched strings to -.Li 64K , -the number of -.Xr stat 2 -calls to 128, and the number of -.Xr readdir 3 -calls to 16K. -This option should be set for programs that can be coerced to a denial of -service attack via patterns that expand to a very large number of matches, -such as a long string of -.Li */../*/.. -.It Dv GLOB_MAGCHAR -Set by the -.Fn glob -function if the pattern included globbing characters. -See the description of the usage of the -.Fa gl_matchc -structure member for more details. -.It Dv GLOB_NOESCAPE -Disable the use of the backslash -.Pq Ql \e -character for quoting. -.It Dv GLOB_NOMAGIC -Is the same as -.Dv GLOB_NOCHECK -but it only appends the -.Fa pattern -if it does not contain any of the special characters ``*'', ``?'' or ``[''. -.Dv GLOB_NOMAGIC -is provided to simplify implementing the historic -.Xr csh 1 -globbing behavior and should probably not be used anywhere else. -.It Dv GLOB_NO_DOTDIRS -Hide -.Sq Li \&. -and -.Sq Li \&.. -from metacharacter matches, regardless of whether -.Dv GLOB_PERIOD -is set and whether the pattern component begins with a literal period. -.It Dv GLOB_PERIOD -Allow metacharacters to match a leading period in a filename. -.It Dv GLOB_STAR -Indicates that two adjacent -.Li * -characters will do a recursive match in all subdirs, without following -symbolic links and three adjacent -.Li * -characters will also follow symbolic links. -.It Dv GLOB_TILDE -Expand patterns that start with -.Ql ~ -to user name home directories. -.El -.Pp -If, during the search, a directory is encountered that cannot be opened -or read and -.Fa errfunc -is -.Pf non- Dv NULL , -.Fn glob -calls -.Fa (*errfunc)(path, errno) . -This may be unintuitive: a pattern like -.Ql */Makefile -will try to -.Xr stat 2 -.Ql foo/Makefile -even if -.Ql foo -is not a directory, resulting in a -call to -.Fa errfunc . -The error routine can suppress this action by testing for -.Dv ENOENT -and -.Dv ENOTDIR ; -however, the -.Dv GLOB_ERR -flag will still cause an immediate -return when this happens. -.Pp -If -.Fa errfunc -returns non-zero, -.Fn glob -stops the scan and returns -.Dv GLOB_ABORTED -after setting -.Fa gl_pathc -and -.Fa gl_pathv -to reflect any paths already matched. -This also happens if an error is encountered and -.Dv GLOB_ERR -is set in -.Fa flags , -regardless of the return value of -.Fa errfunc , -if called. -If -.Dv GLOB_ERR -is not set and either -.Fa errfunc -is -.Dv NULL -or -.Fa errfunc -returns zero, the error is ignored. -.Pp -The -.Fn globfree -function frees any space associated with -.Fa pglob -from a previous call(s) to -.Fn glob . -.Pp -The -.Fn glob_pattern_p -returns -.Dv 1 -if the -.Fa pattern -has any special characters that -.Fn glob -will interpret and -.Dv 0 -otherwise. -If the -.Fa quote -argument is non-zero, then backslash quoted characters are ignored. -.Pp -The historical -.Dv GLOB_QUOTE -flag is no longer supported. -Per -.St -p1003.2-92 , -backslash escaping of special characters is the default behaviour; -it may be disabled by specifying the -.Dv GLOB_NOESCAPE -flag. -.Sh RETURN VALUES -On successful completion, -.Fn glob -returns zero. -In addition the fields of -.Fa pglob -contain the values described below: -.Bl -tag -width GLOB_NOCHECK -.It Fa gl_pathc -contains the total number of matched pathnames so far. -This includes other matches from previous invocations of -.Fn glob -if -.Dv GLOB_APPEND -was specified. -.It Fa gl_matchc -contains the number of matched pathnames in the current invocation of -.Fn glob . -.It Fa gl_flags -contains a copy of the -.Fa flags -parameter with the bit -.Dv GLOB_MAGCHAR -set if -.Fa pattern -contained any of the special characters ``*'', ``?'' or ``['', cleared -if not. -.It Fa gl_pathv -contains a pointer to a -.Dv NULL Ns -terminated -list of matched pathnames. -However, if -.Fa gl_pathc -is zero, the contents of -.Fa gl_pathv -are undefined. -.El -.Pp -If -.Fn glob -terminates due to an error, it sets -.Va errno -and returns one of the following non-zero constants, which are defined -in the include file -.In glob.h : -.Bl -tag -width GLOB_ABORTEDXXX -.It Dv GLOB_ABORTED -The scan was stopped because an error was encountered and either -.Dv GLOB_ERR -was set or -.Fa (*errfunc)() -returned non-zero. -.It Dv GLOB_NOMATCH -The pattern does not match any existing pathname, and -.Dv GLOB_NOCHECK -was not set in -.Dv flags . -.It Dv GLOB_NOSPACE -An attempt to allocate memory failed, or if -.Va errno -was 0 -.Li GLOB_LIMIT -was specified in the flags and -.Li ARG_MAX -patterns were matched. -.El -.Pp -The historical -.Dv GLOB_ABEND -return constant is no longer supported. -Portable applications should use the -.Dv GLOB_ABORTED -constant instead. -.Pp -The arguments -.Fa pglob\-\*[Gt]gl_pathc -and -.Fa pglob\-\*[Gt]gl_pathv -are still set as specified above. -.Sh ENVIRONMENT -.Bl -tag -width HOME -compact -.It Ev HOME -If defined, used as the home directory of the current user in -tilde expansions. -.El -.Sh EXAMPLES -A rough equivalent of -.Ql "ls -l *.c *.h" -can be obtained with the -following code: -.Bd -literal -offset indent -glob_t g; - -g.gl_offs = 2; -glob("*.c", GLOB_DOOFFS, NULL, \*[Am]g); -glob("*.h", GLOB_DOOFFS | GLOB_APPEND, NULL, \*[Am]g); -g.gl_pathv[0] = "ls"; -g.gl_pathv[1] = "-l"; -execvp("ls", g.gl_pathv); -.Ed -.Sh SEE ALSO -.Xr sh 1 , -.Xr fnmatch 3 , -.Xr regexp 3 , -.Xr glob 7 -.Sh STANDARDS -The -.Fn glob -function is expected to be -.St -p1003.2 -compatible with the exception -that the flags -.Dv GLOB_ALTDIRFUNC , -.Dv GLOB_BRACE , -.Dv GLOB_LIMIT , -.Dv GLOB_MAGCHAR , -.Dv GLOB_NOESCAPE , -.Dv GLOB_NOMAGIC , -.Dv GLOB_NO_DOTDIRS , -.Dv GLOB_PERIOD , -.Dv GLOB_STAR , -.Dv GLOB_TILDE , -and the fields -.Fa gl_matchc -and -.Fa gl_flags -should not be used by applications striving for strict -.Tn POSIX -conformance. -.Sh HISTORY -The -.Fn glob -and -.Fn globfree -functions first appeared in -.Bx 4.4 . -The -.Fn glob_pattern_p -function is modelled after the one found in glibc. -.Sh BUGS -Patterns longer than -.Dv MAXPATHLEN -may cause unchecked errors. -.Pp -The -.Fn glob -function may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr stat 2 , -.Xr closedir 3 , -.Xr opendir 3 , -.Xr readdir 3 , -.Xr malloc 3 , -and -.Xr free 3 . diff --git a/lib/libc/gen/glob.c b/lib/libc/gen/glob.c deleted file mode 100644 index f623e25ca..000000000 --- a/lib/libc/gen/glob.c +++ /dev/null @@ -1,1149 +0,0 @@ -/* $NetBSD: glob.c,v 1.35 2013/03/20 23:44:47 lukem Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Guido van Rossum. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)glob.c 8.3 (Berkeley) 10/13/93"; -#else -__RCSID("$NetBSD: glob.c,v 1.35 2013/03/20 23:44:47 lukem Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * glob(3) -- a superset of the one defined in POSIX 1003.2. - * - * The [!...] convention to negate a range is supported (SysV, Posix, ksh). - * - * Optional extra services, controlled by flags not defined by POSIX: - * - * GLOB_MAGCHAR: - * Set in gl_flags if pattern contained a globbing character. - * GLOB_NOMAGIC: - * Same as GLOB_NOCHECK, but it will only append pattern if it did - * not contain any magic characters. [Used in csh style globbing] - * GLOB_ALTDIRFUNC: - * Use alternately specified directory access functions. - * GLOB_TILDE: - * expand ~user/foo to the /home/dir/of/user/foo - * GLOB_BRACE: - * expand {1,2}{a,b} to 1a 1b 2a 2b - * GLOB_PERIOD: - * allow metacharacters to match leading dots in filenames. - * GLOB_NO_DOTDIRS: - * . and .. are hidden from wildcards, even if GLOB_PERIOD is set. - * gl_matchc: - * Number of matches in the current invocation of glob. - */ - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef HAVE_NBTOOL_CONFIG_H -#define NO_GETPW_R -#endif - -#define GLOB_LIMIT_STRING 65536 /* number of readdirs */ -#define GLOB_LIMIT_STAT 128 /* number of stat system calls */ -#define GLOB_LIMIT_READDIR 16384 /* total buffer size of path strings */ -#define GLOB_LIMIT_PATH 1024 /* number of path elements */ -#define GLOB_LIMIT_BRACE 128 /* Number of brace calls */ - -struct glob_limit { - size_t l_string; - size_t l_stat; - size_t l_readdir; - size_t l_brace; -}; - -/* - * XXX: For NetBSD 1.4.x compatibility. (kill me l8r) - */ -#ifndef _DIAGASSERT -#define _DIAGASSERT(a) -#endif - -#define DOLLAR '$' -#define DOT '.' -#define EOS '\0' -#define LBRACKET '[' -#define NOT '!' -#define QUESTION '?' -#define QUOTE '\\' -#define RANGE '-' -#define RBRACKET ']' -#define SEP '/' -#define STAR '*' -#define TILDE '~' -#define UNDERSCORE '_' -#define LBRACE '{' -#define RBRACE '}' -#define SLASH '/' -#define COMMA ',' - -#ifndef USE_8BIT_CHARS - -#define M_QUOTE 0x8000 -#define M_PROTECT 0x4000 -#define M_MASK 0xffff -#define M_ASCII 0x00ff - -typedef unsigned short Char; - -#else - -#define M_QUOTE (Char)0x80 -#define M_PROTECT (Char)0x40 -#define M_MASK (Char)0xff -#define M_ASCII (Char)0x7f - -typedef char Char; - -#endif - - -#define CHAR(c) ((Char)((c)&M_ASCII)) -#define META(c) ((Char)((c)|M_QUOTE)) -#define M_ALL META('*') -#define M_END META(']') -#define M_NOT META('!') -#define M_ONE META('?') -#define M_RNG META('-') -#define M_SET META('[') -#define ismeta(c) (((c)&M_QUOTE) != 0) - - -static int compare(const void *, const void *); -static int g_Ctoc(const Char *, char *, size_t); -static int g_lstat(Char *, __gl_stat_t *, glob_t *); -static DIR *g_opendir(Char *, glob_t *); -static Char *g_strchr(const Char *, int); -static int g_stat(Char *, __gl_stat_t *, glob_t *); -static int glob0(const Char *, glob_t *, struct glob_limit *); -static int glob1(Char *, glob_t *, struct glob_limit *); -static int glob2(Char *, Char *, Char *, const Char *, glob_t *, - struct glob_limit *); -static int glob3(Char *, Char *, Char *, const Char *, const Char *, - const Char *, glob_t *, struct glob_limit *); -static int globextend(const Char *, glob_t *, struct glob_limit *); -static const Char *globtilde(const Char *, Char *, size_t, glob_t *); -static int globexp1(const Char *, glob_t *, struct glob_limit *); -static int globexp2(const Char *, const Char *, glob_t *, int *, - struct glob_limit *); -static int match(const Char *, const Char *, const Char *); -#ifdef DEBUG -static void qprintf(const char *, Char *); -#endif - -int -glob(const char * __restrict pattern, int flags, int (*errfunc)(const char *, - int), glob_t * __restrict pglob) -{ - const unsigned char *patnext; - int c; - Char *bufnext, *bufend, patbuf[MAXPATHLEN+1]; - struct glob_limit limit = { 0, 0, 0, 0 }; - - _DIAGASSERT(pattern != NULL); - - patnext = (const unsigned char *) pattern; - if (!(flags & GLOB_APPEND)) { - pglob->gl_pathc = 0; - pglob->gl_pathv = NULL; - if (!(flags & GLOB_DOOFFS)) - pglob->gl_offs = 0; - } - pglob->gl_flags = flags & ~GLOB_MAGCHAR; - pglob->gl_errfunc = errfunc; - pglob->gl_matchc = 0; - - bufnext = patbuf; - bufend = bufnext + MAXPATHLEN; - if (flags & GLOB_NOESCAPE) { - while (bufnext < bufend && (c = *patnext++) != EOS) - *bufnext++ = c; - } else { - /* Protect the quoted characters. */ - while (bufnext < bufend && (c = *patnext++) != EOS) - if (c == QUOTE) { - if ((c = *patnext++) == EOS) { - c = QUOTE; - --patnext; - } - *bufnext++ = c | M_PROTECT; - } - else - *bufnext++ = c; - } - *bufnext = EOS; - - if (flags & GLOB_BRACE) - return globexp1(patbuf, pglob, &limit); - else - return glob0(patbuf, pglob, &limit); -} - -/* - * Expand recursively a glob {} pattern. When there is no more expansion - * invoke the standard globbing routine to glob the rest of the magic - * characters - */ -static int -globexp1(const Char *pattern, glob_t *pglob, struct glob_limit *limit) -{ - const Char* ptr = pattern; - int rv; - - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(pglob != NULL); - - if ((pglob->gl_flags & GLOB_LIMIT) && - limit->l_brace++ >= GLOB_LIMIT_BRACE) { - errno = 0; - return GLOB_NOSPACE; - } - - /* Protect a single {}, for find(1), like csh */ - if (pattern[0] == LBRACE && pattern[1] == RBRACE && pattern[2] == EOS) - return glob0(pattern, pglob, limit); - - while ((ptr = (const Char *) g_strchr(ptr, LBRACE)) != NULL) - if (!globexp2(ptr, pattern, pglob, &rv, limit)) - return rv; - - return glob0(pattern, pglob, limit); -} - - -/* - * Recursive brace globbing helper. Tries to expand a single brace. - * If it succeeds then it invokes globexp1 with the new pattern. - * If it fails then it tries to glob the rest of the pattern and returns. - */ -static int -globexp2(const Char *ptr, const Char *pattern, glob_t *pglob, int *rv, - struct glob_limit *limit) -{ - int i; - Char *lm, *ls; - const Char *pe, *pm, *pl; - Char patbuf[MAXPATHLEN + 1]; - - _DIAGASSERT(ptr != NULL); - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(pglob != NULL); - _DIAGASSERT(rv != NULL); - - /* copy part up to the brace */ - for (lm = patbuf, pm = pattern; pm != ptr; *lm++ = *pm++) - continue; - ls = lm; - - /* Find the balanced brace */ - for (i = 0, pe = ++ptr; *pe; pe++) - if (*pe == LBRACKET) { - /* Ignore everything between [] */ - for (pm = pe++; *pe != RBRACKET && *pe != EOS; pe++) - continue; - if (*pe == EOS) { - /* - * We could not find a matching RBRACKET. - * Ignore and just look for RBRACE - */ - pe = pm; - } - } - else if (*pe == LBRACE) - i++; - else if (*pe == RBRACE) { - if (i == 0) - break; - i--; - } - - /* Non matching braces; just glob the pattern */ - if (i != 0 || *pe == EOS) { - /* - * we use `pattern', not `patbuf' here so that that - * unbalanced braces are passed to the match - */ - *rv = glob0(pattern, pglob, limit); - return 0; - } - - for (i = 0, pl = pm = ptr; pm <= pe; pm++) { - switch (*pm) { - case LBRACKET: - /* Ignore everything between [] */ - for (pl = pm++; *pm != RBRACKET && *pm != EOS; pm++) - continue; - if (*pm == EOS) { - /* - * We could not find a matching RBRACKET. - * Ignore and just look for RBRACE - */ - pm = pl; - } - break; - - case LBRACE: - i++; - break; - - case RBRACE: - if (i) { - i--; - break; - } - /* FALLTHROUGH */ - case COMMA: - if (i && *pm == COMMA) - break; - else { - /* Append the current string */ - for (lm = ls; (pl < pm); *lm++ = *pl++) - continue; - /* - * Append the rest of the pattern after the - * closing brace - */ - for (pl = pe + 1; (*lm++ = *pl++) != EOS;) - continue; - - /* Expand the current pattern */ -#ifdef DEBUG - qprintf("globexp2", patbuf); -#endif - *rv = globexp1(patbuf, pglob, limit); - - /* move after the comma, to the next string */ - pl = pm + 1; - } - break; - - default: - break; - } - } - *rv = 0; - return 0; -} - - - -/* - * expand tilde from the passwd file. - */ -static const Char * -globtilde(const Char *pattern, Char *patbuf, size_t patsize, glob_t *pglob) -{ - struct passwd *pwd; - const char *h; - const Char *p; - Char *b; - char *d; - Char *pend = &patbuf[patsize / sizeof(Char)]; -#ifndef NO_GETPW_R - struct passwd pwres; - char pwbuf[1024]; -#endif - - pend--; - - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(patbuf != NULL); - _DIAGASSERT(pglob != NULL); - - if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE)) - return pattern; - - /* Copy up to the end of the string or / */ - for (p = pattern + 1, d = (char *)(void *)patbuf; - d < (char *)(void *)pend && *p && *p != SLASH; - *d++ = *p++) - continue; - - if (d == (char *)(void *)pend) - return NULL; - - *d = EOS; - d = (char *)(void *)patbuf; - - if (*d == EOS) { - /* - * handle a plain ~ or ~/ by expanding $HOME - * first and then trying the password file - */ - if ((h = getenv("HOME")) == NULL) { -#ifdef NO_GETPW_R - if ((pwd = getpwuid(getuid())) == NULL) -#else - if (getpwuid_r(getuid(), &pwres, pwbuf, sizeof(pwbuf), - &pwd) != 0 || pwd == NULL) -#endif - return pattern; - else - h = pwd->pw_dir; - } - } - else { - /* - * Expand a ~user - */ -#ifdef NO_GETPW_R - if ((pwd = getpwnam(d)) == NULL) -#else - if (getpwnam_r(d, &pwres, pwbuf, sizeof(pwbuf), &pwd) != 0 || - pwd == NULL) -#endif - return pattern; - else - h = pwd->pw_dir; - } - - /* Copy the home directory */ - for (b = patbuf; b < pend && *h; *b++ = *h++) - continue; - - if (b == pend) - return NULL; - - /* Append the rest of the pattern */ - while (b < pend && (*b++ = *p++) != EOS) - continue; - - if (b == pend) - return NULL; - - return patbuf; -} - - -/* - * The main glob() routine: compiles the pattern (optionally processing - * quotes), calls glob1() to do the real pattern matching, and finally - * sorts the list (unless unsorted operation is requested). Returns 0 - * if things went well, nonzero if errors occurred. It is not an error - * to find no matches. - */ -static int -glob0(const Char *pattern, glob_t *pglob, struct glob_limit *limit) -{ - const Char *qpatnext; - int c, error; - __gl_size_t oldpathc; - Char *bufnext, patbuf[MAXPATHLEN+1]; - - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(pglob != NULL); - - if ((qpatnext = globtilde(pattern, patbuf, sizeof(patbuf), - pglob)) == NULL) - return GLOB_ABEND; - oldpathc = pglob->gl_pathc; - bufnext = patbuf; - - /* We don't need to check for buffer overflow any more. */ - while ((c = *qpatnext++) != EOS) { - switch (c) { - case LBRACKET: - c = *qpatnext; - if (c == NOT) - ++qpatnext; - if (*qpatnext == EOS || - g_strchr(qpatnext+1, RBRACKET) == NULL) { - *bufnext++ = LBRACKET; - if (c == NOT) - --qpatnext; - break; - } - *bufnext++ = M_SET; - if (c == NOT) - *bufnext++ = M_NOT; - c = *qpatnext++; - do { - *bufnext++ = CHAR(c); - if (*qpatnext == RANGE && - (c = qpatnext[1]) != RBRACKET) { - *bufnext++ = M_RNG; - *bufnext++ = CHAR(c); - qpatnext += 2; - } - } while ((c = *qpatnext++) != RBRACKET); - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_END; - break; - case QUESTION: - pglob->gl_flags |= GLOB_MAGCHAR; - *bufnext++ = M_ONE; - break; - case STAR: - pglob->gl_flags |= GLOB_MAGCHAR; - /* collapse adjacent stars to one [or three if globstar] - * to avoid exponential behavior - */ - if (bufnext == patbuf || bufnext[-1] != M_ALL || - ((pglob->gl_flags & GLOB_STAR) != 0 && - (bufnext - 1 == patbuf || bufnext[-2] != M_ALL || - bufnext - 2 == patbuf || bufnext[-3] != M_ALL))) - *bufnext++ = M_ALL; - break; - default: - *bufnext++ = CHAR(c); - break; - } - } - *bufnext = EOS; -#ifdef DEBUG - qprintf("glob0", patbuf); -#endif - - if ((error = glob1(patbuf, pglob, limit)) != 0) - return error; - - if (pglob->gl_pathc == oldpathc) { - /* - * If there was no match we are going to append the pattern - * if GLOB_NOCHECK was specified or if GLOB_NOMAGIC was - * specified and the pattern did not contain any magic - * characters GLOB_NOMAGIC is there just for compatibility - * with csh. - */ - if ((pglob->gl_flags & GLOB_NOCHECK) || - ((pglob->gl_flags & (GLOB_NOMAGIC|GLOB_MAGCHAR)) - == GLOB_NOMAGIC)) { - return globextend(pattern, pglob, limit); - } else { - return GLOB_NOMATCH; - } - } else if (!(pglob->gl_flags & GLOB_NOSORT)) { - qsort(pglob->gl_pathv + pglob->gl_offs + oldpathc, - (size_t)pglob->gl_pathc - oldpathc, sizeof(char *), - compare); - } - - return 0; -} - -static int -compare(const void *p, const void *q) -{ - - _DIAGASSERT(p != NULL); - _DIAGASSERT(q != NULL); - - return strcoll(*(const char * const *)p, *(const char * const *)q); -} - -static int -glob1(Char *pattern, glob_t *pglob, struct glob_limit *limit) -{ - Char pathbuf[MAXPATHLEN+1]; - - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(pglob != NULL); - - /* A null pathname is invalid -- POSIX 1003.1 sect. 2.4. */ - if (*pattern == EOS) - return 0; - /* - * we save one character so that we can use ptr >= limit, - * in the general case when we are appending non nul chars only. - */ - return glob2(pathbuf, pathbuf, - pathbuf + (sizeof(pathbuf) / sizeof(*pathbuf)) - 1, pattern, - pglob, limit); -} - -/* - * The functions glob2 and glob3 are mutually recursive; there is one level - * of recursion for each segment in the pattern that contains one or more - * meta characters. - */ -static int -glob2(Char *pathbuf, Char *pathend, Char *pathlim, const Char *pattern, - glob_t *pglob, struct glob_limit *limit) -{ - __gl_stat_t sb; - const Char *p; - Char *q; - int anymeta; - - _DIAGASSERT(pathbuf != NULL); - _DIAGASSERT(pathend != NULL); - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(pglob != NULL); - -#ifdef DEBUG - qprintf("glob2", pathbuf); -#endif - /* - * Loop over pattern segments until end of pattern or until - * segment with meta character found. - */ - for (anymeta = 0;;) { - if (*pattern == EOS) { /* End of pattern? */ - *pathend = EOS; - if (g_lstat(pathbuf, &sb, pglob)) - return 0; - - if ((pglob->gl_flags & GLOB_LIMIT) && - limit->l_stat++ >= GLOB_LIMIT_STAT) { - errno = 0; - *pathend++ = SEP; - *pathend = EOS; - return GLOB_NOSPACE; - } - if (((pglob->gl_flags & GLOB_MARK) && - pathend[-1] != SEP) && (S_ISDIR(sb.st_mode) || - (S_ISLNK(sb.st_mode) && - (g_stat(pathbuf, &sb, pglob) == 0) && - S_ISDIR(sb.st_mode)))) { - if (pathend >= pathlim) - return GLOB_ABORTED; - *pathend++ = SEP; - *pathend = EOS; - } - ++pglob->gl_matchc; - return globextend(pathbuf, pglob, limit); - } - - /* Find end of next segment, copy tentatively to pathend. */ - q = pathend; - p = pattern; - while (*p != EOS && *p != SEP) { - if (ismeta(*p)) - anymeta = 1; - if (q >= pathlim) - return GLOB_ABORTED; - *q++ = *p++; - } - - if (!anymeta) { - pathend = q; - pattern = p; - while (*pattern == SEP) { - if (pathend >= pathlim) - return GLOB_ABORTED; - *pathend++ = *pattern++; - } - } else /* Need expansion, recurse. */ - return glob3(pathbuf, pathend, pathlim, pattern, p, - pattern, pglob, limit); - } - /* NOTREACHED */ -} - -static int -glob3(Char *pathbuf, Char *pathend, Char *pathlim, const Char *pattern, - const Char *restpattern, const Char *pglobstar, glob_t *pglob, - struct glob_limit *limit) -{ - struct dirent *dp; - DIR *dirp; - __gl_stat_t sbuf; - int error; - char buf[MAXPATHLEN]; - int globstar = 0; - int chase_symlinks = 0; - const Char *termstar = NULL; - - /* - * The readdirfunc declaration can't be prototyped, because it is - * assigned, below, to two functions which are prototyped in glob.h - * and dirent.h as taking pointers to differently typed opaque - * structures. - */ - struct dirent *(*readdirfunc)(void *); - - _DIAGASSERT(pathbuf != NULL); - _DIAGASSERT(pathend != NULL); - _DIAGASSERT(pattern != NULL); - _DIAGASSERT(restpattern != NULL); - _DIAGASSERT(pglob != NULL); - - *pathend = EOS; - errno = 0; - - while (pglobstar < restpattern) { - if ((pglobstar[0] & M_MASK) == M_ALL && - (pglobstar[1] & M_MASK) == M_ALL) { - globstar = 1; - chase_symlinks = (pglobstar[2] & M_MASK) == M_ALL; - termstar = pglobstar + (2 + chase_symlinks); - break; - } - pglobstar++; - } - - if (globstar) { - error = pglobstar == pattern && termstar == restpattern ? - *restpattern == EOS ? - glob2(pathbuf, pathend, pathlim, restpattern - 1, pglob, - limit) : - glob2(pathbuf, pathend, pathlim, restpattern + 1, pglob, - limit) : - glob3(pathbuf, pathend, pathlim, pattern, restpattern, - termstar, pglob, limit); - if (error) - return error; - *pathend = EOS; - } - - if (*pathbuf && (g_lstat(pathbuf, &sbuf, pglob) || - !S_ISDIR(sbuf.st_mode) -#ifdef S_IFLINK - && ((globstar && !chase_symlinks) || !S_ISLNK(sbuf.st_mode)) -#endif - )) - return 0; - - if ((dirp = g_opendir(pathbuf, pglob)) == NULL) { - if (pglob->gl_errfunc) { - if (g_Ctoc(pathbuf, buf, sizeof(buf))) - return GLOB_ABORTED; - if (pglob->gl_errfunc(buf, errno) || - pglob->gl_flags & GLOB_ERR) - return GLOB_ABORTED; - } - /* - * Posix/XOpen: glob should return when it encounters a - * directory that it cannot open or read - * XXX: Should we ignore ENOTDIR and ENOENT though? - * I think that Posix had in mind EPERM... - */ - if (pglob->gl_flags & GLOB_ERR) - return GLOB_ABORTED; - - return 0; - } - - error = 0; - - /* Search directory for matching names. */ - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - readdirfunc = pglob->gl_readdir; - else - readdirfunc = (struct dirent *(*)(void *)) readdir; - while ((dp = (*readdirfunc)(dirp)) != NULL) { - unsigned char *sc; - Char *dc; - - if ((pglob->gl_flags & GLOB_LIMIT) && - limit->l_readdir++ >= GLOB_LIMIT_READDIR) { - errno = 0; - *pathend++ = SEP; - *pathend = EOS; - error = GLOB_NOSPACE; - break; - } - - /* - * Initial DOT must be matched literally, unless we have - * GLOB_PERIOD set. - */ - if ((pglob->gl_flags & GLOB_PERIOD) == 0) - if (dp->d_name[0] == DOT && *pattern != DOT) - continue; - /* - * If GLOB_NO_DOTDIRS is set, . and .. vanish. - */ - if ((pglob->gl_flags & GLOB_NO_DOTDIRS) && - (dp->d_name[0] == DOT) && - ((dp->d_name[1] == EOS) || - ((dp->d_name[1] == DOT) && (dp->d_name[2] == EOS)))) - continue; - /* - * The resulting string contains EOS, so we can - * use the pathlim character, if it is the nul - */ - for (sc = (unsigned char *) dp->d_name, dc = pathend; - dc <= pathlim && (*dc++ = *sc++) != EOS;) - continue; - - /* - * Have we filled the buffer without seeing EOS? - */ - if (dc > pathlim && *pathlim != EOS) { - /* - * Abort when requested by caller, otherwise - * reset pathend back to last SEP and continue - * with next dir entry. - */ - if (pglob->gl_flags & GLOB_ERR) { - error = GLOB_ABORTED; - break; - } - else { - *pathend = EOS; - continue; - } - } - - if (globstar) { -#ifdef S_IFLNK - if (!chase_symlinks && - (g_lstat(pathbuf, &sbuf, pglob) || - S_ISLNK(sbuf.st_mode))) - continue; -#endif - - if (!match(pathend, pattern, termstar)) - continue; - - if (--dc < pathlim - 2) - *dc++ = SEP; - *dc = EOS; - error = glob2(pathbuf, dc, pathlim, pglobstar, - pglob, limit); - if (error) - break; - *pathend = EOS; - } else { - if (!match(pathend, pattern, restpattern)) { - *pathend = EOS; - continue; - } - error = glob2(pathbuf, --dc, pathlim, restpattern, - pglob, limit); - if (error) - break; - } - } - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - (*pglob->gl_closedir)(dirp); - else - closedir(dirp); - - /* - * Again Posix X/Open issue with regards to error handling. - */ - if ((error || errno) && (pglob->gl_flags & GLOB_ERR)) - return GLOB_ABORTED; - - return error; -} - - -/* - * Extend the gl_pathv member of a glob_t structure to accommodate a new item, - * add the new item, and update gl_pathc. - * - * This assumes the BSD realloc, which only copies the block when its size - * crosses a power-of-two boundary; for v7 realloc, this would cause quadratic - * behavior. - * - * Return 0 if new item added, error code if memory couldn't be allocated. - * - * Invariant of the glob_t structure: - * Either gl_pathc is zero and gl_pathv is NULL; or gl_pathc > 0 and - * gl_pathv points to (gl_offs + gl_pathc + 1) items. - */ -static int -globextend(const Char *path, glob_t *pglob, struct glob_limit *limit) -{ - char **pathv; - size_t i, newsize, len; - char *copy; - const Char *p; - - _DIAGASSERT(path != NULL); - _DIAGASSERT(pglob != NULL); - - newsize = sizeof(*pathv) * (2 + pglob->gl_pathc + pglob->gl_offs); - if ((pglob->gl_flags & GLOB_LIMIT) && - newsize > GLOB_LIMIT_PATH * sizeof(*pathv)) - goto nospace; - pathv = pglob->gl_pathv ? realloc(pglob->gl_pathv, newsize) : - malloc(newsize); - if (pathv == NULL) - return GLOB_NOSPACE; - - if (pglob->gl_pathv == NULL && pglob->gl_offs > 0) { - /* first time around -- clear initial gl_offs items */ - pathv += pglob->gl_offs; - for (i = pglob->gl_offs + 1; --i > 0; ) - *--pathv = NULL; - } - pglob->gl_pathv = pathv; - - for (p = path; *p++;) - continue; - len = (size_t)(p - path); - limit->l_string += len; - if ((copy = malloc(len)) != NULL) { - if (g_Ctoc(path, copy, len)) { - free(copy); - return GLOB_ABORTED; - } - pathv[pglob->gl_offs + pglob->gl_pathc++] = copy; - } - pathv[pglob->gl_offs + pglob->gl_pathc] = NULL; - - if ((pglob->gl_flags & GLOB_LIMIT) && - (newsize + limit->l_string) >= GLOB_LIMIT_STRING) - goto nospace; - - return copy == NULL ? GLOB_NOSPACE : 0; -nospace: - errno = 0; - return GLOB_NOSPACE; -} - - -/* - * pattern matching function for filenames. Each occurrence of the * - * pattern causes a recursion level. - */ -static int -match(const Char *name, const Char *pat, const Char *patend) -{ - int ok, negate_range; - Char c, k; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(pat != NULL); - _DIAGASSERT(patend != NULL); - - while (pat < patend) { - c = *pat++; - switch (c & M_MASK) { - case M_ALL: - while (pat < patend && (*pat & M_MASK) == M_ALL) - pat++; /* eat consecutive '*' */ - if (pat == patend) - return 1; - for (; !match(name, pat, patend); name++) - if (*name == EOS) - return 0; - return 1; - case M_ONE: - if (*name++ == EOS) - return 0; - break; - case M_SET: - ok = 0; - if ((k = *name++) == EOS) - return 0; - if ((negate_range = ((*pat & M_MASK) == M_NOT)) != EOS) - ++pat; - while (((c = *pat++) & M_MASK) != M_END) - if ((*pat & M_MASK) == M_RNG) { - if (c <= k && k <= pat[1]) - ok = 1; - pat += 2; - } else if (c == k) - ok = 1; - if (ok == negate_range) - return 0; - break; - default: - if (*name++ != c) - return 0; - break; - } - } - return *name == EOS; -} - -/* Free allocated data belonging to a glob_t structure. */ -void -globfree(glob_t *pglob) -{ - size_t i; - char **pp; - - _DIAGASSERT(pglob != NULL); - - if (pglob->gl_pathv != NULL) { - pp = pglob->gl_pathv + pglob->gl_offs; - for (i = pglob->gl_pathc; i--; ++pp) - if (*pp) - free(*pp); - free(pglob->gl_pathv); - pglob->gl_pathv = NULL; - pglob->gl_pathc = 0; - } -} - -#ifndef __LIBC12_SOURCE__ -int -glob_pattern_p(const char *pattern, int quote) -{ - int range = 0; - - for (; *pattern; pattern++) - switch (*pattern) { - case QUESTION: - case STAR: - return 1; - - case QUOTE: - if (quote && pattern[1] != EOS) - ++pattern; - break; - - case LBRACKET: - range = 1; - break; - - case RBRACKET: - if (range) - return 1; - break; - default: - break; - } - - return 0; -} -#endif - -static DIR * -g_opendir(Char *str, glob_t *pglob) -{ - char buf[MAXPATHLEN]; - - _DIAGASSERT(str != NULL); - _DIAGASSERT(pglob != NULL); - - if (!*str) - (void)strlcpy(buf, ".", sizeof(buf)); - else { - if (g_Ctoc(str, buf, sizeof(buf))) - return NULL; - } - - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return (*pglob->gl_opendir)(buf); - - return opendir(buf); -} - -static int -g_lstat(Char *fn, __gl_stat_t *sb, glob_t *pglob) -{ - char buf[MAXPATHLEN]; - - _DIAGASSERT(fn != NULL); - _DIAGASSERT(sb != NULL); - _DIAGASSERT(pglob != NULL); - - if (g_Ctoc(fn, buf, sizeof(buf))) - return -1; - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return (*pglob->gl_lstat)(buf, sb); - return lstat(buf, sb); -} - -static int -g_stat(Char *fn, __gl_stat_t *sb, glob_t *pglob) -{ - char buf[MAXPATHLEN]; - - _DIAGASSERT(fn != NULL); - _DIAGASSERT(sb != NULL); - _DIAGASSERT(pglob != NULL); - - if (g_Ctoc(fn, buf, sizeof(buf))) - return -1; - if (pglob->gl_flags & GLOB_ALTDIRFUNC) - return (*pglob->gl_stat)(buf, sb); - return stat(buf, sb); -} - -static Char * -g_strchr(const Char *str, int ch) -{ - - _DIAGASSERT(str != NULL); - - do { - if (*str == ch) - return __UNCONST(str); - } while (*str++); - return NULL; -} - -static int -g_Ctoc(const Char *str, char *buf, size_t len) -{ - char *dc; - - _DIAGASSERT(str != NULL); - _DIAGASSERT(buf != NULL); - - if (len == 0) - return 1; - - for (dc = buf; len && (*dc++ = *str++) != EOS; len--) - continue; - - return len == 0; -} - -#ifdef DEBUG -static void -qprintf(const char *str, Char *s) -{ - Char *p; - - _DIAGASSERT(str != NULL); - _DIAGASSERT(s != NULL); - - (void)printf("%s:\n", str); - for (p = s; *p; p++) - (void)printf("%c", CHAR(*p)); - (void)printf("\n"); - for (p = s; *p; p++) - (void)printf("%c", *p & M_PROTECT ? '"' : ' '); - (void)printf("\n"); - for (p = s; *p; p++) - (void)printf("%c", ismeta(*p) ? '_' : ' '); - (void)printf("\n"); -} -#endif diff --git a/lib/libc/gen/gr_private.h b/lib/libc/gen/gr_private.h deleted file mode 100644 index 2532a1754..000000000 --- a/lib/libc/gen/gr_private.h +++ /dev/null @@ -1,114 +0,0 @@ -/* $NetBSD: gr_private.h,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2004-2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Structures and functions used by various group(5) public functions - * and their back-end implementations. - * These are subject to change without notice and should not be used - * outside of libc (even by third-party nss_*.so modules implementing - * group(5) back-ends). - */ - -#define _GROUP_COMPAT /* "group" defaults to compat, so always provide it */ - - -#if defined(__minix) && defined(_REENTRANT) - /* - * mutex to serialize the public group(5) functions use of the - * back-end implementations, which may not be reentrant. - */ -extern mutex_t __grmutex; -#endif /* defined(__minix) */ - - /* - * files methods - */ -struct __grstate_files { /* state shared between files methods */ - int stayopen; /* see getgroupent(3) */ - FILE *fp; /* groups file handle */ -}; - -extern int __grstart_files(struct __grstate_files *); -extern int __grend_files(struct __grstate_files *); -extern int __grscan_files(int *, struct group *, char *, size_t, - struct __grstate_files *, int, const char *, gid_t); - - /* - * dns methods - */ -struct __grstate_dns { /* state shared between dns methods */ - int stayopen; /* see getgroupent(3) */ - void *context; /* Hesiod context */ - int num; /* group index, -1 if no more */ -}; - -extern int __grstart_dns(struct __grstate_dns *); -extern int __grend_dns(struct __grstate_dns *state); -extern int __grscan_dns(int *, struct group *, char *, size_t, - struct __grstate_dns *, int, const char *, gid_t); - - /* - * nis methods - */ -struct __grstate_nis { /* state shared between nis methods */ - int stayopen; /* see getgroupent(3) */ - char *domain; /* NIS domain */ - int done; /* non-zero if search exhausted */ - char *current; /* current first/next match */ - int currentlen; /* length of _nis_current */ -}; - -extern int __grstart_nis(struct __grstate_nis *); -extern int __grend_nis(struct __grstate_nis *); -extern int __grscan_nis(int *, struct group *, char *, size_t, - struct __grstate_nis *, int, const char *, gid_t); - - /* - * compat methods - */ -struct __grstate_compat { /* state shared between compat methods */ - int stayopen; /* see getgroupent(3) */ - FILE *fp; /* file handle */ -/* - * XXX: convert name to a separate compatstate enum and grow name as necessary - * instead of using strdup & free for each + line - */ - char *name; /* NULL if reading file, */ - /* "" if compat "+", */ - /* name if compat "+name" */ -}; - -extern int __grbad_compat(void *nsrv, void *nscb, va_list ap); -extern int __grstart_compat(struct __grstate_compat *); -extern int __grend_compat(struct __grstate_compat *); -extern int __grscan_compat(int *, struct group *, char *, size_t, - struct __grstate_compat *, int, const char *, gid_t, - int (*)(void *, struct group **), void *); diff --git a/lib/libc/gen/humanize_number.3 b/lib/libc/gen/humanize_number.3 deleted file mode 100644 index b078c3785..000000000 --- a/lib/libc/gen/humanize_number.3 +++ /dev/null @@ -1,168 +0,0 @@ -.\" $NetBSD: humanize_number.3,v 1.11 2011/08/20 21:35:32 wiz Exp $ -.\" -.\" Copyright (c) 1999, 2002, 2008 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Luke Mewburn and by Tomas Svensson. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd January 14, 2011 -.Dt HUMANIZE_NUMBER 3 -.Os -.Sh NAME -.Nm dehumanize_number , -.Nm humanize_number -.Nd format a number into a human readable form and vice versa -.Sh SYNOPSIS -.In stdlib.h -.Ft int -.Fn dehumanize_number "const char *str" "int64_t *result" -.Ft int -.Fn humanize_number "char *buffer" "size_t len" "int64_t number" "const char *suffix" "int scale" "int flags" -.Sh DESCRIPTION -The -.Fn humanize_number -function formats the signed 64 bit quantity given in -.Fa number -into -.Fa buffer . -A space and then -.Fa suffix -is appended to the end. -.Fa buffer -must be at least -.Fa len -bytes long. -.Pp -If the formatted number (including -.Fa suffix ) -would be too long to fit into -.Fa buffer , -then divide -.Fa number -by 1024 until it will. -In this case, prefix -.Fa suffix -with the appropriate SI designator. -.Pp -The prefixes are: -.Bl -column "Prefix" "Description" "Multiplier" -offset indent -.It Sy "Prefix" Ta Sy "Description" Ta Sy "Multiplier" -.It k kilo 1024 -.It M mega 1048576 -.It G giga 1073741824 -.It T tera 1099511627776 -.It P peta 1125899906842624 -.It E exa 1152921504606846976 -.El -.Pp -.Fa len -must be at least 4 plus the length of -.Fa suffix , -in order to ensure a useful result is generated into -.Fa buffer . -To use a specific prefix, specify this as -.Fa scale -(Multiplier = 1024 ^ scale). -This can not be combined with any of the -.Fa scale -flags below. -.Pp -The following flags may be passed in -.Pa scale : -.Bl -tag -width Dv -offset indent -.It Dv HN_AUTOSCALE -Format the buffer using the lowest multiplier possible. -.It Dv HN_GETSCALE -Return the prefix index number (the number of times -.Fa number -must be divided to fit) instead of formatting it to the buffer. -.El -.Pp -The following flags may be passed in -.Pa flags : -.Bl -tag -width Dv -offset indent -.It Dv HN_DECIMAL -If the final result is less than 10, display it using one digit. -.It Dv HN_NOSPACE -Do not put a space between -.Fa number -and the prefix. -.It Dv HN_B -Use 'B' (bytes) as prefix if the original result does not have a prefix. -.It Dv HN_DIVISOR_1000 -Divide -.Fa number -with 1000 instead of 1024. -.El -.Pp -The -.Fn dehumanize_number -function parses the string representing an integral value given in -.Fa str -and stores the numerical value in the integer pointed to by -.Fa result . -The provided string may hold one of the suffixes, which will be interpreted -and used to scale up its accompanying numerical value. -.Sh RETURN VALUES -.Fn humanize_number -returns the number of characters stored in -.Fa buffer -(excluding the terminating NUL) upon success, or \-1 upon failure. -If -.Dv HN_GETSCALE -is specified, the prefix index number will be returned instead. -.Pp -.Fn dehumanize_number -returns 0 if the string was parsed correctly. -A \-1 is returned to indicate failure and an error code is stored in -.Va errno . -.Sh ERRORS -.Fn dehumanize_number -will fail and no number will be stored in -.Fa result -if: -.Bl -tag -width Er -.It Bq Er EINVAL -The string in -.Fa str -was empty or carried an unknown suffix. -.It Bq Er ERANGE -The string in -.Fa str -represented a number that does not fit in -.Fa result . -.El -.Sh SEE ALSO -.Xr strsuftoll 3 , -.Xr orders 7 , -.Xr humanize_number 9 -.Sh HISTORY -.Fn humanize_number -first appeared in -.Nx 2.0 . -.Pp -.Fn dehumanize_number -first appeared in -.Nx 5.0 . diff --git a/lib/libc/gen/humanize_number.c b/lib/libc/gen/humanize_number.c deleted file mode 100644 index 533560f31..000000000 --- a/lib/libc/gen/humanize_number.c +++ /dev/null @@ -1,161 +0,0 @@ -/* $NetBSD: humanize_number.c,v 1.16 2012/03/17 20:01:14 christos Exp $ */ - -/* - * Copyright (c) 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Jason R. Thorpe of the Numerical Aerospace Simulation Facility, - * NASA Ames Research Center, by Luke Mewburn and by Tomas Svensson. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: humanize_number.c,v 1.16 2012/03/17 20:01:14 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -int -humanize_number(char *buf, size_t len, int64_t bytes, - const char *suffix, int scale, int flags) -{ - const char *prefixes, *sep; - int b, r, s1, s2, sign; - int64_t divisor, max, post = 1; - size_t i, baselen, maxscale; - - _DIAGASSERT(buf != NULL); - _DIAGASSERT(suffix != NULL); - _DIAGASSERT(scale >= 0); - - if (flags & HN_DIVISOR_1000) { - /* SI for decimal multiplies */ - divisor = 1000; - if (flags & HN_B) - prefixes = "B\0k\0M\0G\0T\0P\0E"; - else - prefixes = "\0\0k\0M\0G\0T\0P\0E"; - } else { - /* - * binary multiplies - * XXX IEC 60027-2 recommends Ki, Mi, Gi... - */ - divisor = 1024; - if (flags & HN_B) - prefixes = "B\0K\0M\0G\0T\0P\0E"; - else - prefixes = "\0\0K\0M\0G\0T\0P\0E"; - } - -#define SCALE2PREFIX(scale) (&prefixes[(scale) << 1]) - maxscale = 7; - - if ((size_t)scale >= maxscale && - (scale & (HN_AUTOSCALE | HN_GETSCALE)) == 0) - return (-1); - - if (buf == NULL || suffix == NULL) - return (-1); - - if (len > 0) - buf[0] = '\0'; - if (bytes < 0) { - sign = -1; - baselen = 3; /* sign, digit, prefix */ - if (-bytes < INT64_MAX / 100) - bytes *= -100; - else { - bytes = -bytes; - post = 100; - baselen += 2; - } - } else { - sign = 1; - baselen = 2; /* digit, prefix */ - if (bytes < INT64_MAX / 100) - bytes *= 100; - else { - post = 100; - baselen += 2; - } - } - if (flags & HN_NOSPACE) - sep = ""; - else { - sep = " "; - baselen++; - } - baselen += strlen(suffix); - - /* Check if enough room for `x y' + suffix + `\0' */ - if (len < baselen + 1) - return (-1); - - if (scale & (HN_AUTOSCALE | HN_GETSCALE)) { - /* See if there is additional columns can be used. */ - for (max = 100, i = len - baselen; i-- > 0;) - max *= 10; - - /* - * Divide the number until it fits the given column. - * If there will be an overflow by the rounding below, - * divide once more. - */ - for (i = 0; bytes >= max - 50 && i < maxscale; i++) - bytes /= divisor; - - if (scale & HN_GETSCALE) { - _DIAGASSERT(__type_fit(int, i)); - return (int)i; - } - } else - for (i = 0; i < (size_t)scale && i < maxscale; i++) - bytes /= divisor; - bytes *= post; - - /* If a value <= 9.9 after rounding and ... */ - if (bytes < 995 && i > 0 && flags & HN_DECIMAL) { - /* baselen + \0 + .N */ - if (len < baselen + 1 + 2) - return (-1); - b = ((int)bytes + 5) / 10; - s1 = b / 10; - s2 = b % 10; - r = snprintf(buf, len, "%d%s%d%s%s%s", - sign * s1, localeconv()->decimal_point, s2, - sep, SCALE2PREFIX(i), suffix); - } else - r = snprintf(buf, len, "%" PRId64 "%s%s%s", - sign * ((bytes + 50) / 100), - sep, SCALE2PREFIX(i), suffix); - - return (r); -} diff --git a/lib/libc/gen/infinity_ieee754.c b/lib/libc/gen/infinity_ieee754.c deleted file mode 100644 index 56a540c69..000000000 --- a/lib/libc/gen/infinity_ieee754.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: infinity_ieee754.c,v 1.3 2005/06/12 05:21:27 lukem Exp $ */ - -/* - * IEEE-compatible infinity.c -- public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinity_ieee754.c,v 1.3 2005/06/12 05:21:27 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -const union __double_u __infinity = -#if BYTE_ORDER == BIG_ENDIAN - { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; -#else - { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; -#endif diff --git a/lib/libc/gen/infinityf_ieee754.c b/lib/libc/gen/infinityf_ieee754.c deleted file mode 100644 index fedbcf36d..000000000 --- a/lib/libc/gen/infinityf_ieee754.c +++ /dev/null @@ -1,20 +0,0 @@ -/* $NetBSD: infinityf_ieee754.c,v 1.2 2005/06/12 05:21:27 lukem Exp $ */ - -/* - * IEEE-compatible infinityf.c -- public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinityf_ieee754.c,v 1.2 2005/06/12 05:21:27 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -const union __float_u __infinityf = -#if BYTE_ORDER == BIG_ENDIAN - { { 0x7f, 0x80, 0, 0 } }; -#else - { { 0, 0, 0x80, 0x7f } }; -#endif diff --git a/lib/libc/gen/infinityl_dbl_ieee754.c b/lib/libc/gen/infinityl_dbl_ieee754.c deleted file mode 100644 index 3b77bdfe8..000000000 --- a/lib/libc/gen/infinityl_dbl_ieee754.c +++ /dev/null @@ -1,21 +0,0 @@ -/* $NetBSD: infinityl_dbl_ieee754.c,v 1.1 2003/10/25 22:31:20 kleink Exp $ */ - -/* - * IEEE-compatible infinityl.c -- public domain. - * For platforms where long double == double. - */ - -#include -#include -#include - -#if LDBL_MANT_DIG != DBL_MANT_DIG -#error double / long double mismatch -#endif - -const union __long_double_u __infinityl = -#if BYTE_ORDER == BIG_ENDIAN - { { 0x7f, 0xf0, 0, 0, 0, 0, 0, 0 } }; -#else - { { 0, 0, 0, 0, 0, 0, 0xf0, 0x7f } }; -#endif diff --git a/lib/libc/gen/infinityl_ieee754.c b/lib/libc/gen/infinityl_ieee754.c deleted file mode 100644 index 7506faac0..000000000 --- a/lib/libc/gen/infinityl_ieee754.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: infinityl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $ */ - -/* - * IEEE-compatible infinityl.c for 64-bit or 128-bit long double format. - * This is public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: infinityl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#ifdef __HAVE_LONG_DOUBLE -#define LDBL_EXPBITS EXT_EXPBITS -#define LDBL_EXP_INFNAN EXT_EXP_INFNAN -#else -#define LDBL_EXPBITS DBL_EXPBITS -#define LDBL_EXP_INFNAN DBL_EXP_INFNAN -#endif - -#define EXP_INFNAN (LDBL_EXP_INFNAN << (31 - LDBL_EXPBITS)) - -const union __long_double_u __infinityl = { { -#if BYTE_ORDER == BIG_ENDIAN - [0] = (EXP_INFNAN >> 24) & 0x7f, - [1] = (EXP_INFNAN >> 16) & 0xff, - [2] = (EXP_INFNAN >> 8) & 0xff, - [3] = (EXP_INFNAN >> 0) & 0xff, -#else - [sizeof(long double)-4] = (EXP_INFNAN >> 0) & 0xff, - [sizeof(long double)-3] = (EXP_INFNAN >> 8) & 0xff, - [sizeof(long double)-2] = (EXP_INFNAN >> 16) & 0xff, - [sizeof(long double)-1] = (EXP_INFNAN >> 24) & 0x7f, -#endif -} }; diff --git a/lib/libc/gen/initdir.c b/lib/libc/gen/initdir.c deleted file mode 100644 index a0623e5e1..000000000 --- a/lib/libc/gen/initdir.c +++ /dev/null @@ -1,276 +0,0 @@ -/* $NetBSD: initdir.c,v 1.3 2012/03/13 21:13:36 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: initdir.c,v 1.3 2012/03/13 21:13:36 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include "extern.h" - -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "dirent_private.h" - -#define MAXITERATIONS 100 - -int -_initdir(DIR *dirp, int fd, const char *name) -{ - int flags = dirp->dd_flags; - int pagesz; - int incr; - - /* - * If the machine's page size is an exact multiple of DIRBLKSIZ, - * use a buffer that is cluster boundary aligned. - * Hopefully this can be a big win someday by allowing page trades - * to user space to be done by getdents() - */ - if (((pagesz = getpagesize()) % DIRBLKSIZ) == 0) - incr = pagesz; - else - incr = DIRBLKSIZ; - - if ((flags & DTF_REWIND) && name == NULL) { - return EINVAL; - } - if ((flags & __DTF_READALL) != 0) { - size_t len; - size_t space; - char *buf, *nbuf; - char *ddptr; - char *ddeptr; - int n; - struct dirent **dpv; - int i; - - /* - * The strategy here for directories on top of a union stack - * is to read all the directory entries into a buffer, sort - * the buffer, and remove duplicate entries by setting the - * inode number to zero. - * - * For directories on an NFS mounted filesystem, we try - * to get a consistent snapshot by trying until we have - * successfully read all of the directory without errors - * (i.e. 'bad cookie' errors from the server because - * the directory was modified). These errors should not - * happen often, but need to be dealt with. - */ - i = 0; -retry: - len = 0; - space = 0; - buf = 0; - ddptr = 0; - - do { - /* - * Always make at least DIRBLKSIZ bytes - * available to getdents - */ - if (space < DIRBLKSIZ) { - space += incr; - len += incr; - nbuf = realloc(buf, len); - if (nbuf == NULL) { - dirp->dd_buf = buf; - return errno; - } - buf = nbuf; - ddptr = buf + (len - space); - } - - dirp->dd_seek = lseek(fd, (off_t)0, SEEK_CUR); - n = getdents(fd, ddptr, space); - /* - * For NFS: EINVAL means a bad cookie error - * from the server. Keep trying to get a - * consistent view, in this case this means - * starting all over again. - */ - if (n == -1 && errno == EINVAL && - (flags & __DTF_RETRY_ON_BADCOOKIE) != 0) { - free(buf); - lseek(fd, (off_t)0, SEEK_SET); - if (++i > MAXITERATIONS) - return EINVAL; - goto retry; - } - if (n > 0) { - ddptr += n; - space -= n; - } - } while (n > 0); - - ddeptr = ddptr; - - /* - * Re-open the directory. - * This has the effect of rewinding back to the - * top of the union stack and is needed by - * programs which plan to fchdir to a descriptor - * which has also been read -- see fts.c. - */ - if (flags & DTF_REWIND) { - (void) close(fd); - if ((fd = open(name, O_RDONLY | O_CLOEXEC)) == -1) { - dirp->dd_buf = buf; - return errno; - } - } - - /* - * There is now a buffer full of (possibly) duplicate - * names. - */ - dirp->dd_buf = buf; - - /* - * Go round this loop twice... - * - * Scan through the buffer, counting entries. - * On the second pass, save pointers to each one. - * Then sort the pointers and remove duplicate names. - */ - if ((flags & DTF_NODUP) != 0) { - for (dpv = 0;;) { - for (n = 0, ddptr = buf; ddptr < ddeptr;) { - struct dirent *dp; - - dp = (struct dirent *)(void *)ddptr; - if ((long)dp & _DIRENT_ALIGN(dp)) - break; - /* - * d_reclen is unsigned, - * so no need to compare <= 0 - */ - if (dp->d_reclen > (ddeptr + 1 - ddptr)) - break; - ddptr += dp->d_reclen; - if (dp->d_fileno) { - if (dpv) - dpv[n] = dp; - n++; - } - } - - if (dpv) { - struct dirent *xp; - - /* - * This sort must be stable. - */ - mergesort(dpv, (size_t)n, sizeof(*dpv), - alphasort); - - dpv[n] = NULL; - xp = NULL; - - /* - * Scan through the buffer in sort - * order, zapping the inode number - * of any duplicate names. - */ - for (n = 0; dpv[n]; n++) { - struct dirent *dp = dpv[n]; - - if ((xp == NULL) || - strcmp(dp->d_name, - xp->d_name)) - xp = dp; - else - dp->d_fileno = 0; -#if !defined(__minix) - if (dp->d_type == DT_WHT && - (flags & DTF_HIDEW)) - dp->d_fileno = 0; -#endif /* !defined(__minix) */ - } - - free(dpv); - break; - } else { - dpv = malloc((n + 1) * - sizeof(struct dirent *)); - if (dpv == NULL) - break; - } - } - } - - _DIAGASSERT(__type_fit(int, len)); - dirp->dd_len = (int)len; - dirp->dd_size = ddptr - dirp->dd_buf; - } else { - dirp->dd_len = incr; - dirp->dd_buf = malloc((size_t)dirp->dd_len); - if (dirp->dd_buf == NULL) - return errno; - dirp->dd_seek = 0; - flags &= ~DTF_REWIND; - } - dirp->dd_loc = 0; - dirp->dd_fd = fd; - dirp->dd_flags = flags; - /* - * Set up seek point for rewinddir. - */ - (void)_telldir_unlocked(dirp); - return 0; -} - -void -_finidir(DIR *dirp) -{ - struct dirpos *poslist; - - free(dirp->dd_buf); - - /* free seekdir/telldir storage */ - for (poslist = dirp->dd_internal; poslist; ) { - struct dirpos *nextpos = poslist->dp_next; - free(poslist); - poslist = nextpos; - } - dirp->dd_internal = NULL; -} diff --git a/lib/libc/gen/initgroups.3 b/lib/libc/gen/initgroups.3 deleted file mode 100644 index 56e52a4f1..000000000 --- a/lib/libc/gen/initgroups.3 +++ /dev/null @@ -1,91 +0,0 @@ -.\" $NetBSD: initgroups.3,v 1.15 2003/08/07 16:42:51 agc Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)initgroups.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd August 10, 2002 -.Dt INITGROUPS 3 -.Os -.Sh NAME -.Nm initgroups -.Nd initialize supplementary group IDs -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn initgroups "const char *name" "gid_t basegid" -.Sh DESCRIPTION -The -.Fn initgroups -function -uses the -.Xr getgrouplist 3 -function to calculate the supplementary group IDs for the user -specified in -.Fa name . -This group list is then set up for the current process using -.Xr setgroups 2 . -The -.Fa basegid -is automatically included in the group list. -Typically this value is given as -the group number from the password file. -.Pp -If the groups database lists more than -.Ev NGROUPS -groups for -.Fa name -(including one for -.Fa basegid ) , -the later groups are ignored. -.Sh RETURN VALUES -The -.Fn initgroups -function -returns \-1 if it was not invoked by the super-user. -.Sh SEE ALSO -.Xr setgroups 2 , -.Xr getgrouplist 3 -.Sh HISTORY -The -.Fn initgroups -function appeared in -.Bx 4.2 . -.Sh BUGS -The -.Fn getgrouplist -function called by -.Fn initgroups -uses the routines based on -.Xr getgrent 3 . -If the invoking program uses any of these routines, -the group structure will -be overwritten in the call to -.Fn initgroups . diff --git a/lib/libc/gen/initgroups.c b/lib/libc/gen/initgroups.c deleted file mode 100644 index 86c6f4ef3..000000000 --- a/lib/libc/gen/initgroups.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: initgroups.c,v 1.22 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)initgroups.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: initgroups.c,v 1.22 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(initgroups,_initgroups) -#endif - -int -initgroups(const char *uname, gid_t agroup) -{ - gid_t groups_list[NGROUPS]; - int ngroups; - gid_t *groups = groups_list; - int rval; - - _DIAGASSERT(uname != NULL); - - ngroups = NGROUPS; - if (getgrouplist(uname, agroup, groups, &ngroups) == -1) { - int maxgroups = ngroups; - groups = calloc((size_t)maxgroups, sizeof *groups); - if (groups == NULL) - return -1; - if (getgrouplist(uname, agroup, groups, &ngroups) == -1) - ngroups = maxgroups; - } - rval = setgroups(ngroups, groups); - if (rval == -1 && errno == EINVAL) { - int ng = (int)sysconf(_SC_NGROUPS_MAX); - if (ng > 0 && ng < ngroups) - rval = setgroups(ng, groups); - } - if (groups != groups_list) - free(groups); - return rval; -} diff --git a/lib/libc/gen/isalnum.3 b/lib/libc/gen/isalnum.3 deleted file mode 100644 index 53d6ec08f..000000000 --- a/lib/libc/gen/isalnum.3 +++ /dev/null @@ -1,97 +0,0 @@ -.\" $NetBSD: isalnum.3,v 1.15 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isalnum.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISALNUM 3 -.Os -.Sh NAME -.Nm isalnum -.Nd alphanumeric character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isalnum "int c" -.Sh DESCRIPTION -The -.Fn isalnum -function tests for any character for which -.Xr isalpha 3 -or -.Xr isdigit 3 -is true. -.Sh RETURN VALUES -The -.Fn isalnum -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isalnum -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isalnum -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isalpha.3 b/lib/libc/gen/isalpha.3 deleted file mode 100644 index 51c9022ae..000000000 --- a/lib/libc/gen/isalpha.3 +++ /dev/null @@ -1,114 +0,0 @@ -.\" $NetBSD: isalpha.3,v 1.14 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isalpha.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISALPHA 3 -.Os -.Sh NAME -.Nm isalpha -.Nd alphabetic character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isalpha "int c" -.Sh DESCRIPTION -The -.Fn isalpha -function tests for any character for which -.Xr isupper 3 -or -.Xr islower 3 -is true and -.\" , or any of an implementation-defined set of characters -for which none of -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr ispunct 3 , -or -.Xr isspace 3 -is true. -In the -.Em ``C'' -locale, -.Fn isalpha -returns true only for the characters for which -.Xr isupper 3 -or -.Xr islower 3 -is true. -.Sh RETURN VALUES -The -.Fn isalpha -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isalpha -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isalpha -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isascii.3 b/lib/libc/gen/isascii.3 deleted file mode 100644 index ecb5830dc..000000000 --- a/lib/libc/gen/isascii.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" $NetBSD: isascii.3,v 1.18 2010/04/30 04:46:18 jruoho Exp $ -.\" -.\" Copyright (c) 1989, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isascii.3 5.1 (Berkeley) 5/2/91 -.\" -.Dd April 30, 2010 -.Dt ISASCII 3 -.Os -.Sh NAME -.Nm isascii -.Nd test for ASCII character -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isascii "int c" -.Sh DESCRIPTION -The -.Fn isascii -function tests for an -.Tn ASCII -character, which is any character with a value in the -range from 0 to 127, inclusive. -.Pp -The -.Fn isascii -is defined on all integer values. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isascii -function conforms to -.St -xpg4 -and -.St -p1003.1-2001 . -The -.St -p1003.1-2008 -revision however marked it as obsolete, noting that -.Fn isascii -cannot be used portably in a localized application. diff --git a/lib/libc/gen/isascii.c b/lib/libc/gen/isascii.c deleted file mode 100644 index d5fff2d03..000000000 --- a/lib/libc/gen/isascii.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: isascii.c,v 1.4 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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. - * - * from: @(#)isctype.c 5.2 (Berkeley) 6/1/90 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isascii.c,v 1.4 2012/06/25 22:32:43 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define _CTYPE_NOINLINE -#include - -int -isascii(int c) -{ - return ((unsigned)(c) <= 0177); -} diff --git a/lib/libc/gen/isatty.c b/lib/libc/gen/isatty.c deleted file mode 100644 index e7191966c..000000000 --- a/lib/libc/gen/isatty.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: isatty.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isatty.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isatty.c,v 1.13 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(isatty,_isatty) -#endif - -int -isatty(int fd) -{ - struct termios t; - - return(tcgetattr(fd, &t) != -1); -} diff --git a/lib/libc/gen/isblank.3 b/lib/libc/gen/isblank.3 deleted file mode 100644 index 59a5ca167..000000000 --- a/lib/libc/gen/isblank.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $NetBSD: isblank.3,v 1.13 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isspace.3 5.3 (Berkeley) 7/31/91 -.\" -.Dd April 17, 2008 -.Dt ISBLANK 3 -.Os -.Sh NAME -.Nm isblank -.Nd blank-space character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isblank "int c" -.Sh DESCRIPTION -The -.Fn isblank -function tests for the standard blank-space characters. -The standard blank-space characters are the following: -.Pp -.Bl -tag -width xxxxx -offset indent -compact -.It Sq \0 -Space character. -.It Li \et -Horizontal tab. -.El -.Pp -In the -.Em ``C'' -locale, -.Fn isblank -returns true only for the standard blank-space characters. -.Sh RETURN VALUES -The -.Fn isblank -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh CAVEATS -The argument to -.Fn isblank -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/iscntrl.3 b/lib/libc/gen/iscntrl.3 deleted file mode 100644 index efea8f8b8..000000000 --- a/lib/libc/gen/iscntrl.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $NetBSD: iscntrl.3,v 1.13 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)iscntrl.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISCNTRL 3 -.Os -.Sh NAME -.Nm iscntrl -.Nd control character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn iscntrl "int c" -.Sh DESCRIPTION -The -.Fn iscntrl -function tests for any control character. -.Sh RETURN VALUES -The -.Fn iscntrl -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn iscntrl -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn iscntrl -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isctype.c b/lib/libc/gen/isctype.c deleted file mode 100644 index b0b8ba4d8..000000000 --- a/lib/libc/gen/isctype.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: isctype.c,v 1.25 2013/08/19 22:43:28 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isctype.c,v 1.25 2013/08/19 22:43:28 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#define _CTYPE_NOINLINE -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#if EOF != -1 -#error "EOF != -1" -#endif - -#include "runetype_local.h" -#include "setlocale_local.h" - -#define _RUNE_LOCALE(loc) \ - ((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE])) - -#define _ISCTYPE_FUNC(name, bit) \ -int \ -is##name(int c) \ -{ \ - return (int)_ctype_tab_[c + 1] & (bit); \ -} \ -int \ -is##name ## _l(int c, locale_t loc) \ -{ \ - return (int)((_RUNE_LOCALE(loc)->rl_ctype_tab[c + 1]) & (bit)); \ -} - -_ISCTYPE_FUNC(alnum, (_CTYPE_A|_CTYPE_D)) -_ISCTYPE_FUNC(alpha, _CTYPE_A) -_ISCTYPE_FUNC(blank, _CTYPE_BL) -_ISCTYPE_FUNC(cntrl, _CTYPE_C ) -_ISCTYPE_FUNC(digit, _CTYPE_D) -_ISCTYPE_FUNC(graph, _CTYPE_G) -_ISCTYPE_FUNC(lower, _CTYPE_L ) -_ISCTYPE_FUNC(print, _CTYPE_R) -_ISCTYPE_FUNC(punct, _CTYPE_P ) -_ISCTYPE_FUNC(space, _CTYPE_S ) -_ISCTYPE_FUNC(upper, _CTYPE_U ) -_ISCTYPE_FUNC(xdigit, _CTYPE_X) - -int -toupper(int c) -{ - return (int)_toupper_tab_[c + 1]; -} - -int -toupper_l(int c, locale_t loc) -{ - return (int)(_RUNE_LOCALE(loc)->rl_toupper_tab[c + 1]); -} - -int -tolower(int c) -{ - return (int)_tolower_tab_[c + 1]; -} - -int -tolower_l(int c, locale_t loc) -{ - return (int)(_RUNE_LOCALE(loc)->rl_tolower_tab[c + 1]); -} - -int -_toupper(int c) -{ - return (c - 'a' + 'A'); -} - -int -_tolower(int c) -{ - return (c - 'A' + 'a'); -} diff --git a/lib/libc/gen/isdigit.3 b/lib/libc/gen/isdigit.3 deleted file mode 100644 index 80e297c37..000000000 --- a/lib/libc/gen/isdigit.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $NetBSD: isdigit.3,v 1.14 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isdigit.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISDIGIT 3 -.Os -.Sh NAME -.Nm isdigit -.Nd decimal-digit character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isdigit "int c" -.Sh DESCRIPTION -The -.Fn isdigit -function tests for any decimal-digit character. -.Sh RETURN VALUES -The -.Fn isdigit -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isdigit -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isdigit -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isfinite.3 b/lib/libc/gen/isfinite.3 deleted file mode 100644 index dd7eb1bae..000000000 --- a/lib/libc/gen/isfinite.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" $NetBSD: isfinite.3,v 1.4 2011/08/06 11:02:41 jruoho Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd August 6, 2011 -.Dt ISFINITE 3 -.Os -.Sh NAME -.Nm isfinite -.Nd test for finite value -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In math.h -.Ft int -.Fn isfinite "real-floating x" -.Sh DESCRIPTION -The -.Fn isfinite -determines whether its argument -.Fa x -has a finite value. -An argument represented in a format wider than its semantic type is -converted to its semantic type first. -The determination is then based on the type of the argument. -.Ss IEEE 754 -It is determined whether the value of -.Fa x -is zero, subnormal, or normal, and neither infinite nor NaN. -.Ss VAX -It is determined whether the value of -.Fa x -is true zero or finite, and neither dirty zero nor ROP. -.Sh RETURN VALUES -The -.Fn isfinite -macro returns a non-zero value if the value of -.Fa x -is finite. -Otherwise 0 is returned. -.Sh ERRORS -No errors are defined. -.Sh SEE ALSO -.Xr finite 3 , -.Xr fpclassify 3 , -.Xr isnormal 3 , -.Xr math 3 , -.Xr signbit 3 -.Sh STANDARDS -The -.Fn isfinite -macro conforms to -.St -isoC-99 . diff --git a/lib/libc/gen/isfinited_ieee754.c b/lib/libc/gen/isfinited_ieee754.c deleted file mode 100644 index 7cdf6eb78..000000000 --- a/lib/libc/gen/isfinited_ieee754.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: isfinited_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinited_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * IEEE 754 double-precision version - */ -int -__isfinited(double x) -{ - union ieee_double_u u; - - u.dblu_d = x; - - if (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN) - return 0; - - return 1; -} diff --git a/lib/libc/gen/isfinitef_ieee754.c b/lib/libc/gen/isfinitef_ieee754.c deleted file mode 100644 index 6014fb723..000000000 --- a/lib/libc/gen/isfinitef_ieee754.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: isfinitef_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinitef_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * IEEE 754 single-precision version - */ -int -__isfinitef(float x) -{ - union ieee_single_u u; - - u.sngu_f = x; - - if (u.sngu_sng.sng_exp == SNG_EXP_INFNAN) - return 0; - - return 1; -} diff --git a/lib/libc/gen/isfinitel_ieee754.c b/lib/libc/gen/isfinitel_ieee754.c deleted file mode 100644 index d95bfb4c6..000000000 --- a/lib/libc/gen/isfinitel_ieee754.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: isfinitel_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $ */ - -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: isfinitel_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $"); -#endif - -#include -#include - -#ifdef __HAVE_LONG_DOUBLE -/* - * 7.12.3.2 isfinite - determine whether an argument has finite value - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__isfinitel(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - if (u.extu_ext.ext_exp == EXT_EXP_INFNAN) - return 0; - - return 1; -} -#endif /* __HAVE_LONG_DOUBLE */ diff --git a/lib/libc/gen/isgraph.3 b/lib/libc/gen/isgraph.3 deleted file mode 100644 index 083e82c4b..000000000 --- a/lib/libc/gen/isgraph.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $NetBSD: isgraph.3,v 1.14 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isgraph.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISGRAPH 3 -.Os -.Sh NAME -.Nm isgraph -.Nd printing character test (space character exclusive) -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isgraph "int c" -.Sh DESCRIPTION -The -.Fn isgraph -function tests for any printing character except space ('\ '). -.Sh RETURN VALUES -The -.Fn isgraph -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isgraph -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isgraph -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isgreater.3 b/lib/libc/gen/isgreater.3 deleted file mode 100644 index e6fed54a4..000000000 --- a/lib/libc/gen/isgreater.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" $NetBSD: isgreater.3,v 1.1 2007/02/22 22:08:20 drochner Exp $ -.\" -.\" Copyright (c) 2003 David Schultz -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/isgreater.3,v 1.3 2005/02/06 03:23:31 das Exp -.\" -.Dd February 12, 2003 -.Dt ISGREATER 3 -.Os -.Sh NAME -.Nm isgreater , isgreaterequal , isless , islessequal , -.Nm islessgreater , isunordered -.Nd "compare two floating-point numbers" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In math.h -.Ft int -.Fn isgreater "real-floating x" "real-floating y" -.Ft int -.Fn isgreaterequal "real-floating x" "real-floating y" -.Ft int -.Fn isless "real-floating x" "real-floating y" -.Ft int -.Fn islessequal "real-floating x" "real-floating y" -.Ft int -.Fn islessgreater "real-floating x" "real-floating y" -.Ft int -.Fn isunordered "real-floating x" "real-floating y" -.Sh DESCRIPTION -Each of the macros -.Fn isgreater , -.Fn isgreaterequal , -.Fn isless , -.Fn islessequal , -and -.Fn islessgreater -take arguments -.Fa x -and -.Fa y -and return a non-zero value if and only if its nominal -relation on -.Fa x -and -.Fa y -is true. -These macros always return zero if either -argument is not a number (NaN), but unlike the corresponding C -operators, they never raise a floating point exception. -.Pp -The -.Fn isunordered -macro takes arguments -.Fa x -and -.Fa y -and returns non-zero if and only if neither -.Fa x -nor -.Fa y -are NaNs. -For any pair of floating-point values, one -of the relationships (less, greater, equal, unordered) holds. -.Sh SEE ALSO -.Xr fpclassify 3 , -.Xr math 3 , -.Xr signbit 3 -.Sh STANDARDS -The -.Fn isgreater , -.Fn isgreaterequal , -.Fn isless , -.Fn islessequal , -.Fn islessgreater , -and -.Fn isunordered -macros conform to -.St -isoC-99 . -.Sh HISTORY -The relational macros described above first appeared in -.Nx 5.0 . diff --git a/lib/libc/gen/isinf.3 b/lib/libc/gen/isinf.3 deleted file mode 100644 index 713e0ca70..000000000 --- a/lib/libc/gen/isinf.3 +++ /dev/null @@ -1,84 +0,0 @@ -.\" $NetBSD: isinf.3,v 1.12 2004/03/04 23:47:56 wiz Exp $ -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)isinf.3 8.2 (Berkeley) 1/29/94 -.\" -.Dd March 5, 2004 -.Dt ISINF 3 -.Os -.Sh NAME -.Nm isinf -.Nd test for infinity -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In math.h -.Ft int -.Fn isinf "real-floating x" -.Sh DESCRIPTION -The -.Fn isinf -macro determines whether its argument -.Fa x -is an infinity (positive or negative). -An argument represented in a format wider than its semantic type is -converted to its semantic type first. -The determination is then based on the type of the argument. -.Ss IEEE 754 -It is determined whether the value of -.Fa x -is an infinity. -.Ss VAX -Infinities are not supported. -.Sh RETURN VALUES -The -.Fn isinf -macro returns a non-zero value if the value of -.Fa x -is an infinity. -Otherwise 0 is returned. -.Sh SEE ALSO -.Xr fpclassify 3 , -.Xr isfinite 3 , -.Xr isinff 3 , -.Xr isnan 3 , -.Xr isnanf 3 , -.Xr isnormal 3 , -.Xr math 3 , -.Xr signbit 3 -.Rs -.%T "IEEE Standard for Binary Floating-Point Arithmetic" -.%Q ANSI -.%R Std 754-1985 -.Re -.Sh STANDARDS -The -.Fn isinf -macro conforms to -.St -isoC-99 . diff --git a/lib/libc/gen/isinfd_ieee754.c b/lib/libc/gen/isinfd_ieee754.c deleted file mode 100644 index 18899b740..000000000 --- a/lib/libc/gen/isinfd_ieee754.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinfd_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* libc.so.12 ABI compatbility */ -#ifdef __weak_alias -__weak_alias(isinf,__isinfd) -#endif - -/* - * 7.12.3.3 isinf - test for infinity - * IEEE 754 double-precision version - */ -int -__isinfd(double x) -{ - union ieee_double_u u; - - u.dblu_d = x; - - return (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN && - (u.dblu_dbl.dbl_frach == 0 && u.dblu_dbl.dbl_fracl == 0)); -} diff --git a/lib/libc/gen/isinff_ieee754.c b/lib/libc/gen/isinff_ieee754.c deleted file mode 100644 index 62f4e0f45..000000000 --- a/lib/libc/gen/isinff_ieee754.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: isinff_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinff_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.3 isinf - test for infinity - * IEEE 754 single-precision version - */ -int -__isinff(float x) -{ - union ieee_single_u u; - - u.sngu_f = x; - - return (u.sngu_sng.sng_exp == SNG_EXP_INFNAN && - u.sngu_sng.sng_frac == 0); -} diff --git a/lib/libc/gen/isinfl_ieee754.c b/lib/libc/gen/isinfl_ieee754.c deleted file mode 100644 index d45a06884..000000000 --- a/lib/libc/gen/isinfl_ieee754.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: isinfl_ieee754.c,v 1.5 2013/11/21 14:14:13 martin Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isinfl_ieee754.c,v 1.5 2013/11/21 14:14:13 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#ifdef __HAVE_LONG_DOUBLE -/* - * 7.12.3.3 isinf - test for infinity - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__isinfl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return u.extu_ext.ext_exp == EXT_EXP_INFNAN - && u.extu_ext.ext_frach == 0 -#if EXT_FRACHMBITS - && u.extu_ext.ext_frachm == 0 -#endif -#if EXT_FRACLMBITS - && u.extu_ext.ext_fraclm == 0 -#endif - && u.extu_ext.ext_fracl == 0; -} -#endif /* __HAVE_LONG_DOUBLE */ diff --git a/lib/libc/gen/islower.3 b/lib/libc/gen/islower.3 deleted file mode 100644 index 1322e36e0..000000000 --- a/lib/libc/gen/islower.3 +++ /dev/null @@ -1,107 +0,0 @@ -.\" $NetBSD: islower.3,v 1.14 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)islower.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISLOWER 3 -.Os -.Sh NAME -.Nm islower -.Nd lower-case character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn islower "int c" -.Sh DESCRIPTION -The -.Fn islower -function tests for any lower-case letter -.\" or any of an -.\" implementation-defined set of characters -for which none of -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr ispunct 3 , -or -.Xr isspace 3 -is true. -In the -.Em ``C'' -locale, -.Fn islower -returns true only for the characters defined as lower-case letters. -.Sh RETURN VALUES -The -.Fn islower -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn islower -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn islower -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isnan.3 b/lib/libc/gen/isnan.3 deleted file mode 100644 index 42442147c..000000000 --- a/lib/libc/gen/isnan.3 +++ /dev/null @@ -1,86 +0,0 @@ -.\" $NetBSD: isnan.3,v 1.2 2004/03/04 23:49:31 wiz Exp $ -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" From: @(#)isinf.3 8.2 (Berkeley) 1/29/94 -.\" from: NetBSD: isinf.3,v 1.10 2003/08/07 16:42:52 agc Exp -.\" -.Dd March 5, 2004 -.Dt ISNAN 3 -.Os -.Sh NAME -.Nm isnan -.Nd test for not-a-number -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In math.h -.Ft int -.Fn isnan "real-floating x" -.Sh DESCRIPTION -The -.Fn isnan -macro determines whether its argument -.Fa x -is not-a-number -.Pq Dq NaN . -An argument represented in a format wider than its semantic type is -converted to its semantic type first. -The determination is then based on the type of the argument. -.Ss IEEE 754 -It is determined whether the value of -.Fa x -is a NaN. -.Ss VAX -NaNs are not supported. -.Sh RETURN VALUES -The -.Fn isnan -macro returns a non-zero value if the value of -.Fa x -is a NaN. -Otherwise 0 is returned. -.Sh SEE ALSO -.Xr fpclassify 3 , -.Xr isfinite 3 , -.Xr isinf 3 , -.Xr isinff 3 , -.Xr isnanf 3 , -.Xr isnormal 3 , -.Xr math 3 , -.Xr signbit 3 -.Rs -.%T "IEEE Standard for Binary Floating-Point Arithmetic" -.%Q ANSI -.%R Std 754-1985 -.Re -.Sh STANDARDS -The -.Fn isnan -macro conforms to -.St -isoC-99 . diff --git a/lib/libc/gen/isnand_ieee754.c b/lib/libc/gen/isnand_ieee754.c deleted file mode 100644 index 0ce4bd936..000000000 --- a/lib/libc/gen/isnand_ieee754.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: isnand_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnand_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* libc.so.12 ABI compatbility */ -#ifdef __weak_alias -__weak_alias(isnan,__isnand) -#endif - -/* - * 7.12.3.4 isnan - test for a NaN - * IEEE 754 double-precision version - */ -int -__isnand(double x) -{ - union ieee_double_u u; - - u.dblu_d = x; - - return (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN && - (u.dblu_dbl.dbl_frach != 0 || u.dblu_dbl.dbl_fracl != 0)); -} diff --git a/lib/libc/gen/isnanf_ieee754.c b/lib/libc/gen/isnanf_ieee754.c deleted file mode 100644 index ee3b94dec..000000000 --- a/lib/libc/gen/isnanf_ieee754.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: isnanf_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnanf_ieee754.c,v 1.1 2004/03/04 23:42:39 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -/* - * 7.12.3.4 isnan - test for a NaN - * IEEE 754 single-precision version - */ -int -__isnanf(float x) -{ - union ieee_single_u u; - - u.sngu_f = x; - - return (u.sngu_sng.sng_exp == SNG_EXP_INFNAN && - u.sngu_sng.sng_frac != 0); -} diff --git a/lib/libc/gen/isnanl_ieee754.c b/lib/libc/gen/isnanl_ieee754.c deleted file mode 100644 index 77f407316..000000000 --- a/lib/libc/gen/isnanl_ieee754.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: isnanl_ieee754.c,v 1.7 2013/11/21 14:14:13 martin Exp $ */ - -/* - * 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. - * 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. - * - * from: Header: isinf.c,v 1.1 91/07/08 19:03:34 torek Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)isinf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: isnanl_ieee754.c,v 1.7 2013/11/21 14:14:13 martin Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#ifdef __HAVE_LONG_DOUBLE -/* - * 7.12.3.4 isnan - test for a NaN - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__isnanl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return u.extu_ext.ext_exp == EXT_EXP_INFNAN - && (u.extu_ext.ext_frach != 0 -#if EXT_FRACHMBITS - || u.extu_ext.ext_frachm != 0 -#endif -#if EXT_FRACLMBITS - || u.extu_ext.ext_fraclm != 0 -#endif - || u.extu_ext.ext_fracl != 0); -} -#endif /* __HAVE_LONG_DOUBLE */ diff --git a/lib/libc/gen/isnormal.3 b/lib/libc/gen/isnormal.3 deleted file mode 100644 index 7ccda97fc..000000000 --- a/lib/libc/gen/isnormal.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $NetBSD: isnormal.3,v 1.3 2008/04/30 13:10:50 martin Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd October 29, 2003 -.Dt ISNORMAL 3 -.Os -.Sh NAME -.Nm isnormal -.Nd test for normal value -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In math.h -.Ft int -.Fn isnormal "real-floating x" -.Sh DESCRIPTION -The -.Fn isnormal -macro determines whether its argument -.Fa x -has a normal value. -An argument represented in a format wider than its semantic type is -converted to its semantic type first. -The determination is then based on the type of the argument. -.Ss IEEE 754 -It is determined whether the value of -.Fa x -is normal, and neither zero, subnormal, infinite nor NaN. -.Ss VAX -It is determined whether the value of -.Fa x -is finite, and neither true zero, dirty zero nor ROP. -.Sh RETURN VALUES -The -.Fn isnormal -macro returns a non-zero value if the value of -.Fa x -is finite. -Otherwise 0 is returned. -.Sh ERRORS -No errors are defined. -.Sh SEE ALSO -.Xr fpclassify 3 , -.Xr isfinite 3 , -.Xr math 3 , -.Xr signbit 3 -.Sh STANDARDS -The -.Fn isnormal -macro conforms to -.St -isoC-99 . diff --git a/lib/libc/gen/isprint.3 b/lib/libc/gen/isprint.3 deleted file mode 100644 index e2091097c..000000000 --- a/lib/libc/gen/isprint.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $NetBSD: isprint.3,v 1.13 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isprint.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISPRINT 3 -.Os -.Sh NAME -.Nm isprint -.Nd printing character test (space character inclusive) -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isprint "int c" -.Sh DESCRIPTION -The -.Fn isprint -function tests for any printing character including space (' '). -.Sh RETURN VALUES -The -.Fn isprint -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isprint -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isprint -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/ispunct.3 b/lib/libc/gen/ispunct.3 deleted file mode 100644 index 8d32ac67e..000000000 --- a/lib/libc/gen/ispunct.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" $NetBSD: ispunct.3,v 1.13 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)ispunct.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISPUNCT 3 -.Os -.Sh NAME -.Nm ispunct -.Nd punctuation character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn ispunct "int c" -.Sh DESCRIPTION -The -.Fn ispunct -function tests for any printing character except space (' ') or a -character for which -.Xr isalnum 3 -is true. -.Sh RETURN VALUES -The -.Fn ispunct -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn ispunct -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn ispunct -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isspace.3 b/lib/libc/gen/isspace.3 deleted file mode 100644 index 4c6d1306a..000000000 --- a/lib/libc/gen/isspace.3 +++ /dev/null @@ -1,120 +0,0 @@ -.\" $NetBSD: isspace.3,v 1.15 2012/10/03 19:28:44 wiz Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isspace.3 5.3 (Berkeley) 7/31/91 -.\" -.Dd April 17, 2008 -.Dt ISSPACE 3 -.Os -.Sh NAME -.Nm isspace -.Nd white-space character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isspace "int c" -.Sh DESCRIPTION -The -.Fn isspace -function tests for the standard white-space characters -.\" or for any -.\" of an implementation-defined set of characters -for which -.Xr isalnum 3 -is false. -The standard white-space characters are the following: -.Pp -.Bl -tag -width xxxxx -offset indent -compact -.It Sq \0 -Space character. -.It Li \ef -Form feed. -.It Li \en -New-line. -.It Li \er -Carriage return. -.It Li \et -Horizontal tab. -.It Li \ev -Vertical tab. -.El -.Pp -In the -.Em ``C'' -locale, -.Fn isspace -returns true only for the standard white-space characters. -.Sh RETURN VALUES -The -.Fn isspace -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isspace -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isspace -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isupper.3 b/lib/libc/gen/isupper.3 deleted file mode 100644 index d969eca56..000000000 --- a/lib/libc/gen/isupper.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" $NetBSD: isupper.3,v 1.14 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isupper.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISUPPER 3 -.Os -.Sh NAME -.Nm isupper -.Nd upper-case character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isupper "int c" -.Sh DESCRIPTION -The -.Fn isupper -function tests for any upper-case letter or any of an -implementation-defined set of characters for which none of -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr ispunct 3 , -or -.Xr isspace 3 -is true. -In the -.Em ``C'' -locale, -.Fn isupper -returns true only for the characters defined as upper-case letters. -.Sh RETURN VALUES -The -.Fn isupper -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isupper -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isupper -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/isxdigit.3 b/lib/libc/gen/isxdigit.3 deleted file mode 100644 index 7777af032..000000000 --- a/lib/libc/gen/isxdigit.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $NetBSD: isxdigit.3,v 1.13 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isxdigit.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt ISXDIGIT 3 -.Os -.Sh NAME -.Nm isxdigit -.Nd hexadecimal-digit character test -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn isxdigit "int c" -.Sh DESCRIPTION -The -.Fn isxdigit -function tests for any hexadecimal-digit character. -.Sh RETURN VALUES -The -.Fn isxdigit -function returns zero if the character tests false and -returns non-zero if the character tests true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn isxdigit -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn isxdigit -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/ldexp_ieee754.c b/lib/libc/gen/ldexp_ieee754.c deleted file mode 100644 index cc8149a6a..000000000 --- a/lib/libc/gen/ldexp_ieee754.c +++ /dev/null @@ -1,142 +0,0 @@ -/* $NetBSD: ldexp_ieee754.c,v 1.5 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Charles M. Hannum. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ldexp_ieee754.c,v 1.5 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -/* - * Multiply the given value by 2^expon. - */ -double -ldexp(double val, int expon) -{ - int oldexp, newexp; - union ieee_double_u u, mul; - - u.dblu_d = val; - oldexp = u.dblu_dbl.dbl_exp; - - /* - * If input is zero, Inf or NaN, just return it. - */ - if (u.dblu_d == 0.0 || oldexp == DBL_EXP_INFNAN) - return (val); - - if (oldexp == 0) { - /* - * u.v is denormal. We must adjust it so that the exponent - * arithmetic below will work. - */ - if (expon <= DBL_EXP_BIAS) { - /* - * Optimization: if the scaling can be done in a single - * multiply, or underflows, just do it now. - */ - if (expon <= -DBL_FRACBITS) { - errno = ERANGE; - return (val < 0.0 ? -0.0 : 0.0); - } - mul.dblu_d = 0.0; - mul.dblu_dbl.dbl_exp = expon + DBL_EXP_BIAS; - u.dblu_d *= mul.dblu_d; - if (u.dblu_d == 0.0) { - errno = ERANGE; - return (val < 0.0 ? -0.0 : 0.0); - } - return (u.dblu_d); - } else { - /* - * We know that expon is very large, and therefore the - * result cannot be denormal (though it may be Inf). - * Shift u.v by just enough to make it normal. - */ - mul.dblu_d = 0.0; - mul.dblu_dbl.dbl_exp = DBL_FRACBITS + DBL_EXP_BIAS; - u.dblu_d *= mul.dblu_d; - expon -= DBL_FRACBITS; - oldexp = u.dblu_dbl.dbl_exp; - } - } - - /* - * u.v is now normalized and oldexp has been adjusted if necessary. - * Calculate the new exponent and check for underflow and overflow. - */ - newexp = oldexp + expon; - - if (newexp <= 0) { - /* - * The output number is either denormal or underflows (see - * comments in machine/ieee.h). - */ - if (newexp <= -DBL_FRACBITS) { - errno = ERANGE; - return (val < 0.0 ? -0.0 : 0.0); - } - /* - * Denormalize the result. We do this with a multiply. If - * expon is very large, it won't fit in a double, so we have - * to adjust the exponent first. This is safe because we know - * that u.v is normal at this point. - */ - if (expon <= -DBL_EXP_BIAS) { - u.dblu_dbl.dbl_exp = 1; - expon += oldexp - 1; - } - mul.dblu_d = 0.0; - mul.dblu_dbl.dbl_exp = expon + DBL_EXP_BIAS; - u.dblu_d *= mul.dblu_d; - return (u.dblu_d); - } else if (newexp >= DBL_EXP_INFNAN) { - /* - * The result overflowed; return +/-Inf. - */ - u.dblu_dbl.dbl_exp = DBL_EXP_INFNAN; - u.dblu_dbl.dbl_frach = 0; - u.dblu_dbl.dbl_fracl = 0; - errno = ERANGE; - return (u.dblu_d); - } else { - /* - * The result is normal; just replace the old exponent with the - * new one. - */ - u.dblu_dbl.dbl_exp = newexp; - return (u.dblu_d); - } -} diff --git a/lib/libc/gen/lockf.3 b/lib/libc/gen/lockf.3 deleted file mode 100644 index 8a0716683..000000000 --- a/lib/libc/gen/lockf.3 +++ /dev/null @@ -1,262 +0,0 @@ -.\" $NetBSD: lockf.3,v 1.12 2011/10/15 21:35:49 rmind Exp $ -.\" -.\" Copyright (c) 1997 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein and S.P. Zeidler. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd October 15, 2011 -.Dt LOCKF 3 -.Os -.Sh NAME -.Nm lockf -.Nd record locking on files -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn lockf "int filedes" "int function" "off_t size" -.Sh DESCRIPTION -The -.Fn lockf -function allows sections of a file to be locked with advisory-mode locks. -Calls to -.Fn lockf -from other processes which attempt to lock the locked file section will -either return an error value or block until the section becomes unlocked. -All the locks for a process are removed when the process terminates. -.Pp -The argument -.Fa filedes -is an open file descriptor. -The file descriptor must have been opened either for write-only -.Dv ( O_WRONLY ) -or read/write -.Dv ( O_RDWR ) -operation. -.Pp -The -.Fa function -argument is a control value which specifies the action to be taken. -The permissible values for -.Fa function -are as follows: -.Pp -.Bl -tag -width F_ULOCKXX -compact -offset indent -.It Sy Function -.Sy Description -.It Dv F_ULOCK -unlock locked sections -.It Dv F_LOCK -lock a section for exclusive use -.It Dv F_TLOCK -test and lock a section for exclusive use -.It Dv F_TEST -test a section for locks by other processes -.El -.Pp -.Dv F_ULOCK -removes locks from a section of the file; -.Dv F_LOCK -and -.Dv F_TLOCK -both lock a section of a file if the section is available; -.Dv F_TEST -detects if a lock by another process is present on the specified section. -.Pp -The -.Fa size -argument is the number of contiguous bytes to be locked or -unlocked. -The section to be locked or unlocked starts at the current -offset in the file and extends forward for a positive size or backward -for a negative size (the preceding bytes up to but not including the -current offset). -However, it is not permitted to lock a section that -starts or extends before the beginning of the file. -If -.Fa size -is 0, the section from the current offset through the largest possible -file offset is locked (that is, from the current offset through the -present or any future end-of-file). -.Pp -The sections locked with -.Dv F_LOCK -or -.Dv F_TLOCK -may, in whole or in part, contain or be contained by a previously -locked section for the same process. -When this occurs, or if adjacent -locked sections would occur, the sections are combined into a single -locked section. -If the request would cause the number of locks to -exceed a system-imposed limit, the request will fail. -.Pp -.Dv F_LOCK -and -.Dv F_TLOCK -requests differ only by the action taken if the section is not -available. -.Dv F_LOCK -blocks the calling process until the section is available. -.Dv F_TLOCK -makes the function fail if the section is already locked by another -process. -.Pp -File locks are released on first close by the locking process of any -file descriptor for the file. -.Pp -.Dv F_ULOCK -requests release (wholly or in part) one or more locked sections -controlled by the process. -Locked sections will be unlocked starting -at the current file offset through -.Fa size -bytes or to the end of file if size is 0. -When all of a locked section -is not released (that is, when the beginning or end of the area to be -unlocked falls within a locked section), the remaining portions of -that section are still locked by the process. -Releasing the center -portion of a locked section will cause the remaining locked beginning -and end portions to become two separate locked sections. -If the -request would cause the number of locks in the system to exceed a -system-imposed limit, the request will fail. -.Pp -An -.Dv F_ULOCK -request in which size is non-zero and the offset of the last byte of -the requested section is the maximum value for an object of type -off_t, when the process has an existing lock in which size is 0 and -which includes the last byte of the requested section, will be treated -as a request to unlock from the start of the requested section with a -size equal to 0. -Otherwise an -.Dv F_ULOCK -request will attempt to unlock only the requested section. -.Pp -A potential for deadlock occurs if a process controlling a locked -region is put to sleep by attempting to lock the locked region of -another process. -This implementation detects that sleeping until a -locked region is unlocked would cause a deadlock and fails with an -.Er EDEADLK -error. -.Pp -.Fn lockf , -.Xr fcntl 2 -and -.Xr flock 2 -locks may be safely used concurrently. -.Pp -Blocking on a section is interrupted by any signal. -.Sh RETURN VALUES -If successful, the -.Fn lockf -function returns 0. -Otherwise, it returns \-1, sets -.Va errno -to indicate an error, and existing locks are not changed. -.Sh ERRORS -.Fn lockf -will fail if: -.Bl -tag -width Er -.It Bq Er EAGAIN -The argument -.Fa function -is -.Dv F_TLOCK -or -.Dv F_TEST -and the section is already locked by another process. -.It Bq Er EBADF -The argument -.Fa filedes -is not a valid open file descriptor. -.Pp -The argument -.Fa function -is -.Dv F_LOCK -or -.Dv F_TLOCK , -and -.Fa filedes -is not a valid file descriptor open for writing. -.It Bq Er EDEADLK -The argument -.Fa function -is -.Dv F_LOCK -and a deadlock is detected. -.It Bq Er EINTR -The argument -.Fa function -is F_LOCK -and -.Fn lockf -was interrupted by the delivery of a signal. -.It Bq Er EINVAL -The argument -.Fa function -is not one of -.Dv F_ULOCK , -.Dv F_LOCK , -.Dv F_TLOCK -or -.Dv F_TEST . -.Pp -The argument -.Fa filedes -refers to a file that does not support locking. -.It Bq Er ENOLCK -The argument -.Fa function -is -.Dv F_ULOCK , -.Dv F_LOCK -or -.Dv F_TLOCK , -and satisfying the lock or unlock request would result in the number -of locked regions in the system exceeding a system-imposed limit. -.El -.Sh SEE ALSO -.Xr fcntl 2 , -.Xr flock 2 , -.Xr flockfile 3 -.Sh STANDARDS -The -.Fn lockf -function conforms to -.St -xpg4.2 -and -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn lockf -function first appeared in -.Fx 1.4 . diff --git a/lib/libc/gen/lockf.c b/lib/libc/gen/lockf.c deleted file mode 100644 index 6f82f5e2c..000000000 --- a/lib/libc/gen/lockf.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: lockf.c,v 1.4 2012/06/25 22:32:43 abs Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: lockf.c,v 1.4 2012/06/25 22:32:43 abs Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(lockf,_lockf) -#endif - - -int -lockf(int filedes, int function, off_t size) -{ - struct flock fl; - int cmd; - - fl.l_start = 0; - fl.l_len = size; - fl.l_whence = SEEK_CUR; - - switch (function) { - case F_ULOCK: - cmd = F_SETLK; - fl.l_type = F_UNLCK; - break; - case F_LOCK: - cmd = F_SETLKW; - fl.l_type = F_WRLCK; - break; - case F_TLOCK: - cmd = F_SETLK; - fl.l_type = F_WRLCK; - break; - case F_TEST: - fl.l_type = F_WRLCK; - if (fcntl(filedes, F_GETLK, &fl) == -1) - return (-1); - if (fl.l_type == F_UNLCK || fl.l_pid == getpid()) - return (0); - errno = EAGAIN; - return (-1); - /* NOTREACHED */ - default: - errno = EINVAL; - return (-1); - /* NOTREACHED */ - } - - return (fcntl(filedes, cmd, &fl)); -} diff --git a/lib/libc/gen/makecontext.3 b/lib/libc/gen/makecontext.3 deleted file mode 100644 index 0742e2185..000000000 --- a/lib/libc/gen/makecontext.3 +++ /dev/null @@ -1,169 +0,0 @@ -.\" $NetBSD: makecontext.3,v 1.10 2012/05/04 12:28:03 joerg Exp $ -.\" -.\" Copyright (c) 2001, 2009 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd May 4, 2012 -.Dt MAKECONTEXT 3 -.Os -.Sh NAME -.Nm makecontext , -.Nm swapcontext -.Nd manipulate user contexts -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ucontext.h -.Ft void -.Fn makecontext "ucontext_t *ucp" "void (*func)()" "int argc" ... -.Ft int -.Fn swapcontext "ucontext_t * restrict oucp" "ucontext_t * restrict ucp" -.Sh DESCRIPTION -The -.Fn makecontext -function modifies the object pointed to by -.Fa ucp , -which has been initialized using -.Xr getcontext 2 . -When this context is resumed using -.Fn swapcontext -or -.Xr setcontext 2 , -program execution continues as if -.Fa func -had been called with the arguments specified after -.Fa argc -in the call of -.Fn makecontext . -The value of -.Fa argc -must be equal to the number of integer arguments following it, -and must be equal to the number of integer arguments expected by -.Fa func ; -otherwise, the behavior is undefined. -.Pp -Before being modified using -.Fn makecontext , -a stack must be allocated for the context (in the -.Fa uc_stack -member), and a context to resume after -.Fa func -has returned must be determined (pointed to by the -.Fa uc_link -member); -otherwise, the behavior is undefined. -If -.Fa uc_link -is a null pointer, then the context is the main context, -and the process will exit with an exit status of 0 upon return. -.Pp -The -.Fn swapcontext -function saves the current context in the object pointed to by -.Fa oucp , -sets the current context to that specified in the object pointed to by -.Fa ucp , -and resumes execution. -When a context saved by -.Fn swapcontext -is restored using -.Xr setcontext 2 , -execution will resume as if the corresponding invocation of -.Fn swapcontext -had just returned (successfully). -.Sh RETURN VALUES -The -.Fn makecontext -function returns no value. -.Pp -On success, -.Fn swapcontext -returns a value of 0, -Otherwise, \-1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn swapcontext -function will fail if: -.Bl -tag -width Er -.It Bq Er EFAULT -The -.Fa oucp -argument or the -.Fa ucp -argument points to an invalid address. -.It Bq Er EINVAL -The contents of the datum pointed to by -.Fa ucp -are invalid. -.El -.Sh SEE ALSO -.Xr _exit 2 , -.Xr getcontext 2 , -.Xr setcontext 2 , -.Xr ucontext 2 -.Sh STANDARDS -The -.Fn makecontext -and -.Fn swapcontext -functions conform to -.St -xsh5 -and -.St -p1003.1-2001 . -.Pp -The -.St -p1003.1-2004 -revision marked the functions -.Fn makecontext -and -.Fn swapcontext -as obsolete, citing portability issues and recommending the use of -.Tn POSIX -threads instead. -The -.St -p1003.1-2008 -revision removed the functions from the specification. -.Pp -.Bf -symbolic -The standard does not clearly define the type of integer arguments -passed to -.Fa func -via -.Fn makecontext ; -portable applications should not rely on the implementation detail that -it may be possible to pass pointer arguments to functions. -.Ef -This may be clarified in a future revision of the standard. -.Sh HISTORY -The -.Fn makecontext -and -.Fn swapcontext -functions first appeared in -.At V.4 . diff --git a/lib/libc/gen/modf_ieee754.c b/lib/libc/gen/modf_ieee754.c deleted file mode 100644 index 39b4d0543..000000000 --- a/lib/libc/gen/modf_ieee754.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $NetBSD: modf_ieee754.c,v 1.4 2012/03/22 13:25:45 he 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 -#include -#include -#include - -/* - * 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(double val, double *iptr) -{ - union ieee_double_u u, v; - u_int64_t frac; - - /* - * If input is +/-Inf or NaN, return +/-0 or NaN. - */ - u.dblu_d = val; - if (u.dblu_dbl.dbl_exp == DBL_EXP_INFNAN) { - *iptr = u.dblu_d; - return (0.0 / u.dblu_d); - } - - /* - * If input can't have a fractional part, return - * (appropriately signed) zero, and make i be the input. - */ - if ((int)u.dblu_dbl.dbl_exp - DBL_EXP_BIAS > DBL_FRACBITS - 1) { - *iptr = u.dblu_d; - v.dblu_d = 0.0; - v.dblu_dbl.dbl_sign = u.dblu_dbl.dbl_sign; - return (v.dblu_d); - } - - /* - * If |input| < 1.0, return it, and set i to the appropriately - * signed zero. - */ - if (u.dblu_dbl.dbl_exp < DBL_EXP_BIAS) { - v.dblu_d = 0.0; - v.dblu_dbl.dbl_sign = u.dblu_dbl.dbl_sign; - *iptr = v.dblu_d; - return (u.dblu_d); - } - - /* - * 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.dblu_d = u.dblu_d; - /* Zero the low bits of the fraction, the sleazy way. */ - frac = ((u_int64_t)v.dblu_dbl.dbl_frach << 32) + v.dblu_dbl.dbl_fracl; - frac >>= DBL_FRACBITS - (u.dblu_dbl.dbl_exp - DBL_EXP_BIAS); - frac <<= DBL_FRACBITS - (u.dblu_dbl.dbl_exp - DBL_EXP_BIAS); - v.dblu_dbl.dbl_fracl = (u_int) (frac & 0xffffffffULL); - v.dblu_dbl.dbl_frach = (u_int) (frac >> 32); - *iptr = v.dblu_d; - - u.dblu_d -= v.dblu_d; - u.dblu_dbl.dbl_sign = v.dblu_dbl.dbl_sign; - return (u.dblu_d); -} diff --git a/lib/libc/gen/nftw.c b/lib/libc/gen/nftw.c deleted file mode 100644 index 0e5134261..000000000 --- a/lib/libc/gen/nftw.c +++ /dev/null @@ -1,114 +0,0 @@ -/* $NetBSD */ - -/* From OpenBSD: nftw.c,v 1.2 2003/07/21 21:15:32 millert Exp */ - -/* - * Copyright (c) 2003 Todd C. Miller - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - * - * Sponsored in part by the Defense Advanced Research Projects - * Agency (DARPA) and Air Force Research Laboratory, Air Force - * Materiel Command, USAF, under agreement number F39502-99-1-0512. - */ - -#include - -#ifndef lint -__RCSID("$NetBSD: nftw.c,v 1.1 2005/12/30 23:07:32 agc Exp $"); -#endif - -#include -#include -#include -#include -#include -#include - -int -nftw(const char *path, int (*fn)(const char *, const struct stat *, int, - struct FTW *), int nfds, int ftwflags) -{ - /* LINTED */ - char * const paths[2] = { __UNCONST(path), NULL }; - struct FTW f; - FTSENT *cur; - FTS *ftsp; - int ftsflags, fnflag, error, postorder, sverrno; - - /* XXX - nfds is currently unused */ - if (nfds < 1 || nfds > OPEN_MAX) { - errno = EINVAL; - return (-1); - } - - ftsflags = FTS_COMFOLLOW; - if (!(ftwflags & FTW_CHDIR)) - ftsflags |= FTS_NOCHDIR; - if (ftwflags & FTW_MOUNT) - ftsflags |= FTS_XDEV; - if (ftwflags & FTW_PHYS) - ftsflags |= FTS_PHYSICAL; - postorder = (ftwflags & FTW_DEPTH) != 0; - ftsp = fts_open(paths, ftsflags, NULL); - if (ftsp == NULL) - return (-1); - error = 0; - while ((cur = fts_read(ftsp)) != NULL) { - switch (cur->fts_info) { - case FTS_D: - if (postorder) - continue; - fnflag = FTW_D; - break; - case FTS_DNR: - fnflag = FTW_DNR; - break; - case FTS_DP: - if (!postorder) - continue; - fnflag = FTW_DP; - break; - case FTS_F: - case FTS_DEFAULT: - fnflag = FTW_F; - break; - case FTS_NS: - case FTS_NSOK: - fnflag = FTW_NS; - break; - case FTS_SL: - fnflag = FTW_SL; - break; - case FTS_SLNONE: - fnflag = FTW_SLN; - break; - case FTS_DC: - errno = ELOOP; - /* FALLTHROUGH */ - default: - error = -1; - goto done; - } - f.base = cur->fts_pathlen - cur->fts_namelen; - f.level = cur->fts_level; - error = fn(cur->fts_path, cur->fts_statp, fnflag, &f); - if (error != 0) - break; - } -done: - sverrno = errno; - (void) fts_close(ftsp); - errno = sverrno; - return (error); -} diff --git a/lib/libc/gen/nice.3 b/lib/libc/gen/nice.3 deleted file mode 100644 index 3aa293f45..000000000 --- a/lib/libc/gen/nice.3 +++ /dev/null @@ -1,93 +0,0 @@ -.\" $NetBSD: nice.3,v 1.14 2011/05/01 02:54:22 christos Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)nice.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 30, 2011 -.Dt NICE 3 -.Os -.Sh NAME -.Nm nice -.Nd set program scheduling priority -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn nice "int incr" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by -.Xr setpriority 2 . -.Ef -.Pp -The -.Fn nice -function obtains the scheduling priority of the process -from the system and sets it to the priority value specified in -.Fa incr . -The priority is a value in the range -20 to 20. -The default priority is 0; lower priorities cause more favorable scheduling. -Only a process with appropriate privileges may lower priorities. -.Pp -Children inherit the priority of their parent processes via -.Xr fork 2 . -.Sh RETURN VALUES -Upon successful completion, -.Fn nice -returns the new nice value minus -.Dv NZERO . -Otherwise, \-1 is returned, the process' nice value is not changed, and -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn nice -function will fail if: -.Bl -tag -width Er -.It Bq Er EPERM -The -.Fa incr -argument is negative and the caller does not have appropriate privileges. -.El -.Sh SEE ALSO -.Xr nice 1 , -.Xr fork 2 , -.Xr setpriority 2 , -.Xr renice 8 -.Sh STANDARDS -The -.Fn nice -function conforms to -.St -xpg4.2 . -.Sh HISTORY -A -.Fn nice -syscall appeared in -.At v6 . diff --git a/lib/libc/gen/nice.c b/lib/libc/gen/nice.c deleted file mode 100644 index 19d671148..000000000 --- a/lib/libc/gen/nice.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: nice.c,v 1.13 2011/05/01 02:49:54 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)nice.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: nice.c,v 1.13 2011/05/01 02:49:54 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(nice,_nice) -#endif - -/* - * Backwards compatible nice. - */ -int -nice(int incr) -{ - int prio; - - errno = 0; - prio = getpriority(PRIO_PROCESS, 0); - if (prio == -1 && errno) - return -1; - if (setpriority(PRIO_PROCESS, 0, prio + incr) == -1) { - if (errno == EACCES) - errno = EPERM; - return -1; - } - return getpriority(PRIO_PROCESS, 0); -} diff --git a/lib/libc/gen/nlist.3 b/lib/libc/gen/nlist.3 deleted file mode 100644 index 2a9f9917a..000000000 --- a/lib/libc/gen/nlist.3 +++ /dev/null @@ -1,79 +0,0 @@ -.\" $NetBSD: nlist.3,v 1.11 2003/08/07 16:42:53 agc Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)nlist.3 8.3 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt NLIST 3 -.Os -.Sh NAME -.Nm nlist -.Nd retrieve symbol table name list from an executable file -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In nlist.h -.Ft int -.Fn nlist "const char *filename" "struct nlist *nl" -.Sh DESCRIPTION -The -.Fn nlist -function -retrieves name list entries from the symbol table of an -executable file. -(See -.Xr a.out 5 . ) -The argument -.Fa \&nl -is set to reference the -beginning of the list. -The list is preened of binary and invalid data; -if an entry in the -name list is valid, the -.Fa n_type -and -.Fa n_value -for the entry are copied into the list -referenced by -.Fa \&nl . -No other data is copied. -The last entry in the list is always -.Dv NULL . -.Sh RETURN VALUES -The number of invalid entries is returned if successful; otherwise, -if the file -.Fa filename -does not exist or is not executable, the returned value is \-1. -.Sh SEE ALSO -.Xr a.out 5 -.Sh HISTORY -A -.Fn nlist -function appeared in -.At v6 . diff --git a/lib/libc/gen/nlist.c b/lib/libc/gen/nlist.c deleted file mode 100644 index ec2531801..000000000 --- a/lib/libc/gen/nlist.c +++ /dev/null @@ -1,143 +0,0 @@ -/* $NetBSD: nlist.c,v 1.25 2014/09/18 13:58:20 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: nlist.c,v 1.25 2014/09/18 13:58:20 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#if 0 -#ifdef __weak_alias -__weak_alias(nlist,_nlist) -#endif -#endif - -#include "nlist_private.h" - -static const struct { - int (*fdnlist)(int, struct nlist *); -} fdnlist_fmts[] = { -#ifdef NLIST_AOUT - { __fdnlist_aout }, -#endif -#ifdef NLIST_COFF - { __fdnlist_coff }, -#endif -#ifdef NLIST_ECOFF - { __fdnlist_ecoff }, -#endif -#ifdef NLIST_ELF32 - { __fdnlist_elf32 }, -#endif -#ifdef NLIST_ELF64 - { __fdnlist_elf64 }, -#endif -}; - -int -nlist(const char *name, struct nlist *list) -{ - int fd, n; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(list != NULL); - - fd = open(name, O_RDONLY | O_CLOEXEC, 0); - if (fd < 0) - return (-1); - n = __fdnlist(fd, list); - (void)close(fd); - return (n); -} - -int -__fdnlist(int fd, struct nlist *list) -{ - size_t i; - int rv; - - _DIAGASSERT(fd != -1); - _DIAGASSERT(list != NULL); - - for (i = 0; i < sizeof(fdnlist_fmts) / sizeof(fdnlist_fmts[0]); i++) - if ((rv = (*fdnlist_fmts[i].fdnlist)(fd, list)) != -1) - return (rv); - return (-1); -} diff --git a/lib/libc/gen/nlist_aout.c b/lib/libc/gen/nlist_aout.c deleted file mode 100644 index 618f35f07..000000000 --- a/lib/libc/gen/nlist_aout.c +++ /dev/null @@ -1,193 +0,0 @@ -/* $NetBSD: nlist_aout.c,v 1.23 2012/03/21 15:32:26 christos Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Copyright (c) 1996 Christopher G. Demetriou. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)nlist.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: nlist_aout.c,v 1.23 2012/03/21 15:32:26 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -struct nlist; -#include "nlist_private.h" - -#ifdef NLIST_AOUT -#include -#include - -int -__fdnlist_aout(int fd, struct nlist *list) -{ - struct nlist *p, *s; - char *strtab; - off_t stroff, symoff; - int nent; - size_t strsize, symsize, cc; - struct nlist nbuf[1024]; - struct exec exec; - struct stat st; - char *scoreboard, *scored; - - _DIAGASSERT(fd != -1); - _DIAGASSERT(list != NULL); - - if (pread(fd, &exec, sizeof(exec), (off_t)0) != sizeof(exec) || - N_BADMAG(exec) || fstat(fd, &st) < 0) - return (-1); - - symoff = N_SYMOFF(exec); - symsize = (size_t)exec.a_syms; - stroff = symoff + symsize; - - /* Check for files too large to mmap. */ - if ((uintmax_t)(st.st_size - stroff) > (uintmax_t)SIZE_T_MAX) { - errno = EFBIG; - return (-1); - } - /* - * Map string table into our address space. This gives us - * an easy way to randomly access all the strings, without - * making the memory allocation permanent as with malloc/free - * (i.e., munmap will return it to the system). - */ - strsize = (size_t)(st.st_size - stroff); - strtab = mmap(NULL, strsize, PROT_READ, MAP_PRIVATE|MAP_FILE, - fd, stroff); - if (strtab == (char *)-1) - return (-1); - /* - * clean out any left-over information for all valid entries. - * Type and value defined to be 0 if not found; historical - * versions cleared other and desc as well. Also figure out - * the largest string length so don't read any more of the - * string table than we have to. - * - * XXX clearing anything other than n_type and n_value violates - * the semantics given in the man page. - */ - nent = 0; - for (p = list; !ISLAST(p); ++p) { - p->n_type = 0; - p->n_other = 0; - p->n_desc = 0; - p->n_value = 0; - ++nent; - } - if (lseek(fd, symoff, SEEK_SET) == -1) - return (-1); -#if defined(__SSP__) || defined(__SSP_ALL__) - scoreboard = malloc((size_t)nent); -#else - scoreboard = alloca((size_t)nent); -#endif - if (scoreboard == NULL) - return (-1); - (void)memset(scoreboard, 0, (size_t)nent); - - while (symsize > 0) { - cc = MIN(symsize, sizeof(nbuf)); - if (read(fd, nbuf, cc) != (ssize_t) cc) - break; - symsize -= cc; - for (s = nbuf; cc > 0; ++s, cc -= sizeof(*s)) { - long soff = s->n_un.n_strx; - - if (soff == 0 || (s->n_type & N_STAB) != 0) - continue; - for (p = list, scored = scoreboard; !ISLAST(p); - p++, scored++) - if (*scored == 0 && - !strcmp(&strtab[(size_t)soff], - p->n_un.n_name)) { - p->n_value = s->n_value; - p->n_type = s->n_type; - p->n_desc = s->n_desc; - p->n_other = s->n_other; - *scored = 1; - if (--nent <= 0) - break; - } - } - } - munmap(strtab, strsize); -#if defined(__SSP__) || defined(__SSP_ALL__) - free(scoreboard); -#endif - return (nent); -} -#endif /* NLIST_AOUT */ diff --git a/lib/libc/gen/nlist_coff.c b/lib/libc/gen/nlist_coff.c deleted file mode 100644 index c808c82aa..000000000 --- a/lib/libc/gen/nlist_coff.c +++ /dev/null @@ -1,195 +0,0 @@ -/* $NetBSD: nlist_coff.c,v 1.11 2012/03/22 14:18:34 christos Exp $ */ - -/* - * Copyright (c) 1996 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nlist_coff.c,v 1.11 2012/03/22 14:18:34 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nlist_private.h" -#ifdef NLIST_COFF -#include -#endif - -#ifdef NLIST_COFF - -#define ES_LEN 18 -struct coff_extsym { - union { - char u_name[8]; - struct { - int u_zero; - int u_offset; - } s; - } u; - int32_t es_value; - int16_t es_scnum; - int16_t es_type; - int8_t es_class; - int8_t es_numaux; -}; -#define es_name u.u_name -#define es_zero u.s.u_zero -#define es_offset u.s.u_offset - -int -__fdnlist_coff(int fd, struct nlist *list) -{ - struct nlist *p; - struct coff_filehdr *filehdrp; - struct stat st; - char *mappedfile; - size_t mappedsize; - u_long symoff, extstroff; - int rv, nent; - long i, nesyms; - - _DIAGASSERT(fd != -1); - _DIAGASSERT(list != NULL); - - rv = -1; - - /* - * If we can't fstat() the file, something bad is going on. - */ - if (fstat(fd, &st) < 0) - goto out; - - /* - * Map the file in its entirety. - */ - if ((uintmax_t)st.st_size > (uintmax_t)SIZE_T_MAX) { - errno = EFBIG; - goto out; - } - mappedsize = (size_t)st.st_size; - mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_PRIVATE|MAP_FILE, - fd, 0); - if (mappedfile == MAP_FAILED) - goto out; - - /* - * Make sure we can access the executable's header - * directly, and make sure we recognize the executable - * as an COFF binary. - */ - if (mappedsize < sizeof (struct coff_filehdr)) - goto unmap; - filehdrp = (void *)&mappedfile[0]; - - if (COFF_BADMAG(filehdrp)) - goto unmap; - - /* - * Find the symbol list. - */ - symoff = filehdrp->f_symptr; - nesyms = filehdrp->f_nsyms; - - if (symoff + ES_LEN * nesyms > mappedsize) - goto unmap; - extstroff = symoff + ES_LEN * nesyms; - - nent = 0; - for (p = list; !ISLAST(p); ++p) { - p->n_type = 0; - p->n_other = 0; - p->n_desc = 0; - p->n_value = 0; - ++nent; - } - - for (i = 0; i < nesyms; i++) { - char *symtabname; - const char *nlistname; - struct coff_extsym esym; - char name[10]; - - memcpy(&esym, &mappedfile[symoff + ES_LEN * i], ES_LEN); - if (esym.es_numaux != 0) { - i += esym.es_numaux; /* XXX Skip aux entry */ - continue; - } - - if (esym.es_zero != 0) { - memcpy(name, esym.es_name, 8); - name[8] = 0; - symtabname = name; - } else if (esym.es_offset != 0) - symtabname = &mappedfile[extstroff + esym.es_offset]; - else - continue; - - for (p = list; !ISLAST(p); p++) { - nlistname = N_NAME(p); - if (!strcmp(symtabname, nlistname)) { - /* - * Translate (roughly) from COFF to nlist - */ - p->n_value = esym.es_value; - p->n_type = N_EXT; /* XXX */ - p->n_desc = 0; /* XXX */ - p->n_other = 0; /* XXX */ - - if (--nent <= 0) - goto done; - break; /* into next run of outer loop */ - } - } - } - -done: - rv = nent; -unmap: - munmap(mappedfile, mappedsize); -out: - return rv; -} - -#endif /* NLIST_COFF */ diff --git a/lib/libc/gen/nlist_ecoff.c b/lib/libc/gen/nlist_ecoff.c deleted file mode 100644 index 8ac558912..000000000 --- a/lib/libc/gen/nlist_ecoff.c +++ /dev/null @@ -1,186 +0,0 @@ -/* $NetBSD: nlist_ecoff.c,v 1.23 2012/03/20 00:31:24 matt Exp $ */ - -/* - * Copyright (c) 1996 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nlist_ecoff.c,v 1.23 2012/03/20 00:31:24 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nlist_private.h" -#ifdef NLIST_ECOFF -#include -#endif - -#ifdef NLIST_ECOFF -#define check(off, size) \ - ((size_t)off >= mappedsize || (size_t)(off + size) > mappedsize) - -int -__fdnlist_ecoff(int fd, struct nlist *list) -{ - struct nlist *p; - const struct ecoff_exechdr *exechdrp; - const struct ecoff_symhdr *symhdrp; - const struct ecoff_extsym *esyms; - struct stat st; - const char *mappedfile; - size_t mappedsize; - u_long symhdroff, extstroff; - u_int symhdrsize; - int rv, nent; - long i, nesyms; - - _DIAGASSERT(fd != -1); - _DIAGASSERT(list != NULL); - - rv = -1; - - /* - * If we can't fstat() the file, something bad is going on. - */ - if (fstat(fd, &st) < 0) - goto out; - - /* - * Map the file in its entirety. - */ - if ((uintmax_t)st.st_size > (uintmax_t)SIZE_T_MAX) { - errno = EFBIG; - goto out; - } - mappedsize = (size_t)st.st_size; - mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_PRIVATE|MAP_FILE, - fd, 0); - if (mappedfile == MAP_FAILED) - goto out; - - /* - * Make sure we can access the executable's header - * directly, and make sure the recognize the executable - * as an ECOFF binary. - */ - if (check(0, sizeof *exechdrp)) - goto unmap; - exechdrp = (const void *)mappedfile; - - if (ECOFF_BADMAG(exechdrp)) - goto unmap; - - /* - * Find the symbol list. - */ - symhdroff = exechdrp->f.f_symptr; - symhdrsize = exechdrp->f.f_nsyms; - - if ((symhdroff + sizeof *symhdrp) > mappedsize || - sizeof *symhdrp != symhdrsize) - goto unmap; - symhdrp = (const void *)&mappedfile[symhdroff]; - - nesyms = symhdrp->esymMax; - if (check(symhdrp->cbExtOffset, nesyms * sizeof *esyms)) - goto unmap; - esyms = (const void *)&mappedfile[symhdrp->cbExtOffset]; - extstroff = symhdrp->cbSsExtOffset; - - /* - * Clean out any left-over information for all valid entries. - * Type and value are defined to be 0 if not found; historical - * versions cleared other and desc as well. - * - * XXX Clearing anything other than n_type and n_value violates - * the semantics given in the man page. - */ - nent = 0; - for (p = list; !ISLAST(p); ++p) { - p->n_type = 0; - p->n_other = 0; - p->n_desc = 0; - p->n_value = 0; - ++nent; - } - - for (i = 0; i < nesyms; i++) { - for (p = list; !ISLAST(p); p++) { - const char *nlistname; - const char *symtabname; - - /* This may be incorrect */ - nlistname = N_NAME(p); - if (*nlistname == '_') - nlistname++; - - symtabname = - &mappedfile[extstroff + esyms[i].es_strindex]; - - if (!strcmp(symtabname, nlistname)) { - /* - * Translate (roughly) from ECOFF to nlist - */ - p->n_value = esyms[i].es_value; - p->n_type = N_EXT; /* XXX */ - p->n_desc = 0; /* XXX */ - p->n_other = 0; /* XXX */ - - if (--nent <= 0) - goto done; - break; /* into next run of outer loop */ - } - } - } - -done: - rv = nent; -unmap: - munmap(__UNCONST(mappedfile), mappedsize); -out: - return rv; -} - -#endif /* NLIST_ECOFF */ diff --git a/lib/libc/gen/nlist_elf32.c b/lib/libc/gen/nlist_elf32.c deleted file mode 100644 index 0b08ba97e..000000000 --- a/lib/libc/gen/nlist_elf32.c +++ /dev/null @@ -1,343 +0,0 @@ -/* $NetBSD: nlist_elf32.c,v 1.38 2015/05/20 04:37:45 matt Exp $ */ - -/* - * Copyright (c) 1996 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nlist_elf32.c,v 1.38 2015/05/20 04:37:45 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -/* If not included by nlist_elf64.c, ELFSIZE won't be defined. */ -#ifndef ELFSIZE -#define ELFSIZE 32 -#endif - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "nlist_private.h" -#if defined(NLIST_ELF32) || defined(NLIST_ELF64) -#include -#endif - -#include /* after sys/exec_elf.h */ - -#if (defined(NLIST_ELF32) && (ELFSIZE == 32)) || \ - (defined(NLIST_ELF64) && (ELFSIZE == 64)) - -/* No need to check for off < 0 because it is unsigned */ -#define check(off, size) (off + size > mappedsize) -#define BAD goto out -#define BADUNMAP goto unmap - -int -ELFNAMEEND(__fdnlist)(int fd, struct nlist *list) -{ - struct stat st; - Elf_Ehdr ehdr; -#if defined(_LP64) || ELFSIZE == 32 || defined(ELF64_MACHDEP_ID) -#if (ELFSIZE == 32) - Elf32_Half nshdr; -#elif (ELFSIZE == 64) - Elf64_Word nshdr; -#endif - /* Only support 64+32 mode on LP64 and those that have defined */ - /* ELF64_MACHDEP_ID, otherwise no support for 64 mode on ILP32 */ - Elf_Ehdr *ehdrp; - Elf_Shdr *shdrp, *symshdrp, *symstrshdrp; - Elf_Sym *symp; - Elf_Off shdr_off; - Elf_Word shdr_size; - struct nlist *p; - char *mappedfile, *strtab; - size_t mappedsize, nsyms; - int nent; -#endif - int rv; - size_t i; - - _DIAGASSERT(fd != -1); - _DIAGASSERT(list != NULL); - - rv = -1; - - /* - * If we can't fstat() the file, something bad is going on. - */ - if (fstat(fd, &st) < 0) - BAD; - - /* - * Map the file in its entirety. - */ - if ((uintmax_t)st.st_size > (uintmax_t)SIZE_T_MAX) { - errno = EFBIG; - BAD; - } - - /* - * Read the elf header of the file. - */ - if ((ssize_t)(i = pread(fd, &ehdr, sizeof(Elf_Ehdr), (off_t)0)) == -1) - BAD; - - /* - * Check that the elf header is correct. - */ - if (i != sizeof(Elf_Ehdr)) - BAD; - if (memcmp(ehdr.e_ident, ELFMAG, SELFMAG) != 0 || - ehdr.e_ident[EI_CLASS] != ELFCLASS) - BAD; - - switch (ehdr.e_machine) { - ELFDEFNNAME(MACHDEP_ID_CASES) - - default: - BAD; - } -#if defined(_LP64) || ELFSIZE == 32 || defined(ELF64_MACHDEP_ID) - symshdrp = symstrshdrp = NULL; - - /* Only support 64+32 mode on LP64 and those that have defined */ - /* ELF64_MACHDEP_ID, otherwise no support for 64 mode on ILP32 */ - if (S_ISCHR(st.st_mode)) { - const char *nlistname; - Elf_Sym sym; - - /* - * Character device; assume /dev/ksyms. - */ - nent = 0; - for (p = list; !ISLAST(p); ++p) { - struct ksyms_gsymbol kg; - int error; - - p->n_other = 0; - p->n_desc = 0; - nlistname = N_NAME(p); - if (*nlistname == '_') - nlistname++; - - memset(&kg, 0, sizeof(kg)); - kg.kg_name = nlistname; -#ifdef OKIOCGSYMBOL - struct ksyms_ogsymbol okg; - error = ioctl(fd, KIOCGSYMBOL, &kg); - if (error == 0) { - sym = kg.kg_sym; - } else if (error && errno == ENOTTY) { - memset(&okg, 0, sizeof(okg)); - okg.kg_name = nlistname; - okg.kg_sym = &sym; - error = ioctl(fd, OKIOCGSYMBOL, &okg); - } -#else - kg.kg_sym = &sym; - error = ioctl(fd, KIOCGSYMBOL, &kg); -#endif - if (error == 0 -#if !defined(_LP64) && ELFSIZE == 64 -#if __mips__ - && (intptr_t)sym.st_value == (intmax_t)sym.st_value -#else - && (uintptr_t)sym.st_value == sym.st_value -#endif -#endif - && 1) { - p->n_value = (uintptr_t)sym.st_value; - switch (ELF_ST_TYPE(sym.st_info)) { - case STT_NOTYPE: - p->n_type = N_UNDF; - break; - case STT_COMMON: - case STT_OBJECT: - p->n_type = N_DATA; - break; - case STT_FUNC: - p->n_type = N_TEXT; - break; - case STT_FILE: - p->n_type = N_FN; - break; - default: - p->n_type = 0; - /* catch other enumerations for gcc */ - break; - } - if (ELF_ST_BIND(sym.st_info) != STB_LOCAL) - p->n_type |= N_EXT; - } else { - nent++; - p->n_value = 0; - p->n_type = 0; - } - } - return nent; - } - - mappedsize = (size_t)st.st_size; - mappedfile = mmap(NULL, mappedsize, PROT_READ, MAP_PRIVATE|MAP_FILE, - fd, (off_t)0); - if (mappedfile == (char *)-1) - BAD; - - /* - * Make sure we can access the executable's header - * directly, and make sure the recognize the executable - * as an ELF binary. - */ - if (check(0, sizeof *ehdrp)) - BADUNMAP; - ehdrp = (Elf_Ehdr *)(void *)&mappedfile[0]; - - /* - * Find the symbol list and string table. - */ - nshdr = ehdrp->e_shnum; - shdr_off = ehdrp->e_shoff; - shdr_size = ehdrp->e_shentsize * nshdr; - - if (check(shdr_off, shdr_size) || - (sizeof *shdrp != ehdrp->e_shentsize)) - BADUNMAP; - shdrp = (void *)&mappedfile[(size_t)shdr_off]; - - for (i = 0; i < nshdr; i++) { - if (shdrp[i].sh_type == SHT_SYMTAB) { - symshdrp = &shdrp[i]; - symstrshdrp = &shdrp[shdrp[i].sh_link]; - } - } - - /* Make sure we're not stripped. */ - if (symshdrp == NULL || symshdrp->sh_offset == 0) - BADUNMAP; - - /* Make sure the symbols and strings are safely mapped. */ - if (check(symshdrp->sh_offset, symshdrp->sh_size)) - BADUNMAP; - if (check(symstrshdrp->sh_offset, symstrshdrp->sh_size)) - BADUNMAP; - - symp = (void *)&mappedfile[(size_t)symshdrp->sh_offset]; - nsyms = (size_t)(symshdrp->sh_size / sizeof(*symp)); - strtab = &mappedfile[(size_t)symstrshdrp->sh_offset]; - - /* - * Clean out any left-over information for all valid entries. - * Type and value are defined to be 0 if not found; historical - * versions cleared other and desc as well. - * - * XXX Clearing anything other than n_type and n_value violates - * the semantics given in the man page. - */ - nent = 0; - for (p = list; !ISLAST(p); ++p) { - p->n_type = 0; - p->n_other = 0; - p->n_desc = 0; - p->n_value = 0; - ++nent; - } - - for (i = 0; i < nsyms; i++) { - for (p = list; !ISLAST(p); ++p) { - const char *nlistname; - char *symtabname; - - /* This may be incorrect */ - nlistname = N_NAME(p); - if (*nlistname == '_') - nlistname++; - - symtabname = &strtab[symp[i].st_name]; - - if (!strcmp(symtabname, nlistname)) { - /* - * Translate (roughly) from ELF to nlist - */ - p->n_value = (uintptr_t)symp[i].st_value; - switch (ELF_ST_TYPE(symp[i].st_info)) { - case STT_NOTYPE: - p->n_type = N_UNDF; - break; - case STT_OBJECT: - case STT_COMMON: - p->n_type = N_DATA; - break; - case STT_FUNC: - p->n_type = N_TEXT; - break; - case STT_FILE: - p->n_type = N_FN; - break; - default: - /* catch other enumerations for gcc */ - break; - } - if (ELF_ST_BIND(symp[i].st_info) != STB_LOCAL) - p->n_type |= N_EXT; - p->n_desc = 0; /* XXX */ - p->n_other = 0; /* XXX */ - - if (--nent <= 0) - goto done; - break; /* into next run of outer loop */ - } - } - } - -done: - rv = nent; -unmap: - munmap(mappedfile, mappedsize); -#endif /* _LP64 || ELFSIZE == 32 || ELF64_MACHDEP_ID */ -out: - return (rv); -} - -#endif diff --git a/lib/libc/gen/nlist_elf64.c b/lib/libc/gen/nlist_elf64.c deleted file mode 100644 index 9f9cff26b..000000000 --- a/lib/libc/gen/nlist_elf64.c +++ /dev/null @@ -1,44 +0,0 @@ -/* $NetBSD: nlist_elf64.c,v 1.6 2003/07/26 19:24:43 salo Exp $ */ - -/* - * Copyright (c) 1996 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nlist_elf64.c,v 1.6 2003/07/26 19:24:43 salo Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define ELFSIZE 64 - -#include "nlist_elf32.c" diff --git a/lib/libc/gen/nlist_private.h b/lib/libc/gen/nlist_private.h deleted file mode 100644 index 651652480..000000000 --- a/lib/libc/gen/nlist_private.h +++ /dev/null @@ -1,97 +0,0 @@ -/* $NetBSD: nlist_private.h,v 1.23 2015/06/13 17:28:42 dennis Exp $ */ - -/* - * Copyright (c) 1996 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * 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. - * - * <> - */ - -#if defined(__alpha__) -# define NLIST_ECOFF -# define NLIST_ELF64 -#elif defined(__x86_64__) -# define NLIST_ELF64 -# define NLIST_ELF32 -#elif defined(__mips__) -# define NLIST_ECOFF -# define NLIST_ELF32 -# ifndef __mips_o32 -# define NLIST_ELF64 -# endif -#elif defined(__arm__) || defined(__i386__) || defined (__m68k__) || \ - defined(__powerpc__) || defined(__vax__) -# define NLIST_AOUT -# define NLIST_ELF32 -#elif defined(__sparc__) -# define NLIST_AOUT -# define NLIST_ELF32 -# define NLIST_ELF64 -#elif defined(__SH5__) -# define NLIST_ELF32 -# define NLIST_ELF64 -#elif defined(__sh__) -# define NLIST_COFF -# define NLIST_ELF32 -#elif defined(__hppa__) -# define NLIST_ELF32 -#elif defined(__riscv__) -# define NLIST_ELF32 -# ifdef __riscv64 -# define NLIST_ELF64 -# endif -#elif defined(__aarch64__) -# define NLIST_ELF64 -#else -# define NLIST_AOUT -/* #define NLIST_ECOFF */ -/* #define NLIST_ELF32 */ -/* #define NLIST_ELF64 */ -#endif - -#define ISLAST(p) (N_NAME(p) == 0 || N_NAME(p)[0] == 0) - -struct nlist; - -#ifdef NLIST_AOUT -int __fdnlist_aout(int, struct nlist *); -#endif -#ifdef NLIST_COFF -int __fdnlist_coff(int, struct nlist *); -#endif -#ifdef NLIST_ECOFF -int __fdnlist_ecoff(int, struct nlist *); -#endif -#ifdef NLIST_ELF32 -int __fdnlist_elf32(int, struct nlist *); -#endif -#ifdef NLIST_ELF64 -int __fdnlist_elf64(int, struct nlist *); -#endif diff --git a/lib/libc/gen/opendir.c b/lib/libc/gen/opendir.c deleted file mode 100644 index 5442e6a1c..000000000 --- a/lib/libc/gen/opendir.c +++ /dev/null @@ -1,193 +0,0 @@ -/* $NetBSD: opendir.c,v 1.39 2014/11/26 16:48:43 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)opendir.c 8.7 (Berkeley) 12/10/94"; -#else -__RCSID("$NetBSD: opendir.c,v 1.39 2014/11/26 16:48:43 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include "extern.h" - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "dirent_private.h" - -static DIR *__opendir_common(int, const char *, int); - -__weak_alias(fdopendir,_fdopendir) - -/* - * Open a directory. - */ -DIR * -opendir(const char *name) -{ - - _DIAGASSERT(name != NULL); - - return (__opendir2(name, DTF_HIDEW|DTF_NODUP)); -} - -DIR * -__opendir2(const char *name, int flags) -{ - DIR *dirp; - int fd; - - if ((fd = open(name, O_RDONLY|O_DIRECTORY|O_NONBLOCK|O_CLOEXEC)) == -1) - return NULL; - - dirp = __opendir_common(fd, name, flags); - if (dirp == NULL) { - int serrno = errno; - (void)close(fd); - errno = serrno; - } - return dirp; -} - -#ifndef __LIBC12_SOURCE__ -DIR * -_fdopendir(int fd) -{ - struct stat sb; - - if (fstat(fd, &sb) == -1) - return NULL; - - if (!S_ISDIR(sb.st_mode)) { - errno = ENOTDIR; - return NULL; - } - - /* This is optional according to POSIX, but a good measure */ - if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) - return NULL; - - return __opendir_common(fd, NULL, DTF_HIDEW|DTF_NODUP); -} -#endif - -static DIR * -__opendir_common(int fd, const char *name, int flags) -{ - DIR *dirp; - int serrno; -#if !defined(__minix) - struct statvfs sfb; -#else - struct stat sb; -#endif /* !defined(__minix) */ - int error; - -#if defined(__minix) - dirp = NULL; /* LSC: Make sure the pointer is initialized */ - if (fstat(fd, &sb) || !S_ISDIR(sb.st_mode)) { - errno = ENOTDIR; - goto error; - } -#endif /* defined(__minix) */ - - if ((dirp = malloc(sizeof(*dirp))) == NULL) - goto error; - dirp->dd_buf = NULL; - dirp->dd_internal = NULL; -#ifdef _REENTRANT - if (__isthreaded) { - if ((dirp->dd_lock = malloc(sizeof(mutex_t))) == NULL) - goto error; - mutex_init((mutex_t *)dirp->dd_lock, NULL); - } -#endif - - /* - * Tweak flags for the underlying filesystem. - */ - -#if defined(__minix) - /* MOUNT_UNION and MOUNT_NFS not supported */ - flags &= ~DTF_NODUP; -#else - if (fstatvfs1(fd, &sfb, ST_NOWAIT) < 0) - goto error; - if ((flags & DTF_NODUP) != 0) { - if (!strncmp(sfb.f_fstypename, MOUNT_UNION, - sizeof(sfb.f_fstypename)) || - (sfb.f_flag & MNT_UNION) != 0) { - flags |= __DTF_READALL; - } else { - flags &= ~DTF_NODUP; - } - } - if (!strncmp(sfb.f_fstypename, MOUNT_NFS, sizeof(sfb.f_fstypename))) { - flags |= __DTF_READALL | __DTF_RETRY_ON_BADCOOKIE; - } -#endif /* !defined(__minix) */ - - dirp->dd_flags = flags; - error = _initdir(dirp, fd, name); - if (error) { - errno = error; - goto error; - } - - return (dirp); -error: - serrno = errno; - if (dirp != NULL) { -#ifdef _REENTRANT - if (__isthreaded) { - mutex_destroy((mutex_t *)dirp->dd_lock); - free(dirp->dd_lock); - } -#endif - free(dirp->dd_buf); - } - free(dirp); - errno = serrno; - return NULL; -} diff --git a/lib/libc/gen/pause.3 b/lib/libc/gen/pause.3 deleted file mode 100644 index 413ffbb9a..000000000 --- a/lib/libc/gen/pause.3 +++ /dev/null @@ -1,92 +0,0 @@ -.\" $NetBSD: pause.3,v 1.15 2003/08/07 16:42:55 agc Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)pause.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt PAUSE 3 -.Os -.Sh NAME -.Nm pause -.Nd stop until signal -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn pause void -.Sh DESCRIPTION -.Bf -symbolic -Pause is made obsolete by -.Xr sigsuspend 2 . -.Ef -.Pp -The -.Fn pause -function -forces a process to pause until -a signal is received from either the -.Xr kill 2 -function -or an interval timer. -(See -.Xr setitimer 2 . ) -Upon termination of a signal handler started during a -.Fn pause , -the -.Fn pause -call will return. -.Sh RETURN VALUES -Always returns \-1. -.Sh ERRORS -The -.Fn pause -function -always returns: -.Bl -tag -width Er -.It Bq Er EINTR -The call was interrupted. -.El -.Sh SEE ALSO -.Xr kill 2 , -.Xr poll 2 , -.Xr select 2 , -.Xr setitimer 2 , -.Xr sigsuspend 2 -.Sh STANDARDS -The -.Fn pause -function conforms to -.St -p1003.1-90 . -.Sh HISTORY -A -.Fn pause -syscall -appeared in -.At v6 . diff --git a/lib/libc/gen/pause.c b/lib/libc/gen/pause.c deleted file mode 100644 index 06414c54e..000000000 --- a/lib/libc/gen/pause.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: pause.c,v 1.11 2012/06/24 15:26:03 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)pause.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: pause.c,v 1.11 2012/06/24 15:26:03 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(pause,_pause) -#endif - -/* - * Backwards compatible pause. - */ -int -pause(void) -{ - sigset_t omask; - - if (sigprocmask(SIG_BLOCK, NULL, &omask) == -1) - return -1; - - return sigsuspend(&omask); -} diff --git a/lib/libc/gen/popen.3 b/lib/libc/gen/popen.3 deleted file mode 100644 index 4c51f892a..000000000 --- a/lib/libc/gen/popen.3 +++ /dev/null @@ -1,227 +0,0 @@ -.\" $NetBSD: popen.3,v 1.20 2015/01/21 08:35:31 wiz Exp $ -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)popen.3 8.2 (Berkeley) 5/3/95 -.\" -.Dd January 19, 2015 -.Dt POPEN 3 -.Os -.Sh NAME -.Nm popen , -.Nm popenve , -.Nm pclose -.Nd process -.Tn I/O -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdio.h -.Ft FILE * -.Fn popen "const char *command" "const char *type" -.Ft FILE * -.Fn popenve "const char *path" "char * const *argv" "char * const *envp" "const char *type" -.Ft int -.Fn pclose "FILE *stream" -.Sh DESCRIPTION -The -.Fn popen -function -.Dq opens -a process by creating an IPC connection, -forking, -and invoking the shell. -Historically, -.Nm popen -was implemented with a unidirectional pipe; -hence many implementations of -.Nm popen -only allow the -.Fa type -argument to specify reading or writing, not both. -Since -.Nm popen -is now implemented using sockets, the -.Fa type -may request a bidirectional data flow. -The -.Fa type -argument is a pointer to a null-terminated string -which must be -.Ql r -for reading, -.Ql w -for writing, or -.Ql r+ -for reading and writing. -In addition if the character -.Ql e -is present in the -.Fa type -string, the file descriptor used internally is set to be closed on -.Xr exec 3 . -.Pp -The -.Fa command -argument is a pointer to a null-terminated string -containing a shell command line. -This command is passed to -.Pa /bin/sh -using the -.Fl c -flag; interpretation, if any, is performed by the shell. -.Pp -The -.Fn popenve -function is similar to -.Fn popen -but the first three arguments are passed -to -.Xr execve 2 -and there is no shell involved in the command invocation. -.Pp -The return value from -.Fn popen -and -.Fn popenve -is a normal standard -.Tn I/O -stream in all respects -save that it must be closed with -.Fn pclose -rather than -.Fn fclose . -Writing to such a stream -writes to the standard input of the command; -the command's standard output is the same as that of the process that called -.Fn popen , -unless this is altered by the command itself. -Conversely, reading from a -.Dq popened -stream reads the command's standard output, and -the command's standard input is the same as that of the process that called -.Fn popen . -.Pp -Note that output -.Fn popen -streams are fully buffered by default. -.Pp -The -.Fn pclose -function waits for the associated process to terminate -and returns the exit status of the command -as returned by -.Fn wait4 . -.Sh RETURN VALUES -The -.Fn popen -function returns -.Dv NULL -if the -.Xr vfork 2 , -.Xr pipe 2 , -or -.Xr socketpair 2 -calls fail, -or if it cannot allocate memory, preserving -the errno from those functions. -.Pp -The -.Fn pclose -function -returns \-1 if -.Fa stream -is not associated with a -.Dq popened -command, if -.Fa stream -has already been -.Dq pclosed , -setting errno to -.Dv ESRCH -or if -.Xr wait4 2 -returns an error, preserving the errno returned by -.Xr wait4 2 . -.Sh SEE ALSO -.Xr sh 1 , -.Xr execve 2 , -.Xr fork 2 , -.Xr pipe 2 , -.Xr socketpair 2 , -.Xr wait4 2 , -.Xr fclose 3 , -.Xr fflush 3 , -.Xr fopen 3 , -.Xr shquote 3 , -.Xr stdio 3 , -.Xr system 3 -.Sh STANDARDS -The -.Fn popen -and -.Fn pclose -functions conform to -.St -p1003.2-92 . -.Sh HISTORY -A -.Fn popen -and a -.Fn pclose -function appeared in -.At v7 . -.Sh BUGS -Since the standard input of a command opened for reading -shares its seek offset with the process that called -.Fn popen , -if the original process has done a buffered read, -the command's input position may not be as expected. -Similarly, the output from a command opened for writing -may become intermingled with that of the original process. -The latter can be avoided by calling -.Xr fflush 3 -before -.Fn popen . -.Pp -Failure to execute the shell -is indistinguishable from the shell's failure to execute command, -or an immediate exit of the command. -The only hint is an exit status of 127. -.Pp -The -.Fn popen -argument -always calls -.Xr sh 1 , -never calls -.Xr csh 1 . -.Pp -The -.Fn popenve -function first appeared in -.Nx 8 . diff --git a/lib/libc/gen/popen.c b/lib/libc/gen/popen.c deleted file mode 100644 index 0ed6dcc0c..000000000 --- a/lib/libc/gen/popen.c +++ /dev/null @@ -1,309 +0,0 @@ -/* $NetBSD: popen.c,v 1.35 2015/02/02 22:07:05 christos Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software written by Ken Arnold and - * published in UNIX Review, Vol. 6, No. 8. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)popen.c 8.3 (Berkeley) 5/3/95"; -#else -__RCSID("$NetBSD: popen.c,v 1.35 2015/02/02 22:07:05 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "env.h" - -#ifdef __weak_alias -__weak_alias(popen,_popen) -__weak_alias(pclose,_pclose) -#endif - -static struct pid { - struct pid *next; - FILE *fp; -#ifdef _REENTRANT - int fd; -#endif - pid_t pid; -} *pidlist; - -#ifdef _REENTRANT -static rwlock_t pidlist_lock = RWLOCK_INITIALIZER; -#endif - -static struct pid * -pdes_get(int *pdes, const char **type) -{ - struct pid *cur; - int flags = strchr(*type, 'e') ? O_CLOEXEC : 0; - int serrno; - - if (strchr(*type, '+')) { - int stype = flags ? (SOCK_STREAM | SOCK_CLOEXEC) : SOCK_STREAM; - *type = "r+"; - if (socketpair(AF_LOCAL, stype, 0, pdes) < 0) - return NULL; - } else { - *type = strrchr(*type, 'r') ? "r" : "w"; - if (pipe2(pdes, flags) == -1) - return NULL; - } - - if ((cur = malloc(sizeof(*cur))) != NULL) - return cur; - serrno = errno; - (void)close(pdes[0]); - (void)close(pdes[1]); - errno = serrno; - return NULL; -} - -static void -pdes_child(int *pdes, const char *type) -{ - struct pid *old; - - /* POSIX.2 B.3.2.2 "popen() shall ensure that any streams - from previous popen() calls that remain open in the - parent process are closed in the new child process. */ - for (old = pidlist; old; old = old->next) -#ifdef _REENTRANT - (void)close(old->fd); /* don't allow a flush */ -#else - (void)close(fileno(old->fp)); /* don't allow a flush */ -#endif - - if (type[0] == 'r') { - (void)close(pdes[0]); - if (pdes[1] != STDOUT_FILENO) { - (void)dup2(pdes[1], STDOUT_FILENO); - (void)close(pdes[1]); - } - if (type[1] == '+') - (void)dup2(STDOUT_FILENO, STDIN_FILENO); - } else { - (void)close(pdes[1]); - if (pdes[0] != STDIN_FILENO) { - (void)dup2(pdes[0], STDIN_FILENO); - (void)close(pdes[0]); - } - } -} - -static void -pdes_parent(int *pdes, struct pid *cur, pid_t pid, const char *type) -{ - FILE *iop; - - /* Parent; assume fdopen can't fail. */ - if (*type == 'r') { - iop = fdopen(pdes[0], type); -#ifdef _REENTRANT - cur->fd = pdes[0]; -#endif - (void)close(pdes[1]); - } else { - iop = fdopen(pdes[1], type); -#ifdef _REENTRANT - cur->fd = pdes[1]; -#endif - (void)close(pdes[0]); - } - - /* Link into list of file descriptors. */ - cur->fp = iop; - cur->pid = pid; - cur->next = pidlist; - pidlist = cur; -} - -static void -pdes_error(int *pdes, struct pid *cur) -{ - free(cur); - (void)close(pdes[0]); - (void)close(pdes[1]); -} - -FILE * -popen(const char *cmd, const char *type) -{ - struct pid *cur; - int pdes[2], serrno; - pid_t pid; - - _DIAGASSERT(cmd != NULL); - _DIAGASSERT(type != NULL); - - if ((cur = pdes_get(pdes, &type)) == NULL) - return NULL; - -#ifdef _REENTRANT - (void)rwlock_rdlock(&pidlist_lock); -#endif - (void)__readlockenv(); - switch (pid = vfork()) { - case -1: /* Error. */ - serrno = errno; - (void)__unlockenv(); -#ifdef _REENTRANT - (void)rwlock_unlock(&pidlist_lock); -#endif - pdes_error(pdes, cur); - errno = serrno; - return NULL; - /* NOTREACHED */ - case 0: /* Child. */ - pdes_child(pdes, type); - execl(_PATH_BSHELL, "sh", "-c", cmd, NULL); - _exit(127); - /* NOTREACHED */ - } - (void)__unlockenv(); - - pdes_parent(pdes, cur, pid, type); - -#ifdef _REENTRANT - (void)rwlock_unlock(&pidlist_lock); -#endif - - return cur->fp; -} - -FILE * -popenve(const char *cmd, char *const *argv, char *const *envp, const char *type) -{ - struct pid *cur; - int pdes[2], serrno; - pid_t pid; - - _DIAGASSERT(cmd != NULL); - _DIAGASSERT(type != NULL); - - if ((cur = pdes_get(pdes, &type)) == NULL) - return NULL; - -#ifdef _REENTRANT - (void)rwlock_rdlock(&pidlist_lock); -#endif - switch (pid = vfork()) { - case -1: /* Error. */ - serrno = errno; -#ifdef _REENTRANT - (void)rwlock_unlock(&pidlist_lock); -#endif - pdes_error(pdes, cur); - errno = serrno; - return NULL; - /* NOTREACHED */ - case 0: /* Child. */ - pdes_child(pdes, type); - execve(cmd, argv, envp); - _exit(127); - /* NOTREACHED */ - } - - pdes_parent(pdes, cur, pid, type); - -#ifdef _REENTRANT - (void)rwlock_unlock(&pidlist_lock); -#endif - - return cur->fp; -} - -/* - * pclose -- - * Pclose returns -1 if stream is not associated with a `popened' command, - * if already `pclosed', or waitpid returns an error. - */ -int -pclose(FILE *iop) -{ - struct pid *cur, *last; - int pstat; - pid_t pid; - - _DIAGASSERT(iop != NULL); - -#ifdef _REENTRANT - rwlock_wrlock(&pidlist_lock); -#endif - - /* Find the appropriate file pointer. */ - for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next) - if (cur->fp == iop) - break; - if (cur == NULL) { -#ifdef _REENTRANT - (void)rwlock_unlock(&pidlist_lock); -#endif - errno = ESRCH; - return -1; - } - - (void)fclose(iop); - - /* Remove the entry from the linked list. */ - if (last == NULL) - pidlist = cur->next; - else - last->next = cur->next; - -#ifdef _REENTRANT - (void)rwlock_unlock(&pidlist_lock); -#endif - - do { - pid = waitpid(cur->pid, &pstat, 0); - } while (pid == -1 && errno == EINTR); - - free(cur); - - return pid == -1 ? -1 : pstat; -} diff --git a/lib/libc/gen/posix_spawn.3 b/lib/libc/gen/posix_spawn.3 deleted file mode 100644 index 67f5bb408..000000000 --- a/lib/libc/gen/posix_spawn.3 +++ /dev/null @@ -1,484 +0,0 @@ -.\" $NetBSD: posix_spawn.3,v 1.6 2014/02/02 16:59:06 wiz Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawn.3,v 1.2.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd February 2, 2014 -.Dt POSIX_SPAWN 3 -.Os -.Sh NAME -.Nm posix_spawn , -.Nm posix_spawnp -.Nd "spawn a process" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawn "pid_t *restrict pid" "const char *restrict path" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]" -.Ft int -.Fn posix_spawnp "pid_t *restrict pid" "const char *restrict file" "const posix_spawn_file_actions_t *file_actions" "const posix_spawnattr_t *restrict attrp" "char *const argv[restrict]" "char *const envp[restrict]" -.Sh DESCRIPTION -The -.Fn posix_spawn -and -.Fn posix_spawnp -functions create a new process (child process) from the specified -process image. -The new process image is constructed from a regular executable -file called the new process image file. -.Pp -When a C program is executed as the result of this call, it is -entered as a C-language function call as follows: -.Bd -literal -offset indent -int main(int argc, char *argv[]); -.Ed -.Pp -where -.Fa argc -is the argument count and -.Fa argv -is an array of character pointers to the arguments themselves. -In addition, the variable: -.Bd -literal -offset indent -extern char **environ; -.Ed -.Pp -points to an array of character pointers to -the environment strings. -.Pp -The argument -.Fa argv -is an array of character pointers to null-terminated -strings. -The last member of this array is a null pointer and is not counted -in -.Fa argc . -These strings constitute the argument list available to the new process -image. -The value in -.Fa argv Ns [0] -should point to -a filename that is associated with the process image being started by -the -.Fn posix_spawn -or -.Fn posix_spawnp -function. -.Pp -The argument -.Fa envp -is an array of character pointers to null-terminated strings. -These strings constitute the environment for the new process image. -The environment array is terminated by a null pointer. -.Pp -The -.Fa path -argument to -.Fn posix_spawn -is a pathname that identifies the new process image file to execute. -.Pp -The -.Fa file -parameter to -.Fn posix_spawnp -is used to construct a pathname that identifies the new process -image file. -If the file parameter contains a slash character, the file parameter -is used as the pathname for the new process image file. -Otherwise, the path prefix for this file is obtained by a search -of the directories passed as the environment variable -.Dq Ev PATH . -If this variable is not specified, -the default path is set according to the -.Dv _PATH_DEFPATH -definition in -.In paths.h , -which is set to -.Dq Ev /usr/bin:/bin . -.Pp -If -.Fa file_actions -is a null pointer, then file descriptors open in the -calling process remain open in the child process, except for those -whose close-on-exec flag -.Dv FD_CLOEXEC -is set (see -.Fn fcntl ) . -For those -file descriptors that remain open, all attributes of the corresponding -open file descriptions, including file locks (see -.Fn fcntl ) , -remain unchanged. -.Pp -If -.Fa file_actions -is not -.Dv NULL , -then the file descriptors open in the child process are -those open in the calling process as modified by the spawn file -actions object pointed to by -.Fa file_actions -and the -.Dv FD_CLOEXEC -flag of each remaining open file descriptor after the spawn file actions -have been processed. -The effective order of processing the spawn file actions are: -.Bl -enum -.It -The set of open file descriptors for the child process initially -are the same set as is open for the calling process. -All attributes of the corresponding open file descriptions, including -file locks (see -.Fn fcntl ) , -remain unchanged. -.It -The signal mask, signal default actions, and the effective user and -group IDs for the child process are changed as specified in the -attributes object referenced by -.Fa attrp . -.It -The file actions specified by the spawn file actions object are -performed in the order in which they were added to the spawn file -actions object. -.It -Any file descriptor that has its -.Dv FD_CLOEXEC -flag set (see -.Fn fcntl ) -is closed. -.El -.Pp -The maximum number of -.Fa file_actions -objects is limited to the -.Dv RLIMIT_NOFILE -rlimit times 2. -.Pp -The -.Vt posix_spawnattr_t -spawn attributes object type is defined in -.In spawn.h . -It contains the attributes defined below. -.Pp -If the -.Dv POSIX_SPAWN_SETPGROUP -flag is set in the spawn-flags attribute of the object referenced by -.Fa attrp , -and the spawn-pgroup attribute of the same object is non-zero, then the -child's process group is as specified in the spawn-pgroup -attribute of the object referenced by -.Fa attrp . -.Pp -As a special case, if the -.Dv POSIX_SPAWN_SETPGROUP -flag is set in the spawn-flags attribute of the object referenced by -.Fa attrp , -and the spawn-pgroup attribute of the same object is set to zero, then -the child is in a new process group with a process group ID equal -to its process ID. -.Pp -If the -.Dv POSIX_SPAWN_SETPGROUP -flag is not set in the spawn-flags attribute of the object referenced by -.Fa attrp , -the new child process inherits the parent's process group. -.Pp -If the -.Dv POSIX_SPAWN_SETSCHEDPARAM -flag is set in the spawn-flags attribute of the object referenced by -.Fa attrp , -but -.Dv POSIX_SPAWN_SETSCHEDULER -is not set, the new process image initially has the scheduling -policy of the calling process with the scheduling parameters specified -in the spawn-schedparam attribute of the object referenced by -.Fa attrp . -.Pp -If the -.Dv POSIX_SPAWN_SETSCHEDULER -flag is set in the spawn-flags attribute of the object referenced by -.Fa attrp -(regardless of the setting of the -.Dv POSIX_SPAWN_SETSCHEDPARAM -flag), the new process image initially has the scheduling policy -specified in the spawn-schedpolicy attribute of the object referenced by -.Fa attrp -and the scheduling parameters specified in the spawn-schedparam -attribute of the same object. -.Pp -The -.Dv POSIX_SPAWN_RESETIDS -flag in the spawn-flags attribute of the object referenced by -.Fa attrp -governs the effective user ID of the child process. -If this flag is not set, the child process inherits the parent -process' effective user ID. -If this flag is set, the child process' effective user ID is reset -to the parent's real user ID. -In either case, if the set-user-ID mode bit of the new process image -file is set, the effective user ID of the child process becomes -that file's owner ID before the new process image begins execution. -.Pp -The -.Dv POSIX_SPAWN_RESETIDS -flag in the spawn-flags attribute of the object referenced by -.Fa attrp -also governs the effective group ID of the child process. -If this flag is not set, the child process inherits the parent -process' effective group ID. -If this flag is set, the child process' effective group ID is -reset to the parent's real group ID. -In either case, if the set-group-ID mode bit of the new process image -file is set, the effective group ID of the child process becomes -that file's group ID before the new process image begins execution. -.Pp -If the -.Dv POSIX_SPAWN_SETSIGMASK -flag is set in the spawn-flags attribute of the object referenced by -.Fa attrp , -the child process initially has the signal mask specified in the -spawn-sigmask attribute of the object referenced by -.Fa attrp . -.Pp -If the -.Dv POSIX_SPAWN_SETSIGDEF -flag is set in the spawn-flags attribute of the object referenced by -.Fa attrp , -the signals specified in the spawn-sigdefault attribute of the same -object is set to their default actions in the child process. -Signals set to the default action in the parent process is set to -the default action in the child process. -.Pp -Signals set to be caught by the calling process is set to the -default action in the child process. -.Pp -Signals set to be ignored by the calling process image is set to -be ignored by the child process, unless otherwise specified by the -.Dv POSIX_SPAWN_SETSIGDEF -flag being set in the spawn-flags attribute of the object referenced by -.Fa attrp -and the signals being indicated in the spawn-sigdefault attribute -of the object referenced by -.Fa attrp . -.Pp -If the value of the -.Fa attrp -pointer is -.Dv NULL , -then the default values are used. -.Pp -All process attributes, other than those influenced by the attributes -set in the object referenced by -.Fa attrp -as specified above or by the file descriptor manipulations specified in -.Fa file_actions , -appear in the new process image as though -.Fn vfork -had been called to create a child process and then -.Fn execve -had been called by the child process to execute the new process image. -.Pp -The implementation uses vfork(), thus the fork handlers are not run when -.Fn posix_spawn -or -.Fn posix_spawnp -is called. -.Sh RETURN VALUES -Upon successful completion, -.Fn posix_spawn -and -.Fn posix_spawnp -return the process ID of the child process to the parent process, -in the variable pointed to by a -.Pf non- Dv NULL -.Fa pid -argument, and return zero as the function return value. -Otherwise, no child process is created, no value is stored into -the variable pointed to by -.Fa pid , -and an error number is returned as the function return value to -indicate the error. -If the -.Fa pid -argument is a null pointer, the process ID of the child is not returned -to the caller. -.Sh ERRORS -.Bl -enum -.It -If -.Fn posix_spawn -and -.Fn posix_spawnp -fail for any of the reasons that would cause -.Fn vfork -or one of the -.Nm exec -to fail, an error value is returned as described by -.Fn vfork -and -.Nm exec , -respectively (or, if the error occurs after the calling process successfully -returns, the child process exits with exit status 127). -.It -If -.Nm POSIX_SPAWN_SETPGROUP -is set in the spawn-flags attribute of the object referenced by attrp, and -.Fn posix_spawn -or -.Fn posix_spawnp -fails while changing the child's process group, an error value is returned as -described by -.Fn setpgid -(or, if the error occurs after the calling process successfully returns, -the child process exits with exit status 127). -.It -If -.Nm POSIX_SPAWN_SETSCHEDPARAM -is set and -.Nm POSIX_SPAWN_SETSCHEDULER -is not set in the spawn-flags attribute of the object referenced by attrp, then -if -.Fn posix_spawn -or -.Fn posix_spawnp -fails for any of the reasons that would cause -.Fn sched_setparam -to fail, an error value is returned as described by -.Fn sched_setparam -(or, if the error occurs after the calling process successfully returns, the -child process exits with exit status 127). -.It -If -.Nm POSIX_SPAWN_SETSCHEDULER -is set in the spawn-flags attribute of the object referenced by attrp, and if -.Fn posix_spawn -or -.Fn posix_spawnp -fails for any of the reasons that would cause -.Fn sched_setscheduler -to fail, an error value is returned as described by -.Fn sched_setscheduler -(or, if the error occurs after the calling process successfully returns, -the child process exits with exit status 127). -.It -If the -.Fa file_actions -argument is not -.Dv NULL , -and specifies any -.Fn close , -.Fn dup2 , -or -.Fn open -actions to be performed, and if -.Fn posix_spawn -or -.Fn posix_spawnp -fails for any of the reasons that would cause -.Fn close , -.Fn dup2 , -or -.Fn open -to fail, an error value is returned as described by -.Fn close , -.Fn dup2 , -and -.Fn open , -respectively (or, if the error occurs after the calling process successfully -returns, the child process exits with exit status 127). An open file action -may, by itself, result in any of the errors described by -.Fn close -or -.Fn dup2 , -in addition to those described by -.Fn open . -Finally, if the number of -.Fa file_actions -objects exceeds the allowed limit, -.Er EINVAL -is returned. -.El -.Sh SEE ALSO -.Xr close 2 , -.Xr dup2 2 , -.Xr execve 2 , -.Xr fcntl 2 , -.Xr open 2 , -.Xr setpgid 2 , -.Xr vfork 2 , -.Xr posix_spawn_file_actions_addclose 3 , -.Xr posix_spawn_file_actions_adddup2 3 , -.Xr posix_spawn_file_actions_addopen 3 , -.Xr posix_spawn_file_actions_destroy 3 , -.Xr posix_spawn_file_actions_init 3 , -.Xr posix_spawnattr_destroy 3 , -.Xr posix_spawnattr_getflags 3 , -.Xr posix_spawnattr_getpgroup 3 , -.Xr posix_spawnattr_getschedparam 3 , -.Xr posix_spawnattr_getschedpolicy 3 , -.Xr posix_spawnattr_getsigdefault 3 , -.Xr posix_spawnattr_getsigmask 3 , -.Xr posix_spawnattr_init 3 , -.Xr posix_spawnattr_setflags 3 , -.Xr posix_spawnattr_setpgroup 3 , -.Xr posix_spawnattr_setschedparam 3 , -.Xr posix_spawnattr_setschedpolicy 3 , -.Xr posix_spawnattr_setsigdefault 3 , -.Xr posix_spawnattr_setsigmask 3 , -.Xr sched_setparam 3 , -.Xr sched_setscheduler 3 -.Sh STANDARDS -The -.Fn posix_spawn -and -.Fn posix_spawnp -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawn -and -.Fn posix_spawnp -functions first appeared in -.Fx 8.0 . -The library parts were ported and a kernel implementation of -.Fn posix_spawn -added for -.Nx 6.0 -during Google Summer of Code by Charles Zhang and Martin Husemann. -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawn_file_actions_addopen.3 b/lib/libc/gen/posix_spawn_file_actions_addopen.3 deleted file mode 100644 index 9a23d6f9e..000000000 --- a/lib/libc/gen/posix_spawn_file_actions_addopen.3 +++ /dev/null @@ -1,190 +0,0 @@ -.\" $NetBSD: posix_spawn_file_actions_addopen.3,v 1.5 2014/02/02 16:59:13 wiz Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawn_file_actions_addopen.3,v 1.2.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd February 2, 2014 -.Dt POSIX_SPAWN_FILE_ACTIONS_ADDOPEN 3 -.Os -.Sh NAME -.Nm posix_spawn_file_actions_addopen , -.Nm posix_spawn_file_actions_adddup2 , -.Nm posix_spawn_file_actions_addclose -.Nd "add open, dup2 or close action to spawn file actions object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawn_file_actions_addopen "posix_spawn_file_actions_t * file_actions" "int fildes" "const char *restrict path" "int oflag" "mode_t mode" -.Ft int -.Fn posix_spawn_file_actions_adddup2 "posix_spawn_file_actions_t * file_actions" "int fildes" "int newfildes" -.Ft int -.Fn posix_spawn_file_actions_addclose "posix_spawn_file_actions_t * file_actions" "int fildes" -.Sh DESCRIPTION -These functions add an open, dup2 or close action to a spawn -file actions object. -.Pp -A spawn file actions object is of type -.Vt posix_spawn_file_actions_t -(defined in -.In spawn.h ) -and is used to specify a series of actions to be performed by a -.Fn posix_spawn -or -.Fn posix_spawnp -operation in order to arrive at the set of open file descriptors for the -child process given the set of open file descriptors of the parent. -.Pp -A spawn file actions object, when passed to -.Fn posix_spawn -or -.Fn posix_spawnp , -specify how the set of open file descriptors in the calling -process is transformed into a set of potentially open file descriptors -for the spawned process. -This transformation is as if the specified sequence of actions was -performed exactly once, in the context of the spawned process (prior to -execution of the new process image), in the order in which the actions -were added to the object; additionally, when the new process image is -executed, any file descriptor (from this new set) which has its -.Dv FD_CLOEXEC -flag set is closed (see -.Fn posix_spawn ) . -.Pp -The -.Fn posix_spawn_file_actions_addopen -function adds an open action to the object referenced by -.Fa file_actions -that causes the file named by -.Fa path -to be opened (as if -.Bd -literal -offset indent -open(path, oflag, mode) -.Ed -.Pp -had been called, and the returned file descriptor, if not -.Fa fildes , -had been changed to -.Fa fildes ) -when a new process is spawned using this file actions object. -If -.Fa fildes -was already an open file descriptor, it is closed before the new -file is opened. -.Pp -The string described by -.Fa path -is copied by the -.Fn posix_spawn_file_actions_addopen -function. -.Pp -The -.Fn posix_spawn_file_actions_adddup2 -function adds a dup2 action to the object referenced by -.Fa file_actions -that causes the file descriptor -.Fa fildes -to be duplicated as -.Fa newfildes -(as if -.Bd -literal -offset indent -dup2(fildes, newfildes) -.Ed -.Pp -had been called) when a new process is spawned using this file actions object. -.Pp -The -.Fn posix_spawn_file_actions_addclose -function adds a close action to the object referenced by -.Fa file_actions -that causes the file descriptor -.Fa fildes -to be closed (as if -.Bd -literal -offset indent -close(fildes) -.Ed -.Pp -had been called) when a new process is spawned using this file actions -object. -.Sh RETURN VALUES -Upon successful completion, these functions return zero; -otherwise, an error number is returned to indicate the error. -.Sh ERRORS -These -functions fail if: -.Bl -tag -width Er -.It Bq Er EBADF -The value specified by -.Fa fildes -or -.Fa newfildes -is negative. -.It Bq Er EINVAL -The value specified by -.Fa file_actions -is invalid. -.It Bq Er ENOMEM -Insufficient memory exists to add to the spawn file actions object. -.El -.Sh SEE ALSO -.Xr close 2 , -.Xr dup2 2 , -.Xr open 2 , -.Xr posix_spawn 3 , -.Xr posix_spawn_file_actions_destroy 3 , -.Xr posix_spawn_file_actions_init 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawn_file_actions_addopen , -.Fn posix_spawn_file_actions_adddup2 -and -.Fn posix_spawn_file_actions_addclose -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawn_file_actions_addopen , -.Fn posix_spawn_file_actions_adddup2 -and -.Fn posix_spawn_file_actions_addclose -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawn_file_actions_init.3 b/lib/libc/gen/posix_spawn_file_actions_init.3 deleted file mode 100644 index d33a09c26..000000000 --- a/lib/libc/gen/posix_spawn_file_actions_init.3 +++ /dev/null @@ -1,112 +0,0 @@ -.\" $NetBSD: posix_spawn_file_actions_init.3,v 1.5 2014/02/02 16:59:13 wiz Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawn_file_actions_init.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd February 2, 2014 -.Dt POSIX_SPAWN_FILE_ACTIONS_INIT 3 -.Os -.Sh NAME -.Nm posix_spawn_file_actions_init , -.Nm posix_spawn_file_actions_destroy -.Nd "initialize and destroy spawn file actions object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawn_file_actions_init "posix_spawn_file_actions_t * file_actions" -.Ft int -.Fn posix_spawn_file_actions_destroy "posix_spawn_file_actions_t * file_actions" -.Sh DESCRIPTION -The -.Fn posix_spawn_file_actions_init -function initialize the object referenced by -.Fn file_actions -to contain no file actions for -.Fn posix_spawn -or -.Fn posix_spawnp . -Initializing an already initialized spawn file actions object may cause -memory to be leaked. -.Pp -The -.Fn posix_spawn_file_actions_destroy -function destroy the object referenced by -.Fa file_actions ; -the object becomes, in effect, uninitialized. -A destroyed spawn file actions object can be reinitialized using -.Fn posix_spawn_file_actions_init . -The object should not be used after it has been destroyed. -.Sh RETURN VALUES -Upon successful completion, these functions return zero; -otherwise, an error number is returned to indicate the error. -.Sh ERRORS -The -.Fn posix_spawn_file_actions_init -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The value specified by -.Fa file_actions -is invalid. -.It Bq Er ENOMEM -Insufficient memory exists to initialize the spawn file actions object. -.El -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawn_file_actions_addclose 3 , -.Xr posix_spawn_file_actions_adddup2 3 , -.Xr posix_spawn_file_actions_addopen 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawn_file_actions_init -and -.Fn posix_spawn_file_actions_destroy -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawn_file_actions_init -and -.Fn posix_spawn_file_actions_destroy -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawn_fileactions.c b/lib/libc/gen/posix_spawn_fileactions.c deleted file mode 100644 index c19ab69df..000000000 --- a/lib/libc/gen/posix_spawn_fileactions.c +++ /dev/null @@ -1,173 +0,0 @@ -/*- - * Copyright (c) 2008 Ed Schouten - * 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 -__RCSID("$NetBSD: posix_spawn_fileactions.c,v 1.4 2014/02/02 14:54:39 martin Exp $"); - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -#define MIN_SIZE 16 - -/* - * File descriptor actions - */ - -int -posix_spawn_file_actions_init(posix_spawn_file_actions_t *fa) -{ - if (fa == NULL) - return EINVAL; - - fa->fae = malloc(MIN_SIZE * sizeof(struct posix_spawn_file_actions_entry)); - if (fa->fae == NULL) - return ENOMEM; - fa->size = MIN_SIZE; - fa->len = 0; - - return 0; -} - -int -posix_spawn_file_actions_destroy(posix_spawn_file_actions_t *fa) -{ - unsigned int i; - - if (fa == NULL) - return EINVAL; - - for (i = 0; i < fa->len; i++) { - if (fa->fae[i].fae_action == FAE_OPEN) - free(fa->fae[i].fae_path); - } - - free(fa->fae); - return 0; -} - -static int -posix_spawn_file_actions_getentry(posix_spawn_file_actions_t *fa, - unsigned int *i) -{ - posix_spawn_file_actions_entry_t *fae; - - if (fa == NULL) - return EINVAL; - - if (fa->len < fa->size) - goto out; - - fae = realloc(fa->fae, (fa->size + MIN_SIZE) * sizeof(*fa->fae)); - if (fae == NULL) - return ENOMEM; - - fa->fae = fae; - fa->size += MIN_SIZE; - -out: - *i = fa->len; - return 0; -} - -int -posix_spawn_file_actions_addopen(posix_spawn_file_actions_t * __restrict fa, - int fildes, const char * __restrict path, int oflag, mode_t mode) -{ - char *faepath; - unsigned int i; - int error; - - if (fildes < 0) - return EBADF; - - error = posix_spawn_file_actions_getentry(fa, &i); - if (error) - return error; - - faepath = strdup(path); - if (faepath == NULL) - return ENOMEM; - - fa->fae[i].fae_action = FAE_OPEN; - fa->fae[i].fae_path = faepath; - fa->fae[i].fae_fildes = fildes; - fa->fae[i].fae_oflag = oflag; - fa->fae[i].fae_mode = mode; - fa->len++; - - return 0; -} - -int -posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *fa, - int fildes, int newfildes) -{ - unsigned int i; - int error; - - if (fildes < 0 || newfildes < 0) - return EBADF; - - error = posix_spawn_file_actions_getentry(fa, &i); - if (error) - return error; - - fa->fae[i].fae_action = FAE_DUP2; - fa->fae[i].fae_fildes = fildes; - fa->fae[i].fae_newfildes = newfildes; - fa->len++; - - return 0; -} - -int -posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *fa, - int fildes) -{ - unsigned int i; - int error; - - if (fildes < 0) - return EBADF; - - error = posix_spawn_file_actions_getentry(fa, &i); - if (error) - return error; - - fa->fae[i].fae_action = FAE_CLOSE; - fa->fae[i].fae_fildes = fildes; - fa->len++; - - return 0; -} diff --git a/lib/libc/gen/posix_spawn_sched.c b/lib/libc/gen/posix_spawn_sched.c deleted file mode 100644 index dc1dda9e7..000000000 --- a/lib/libc/gen/posix_spawn_sched.c +++ /dev/null @@ -1,155 +0,0 @@ -/*- - * Copyright (c) 2008 Ed Schouten - * 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 -__RCSID("$NetBSD: posix_spawn_sched.c,v 1.2 2014/02/02 14:54:39 martin Exp $"); - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include -#include - -/* - * Spawn attributes - */ - -int -posix_spawnattr_init(posix_spawnattr_t *ret) -{ - if (ret == NULL) - return -1; - - memset(ret, 0, sizeof(posix_spawnattr_t)); - return 0; -} - -int -posix_spawnattr_destroy(posix_spawnattr_t *sa) -{ - if (sa == NULL) - return -1; - - return 0; -} - -int -posix_spawnattr_getflags(const posix_spawnattr_t * __restrict sa, - short * __restrict flags) -{ - *flags = sa->sa_flags; - return 0; -} - -int -posix_spawnattr_getpgroup(const posix_spawnattr_t * __restrict sa, - pid_t * __restrict pgroup) -{ - *pgroup = sa->sa_pgroup; - return 0; -} - -int -posix_spawnattr_getschedparam(const posix_spawnattr_t * __restrict sa, - struct sched_param * __restrict schedparam) -{ - *schedparam = sa->sa_schedparam; - return 0; -} - -int -posix_spawnattr_getschedpolicy(const posix_spawnattr_t * __restrict sa, - int * __restrict schedpolicy) -{ - *schedpolicy = sa->sa_schedpolicy; - return 0; -} - -int -posix_spawnattr_getsigdefault(const posix_spawnattr_t * __restrict sa, - sigset_t * __restrict sigdefault) -{ - *sigdefault = sa->sa_sigdefault; - return 0; -} - -int -posix_spawnattr_getsigmask(const posix_spawnattr_t * __restrict sa, - sigset_t * __restrict sigmask) -{ - *sigmask = sa->sa_sigmask; - return 0; -} - -int -posix_spawnattr_setflags(posix_spawnattr_t *sa, short flags) -{ - sa->sa_flags = flags; - return 0; -} - -int -posix_spawnattr_setpgroup(posix_spawnattr_t *sa, pid_t pgroup) -{ - sa->sa_pgroup = pgroup; - return 0; -} - -int -posix_spawnattr_setschedparam(posix_spawnattr_t * __restrict sa, - const struct sched_param * __restrict schedparam) -{ - sa->sa_schedparam = *schedparam; - return 0; -} - -int -posix_spawnattr_setschedpolicy(posix_spawnattr_t *sa, int schedpolicy) -{ - sa->sa_schedpolicy = schedpolicy; - return 0; -} - -int -posix_spawnattr_setsigdefault(posix_spawnattr_t * __restrict sa, - const sigset_t * __restrict sigdefault) -{ - sa->sa_sigdefault = *sigdefault; - return 0; -} - -int -posix_spawnattr_setsigmask(posix_spawnattr_t * __restrict sa, - const sigset_t * __restrict sigmask) -{ - sa->sa_sigmask = *sigmask; - return 0; -} diff --git a/lib/libc/gen/posix_spawnattr_getflags.3 b/lib/libc/gen/posix_spawnattr_getflags.3 deleted file mode 100644 index bb29c53be..000000000 --- a/lib/libc/gen/posix_spawnattr_getflags.3 +++ /dev/null @@ -1,115 +0,0 @@ -.\" $NetBSD: posix_spawnattr_getflags.3,v 1.4 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getflags.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd December 20, 2011 -.Dt POSIX_SPAWNATTR_GETFLAGS 3 -.Os -.Sh NAME -.Nm posix_spawnattr_getflags , -.Nm posix_spawnattr_setflags -.Nd "get and set the spawn-flags attribute of a spawn attributes object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawnattr_getflags "const posix_spawnattr_t *restrict attr" "short *restrict flags" -.Ft int -.Fn posix_spawnattr_setflags "posix_spawnattr_t *attr" "short flags" -.Sh DESCRIPTION -The -.Fn posix_spawnattr_getflags -function obtains the value of the spawn-flags attribute from the -attributes object referenced by -.Fa attr . -.Pp -The -.Fn posix_spawnattr_setflags -function sets the spawn-flags attribute in an initialized -attributes object referenced by -.Fa attr . -.Pp -The spawn-flags attribute is used to indicate which process attributes -are to be changed in the new process image when invoking -.Fn posix_spawn -or -.Fn posix_spawnp . -It is the bitwise-inclusive OR of zero or more of the following flags -(see -.Fn posix_spawn ) : -.Bl -tag -offset indent -.It Dv POSIX_SPAWN_RESETIDS -.It Dv POSIX_SPAWN_SETPGROUP -.It Dv POSIX_SPAWN_SETSIGDEF -.It Dv POSIX_SPAWN_SETSIGMASK -.It Dv POSIX_SPAWN_SETSCHEDPARAM -.It Dv POSIX_SPAWN_SETSCHEDULER -.El -.Pp -These flags are defined in -.In spawn.h . -The default value of this attribute is as if no flags were set. -.Sh RETURN VALUES -The -.Fn posix_spawnattr_getflags -and -.Fn posix_spawnattr_setflags -functions return zero. -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawnattr_destroy 3 , -.Xr posix_spawnattr_init 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawnattr_getflags -and -.Fn posix_spawnattr_setflags -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawnattr_getflags -and -.Fn posix_spawnattr_setflags -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getpgroup.3 b/lib/libc/gen/posix_spawnattr_getpgroup.3 deleted file mode 100644 index 7f6c6fb3d..000000000 --- a/lib/libc/gen/posix_spawnattr_getpgroup.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" $NetBSD: posix_spawnattr_getpgroup.3,v 1.4 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getpgroup.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd December 20, 2011 -.Dt POSIX_SPAWNATTR_GETPGROUP 3 -.Os -.Sh NAME -.Nm posix_spawnattr_getpgroup , -.Nm posix_spawnattr_setpgroup -.Nd "get and set the spawn-pgroup attribute of a spawn attributes object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawnattr_getpgroup "const posix_spawnattr_t *restrict attr" "pid_t *restrict pgroup" -.Ft int -.Fn posix_spawnattr_setpgroup "posix_spawnattr_t *attr" "pid_t pgroup" -.Sh DESCRIPTION -The -.Fn posix_spawnattr_getpgroup -function obtains the value of the spawn-pgroup attribute from the -attributes object referenced by -.Fa attr . -.Pp -The -.Fn posix_spawnattr_setpgroup -function sets the spawn-pgroup attribute in an initialized -attributes object referenced by -.Fa attr . -.Pp -The spawn-pgroup attribute represents the process group to be joined by -the new process image in a spawn operation (if -.Dv POSIX_SPAWN_SETPGROUP -is set in the spawn-flags attribute). -The default value of this attribute is zero. -.Sh RETURN VALUES -The -.Fn posix_spawnattr_getpgroup -and -.Fn posix_spawnattr_setpgroup -functions return zero. -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawnattr_destroy 3 , -.Xr posix_spawnattr_init 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawnattr_getpgroup -and -.Fn posix_spawnattr_setpgroup -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawnattr_getpgroup -and -.Fn posix_spawnattr_setpgroup -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getschedparam.3 b/lib/libc/gen/posix_spawnattr_getschedparam.3 deleted file mode 100644 index c5936bbec..000000000 --- a/lib/libc/gen/posix_spawnattr_getschedparam.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" $NetBSD: posix_spawnattr_getschedparam.3,v 1.4 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getschedparam.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd December 20, 2011 -.Dt POSIX_SPAWNATTR_GETSCHEDPARAM 3 -.Os -.Sh NAME -.Nm posix_spawnattr_getschedparam , -.Nm posix_spawnattr_setschedparam -.Nd "get and set the spawn-schedparam attribute of a spawn attributes object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawnattr_getschedparam "const posix_spawnattr_t *restrict attr" "struct sched_param *restrict schedparam" -.Ft int -.Fn posix_spawnattr_setschedparam "posix_spawnattr_t *attr" "const struct sched_param *restrict schedparam" -.Sh DESCRIPTION -The -.Fn posix_spawnattr_getschedparam -function obtains the value of the spawn-schedparam attribute from the -attributes object referenced by -.Fa attr . -.Pp -The -.Fn posix_spawnattr_setschedparam -function sets the spawn-schedparam attribute in an initialized attributes -object referenced by -.Fa attr . -.Pp -The spawn-schedparam attribute represents the scheduling parameters to -be assigned to the new process image in a spawn operation (if -.Dv POSIX_SPAWN_SETSCHEDULER -or -.Dv POSIX_SPAWN_SETSCHEDPARAM -is set in the spawn-flags attribute). -The default value of this attribute is unspecified. -.Sh RETURN VALUES -The -.Fn posix_spawnattr_getschedparam -and -.Fn posix_spawnattr_setschedparam -functions return zero. -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawnattr_destroy 3 , -.Xr posix_spawnattr_getschedpolicy 3 , -.Xr posix_spawnattr_init 3 , -.Xr posix_spawnattr_setschedpolicy 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawnattr_getschedparam -and -.Fn posix_spawnattr_setschedparam -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawnattr_getschedparam -and -.Fn posix_spawnattr_setschedparam -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getschedpolicy.3 b/lib/libc/gen/posix_spawnattr_getschedpolicy.3 deleted file mode 100644 index 19e3a1522..000000000 --- a/lib/libc/gen/posix_spawnattr_getschedpolicy.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $NetBSD: posix_spawnattr_getschedpolicy.3,v 1.4 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getschedpolicy.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd December 20, 2011 -.Dt POSIX_SPAWNATTR_GETSCHEDPOLICY 3 -.Os -.Sh NAME -.Nm posix_spawnattr_getschedpolicy , -.Nm posix_spawnattr_setschedpolicy -.Nd "get and set the spawn-schedpolicy attribute of a spawn attributes object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawnattr_getschedpolicy "const posix_spawnattr_t *restrict attr" "int *restrict schedpolicy" -.Ft int -.Fn posix_spawnattr_setschedpolicy "posix_spawnattr_t *attr" "int schedpolicy" -.Sh DESCRIPTION -The -.Fn posix_spawnattr_getschedpolicy -function obtains the value of the spawn-schedpolicy attribute from the -attributes object referenced by -.Fa attr . -.Pp -The -.Fn posix_spawnattr_setschedpolicy -function sets the spawn-schedpolicy attribute in an initialized attributes -object referenced by -.Fa attr . -.Pp -The spawn-schedpolicy attribute represents the scheduling policy to -be assigned to the new process image in a spawn operation (if -.Dv POSIX_SPAWN_SETSCHEDULER -is set in the spawn-flags attribute). -The default value of this attribute is unspecified. -.Sh RETURN VALUES -The -.Fn posix_spawnattr_getschedpolicy -and -.Fn posix_spawnattr_setschedpolicy -functions return zero. -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawnattr_destroy 3 , -.Xr posix_spawnattr_getschedparam 3 , -.Xr posix_spawnattr_init 3 , -.Xr posix_spawnattr_setschedparam 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawnattr_getschedpolicy -and -.Fn posix_spawnattr_setschedpolicy -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawnattr_getschedpolicy -and -.Fn posix_spawnattr_setschedpolicy -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getsigdefault.3 b/lib/libc/gen/posix_spawnattr_getsigdefault.3 deleted file mode 100644 index a3a321e2e..000000000 --- a/lib/libc/gen/posix_spawnattr_getsigdefault.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $NetBSD: posix_spawnattr_getsigdefault.3,v 1.4 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getsigdefault.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd December 20, 2011 -.Dt POSIX_SPAWNATTR_GETSIGDEFAULT 3 -.Os -.Sh NAME -.Nm posix_spawnattr_getsigdefault , -.Nm posix_spawnattr_setsigdefault -.Nd "get and set the spawn-sigdefault attribute of a spawn attributes object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawnattr_getsigdefault "const posix_spawnattr_t *restrict attr" "sigset_t *restrict sigdefault" -.Ft int -.Fn posix_spawnattr_setsigdefault "posix_spawnattr_t *attr" "const sigset_t *restrict sigdefault" -.Sh DESCRIPTION -The -.Fn posix_spawnattr_getsigdefault -function obtains the value of the spawn-sigdefault attribute from the -attributes object referenced by -.Fa attr . -.Pp -The -.Fn posix_spawnattr_setsigdefault -function sets the spawn-sigdefault attribute in an initialized attributes -object referenced by -.Fa attr . -.Pp -The spawn-sigdefault attribute represents the set of signals to be forced to -default signal handling in the new process image (if -.Dv POSIX_SPAWN_SETSIGDEF -is set in the spawn-flags attribute) by a spawn operation. -The default value of this attribute is an empty signal set. -.Sh RETURN VALUES -The -.Fn posix_spawnattr_getsigdefault -and -.Fn posix_spawnattr_setsigdefault -functions return zero. -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawnattr_destroy 3 , -.Xr posix_spawnattr_getsigmask 3 , -.Xr posix_spawnattr_init 3 , -.Xr posix_spawnattr_setsigmask 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawnattr_getsigdefault -and -.Fn posix_spawnattr_setsigdefault -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawnattr_getsigdefault -and -.Fn posix_spawnattr_setsigdefault -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_getsigmask.3 b/lib/libc/gen/posix_spawnattr_getsigmask.3 deleted file mode 100644 index 0b0ad4c52..000000000 --- a/lib/libc/gen/posix_spawnattr_getsigmask.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" $NetBSD: posix_spawnattr_getsigmask.3,v 1.4 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_getsigmask.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd December 20, 2011 -.Dt POSIX_SPAWNATTR_GETSIGMASK 3 -.Os -.Sh NAME -.Nm posix_spawnattr_getsigmask , -.Nm posix_spawnattr_setsigmask -.Nd "get and set the spawn-sigmask attribute of a spawn attributes object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawnattr_getsigmask "const posix_spawnattr_t *restrict attr" "sigset_t *restrict sigmask" -.Ft int -.Fn posix_spawnattr_setsigmask "posix_spawnattr_t *attr" "const sigset_t *restrict sigmask" -.Sh DESCRIPTION -The -.Fn posix_spawnattr_getsigmask -function obtains the value of the spawn-sigmask attribute from the -attributes object referenced by -.Fa attr . -.Pp -The -.Fn posix_spawnattr_setsigmask -function sets the spawn-sigmask attribute in an initialized attributes -object referenced by -.Fa attr . -.Pp -The spawn-sigmask attribute represents the signal mask in effect in the -new process image of a spawn operation (if -.Dv POSIX_SPAWN_SETSIGMASK -is set in the spawn-flags attribute). -The default value of this attribute is unspecified. -.Sh RETURN VALUES -The -.Fn posix_spawnattr_getsigmask -and -.Fn posix_spawnattr_setsigmask -functions return zero. -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawnattr_destroy 3 , -.Xr posix_spawnattr_init 3 , -.Xr posix_spawnattr_setsigmask 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawnattr_getsigmask -and -.Fn posix_spawnattr_setsigmask -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawnattr_getsigmask -and -.Fn posix_spawnattr_setsigmask -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnattr_init.3 b/lib/libc/gen/posix_spawnattr_init.3 deleted file mode 100644 index 2358bc0a9..000000000 --- a/lib/libc/gen/posix_spawnattr_init.3 +++ /dev/null @@ -1,127 +0,0 @@ -.\" $NetBSD: posix_spawnattr_init.3,v 1.4 2014/03/18 18:20:37 riastradh Exp $ -.\" -.\" Copyright (c) 2008 Ed Schouten -.\" 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. -.\" -.\" Portions of this text are reprinted and reproduced in electronic form -.\" from IEEE Std 1003.1, 2004 Edition, Standard for Information Technology -- -.\" Portable Operating System Interface (POSIX), The Open Group Base -.\" Specifications Issue 6, Copyright (C) 2001-2004 by the Institute of -.\" Electrical and Electronics Engineers, Inc and The Open Group. In the -.\" event of any discrepancy between this version and the original IEEE and -.\" The Open Group Standard, the original IEEE and The Open Group Standard is -.\" the referee document. The original Standard can be obtained online at -.\" http://www.opengroup.org/unix/online.html. -.\" -.\" $FreeBSD: src/lib/libc/gen/posix_spawnattr_init.3,v 1.1.2.1.4.1 2010/06/14 02:09:06 kensmith Exp $ -.\" -.Dd December 20, 2011 -.Dt POSIX_SPAWNATTR_INIT 3 -.Os -.Sh NAME -.Nm posix_spawnattr_init , -.Nm posix_spawnattr_destroy -.Nd "initialize and destroy spawn attributes object" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In spawn.h -.Ft int -.Fn posix_spawnattr_init "posix_spawnattr_t * attr" -.Ft int -.Fn posix_spawnattr_destroy "posix_spawnattr_t * attr" -.Sh DESCRIPTION -The -.Fn posix_spawnattr_init -function initializes a spawn attributes object -.Fa attr -with the default value for all of the individual attributes used by the -implementation. -Initializing an already initialized spawn attributes object may cause -memory to be leaked. -.Pp -The -.Fn posix_spawnattr_destroy -function destroys a spawn attributes object. -A destroyed -.Fa attr -attributes object can be reinitialized using -.Fn posix_spawnattr_init . -The object should not be used after it has been destroyed. -.Pp -A spawn attributes object is of type -.Vt posix_spawnattr_t -(defined in -.In spawn.h ) -and is used to specify the inheritance of process attributes across a -spawn operation. -.Pp -The resulting spawn attributes object (possibly modified by setting -individual attribute values), is used to modify the behavior of -.Fn posix_spawn -or -.Fn posix_spawnp . -After a spawn attributes object has been used to spawn a process by a -call to a -.Fn posix_spawn -or -.Fn posix_spawnp , -any function affecting the attributes object (including destruction) -will not affect any process that has been spawned in this way. -.Sh RETURN VALUES -Upon successful completion, -.Fn posix_spawnattr_init -and -.Fn posix_spawnattr_destroy -return zero; -otherwise, an error number is returned to indicate the error. -.Sh ERRORS -The -.Fn posix_spawnattr_init -function will fail if: -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory exists to initialize the spawn file actions object. -.El -.Sh SEE ALSO -.Xr posix_spawn 3 , -.Xr posix_spawnp 3 -.Sh STANDARDS -The -.Fn posix_spawnattr_init -and -.Fn posix_spawnattr_destroy -functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn posix_spawnattr_init -and -.Fn posix_spawnattr_destroy -functions first appeared in -.Fx 8.0 -and imported for -.Nx 6.0 . -.Sh AUTHORS -.An Ed Schouten Aq Mt ed@FreeBSD.org diff --git a/lib/libc/gen/posix_spawnp.c b/lib/libc/gen/posix_spawnp.c deleted file mode 100644 index 5149f625d..000000000 --- a/lib/libc/gen/posix_spawnp.c +++ /dev/null @@ -1,81 +0,0 @@ -/* $NetBSD: posix_spawnp.c,v 1.2 2012/02/22 17:51:01 martin Exp $ */ - -/*- - * Copyright (c) 2011 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Martin Husemann . - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: posix_spawnp.c,v 1.2 2012/02/22 17:51:01 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - - -int posix_spawnp(pid_t * __restrict pid, const char * __restrict file, - const posix_spawn_file_actions_t *fa, - const posix_spawnattr_t * __restrict sa, - char * const *__restrict cav, char * const *__restrict env) -{ - char fpath[FILENAME_MAX], *last, *p; - char *path; - - /* - * If there is a / in the filename, or no PATH environment variable - * set, fall straight through to posix_spawn(). - */ - if (strchr(file, '/') != NULL || (path = getenv("PATH")) == NULL) - return posix_spawn(pid, file, fa, sa, cav, env); - - path = strdup(path); - if (path == NULL) - return ENOMEM; - - /* - * Find an executable image with the given name in the PATH - */ - for (p = strtok_r(path, ":", &last); p; - p = strtok_r(NULL, ":", &last)) { - snprintf(fpath, sizeof fpath, "%s/%s", p, file); - fpath[FILENAME_MAX-1] = 0; - if (access(fpath, X_OK) == 0) - break; - } - free(path); - - /* - * Use posix_spawn() with the found binary - */ - return posix_spawn(pid, fpath, fa, sa, cav, env); -} - diff --git a/lib/libc/gen/psignal.3 b/lib/libc/gen/psignal.3 deleted file mode 100644 index 05e5922fc..000000000 --- a/lib/libc/gen/psignal.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" $NetBSD: psignal.3,v 1.17 2010/08/27 08:38:41 christos Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)psignal.3 8.2 (Berkeley) 2/27/95 -.\" -.Dd August 27, 2010 -.Dt PSIGNAL 3 -.Os -.Sh NAME -.Nm psignal , -.Nm psiginfo , -.Nm sys_siglist , -.Nm sys_signame -.Nd system signal messages -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft void -.Fn psignal "int sig" "const char *s" -.Fn psiginfo "const siginfo_t *si" "const char *s" -.Vt extern const char * const sys_siglist[]; -.Vt extern const char * const sys_signame[]; -.Sh DESCRIPTION -The -.Fn psignal -function locates the descriptive message -string for the given signal number -.Fa sig -and writes it to the standard error. -.Pp -If the argument -.Fa s -is -.Pf non- Dv NULL -it is written to the standard error file descriptor -prior to the message string, -immediately followed by a colon and a space. -If the signal number is not recognized -.Pq Xr sigaction 2 , -the string -.Dq "Unknown signal" -is produced. -.Pp -The -.Fn psiginfo -function produces the same output as the -.Fn psignal -function, only it uses the signal number information from the -.Fa si -argument. -.Pp -The message strings can be accessed directly using the external array -.Va sys_siglist , -indexed by recognized signal numbers. -The external array -.Va sys_signame -is used similarly and contains short, upper-case abbreviations for signals -which are useful for recognizing signal names in user input. -The defined variable -.Dv NSIG -contains a count of the strings in -.Va sys_siglist -and -.Va sys_signame . -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr perror 3 , -.Xr setlocale 3 , -.Xr strsignal 3 -.Sh HISTORY -The -.Fn psignal -function appeared in -.Bx 4.2 . -The -.Fn psiginfo -function appeared in -.Nx 6.0 . diff --git a/lib/libc/gen/psignal.c b/lib/libc/gen/psignal.c deleted file mode 100644 index 4472be69c..000000000 --- a/lib/libc/gen/psignal.c +++ /dev/null @@ -1,85 +0,0 @@ -/* $NetBSD: psignal.c,v 1.23 2012/03/13 21:13:36 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)psignal.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: psignal.c,v 1.23 2012/03/13 21:13:36 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#include -#include -#include -#include - -#include "extern.h" - -#ifdef __weak_alias -__weak_alias(psignal,_psignal) -#endif - -void -psignal(int sig, const char *s) -{ - struct iovec *v; - struct iovec iov[4]; - char buf[NL_TEXTMAX]; - - v = iov; - if (s && *s) { - v->iov_base = __UNCONST(s); - v->iov_len = strlen(s); - v++; - v->iov_base = __UNCONST(": "); - v->iov_len = 2; - v++; - } - v->iov_base = __UNCONST(__strsignal((int)sig, buf, sizeof(buf))); - v->iov_len = strlen(v->iov_base); - v++; - v->iov_base = __UNCONST("\n"); - v->iov_len = 1; - (void)writev(STDERR_FILENO, iov, (int)((v - iov) + 1)); -} - -void -psiginfo(const siginfo_t *si, const char *s) -{ - psignal(si->si_signo, s); -} diff --git a/lib/libc/gen/pthread_atfork.3 b/lib/libc/gen/pthread_atfork.3 deleted file mode 100644 index b29f414dd..000000000 --- a/lib/libc/gen/pthread_atfork.3 +++ /dev/null @@ -1,129 +0,0 @@ -.\" $NetBSD: pthread_atfork.3,v 1.7 2014/07/19 14:58:50 wiz Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Nathan J. Williams. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd July 18, 2014 -.Dt PTHREAD_ATFORK 3 -.Os -.Sh NAME -.Nm pthread_atfork -.Nd register handlers to be called when process forks -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In pthread.h -.Ft int -.Fn pthread_atfork "void (*prepare)(void)" "void (*parent)(void)" "void (*child)(void)" -.Sh DESCRIPTION -The -.Fn pthread_atfork -function registers the provided handler functions to be called when the -.Xr fork 2 -function is called. -Each of the three handlers is called at a different place in the -.Xr fork 2 -sequence. -The -.Ar prepare -handler is called in the parent process before the fork happens, the -.Ar parent -handler is called in the parent process after the fork has happened, and the -.Ar child -handler is called in the child process after the fork has happened. -The -.Ar parent -and -.Ar child -handlers are called in the order in which they were registered, while the -.Ar prepare -handlers are called in reverse of the order in which they were registered. -.Pp -Any of the handlers given may be -.Dv NULL . -.Pp -The intended use of -.Fn pthread_atfork -is to provide a consistent state to a child process from a multithreaded parent -process where locks may be acquired and released asynchronously with respect to the -.Xr fork 2 -call. -Each subsystem with locks that are used in a child process should register -handlers with -.Fn pthread_atfork -that acquires those locks in the -.Ar prepare -handler and releases them in the -.Ar parent -handler. -.Sh RETURN VALUES -The -.Fn pthread_atfork -function returns 0 on success and an error number on failure. -.Sh ERRORS -The following error code may be returned: -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory exists to register the fork handlers. -.El -.Sh SEE ALSO -.Xr fork 2 , -.Xr pthread_mutex 3 , -.Xr signal 7 -.Sh STANDARDS -The -.Fn pthread_atfork -function conforms to -.St -p1003.1c-95 . -.Sh HISTORY -The -.Fn pthread_atfork -function first appeared in -.Nx 2.0 . -.Sh CAVEATS -After calling -.Xr fork 2 -from a multithreaded process, it is only safe to call -async-signal-safe functions until calling one of the -.Xr exec 3 -functions. -The -.Fn pthread_* -functions are not async-signal-safe, so it is not safe to use such functions -in the -.Ar child -handler. -POSIX does not mandate that -.Fn pthread_mutex_unlock -be async-signal-safe, but it is in -.Nx -and thus safe to use within the -.Ar child -handler. -.Sh BUGS -There is no way to unregister a handler registered with -.Fn pthread_atfork . diff --git a/lib/libc/gen/pthread_atfork.c b/lib/libc/gen/pthread_atfork.c deleted file mode 100644 index 2d8252645..000000000 --- a/lib/libc/gen/pthread_atfork.c +++ /dev/null @@ -1,205 +0,0 @@ -/* $NetBSD: pthread_atfork.c,v 1.10 2015/01/20 18:31:25 christos Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Nathan J. Williams. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pthread_atfork.c,v 1.10 2015/01/20 18:31:25 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include "reentrant.h" - -#ifdef __weak_alias -__weak_alias(pthread_atfork, _pthread_atfork) -__weak_alias(fork, _fork) -#endif /* __weak_alias */ - -pid_t __fork(void); /* XXX */ - -struct atfork_callback { - SIMPLEQ_ENTRY(atfork_callback) next; - void (*fn)(void); -}; - -/* - * Hypothetically, we could protect the queues with a rwlock which is - * write-locked by pthread_atfork() and read-locked by fork(), but - * since the intended use of the functions is obtaining locks to hold - * across the fork, forking is going to be serialized anyway. - */ -static struct atfork_callback atfork_builtin; -#ifdef _REENTRANT -static mutex_t atfork_lock = MUTEX_INITIALIZER; -#endif -SIMPLEQ_HEAD(atfork_callback_q, atfork_callback); - -static struct atfork_callback_q prepareq = SIMPLEQ_HEAD_INITIALIZER(prepareq); -static struct atfork_callback_q parentq = SIMPLEQ_HEAD_INITIALIZER(parentq); -static struct atfork_callback_q childq = SIMPLEQ_HEAD_INITIALIZER(childq); - -static struct atfork_callback * -af_alloc(void) -{ - - if (atfork_builtin.fn == NULL) - return &atfork_builtin; - - return malloc(sizeof(atfork_builtin)); -} - -static void -af_free(struct atfork_callback *af) -{ - - if (af != &atfork_builtin) - free(af); -} - -int -pthread_atfork(void (*prepare)(void), void (*parent)(void), - void (*child)(void)) -{ - struct atfork_callback *newprepare, *newparent, *newchild; - - newprepare = newparent = newchild = NULL; - - mutex_lock(&atfork_lock); - if (prepare != NULL) { - newprepare = af_alloc(); - if (newprepare == NULL) { - mutex_unlock(&atfork_lock); - return ENOMEM; - } - newprepare->fn = prepare; - } - - if (parent != NULL) { - newparent = af_alloc(); - if (newparent == NULL) { - if (newprepare != NULL) - af_free(newprepare); - mutex_unlock(&atfork_lock); - return ENOMEM; - } - newparent->fn = parent; - } - - if (child != NULL) { - newchild = af_alloc(); - if (newchild == NULL) { - if (newprepare != NULL) - af_free(newprepare); - if (newparent != NULL) - af_free(newparent); - mutex_unlock(&atfork_lock); - return ENOMEM; - } - newchild->fn = child; - } - - /* - * The order in which the functions are called is specified as - * LIFO for the prepare handler and FIFO for the others; insert - * at the head and tail as appropriate so that SIMPLEQ_FOREACH() - * produces the right order. - */ - if (prepare) - SIMPLEQ_INSERT_HEAD(&prepareq, newprepare, next); - if (parent) - SIMPLEQ_INSERT_TAIL(&parentq, newparent, next); - if (child) - SIMPLEQ_INSERT_TAIL(&childq, newchild, next); - mutex_unlock(&atfork_lock); - - return 0; -} - -pid_t -fork(void) -{ - struct atfork_callback *iter; - pid_t ret; - - mutex_lock(&atfork_lock); - SIMPLEQ_FOREACH(iter, &prepareq, next) - (*iter->fn)(); - - ret = __fork(); - - if (ret != 0) { - /* - * We are the parent. It doesn't matter here whether - * the fork call succeeded or failed. - */ - SIMPLEQ_FOREACH(iter, &parentq, next) - (*iter->fn)(); - mutex_unlock(&atfork_lock); - } else { - /* We are the child */ - SIMPLEQ_FOREACH(iter, &childq, next) - (*iter->fn)(); - /* - * Note: We are explicitly *not* unlocking - * atfork_lock. Unlocking atfork_lock is problematic, - * because if any threads in the parent blocked on it - * between the initial lock and the fork() syscall, - * unlocking in the child will try to schedule - * threads, and either the internal mutex interlock or - * the runqueue spinlock could have been held at the - * moment of fork(). Since the other threads do not - * exist in this process, the spinlock will never be - * unlocked, and we would wedge. - * Instead, we reinitialize atfork_lock, since we know - * that the state of the atfork lists is consistent here, - * and that there are no other threads to be affected by - * the forcible cleaning of the queue. - * This permits double-forking to work, although - * it requires knowing that it's "safe" to initialize - * a locked mutex in this context. - * - * The problem exists for users of this interface, - * too, since the intented use of pthread_atfork() is - * to acquire locks across the fork call to ensure - * that the child sees consistent state. There's not - * much that can usefully be done in a child handler, - * and conventional wisdom discourages using them, but - * they're part of the interface, so here we are... - */ - mutex_init(&atfork_lock, NULL); - } - - return ret; -} diff --git a/lib/libc/gen/pw_private.h b/lib/libc/gen/pw_private.h deleted file mode 100644 index ee451d8e2..000000000 --- a/lib/libc/gen/pw_private.h +++ /dev/null @@ -1,8 +0,0 @@ -/* $NetBSD: pw_private.h,v 1.3 2012/03/20 16:36:05 matt Exp $ */ - -/* - * Written by Jason R. Thorpe , June 26, 1998. - * Public domain. - */ - -int __pw_scan(char *bp, struct passwd *pw, int *flags); diff --git a/lib/libc/gen/pw_scan.c b/lib/libc/gen/pw_scan.c deleted file mode 100644 index 7c162d8c6..000000000 --- a/lib/libc/gen/pw_scan.c +++ /dev/null @@ -1,240 +0,0 @@ -/* $NetBSD: pw_scan.c,v 1.23 2012/03/13 21:13:36 christos Exp $ */ - -/* - * Copyright (c) 1987, 1993, 1994, 1995 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#include "compat_pwd.h" - -#else -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: pw_scan.c,v 1.23 2012/03/13 21:13:36 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(_LIBC) -#include "namespace.h" -#endif -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef _LIBC -#include "pw_private.h" -#endif -#endif /* ! HAVE_NBTOOL_CONFIG_H */ - -static int -gettime(time_t *res, const char *p, int *flags, int dowarn, int flag) -{ - long long l; - char *ep; - const char *vp; - - if (*p == '\0') { - *flags |= flag; - *res = 0; - return 1; - } - l = strtoll(p, &ep, 0); - if (p == ep || *ep != '\0') { - vp = "Invalid number"; - goto done; - } - if (errno == ERANGE && (l == LLONG_MAX || l == LLONG_MIN)) { - vp = strerror(errno); - goto done; - } - _DIAGASSERT(__type_fit(time_t, l)); - *res = (time_t)l; - return 1; -done: - if (dowarn) { - warnx("%s `%s' for %s time", vp, p, - flag == _PASSWORD_NOEXP ? "expiration" : "change"); - } - return 0; - -} - -static int -getid(unsigned long *res, const char *p, int *flags, int dowarn, int flag) -{ - unsigned long ul; - char *ep; - - if (*p == '\0') { - *flags |= flag; - *res = 0; - return 1; - } - ul = strtoul(p, &ep, 0); - if (p == ep || *ep != '\0') { - ep = __UNCONST("Invalid number"); - goto done; - } - if (errno == ERANGE && ul == ULONG_MAX) { - ep = strerror(errno); - goto done; - } - if (ul > *res) { - ep = strerror(ERANGE); - goto done; - } - - *res = ul; - return 1; -done: - if (dowarn) - warnx("%s %s `%s'", ep, - flag == _PASSWORD_NOUID ? "uid" : "gid", p); - return 0; - -} - -int -#ifdef _LIBC -__pw_scan(char *bp, struct passwd *pw, int *flags) -#else -pw_scan( char *bp, struct passwd *pw, int *flags) -#endif -{ - unsigned long id; - time_t ti; - int root, inflags; - int dowarn; - const char *p, *sh; - - _DIAGASSERT(bp != NULL); - _DIAGASSERT(pw != NULL); - - if (flags) { - inflags = *flags; - *flags = 0; - } else { - inflags = 0; - flags = &inflags; - } - dowarn = !(inflags & _PASSWORD_NOWARN); - - if (!(pw->pw_name = strsep(&bp, ":"))) /* login */ - goto fmt; - if (strlen(pw->pw_name) > (LOGIN_NAME_MAX - 1)) { - if (dowarn) - warnx("username too long, `%s' > %d", pw->pw_name, - LOGIN_NAME_MAX - 1); - return 0; - } - - root = !strcmp(pw->pw_name, "root"); - - if (!(pw->pw_passwd = strsep(&bp, ":"))) /* passwd */ - goto fmt; - - if (!(p = strsep(&bp, ":"))) /* uid */ - goto fmt; - - id = UID_MAX; - if (!getid(&id, p, flags, dowarn, _PASSWORD_NOUID)) - return 0; - - if (root && id) { - if (dowarn) - warnx("root uid should be 0"); - return 0; - } - - pw->pw_uid = (uid_t)id; - - if (!(p = strsep(&bp, ":"))) /* gid */ - goto fmt; - - id = GID_MAX; - if (!getid(&id, p, flags, dowarn, _PASSWORD_NOGID)) - return 0; - - pw->pw_gid = (gid_t)id; - - if (inflags & _PASSWORD_OLDFMT) { - pw->pw_class = __UNCONST(""); - pw->pw_change = 0; - pw->pw_expire = 0; - *flags |= (_PASSWORD_NOCHG | _PASSWORD_NOEXP); - } else { - pw->pw_class = strsep(&bp, ":"); /* class */ - if (!(p = strsep(&bp, ":"))) /* change */ - goto fmt; - if (!gettime(&ti, p, flags, dowarn, _PASSWORD_NOCHG)) - return 0; - pw->pw_change = ti; - - if (!(p = strsep(&bp, ":"))) /* expire */ - goto fmt; - if (!gettime(&ti, p, flags, dowarn, _PASSWORD_NOEXP)) - return 0; - pw->pw_expire = ti; - } - - pw->pw_gecos = strsep(&bp, ":"); /* gecos */ - pw->pw_dir = strsep(&bp, ":"); /* directory */ - if (!(pw->pw_shell = strsep(&bp, ":"))) /* shell */ - goto fmt; - -#if ! HAVE_NBTOOL_CONFIG_H - p = pw->pw_shell; - if (root && *p) /* empty == /bin/sh */ - for (setusershell();;) { - if (!(sh = getusershell())) { - if (dowarn) - warnx("warning, unknown root shell"); - break; - } - if (!strcmp(p, sh)) - break; - } -#endif - - if ((p = strsep(&bp, ":")) != NULL) { /* too many */ -fmt: - if (dowarn) - warnx("corrupted entry"); - return 0; - } - - return 1; -} diff --git a/lib/libc/gen/pwcache.3 b/lib/libc/gen/pwcache.3 deleted file mode 100644 index c0b679af9..000000000 --- a/lib/libc/gen/pwcache.3 +++ /dev/null @@ -1,220 +0,0 @@ -.\" $NetBSD: pwcache.3,v 1.17 2008/05/02 18:11:04 martin Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" -.\" Copyright (c) 2002 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" -.\" @(#)pwcache.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd January 24, 2002 -.Dt PWCACHE 3 -.Os -.Sh NAME -.Nm pwcache , -.Nm user_from_uid , -.Nm group_from_gid -.Nd cache password and group entries -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In pwd.h -.Ft const char * -.Fn user_from_uid "uid_t uid" "int nouser" -.Ft int -.Fn uid_from_user "const char *name" "uid_t *uid" -.Ft int -.Fn pwcache_userdb "int (*setpassent)(int)" "void (*endpwent)(void)" "struct passwd * (*getpwnam)(const char *)" "struct passwd * (*getpwuid)(uid_t)" -.In grp.h -.Ft const char * -.Fn group_from_gid "gid_t gid" "int nogroup" -.Ft int -.Fn gid_from_group "const char *name" "gid_t *gid" -.Ft int -.Fn pwcache_groupdb "int (*setgroupent)(int)" "void (*endgrent)(void)" "struct group * (*getgrnam)(const char *)" "struct group * (*getgrgid)(gid_t)" -.Sh DESCRIPTION -The -.Fn user_from_uid -function returns the user name associated with the argument -.Fa uid . -The user name is cached so that multiple calls with the same -.Fa uid -do not require additional calls to -.Xr getpwuid 3 . -If there is no user associated with the -.Fa uid , -a pointer is returned -to a string representation of the -.Fa uid , -unless the argument -.Fa nouser -is non-zero, in which case a -.Dv NULL -pointer is returned. -.Pp -The -.Fn group_from_gid -function returns the group name associated with the argument -.Fa gid . -The group name is cached so that multiple calls with the same -.Fa gid -do not require additional calls to -.Xr getgrgid 3 . -If there is no group associated with the -.Fa gid , -a pointer is returned -to a string representation of the -.Fa gid , -unless the argument -.Fa nogroup -is non-zero, in which case a -.Dv NULL -pointer is returned. -.Pp -The -.Fn uid_from_user -function returns the uid associated with the argument -.Fa name . -The uid is cached so that multiple calls with the same -.Fa name -do not require additional calls to -.Xr getpwnam 3 . -If there is no uid associated with the -.Fa name , -the -.Fn uid_from_user -function returns \-1; otherwise it stores the uid at the location pointed to by -.Fa uid -and returns 0. -.Pp -The -.Fn gid_from_group -function returns the gid associated with the argument -.Fa name . -The gid is cached so that multiple calls with the same -.Fa name -do not require additional calls to -.Xr getgrnam 3 . -If there is no gid associated with the -.Fa name , -the -.Fn gid_from_group -function returns \-1; otherwise it stores the gid at the location pointed to by -.Fa gid -and returns 0. -.Pp -The -.Fn pwcache_userdb -function changes the user database access routines which -.Fn user_from_uid -and -.Fn uid_from_user -call to search for users. -The caches are flushed and the existing -.Fn endpwent -method is called before switching to the new routines. -.Fa getpwnam -and -.Fa getpwuid -must be provided, and -.Fa setpassent -and -.Fa endpwent -may be -.Dv NULL -pointers. -.Pp -The -.Fn pwcache_groupdb -function changes the group database access routines which -.Fn group_from_gid -and -.Fn gid_from_group -call to search for groups. -The caches are flushed and the existing -.Fn endgrent -method is called before switching to the new routines. -.Fa getgrnam -and -.Fa getgrgid -must be provided, and -.Fa setgroupent -and -.Fa endgrent -may be -.Dv NULL -pointers. -.Sh SEE ALSO -.Xr getgrgid 3 , -.Xr getgrnam 3 , -.Xr getpwnam 3 , -.Xr getpwuid 3 -.Sh HISTORY -The -.Fn user_from_uid -and -.Fn group_from_gid -functions first appeared in -.Bx 4.4 . -.Pp -The -.Fn uid_from_user -and -.Fn gid_from_group -functions first appeared in -.Nx 1.4 . -.Pp -The -.Fn pwcache_userdb -and -.Fn pwcache_groupdb -functions first appeared in -.Nx 1.6 . diff --git a/lib/libc/gen/pwcache.c b/lib/libc/gen/pwcache.c deleted file mode 100644 index 2caf96a51..000000000 --- a/lib/libc/gen/pwcache.c +++ /dev/null @@ -1,643 +0,0 @@ -/* $NetBSD: pwcache.c,v 1.31 2010/03/23 20:28:59 drochner Exp $ */ - -/*- - * Copyright (c) 1992 Keith Muller. - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Keith Muller of the University of California, San Diego. - * - * 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. - */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -/* - * XXX Undefine the renames of these functions so that we don't - * XXX rename the versions found in the host's by mistake! - */ -#undef group_from_gid -#undef user_from_uid -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)cache.c 8.1 (Berkeley) 5/31/93"; -#else -__RCSID("$NetBSD: pwcache.c,v 1.31 2010/03/23 20:28:59 drochner Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#if HAVE_NBTOOL_CONFIG_H -/* XXX Now, re-apply the renaming that we undid above. */ -#define group_from_gid __nbcompat_group_from_gid -#define user_from_uid __nbcompat_user_from_uid -#endif - -#ifdef __weak_alias -__weak_alias(user_from_uid,_user_from_uid) -__weak_alias(group_from_gid,_group_from_gid) -__weak_alias(pwcache_groupdb,_pwcache_groupdb) -#endif - -#if !HAVE_PWCACHE_USERDB || HAVE_NBTOOL_CONFIG_H -#include "pwcache.h" - -/* - * routines that control user, group, uid and gid caches (for the archive - * member print routine). - * IMPORTANT: - * these routines cache BOTH hits and misses, a major performance improvement - */ - -/* - * function pointers to various name lookup routines. - * these may be changed as necessary. - */ -static int (*_pwcache_setgroupent)(int) = setgroupent; -static void (*_pwcache_endgrent)(void) = endgrent; -static struct group * (*_pwcache_getgrnam)(const char *) = getgrnam; -static struct group * (*_pwcache_getgrgid)(gid_t) = getgrgid; -static int (*_pwcache_setpassent)(int) = setpassent; -static void (*_pwcache_endpwent)(void) = endpwent; -static struct passwd * (*_pwcache_getpwnam)(const char *) = getpwnam; -static struct passwd * (*_pwcache_getpwuid)(uid_t) = getpwuid; - -/* - * internal state - */ -static int pwopn; /* is password file open */ -static int gropn; /* is group file open */ -static UIDC **uidtb; /* uid to name cache */ -static GIDC **gidtb; /* gid to name cache */ -static UIDC **usrtb; /* user name to uid cache */ -static GIDC **grptb; /* group name to gid cache */ - -static int uidtb_fail; /* uidtb_start() failed ? */ -static int gidtb_fail; /* gidtb_start() failed ? */ -static int usrtb_fail; /* usrtb_start() failed ? */ -static int grptb_fail; /* grptb_start() failed ? */ - - -static u_int st_hash(const char *, size_t, int); -static int uidtb_start(void); -static int gidtb_start(void); -static int usrtb_start(void); -static int grptb_start(void); - - -static u_int -st_hash(const char *name, size_t len, int tabsz) -{ - u_int key = 0; - - _DIAGASSERT(name != NULL); - - while (len--) { - key += *name++; - key = (key << 8) | (key >> 24); - } - - return (key % tabsz); -} - -/* - * uidtb_start - * creates an an empty uidtb - * Return: - * 0 if ok, -1 otherwise - */ -static int -uidtb_start(void) -{ - - if (uidtb != NULL) - return (0); - if (uidtb_fail) - return (-1); - if ((uidtb = (UIDC **)calloc(UID_SZ, sizeof(UIDC *))) == NULL) { - ++uidtb_fail; - return (-1); - } - return (0); -} - -/* - * gidtb_start - * creates an an empty gidtb - * Return: - * 0 if ok, -1 otherwise - */ -static int -gidtb_start(void) -{ - - if (gidtb != NULL) - return (0); - if (gidtb_fail) - return (-1); - if ((gidtb = (GIDC **)calloc(GID_SZ, sizeof(GIDC *))) == NULL) { - ++gidtb_fail; - return (-1); - } - return (0); -} - -/* - * usrtb_start - * creates an an empty usrtb - * Return: - * 0 if ok, -1 otherwise - */ -static int -usrtb_start(void) -{ - - if (usrtb != NULL) - return (0); - if (usrtb_fail) - return (-1); - if ((usrtb = (UIDC **)calloc(UNM_SZ, sizeof(UIDC *))) == NULL) { - ++usrtb_fail; - return (-1); - } - return (0); -} - -/* - * grptb_start - * creates an an empty grptb - * Return: - * 0 if ok, -1 otherwise - */ -static int -grptb_start(void) -{ - - if (grptb != NULL) - return (0); - if (grptb_fail) - return (-1); - if ((grptb = (GIDC **)calloc(GNM_SZ, sizeof(GIDC *))) == NULL) { - ++grptb_fail; - return (-1); - } - return (0); -} - -/* - * user_from_uid() - * caches the name (if any) for the uid. If noname clear, we always - * return the stored name (if valid or invalid match). - * We use a simple hash table. - * Return - * Pointer to stored name (or a empty string) - */ -const char * -user_from_uid(uid_t uid, int noname) -{ - struct passwd *pw; - UIDC *ptr, **pptr; - - if ((uidtb == NULL) && (uidtb_start() < 0)) - return (NULL); - - /* - * see if we have this uid cached - */ - pptr = uidtb + (uid % UID_SZ); - ptr = *pptr; - - if ((ptr != NULL) && (ptr->valid > 0) && (ptr->uid == uid)) { - /* - * have an entry for this uid - */ - if (!noname || (ptr->valid == VALID)) - return (ptr->name); - return (NULL); - } - - /* - * No entry for this uid, we will add it - */ - if (!pwopn) { - if (_pwcache_setpassent != NULL) - (*_pwcache_setpassent)(1); - ++pwopn; - } - - if (ptr == NULL) - *pptr = ptr = (UIDC *)malloc(sizeof(UIDC)); - - if ((pw = (*_pwcache_getpwuid)(uid)) == NULL) { - /* - * no match for this uid in the local password file - * a string that is the uid in numeric format - */ - if (ptr == NULL) - return (NULL); - ptr->uid = uid; - (void)snprintf(ptr->name, UNMLEN, "%lu", (long) uid); - ptr->valid = INVALID; - if (noname) - return (NULL); - } else { - /* - * there is an entry for this uid in the password file - */ - if (ptr == NULL) - return (pw->pw_name); - ptr->uid = uid; - (void)strlcpy(ptr->name, pw->pw_name, UNMLEN); - ptr->valid = VALID; - } - return (ptr->name); -} - -/* - * group_from_gid() - * caches the name (if any) for the gid. If noname clear, we always - * return the stored name (if valid or invalid match). - * We use a simple hash table. - * Return - * Pointer to stored name (or a empty string) - */ -const char * -group_from_gid(gid_t gid, int noname) -{ - struct group *gr; - GIDC *ptr, **pptr; - - if ((gidtb == NULL) && (gidtb_start() < 0)) - return (NULL); - - /* - * see if we have this gid cached - */ - pptr = gidtb + (gid % GID_SZ); - ptr = *pptr; - - if ((ptr != NULL) && (ptr->valid > 0) && (ptr->gid == gid)) { - /* - * have an entry for this gid - */ - if (!noname || (ptr->valid == VALID)) - return (ptr->name); - return (NULL); - } - - /* - * No entry for this gid, we will add it - */ - if (!gropn) { - if (_pwcache_setgroupent != NULL) - (*_pwcache_setgroupent)(1); - ++gropn; - } - - if (ptr == NULL) - *pptr = ptr = (GIDC *)malloc(sizeof(GIDC)); - - if ((gr = (*_pwcache_getgrgid)(gid)) == NULL) { - /* - * no match for this gid in the local group file, put in - * a string that is the gid in numberic format - */ - if (ptr == NULL) - return (NULL); - ptr->gid = gid; - (void)snprintf(ptr->name, GNMLEN, "%lu", (long) gid); - ptr->valid = INVALID; - if (noname) - return (NULL); - } else { - /* - * there is an entry for this group in the group file - */ - if (ptr == NULL) - return (gr->gr_name); - ptr->gid = gid; - (void)strlcpy(ptr->name, gr->gr_name, GNMLEN); - ptr->valid = VALID; - } - return (ptr->name); -} - -/* - * uid_from_user() - * caches the uid for a given user name. We use a simple hash table. - * Return - * the uid (if any) for a user name, or a -1 if no match can be found - */ -int -uid_from_user(const char *name, uid_t *uid) -{ - struct passwd *pw; - UIDC *ptr, **pptr; - size_t namelen; - - /* - * return -1 for mangled names - */ - if (name == NULL || ((namelen = strlen(name)) == 0)) - return (-1); - if ((usrtb == NULL) && (usrtb_start() < 0)) - return (-1); - - /* - * look up in hash table, if found and valid return the uid, - * if found and invalid, return a -1 - */ - pptr = usrtb + st_hash(name, namelen, UNM_SZ); - ptr = *pptr; - - if ((ptr != NULL) && (ptr->valid > 0) && !strcmp(name, ptr->name)) { - if (ptr->valid == INVALID) - return (-1); - *uid = ptr->uid; - return (0); - } - - if (!pwopn) { - if (_pwcache_setpassent != NULL) - (*_pwcache_setpassent)(1); - ++pwopn; - } - - if (ptr == NULL) - *pptr = ptr = (UIDC *)malloc(sizeof(UIDC)); - - /* - * no match, look it up, if no match store it as an invalid entry, - * or store the matching uid - */ - if (ptr == NULL) { - if ((pw = (*_pwcache_getpwnam)(name)) == NULL) - return (-1); - *uid = pw->pw_uid; - return (0); - } - (void)strlcpy(ptr->name, name, UNMLEN); - if ((pw = (*_pwcache_getpwnam)(name)) == NULL) { - ptr->valid = INVALID; - return (-1); - } - ptr->valid = VALID; - *uid = ptr->uid = pw->pw_uid; - return (0); -} - -/* - * gid_from_group() - * caches the gid for a given group name. We use a simple hash table. - * Return - * the gid (if any) for a group name, or a -1 if no match can be found - */ -int -gid_from_group(const char *name, gid_t *gid) -{ - struct group *gr; - GIDC *ptr, **pptr; - size_t namelen; - - /* - * return -1 for mangled names - */ - if (name == NULL || ((namelen = strlen(name)) == 0)) - return (-1); - if ((grptb == NULL) && (grptb_start() < 0)) - return (-1); - - /* - * look up in hash table, if found and valid return the uid, - * if found and invalid, return a -1 - */ - pptr = grptb + st_hash(name, namelen, GID_SZ); - ptr = *pptr; - - if ((ptr != NULL) && (ptr->valid > 0) && !strcmp(name, ptr->name)) { - if (ptr->valid == INVALID) - return (-1); - *gid = ptr->gid; - return (0); - } - - if (!gropn) { - if (_pwcache_setgroupent != NULL) - (*_pwcache_setgroupent)(1); - ++gropn; - } - - if (ptr == NULL) - *pptr = ptr = (GIDC *)malloc(sizeof(GIDC)); - - /* - * no match, look it up, if no match store it as an invalid entry, - * or store the matching gid - */ - if (ptr == NULL) { - if ((gr = (*_pwcache_getgrnam)(name)) == NULL) - return (-1); - *gid = gr->gr_gid; - return (0); - } - - (void)strlcpy(ptr->name, name, GNMLEN); - if ((gr = (*_pwcache_getgrnam)(name)) == NULL) { - ptr->valid = INVALID; - return (-1); - } - ptr->valid = VALID; - *gid = ptr->gid = gr->gr_gid; - return (0); -} - -#define FLUSHTB(arr, len, fail) \ - do { \ - if (arr != NULL) { \ - for (i = 0; i < len; i++) \ - if (arr[i] != NULL) \ - free(arr[i]); \ - arr = NULL; \ - } \ - fail = 0; \ - } while (/* CONSTCOND */0); - -int -pwcache_userdb( - int (*a_setpassent)(int), - void (*a_endpwent)(void), - struct passwd * (*a_getpwnam)(const char *), - struct passwd * (*a_getpwuid)(uid_t)) -{ - int i; - - /* a_setpassent and a_endpwent may be NULL */ - if (a_getpwnam == NULL || a_getpwuid == NULL) - return (-1); - - if (_pwcache_endpwent != NULL) - (*_pwcache_endpwent)(); - FLUSHTB(uidtb, UID_SZ, uidtb_fail); - FLUSHTB(usrtb, UNM_SZ, usrtb_fail); - pwopn = 0; - _pwcache_setpassent = a_setpassent; - _pwcache_endpwent = a_endpwent; - _pwcache_getpwnam = a_getpwnam; - _pwcache_getpwuid = a_getpwuid; - - return (0); -} - -int -pwcache_groupdb( - int (*a_setgroupent)(int), - void (*a_endgrent)(void), - struct group * (*a_getgrnam)(const char *), - struct group * (*a_getgrgid)(gid_t)) -{ - int i; - - /* a_setgroupent and a_endgrent may be NULL */ - if (a_getgrnam == NULL || a_getgrgid == NULL) - return (-1); - - if (_pwcache_endgrent != NULL) - (*_pwcache_endgrent)(); - FLUSHTB(gidtb, GID_SZ, gidtb_fail); - FLUSHTB(grptb, GNM_SZ, grptb_fail); - gropn = 0; - _pwcache_setgroupent = a_setgroupent; - _pwcache_endgrent = a_endgrent; - _pwcache_getgrnam = a_getgrnam; - _pwcache_getgrgid = a_getgrgid; - - return (0); -} - - -#ifdef TEST_PWCACHE - -struct passwd * -test_getpwnam(const char *name) -{ - static struct passwd foo; - - memset(&foo, 0, sizeof(foo)); - if (strcmp(name, "toor") == 0) { - foo.pw_uid = 666; - return &foo; - } - return (getpwnam(name)); -} - -int -main(int argc, char *argv[]) -{ - uid_t u; - int r, i; - - printf("pass 1 (default userdb)\n"); - for (i = 1; i < argc; i++) { - printf("i: %d, pwopn %d usrtb_fail %d usrtb %p\n", - i, pwopn, usrtb_fail, usrtb); - r = uid_from_user(argv[i], &u); - if (r == -1) - printf(" uid_from_user %s: failed\n", argv[i]); - else - printf(" uid_from_user %s: %d\n", argv[i], u); - } - printf("pass 1 finish: pwopn %d usrtb_fail %d usrtb %p\n", - pwopn, usrtb_fail, usrtb); - - puts(""); - printf("pass 2 (replacement userdb)\n"); - printf("pwcache_userdb returned %d\n", - pwcache_userdb(setpassent, test_getpwnam, getpwuid)); - printf("pwopn %d usrtb_fail %d usrtb %p\n", pwopn, usrtb_fail, usrtb); - - for (i = 1; i < argc; i++) { - printf("i: %d, pwopn %d usrtb_fail %d usrtb %p\n", - i, pwopn, usrtb_fail, usrtb); - u = -1; - r = uid_from_user(argv[i], &u); - if (r == -1) - printf(" uid_from_user %s: failed\n", argv[i]); - else - printf(" uid_from_user %s: %d\n", argv[i], u); - } - printf("pass 2 finish: pwopn %d usrtb_fail %d usrtb %p\n", - pwopn, usrtb_fail, usrtb); - - puts(""); - printf("pass 3 (null pointers)\n"); - printf("pwcache_userdb returned %d\n", - pwcache_userdb(NULL, NULL, NULL)); - - return (0); -} -#endif /* TEST_PWCACHE */ -#endif /* !HAVE_PWCACHE_USERDB */ diff --git a/lib/libc/gen/pwcache.h b/lib/libc/gen/pwcache.h deleted file mode 100644 index 3bd651b60..000000000 --- a/lib/libc/gen/pwcache.h +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: pwcache.h,v 1.5 2003/11/10 08:51:51 wiz Exp $ */ - -/*- - * Copyright (c) 1992 Keith Muller. - * Copyright (c) 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Keith Muller of the University of California, San Diego. - * - * 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. - * - * @(#)cache.h 8.1 (Berkeley) 5/31/93 - */ - -/* - * Constants and data structures used to implement group and password file - * caches. Traditional passwd/group cache routines perform quite poorly with - * archives. The chances of hitting a valid lookup with an archive is quite a - * bit worse than with files already resident on the file system. These misses - * create a MAJOR performance cost. To address this problem, these routines - * cache both hits and misses. - * - * NOTE: name lengths must be as large as those stored in ANY PROTOCOL and - * as stored in the passwd and group files. CACHE SIZES MUST BE PRIME - */ -#define UNMLEN 32 /* >= user name found in any protocol */ -#define GNMLEN 32 /* >= group name found in any protocol */ -#define UID_SZ 317 /* size of uid to user_name cache */ -#define UNM_SZ 317 /* size of user_name to uid cache */ -#define GID_SZ 251 /* size of gid to group_name cache */ -#define GNM_SZ 251 /* size of group_name to gid cache */ -#define VALID 1 /* entry and name are valid */ -#define INVALID 2 /* entry valid, name NOT valid */ - -/* - * Node structures used in the user, group, uid, and gid caches. - */ - -typedef struct uidc { - int valid; /* is this a valid or a miss entry */ - char name[UNMLEN]; /* uid name */ - uid_t uid; /* cached uid */ -} UIDC; - -typedef struct gidc { - int valid; /* is this a valid or a miss entry */ - char name[GNMLEN]; /* gid name */ - gid_t gid; /* cached gid */ -} GIDC; diff --git a/lib/libc/gen/raise.3 b/lib/libc/gen/raise.3 deleted file mode 100644 index bbef77457..000000000 --- a/lib/libc/gen/raise.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" $NetBSD: raise.3,v 1.10 2011/05/09 09:06:21 jruoho Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)raise.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd May 9, 2011 -.Dt RAISE 3 -.Os -.Sh NAME -.Nm raise -.Nd send a signal to the current thread -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn raise "int sig" -.Sh DESCRIPTION -The -.Fn raise -function sends the signal -.Fa sig -to the current thread. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, a value of \-1 is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn raise -function -may fail and set -.Va errno -for any of the errors specified for the -library functions -.Xr _lwp_self 2 -and -.Xr _lwp_kill 2 . -.Sh SEE ALSO -.Xr kill 2 , -.Xr raise_default_signal 3 -.Sh STANDARDS -The -.Fn raise -function -conforms to -.St -ansiC -and -.St -susv2 . diff --git a/lib/libc/gen/raise.c b/lib/libc/gen/raise.c deleted file mode 100644 index 2c77d665c..000000000 --- a/lib/libc/gen/raise.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: raise.c,v 1.8 2009/01/29 23:52:21 rmind Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)raise.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: raise.c,v 1.8 2009/01/29 23:52:21 rmind Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -int -raise(int s) -{ - - return _lwp_kill(_lwp_self(), s); -} diff --git a/lib/libc/gen/randomid.3 b/lib/libc/gen/randomid.3 deleted file mode 100644 index dbb31cef6..000000000 --- a/lib/libc/gen/randomid.3 +++ /dev/null @@ -1,148 +0,0 @@ -.\" $NetBSD: randomid.3,v 1.7 2006/01/05 19:45:29 rpaulo Exp $ -.\" -.\" Copyright (C) 2006 The NetBSD Foundation -.\" All rights reserved. -.\" -.\" Copyright (C) 2003 WIDE Project. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the project 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 PROJECT 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 PROJECT OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd January 5, 2006 -.Dt RANDOMID 3 -.Os -.Sh NAME -.Nm randomid -.Nm randomid_new , -.Nm randomid_delete , -.Nd provide pseudo-random data stream without repetitions -.Sh SYNOPSIS -.In sys/types.h -.In randomid.h -.Ft uint32_t -.Fn randomid "randomid_t ctx" -.Ft randomid_t -.Fn randomid_new "int bits" "long timeo" -.Ft void -.Fn randomid_delete "randomid_t ctx" -.Sh DESCRIPTION -The -.Fn randomid -function provides pseudo-random data stream, -which is guaranteed not to generate the same number twice during -a certain duration. -.Fa ctx -is the context which holds internal state for the random number generator. -.Pp -To initialize a context, -.Fa randomid_new -is used. -.Fa bits -specifies the bitwidth of the value generated by -.Fn randomid . -Currently 32, 20, and 16 are supported. -.Fa timeo -specifies the reinitialization interval in seconds. -.Fa timeo -has to be bigger than -.Dv RANDOMID_TIMEO_MIN . -.Fa randomid_new -returns a dynamically-allocated memory region allocated by -.Xr malloc 3 . -.Pp -.Fn randomid_delete -will -.Xr free 3 -the internal state -.Fa ctx . -.Pp -The same number may appear after two reinitialization events of the internal state, -.Fa ctx . -Reinitialization happens when the random number generator cycle is exhausted, -or -.Fa timeo -seconds have passed since the last reinitialization. -For instance, -.Fa ctx -configured to generate 16 bit data stream will reinitialize its internal state -every 30000 calls to -.Fn randomid -.Po -or after -.Fa timeo -seconds -.Pc , -therefore the same data will not appear until after 30000 calls to -.Fn randomid -.Po -or after -.Fa timeo -seconds -.Pc . -.Pp -The internal state, -.Fa ctx , -determines the data stream generated by -.Fn randomid . -.Fa ctx -must be allocated per data stream -.Pq such as a specific data field . -It must not be shared among multiple data streams with different usage. -.\" -.Sh EXAMPLES -.Bd -literal -offset indent -#include \*[Lt]stdio.h\*[Gt] -#include \*[Lt]sys/types.h\*[Gt] -#include \*[Lt]randomid.h\*[Gt] - -uint32_t -genid(void) -{ - static randomid_t ctx = NULL; - - if (!ctx) - ctx = randomid_new(16, (long)3600); - return randomid(ctx); -} -.Ed -.\" -.Sh ERRORS -.Fn randomid_new -returns -.Dv NULL -on error and sets the external variable -.Va errno . -.\" -.Sh SEE ALSO -.Xr arc4random 3 -.\" -.Sh HISTORY -The pseudo-random data stream generator was designed by Niels Provos for -.Ox -IPv4 fragment ID generation. -.Fn randomid -is a generalized version of the generator, reworked by Jun-ichiro itojun Hagino, -and was introduced in -.Nx 2.0 . diff --git a/lib/libc/gen/randomid.c b/lib/libc/gen/randomid.c deleted file mode 100644 index 4eb9a3b32..000000000 --- a/lib/libc/gen/randomid.c +++ /dev/null @@ -1,324 +0,0 @@ -/* $NetBSD: randomid.c,v 1.13 2009/01/11 02:46:27 christos Exp $ */ -/* $KAME: ip6_id.c,v 1.8 2003/09/06 13:41:06 itojun Exp $ */ -/* $OpenBSD: ip_id.c,v 1.6 2002/03/15 18:19:52 millert Exp $ */ - -/* - * Copyright (C) 2003 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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. - */ - -/* - * Copyright 1998 Niels Provos - * All rights reserved. - * - * Theo de Raadt came up with the idea of using - * such a mathematical system to generate more random (yet non-repeating) - * ids to solve the resolver/named problem. But Niels designed the - * actual system based on the constraints. - * - * 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 ``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. - */ - -/* - * seed = random (bits - 1) bit - * n = prime, g0 = generator to n, - * j = random so that gcd(j,n-1) == 1 - * g = g0^j mod n will be a generator again. - * - * X[0] = random seed. - * X[n] = a*X[n-1]+b mod m is a Linear Congruential Generator - * with a = 7^(even random) mod m, - * b = random with gcd(b,m) == 1 - * m = constant and a maximal period of m-1. - * - * The transaction id is determined by: - * id[n] = seed xor (g^X[n] mod n) - * - * Effectivly the id is restricted to the lower (bits - 1) bits, thus - * yielding two different cycles by toggling the msb on and off. - * This avoids reuse issues caused by reseeding. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: randomid.c,v 1.13 2009/01/11 02:46:27 christos Exp $"); -#endif - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(randomid,_randomid) -__weak_alias(randomid_new,_randomid_new) -__weak_alias(randomid_delete,_randomid_delete) -#endif - -struct randomconf { - const int rc_bits; /* resulting bits */ - const u_int32_t rc_max; /* Uniq cycle, avoid blackjack prediction */ - const u_int32_t rc_gen; /* Starting generator */ - const u_int32_t rc_n; /* ru_n: prime, ru_n - 1: product of pfacts[] */ - const u_int32_t rc_agen; /* determine ru_a as ru_agen^(2*rand) */ - const u_int32_t rc_m; /* ru_m = 2^x*3^y */ - const u_int32_t rc_pfacts[4]; /* factors of ru_n */ - const int rc_skip; /* skip values */ -}; - -struct randomid_ctx { - struct randomconf *ru_conf; -#define ru_bits ru_conf->rc_bits -#define ru_max ru_conf->rc_max -#define ru_gen ru_conf->rc_gen -#define ru_n ru_conf->rc_n -#define ru_agen ru_conf->rc_agen -#define ru_m ru_conf->rc_m -#define ru_pfacts ru_conf->rc_pfacts -#define ru_skip ru_conf->rc_skip - long ru_out; /* Time after wich will be reseeded */ - u_int32_t ru_counter; - u_int32_t ru_msb; - - u_int32_t ru_x; - u_int32_t ru_seed, ru_seed2; - u_int32_t ru_a, ru_b; - u_int32_t ru_g; - time_t ru_reseed; -}; - -static struct randomconf randomconf[] = { - { - 32, /* resulting bits */ - 1000000000, /* Uniq cycle, avoid blackjack prediction */ - 2, /* Starting generator */ - 2147483629, /* RU_N-1 = 2^2*3^2*59652323 */ - 7, /* determine ru_a as RU_AGEN^(2*rand) */ - 1836660096, /* RU_M = 2^7*3^15 - don't change */ - { 2, 3, 59652323, 0 }, /* factors of ru_n */ - 3, /* skip values */ - }, - { - 20, /* resulting bits */ - 200000, /* Uniq cycle, avoid blackjack prediction */ - 2, /* Starting generator */ - 524269, /* RU_N-1 = 2^2*3^2*14563 */ - 7, /* determine ru_a as RU_AGEN^(2*rand) */ - 279936, /* RU_M = 2^7*3^7 - don't change */ - { 2, 3, 14563, 0 }, /* factors of ru_n */ - 3, /* skip values */ - }, - { - 16, /* resulting bits */ - 30000, /* Uniq cycle, avoid blackjack prediction */ - 2, /* Starting generator */ - 32749, /* RU_N-1 = 2^2*3*2729 */ - 7, /* determine ru_a as RU_AGEN^(2*rand) */ - 31104, /* RU_M = 2^7*3^5 - don't change */ - { 2, 3, 2729, 0 }, /* factors of ru_n */ - 0, /* skip values */ - }, - { - .rc_bits = -1, /* termination */ - }, -}; - -static u_int32_t pmod(u_int32_t, u_int32_t, u_int32_t); -static void initid(struct randomid_ctx *); - -struct randomid_ctx *randomid_new(int, long); -void randomid_delete(struct randomid_ctx *); -u_int32_t randomid(struct randomid_ctx *); - -/* - * Do a fast modular exponation, returned value will be in the range - * of 0 - (mod-1) - */ - -static u_int32_t -pmod(u_int32_t gen, u_int32_t expo, u_int32_t mod) -{ - u_int64_t s, t, u; - - s = 1; - t = gen; - u = expo; - - while (u) { - if (u & 1) - s = (s * t) % mod; - u >>= 1; - t = (t * t) % mod; - } - return ((u_int32_t)s & UINT32_MAX); -} - -/* - * Initalizes the seed and chooses a suitable generator. Also toggles - * the msb flag. The msb flag is used to generate two distinct - * cycles of random numbers and thus avoiding reuse of ids. - * - * This function is called from id_randomid() when needed, an - * application does not have to worry about it. - */ -static void -initid(struct randomid_ctx *p) -{ - u_int32_t j, i; - int noprime = 1; - struct timeval tv; - - p->ru_x = arc4random() % p->ru_m; - - /* (bits - 1) bits of random seed */ - p->ru_seed = arc4random() & (~0U >> (32 - p->ru_bits + 1)); - p->ru_seed2 = arc4random() & (~0U >> (32 - p->ru_bits + 1)); - - /* Determine the LCG we use */ - p->ru_b = (arc4random() & (~0U >> (32 - p->ru_bits))) | 1; - p->ru_a = pmod(p->ru_agen, - (arc4random() & (~0U >> (32 - p->ru_bits))) & (~1U), p->ru_m); - while (p->ru_b % 3 == 0) - p->ru_b += 2; - - j = arc4random() % p->ru_n; - - /* - * Do a fast gcd(j, RU_N - 1), so we can find a j with - * gcd(j, RU_N - 1) == 1, giving a new generator for - * RU_GEN^j mod RU_N - */ - while (noprime) { - for (i = 0; p->ru_pfacts[i] > 0; i++) - if (j % p->ru_pfacts[i] == 0) - break; - - if (p->ru_pfacts[i] == 0) - noprime = 0; - else - j = (j + 1) % p->ru_n; - } - - p->ru_g = pmod(p->ru_gen, j, p->ru_n); - p->ru_counter = 0; - - gettimeofday(&tv, NULL); - p->ru_reseed = tv.tv_sec + p->ru_out; - p->ru_msb = p->ru_msb ? 0 : (1U << (p->ru_bits - 1)); -} - -struct randomid_ctx * -randomid_new(int bits, long timeo) -{ - struct randomconf *conf; - struct randomid_ctx *ctx; - - if (timeo < RANDOMID_TIMEO_MIN) { - errno = EINVAL; - return (NULL); - } - - for (conf = randomconf; conf->rc_bits > 0; conf++) { - if (bits == conf->rc_bits) - break; - } - - /* unsupported bits */ - if (bits != conf->rc_bits) { - errno = ENOTSUP; - return (NULL); - } - - ctx = malloc(sizeof(*ctx)); - if (!ctx) - return (NULL); - - memset(ctx, 0, sizeof(*ctx)); - ctx->ru_conf = conf; - ctx->ru_out = timeo; - - return (ctx); -} - -void -randomid_delete(struct randomid_ctx *ctx) -{ - - memset(ctx, 0, sizeof(*ctx)); - free(ctx); -} - -u_int32_t -randomid(struct randomid_ctx *p) -{ - int i, n; - struct timeval tv; - - gettimeofday(&tv, NULL); - if (p->ru_counter >= p->ru_max || tv.tv_sec > p->ru_reseed) - initid(p); - - /* Skip a random number of ids */ - if (p->ru_skip) { - n = arc4random() & p->ru_skip; - if (p->ru_counter + n >= p->ru_max) - initid(p); - } else - n = 0; - - for (i = 0; i <= n; i++) { - /* Linear Congruential Generator */ - p->ru_x = (u_int32_t)(((u_int64_t)p->ru_a * p->ru_x + p->ru_b) % p->ru_m); - } - - p->ru_counter += i; - - return (p->ru_seed ^ pmod(p->ru_g, p->ru_seed2 + p->ru_x, p->ru_n)) | - p->ru_msb; -} diff --git a/lib/libc/gen/readdir.c b/lib/libc/gen/readdir.c deleted file mode 100644 index e834621e2..000000000 --- a/lib/libc/gen/readdir.c +++ /dev/null @@ -1,141 +0,0 @@ -/* $NetBSD: readdir.c,v 1.26 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)readdir.c 8.3 (Berkeley) 9/29/94"; -#else -__RCSID("$NetBSD: readdir.c,v 1.26 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include "extern.h" -#include - -#include -#include -#include -#include - -#include "dirent_private.h" - -/* - * get next entry in a directory. - */ -struct dirent * -_readdir_unlocked(DIR *dirp, int skipdeleted) -{ - struct dirent *dp; - - for (;;) { - if (dirp->dd_loc >= dirp->dd_size) { - if (dirp->dd_flags & __DTF_READALL) - return (NULL); - dirp->dd_loc = 0; - } - if (dirp->dd_loc == 0 && !(dirp->dd_flags & __DTF_READALL)) { - dirp->dd_seek = lseek(dirp->dd_fd, (off_t)0, SEEK_CUR); - dirp->dd_size = getdents(dirp->dd_fd, - dirp->dd_buf, (size_t)dirp->dd_len); - if (dirp->dd_size <= 0) - return (NULL); - } - dp = (struct dirent *) - (void *)(dirp->dd_buf + (size_t)dirp->dd_loc); - if ((intptr_t)dp & _DIRENT_ALIGN(dp))/* bogus pointer check */ - return (NULL); - /* d_reclen is unsigned; no need to compare it <= 0 */ - if (dp->d_reclen > dirp->dd_len + 1 - dirp->dd_loc) - return (NULL); - dirp->dd_loc += dp->d_reclen; - if (dp->d_ino == 0 && skipdeleted) - continue; -#if !defined(__minix) - if (dp->d_type == DT_WHT && (dirp->dd_flags & DTF_HIDEW)) - continue; -#endif /* !defined(__minix) */ - return (dp); - } -} - -struct dirent * -readdir(DIR *dirp) -{ - struct dirent *dp; - -#ifdef _REENTRANT - if (__isthreaded) { - mutex_lock((mutex_t *)dirp->dd_lock); - dp = _readdir_unlocked(dirp, 1); - mutex_unlock((mutex_t *)dirp->dd_lock); - } - else -#endif - dp = _readdir_unlocked(dirp, 1); - return (dp); -} - -int -readdir_r(DIR *dirp, struct dirent *entry, struct dirent **result) -{ - struct dirent *dp; - int saved_errno; - - saved_errno = errno; - errno = 0; -#ifdef _REENTRANT - if (__isthreaded) { - mutex_lock((mutex_t *)dirp->dd_lock); - if ((dp = _readdir_unlocked(dirp, 1)) != NULL) - memcpy(entry, dp, (size_t)_DIRENT_SIZE(dp)); - mutex_unlock((mutex_t *)dirp->dd_lock); - } - else -#endif - if ((dp = _readdir_unlocked(dirp, 1)) != NULL) - memcpy(entry, dp, (size_t)_DIRENT_SIZE(dp)); - - if (errno != 0) { - if (dp == NULL) - return (errno); - } else - errno = saved_errno; - - if (dp != NULL) - *result = entry; - else - *result = NULL; - - return (0); -} diff --git a/lib/libc/gen/realpath.3 b/lib/libc/gen/realpath.3 deleted file mode 100644 index 335cafb91..000000000 --- a/lib/libc/gen/realpath.3 +++ /dev/null @@ -1,163 +0,0 @@ -.\" $NetBSD: realpath.3,v 1.18 2013/05/24 09:35:11 wiz Exp $ -.\" -.\" Copyright (c) 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Jan-Simon Pendry. -.\" -.\" 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. -.\" -.\" from: @(#)realpath.3 8.2 (Berkeley) 2/16/94 -.\" -.Dd May 24, 2013 -.Dt REALPATH 3 -.Os -.Sh NAME -.Nm realpath -.Nd returns the canonicalized absolute pathname -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/param.h -.In stdlib.h -.Ft "char *" -.Fn realpath "const char * restrict pathname" "char * restrict resolvedname" -.Sh DESCRIPTION -The -.Fn realpath -function resolves all symbolic links, extra -.Dq / -characters and references to -.Pa /./ -and -.Pa /../ -in -.Fa pathname , -and copies the resulting absolute pathname into -the memory referenced by -.Fa resolvedname . -The -.Fa resolvedname -argument -.Em must -refer to a buffer capable of storing at least -.Dv MAXPATHLEN -characters, or be -.Dv NULL . -.Pp -The -.Fn realpath -function will resolve both absolute and relative paths -and return the absolute pathname corresponding to -.Fa pathname . -.Sh RETURN VALUES -If -.Fa resolvedname -is -.Dv NULL , -it will be allocated and the returned pointer can be deallocated using -.Xr free 3 . -The -.Fn realpath -function returns -.Fa resolvedname -on success. -If an error occurs, -.Fn realpath -returns -.Dv NULL , -and -.Fa resolvedname -was not allocated by -.Fn realpath , -it will contain the pathname which caused the problem. -.Sh ERRORS -The function -.Fn realpath -may fail and set the external variable -.Va errno -for any of the errors specified for the library functions -.\" First sorted by section, then by name. -.Xr lstat 2 , -.Xr readlink 2 , -.Xr getcwd 3 -and -.Xr malloc 3 . -.Pp -In addition, the following errors may be reported: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of the -.Fa pathname -argument is -.Dv NULL . -.It Bq Er ELOOP -Too many symbolic links were encountered in translating the -.Fa pathname . -.It Bq Er ENAMETOOLONG -The resulting absolute pathname exceeds -.Dv MAXPATHLEN -characters. -.It Bq Er ENOENT -The value of the -.Fa pathname -argument is an empty string; -or a symbolic link to an empty string is encountered. -.It Bq Er ENOTDIR -A component of the path prefix is not a directory. -.El -.Sh SEE ALSO -.Xr getcwd 3 -.Sh STANDARDS -.Fn realpath -first appeared in -.St -xpg4.2 -and is part of -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn realpath -function call first appeared in -.Bx 4.4 . -In -.Nx 7.0 -the function was updated to accept a -.Dv NULL -pointer for the -.Fa resolvedname -argument. -.Sh BUGS -This implementation of -.Fn realpath -differs slightly from the Solaris implementation. -The -.Bx 4.4 -version always returns absolute pathnames, -whereas the Solaris implementation will, -under certain circumstances, return a relative -.Fa resolvedname -when given a relative -.Fa pathname . diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c deleted file mode 100644 index a16685247..000000000 --- a/lib/libc/gen/rewinddir.c +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: rewinddir.c,v 1.13 2010/09/26 02:26:59 yamt Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)rewinddir.c 8.1 (Berkeley) 6/8/93"; -#else -__RCSID("$NetBSD: rewinddir.c,v 1.13 2010/09/26 02:26:59 yamt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include "extern.h" -#include - -#include -#include - -#include "dirent_private.h" - -#ifdef __weak_alias -__weak_alias(rewinddir,_rewinddir) -#endif - -void -rewinddir(DIR *dirp) -{ - int fd; - -#ifdef _REENTRANT - if (__isthreaded) { - mutex_lock((mutex_t *)dirp->dd_lock); - } -#endif - fd = dirp->dd_fd; - _finidir(dirp); - dirp->dd_seek = lseek(fd, (off_t)0, SEEK_SET); - _initdir(dirp, fd, NULL); -#ifdef _REENTRANT - if (__isthreaded) { - mutex_unlock((mutex_t *)dirp->dd_lock); - } -#endif -} diff --git a/lib/libc/gen/scandir.3 b/lib/libc/gen/scandir.3 deleted file mode 100644 index 01d88b2c9..000000000 --- a/lib/libc/gen/scandir.3 +++ /dev/null @@ -1,113 +0,0 @@ -.\" $NetBSD: scandir.3,v 1.14 2010/12/17 19:20:42 njoly Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)scandir.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 29, 2010 -.Dt SCANDIR 3 -.Os -.Sh NAME -.Nm scandir , -.Nm alphasort -.Nd scan a directory -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In dirent.h -.Ft int -.Fn scandir "const char *dirname" "struct dirent ***namelist" "int \*(lp*select\*(rp\*(lpconst struct dirent *\*(rp" "int \*(lp*compar\*(rp\*(lpconst void *, const void *\*(rp" -.Ft int -.Fn alphasort "const void *d1" "const void *d2" -.Sh DESCRIPTION -The -.Fn scandir -function -reads the directory -.Fa dirname -and builds an array of pointers to directory -entries using -.Xr malloc 3 . -It returns the number of entries in the array. -A pointer to the array of directory entries is stored in the location -referenced by -.Fa namelist . -.Pp -The -.Fa select -parameter is a pointer to a user supplied subroutine which is called by -.Fn scandir -to select which entries are to be included in the array. -The select routine is passed a -pointer to a directory entry and should return a non-zero -value if the directory entry is to be included in the array. -If -.Fa select -is null, then all the directory entries will be included. -.Pp -The -.Fa compar -parameter is a pointer to a user supplied subroutine which is passed to -.Xr qsort 3 -to sort the completed array. -If this pointer is null, the array is not sorted. -.Pp -The -.Fn alphasort -function -is a routine which can be used for the -.Fa compar -parameter to sort the array alphabetically. -.Pp -The memory allocated for the array can be deallocated with -.Xr free 3 , -by freeing each pointer in the array and then the array itself. -.Sh DIAGNOSTICS -Returns \-1 if the directory cannot be opened for reading or if -.Xr malloc 3 -cannot allocate enough memory to hold all the data structures. -.Sh SEE ALSO -.Xr directory 3 , -.Xr dirent 3 , -.Xr malloc 3 , -.Xr qsort 3 -.Sh STANDARDS -The -.Fn scandir -and -.Fn alphasort -functions conform to -.St -p1003.1-2008 . -.Sh HISTORY -The -.Fn scandir -and -.Fn alphasort -functions appeared in -.Bx 4.2 . diff --git a/lib/libc/gen/scandir.c b/lib/libc/gen/scandir.c deleted file mode 100644 index ed3aac8d8..000000000 --- a/lib/libc/gen/scandir.c +++ /dev/null @@ -1,152 +0,0 @@ -/* $NetBSD: scandir.c,v 1.27 2012/03/13 21:13:36 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)scandir.c 8.3 (Berkeley) 1/2/94"; -#else -__RCSID("$NetBSD: scandir.c,v 1.27 2012/03/13 21:13:36 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * Scan the directory dirname calling selectfn to make a list of selected - * directory entries then sort using qsort and compare routine dcomp. - * Returns the number of entries and a pointer to a list of pointers to - * struct dirent (through namelist). Returns -1 if there were any errors. - */ - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include - -/* - * Compute an estimate of the number of entries in a directory based on - * the file size. Returns the estimated number of entries or 0 on failure. - */ -static size_t -dirsize(int fd, size_t olen) -{ - struct stat stb; - size_t nlen; - - if (fstat(fd, &stb) == -1) - return 0; - /* - * Estimate the array size by taking the size of the directory file - * and dividing it by a multiple of the minimum size entry. - */ - nlen = (size_t)(stb.st_size / _DIRENT_MINSIZE((struct dirent *)0)); - /* - * If the size turns up 0, switch to an alternate strategy and use the - * file size as the number of entries like ZFS returns. If that turns - * out to be 0 too return a minimum of 10 entries, plus the old length. - */ - if (nlen == 0) - nlen = (size_t)(stb.st_size ? stb.st_size : 10); - return olen + nlen; -} - -int -scandir(const char *dirname, struct dirent ***namelist, - int (*selectfn)(const struct dirent *), - int (*dcomp)(const void *, const void *)) -{ - struct dirent *d, *p, **names, **newnames; - size_t nitems, arraysz; - DIR *dirp; - - _DIAGASSERT(dirname != NULL); - _DIAGASSERT(namelist != NULL); - - if ((dirp = opendir(dirname)) == NULL) - return -1; - - if ((arraysz = dirsize(dirp->dd_fd, 0)) == 0) - goto bad; - - names = malloc(arraysz * sizeof(*names)); - if (names == NULL) - goto bad; - - nitems = 0; - while ((d = readdir(dirp)) != NULL) { - if (selectfn != NULL && !(*selectfn)(d)) - continue; /* just selected names */ - - /* - * Check to make sure the array has space left and - * realloc the maximum size. - */ - if (nitems >= arraysz) { - if ((arraysz = dirsize(dirp->dd_fd, arraysz)) == 0) - goto bad2; - newnames = realloc(names, arraysz * sizeof(*names)); - if (newnames == NULL) - goto bad2; - names = newnames; - } - - /* - * Make a minimum size copy of the data - */ - p = malloc((size_t)_DIRENT_SIZE(d)); - if (p == NULL) - goto bad2; - p->d_fileno = d->d_fileno; - p->d_reclen = d->d_reclen; - p->d_type = d->d_type; - p->d_namlen = d->d_namlen; - (void)memmove(p->d_name, d->d_name, (size_t)(p->d_namlen + 1)); - names[nitems++] = p; - } - (void)closedir(dirp); - if (nitems && dcomp != NULL) - qsort(names, nitems, sizeof(*names), dcomp); - *namelist = names; - _DIAGASSERT(__type_fit(int, nitems)); - return (int)nitems; - -bad2: - while (nitems-- > 0) - free(names[nitems]); - free(names); -bad: - (void)closedir(dirp); - return -1; -} diff --git a/lib/libc/gen/seekdir.c b/lib/libc/gen/seekdir.c deleted file mode 100644 index 1c78fb0d9..000000000 --- a/lib/libc/gen/seekdir.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: seekdir.c,v 1.15 2013/03/06 11:27:46 yamt Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)seekdir.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: seekdir.c,v 1.15 2013/03/06 11:27:46 yamt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include "extern.h" -#include - -#include - -#include "dirent_private.h" - -#ifdef __weak_alias -__weak_alias(seekdir,_seekdir) -#endif - -/* - * Seek to an entry in a directory. - * _seekdir_unlocked is in telldir.c so that it can share opaque - * data structures. - */ -void -seekdir(DIR *dirp, long loc) -{ - -#ifdef _REENTRANT - if (__isthreaded) { - mutex_lock((mutex_t *)dirp->dd_lock); - _seekdir_unlocked(dirp, loc); - mutex_unlock((mutex_t *)dirp->dd_lock); - } else -#endif - _seekdir_unlocked(dirp, loc); -} diff --git a/lib/libc/gen/setdomainname.c b/lib/libc/gen/setdomainname.c deleted file mode 100644 index b392c1fc2..000000000 --- a/lib/libc/gen/setdomainname.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: setdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: setdomainname.c,v 1.13 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(setdomainname,_setdomainname) -#endif - -int -setdomainname(const char *name, size_t namelen) -{ - int mib[2]; - - _DIAGASSERT(name != NULL); - - mib[0] = CTL_KERN; - mib[1] = KERN_DOMAINNAME; - if (sysctl(mib, 2, NULL, NULL, name, namelen) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/gen/sethostname.c b/lib/libc/gen/sethostname.c deleted file mode 100644 index 4da934ae4..000000000 --- a/lib/libc/gen/sethostname.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: sethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sethostname.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: sethostname.c,v 1.13 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(sethostname,_sethostname) -#endif - -int -sethostname(const char *name, size_t namelen) -{ - int mib[2]; - - _DIAGASSERT(name != NULL); - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - if (sysctl(mib, 2, NULL, NULL, name, namelen) == -1) - return (-1); - return (0); -} diff --git a/lib/libc/gen/setjmp.3 b/lib/libc/gen/setjmp.3 deleted file mode 100644 index 2c4b38961..000000000 --- a/lib/libc/gen/setjmp.3 +++ /dev/null @@ -1,229 +0,0 @@ -.\" $NetBSD: setjmp.3,v 1.17 2008/05/31 16:15:07 enami Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)setjmp.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 1, 2008 -.Dt SETJMP 3 -.Os -.Sh NAME -.Nm sigsetjmp , -.Nm siglongjmp , -.Nm setjmp , -.Nm longjmp , -.Nm _setjmp , -.Nm _longjmp , -.Nm longjmperror -.Nd non-local jumps -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In setjmp.h -.Ft int -.Fn sigsetjmp "sigjmp_buf env" "int savemask" -.Ft void -.Fn siglongjmp "sigjmp_buf env" "int val" -.Ft int -.Fn setjmp "jmp_buf env" -.Ft void -.Fn longjmp "jmp_buf env" "int val" -.Ft int -.Fn _setjmp "jmp_buf env" -.Ft void -.Fn _longjmp "jmp_buf env" "int val" -.Ft void -.Fn longjmperror void -.Sh DESCRIPTION -The -.Fn sigsetjmp , -.Fn setjmp , -and -.Fn _setjmp -functions save their calling environment in -.Fa env . -Each of these functions returns 0. -.Pp -The corresponding -.Fn longjmp -functions restore the environment saved by the most recent -invocation of the respective -.Fn setjmp -function. -They then return so that program execution continues as if the corresponding -invocation of the -.Fn setjmp -call had just returned the value specified by -.Fa val , -instead of 0. -.Pp -Pairs of calls may be intermixed, i.e., both -.Fn sigsetjmp -and -.Fn siglongjmp -as well as -.Fn setjmp -and -.Fn longjmp -combinations may be used in the same program. -However, individual calls may not, e.g., the -.Fa env -argument to -.Fn setjmp -may not be passed to -.Fn siglongjmp . -.Pp -The -.Fn longjmp -routines may not be called after the routine which called the -.Fn setjmp -routines returns. -.Pp -All accessible objects have values as of the time -.Fn longjmp -routine was called, except that the values of objects of automatic storage -invocation duration that do not have the -.Li volatile -type and have been changed between the -.Fn setjmp -invocation and -.Fn longjmp -call are indeterminate. -.Pp -The -.Fn setjmp Ns / Ns Fn longjmp -function pairs save and restore the signal mask while -.Fn _setjmp Ns / Ns Fn _longjmp -function pairs save and restore only the register set and the stack. -(See -.Fn sigprocmask 2 . ) -.Pp -The -.Fn sigsetjmp Ns / Ns Fn siglongjmp -function pairs save and restore the signal mask if the argument -.Fa savemask -is non-zero. -Otherwise, only the register set and the stack are saved. -.Pp -In other words, -.Fn setjmp Ns / Ns Fn longjmp -are functionally equivalent to -.Fn sigsetjmp Ns / Ns Fn siglongjmp -when -.Fn sigsetjmp -is called with a non-zero -.Fa savemask -argument. -Conversely, -.Fn _setjmp Ns / Ns Fn _longjmp -are functionally equivalent to -.Fn sigsetjmp Ns / Ns Fn siglongjmp -when -.Fn sigsetjmp -is called with a zero-value -.Fa savemask . -.Pp -The -.Fn sigsetjmp Ns / Ns Fn siglongjmp -interfaces are preferred for maximum portability. -.Sh ERRORS -If the contents of the -.Fa env -are corrupted or correspond to an environment that has already returned, -the -.Fn longjmp -routine calls the routine -.Xr longjmperror 3 . -If -.Fn longjmperror -returns, the program is aborted (see -.Xr abort 3 ) . -The default version of -.Fn longjmperror -prints the message -.Dq Li longjmp botch -to standard error and returns. -User programs wishing to exit more gracefully should write their own -versions of -.Fn longjmperror . -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr sigaltstack 2 , -.Xr sigprocmask 2 , -.Xr pthread_sigmask 3 , -.Xr signal 3 -.Sh STANDARDS -The -.Fn setjmp -and -.Fn longjmp -functions conform to -.St -ansiC . -The -.Fn sigsetjmp -and -.Fn siglongjmp -functions conform to -.St -p1003.1-90 . -.Sh CAVEATS -Historically, on -.At V , -the -.Fn setjmp Ns / Ns Fn longjmp -functions have been equivalent to the -.Bx -.Fn _setjmp Ns / Ns Fn _longjmp -functions and do not restore the signal mask. -Because of this discrepancy, the -.Fn sigsetjmp Ns / Ns Fn siglongjmp -interfaces should be used if portability is desired. -.Pp -Use of -.Fn longjmp -or -.Fn siglongjmp -from inside a signal handler is not as easy as it might seem. -Generally speaking, all possible code paths between the -.Fn setjmp -and -.Fn longjmp -must be signal race safe. -Furthermore, the code paths must not do resource management -(such as -.Xr open 2 -or -.Xr close 2 ) -without blocking the signal in question, or resources might -be mismanaged. -Obviously this makes -.Fn longjmp -much less useful than previously thought. diff --git a/lib/libc/gen/setjmperr.c b/lib/libc/gen/setjmperr.c deleted file mode 100644 index 5b1432e15..000000000 --- a/lib/libc/gen/setjmperr.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $ */ - -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)setjmperr.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: setjmperr.c,v 1.8 2012/06/24 15:26:03 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * This routine is called from longjmp() when an error occurs. - * Programs that wish to exit gracefully from this error may - * write their own versions. - * If this routine returns, the program is aborted. - */ - -#include -#include - -void -longjmperror(void) -{ -#define ERRMSG "longjmp botch.\n" - (void)write(STDERR_FILENO, ERRMSG, sizeof(ERRMSG) - 1); -} diff --git a/lib/libc/gen/setmode.3 b/lib/libc/gen/setmode.3 deleted file mode 100644 index 9c131d25e..000000000 --- a/lib/libc/gen/setmode.3 +++ /dev/null @@ -1,150 +0,0 @@ -.\" $NetBSD: setmode.3,v 1.21 2009/01/11 02:46:27 christos Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)setmode.3 8.2 (Berkeley) 4/28/95 -.\" -.Dd January 4, 2009 -.Dt SETMODE 3 -.Os -.Sh NAME -.Nm getmode , -.Nm setmode -.Nd modify mode bits -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft void * -.Fn setmode "const char *mode_str" -.Ft mode_t -.Fn getmode "const void *set" "mode_t mode" -.Sh DESCRIPTION -The -.Fn setmode -function accepts a string representation of a file mode change, -compiles it to binary form, and returns an abstract representation -that may be passed to -.Fn getmode . -The string may be an numeric (octal) or symbolic string of the form -accepted by -.Xr chmod 1 , -and may represent either an exact mode to set or a change to make to -the existing mode. -.Pp -The -.Fn getmode -function -adjusts the file permission bits given by -.Fa mode -according to the compiled change representation -.Fa set , -and returns the adjusted mode. -While only the permission bits are altered, other parts of the file -mode, particularly the type, may be examined. -.Pp -Because some of the possible symbolic values are defined relative to -the file creation mask, -.Fn setmode -may call -.Xr umask 2 , -temporarily changing the mask. -If this occurs, the file creation mask will be restored before -.Fn setmode -returns. -If the calling program changes the value of its file creation mask -after calling -.Fn setmode , -.Fn setmode -must be called again to recompile the mode string if -.Fn getmode -is to modify future file modes correctly. -.Pp -If the mode passed to -.Fn setmode -is invalid, -.Fn setmode -returns -.Dv NULL . -.Sh EXAMPLES -The effects of the shell command -.Ql "chmod a+x myscript.sh" -can be duplicated as follows: -.Bd -literal -offset indent -const char *file = "myscript.sh"; -struct stat st; -mode_t newmode; - -stat(file, \*[Am]st); -newmode = getmode(setmode("a+x"), st.st_mode); -chmod(file, newmode); -.Ed -.Sh ERRORS -The -.Fn setmode -function -may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr malloc 3 -or -.Xr strtol 3 . -In addition, -.Fn setmode -will fail and set -.Va errno -to: -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa mode -argument does not represent a valid mode. -.El -.Sh SEE ALSO -.Xr chmod 1 , -.Xr stat 2 , -.Xr umask 2 , -.Xr malloc 3 -.Sh HISTORY -The -.Fn getmode -and -.Fn setmode -functions first appeared in -.Bx 4.4 . -.Sh BUGS -Each call to -.Nm setmode -allocates a small amount of memory that there is no correct way to -free. -.Pp -The type of -.Fa set -should really be some opaque struct type used only by these functions -rather than -.Ft void * . diff --git a/lib/libc/gen/setmode.c b/lib/libc/gen/setmode.c deleted file mode 100644 index a2ea01d4c..000000000 --- a/lib/libc/gen/setmode.c +++ /dev/null @@ -1,485 +0,0 @@ -/* $NetBSD: setmode.c,v 1.34 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1989, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Dave Borman at Cray Research, Inc. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)setmode.c 8.2 (Berkeley) 3/25/94"; -#else -__RCSID("$NetBSD: setmode.c,v 1.34 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef SETMODE_DEBUG -#include -#endif - -#ifdef __weak_alias -__weak_alias(getmode,_getmode) -__weak_alias(setmode,_setmode) -#endif - -#define SET_LEN 6 /* initial # of bitcmd struct to malloc */ -#define SET_LEN_INCR 4 /* # of bitcmd structs to add as needed */ - -typedef struct bitcmd { - char cmd; - char cmd2; - mode_t bits; -} BITCMD; - -#define CMD2_CLR 0x01 -#define CMD2_SET 0x02 -#define CMD2_GBITS 0x04 -#define CMD2_OBITS 0x08 -#define CMD2_UBITS 0x10 - -static BITCMD *addcmd(BITCMD *, mode_t, mode_t, mode_t, mode_t); -static void compress_mode(BITCMD *); -#ifdef SETMODE_DEBUG -static void dumpmode(BITCMD *); -#endif - -/* - * Given the old mode and an array of bitcmd structures, apply the operations - * described in the bitcmd structures to the old mode, and return the new mode. - * Note that there is no '=' command; a strict assignment is just a '-' (clear - * bits) followed by a '+' (set bits). - */ -mode_t -getmode(const void *bbox, mode_t omode) -{ - const BITCMD *set; - mode_t clrval, newmode, value; - - _DIAGASSERT(bbox != NULL); - - set = (const BITCMD *)bbox; - newmode = omode; - for (value = 0;; set++) - switch(set->cmd) { - /* - * When copying the user, group or other bits around, we "know" - * where the bits are in the mode so that we can do shifts to - * copy them around. If we don't use shifts, it gets real - * grundgy with lots of single bit checks and bit sets. - */ - case 'u': - value = (newmode & S_IRWXU) >> 6; - goto common; - - case 'g': - value = (newmode & S_IRWXG) >> 3; - goto common; - - case 'o': - value = newmode & S_IRWXO; -common: if (set->cmd2 & CMD2_CLR) { - clrval = - (set->cmd2 & CMD2_SET) ? S_IRWXO : value; - if (set->cmd2 & CMD2_UBITS) - newmode &= ~((clrval<<6) & set->bits); - if (set->cmd2 & CMD2_GBITS) - newmode &= ~((clrval<<3) & set->bits); - if (set->cmd2 & CMD2_OBITS) - newmode &= ~(clrval & set->bits); - } - if (set->cmd2 & CMD2_SET) { - if (set->cmd2 & CMD2_UBITS) - newmode |= (value<<6) & set->bits; - if (set->cmd2 & CMD2_GBITS) - newmode |= (value<<3) & set->bits; - if (set->cmd2 & CMD2_OBITS) - newmode |= value & set->bits; - } - break; - - case '+': - newmode |= set->bits; - break; - - case '-': - newmode &= ~set->bits; - break; - - case 'X': - if (omode & (S_IFDIR|S_IXUSR|S_IXGRP|S_IXOTH)) - newmode |= set->bits; - break; - - case '\0': - default: -#ifdef SETMODE_DEBUG - (void)printf("getmode:%04o -> %04o\n", omode, newmode); -#endif - return (newmode); - } -} - -#define ADDCMD(a, b, c, d) do { \ - if (set >= endset) { \ - BITCMD *newset; \ - setlen += SET_LEN_INCR; \ - newset = realloc(saveset, sizeof(BITCMD) * setlen); \ - if (newset == NULL) \ - goto out; \ - set = newset + (set - saveset); \ - saveset = newset; \ - endset = newset + (setlen - 2); \ - } \ - set = addcmd(set, (mode_t)(a), (mode_t)(b), (mode_t)(c), (d)); \ -} while (/*CONSTCOND*/0) - -#define STANDARD_BITS (S_ISUID|S_ISGID|S_IRWXU|S_IRWXG|S_IRWXO) - -void * -setmode(const char *p) -{ - int serrno; - char op, *ep; - BITCMD *set, *saveset, *endset; - sigset_t signset, sigoset; - mode_t mask, perm, permXbits, who; - long lval; - int equalopdone = 0; /* pacify gcc */ - int setlen; - - if (!*p) { - errno = EINVAL; - return NULL; - } - - /* - * Get a copy of the mask for the permissions that are mask relative. - * Flip the bits, we want what's not set. Since it's possible that - * the caller is opening files inside a signal handler, protect them - * as best we can. - */ - sigfillset(&signset); - (void)sigprocmask(SIG_BLOCK, &signset, &sigoset); - (void)umask(mask = umask(0)); - mask = ~mask; - (void)sigprocmask(SIG_SETMASK, &sigoset, NULL); - - setlen = SET_LEN + 2; - - if ((set = malloc((u_int)(sizeof(BITCMD) * setlen))) == NULL) - return (NULL); - saveset = set; - endset = set + (setlen - 2); - - /* - * If an absolute number, get it and return; disallow non-octal digits - * or illegal bits. - */ - if (isdigit((unsigned char)*p)) { - errno = 0; - lval = strtol(p, &ep, 8); - if (*ep) { - errno = EINVAL; - goto out; - } - if (errno == ERANGE && (lval == LONG_MAX || lval == LONG_MIN)) - goto out; - if (lval & ~(STANDARD_BITS|S_ISTXT)) { - errno = EINVAL; - goto out; - } - perm = (mode_t)lval; - ADDCMD('=', (STANDARD_BITS|S_ISTXT), perm, mask); - set->cmd = 0; - return (saveset); - } - - /* - * Build list of structures to set/clear/copy bits as described by - * each clause of the symbolic mode. - */ - for (;;) { - /* First, find out which bits might be modified. */ - for (who = 0;; ++p) { - switch (*p) { - case 'a': - who |= STANDARD_BITS; - break; - case 'u': - who |= S_ISUID|S_IRWXU; - break; - case 'g': - who |= S_ISGID|S_IRWXG; - break; - case 'o': - who |= S_IRWXO; - break; - default: - goto getop; - } - } - -getop: if ((op = *p++) != '+' && op != '-' && op != '=') { - errno = EINVAL; - goto out; - } - if (op == '=') - equalopdone = 0; - - who &= ~S_ISTXT; - for (perm = 0, permXbits = 0;; ++p) { - switch (*p) { - case 'r': - perm |= S_IRUSR|S_IRGRP|S_IROTH; - break; - case 's': - /* - * If specific bits where requested and - * only "other" bits ignore set-id. - */ - if (who == 0 || (who & ~S_IRWXO)) - perm |= S_ISUID|S_ISGID; - break; - case 't': - /* - * If specific bits where requested and - * only "other" bits ignore set-id. - */ - if (who == 0 || (who & ~S_IRWXO)) { - who |= S_ISTXT; - perm |= S_ISTXT; - } - break; - case 'w': - perm |= S_IWUSR|S_IWGRP|S_IWOTH; - break; - case 'X': - permXbits = S_IXUSR|S_IXGRP|S_IXOTH; - break; - case 'x': - perm |= S_IXUSR|S_IXGRP|S_IXOTH; - break; - case 'u': - case 'g': - case 'o': - /* - * When ever we hit 'u', 'g', or 'o', we have - * to flush out any partial mode that we have, - * and then do the copying of the mode bits. - */ - if (perm) { - ADDCMD(op, who, perm, mask); - perm = 0; - } - if (op == '=') - equalopdone = 1; - if (op == '+' && permXbits) { - ADDCMD('X', who, permXbits, mask); - permXbits = 0; - } - ADDCMD(*p, who, op, mask); - break; - - default: - /* - * Add any permissions that we haven't already - * done. - */ - if (perm || (op == '=' && !equalopdone)) { - if (op == '=') - equalopdone = 1; - ADDCMD(op, who, perm, mask); - perm = 0; - } - if (permXbits) { - ADDCMD('X', who, permXbits, mask); - permXbits = 0; - } - goto apply; - } - } - -apply: if (!*p) - break; - if (*p != ',') - goto getop; - ++p; - } - set->cmd = 0; -#ifdef SETMODE_DEBUG - (void)printf("Before compress_mode()\n"); - dumpmode(saveset); -#endif - compress_mode(saveset); -#ifdef SETMODE_DEBUG - (void)printf("After compress_mode()\n"); - dumpmode(saveset); -#endif - return (saveset); -out: - serrno = errno; - free(saveset); - errno = serrno; - return NULL; -} - -static BITCMD * -addcmd(BITCMD *set, mode_t op, mode_t who, mode_t oparg, mode_t mask) -{ - - _DIAGASSERT(set != NULL); - - switch (op) { - case '=': - set->cmd = '-'; - set->bits = who ? who : STANDARD_BITS; - set++; - - op = '+'; - /* FALLTHROUGH */ - case '+': - case '-': - case 'X': - set->cmd = op; - set->bits = (who ? who : mask) & oparg; - break; - - case 'u': - case 'g': - case 'o': - set->cmd = op; - if (who) { - set->cmd2 = ((who & S_IRUSR) ? CMD2_UBITS : 0) | - ((who & S_IRGRP) ? CMD2_GBITS : 0) | - ((who & S_IROTH) ? CMD2_OBITS : 0); - set->bits = (mode_t)~0; - } else { - set->cmd2 = CMD2_UBITS | CMD2_GBITS | CMD2_OBITS; - set->bits = mask; - } - - if (oparg == '+') - set->cmd2 |= CMD2_SET; - else if (oparg == '-') - set->cmd2 |= CMD2_CLR; - else if (oparg == '=') - set->cmd2 |= CMD2_SET|CMD2_CLR; - break; - } - return (set + 1); -} - -#ifdef SETMODE_DEBUG -static void -dumpmode(BITCMD *set) -{ - - _DIAGASSERT(set != NULL); - - for (; set->cmd; ++set) - (void)printf("cmd: '%c' bits %04o%s%s%s%s%s%s\n", - set->cmd, set->bits, set->cmd2 ? " cmd2:" : "", - set->cmd2 & CMD2_CLR ? " CLR" : "", - set->cmd2 & CMD2_SET ? " SET" : "", - set->cmd2 & CMD2_UBITS ? " UBITS" : "", - set->cmd2 & CMD2_GBITS ? " GBITS" : "", - set->cmd2 & CMD2_OBITS ? " OBITS" : ""); -} -#endif - -/* - * Given an array of bitcmd structures, compress by compacting consecutive - * '+', '-' and 'X' commands into at most 3 commands, one of each. The 'u', - * 'g' and 'o' commands continue to be separate. They could probably be - * compacted, but it's not worth the effort. - */ -static void -compress_mode(BITCMD *set) -{ - BITCMD *nset; - int setbits, clrbits, Xbits, op; - - _DIAGASSERT(set != NULL); - - for (nset = set;;) { - /* Copy over any 'u', 'g' and 'o' commands. */ - while ((op = nset->cmd) != '+' && op != '-' && op != 'X') { - *set++ = *nset++; - if (!op) - return; - } - - for (setbits = clrbits = Xbits = 0;; nset++) { - if ((op = nset->cmd) == '-') { - clrbits |= nset->bits; - setbits &= ~nset->bits; - Xbits &= ~nset->bits; - } else if (op == '+') { - setbits |= nset->bits; - clrbits &= ~nset->bits; - Xbits &= ~nset->bits; - } else if (op == 'X') - Xbits |= nset->bits & ~setbits; - else - break; - } - if (clrbits) { - set->cmd = '-'; - set->cmd2 = 0; - set->bits = clrbits; - set++; - } - if (setbits) { - set->cmd = '+'; - set->cmd2 = 0; - set->bits = setbits; - set++; - } - if (Xbits) { - set->cmd = 'X'; - set->cmd2 = 0; - set->bits = Xbits; - set++; - } - } -} diff --git a/lib/libc/gen/setproctitle.3 b/lib/libc/gen/setproctitle.3 deleted file mode 100644 index 8d32011f7..000000000 --- a/lib/libc/gen/setproctitle.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" $NetBSD: setproctitle.3,v 1.18 2003/07/26 19:24:44 salo Exp $ -.\" -.\" Copyright (c) 1994, 1995 Christopher G. Demetriou -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed for the -.\" NetBSD Project. See http://www.NetBSD.org/ for -.\" information about NetBSD. -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" 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. -.\" -.\" <> -.\" -.Dd April 13, 1994 -.Dt SETPROCTITLE 3 -.Os -.Sh NAME -.Nm setproctitle -.Nd set process title -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft void -.Fn setproctitle "const char *fmt" "..." -.Sh DESCRIPTION -The -.Fn setproctitle -function sets the invoking process's title. -The process title is set to the last component of the program -name, followed by a colon and the formatted string specified -by -.Va fmt . -If -.Va fmt -is -.Dv NULL , -the colon and formatted string are omitted. -The length of a process title is limited to 2048 bytes. -.Sh EXAMPLES -Set the process title to the program name, with no further information: -.Bd -literal -offset indent -setproctitle(NULL); -.Ed -.Pp -Set the process title to the program name, an informational string, -and the process id: -.Bd -literal -offset indent -setproctitle("foo! (%d)", getpid()); -.Ed -.Sh SEE ALSO -.Xr ps 1 , -.Xr w 1 , -.Xr getprogname 3 , -.Xr printf 3 -.Sh HISTORY -The -.Fn setproctitle -function first appeared in -.Nx 1.0 . -.Sh CAVEATS -It is important never to pass a string with user-supplied data as a -format without using -.Ql %s . -An attacker can put format specifiers in the string to mangle your stack, -leading to a possible security hole. -This holds true even if you have built the string -.Dq by hand -using a function like -.Fn snprintf , -as the resulting string may still contain user-supplied conversion specifiers -for later interpolation by -.Fn setproctitle . -.Pp -Always be sure to use the proper secure idiom: -.Bd -literal -offset indent -setproctitle("%s", string); -.Ed diff --git a/lib/libc/gen/setproctitle.c b/lib/libc/gen/setproctitle.c deleted file mode 100644 index 513892264..000000000 --- a/lib/libc/gen/setproctitle.c +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: setproctitle.c,v 1.22 2008/01/03 04:26:27 christos Exp $ */ - -/* - * Copyright (c) 1994, 1995 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: setproctitle.c,v 1.22 2008/01/03 04:26:27 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(setproctitle,_setproctitle) -#endif - -#define MAX_PROCTITLE 2048 - -/* - * For compatibility with old versions of crt0 that didn't define __ps_strings, - * define it as a common here. - */ -struct ps_strings *__ps_strings; - -void -setproctitle(const char *fmt, ...) -{ - static char buf[MAX_PROCTITLE], *bufp; - const char *pname = getprogname(); - - if (fmt != NULL) { - int len = snprintf(buf, sizeof(buf), "%s: ", pname); - if (len >= 0) { - va_list ap; - - va_start(ap, fmt); - (void)vsnprintf(buf + len, sizeof(buf) - len, fmt, ap); - va_end(ap); - } - } else - (void)snprintf(buf, sizeof(buf), "%s", pname); - - bufp = buf; - -#ifdef USRSTACK - /* - * For compatibility with old versions of crt0 and old kernels, set - * __ps_strings to a default value if it's null. - * But only if USRSTACK is defined. It might not be defined if - * user-level code can not assume it's a constant (i.e. m68k). - */ - if (__ps_strings == 0) - __ps_strings = PS_STRINGS; -#endif /* USRSTACK */ - - if (__ps_strings != 0) { - __ps_strings->ps_nargvstr = 1; - __ps_strings->ps_argvstr = &bufp; - } -} diff --git a/lib/libc/gen/setprogname.c b/lib/libc/gen/setprogname.c deleted file mode 100644 index 489952371..000000000 --- a/lib/libc/gen/setprogname.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: setprogname.c,v 1.3 2003/07/26 19:24:44 salo Exp $ */ - -/* - * Copyright (c) 2001 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: setprogname.c,v 1.3 2003/07/26 19:24:44 salo Exp $"); -#endif /* LIBC_SCCS and not lint */ - -/* In NetBSD, the program name is set by crt0. It can't be overridden. */ -#undef REALLY_SET_PROGNAME - -#include - -#ifdef REALLY_SET_PROGNAME -#include - -extern const char *__progname; -#endif - -/*ARGSUSED*/ -void -setprogname(const char *progname) -{ - -#ifdef REALLY_SET_PROGNAME - __progname = strrchr(progname, '/'); - if (__progname == NULL) - __progname = progname; - else - __progname++; -#endif -} diff --git a/lib/libc/gen/shquote.3 b/lib/libc/gen/shquote.3 deleted file mode 100644 index 026467fcf..000000000 --- a/lib/libc/gen/shquote.3 +++ /dev/null @@ -1,244 +0,0 @@ -.\" $NetBSD: shquote.3,v 1.9 2008/09/07 08:55:46 apb Exp $ -.\" -.\" Copyright (c) 2001 Christopher G. Demetriou -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed for the -.\" NetBSD Project. See http://www.NetBSD.org/ for -.\" information about NetBSD. -.\" 4. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" 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. -.\" -.\" <> -.\" -.Dd September 7, 2008 -.Dt SHQUOTE 3 -.Os -.Sh NAME -.Nm shquote , -.Nm shquotev -.Nd quote argument strings for use with the shell -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft size_t -.Fn shquote "const char *arg" "char *buf" "size_t bufsize" -.Ft size_t -.Fn shquotev "int argc" "char * const *argv" "char *buf" "size_t bufsize" -.Sh DESCRIPTION -The -.Fn shquote -and -.Fn shquotev -functions copy strings and transform the copies by adding shell -escape and quoting characters. -They are used to encapsulate -arguments to be included in command strings passed to the -.Fn system -and -.Fn popen -functions, so that the arguments will have the correct values -after being evaluated by the shell. -.Pp -The exact method of quoting and escaping may vary, and is intended -to match the conventions of the shell used by -.Fn system -and -.Fn popen . -It may not match the conventions used by other shells. -In this implementation, the following -transformation is applied to each input string: -.Bl -bullet -width indent -.It -it is surrounded by single quotes -.Pq ' , -.It -any single quotes in the input are escaped by replacing them with -the four-character sequence: -.Li '\e'' , -and -.It -extraneous pairs of single quotes (caused by multiple adjacent single -quotes in the input string, or by single quotes at the beginning or -end of the input string) are elided. -.El -.Pp -The -.Fn shquote -function transforms the string specified by its -.Fa arg -argument, and places the result into the memory pointed to by -.Fa buf . -.Pp -The -.Fn shquotev -function transforms each of the -.Fa argc -strings specified by the array -.Fa argv -independently. -The transformed strings are placed in the memory pointed to by -.Fa buf , -separated by spaces. -It does not modify the pointer array specified by -.Fa argv -or the strings pointed to by the pointers in the array. -.Pp -Both functions write up to -.Fa bufsize -- 1 characters of output into the buffer pointed to by -.Fa buf , -then add a -.Li NUL -character to terminate the output string. -If -.Fa bufsize -is given as zero, the -.Fa buf -parameter is ignored and no output is written. -.Sh RETURN VALUES -The -.Fn shquote -and -.Fn shquotev -functions return the number of characters necessary to hold the -result from operating on their input strings, -not including the terminating -.Li NUL . -That is, they return the length of the string that would have -been written to the output buffer, if it were large enough. -If an error occurs during processing, the value ((size_t)\-1) -is returned and -.Va errno -is set appropriately. -.Sh EXAMPLES -The following code fragment demonstrates how you might use -.Fn shquotev -to construct a command string to be used with -.Fn system . -The command uses an environment variable (which will be expanded by -the shell) to determine the actual program to run. -Note that the environment variable may be expanded by -the shell into multiple words. -The first word of the expansion will be used by the shell -as the name of the program to run, -and the rest will be passed as arguments to the program. -.Bd -literal -offset indent -char **argv, c, *cmd; -size_t cmdlen, len, qlen; -int argc; - -\&... - -/* - * Size buffer to hold the command string, and allocate it. - * Buffer of length one given to snprintf() for portability. - */ -cmdlen = snprintf(\*[Am]c, 1, "${PROG-%s} ", PROG_DEFAULT); -qlen = shquotev(argc, argv, NULL, 0); -if (qlen == (size_t)-1) { - \&... -} -cmdlen += qlen + 1; -cmd = malloc(cmdlen); -if (cmd == NULL) { - \&... -} - -/* Create the command string. */ -len = snprintf(cmd, cmdlen, "${PROG-%s} ", PROG_DEFAULT); -qlen = shquotev(argc, argv, cmd + len, cmdlen - len); -if (qlen == (size_t)-1) { - /* Should not ever happen. */ - \&... -} -len += qlen; - -/* "cmd" can now be passed to system(). */ -.Ed -.Pp -The following example shows how you would implement the same -functionality using the -.Fn shquote -function directly. -.Bd -literal -offset indent -char **argv, c, *cmd; -size_t cmdlen, len, qlen; -int argc, i; - -\&... - -/* - * Size buffer to hold the command string, and allocate it. - * Buffer of length one given to snprintf() for portability. - */ -cmdlen = snprintf(\*[Am]c, 1, "${PROG-%s} ", PROG_DEFAULT); -for (i = 0; i \*[Lt] argc; i++) { - qlen = shquote(argv[i], NULL, 0); - if (qlen == (size_t)-1) { - \&... - } - cmdlen += qlen + 1; -} -cmd = malloc(cmdlen); -if (cmd == NULL) { - \&... -} - -/* Start the command string with the env var reference. */ -len = snprintf(cmd, cmdlen, "${PROG-%s} ", PROG_DEFAULT); - -/* Quote all of the arguments when copying them. */ -for (i = 0; i \*[Lt] argc; i++) { - qlen = shquote(argv[i], cmd + len, cmdlen - len); - if (qlen == (size_t)-1) { - /* Should not ever happen. */ - \&... - } - len += qlen; - cmd[len++] = ' '; -} -cmd[--len] = '\e0'; - -/* "cmd" can now be passed to system(). */ -.Ed -.Sh SEE ALSO -.Xr sh 1 , -.Xr popen 3 , -.Xr system 3 -.Sh BUGS -This implementation does not currently handle strings containing multibyte -characters properly. -To address this issue, -.Pa /bin/sh -.Po -the shell used by -.Fn system -and -.Fn popen -.Pc -must first be fixed to handle multibyte characters. -When that has been done, -these functions can have multibyte character support enabled. diff --git a/lib/libc/gen/shquote.c b/lib/libc/gen/shquote.c deleted file mode 100644 index e72837f5f..000000000 --- a/lib/libc/gen/shquote.c +++ /dev/null @@ -1,189 +0,0 @@ -/* $NetBSD: shquote.c,v 1.8 2006/03/19 02:33:02 christos Exp $ */ - -/* - * Copyright (c) 2001 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: shquote.c,v 1.8 2006/03/19 02:33:02 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -/* - * Define SHQUOTE_USE_MULTIBYTE if you want shquote() to handle multibyte - * characters using mbrtowc(). - * - * Please DO NOT rip this #ifdef out of the code. It's also here to help - * portability. - */ -#undef SHQUOTE_USE_MULTIBYTE - -#include "namespace.h" -#include -#include -#ifdef SHQUOTE_USE_MULTIBYTE -#include -#include -#include -#endif - -#ifdef __weak_alias -__weak_alias(shquote,_shquote) -#endif - -/* - * shquote(): - * - * Requotes arguments so that they'll be interpreted properly by the - * shell (/bin/sh). - * - * Wraps single quotes around the string, and replaces single quotes - * in the string with the sequence: - * '\'' - * - * Returns the number of characters required to hold the resulting quoted - * argument. - * - * The buffer supplied is filled in and NUL-terminated. If 'bufsize' - * indicates that the buffer is too short to hold the output string, the - * first (bufsize - 1) bytes of quoted argument are filled in and the - * buffer is NUL-terminated. - * - * Changes could be made to optimize the length of strings output by this - * function: - * - * * if there are no metacharacters or whitespace in the input, - * the output could be the input string. - */ - -#ifdef SHQUOTE_USE_MULTIBYTE - -#define XLATE_OUTCH(x) wcrtomb(outch, (x), &mbso) -#define XLATE_INCH() \ - do { \ - n = mbrtowc(&c, arg, MB_CUR_MAX, &mbsi); \ - } while (/*LINTED const cond*/0) - -#else - -#define XLATE_OUTCH(x) (outch[0] = (x), 1) -#define XLATE_INCH() \ - do { \ - n = ((c = *arg) != '\0') ? 1 : 0; \ - } while (/*LINTED const cond*/0) - -#endif - -#define PUT(x) \ - do { \ - outchlen = XLATE_OUTCH(x); \ - if (outchlen == (size_t)-1) \ - goto bad; \ - rv += outchlen; \ - if (bufsize != 0) { \ - if (bufsize < outchlen || \ - (bufsize == outchlen && \ - outch[outchlen - 1] != '\0')) { \ - *buf = '\0'; \ - bufsize = 0; \ - } else { \ - memcpy(buf, outch, outchlen); \ - buf += outchlen; \ - bufsize -= outchlen; \ - } \ - } \ - } while (/*LINTED const cond*/0) - -size_t -shquote(const char *arg, char *buf, size_t bufsize) -{ -#ifdef SHQUOTE_USE_MULTIBYTE - char outch[MB_LEN_MAX]; - mbstate_t mbsi, mbso; - wchar_t c, lastc; - size_t outchlen; -#else - char outch[1]; - char c, lastc; - size_t outchlen; -#endif - size_t rv; - int n; - - rv = 0; - lastc = 0; -#ifdef SHQUOTE_USE_MULTIBYTE - memset(&mbsi, 0, sizeof mbsi); - memset(&mbso, 0, sizeof mbso); -#endif - - if (*arg != '\'') - PUT('\''); - for (;;) { - XLATE_INCH(); - if (n <= 0) - break; - arg += n; - lastc = c; - - if (c == '\'') { - if (rv != 0) - PUT('\''); - PUT('\\'); - PUT('\''); - for (;;) { - XLATE_INCH(); - if (n <= 0 || c != '\'') - break; - PUT('\\'); - PUT('\''); - arg += n; - } - if (n > 0) - PUT('\''); - } else - PUT(c); - } - if (lastc != '\'') - PUT('\''); - - /* Put multibyte or NUL terminator, but don't count the NUL. */ - PUT('\0'); - rv--; - - return rv; - -bad: - /* A multibyte character encoding or decoding error occurred. */ - return (size_t)-1; -} diff --git a/lib/libc/gen/shquotev.c b/lib/libc/gen/shquotev.c deleted file mode 100644 index 4953f47ff..000000000 --- a/lib/libc/gen/shquotev.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: shquotev.c,v 1.5 2005/06/12 05:21:27 lukem Exp $ */ - -/* - * Copyright (c) 2001 Christopher G. Demetriou - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the - * NetBSD Project. See http://www.NetBSD.org/ for - * information about NetBSD. - * 4. The name of the author may not be used to endorse or promote products - * derived from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * <> - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: shquotev.c,v 1.5 2005/06/12 05:21:27 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -/* - * shquotev(): - * - * Apply shquote() to a set of strings, separating the results by spaces. - */ - -size_t -shquotev(int argc, char * const * argv, char *buf, size_t bufsize) -{ - size_t rv, callrv; - int i; - - rv = 0; - - if (argc == 0) { - if (bufsize != 0) - *buf = '\0'; - return rv; - } - - for (i = 0; i < argc; i++) { - callrv = shquote(argv[i], buf, bufsize); - if (callrv == (size_t)-1) - goto bad; - rv += callrv; - buf += callrv; - bufsize = (bufsize > callrv) ? (bufsize - callrv) : 0; - - if (i < (argc - 1)) { - rv++; - if (bufsize > 1) { - *buf++ = ' '; - bufsize--; - } - } - } - - return rv; - -bad: - return (size_t)-1; -} diff --git a/lib/libc/gen/sighold.3 b/lib/libc/gen/sighold.3 deleted file mode 100644 index b29e46bfa..000000000 --- a/lib/libc/gen/sighold.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" $NetBSD: sighold.3,v 1.5 2010/04/30 04:39:16 jruoho Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 30, 2010 -.Dt SIGHOLD 3 -.Os -.Sh NAME -.Nm sighold -.Nd manipulate current signal mask -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn sighold "int sig" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by -.Xr sigprocmask 2 . -.Ef -.Pp -The -.Fn sighold -function adds the signal -.Fa sig -to the calling process' signal mask. -.Sh RETURN VALUES -If successful, the -.Fn sighold -function returns 0. -Otherwise \-1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn sighold -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The argument -.Fa sig -is not a valid signal number. -.El -.Sh SEE ALSO -.Xr sigprocmask 2 , -.Xr sigrelse 3 -.Sh STANDARDS -The -.Fn sighold -function conforms to -.St -p1003.1-2001 . -It was however marked as obsolete in the -.St -p1003.1-2008 -revision of the standard. diff --git a/lib/libc/gen/sighold.c b/lib/libc/gen/sighold.c deleted file mode 100644 index 7fa70c983..000000000 --- a/lib/libc/gen/sighold.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: sighold.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sighold.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include "namespace.h" -#include -#include - -int -sighold(int sig) -{ - sigset_t set; - - sigemptyset(&set); - if (sigaddset(&set, sig) != 0) - return (-1); - - return (sigprocmask(SIG_BLOCK, &set, NULL)); -} diff --git a/lib/libc/gen/sigignore.3 b/lib/libc/gen/sigignore.3 deleted file mode 100644 index 41ed44e83..000000000 --- a/lib/libc/gen/sigignore.3 +++ /dev/null @@ -1,85 +0,0 @@ -.\" $NetBSD: sigignore.3,v 1.6 2010/04/30 06:48:20 wiz Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 30, 2010 -.Dt SIGIGNORE 3 -.Os -.Sh NAME -.Nm sigignore -.Nd manipulate signal dispositions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn sigignore "int sig" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by -.Xr sigaction 2 . -.Ef -.Pp -The -.Fn sigignore -function sets the disposition of the signal -.Fa sig -to -.Dv SIG_IGN . -.Sh RETURN VALUES -If successful, the -.Fn sigignore -function returns 0. -Otherwise \-1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn sigignore -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The argument -.Fa sig -is not a valid signal number; -or an attempt is made to ignore a signal that cannot be ignored, -such as -.Dv SIGKILL -or -.Dv SIGSTOP . -.El -.Sh SEE ALSO -.Xr sigaction 2 -.Sh STANDARDS -The -.Fn sigignore -function conforms to -.St -p1003.1-2001 . -It was however marked as obsolete in the -.St -p1003.1-2008 -revision of the standard. diff --git a/lib/libc/gen/sigignore.c b/lib/libc/gen/sigignore.c deleted file mode 100644 index e9d73221b..000000000 --- a/lib/libc/gen/sigignore.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: sigignore.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sigignore.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include "namespace.h" -#include -#include - -int -sigignore(int sig) -{ - struct sigaction sa; - - sa.sa_handler = SIG_IGN; - if (sigemptyset(&sa.sa_mask) != 0) - return (-1); - sa.sa_flags = 0; - - return (sigaction(sig, &sa, NULL)); -} diff --git a/lib/libc/gen/siginterrupt.3 b/lib/libc/gen/siginterrupt.3 deleted file mode 100644 index f03283316..000000000 --- a/lib/libc/gen/siginterrupt.3 +++ /dev/null @@ -1,105 +0,0 @@ -.\" $NetBSD: siginterrupt.3,v 1.11 2003/08/07 16:42:56 agc Exp $ -.\" -.\" Copyright (c) 1985, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)siginterrupt.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt SIGINTERRUPT 3 -.Os -.Sh NAME -.Nm siginterrupt -.Nd allow signals to interrupt system calls -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn siginterrupt "int sig" "int flag" -.Sh DESCRIPTION -The -.Fn siginterrupt -function -is used to change the system call restart -behavior when a system call is interrupted by the specified signal. -If the flag is false (0), then system calls will be restarted if -they are interrupted by the specified signal -and no data has been transferred yet. -System call restart is the default behavior on -.Bx 4.2 . -.Pp -If the flag is true (1), -then restarting of system calls is disabled. -If a system call is interrupted by the specified signal -and no data has been transferred, -the system call will return \-1 with the global variable -.Va errno -set to -.Dv EINTR . -Interrupted system calls that have started transferring -data will return the amount of data actually transferred. -System call interrupt is the signal behavior found on -.Bx 4.1 -and -.At V -systems. -.Pp -Note that the new -.Bx 4.2 -signal handling semantics are not -altered in any other way. -Most notably, signal handlers always remain installed until -explicitly changed by a subsequent -.Xr sigaction 2 -call, and the signal mask operates as documented in -.Xr sigaction 2 . -Programs may switch between restartable and interruptible -system call operation as often as desired in the execution of a program. -.Pp -Issuing a -.Fn siginterrupt 3 -call during the execution of a signal handler will cause -the new action to take place on the next signal to be caught. -.Sh NOTES -This library routine uses an extension of the -.Xr sigaction 2 -system call that is not available in -.Bx 4.2 , -hence it should not be used if backward compatibility is needed. -.Sh RETURN VALUES -A 0 value indicates that the call succeeded. -A \-1 value indicates that an invalid signal number has been supplied. -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 -.Sh HISTORY -The -.Fn siginterrupt -function appeared in -.Bx 4.3 . diff --git a/lib/libc/gen/siginterrupt.c b/lib/libc/gen/siginterrupt.c deleted file mode 100644 index 1e79d42ce..000000000 --- a/lib/libc/gen/siginterrupt.c +++ /dev/null @@ -1,69 +0,0 @@ -/* $NetBSD: siginterrupt.c,v 1.13 2012/06/25 22:32:43 abs Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)siginterrupt.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: siginterrupt.c,v 1.13 2012/06/25 22:32:43 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#ifdef __weak_alias -__weak_alias(siginterrupt,_siginterrupt) -#endif - -extern sigset_t __sigintr; -/* - * Set signal state to prevent restart of system calls - * after an instance of the indicated signal. - */ -int -siginterrupt(int sig, int flag) -{ - struct sigaction sa; - int ret; - - if ((ret = sigaction(sig, (struct sigaction *)0, &sa)) < 0) - return (ret); - if (flag) { - sigaddset(&__sigintr, sig); - sa.sa_flags &= ~SA_RESTART; - } else { - sigdelset(&__sigintr, sig); - sa.sa_flags |= SA_RESTART; - } - return (sigaction(sig, &sa, (struct sigaction *)0)); -} diff --git a/lib/libc/gen/siglist.c b/lib/libc/gen/siglist.c deleted file mode 100644 index 3b2e464b5..000000000 --- a/lib/libc/gen/siglist.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: siglist.c,v 1.17 2007/01/17 23:24:22 hubertf Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)siglist.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: siglist.c,v 1.17 2007/01/17 23:24:22 hubertf Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include - -static const char *const __siglist14[] = { - "Signal 0", /* 0 */ - "Hangup", /* 1 SIGHUP */ - "Interrupt", /* 2 SIGINT */ - "Quit", /* 3 SIGQUIT */ - "Illegal instruction", /* 4 SIGILL */ - "Trace/BPT trap", /* 5 SIGTRAP */ - "Abort trap", /* 6 SIGABRT */ - "EMT trap", /* 7 SIGEMT */ - "Floating point exception", /* 8 SIGFPE */ - "Killed", /* 9 SIGKILL */ - "Bus error", /* 10 SIGBUS */ - "Segmentation fault", /* 11 SIGSEGV */ - "Bad system call", /* 12 SIGSYS */ - "Broken pipe", /* 13 SIGPIPE */ - "Alarm clock", /* 14 SIGALRM */ - "Terminated", /* 15 SIGTERM */ - "Urgent I/O condition", /* 16 SIGURG */ - "Suspended (signal)", /* 17 SIGSTOP */ - "Suspended", /* 18 SIGTSTP */ - "Continued", /* 19 SIGCONT */ - "Child exited", /* 20 SIGCHLD */ - "Stopped (tty input)", /* 21 SIGTTIN */ - "Stopped (tty output)", /* 22 SIGTTOU */ - "I/O possible", /* 23 SIGIO */ - "Cputime limit exceeded", /* 24 SIGXCPU */ - "Filesize limit exceeded", /* 25 SIGXFSZ */ - "Virtual timer expired", /* 26 SIGVTALRM */ - "Profiling timer expired", /* 27 SIGPROF */ - "Window size changes", /* 28 SIGWINCH */ - "Information request", /* 29 SIGINFO */ - "User defined signal 1", /* 30 SIGUSR1 */ - "User defined signal 2", /* 31 SIGUSR2 */ - "Power fail/restart", /* 32 SIGPWR */ - "Real time signal 0", /* 33 SIGRTMIN + 0 */ - "Real time signal 1", /* 34 SIGRTMIN + 1 */ - "Real time signal 2", /* 35 SIGRTMIN + 2 */ - "Real time signal 3", /* 36 SIGRTMIN + 3 */ - "Real time signal 4", /* 37 SIGRTMIN + 4 */ - "Real time signal 5", /* 38 SIGRTMIN + 5 */ - "Real time signal 6", /* 39 SIGRTMIN + 6 */ - "Real time signal 7", /* 40 SIGRTMIN + 7 */ - "Real time signal 8", /* 41 SIGRTMIN + 8 */ - "Real time signal 9", /* 42 SIGRTMIN + 9 */ - "Real time signal 10", /* 43 SIGRTMIN + 10 */ - "Real time signal 11", /* 44 SIGRTMIN + 11 */ - "Real time signal 12", /* 45 SIGRTMIN + 12 */ - "Real time signal 13", /* 46 SIGRTMIN + 13 */ - "Real time signal 14", /* 47 SIGRTMIN + 14 */ - "Real time signal 15", /* 48 SIGRTMIN + 15 */ - "Real time signal 16", /* 49 SIGRTMIN + 16 */ - "Real time signal 17", /* 50 SIGRTMIN + 17 */ - "Real time signal 18", /* 51 SIGRTMIN + 18 */ - "Real time signal 19", /* 52 SIGRTMIN + 19 */ - "Real time signal 20", /* 53 SIGRTMIN + 20 */ - "Real time signal 21", /* 54 SIGRTMIN + 21 */ - "Real time signal 22", /* 55 SIGRTMIN + 22 */ - "Real time signal 23", /* 56 SIGRTMIN + 23 */ - "Real time signal 24", /* 57 SIGRTMIN + 24 */ - "Real time signal 25", /* 58 SIGRTMIN + 25 */ - "Real time signal 26", /* 59 SIGRTMIN + 26 */ - "Real time signal 27", /* 60 SIGRTMIN + 27 */ - "Real time signal 28", /* 61 SIGRTMIN + 28 */ - "Real time signal 29", /* 62 SIGRTMIN + 29 */ - "Real time signal 30", /* 63 SIGRTMIN + 30 */ -}; - -const int __sys_nsig14 = sizeof(__siglist14) / sizeof(__siglist14[0]); - -const char * const *__sys_siglist14 = __siglist14; diff --git a/lib/libc/gen/signal.3 b/lib/libc/gen/signal.3 deleted file mode 100644 index e554195a3..000000000 --- a/lib/libc/gen/signal.3 +++ /dev/null @@ -1,191 +0,0 @@ -.\" $NetBSD: signal.3,v 1.24 2004/06/13 19:17:06 lha Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)signal.3 8.3 (Berkeley) 4/19/94 -.\" -.Dd June 11, 2004 -.Dt SIGNAL 3 -.Os -.Sh NAME -.Nm signal -.Nd simplified software signal facilities -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.\" The following is Quite Ugly, but syntactically correct. Don't try to -.\" fix it. -.Ft void \*(lp* -.Fn signal "int sig" "void \*(lp*func\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint" -.Sh DESCRIPTION -This -.Fn signal -facility -is a simplified interface to the more general -.Xr sigaction 2 -facility. -.Pp -Signals allow the manipulation of a process from outside its -domain as well as allowing the process to manipulate itself or -copies of itself (children). -There are two general types of signals: -those that cause termination of a process and those that do not. -Signals which cause termination of a program might result from -an irrecoverable error or might be the result of a user at a terminal -typing the `interrupt' character. -Signals are used when a process is stopped because it wishes to access -its control terminal while in the background (see -.Xr tty 4 ) . -Signals are optionally generated -when a process resumes after being stopped, -when the status of child processes changes, -or when input is ready at the control terminal. -Most signals result in the termination of the process receiving them -if no action -is taken; some signals instead cause the process receiving them -to be stopped, or are simply discarded if the process has not -requested otherwise. -Except for the -.Dv SIGKILL -and -.Dv SIGSTOP -signals, the -.Fn signal -function allows for a signal to be caught, to be ignored, or to generate -an interrupt. -See -.Xr signal 7 -for comprehensive list of supported signals. -.Pp -The -.Fa func -procedure allows a user to choose the action upon receipt of a signal. -To set the default action of the signal to occur as listed above, -.Fa func -should be -.Dv SIG_DFL . -A -.Dv SIG_DFL -resets the default action. -To ignore the signal -.Fa func -should be -.Dv SIG_IGN . -This will cause subsequent instances of the signal to be ignored -and pending instances to be discarded. -If -.Dv SIG_IGN -is not used, -further occurrences of the signal are -automatically blocked and -.Fa func -is called. -.Pp -The handled signal is unblocked when the -function returns and -the process continues from where it left off when the signal occurred. -.Bf -symbolic -Unlike previous signal facilities, the handler -func() remains installed after a signal has been delivered. -.Ef -.Pp -For some system calls, if a signal is caught while the call is -executing and the call is prematurely terminated, -the call is automatically restarted. -(The handler is installed using the -.Dv SA_RESTART -flag with -.Xr sigaction 2 ) . -The affected system calls include -.Xr read 2 , -.Xr write 2 , -.Xr sendto 2 , -.Xr recvfrom 2 , -.Xr sendmsg 2 -and -.Xr recvmsg 2 -on a communications channel or a low speed device -and during a -.Xr ioctl 2 -or -.Xr wait 2 . -However, calls that have already committed are not restarted, -but instead return a partial success (for example, a short read count). -.Pp -When a process which has installed signal handlers forks, -the child process inherits the signals. -All caught signals may be reset to their default action by a call -to the -.Xr execve 2 -function; -ignored signals remain ignored. -.Pp -Only functions that are async-signal-safe can safely be used in signal -handlers, see -.Xr signal 7 -for a complete list. -.Sh RETURN VALUES -The previous action is returned on a successful call. -Otherwise, -.Dv SIG_ERR -is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn signal -will fail and no action will take place if one of the following occur: -.Bl -tag -width Er -.It Bq Er EINVAL -Specified -.Em sig -is not a valid signal number. -.It Bq Er EINVAL -An attempt is made to ignore or supply a handler for -.Dv SIGKILL -or -.Dv SIGSTOP . -.El -.Sh SEE ALSO -.Xr kill 1 , -.Xr kill 2 , -.Xr ptrace 2 , -.Xr sigaction 2 , -.Xr sigaltstack 2 , -.Xr sigprocmask 2 , -.Xr sigsuspend 2 , -.Xr psignal 3 , -.Xr setjmp 3 , -.Xr strsignal 3 , -.Xr tty 4 , -.Xr signal 7 -.Sh HISTORY -This -.Fn signal -facility appeared in -.Bx 4.0 . diff --git a/lib/libc/gen/signal.c b/lib/libc/gen/signal.c deleted file mode 100644 index cc3cce2c5..000000000 --- a/lib/libc/gen/signal.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: signal.c,v 1.13 2012/06/25 22:32:44 abs Exp $ */ - -/* - * Copyright (c) 1985, 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)signal.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: signal.c,v 1.13 2012/06/25 22:32:44 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * Almost backwards compatible signal. - */ -#include "namespace.h" -#include - -#ifdef __weak_alias -__weak_alias(signal,_signal) -#endif - -sigset_t __sigintr; /* shared with siginterrupt */ - -sig_t -signal(int s, sig_t a) -{ - struct sigaction sa, osa; - - sa.sa_handler = a; - sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - if (!sigismember(&__sigintr, s)) - sa.sa_flags |= SA_RESTART; - if (sigaction(s, &sa, &osa) < 0) - return (SIG_ERR); - return (osa.sa_handler); -} diff --git a/lib/libc/gen/signame.c b/lib/libc/gen/signame.c deleted file mode 100644 index a5f137d78..000000000 --- a/lib/libc/gen/signame.c +++ /dev/null @@ -1,111 +0,0 @@ -/* $NetBSD: signame.c,v 1.13 2005/09/13 01:44:09 christos Exp $ */ - -/* - * Copyright (c) 1983 Regents of the University of California. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "from: @(#)siglist.c 5.6 (Berkeley) 2/23/91";*/ -#else -__RCSID("$NetBSD: signame.c,v 1.13 2005/09/13 01:44:09 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -static const char *const __signame14[] = { - "Signal 0", /* 0 */ - "HUP", /* 1 SIGHUP */ - "INT", /* 2 SIGINT */ - "QUIT", /* 3 SIGQUIT */ - "ILL", /* 4 SIGILL */ - "TRAP", /* 5 SIGTRAP */ - "ABRT", /* 6 SIGABRT */ - "EMT", /* 7 SIGEMT */ - "FPE", /* 8 SIGFPE */ - "KILL", /* 9 SIGKILL */ - "BUS", /* 10 SIGBUS */ - "SEGV", /* 11 SIGSEGV */ - "SYS", /* 12 SIGSYS */ - "PIPE", /* 13 SIGPIPE */ - "ALRM", /* 14 SIGALRM */ - "TERM", /* 15 SIGTERM */ - "URG", /* 16 SIGURG */ - "STOP", /* 17 SIGSTOP */ - "TSTP", /* 18 SIGTSTP */ - "CONT", /* 19 SIGCONT */ - "CHLD", /* 20 SIGCHLD */ - "TTIN", /* 21 SIGTTIN */ - "TTOU", /* 22 SIGTTOU */ - "IO", /* 23 SIGIO */ - "XCPU", /* 24 SIGXCPU */ - "XFSZ", /* 25 SIGXFSZ */ - "VTALRM", /* 26 SIGVTALRM */ - "PROF", /* 27 SIGPROF */ - "WINCH", /* 28 SIGWINCH */ - "INFO", /* 29 SIGINFO */ - "USR1", /* 30 SIGUSR1 */ - "USR2", /* 31 SIGUSR2 */ - "PWR", /* 32 SIGPWR */ - "RT0", /* 33 SIGRTMIN + 0 */ - "RT1", /* 34 SIGRTMIN + 1 */ - "RT2", /* 35 SIGRTMIN + 2 */ - "RT3", /* 36 SIGRTMIN + 3 */ - "RT4", /* 37 SIGRTMIN + 4 */ - "RT5", /* 38 SIGRTMIN + 5 */ - "RT6", /* 39 SIGRTMIN + 6 */ - "RT7", /* 40 SIGRTMIN + 7 */ - "RT8", /* 41 SIGRTMIN + 8 */ - "RT9", /* 42 SIGRTMIN + 9 */ - "RT10", /* 43 SIGRTMIN + 10 */ - "RT11", /* 44 SIGRTMIN + 11 */ - "RT12", /* 45 SIGRTMIN + 12 */ - "RT13", /* 46 SIGRTMIN + 13 */ - "RT14", /* 47 SIGRTMIN + 14 */ - "RT15", /* 48 SIGRTMIN + 15 */ - "RT16", /* 49 SIGRTMIN + 16 */ - "RT17", /* 50 SIGRTMIN + 17 */ - "RT18", /* 51 SIGRTMIN + 18 */ - "RT19", /* 52 SIGRTMIN + 19 */ - "RT20", /* 53 SIGRTMIN + 20 */ - "RT21", /* 54 SIGRTMIN + 21 */ - "RT22", /* 55 SIGRTMIN + 22 */ - "RT23", /* 56 SIGRTMIN + 23 */ - "RT24", /* 57 SIGRTMIN + 24 */ - "RT25", /* 58 SIGRTMIN + 25 */ - "RT26", /* 59 SIGRTMIN + 26 */ - "RT27", /* 60 SIGRTMIN + 27 */ - "RT28", /* 61 SIGRTMIN + 28 */ - "RT29", /* 62 SIGRTMIN + 29 */ - "RT30", /* 63 SIGRTMIN + 30 */ -}; - -const char * const *__sys_signame14 = __signame14; diff --git a/lib/libc/gen/signbit.3 b/lib/libc/gen/signbit.3 deleted file mode 100644 index 71e3eb599..000000000 --- a/lib/libc/gen/signbit.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" $NetBSD: signbit.3,v 1.3 2008/04/30 13:10:50 martin Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd October 29, 2003 -.Dt SIGNBIT 3 -.Os -.Sh NAME -.Nm signbit -.Nd test sign -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In math.h -.Ft int -.Fn signbit "real-floating x" -.Sh DESCRIPTION -The -.Fn signbit -macro determines whether the sign of its argument value -.Fa x -is negative. -An argument represented in a format wider than its semantic type is -converted to its semantic type first. -The determination is then based on the type of the argument. -.Ss IEEE754 -The sign is determined for all values, including infinities, zeroes, -and NaNs -.Ss VAX -The sign is determined for finites, true zeros, and dirty zeroes; -for ROPs the sign is reported negative. -.Sh RETURN VALUES -The -.Fn signbit -macro returns a non-zero value if the sign of its value -.Fa x -is negative. -Otherwise 0 is returned. -.Sh ERRORS -No errors are defined. -.Sh SEE ALSO -.Xr fpclassify 3 , -.Xr isfinite 3 , -.Xr isnormal 3 , -.Xr math 3 -.Sh STANDARDS -The -.Fn signbit -macro conforms to -.St -isoC-99 . diff --git a/lib/libc/gen/signbitd_ieee754.c b/lib/libc/gen/signbitd_ieee754.c deleted file mode 100644 index 9ea2f169f..000000000 --- a/lib/libc/gen/signbitd_ieee754.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitd_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: signbitd_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * IEEE 754 double-precision version - */ -int -__signbitd(double x) -{ - union ieee_double_u u; - - u.dblu_d = x; - - return (u.dblu_dbl.dbl_sign == 1); -} diff --git a/lib/libc/gen/signbitf_ieee754.c b/lib/libc/gen/signbitf_ieee754.c deleted file mode 100644 index df63bd7bc..000000000 --- a/lib/libc/gen/signbitf_ieee754.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: signbitf_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: signbitf_ieee754.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include -#include - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * IEEE 754 single-precision version - */ -int -__signbitf(float x) -{ - union ieee_single_u u; - - u.sngu_f = x; - - return (u.sngu_sng.sng_sign == 1); -} diff --git a/lib/libc/gen/signbitl_ieee754.c b/lib/libc/gen/signbitl_ieee754.c deleted file mode 100644 index 7e8b1535e..000000000 --- a/lib/libc/gen/signbitl_ieee754.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: signbitl_ieee754.c,v 1.1 2011/01/17 23:53:03 matt Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD"); -#endif - -#include -#include - -#ifdef __HAVE_LONG_DOUBLE - -/* - * 7.12.3.6 signbit - determine whether the sign of an argument is negative - * IEEE 754 compatible 128-bit extended-precision version - */ -int -__signbitl(long double x) -{ - union ieee_ext_u u; - - u.extu_ld = x; - - return (u.extu_ext.ext_sign == 1); -} - -#endif /* __HAVE_LONG_DOUBLE */ diff --git a/lib/libc/gen/sigrelse.3 b/lib/libc/gen/sigrelse.3 deleted file mode 100644 index f70cc49e0..000000000 --- a/lib/libc/gen/sigrelse.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" $NetBSD: sigrelse.3,v 1.4 2010/04/30 04:39:16 jruoho Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 30, 2010 -.Dt SIGRELSE 3 -.Os -.Sh NAME -.Nm sigrelse -.Nd manipulate current signal mask -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn sigrelse "int sig" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by -.Xr sigprocmask 2 . -.Ef -.Pp -The -.Fn sigrelse -function removes the signal -.Fa sig -from the calling process' signal mask. -.Sh RETURN VALUES -If successful, the -.Fn sigrelse -function returns 0. -Otherwise \-1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn sigrelse -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The argument -.Fa sig -is not a valid signal number. -.El -.Sh SEE ALSO -.Xr sigprocmask 2 , -.Xr sighold 3 -.Sh STANDARDS -The -.Fn sigrelse -function conforms to -.St -p1003.1-2001 . -It was however marked as obsolete in the -.St -p1003.1-2008 -revision of the standard. diff --git a/lib/libc/gen/sigrelse.c b/lib/libc/gen/sigrelse.c deleted file mode 100644 index 6a6643efc..000000000 --- a/lib/libc/gen/sigrelse.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: sigrelse.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sigrelse.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include "namespace.h" -#include -#include - -int -sigrelse(int sig) -{ - sigset_t set; - - sigemptyset(&set); - if (sigaddset(&set, sig) != 0) - return (-1); - - return (sigprocmask(SIG_UNBLOCK, &set, NULL)); -} diff --git a/lib/libc/gen/sigset.3 b/lib/libc/gen/sigset.3 deleted file mode 100644 index c5da28189..000000000 --- a/lib/libc/gen/sigset.3 +++ /dev/null @@ -1,125 +0,0 @@ -.\" $NetBSD: sigset.3,v 1.8 2010/04/30 06:48:20 wiz Exp $ -.\" -.\" Copyright (c) 2003 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 30, 2010 -.Dt SIGSET 3 -.Os -.Sh NAME -.Nm sigset -.Nd manipulate signal dispositions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.\" The following is Quite Ugly, but syntactically correct. Don't try to -.\" fix it. -.Ft void \*(lp* -.Fn sigset "int sig" "void \*(lp*disp\*(rp\*(lpint\*(rp\*(rp\*(rp\*(lpint" -.Sh DESCRIPTION -.Bf -symbolic -This interface is made obsolete by -.Xr sigaction 2 -and -.Xr sigprocmask 2 . -.Ef -.Pp -The -.Fn sigset -function manipulates the disposition of the signal -.Fa sig . -The new disposition is given in -.Fa disp . -.Pp -If -.Fa disp -is one of -.Dv SIG_DFL , -.Dv SIG_IGN , -or the address of a handler function, -the disposition of -.Fa sig -is changed accordingly, and -.Fa sig -is removed from the process' signal mask. -Also, if -.Fa disp -is the address of a handler function, -.Fa sig -will be added to the process' signal mask during execution of the handler. -.Pp -If -.Fa disp -is equal to -.Dv SIG_HOLD , -.Fa sig -is added to the calling process' signal mask and the disposition of -.Fa sig -remains unchanged. -.Sh RETURN VALUES -If successful, the -.Fn sigset -function returns -.Dv SIG_HOLD -if -.Fa sig -had been blocked, -and the previous disposition of -.Fa sig -if it had not been blocked. -Otherwise -.Dv SIG_ERR -is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Fn sigset -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The argument -.Fa sig -is not a valid signal number; -or an attempt is made to ignore a signal that cannot be ignored, -such as -.Dv SIGKILL -or -.Dv SIGSTOP . -.El -.Sh SEE ALSO -.Xr sigaction 2 , -.Xr sigprocmask 2 -.Sh STANDARDS -The -.Fn sigset -function conforms to -.St -p1003.1-2001 . -It was however marked as obsolete in the -.St -p1003.1-2008 -revision of the standard. diff --git a/lib/libc/gen/sigset.c b/lib/libc/gen/sigset.c deleted file mode 100644 index 466f41da1..000000000 --- a/lib/libc/gen/sigset.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: sigset.c,v 1.2 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sigset.c,v 1.2 2008/04/28 20:22:59 martin Exp $"); -#endif - -#include "namespace.h" -#include -#include -#include - -sig_t -sigset(int sig, void (*disp)(int)) -{ - sigset_t set, oset; - struct sigaction sa, osa; - - osa.sa_handler = SIG_ERR; - - if (disp == SIG_HOLD) { - /* Add sig to current signal mask. */ - if (sigemptyset(&set) != 0) - goto out; - if (sigaddset(&set, sig) != 0) - goto out; - if (sigprocmask(SIG_BLOCK, &set, &oset) != 0) - goto out; - - if (sigismember(&oset, sig)) { - /* Had been masked before, return SIG_HOLD. */ - osa.sa_handler = SIG_HOLD; - } else { - /* Return previous disposition. */ - (void)sigaction(sig, NULL, &osa); - } - } else if (disp == SIG_ERR) { - errno = EINVAL; - } else { - /* Set up and install new disposition. */ - sa.sa_handler = disp; - if (sigemptyset(&sa.sa_mask) != 0) - goto out; - sa.sa_flags = 0; - - if (sigaction(sig, &sa, &osa) != 0) { - osa.sa_handler = SIG_ERR; - goto out; - } - - /* Delete sig from current signal mask. */ - if (sigemptyset(&set) != 0) - return (SIG_ERR); - if (sigaddset(&set, sig) != 0) - return (SIG_ERR); - if (sigprocmask(SIG_UNBLOCK, &set, &oset) != 0) - return (SIG_ERR); - - /* If had been masked before, return SIG_HOLD. */ - if (sigismember(&oset, sig)) - osa.sa_handler = SIG_HOLD; - } - - out: - return (osa.sa_handler); -} diff --git a/lib/libc/gen/sigsetops.3 b/lib/libc/gen/sigsetops.3 deleted file mode 100644 index e97e130da..000000000 --- a/lib/libc/gen/sigsetops.3 +++ /dev/null @@ -1,124 +0,0 @@ -.\" $NetBSD: sigsetops.3,v 1.14 2003/08/07 16:42:57 agc Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)sigsetops.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt SIGSETOPS 3 -.Os -.Sh NAME -.Nm sigemptyset , -.Nm sigfillset , -.Nm sigaddset , -.Nm sigdelset , -.Nm sigismember -.Nd manipulate signal sets -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In signal.h -.Ft int -.Fn sigemptyset "sigset_t *set" -.Ft int -.Fn sigfillset "sigset_t *set" -.Ft int -.Fn sigaddset "sigset_t *set" "int signo" -.Ft int -.Fn sigdelset "sigset_t *set" "int signo" -.Ft int -.Fn sigismember "sigset_t *set" "int signo" -.Sh DESCRIPTION -These functions manipulate signal sets stored in a -.Fa sigset_t . -Either -.Fn sigemptyset -or -.Fn sigfillset -must be called for every object of type -.Fa sigset_t -before any other use of the object. -.Pp -The -.Fn sigemptyset -function initializes a signal set to be empty. -.Pp -The -.Fn sigfillset -function initializes a signal set to contain all signals. -.Pp -The -.Fn sigaddset -function adds the specified signal -.Fa signo -to the signal set. -.Pp -The -.Fn sigdelset -function deletes the specified signal -.Fa signo -from the signal set. -.Pp -The -.Fn sigismember -function returns whether a specified signal -.Fa signo -is contained in the signal set. -.Pp -.Fn sigemptyset -and -.Fn sigfillset -are provided as macros, but actual functions are available -if their names are undefined (with #undef -.Em name ) . -.Sh RETURN VALUES -The -.Fn sigismember -function returns 1 -if the signal is a member of the set, -a 0 otherwise. -The other functions return 0 upon success. -A \-1 return value -indicates an error occurred and the global variable -.Va errno -is set to indicate the reason. -.Sh ERRORS -These functions could fail if one of the following occurs: -.Bl -tag -width Er -.It Bq Er EINVAL -.Fa signo -has an invalid value. -.El -.Sh SEE ALSO -.Xr kill 2 , -.Xr sigaction 2 , -.Xr sigsuspend 2 , -.Xr signal 7 -.Sh STANDARDS -These functions conform to -.St -p1003.1-90 . diff --git a/lib/libc/gen/sigsetops.c b/lib/libc/gen/sigsetops.c deleted file mode 100644 index 5b227355a..000000000 --- a/lib/libc/gen/sigsetops.c +++ /dev/null @@ -1,46 +0,0 @@ -/* $NetBSD: sigsetops.c,v 1.16 2010/07/31 00:04:43 joerg Exp $ */ - -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)sigsetops.c 8.1 (Berkeley) 6/4/93 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sigsetops.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: sigsetops.c,v 1.16 2010/07/31 00:04:43 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#define __SIGSETOPS_BODY - -#include -#include diff --git a/lib/libc/gen/sleep.3 b/lib/libc/gen/sleep.3 deleted file mode 100644 index 9cf8e19a3..000000000 --- a/lib/libc/gen/sleep.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $NetBSD: sleep.3,v 1.15 2003/08/07 16:42:57 agc Exp $ -.\" -.\" Copyright (c) 1986, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sleep.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt SLEEP 3 -.Os -.Sh NAME -.Nm sleep -.Nd suspend process execution for interval of seconds -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft unsigned int -.Fn sleep "unsigned int seconds" -.Sh DESCRIPTION -The -.Fn sleep -function suspends execution of the calling process until either the -number of seconds specified by -.Fa seconds -have elapsed or a signal is delivered to the calling process and its -action is to invoke a signal-catching function or to terminate the -process. -The suspension time may be longer than requested due to the -scheduling of other activity by the system. -.Sh RETURN VALUES -If the -.Fn sleep -function returns because the requested time has elapsed, the value -returned will be zero. -If the -.Fn sleep -function returns due to the delivery of a signal, the value returned -will be the unslept amount (the request time minus the time actually -slept) in seconds. -.Sh SEE ALSO -.Xr nanosleep 2 , -.Xr usleep 3 -.Sh STANDARDS -The -.Fn sleep -function conforms to -.St -p1003.1-90 . -.Sh HISTORY -A -.Fn sleep -function appeared in -.At v7 . diff --git a/lib/libc/gen/sleep.c b/lib/libc/gen/sleep.c deleted file mode 100644 index abb60d398..000000000 --- a/lib/libc/gen/sleep.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: sleep.c,v 1.23 2012/06/25 22:32:44 abs Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sleep.c,v 1.23 2012/06/25 22:32:44 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(sleep,_sleep) -#endif - -unsigned int -sleep(unsigned int seconds) -{ - struct timespec rqt, rmt; - - rqt.tv_sec = seconds; - rqt.tv_nsec = 0; - - nanosleep(&rqt, &rmt); - - return (unsigned int)rmt.tv_sec; -} diff --git a/lib/libc/gen/stringlist.3 b/lib/libc/gen/stringlist.3 deleted file mode 100644 index 2eb83fc6a..000000000 --- a/lib/libc/gen/stringlist.3 +++ /dev/null @@ -1,144 +0,0 @@ -.\" $NetBSD: stringlist.3,v 1.15 2010/05/06 09:46:49 jruoho Exp $ -.\" -.\" Copyright (c) 1997, 1999 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This file was contributed to The NetBSD Foundation by Luke Mewburn. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd May 6, 2010 -.Dt STRINGLIST 3 -.Os -.Sh NAME -.Nm stringlist , -.Nm sl_init , -.Nm sl_add , -.Nm sl_free , -.Nm sl_find , -.Nm sl_delete -.Nd stringlist manipulation functions -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stringlist.h -.Ft StringList * -.Fn sl_init -.Ft int -.Fn sl_add "StringList *sl" "char *item" -.Ft void -.Fn sl_free "StringList *sl" "int freeall" -.Ft char * -.Fn sl_find "StringList *sl" "const char *item" -.Ft int -.Fn sl_delete "StringList *sl" "const char *item" "int freeit" -.Sh DESCRIPTION -The -.Nm -functions manipulate stringlists, which are lists of -strings that extend automatically if necessary. -.Pp -The -.Ar StringList -structure has the following definition: -.Bd -literal -offset indent -typedef struct _stringlist { - char **sl_str; - size_t sl_max; - size_t sl_cur; -} StringList; -.Ed -.Pp -where: -.Bl -tag -width "sl_str" -offset indent -.It Ar sl_str -is a pointer to the base of the array containing the list, -.It Ar sl_max -is the size of -.Ar sl_str , -and -.It Ar sl_cur -is the offset in -.Ar sl_str -of the current element. -.El -.Pp -The following stringlist manipulation functions are available: -.Bl -tag -width "sl_delete()" -offset 2n -.It Fn sl_init -Create a stringlist. -Returns a pointer to a -.Ar StringList , -or -.Dv NULL -in case of failure. -.It Fn sl_free -Releases memory occupied by -.Ar sl -and the -.Ar sl-\*[Gt]sl_str -array. -If -.Ar freeall -is non-zero, then each of the items within -.Ar sl-\*[Gt]sl_str -is released as well. -.It Fn sl_add -Add -.Ar item -to -.Ar sl-\*[Gt]sl_str -at -.Ar sl-\*[Gt]sl_cur , -extending the size of -.Ar sl-\*[Gt]sl_str . -Returns zero upon success, \-1 upon failure. -.It Fn sl_find -Find -.Ar item -in -.Ar sl , -returning -.Dv NULL -if it's not found. -.It Fn sl_delete -Remove -.Ar item -from the list. -If -.Ar freeit -is non-zero, the string is freed. -Returns -.Dv 0 -if the name is found -and -.Dv \-1 -if the name is not found. -.El -.Sh SEE ALSO -.Xr free 3 , -.Xr malloc 3 -.Sh HISTORY -The -.Nm -functions appeared in -.Nx 1.3 . diff --git a/lib/libc/gen/stringlist.c b/lib/libc/gen/stringlist.c deleted file mode 100644 index c86ff630c..000000000 --- a/lib/libc/gen/stringlist.c +++ /dev/null @@ -1,158 +0,0 @@ -/* $NetBSD: stringlist.c,v 1.14 2015/05/21 01:29:13 christos Exp $ */ - -/*- - * Copyright (c) 1994, 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: stringlist.c,v 1.14 2015/05/21 01:29:13 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(sl_add,_sl_add) -__weak_alias(sl_find,_sl_find) -__weak_alias(sl_free,_sl_free) -__weak_alias(sl_init,_sl_init) -__weak_alias(sl_delete,_sl_delete) -#endif - -#define _SL_CHUNKSIZE 20 - -/* - * sl_init(): Initialize a string list - */ -StringList * -sl_init(void) -{ - StringList *sl; - - sl = malloc(sizeof(StringList)); - if (sl == NULL) - return NULL; - - sl->sl_cur = 0; - sl->sl_max = _SL_CHUNKSIZE; - sl->sl_str = NULL; - errno = reallocarr(&sl->sl_str, sl->sl_max, sizeof(char *)); - if (errno) { - free(sl); - sl = NULL; - } - return sl; -} - - -/* - * sl_add(): Add an item to the string list - */ -int -sl_add(StringList *sl, char *name) -{ - - _DIAGASSERT(sl != NULL); - - if (sl->sl_cur == sl->sl_max - 1) { - char **new = sl->sl_str; - - errno = reallocarr(&new, (sl->sl_max + _SL_CHUNKSIZE), - sizeof(char *)); - if (errno) - return -1; - sl->sl_max += _SL_CHUNKSIZE; - sl->sl_str = new; - } - sl->sl_str[sl->sl_cur++] = name; - return 0; -} - - -/* - * sl_free(): Free a stringlist - */ -void -sl_free(StringList *sl, int all) -{ - size_t i; - - if (sl == NULL) - return; - if (sl->sl_str) { - if (all) - for (i = 0; i < sl->sl_cur; i++) - free(sl->sl_str[i]); - free(sl->sl_str); - } - free(sl); -} - - -/* - * sl_find(): Find a name in the string list - */ -char * -sl_find(StringList *sl, const char *name) -{ - size_t i; - - _DIAGASSERT(sl != NULL); - - for (i = 0; i < sl->sl_cur; i++) - if (strcmp(sl->sl_str[i], name) == 0) - return sl->sl_str[i]; - - return NULL; -} - -int -sl_delete(StringList *sl, const char *name, int all) -{ - size_t i, j; - - for (i = 0; i < sl->sl_cur; i++) - if (strcmp(sl->sl_str[i], name) == 0) { - if (all) - free(sl->sl_str[i]); - for (j = i + 1; j < sl->sl_cur; j++) - sl->sl_str[j - 1] = sl->sl_str[j]; - sl->sl_str[--sl->sl_cur] = NULL; - return 0; - } - return -1; -} - diff --git a/lib/libc/gen/sysconf.3 b/lib/libc/gen/sysconf.3 deleted file mode 100644 index 30bf56264..000000000 --- a/lib/libc/gen/sysconf.3 +++ /dev/null @@ -1,331 +0,0 @@ -.\" $NetBSD: sysconf.3,v 1.44 2015/08/20 11:05:39 wiz Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sysconf.3 8.3 (Berkeley) 4/19/94 -.\" -.Dd August 20, 2015 -.Dt SYSCONF 3 -.Os -.Sh NAME -.Nm sysconf -.Nd get configurable system variables -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft long -.Fn sysconf "int name" -.Sh DESCRIPTION -This interface is defined by -.St -p1003.1-88 . -A far more complete interface is available using -.Xr sysctl 3 . -.Pp -The -.Fn sysconf -function provides a method for applications to determine the current -value of a configurable system limit or option variable. -The -.Fa name -argument specifies the system variable to be queried. -Symbolic constants for each name value are found in the include file -.In unistd.h . -.Pp -The available values are as follows: -.Bl -tag -width "123456" -.It Li _SC_ARG_MAX -The maximum bytes of argument to -.Xr execve 2 . -.It Li _SC_ATEXIT_MAX -The maximum number of functions that may be registered with -.Xr atexit 3 . -.It Li _SC_BARRIERS -The version of -.St -p1003.1 -and its -Barriers -option to which the system attempts to conform, -otherwise \-1. -.It Li _SC_CLOCK_SELECTION -Return the -.Tn POSIX -version the implementation of the Clock Selection Option -on this system conforms to, -or \-1 if unavailable. -.It Li _SC_CHILD_MAX -The maximum number of simultaneous processes per user id. -.It Li _SC_CLK_TCK -The number of clock ticks per second. -.It Li _SC_FSYNC -Return 1 if the File Synchronization Option is available on this system, -otherwise \-1. -.It Li _SC_HOST_NAME_MAX -The maximum size of a hostname, including -.Dv NULL . -.It Li _SC_IOV_MAX -The maximum number of -.Va iovec -structures that a process has available for use with -.Xr preadv 2 , -.Xr pwritev 2 , -.Xr readv 2 , -.Xr recvmsg 2 , -.Xr sendmsg 2 -or -.Xr writev 2 . -.It Li _SC_JOB_CONTROL -Return 1 if job control is available on this system, otherwise \-1. -.It Li _SC_LOGIN_NAME_MAX -Returns the size of the storage required for a login name, in bytes, -including the terminating NUL. -.It Li _SC_MAPPED_FILES -Return 1 if the Memory Mapped Files Option is available on this system, -otherwise \-1. -.It Li _SC_MEMLOCK -Return 1 if the Process Memory Locking Option is available on this system, -otherwise \-1. -.It Li _SC_MEMLOCK_RANGE -Return 1 if the Range Memory Locking Option is available on this system, -otherwise \-1. -.It Li _SC_MEMORY_PROTECTION -Return 1 if the Memory Protection Option is available on this system, -otherwise \-1. -.It Li _SC_MONOTONIC_CLOCK -Return the -.Tn POSIX -version the implementation of the Monotonic Clock Option -on this system conforms to, -or \-1 if unavailable. -.It Li _SC_NGROUPS_MAX -The maximum number of supplemental groups. -.It Li _SC_OPEN_MAX -The maximum number of open files per process. -.It Li _SC_PAGESIZE -The size of a system page in bytes. -.It Li _SC_PASS_MAX -The maximum length of the password, not counting -.Dv NULL . -.It Li _SC_READER_WRITER_LOCKS -The version of -.St -p1003.1 -and its -Read-Write Locks -option to which the system attempts to conform, -otherwise \-1. -.It Li _SC_REGEXP -Return 1 if -.Tn POSIX -regular expressions are available on this system, otherwise \-1. -.It Li _SC_SEMAPHORES -The version of -.St -p1003.1 -and its -Semaphores -option to which the system attempts to conform, -otherwise \-1. -.It Li _SC_SHELL -Return 1 if -.Tn POSIX -shell is available on this system, otherwise \-1. -.It Li _SC_SPIN_LOCKS -The version of -.St -p1003.1 -and its -Spin Locks -option to which the system attempts to conform, -otherwise \-1. -.It Li _SC_STREAM_MAX -The minimum maximum number of streams that a process may have open -at any one time. -.It Li _SC_SYMLOOP_MAX -The maximum number of symbolic links that may be expanded in a path name. -.It Li _SC_SYNCHRONIZED_IO -Return 1 if the Synchronized I/O Option is available on this system, -otherwise \-1. -.It Li _SC_THREADS -The version of -.St -p1003.1 -and its -Threads -option to which the system attempts to conform, -otherwise \-1. -.It Li _SC_TIMERS -The version of -.St -p1003.1 -and its -Timers -option to which the system attempts to conform, -otherwise \-1. -.It Li _SC_TZNAME_MAX -The minimum maximum number of types supported for the name of a -timezone. -.It Li _SC_SAVED_IDS -Returns 1 if saved set-group and saved set-user ID is available, -otherwise \-1. -.It Li _SC_VERSION -The version of ISO/IEC 9945 (POSIX 1003.1) with which the system -attempts to comply. -.It Li _SC_XOPEN_SHM -Return 1 if the -.St -xpg4.2 -Shared Memory -option is available on this system, -otherwise \-1. -.Pp -Availability of the -Shared Memory -option depends on the -.Li SYSVSHM -kernel option. -.It Li _SC_BC_BASE_MAX -The maximum ibase/obase values in the -.Xr bc 1 -utility. -.It Li _SC_BC_DIM_MAX -The maximum array size in the -.Xr bc 1 -utility. -.It Li _SC_BC_SCALE_MAX -The maximum scale value in the -.Xr bc 1 -utility. -.It Li _SC_BC_STRING_MAX -The maximum string length in the -.Xr bc 1 -utility. -.It Li _SC_COLL_WEIGHTS_MAX -The maximum number of weights that can be assigned to any entry of -the LC_COLLATE order keyword in the locale definition file. -.It Li _SC_EXPR_NEST_MAX -The maximum number of expressions that can be nested within -parenthesis by the -.Xr expr 1 -utility. -.It Li _SC_LINE_MAX -The maximum length in bytes of a text-processing utility's input -line. -.It Li _SC_RE_DUP_MAX -The maximum number of repeated occurrences of a regular expression -permitted when using interval notation. -.It Li _SC_2_VERSION -The version of POSIX 1003.2 with which the system attempts to comply. -.It Li _SC_2_C_BIND -Return 1 if the system's C-language development facilities support the -C-Language Bindings Option, otherwise \-1. -.It Li _SC_2_C_DEV -Return 1 if the system supports the C-Language Development Utilities Option, -otherwise \-1. -.It Li _SC_2_CHAR_TERM -Return 1 if the system supports at least one terminal type capable of -all operations described in POSIX 1003.2, otherwise \-1. -.It Li _SC_2_FORT_DEV -Return 1 if the system supports the FORTRAN Development Utilities Option, -otherwise \-1. -.It Li _SC_2_FORT_RUN -Return 1 if the system supports the FORTRAN Runtime Utilities Option, -otherwise \-1. -.It Li _SC_2_LOCALEDEF -Return 1 if the system supports the creation of locales, otherwise \-1. -.It Li _SC_2_SW_DEV -Return 1 if the system supports the Software Development Utilities Option, -otherwise \-1. -.It Li _SC_2_UPE -Return 1 if the system supports the User Portability Utilities Option, -otherwise \-1. -.It Li _SC_GETGR_R_SIZE_MAX -The minimum size of the -.Fa buffer -passed to -.Xr getgrgid_r 3 -and -.Xr getgrnam_r 3 . -.It Li _SC_GETPW_R_SIZE_MAX -The minimum size of the -.Fa buffer -passed to -.Xr getpwnam_r 3 -and -.Xr getpwuid_r 3 . -.It Li _SC_NPROCESSORS_CONF -The number of processors configured. -.It Li _SC_NPROCESSORS_ONLN -The number of processors online (capable of running processes). -.It Li _SC_PHYS_PAGES -The amount of physical memory on the system in -.Li _SC_PAGESIZE -bytes. -.El -.Sh RETURN VALUES -If the call to -.Nm sysconf -is not successful, \-1 is returned and -.Va errno -is set appropriately. -Otherwise, if the variable is associated with functionality that is not -supported, \-1 is returned and -.Va errno -is not modified. -Otherwise, the current variable value is returned. -.Sh ERRORS -The -.Fn sysconf -function may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr sysctl 3 . -In addition, the following error may be reported: -.Bl -tag -width Er -.It Bq Er EINVAL -The value of the -.Fa name -argument is invalid. -.El -.Sh SEE ALSO -.Xr getconf 1 , -.Xr limits 3 , -.Xr sysctl 3 -.Sh STANDARDS -The -.Fn sysconf -function conforms to -.St -p1003.1-90 . -The constants -.Li _SC_NPROCESSORS_CONF -and -.Li _SC_NPROCESSORS_ONLN -are not part of the standard, but are provided by many systems. -.Sh HISTORY -The -.Nm sysconf -function first appeared in -.Bx 4.4 . -.Sh BUGS -The value for _SC_STREAM_MAX is a minimum maximum, and required to be -the same as ANSI C's FOPEN_MAX, so the returned value is a ridiculously -small and misleading number. diff --git a/lib/libc/gen/sysconf.c b/lib/libc/gen/sysconf.c deleted file mode 100644 index 3ff5d84fd..000000000 --- a/lib/libc/gen/sysconf.c +++ /dev/null @@ -1,428 +0,0 @@ -/* $NetBSD: sysconf.c,v 1.36 2013/12/19 19:11:50 rmind Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Sean Eric Fagan of Cygnus Support. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sysconf.c 8.2 (Berkeley) 3/20/94"; -#else -__RCSID("$NetBSD: sysconf.c,v 1.36 2013/12/19 19:11:50 rmind Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(sysconf,__sysconf) -#endif - -/* - * sysconf -- - * get configurable system variables. - * - * XXX - * POSIX 1003.1 (ISO/IEC 9945-1, 4.8.1.3) states that the variable values - * not change during the lifetime of the calling process. This would seem - * to require that any change to system limits kill all running processes. - * A workaround might be to cache the values when they are first retrieved - * and then simply return the cached value on subsequent calls. This is - * less useful than returning up-to-date values, however. - */ -long -sysconf(int name) -{ - struct rlimit rl; - size_t len; - uint64_t mem; - int mib[CTL_MAXNAME], value; - unsigned int mib_len; - struct clockinfo tmpclock; - static int clk_tck; - - len = sizeof(value); - - /* Default length of the MIB */ - mib_len = 2; - - switch (name) { - -/* 1003.1 */ - case _SC_ARG_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_ARGMAX; - break; - case _SC_CHILD_MAX: - return (getrlimit(RLIMIT_NPROC, &rl) ? -1 : (long)rl.rlim_cur); - case _O_SC_CLK_TCK: - /* - * For applications compiled when CLK_TCK was a compile-time - * constant. - */ - return 100; - case _SC_CLK_TCK: - /* - * Has to be handled specially because it returns a - * struct clockinfo instead of an integer. Also, since - * this might be called often by some things that - * don't grok CLK_TCK can be a macro expanding to a - * function, cache the value. - */ - if (clk_tck == 0) { - mib[0] = CTL_KERN; - mib[1] = KERN_CLOCKRATE; - len = sizeof(struct clockinfo); - clk_tck = sysctl(mib, 2, &tmpclock, &len, NULL, 0) - == -1 ? -1 : tmpclock.hz; - } - return(clk_tck); - case _SC_JOB_CONTROL: - mib[0] = CTL_KERN; - mib[1] = KERN_JOB_CONTROL; - goto yesno; - case _SC_NGROUPS_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_NGROUPS; - break; - case _SC_OPEN_MAX: - return (getrlimit(RLIMIT_NOFILE, &rl) ? -1 : (long)rl.rlim_cur); - case _SC_STREAM_MAX: - mib[0] = CTL_USER; - mib[1] = USER_STREAM_MAX; - break; - case _SC_TZNAME_MAX: - mib[0] = CTL_USER; - mib[1] = USER_TZNAME_MAX; - break; - case _SC_SAVED_IDS: - mib[0] = CTL_KERN; - mib[1] = KERN_SAVED_IDS; - goto yesno; - case _SC_VERSION: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX1; - break; - -/* 1003.1b */ - case _SC_PAGESIZE: - return _getpagesize(); - case _SC_FSYNC: - mib[0] = CTL_KERN; - mib[1] = KERN_FSYNC; - goto yesno; - case _SC_SYNCHRONIZED_IO: - mib[0] = CTL_KERN; - mib[1] = KERN_SYNCHRONIZED_IO; - goto yesno; - case _SC_MAPPED_FILES: - mib[0] = CTL_KERN; - mib[1] = KERN_MAPPED_FILES; - goto yesno; - case _SC_MEMLOCK: - mib[0] = CTL_KERN; - mib[1] = KERN_MEMLOCK; - goto yesno; - case _SC_MEMLOCK_RANGE: - mib[0] = CTL_KERN; - mib[1] = KERN_MEMLOCK_RANGE; - goto yesno; - case _SC_MEMORY_PROTECTION: - mib[0] = CTL_KERN; - mib[1] = KERN_MEMORY_PROTECTION; - goto yesno; - case _SC_MONOTONIC_CLOCK: - mib[0] = CTL_KERN; - mib[1] = KERN_MONOTONIC_CLOCK; - goto yesno; - case _SC_SEMAPHORES: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX_SEMAPHORES; - goto yesno; - case _SC_TIMERS: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX_TIMERS; - goto yesno; - -/* 1003.1c */ - case _SC_LOGIN_NAME_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_LOGIN_NAME_MAX; - break; - case _SC_THREADS: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX_THREADS; - goto yesno; - -/* 1003.1j */ - case _SC_BARRIERS: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX_BARRIERS; - goto yesno; - case _SC_SPIN_LOCKS: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX_SPIN_LOCKS; - goto yesno; - /* Historical; Threads option in 1003.1-2001 */ - case _SC_READER_WRITER_LOCKS: - mib[0] = CTL_KERN; - mib[1] = KERN_POSIX_READER_WRITER_LOCKS; - goto yesno; - -/* 1003.2 */ - case _SC_BC_BASE_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_BASE_MAX; - break; - case _SC_BC_DIM_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_DIM_MAX; - break; - case _SC_BC_SCALE_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_SCALE_MAX; - break; - case _SC_BC_STRING_MAX: - mib[0] = CTL_USER; - mib[1] = USER_BC_STRING_MAX; - break; - case _SC_COLL_WEIGHTS_MAX: - mib[0] = CTL_USER; - mib[1] = USER_COLL_WEIGHTS_MAX; - break; - case _SC_EXPR_NEST_MAX: - mib[0] = CTL_USER; - mib[1] = USER_EXPR_NEST_MAX; - break; - case _SC_LINE_MAX: - mib[0] = CTL_USER; - mib[1] = USER_LINE_MAX; - break; - case _SC_RE_DUP_MAX: - mib[0] = CTL_USER; - mib[1] = USER_RE_DUP_MAX; - break; - case _SC_2_VERSION: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_VERSION; - break; - case _SC_2_C_BIND: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_C_BIND; - goto yesno; - case _SC_2_C_DEV: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_C_DEV; - goto yesno; - case _SC_2_CHAR_TERM: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_CHAR_TERM; - goto yesno; - case _SC_2_FORT_DEV: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_FORT_DEV; - goto yesno; - case _SC_2_FORT_RUN: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_FORT_RUN; - goto yesno; - case _SC_2_LOCALEDEF: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_LOCALEDEF; - goto yesno; - case _SC_2_SW_DEV: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_SW_DEV; - goto yesno; - case _SC_2_UPE: - mib[0] = CTL_USER; - mib[1] = USER_POSIX2_UPE; - goto yesno; - -/* XPG 4.2 */ - case _SC_IOV_MAX: - mib[0] = CTL_KERN; - mib[1] = KERN_IOV_MAX; - break; - case _SC_XOPEN_SHM: - mib[0] = CTL_KERN; - mib[1] = KERN_SYSVIPC; - mib[2] = KERN_SYSVIPC_SHM; - mib_len = 3; - goto yesno; - -/* 1003.1-2001, XSI Option Group */ - case _SC_AIO_LISTIO_MAX: - if (sysctlgetmibinfo("kern.aio_listio_max", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - break; - case _SC_AIO_MAX: - if (sysctlgetmibinfo("kern.aio_max", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - break; - case _SC_ASYNCHRONOUS_IO: - if (sysctlgetmibinfo("kern.posix_aio", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - goto yesno; - case _SC_MESSAGE_PASSING: - if (sysctlgetmibinfo("kern.posix_msg", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - goto yesno; - case _SC_MQ_OPEN_MAX: - if (sysctlgetmibinfo("kern.mqueue.mq_open_max", &mib[0], - &mib_len, NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - break; - case _SC_MQ_PRIO_MAX: - if (sysctlgetmibinfo("kern.mqueue.mq_prio_max", &mib[0], - &mib_len, NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - break; - case _SC_PRIORITY_SCHEDULING: - if (sysctlgetmibinfo("kern.posix_sched", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - goto yesno; - case _SC_ATEXIT_MAX: - mib[0] = CTL_USER; - mib[1] = USER_ATEXIT_MAX; - break; - -/* 1003.1-2001, TSF */ - case _SC_GETGR_R_SIZE_MAX: - return _GETGR_R_SIZE_MAX; - case _SC_GETPW_R_SIZE_MAX: - return _GETPW_R_SIZE_MAX; - -/* Unsorted */ - case _SC_HOST_NAME_MAX: - return MAXHOSTNAMELEN; - case _SC_PASS_MAX: - return _PASSWORD_LEN; - case _SC_REGEXP: - return _POSIX_REGEXP; - case _SC_SHARED_MEMORY_OBJECTS: - return _POSIX_SHARED_MEMORY_OBJECTS; - case _SC_SHELL: - return _POSIX_SHELL; -#ifndef __minix - case _SC_SPAWN: - return _POSIX_SPAWN; -#endif /* !__minix */ - case _SC_SYMLOOP_MAX: - return MAXSYMLINKS; - -yesno: if (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1) - return (-1); - if (value == 0) - return (-1); - return (value); - -/* Extensions */ - case _SC_NPROCESSORS_CONF: - mib[0] = CTL_HW; - mib[1] = HW_NCPU; - break; - case _SC_NPROCESSORS_ONLN: - mib[0] = CTL_HW; - mib[1] = HW_NCPUONLINE; - break; - -/* Linux/Solaris */ - case _SC_PHYS_PAGES: - len = sizeof(mem); - mib[0] = CTL_HW; - mib[1] = HW_PHYSMEM64; - return sysctl(mib, 2, &mem, &len, NULL, 0) == -1 ? -1 : - (long)(mem / _getpagesize()); - -/* Native */ - case _SC_SCHED_RT_TS: - if (sysctlgetmibinfo("kern.sched.rtts", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - break; - case _SC_SCHED_PRI_MIN: - if (sysctlgetmibinfo("kern.sched.pri_min", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - break; - case _SC_SCHED_PRI_MAX: - if (sysctlgetmibinfo("kern.sched.pri_max", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) - return -1; - break; - case _SC_THREAD_DESTRUCTOR_ITERATIONS: - return _POSIX_THREAD_DESTRUCTOR_ITERATIONS; - case _SC_THREAD_KEYS_MAX: - return _POSIX_THREAD_KEYS_MAX; - case _SC_THREAD_STACK_MIN: - return _getpagesize(); - case _SC_THREAD_THREADS_MAX: - if (sysctlgetmibinfo("kern.maxproc", &mib[0], &mib_len, - NULL, NULL, NULL, SYSCTL_VERSION)) /* XXX */ - return -1; - goto yesno; - case _SC_THREAD_ATTR_STACKADDR: - return _POSIX_THREAD_ATTR_STACKADDR; - case _SC_THREAD_ATTR_STACKSIZE: - return _POSIX_THREAD_ATTR_STACKSIZE; - case _SC_THREAD_SAFE_FUNCTIONS: - return _POSIX_THREAD_SAFE_FUNCTIONS; - case _SC_THREAD_PRIORITY_SCHEDULING: - case _SC_THREAD_PRIO_INHERIT: - case _SC_THREAD_PRIO_PROTECT: - case _SC_THREAD_PROCESS_SHARED: - return -1; - case _SC_TTY_NAME_MAX: - return pathconf(_PATH_DEV, _PC_NAME_MAX); - default: - errno = EINVAL; - return (-1); - } - return (sysctl(mib, mib_len, &value, &len, NULL, 0) == -1 ? -1 : value); -} diff --git a/lib/libc/gen/sysctl.3 b/lib/libc/gen/sysctl.3 deleted file mode 100644 index 2fd2c12bf..000000000 --- a/lib/libc/gen/sysctl.3 +++ /dev/null @@ -1,739 +0,0 @@ -.\" $NetBSD: sysctl.3,v 1.202 2014/06/13 22:05:15 wiz Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)sysctl.3 8.4 (Berkeley) 5/9/95 -.\" -.Dd June 13, 2014 -.Dt SYSCTL 3 -.Os -.Sh NAME -.Nm sysctl , -.Nm sysctlbyname , -.Nm sysctlgetmibinfo , -.Nm sysctlnametomib , -.Nm asysctl , -.Nm asysctlbyname -.Nd get or set system information -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/param.h -.In sys/sysctl.h -.Ft int -.Fn sysctl "const int *name" "u_int namelen" "void *oldp" "size_t *oldlenp" \ -"const void *newp" "size_t newlen" -.Ft int -.Fn sysctlbyname "const char *sname" "void *oldp" "size_t *oldlenp" \ -"const void *newp" "size_t newlen" -.Ft int -.Fn sysctlgetmibinfo "const char *sname" "int *name" "u_int *namelenp" \ -"char *cname" "size_t *csz" "struct sysctlnode **rnode" "int v" -.Ft int -.Fn sysctlnametomib "const char *sname" "int *name" "size_t *namelenp" -.Ft void * -.Fn asysctl "const int *name" "size_t namelen" "size_t *len" -.Ft void * -.Fn asysctlbyname "const char *sname" "size_t *len" -.Sh DESCRIPTION -The -.Nm -function retrieves system information and allows processes with -appropriate privileges to set system information. -The information available from -.Nm -consists of integers, strings, and tables. -Information may be retrieved and set from the command interface -using the -.Xr sysctl 8 -utility. -.Pp -Unless explicitly noted below, -.Nm -returns a consistent snapshot of the data requested. -Consistency is obtained by locking the destination -buffer into memory so that the data may be copied out without blocking. -Calls to -.Nm -are serialized to avoid deadlock. -.Pp -The state is described using a ``Management Information Base'' (MIB) -style name, listed in -.Fa name , -which is a -.Fa namelen -length array of integers. -.Pp -The -.Fn sysctlbyname -function accepts a string representation of a MIB entry and internally -maps it to the appropriate numeric MIB representation. -Its semantics are otherwise no different from -.Fn sysctl . -.Pp -The information is copied into the buffer specified by -.Fa oldp . -The size of the buffer is given by the location specified by -.Fa oldlenp -before the call, -and that location gives the amount of data copied after a successful call. -If the amount of data available is greater -than the size of the buffer supplied, -the call supplies as much data as fits in the buffer provided -and returns with the error code ENOMEM. -If the old value is not desired, -.Fa oldp -and -.Fa oldlenp -should be set to -.Dv NULL . -.Pp -The size of the available data can be determined by calling -.Nm -with a -.Dv NULL -parameter for -.Fa oldp . -The size of the available data will be returned in the location pointed to by -.Fa oldlenp . -For some operations, the amount of space may change often. -For these operations, -the system attempts to round up so that the returned size is -large enough for a call to return the data shortly thereafter. -.Pp -To set a new value, -.Fa newp -is set to point to a buffer of length -.Fa newlen -from which the requested value is to be taken. -If a new value is not to be set, -.Fa newp -should be set to -.Dv NULL -and -.Fa newlen -set to 0. -.Pp -The -.Fn sysctlnametomib -function can be used to map the string representation of a MIB entry -to the numeric version. -The -.Fa name -argument should point to an array of integers large enough to hold the -MIB, and -.Fa namelenp -should indicate the number of integer slots available. -Following a successful translation, the size_t indicated by -.Fa namelenp -will be changed to show the number of slots consumed. -.Pp -The -.Fn sysctlgetmibinfo -function performs name translation similar to -.Fn sysctlnametomib , -but also canonicalizes the name (or returns the first erroneous token -from the string being parsed) into the space indicated by -.Fa cname -and -.Fa csz . -.Fa csz -should indicate the size of the buffer pointed to by -.Fa cname -and on return, will indicate the size of the returned string including -the trailing -.Sq nul -character. -.Pp -The -.Fa rnode -and -.Fa v -arguments to -.Fn sysctlgetmibinfo -are used to provide a tree for it to parse into, and to get back -either a pointer to, or a copy of, the terminal node. -If -.Fa rnode -is -.Dv NULL , -.Fn sysctlgetmibinfo -uses its own internal tree for parsing, and checks it against the -kernel at each call, to make sure that the name-to-number mapping is -kept up to date. -The -.Fa v -argument is ignored in this case. -If -.Fa rnode -is not -.Dv NULL -but the pointer it references is, on a successful return, -.Fa rnode -will be adjusted to point to a copy of the terminal node. -The -.Fa v -argument indicates which version of the -.Nm -node structure the caller wants. -The application must later -.Fn free -this copy. -If neither -.Fa rnode -nor the pointer it references are -.Dv NULL , -the pointer is used as the address of a tree over which the parsing is -done. -In this last case, the tree is not checked against the kernel, no -refreshing of the mappings is performed, and the value given by -.Fa v -must agree with the version indicated by the tree. -It is recommended that applications always use -.Dv SYSCTL_VERSION -as the value for -.Fa v , -as defined in the include file -.Pa sys/sysctl.h . -.Pp -The numeric and text names of sysctl variables are described in -.Xr sysctl 7 . -The numeric names are defined as preprocessor macros. -The top level names are defined with a CTL_ prefix in -.In sys/sysctl.h . -The next and subsequent levels down have different prefixes for each -subtree. -.Pp -For example, the following retrieves the maximum number of processes allowed -in the system - the -.Li kern.maxproc -variable: -.Bd -literal -offset indent -compact -int mib[2], maxproc; -size_t len; -.sp -mib[0] = CTL_KERN; -mib[1] = KERN_MAXPROC; -len = sizeof(maxproc); -sysctl(mib, 2, \*[Am]maxproc, \*[Am]len, NULL, 0); -.Ed -.sp -To retrieve the standard search path for the system utilities - -.Li user.cs_path : -.Bd -literal -offset indent -compact -int mib[2]; -size_t len; -char *p; -.sp -mib[0] = CTL_USER; -mib[1] = USER_CS_PATH; -sysctl(mib, 2, NULL, \*[Am]len, NULL, 0); -p = malloc(len); -sysctl(mib, 2, p, \*[Am]len, NULL, 0); -.Ed -.Pp -The -.Fn asysctl -and -.Fn asysctlbyname -functions are wrappers for -.Fn sysctl -and -.Fn sysctlbyname . -They return memory allocated with -.Xr malloc 3 -and resize the buffer in a loop until all data fits. -.Sh DYNAMIC OPERATIONS -Several meta-identifiers are provided to perform operations on the -.Nm -tree itself, or support alternate means of accessing the data -instrumented by the -.Nm -tree. -.Bl -column CTLXCREATESYMXXX -.It Sy Name Description -.It CTL\_QUERY Retrieve a mapping of names to numbers below a given node -.It CTL\_CREATE Create a new node -.It CTL\_CREATESYM Create a new node by its kernel symbol -.It CTL\_DESTROY Destroy a node -.It CTL\_DESCRIBE Retrieve node descriptions -.El -.Pp -The core interface to all of these meta-functions is the structure -that the kernel uses to describe the tree internally, as defined in -.In sys/sysctl.h -as: -.Pp -.Bd -literal -struct sysctlnode { - uint32_t sysctl_flags; /* flags and type */ - int32_t sysctl_num; /* mib number */ - char sysctl_name[SYSCTL_NAMELEN]; /* node name */ - uint32_t sysctl_ver; /* node's version vs. rest of tree */ - uint32_t __rsvd; - union { - struct { - uint32_t suc_csize; /* size of child node array */ - uint32_t suc_clen; /* number of valid children */ - struct sysctlnode* suc_child; /* array of child nodes */ - } scu_child; - struct { - void *sud_data; /* pointer to external data */ - size_t sud_offset; /* offset to data */ - } scu_data; - int32_t scu_alias; /* node this node refers to */ - int32_t scu_idata; /* immediate "int" data */ - u_quad_t scu_qdata; /* immediate "u_quad_t" data */ - } sysctl_un; - size_t _sysctl_size; /* size of instrumented data */ - sysctlfn _sysctl_func; /* access helper function */ - struct sysctlnode *sysctl_parent; /* parent of this node */ - const char *sysctl_desc; /* description of node */ -}; - -#define sysctl_csize sysctl_un.scu_child.suc_csize -#define sysctl_clen sysctl_un.scu_child.suc_clen -#define sysctl_child sysctl_un.scu_child.suc_child -#define sysctl_data sysctl_un.scu_data.sud_data -#define sysctl_offset sysctl_un.scu_data.sud_offset -#define sysctl_alias sysctl_un.scu_alias -#define sysctl_idata sysctl_un.scu_idata -#define sysctl_qdata sysctl_un.scu_qdata -.Ed -.Pp -Querying the tree to discover the name to number mapping permits -dynamic discovery of all the data that the tree currently has -instrumented. -For example, to discover all the nodes below the -CTL_VFS node: -.Pp -.Bd -literal -offset indent -compact -struct sysctlnode query, vfs[128]; -int mib[2]; -size_t len; -.sp -mib[0] = CTL_VFS; -mib[1] = CTL_QUERY; -memset(\*[Am]query, 0, sizeof(query)); -query.sysctl_flags = SYSCTL_VERSION; -len = sizeof(vfs); -sysctl(mib, 2, \*[Am]vfs[0], \*[Am]len, \*[Am]query, sizeof(query)); -.Ed -.Pp -Note that a reference to an empty node with -.Fa sysctl_flags -set to -.Dv SYSCTL_VERSION -is passed to sysctl in order to indicate the version that the program -is using. -All dynamic operations passing nodes into sysctl require that the -version be explicitly specified. -.Pp -Creation and destruction of nodes works by constructing part of a new -node description (or a description of the existing node) and invoking -CTL_CREATE (or CTL_CREATESYM) or CTL_DESTROY at the parent of the new -node, with a pointer to the new node passed via the -.Fa new -and -.Fa newlen -arguments. -If valid values for -.Fa old -and -.Fa oldlenp -are passed, a copy of the new node once in the tree will be returned. -If the create operation fails because a node with the same name or MIB -number exists, a copy of the conflicting node will be returned. -.Pp -The minimum requirements for creating a node are setting the -.Fa sysctl_flags -to indicate the new node's type, -.Fa sysctl_num -to either the new node's number (or CTL_CREATE or CTL_CREATESYM if a -dynamically allocated MIB number is acceptable), -.Fa sysctl_size -to the size of the data to be instrumented (which must agree with the -given type), and -.Fa sysctl_name -must be set to the new node's name. -Nodes that are not of type -.Dq node -must also have some description of the data to be instrumented, which -will vary depending on what is to be instrumented. -.Pp -If existing kernel data is to be covered by this new node, its address -should be given in -.Fa sysctl_data -or, if CTL_CREATESYM is used, -.Fa sysctl_data -should be set to a string containing its name from the kernel's symbol -table. -If new data is to be instrumented and an initial value is available, -the new integer or quad type data should be placed into either -.Fa sysctl_idata -or -.Fa sysctl_qdata , -respectively, along with the SYSCTL_IMMEDIATE flag being set, or -.Fa sysctl_data -should be set to point to a copy of the new data, and the -SYSCTL_OWNDATA flag must be set. -This latter method is the only way that new string and struct type -nodes can be initialized. -Invalid kernel addresses are accepted, but any attempt to access those -nodes will return an error. -.Pp -The -.Fa sysctl_csize , -.Fa sysctl_clen , -.Fa sysctl_child , -.Fa sysctl_parent , -and -.Fa sysctl_alias -members are used by the kernel to link the tree together and must be -.Dv NULL -or 0. -Nodes created in this manner cannot have helper functions, so -.Fa sysctl_func -must also be -.Dv NULL . -If the -.Fa sysctl_ver -member is non-zero, it must match either the version of the parent or -the version at the root of the MIB or an error is returned. -This can be used to ensure that nodes are only added or removed from a -known state of the tree. -Note: It may not be possible to determine the version at the root -of the tree. -.Pp -This example creates a new subtree and adds a node to it that controls the -.Fa audiodebug -kernel variable, thereby making it tunable at at any time, without -needing to use -.Xr ddb 4 -or -.Xr kvm 3 -to alter the kernel's memory directly. -.Pp -.Bd -literal -offset indent -compact -struct sysctlnode node; -int mib[2]; -size_t len; -.sp -mib[0] = CTL_CREATE; /* create at top-level */ -len = sizeof(node); -memset(\*[Am]node, 0, len); -node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_NODE; -snprintf(node.sysctl_name, sizeof(node.sysctl_name), "local"); -node.sysctl_num = CTL_CREATE; /* request dynamic MIB number */ -sysctl(\*[Am]mib[0], 1, \*[Am]node, \*[Am]len, \*[Am]node, len); -.sp -mib[0] = node.sysctl_num; /* use new MIB number */ -mib[1] = CTL_CREATESYM; /* create at second level */ -len = sizeof(node); -memset(\*[Am]node, 0, len); -node.sysctl_flags = SYSCTL_VERSION|CTLFLAG_READWRITE|CTLTYPE_INT; -snprintf(node.sysctl_name, sizeof(node.sysctl_name), "audiodebug"); -node.sysctl_num = CTL_CREATE; -node.sysctl_data = "audiodebug"; /* kernel symbol to be used */ -sysctl(\*[Am]mib[0], 2, NULL, NULL, \*[Am]node, len); -.Ed -.Pp -The process for deleting nodes is similar, but less data needs to -be supplied. -Only the -.Fa sysctl_num -field -needs to be filled in; almost all other fields must be left blank. -The -.Fa sysctl_name -and/or -.Fa sysctl_ver -fields can be filled in with the name and version of the existing node -as additional checks on what will be deleted. -If all the given data fail to match any node, nothing will be deleted. -If valid values for -.Fa old -and -.Fa oldlenp -are supplied and a node is deleted, a copy of what was in the MIB tree -will be returned. -.Pp -This sample code shows the deletion of the two nodes created in the -above example: -.Pp -.Bd -literal -offset indent -compact -int mib[2]; -.sp -len = sizeof(node); -memset(\*[Am]node, 0, len); -node.sysctl_flags = SYSCTL_VERSION; -.sp -mib[0] = 3214; /* assumed number for "local" */ -mib[1] = CTL_DESTROY; -node.sysctl_num = 3215; /* assumed number for "audiodebug" */ -sysctl(\*[Am]mib[0], 2, NULL, NULL, \*[Am]node, len); -.sp -mib[0] = CTL_DESTROY; -node.sysctl_num = 3214; /* now deleting "local" */ -sysctl(\*[Am]mib[0], 1, NULL, NULL, \*[Am]node, len); -.Ed -.Pp -Descriptions of each of the nodes can also be retrieved, if they are -available. -Descriptions can be retrieved in bulk at each level or on a per-node -basis. -The layout of the buffer into which the descriptions are returned is a -series of variable length structures, each of which describes its own -size. -The length indicated includes the terminating -.Sq nul -character. -Nodes that have no description or where the description is not -available are indicated by an empty string. -The -.Fa descr_ver -will match the -.Fa sysctl_ver -value for a given node, so that descriptions for nodes whose number -have been recycled can be detected and ignored or discarded. -.Pp -.Bd -literal -struct sysctldesc { - int32_t descr_num; /* mib number of node */ - uint32_t descr_ver; /* version of node */ - uint32_t descr_len; /* length of description string */ - char descr_str[1]; /* not really 1...see above */ -}; -.Ed -.Pp -The -.Fn NEXT_DESCR -macro can be used to skip to the next description in the retrieved -list. -.Pp -.Bd -literal -offset indent -compact -struct sysctlnode desc; -struct sysctldesc *d; -char buf[1024]; -int mib[2]; -size_t len; -.sp -/* retrieve kern-level descriptions */ -mib[0] = CTL_KERN; -mib[1] = CTL_DESCRIBE; -d = (struct sysctldesc *)\*[Am]buf[0]; -len = sizeof(buf); -sysctl(mib, 2, d, \*[Am]len, NULL, 0); -while ((caddr_t)d \*[Lt] (caddr_t)\*[Am]buf[len]) { - printf("node %d: %.*s\\n", d-\*[Gt]descr_num, d-\*[Gt]descr_len, - d-\*[Gt]descr_str); - d = NEXT_DESCR(d); -} -.sp -/* retrieve description for kern.securelevel */ -memset(\*[Am]desc, 0, sizeof(desc)); -desc.sysctl_flags = SYSCTL_VERSION; -desc.sysctl_num = KERN_SECURELEVEL; -d = (struct sysctldesc *)\*[Am]buf[0]; -len = sizeof(buf); -sysctl(mib, 2, d, \*[Am]len, \*[Am]desc, sizeof(desc)); -printf("kern.securelevel: %.*s\\n", d-\*[Gt]descr_len, d-\*[Gt]descr_str); -.Ed -.Pp -Descriptions can also be set as follows, subject to the following rules: -.Pp -.Bl -bullet -compact -.It -The kernel securelevel is at zero or lower -.It -The caller has super-user privileges -.It -The node does not currently have a description -.It -The node is not marked as -.Dq permanent -.El -.Pp -.Bd -literal -offset indent -compact -struct sysctlnode desc; -int mib[2]; -.sp -/* presuming the given top-level node was just added... */ -mib[0] = 3214; /* mib numbers taken from previous examples */ -mib[1] = CTL_DESCRIBE; -memset(\*[Am]desc, 0, sizeof(desc)); -desc.sysctl_flags = SYSCTL_VERSION; -desc.sysctl_num = 3215; -desc.sysctl_desc = "audio debug control knob"; -sysctl(mib, 2, NULL, NULL, \*[Am]desc, sizeof(desc)); -.Ed -.Pp -Upon successfully setting a description, the new description will be -returned in the space indicated by the -.Fa oldp -and -.Fa oldlenp -arguments. -.Pp -The -.Fa sysctl_flags -field in the struct sysctlnode contains the sysctl version, node type -information, and a number of flags. -The macros -.Fn SYSCTL_VERS , -.Fn SYSCTL_TYPE , -and -.Fn SYSCTL_FLAGS -can be used to access the different fields. -Valid flags are: -.Bl -column CTLFLAGXPERMANENTXXX -.It Sy Name Description -.It CTLFLAG\_READONLY Node is read-only -.It CTLFLAG\_READWRITE Node is writable by the superuser -.It CTLFLAG\_ANYWRITE Node is writable by anyone -.It CTLFLAG\_PRIVATE Node is readable only by the superuser -.It CTLFLAG\_PERMANENT Node cannot be removed (cannot be set by -processes) -.It CTLFLAG\_OWNDATA Node owns data and does not instrument -existing data -.It CTLFLAG\_IMMEDIATE Node contains instrumented data and does not -instrument existing data -.It CTLFLAG\_HEX Node's contents should be displayed in a hexadecimal -form -.It CTLFLAG\_ROOT Node is the root of a tree (cannot be set at -any time) -.It CTLFLAG\_ANYNUMBER Node matches any MIB number (cannot be set by -processes) -.It CTLFLAG\_HIDDEN Node not displayed by default -.It CTLFLAG\_ALIAS Node refers to a sibling node (cannot be set -by processes) -.It CTLFLAG\_OWNDESC Node owns its own description string space -.El -.Sh RETURN VALUES -If the call to -.Nm -is successful, 0 is returned. -Otherwise \-1 is returned and -.Va errno -is set appropriately. -.Sh FILES -.Bl -tag -width \*[Lt]netinet6/udp6Xvar.h\*[Gt] -compact -.It Aq Pa sys/sysctl.h -definitions for top level identifiers, second level kernel and hardware -identifiers, and user level identifiers -.It Aq Pa sys/socket.h -definitions for second level network identifiers -.It Aq Pa sys/gmon.h -definitions for third level profiling identifiers -.It Aq Pa uvm/uvm_param.h -definitions for second level virtual memory identifiers -.It Aq Pa netinet/in.h -definitions for third level IPv4/v6 identifiers and -fourth level IPv4/v6 identifiers -.It Aq Pa netinet/icmp_var.h -definitions for fourth level ICMP identifiers -.It Aq Pa netinet/icmp6.h -definitions for fourth level ICMPv6 identifiers -.It Aq Pa netinet/tcp_var.h -definitions for fourth level TCP identifiers -.It Aq Pa netinet/udp_var.h -definitions for fourth level UDP identifiers -.It Aq Pa netinet6/udp6_var.h -definitions for fourth level IPv6 UDP identifiers -.It Aq Pa netinet6/ipsec.h -definitions for fourth level IPsec identifiers -.It Aq Pa netkey/key_var.h -definitions for third level PF_KEY identifiers -.It Aq Pa machine/cpu.h -definitions for second level machdep identifiers -.El -.Sh ERRORS -The following errors may be reported: -.Bl -tag -width Er -.It Bq Er EFAULT -The buffer -.Fa name , -.Fa oldp , -.Fa newp , -or length pointer -.Fa oldlenp -contains an invalid address, or the requested value is temporarily -unavailable. -.It Bq Er EINVAL -The -.Fa name -array is zero or greater than -.Dv CTL_MAXNAME ; -or a non-null -.Fa newp -is given and its specified length in -.Fa newlen -is too large or too small, or the given value is not acceptable for -the given node. -.It Bq Er EISDIR -The -.Fa name -array specifies an intermediate rather than terminal name. -.It Bq Er ENOENT -The -.Fa name -array specifies a node that does not exist in the tree; -or an attempt was made to destroy a node that does not exist, or to -create or destroy a node below a node that does not exist. -.It Bq Er ENOMEM -The length pointed to by -.Fa oldlenp -is too short to hold the requested value. -.It Bq Er ENOTDIR -The -.Fa name -array specifies a node below a node that addresses data. -.It Bq Er ENOTEMPTY -An attempt was made to destroy a node that still has children. -.It Bq Er EOPNOTSUPP -The -.Fa name -array specifies a value that is unknown or a meta-operation was -attempted that the requested node does not support. -.It Bq Er EPERM -An attempt is made to set a read-only value; or -a process without appropriate privilege attempts to set a value or to -create or destroy a node; or -an attempt to change a value protected by the current kernel security -level is made. -.El -.Sh SEE ALSO -.Xr sysctl 7 , -.Xr sysctl 8 , -.Xr secmodel_securelevel 9 -.\" .Xr sysctl 9 -.Sh HISTORY -The -.Nm -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/sysctl.c b/lib/libc/gen/sysctl.c deleted file mode 100644 index 11e5d102c..000000000 --- a/lib/libc/gen/sysctl.c +++ /dev/null @@ -1,391 +0,0 @@ -/* $NetBSD: sysctl.c,v 1.35 2015/02/05 16:05:20 christos Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sysctl.c 8.2 (Berkeley) 1/4/94"; -#else -__RCSID("$NetBSD: sysctl.c,v 1.35 2015/02/05 16:05:20 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#define __COMPAT_SYSCTL -#include - -#include -#include -#include -#include -#include -#include -#include "extern.h" - -#ifdef __weak_alias -__weak_alias(sysctl,_sysctl) -#endif - -/* - * handles requests off the user subtree - */ -static int user_sysctl(const int *, u_int, void *, size_t *, - const void *, size_t); - -/* - * copies out individual nodes taking target version into account - */ -static size_t __cvt_node_out(uint, const struct sysctlnode *, void **, - size_t *); - -#include - -int -sysctl(const int *name, unsigned int namelen, - void *oldp, size_t *oldlenp, - const void *newp, size_t newlen) -{ - size_t oldlen, savelen; - int error; - - if (name[0] != CTL_USER) - return (__sysctl(name, namelen, oldp, oldlenp, - newp, newlen)); - - oldlen = (oldlenp == NULL) ? 0 : *oldlenp; - savelen = oldlen; - error = user_sysctl(name + 1, namelen - 1, oldp, &oldlen, newp, newlen); - - if (error != 0) { - errno = error; - return (-1); - } - - if (oldlenp != NULL) { - *oldlenp = oldlen; - if (oldp != NULL && oldlen > savelen) { - errno = ENOMEM; - return (-1); - } - } - - return (0); -} - -static int -user_sysctl(const int *name, unsigned int namelen, - void *oldp, size_t *oldlenp, - const void *newp, size_t newlen) -{ -#define _INT(s, n, v, d) { \ - .sysctl_flags = CTLFLAG_IMMEDIATE|CTLFLAG_PERMANENT| \ - CTLTYPE_INT|SYSCTL_VERSION, \ - .sysctl_size = sizeof(int), \ - .sysctl_name = (s), \ - .sysctl_num = (n), \ - .sysctl_un.scu_idata = (v), \ - .sysctl_desc = (d), \ - } - - /* - * the nodes under the "user" node - */ - static const struct sysctlnode sysctl_usermib[] = { -#if defined(lint) - /* - * lint doesn't like my initializers - */ - 0 -#else /* !lint */ - { - .sysctl_flags = SYSCTL_VERSION|CTLFLAG_PERMANENT| - CTLTYPE_STRING, - .sysctl_size = sizeof(_PATH_STDPATH), - .sysctl_name = "cs_path", - .sysctl_num = USER_CS_PATH, - .sysctl_data = __UNCONST(_PATH_STDPATH), - .sysctl_desc = __UNCONST( - "A value for the PATH environment variable " - "that finds all the standard utilities"), - }, - _INT("bc_base_max", USER_BC_BASE_MAX, BC_BASE_MAX, - "The maximum ibase/obase values in the bc(1) utility"), - _INT("bc_dim_max", USER_BC_DIM_MAX, BC_DIM_MAX, - "The maximum array size in the bc(1) utility"), - _INT("bc_scale_max", USER_BC_SCALE_MAX, BC_SCALE_MAX, - "The maximum scale value in the bc(1) utility"), - _INT("bc_string_max", USER_BC_STRING_MAX, BC_STRING_MAX, - "The maximum string length in the bc(1) utility"), - _INT("coll_weights_max", USER_COLL_WEIGHTS_MAX, - COLL_WEIGHTS_MAX, "The maximum number of weights that can " - "be assigned to any entry of the LC_COLLATE order keyword " - "in the locale definition file"), - _INT("expr_nest_max", USER_EXPR_NEST_MAX, EXPR_NEST_MAX, - "The maximum number of expressions that can be nested " - "within parenthesis by the expr(1) utility"), - _INT("line_max", USER_LINE_MAX, LINE_MAX, "The maximum length " - "in bytes of a text-processing utility's input line"), - _INT("re_dup_max", USER_RE_DUP_MAX, RE_DUP_MAX, "The maximum " - "number of repeated occurrences of a regular expression " - "permitted when using interval notation"), - _INT("posix2_version", USER_POSIX2_VERSION, _POSIX2_VERSION, - "The version of POSIX 1003.2 with which the system " - "attempts to comply"), -#ifdef _POSIX2_C_BIND - _INT("posix2_c_bind", USER_POSIX2_C_BIND, 1, - "Whether the system's C-language development facilities " - "support the C-Language Bindings Option"), -#else - _INT("posix2_c_bind", USER_POSIX2_C_BIND, 0, - "Whether the system's C-language development facilities " - "support the C-Language Bindings Option"), -#endif -#ifdef POSIX2_C_DEV - _INT("posix2_c_dev", USER_POSIX2_C_DEV, 1, - "Whether the system supports the C-Language Development " - "Utilities Option"), -#else - _INT("posix2_c_dev", USER_POSIX2_C_DEV, 0, - "Whether the system supports the C-Language Development " - "Utilities Option"), -#endif -#ifdef POSIX2_CHAR_TERM - _INT("posix2_char_term", USER_POSIX2_CHAR_TERM, 1, - "Whether the system supports at least one terminal type " - "capable of all operations described in POSIX 1003.2"), -#else - _INT("posix2_char_term", USER_POSIX2_CHAR_TERM, 0, - "Whether the system supports at least one terminal type " - "capable of all operations described in POSIX 1003.2"), -#endif -#ifdef POSIX2_FORT_DEV - _INT("posix2_fort_dev", USER_POSIX2_FORT_DEV, 1, - "Whether the system supports the FORTRAN Development " - "Utilities Option"), -#else - _INT("posix2_fort_dev", USER_POSIX2_FORT_DEV, 0, - "Whether the system supports the FORTRAN Development " - "Utilities Option"), -#endif -#ifdef POSIX2_FORT_RUN - _INT("posix2_fort_run", USER_POSIX2_FORT_RUN, 1, - "Whether the system supports the FORTRAN Runtime " - "Utilities Option"), -#else - _INT("posix2_fort_run", USER_POSIX2_FORT_RUN, 0, - "Whether the system supports the FORTRAN Runtime " - "Utilities Option"), -#endif -#ifdef POSIX2_LOCALEDEF - _INT("posix2_localedef", USER_POSIX2_LOCALEDEF, 1, - "Whether the system supports the creation of locales"), -#else - _INT("posix2_localedef", USER_POSIX2_LOCALEDEF, 0, - "Whether the system supports the creation of locales"), -#endif -#ifdef POSIX2_SW_DEV - _INT("posix2_sw_dev", USER_POSIX2_SW_DEV, 1, - "Whether the system supports the Software Development " - "Utilities Option"), -#else - _INT("posix2_sw_dev", USER_POSIX2_SW_DEV, 0, - "Whether the system supports the Software Development " - "Utilities Option"), -#endif -#ifdef POSIX2_UPE - _INT("posix2_upe", USER_POSIX2_UPE, 1, - "Whether the system supports the User Portability " - "Utilities Option"), -#else - _INT("posix2_upe", USER_POSIX2_UPE, 0, - "Whether the system supports the User Portability " - "Utilities Option"), -#endif - _INT("stream_max", USER_STREAM_MAX, FOPEN_MAX, - "The minimum maximum number of streams that a process " - "may have open at any one time"), - _INT("tzname_max", USER_TZNAME_MAX, NAME_MAX, - "The minimum maximum number of types supported for the " - "name of a timezone"), - _INT("atexit_max", USER_ATEXIT_MAX, -1, - "The maximum number of functions that may be registered " - "with atexit(3)"), -#endif /* !lint */ - }; -#undef _INT - - static const int clen = sizeof(sysctl_usermib) / - sizeof(sysctl_usermib[0]); - - const struct sysctlnode *node; - int ni; - size_t l, sz; - - /* - * none of these nodes are writable and they're all terminal (for now) - */ - if (namelen != 1) - return (EINVAL); - - l = *oldlenp; - if (name[0] == CTL_QUERY) { - uint v; - node = newp; - if (node == NULL) - return (EINVAL); - else if (SYSCTL_VERS(node->sysctl_flags) == SYSCTL_VERS_1 && - newlen == sizeof(struct sysctlnode)) - v = SYSCTL_VERS_1; - else - return (EINVAL); - - sz = 0; - for (ni = 0; ni < clen; ni++) - sz += __cvt_node_out(v, &sysctl_usermib[ni], &oldp, &l); - *oldlenp = sz; - return (0); - } - - if (name[0] == CTL_DESCRIBE) { - /* - * XXX make sure this is larger than the largest - * "user" description - */ - char buf[192]; - struct sysctldesc *d1 = (void *)&buf[0], *d2 = oldp; - size_t d; - - node = newp; - if (node != NULL && - (SYSCTL_VERS(node->sysctl_flags) < SYSCTL_VERS_1 || - newlen != sizeof(struct sysctlnode))) - return (EINVAL); - - sz = 0; - for (ni = 0; ni < clen; ni++) { - memset(&buf[0], 0, sizeof(buf)); - if (node != NULL && - node->sysctl_num != sysctl_usermib[ni].sysctl_num) - continue; - d1->descr_num = sysctl_usermib[ni].sysctl_num; - d1->descr_ver = sysctl_usermib[ni].sysctl_ver; - if (sysctl_usermib[ni].sysctl_desc == NULL) - d1->descr_len = 1; - else { - size_t dlen; - (void)strlcpy(d1->descr_str, - sysctl_usermib[ni].sysctl_desc, - sizeof(buf) - sizeof(*d1)); - dlen = strlen(d1->descr_str) + 1; - _DIAGASSERT(__type_fit(uint32_t, dlen)); - d1->descr_len = (uint32_t)dlen; - } - d = (size_t)__sysc_desc_adv(NULL, d1->descr_len); - if (d2 != NULL) - memcpy(d2, d1, d); - sz += d; - d2 = (struct sysctldesc *)(void *)((char *)d2 + d); - if (node != NULL) - break; - } - *oldlenp = sz; - if (sz == 0 && node != NULL) - return (ENOENT); - return (0); - - } - - /* - * none of these nodes are writable - */ - if (newp != NULL || newlen != 0) - return (EPERM); - - node = &sysctl_usermib[0]; - for (ni = 0; ni < clen; ni++) - if (name[0] == node[ni].sysctl_num) - break; - if (ni == clen) - return (EOPNOTSUPP); - - node = &node[ni]; - if (node->sysctl_flags & CTLFLAG_IMMEDIATE) { - switch (SYSCTL_TYPE(node->sysctl_flags)) { - case CTLTYPE_INT: - newp = &node->sysctl_idata; - break; - case CTLTYPE_QUAD: - newp = &node->sysctl_qdata; - break; - default: - return (EINVAL); - } - } - else - newp = node->sysctl_data; - - l = MIN(l, node->sysctl_size); - if (oldp != NULL) - memcpy(oldp, newp, l); - *oldlenp = node->sysctl_size; - - return (0); -} - -static size_t -__cvt_node_out(uint v, const struct sysctlnode *n, void **o, size_t *l) -{ - const void *src = n; - size_t sz; - - switch (v) { -#if (SYSCTL_VERSION != SYSCTL_VERS_1) -#error __cvt_node_out: no support for SYSCTL_VERSION -#endif /* (SYSCTL_VERSION != SYSCTL_VERS_1) */ - - case SYSCTL_VERSION: - sz = sizeof(struct sysctlnode); - break; - - default: - sz = 0; - break; - } - - if (sz > 0 && *o != NULL && *l >= sz) { - memcpy(*o, src, sz); - *o = sz + (caddr_t)*o; - *l -= sz; - } - - return(sz); -} diff --git a/lib/libc/gen/sysctlbyname.c b/lib/libc/gen/sysctlbyname.c deleted file mode 100644 index 0a6be7f32..000000000 --- a/lib/libc/gen/sysctlbyname.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: sysctlbyname.c,v 1.7 2010/12/13 23:10:13 pooka Exp $ */ - -/*- - * Copyright (c) 2003,2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Brown. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sysctlbyname.c,v 1.7 2010/12/13 23:10:13 pooka Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#endif -#include -#include - -#ifdef RUMP_ACTION -#include -#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f) -#else -#ifdef __weak_alias -__weak_alias(sysctlbyname,_sysctlbyname) -#endif -#endif - -/* - * trivial sysctlbyname() function for the "lazy". - */ -int -sysctlbyname(const char *gname, void *oldp, size_t *oldlenp, - const void *newp, size_t newlen) -{ - int name[CTL_MAXNAME], rc; - u_int namelen; - - rc = sysctlgetmibinfo(gname, &name[0], &namelen, NULL, NULL, NULL, - SYSCTL_VERSION); - if (rc == 0) - rc = sysctl(&name[0], namelen, oldp, oldlenp, newp, newlen); - return (rc); -} diff --git a/lib/libc/gen/sysctlgetmibinfo.c b/lib/libc/gen/sysctlgetmibinfo.c deleted file mode 100644 index 19d94f545..000000000 --- a/lib/libc/gen/sysctlgetmibinfo.c +++ /dev/null @@ -1,611 +0,0 @@ -/* $NetBSD: sysctlgetmibinfo.c,v 1.11 2014/05/16 12:22:32 martin Exp $ */ - -/*- - * Copyright (c) 2003,2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Brown. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sysctlgetmibinfo.c,v 1.11 2014/05/16 12:22:32 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#ifdef _REENTRANT -#include "reentrant.h" -#endif /* _REENTRANT */ -#endif /* RUMP_ACTION */ -#include -#include - -#include -#include -#include -#include -#include - -#ifdef RUMP_ACTION -#include -#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f) -#else -#ifdef __weak_alias -__weak_alias(__learn_tree,___learn_tree) -__weak_alias(sysctlgetmibinfo,_sysctlgetmibinfo) -#endif -#endif - -/* - * the place where we attach stuff we learn on the fly, not - * necessarily used. - */ -static struct sysctlnode sysctl_mibroot = { -#if defined(lint) - /* - * lint doesn't like my initializers - */ - 0 -#else /* !lint */ - .sysctl_flags = SYSCTL_VERSION|CTLFLAG_ROOT|CTLTYPE_NODE, - .sysctl_size = sizeof(struct sysctlnode), - .sysctl_name = "(root)", -#endif /* !lint */ -}; - -/* - * routines to handle learning and cleanup - */ -static int compar(const void *, const void *); -static void free_children(struct sysctlnode *); -static void relearnhead(void); - -/* - * specifically not static since sysctl(8) "borrows" it. - */ -int __learn_tree(int *, u_int, struct sysctlnode *); - -/* - * for ordering nodes -- a query may or may not be given them in - * numeric order - */ -static int -compar(const void *a, const void *b) -{ - - return (((const struct sysctlnode *)a)->sysctl_num - - ((const struct sysctlnode *)b)->sysctl_num); -} - -/* - * recursively nukes a branch or an entire tree from the given node - */ -static void -free_children(struct sysctlnode *rnode) -{ - struct sysctlnode *node; - - if (rnode == NULL || - SYSCTL_TYPE(rnode->sysctl_flags) != CTLTYPE_NODE || - rnode->sysctl_child == NULL) - return; - - for (node = rnode->sysctl_child; - node < &rnode->sysctl_child[rnode->sysctl_clen]; - node++) { - free_children(node); - } - free(rnode->sysctl_child); - rnode->sysctl_child = NULL; -} - -/* - * verifies that the head of the tree in the kernel is the same as the - * head of the tree we already got, integrating new stuff and removing - * old stuff, if it's not. - */ -static void -relearnhead(void) -{ - struct sysctlnode *h, *i, *o, qnode; - size_t si, so; - int rc, name; - size_t nlen, olen, ni, oi; - uint32_t t; - - /* - * if there's nothing there, there's no need to expend any - * effort - */ - if (sysctl_mibroot.sysctl_child == NULL) - return; - - /* - * attempt to pull out the head of the tree, starting with the - * size we have now, and looping if we need more (or less) - * space - */ - si = 0; - so = sysctl_mibroot.sysctl_clen * sizeof(struct sysctlnode); - name = CTL_QUERY; - memset(&qnode, 0, sizeof(qnode)); - qnode.sysctl_flags = SYSCTL_VERSION; - do { - si = so; - h = malloc(si); - rc = sysctl(&name, 1, h, &so, &qnode, sizeof(qnode)); - if (rc == -1 && errno != ENOMEM) - return; - if (si < so) - free(h); - } while (si < so); - - /* - * order the new copy of the head - */ - nlen = so / sizeof(struct sysctlnode); - qsort(h, nlen, sizeof(struct sysctlnode), compar); - - /* - * verify that everything is the same. if it is, we don't - * need to do any more work here. - */ - olen = sysctl_mibroot.sysctl_clen; - rc = (nlen == olen) ? 0 : 1; - o = sysctl_mibroot.sysctl_child; - for (ni = 0; rc == 0 && ni < nlen; ni++) { - if (h[ni].sysctl_num != o[ni].sysctl_num || - h[ni].sysctl_ver != o[ni].sysctl_ver) - rc = 1; - } - if (rc == 0) { - free(h); - return; - } - - /* - * something changed. h will become the new head, and we need - * pull over any subtrees we already have if they're the same - * version. - */ - i = h; - ni = oi = 0; - while (ni < nlen && oi < olen) { - /* - * something was inserted or deleted - */ - if (SYSCTL_TYPE(i[ni].sysctl_flags) == CTLTYPE_NODE) - i[ni].sysctl_child = NULL; - if (i[ni].sysctl_num != o[oi].sysctl_num) { - if (i[ni].sysctl_num < o[oi].sysctl_num) { - ni++; - } - else { - free_children(&o[oi]); - oi++; - } - continue; - } - - /* - * same number, but different version, so throw away - * any accumulated children - */ - if (i[ni].sysctl_ver != o[oi].sysctl_ver) - free_children(&o[oi]); - - /* - * this node is the same, but we only need to - * move subtrees. - */ - else if (SYSCTL_TYPE(i[ni].sysctl_flags) == CTLTYPE_NODE) { - /* - * move subtree to new parent - */ - i[ni].sysctl_clen = o[oi].sysctl_clen; - i[ni].sysctl_csize = o[oi].sysctl_csize; - i[ni].sysctl_child = o[oi].sysctl_child; - /* - * reparent inherited subtree - */ - for (t = 0; - i[ni].sysctl_child != NULL && - t < i[ni].sysctl_clen; - t++) - i[ni].sysctl_child[t].sysctl_parent = &i[ni]; - } - ni++; - oi++; - } - - /* - * left over new nodes need to have empty subtrees cleared - */ - while (ni < nlen) { - if (SYSCTL_TYPE(i[ni].sysctl_flags) == CTLTYPE_NODE) - i[ni].sysctl_child = NULL; - ni++; - } - - /* - * left over old nodes need to be cleaned out - */ - while (oi < olen) { - free_children(&o[oi]); - oi++; - } - - /* - * pop new head in - */ - _DIAGASSERT(__type_fit(uint32_t, nlen)); - sysctl_mibroot.sysctl_csize = - sysctl_mibroot.sysctl_clen = (uint32_t)nlen; - sysctl_mibroot.sysctl_child = h; - free(o); -} - -/* - * sucks in the children at a given level and attaches it to the tree. - */ -int -__learn_tree(int *name, u_int namelen, struct sysctlnode *pnode) -{ - struct sysctlnode qnode; - uint32_t rc; - size_t sz; - - if (pnode == NULL) - pnode = &sysctl_mibroot; - if (SYSCTL_TYPE(pnode->sysctl_flags) != CTLTYPE_NODE) { - errno = EINVAL; - return (-1); - } - if (pnode->sysctl_child != NULL) - return (0); - - if (pnode->sysctl_clen == 0) - sz = SYSCTL_DEFSIZE * sizeof(struct sysctlnode); - else - sz = pnode->sysctl_clen * sizeof(struct sysctlnode); - pnode->sysctl_child = malloc(sz); - if (pnode->sysctl_child == NULL) - return (-1); - - name[namelen] = CTL_QUERY; - pnode->sysctl_clen = 0; - pnode->sysctl_csize = 0; - memset(&qnode, 0, sizeof(qnode)); - qnode.sysctl_flags = SYSCTL_VERSION; - rc = sysctl(name, namelen + 1, pnode->sysctl_child, &sz, - &qnode, sizeof(qnode)); - if (sz == 0) { - free(pnode->sysctl_child); - pnode->sysctl_child = NULL; - return (rc); - } - if (rc) { - free(pnode->sysctl_child); - pnode->sysctl_child = NULL; - if ((sz % sizeof(struct sysctlnode)) != 0) - errno = EINVAL; - if (errno != ENOMEM) - return (rc); - } - - if (pnode->sysctl_child == NULL) { - pnode->sysctl_child = malloc(sz); - if (pnode->sysctl_child == NULL) - return (-1); - - rc = sysctl(name, namelen + 1, pnode->sysctl_child, &sz, - &qnode, sizeof(qnode)); - if (rc) { - free(pnode->sysctl_child); - pnode->sysctl_child = NULL; - return (rc); - } - } - - /* - * how many did we get? - */ - sz /= sizeof(struct sysctlnode); - pnode->sysctl_csize = pnode->sysctl_clen = (uint32_t)sz; - if (pnode->sysctl_clen != sz) { - free(pnode->sysctl_child); - pnode->sysctl_child = NULL; - errno = EINVAL; - return (-1); - } - - /* - * you know, the kernel doesn't really keep them in any - * particular order...just like entries in a directory - */ - qsort(pnode->sysctl_child, pnode->sysctl_clen, - sizeof(struct sysctlnode), compar); - - /* - * rearrange parent<->child linkage - */ - for (rc = 0; rc < pnode->sysctl_clen; rc++) { - pnode->sysctl_child[rc].sysctl_parent = pnode; - if (SYSCTL_TYPE(pnode->sysctl_child[rc].sysctl_flags) == - CTLTYPE_NODE) { - /* - * these nodes may have children, but we - * haven't discovered that yet. - */ - pnode->sysctl_child[rc].sysctl_child = NULL; - } - pnode->sysctl_child[rc].sysctl_desc = NULL; - } - - return (0); -} - -/* - * that's "given name" as a string, the integer form of the name fit - * to be passed to sysctl(), "canonicalized name" (optional), and a - * pointer to the length of the integer form. oh, and then a pointer - * to the node, in case you (the caller) care. you can leave them all - * NULL except for gname, though that might be rather pointless, - * unless all you wanna do is verify that a given name is acceptable. - * - * returns either 0 (everything was fine) or -1 and sets errno - * accordingly. if errno is set to EAGAIN, we detected a change to - * the mib while parsing, and you should try again. in the case of an - * invalid node name, cname will be set to contain the offending name. - */ -#ifdef _REENTRANT -static mutex_t sysctl_mutex = MUTEX_INITIALIZER; -static int sysctlgetmibinfo_unlocked(const char *, int *, u_int *, char *, - size_t *, struct sysctlnode **, int); -#endif /* __REENTRANT */ - -int -sysctlgetmibinfo(const char *gname, int *iname, u_int *namelenp, - char *cname, size_t *csz, struct sysctlnode **rnode, int v) -#ifdef _REENTRANT -{ - int rc; - - mutex_lock(&sysctl_mutex); - rc = sysctlgetmibinfo_unlocked(gname, iname, namelenp, cname, csz, - rnode, v); - mutex_unlock(&sysctl_mutex); - - return (rc); -} - -static int -sysctlgetmibinfo_unlocked(const char *gname, int *iname, u_int *namelenp, - char *cname, size_t *csz, struct sysctlnode **rnode, - int v) -#endif /* _REENTRANT */ -{ - struct sysctlnode *pnode, *node; - int name[CTL_MAXNAME], n, haven; - u_int ni, nl; - intmax_t q; - char sep[2], token[SYSCTL_NAMELEN], - pname[SYSCTL_NAMELEN * CTL_MAXNAME + CTL_MAXNAME]; - const char *piece, *dot; - char *t; - size_t l; - - if (rnode != NULL) { - if (*rnode == NULL) { - /* XXX later deal with dealing back a sub version */ - if (v != SYSCTL_VERSION) - return (EINVAL); - - pnode = &sysctl_mibroot; - } - else { - /* this is just someone being silly */ - if (SYSCTL_VERS((*rnode)->sysctl_flags) != (uint32_t)v) - return (EINVAL); - - /* XXX later deal with other people's trees */ - if (SYSCTL_VERS((*rnode)->sysctl_flags) != - SYSCTL_VERSION) - return (EINVAL); - - pnode = *rnode; - } - } - else - pnode = &sysctl_mibroot; - - if (pnode == &sysctl_mibroot) - relearnhead(); - - nl = ni = 0; - token[0] = '\0'; - pname[0] = '\0'; - node = NULL; - - /* - * default to using '.' as the separator, but allow '/' as - * well, and then allow a leading separator - */ - if ((dot = strpbrk(gname, "./")) == NULL) - sep[0] = '.'; - else - sep[0] = dot[0]; - sep[1] = '\0'; - if (gname[0] == sep[0]) { - strlcat(pname, sep, sizeof(pname)); - gname++; - } - -#define COPY_OUT_DATA(t, c, cs, nlp, l) do { \ - if ((c) != NULL && (cs) != NULL) \ - *(cs) = strlcpy((c), (t), *(cs)); \ - else if ((cs) != NULL) \ - *(cs) = strlen(t) + 1; \ - if ((nlp) != NULL) \ - *(nlp) = (l); \ - } while (/*CONSTCOND*/0) - - piece = gname; - while (piece != NULL && *piece != '\0') { - /* - * what was i looking for? - */ - dot = strchr(piece, sep[0]); - if (dot == NULL) { - l = strlcpy(token, piece, sizeof(token)); - if (l > sizeof(token)) { - COPY_OUT_DATA(piece, cname, csz, namelenp, nl); - errno = ENAMETOOLONG; - return (-1); - } - } - else if (dot - piece > (intptr_t)(sizeof(token) - 1)) { - COPY_OUT_DATA(token, cname, csz, namelenp, nl); - errno = ENAMETOOLONG; - return (-1); - } - else { - strncpy(token, piece, (size_t)(dot - piece)); - token[dot - piece] = '\0'; - } - - /* - * i wonder if this "token" is an integer? - */ - errno = 0; - q = strtoimax(token, &t, 0); - n = (int)q; - if (errno != 0 || *t != '\0') - haven = 0; - else if (q < INT_MIN || q > UINT_MAX) - haven = 0; - else - haven = 1; - - /* - * make sure i have something to look at - */ - if (SYSCTL_TYPE(pnode->sysctl_flags) != CTLTYPE_NODE) { - if (haven && nl > 0) { - strlcat(pname, sep, sizeof(pname)); - goto just_numbers; - } - COPY_OUT_DATA(token, cname, csz, namelenp, nl); - errno = ENOTDIR; - return (-1); - } - if (pnode->sysctl_child == NULL) { - if (__learn_tree(name, nl, pnode) == -1) { - COPY_OUT_DATA(token, cname, csz, namelenp, nl); - return (-1); - } - } - node = pnode->sysctl_child; - if (node == NULL) { - COPY_OUT_DATA(token, cname, csz, namelenp, nl); - errno = ENOENT; - return (-1); - } - - /* - * now...is it there? - */ - for (ni = 0; ni < pnode->sysctl_clen; ni++) - if ((haven && ((n == node[ni].sysctl_num) || - (node[ni].sysctl_flags & CTLFLAG_ANYNUMBER))) || - strcmp(token, node[ni].sysctl_name) == 0) - break; - if (ni >= pnode->sysctl_clen) { - COPY_OUT_DATA(token, cname, csz, namelenp, nl); - errno = ENOENT; - return (-1); - } - - /* - * ah...it is. - */ - pnode = &node[ni]; - if (nl > 0) - strlcat(pname, sep, sizeof(pname)); - if (haven && n != pnode->sysctl_num) { - just_numbers: - strlcat(pname, token, sizeof(pname)); - name[nl] = n; - } - else { - strlcat(pname, pnode->sysctl_name, sizeof(pname)); - name[nl] = pnode->sysctl_num; - } - piece = (dot != NULL) ? dot + 1 : NULL; - nl++; - if (nl == CTL_MAXNAME) { - COPY_OUT_DATA(token, cname, csz, namelenp, nl); - errno = ERANGE; - return (-1); - } - } - - if (nl == 0) { - if (namelenp != NULL) - *namelenp = 0; - errno = EINVAL; - return (-1); - } - - COPY_OUT_DATA(pname, cname, csz, namelenp, nl); - if (iname != NULL && namelenp != NULL) - memcpy(iname, &name[0], MIN(nl, *namelenp) * sizeof(int)); - if (namelenp != NULL) - *namelenp = nl; - if (rnode != NULL) { - if (*rnode != NULL) - /* - * they gave us a private tree to work in, so - * we give back a pointer into that private - * tree - */ - *rnode = pnode; - else { - /* - * they gave us a place to put the node data, - * so give them a copy - */ - *rnode = malloc(sizeof(struct sysctlnode)); - if (*rnode != NULL) { - **rnode = *pnode; - (*rnode)->sysctl_child = NULL; - (*rnode)->sysctl_parent = NULL; - } - } - } - - return (0); -} diff --git a/lib/libc/gen/sysctlnametomib.c b/lib/libc/gen/sysctlnametomib.c deleted file mode 100644 index 735f4f0d0..000000000 --- a/lib/libc/gen/sysctlnametomib.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: sysctlnametomib.c,v 1.7 2012/03/13 21:13:37 christos Exp $ */ - -/*- - * Copyright (c) 2003,2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Brown. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sysctlnametomib.c,v 1.7 2012/03/13 21:13:37 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#endif -#include -#include -#include - -#ifdef RUMP_ACTION -#include -#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f) -#else -#ifdef __weak_alias -__weak_alias(sysctlnametomib,_sysctlnametomib) -#endif -#endif /* RUMP_ACTION */ - -/* - * freebsd compatible sysctlnametomib() function, implemented as an - * extremely thin wrapper around sysctlgetmibinfo(). i think the use - * of size_t as the third argument is erroneous, but what can we do - * about that? - */ -int -sysctlnametomib(const char *gname, int *iname, size_t *namelenp) -{ - u_int unamelen; - int rc; - - _DIAGASSERT(__type_fit(u_int, *namelenp)); - unamelen = (u_int)*namelenp; - rc = sysctlgetmibinfo(gname, iname, &unamelen, NULL, NULL, NULL, - SYSCTL_VERSION); - *namelenp = unamelen; - - return (rc); -} diff --git a/lib/libc/gen/syslog.3 b/lib/libc/gen/syslog.3 deleted file mode 100644 index 1b7baeda6..000000000 --- a/lib/libc/gen/syslog.3 +++ /dev/null @@ -1,517 +0,0 @@ -.\" $NetBSD: syslog.3,v 1.29 2011/07/25 19:42:50 njoly Exp $ -.\" $OpenBSD: syslog.3,v 1.25 2005/07/22 03:16:58 jaredy Exp $ -.\" -.\" Copyright (c) 1985, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)syslog.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd May 3, 2010 -.Dt SYSLOG 3 -.Os -.Sh NAME -.Nm syslog , -.Nm syslog_r , -.Nm vsyslog , -.Nm vsyslog_r , -.Nm syslogp , -.Nm syslogp_r , -.Nm vsyslogp , -.Nm vsyslogp_r , -.Nm openlog , -.Nm openlog_r , -.Nm closelog , -.Nm closelog_r , -.Nm setlogmask , -.Nm setlogmask_r -.Nd control system log -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In syslog.h -.Ft void -.Fn syslog "int priority" "const char *message" "..." -.Ft void -.Fn syslog_r "int priority" "struct syslog_data *data" "const char *message" "..." -.Ft void -.Fn syslogp "int priority" "const char *msgid" "const char *sdfmt" "const char *message" "..." -.Ft void -.Fn syslogp_r "int priority" "struct syslog_data *data" "const char *msgid" "const char *sdfmt" "const char *message" "..." -.\" .Ft void -.\" .Fn syslog_ss "int priority" "struct syslog_data *data" "const char *message" "..." -.Ft void -.Fn openlog "const char *ident" "int logopt" "int facility" -.Ft void -.Fn openlog_r "const char *ident" "int logopt" "int facility" "struct syslog_data *data" -.Ft void -.Fn closelog void -.Ft void -.Fn closelog_r "struct syslog_data *data" -.Ft int -.Fn setlogmask "int maskpri" -.Ft int -.Fn setlogmask_r "int maskpri" "struct syslog_data *data" -.In stdarg.h -.Ft void -.Fn vsyslog "int priority" "const char *message" "va_list args" -.Ft void -.Fn vsyslog_r "int priority" "struct syslog_data *data" "const char *message" "va_list args" -.Ft void -.Fn vsyslogp "int priority" "const char *msgid" "const char *sdfmt" "const char *message" "va_list args" -.Ft void -.Fn vsyslogp_r "int priority" "struct syslog_data *data" "const char *msgid" "const char *sdfmt" "const char *message" "va_list args" -.\" .Ft void -.\" .Fn vsyslog_ss "int priority" "struct syslog_data *data" "const char *message" "va_list args" -.Sh DESCRIPTION -The -.Fn syslog -function -writes -.Fa message -to the system message logger. -The message is then written to the system console, log files, -logged-in users, or forwarded to other machines as appropriate (see -.Xr syslogd 8 ) . -.Pp -The message is identical to a -.Xr printf 3 -format string, except that -.Ql %m -is replaced by the current error -message. -(As denoted by the global variable -.Va errno ; -see -.Xr strerror 3 . ) -A trailing newline is added if none is present. -.\" shouldn't the newline statement be removed? -.\" when logging through a socket a newline is -.\" not added nor is it required. -- ms -.Pp -The -.Fn syslog_r -function is a multithread-safe version of the -.Fn syslog -function. -It takes a pointer to a -.Fa syslog_data -structure which is used to store -information. -This parameter must be initialized before -.Fn syslog_r -is called. -The -.Dv SYSLOG_DATA_INIT -constant is used for this purpose. -The -.Fa syslog_data -structure and the -.Dv SYSLOG_DATA_INIT -constant are defined as: -.Bd -literal -offset indent -struct syslog_data { - int log_file; - int connected; - int opened; - int log_stat; - const char *log_tag; - int log_fac; - int log_mask; -}; - -#define SYSLOG_DATA_INIT { \e - .log_file = -1, \e - .log_fac = LOG_USER, \e - .log_mask = 0xff, \e -} -.Ed -.Pp -The structure is composed of the following elements: -.Bl -tag -width connected -offset indent -.It Va log_file -contains the file descriptor of the file where the message is logged -.It Va connected -indicates if connect has been done -.It Va opened -indicates if -.Fn openlog_r -has been called -.It Va log_stat -status bits, set by -.Fn openlog_r -.It Va log_tag -string to tag the entry with -.It Va log_fac -facility code -.It Va log_mask -mask of priorities to be logged -.El -.\" .Pp -.\" The -.\" .Fn syslog_ss -.\" is the async-signal-safe version of -.\" .Fn syslog_r -.\" and is also multithread-safe. -.\" It has the following limitations: -.\" .Bl -enum -offset indent -.\" .It -.\" The format string cannot contain multi-byte character sequences. -.\" .It -.\" Floating point formats are not supported and print -.\" .Dq UNK . -.\" .It -.\" The time of the event is not sent to -.\" .Xr syslogd 8 . -.\" .It -.\" The error string in the %m format is not printed symbolically but as -.\" .Dq Error %d . -.\" .El -.\" .Pp -.\" For more information about async-signal-safe functions and signal handlers, see -.\" .Xr signal 7 . -.Pp -The -.Fn vsyslog -function -is an alternative form in which the arguments have already been captured -using the variable-length argument facilities of -.Xr stdarg 3 . -.Pp -The -.Fn syslogp -variants take additional arguments which correspond to new fields in the -syslog-protocol message format. -All three arguments are evaluated as -.Xr printf 3 -format strings and any of them can be -.Dv NULL . -This enables applications to use message IDs, structured data, and UTF-8 encoded -content in messages. -.Pp -The message is tagged with -.Fa priority . -Priorities are encoded as a -.Fa facility -and a -.Em level . -The facility describes the part of the system -generating the message. -The level is selected from the following -.Em ordered -(high to low) list: -.Bl -tag -width LOG_AUTHPRIV -.It Dv LOG_EMERG -A panic condition. -This is normally broadcast to all users. -.It Dv LOG_ALERT -A condition that should be corrected immediately, such as a corrupted -system database. -.It Dv LOG_CRIT -Critical conditions, e.g., hard device errors. -.It Dv LOG_ERR -Errors. -.It Dv LOG_WARNING -Warning messages. -.It Dv LOG_NOTICE -Conditions that are not error conditions, -but should possibly be handled specially. -.It Dv LOG_INFO -Informational messages. -.It Dv LOG_DEBUG -Messages that contain information -normally of use only when debugging a program. -.El -.Pp -The -.Fn vsyslog_r -is used the same way as -.Fn vsyslog -except that it takes an additional pointer to a -.Fa syslog_data -structure. -It is a multithread-safe version of the -.Fn vsyslog -function described above. -.\" The -.\" .Fn vsyslog_ss -.\" is the async-signal-safe version of -.\" .Fn vsyslog_r , -.\" is also multithread-safe, and has the same limitations as -.\" .Fn syslog_ss . -.Pp -The -.Fn openlog -function -provides for more specialized processing of the messages sent -by -.Fn syslog -and -.Fn vsyslog . -The parameter -.Fa ident -is a string that will be prepended to every message. -The -.Fa logopt -argument -is a bit field specifying logging options, which is formed by -.Tn OR Ns 'ing -one or more of the following values: -.Bl -tag -width LOG_AUTHPRIV -.It Dv LOG_CONS -If -.Fn syslog -cannot pass the message to -.Xr syslogd 8 -it will attempt to write the message to the console -.Pq Dq Pa /dev/console . -.It Dv LOG_NDELAY -Open the connection to -.Xr syslogd 8 -immediately. -Normally the open is delayed until the first message is logged. -Useful for programs that need to manage the order in which file -descriptors are allocated. -.It Dv LOG_PERROR -Write the message to standard error output as well to the system log. -.It Dv LOG_PID -Log the process id with each message: useful for identifying -instantiations of daemons. -(This PID is placed within brackets -between the ident and the message.) -.El -.Pp -The -.Fa facility -parameter encodes a default facility to be assigned to all messages -that do not have an explicit facility encoded: -.Bl -tag -width LOG_AUTHPRIV -.It Dv LOG_AUTH -The authorization system: -.Xr login 1 , -.Xr su 1 , -.Xr getty 8 , -etc. -.It Dv LOG_AUTHPRIV -The same as -.Dv LOG_AUTH , -but logged to a file readable only by -selected individuals. -.It Dv LOG_CRON -The cron daemon: -.Xr cron 8 . -.It Dv LOG_DAEMON -System daemons, such as -.Xr routed 8 , -that are not provided for explicitly by other facilities. -.It Dv LOG_FTP -The file transfer protocol daemon: -.Xr ftpd 8 . -.It Dv LOG_KERN -Messages generated by the kernel. -These cannot be generated by any user processes. -.It Dv LOG_LPR -The line printer spooling system: -.Xr lpr 1 , -.Xr lpc 8 , -.Xr lpd 8 , -etc. -.It Dv LOG_MAIL -The mail system. -.It Dv LOG_NEWS -The network news system. -.It Dv LOG_SYSLOG -Messages generated internally by -.Xr syslogd 8 . -.It Dv LOG_USER -Messages generated by random user processes. -This is the default facility identifier if none is specified. -.It Dv LOG_UUCP -The uucp system. -.It Dv LOG_LOCAL0 -Reserved for local use. -Similarly for -.Dv LOG_LOCAL1 -through -.Dv LOG_LOCAL7 . -.El -.Pp -The -.Fn openlog_r -function is the multithread-safe version of the -.Fn openlog -function. -It takes an additional pointer to a -.Fa syslog_data -structure. -This function must be used in conjunction with the other -multithread-safe functions. -.Pp -The -.Fn closelog -function -can be used to close the log file. -.Pp -The -.Fn closelog_r -does the same thing as -.Xr closelog 3 -but in a multithread-safe way and takes an additional -pointer to a -.Fa syslog_data -structure. -.Pp -The -.Fn setlogmask -function -sets the log priority mask to -.Fa maskpri -and returns the previous mask. -Calls to -.Fn syslog -with a priority not set in -.Fa maskpri -are rejected. -The mask for an individual priority -.Fa pri -is calculated by the macro -.Fn LOG_MASK pri ; -the mask for all priorities up to and including -.Fa toppri -is given by the macro -.Fn LOG_UPTO toppri . -The default allows all priorities to be logged. -.Pp -The -.Fn setlogmask_r -function is the multithread-safe version of -.Fn setlogmask . -It takes an additional pointer to a -.Fa syslog_data -structure. -.Sh RETURN VALUES -The routines -.Fn closelog , -.Fn closelog_r , -.Fn openlog , -.Fn openlog_r , -.Fn syslog , -.Fn syslog_r , -.Fn vsyslog , -.Fn vsyslog_r , -.Fn syslogp , -.Fn syslogp_r , -.Fn vsyslogp , -and -.Fn vsyslogp_r -return no value. -.Pp -The routines -.Fn setlogmask -and -.Fn setlogmask_r -always return the previous log mask level. -.Sh EXAMPLES -.Bd -literal -offset indent -compact -syslog(LOG_ALERT, "who: internal error 23"); - -openlog("ftpd", LOG_PID | LOG_NDELAY, LOG_FTP); - -setlogmask(LOG_UPTO(LOG_ERR)); - -syslog(LOG_INFO, "Connection from host %d", CallingHost); - -syslog(LOG_INFO|LOG_LOCAL2, "foobar error: %m"); - -syslogp(LOG_INFO|LOG_LOCAL2, NULL, NULL, "foobar error: %m"); - -syslogp(LOG_INFO, "ID%d", "[meta language=\e"en-US\e"]", - "event: %s", 42, EventDescription); -.Ed -.Pp -For the multithread-safe functions: -.Bd -literal -offset indent -struct syslog_data sdata = SYSLOG_DATA_INIT; - -syslog_r(LOG_INFO|LOG_LOCAL2, \*[Am]sdata, "foobar error: %m"); -.Ed -.Sh SEE ALSO -.Xr logger 1 , -.Xr syslogd 8 -.Rs -.%R RFC -.%N 3164 -.%D August 2001 -.%T The BSD syslog Protocol -.Re -.Rs -.%R Internet-Draft -.%N draft-ietf-syslog-protocol-23 -.%D September 2007 -.%T The syslog Protocol -.Re -.Sh HISTORY -These non-multithread-safe functions appeared in -.Bx 4.2 . -The multithread-safe functions appeared in -.Ox 3.1 -and then in -.Nx 4.0 . -The async-signal-safe functions appeared in -.Nx 4.0 . -The syslog-protocol functions appeared in -.Nx 5.0 . -.Sh CAVEATS -It is important never to pass a string with user-supplied data as a -format without using -.Ql %s . -An attacker can put format specifiers in the string to mangle your stack, -leading to a possible security hole. -This holds true even if you have built the string -.Dq by hand -using a function like -.Fn snprintf , -as the resulting string may still contain user-supplied conversion specifiers -for later interpolation by -.Fn syslog . -.Pp -Always be sure to use the proper secure idiom: -.Bd -literal -offset indent -syslog(priority, "%s", string); -.Ed -.Pp -With -.Fn syslogp -the caller is responsible to use the right formatting for the message fields. -A -.Fa msgid -must only contain up to 32 ASCII characters. -A -.Fa sdfmt -has strict rules for paranthesis and character quoting. -If the -.Fa msgfmt -contains UTF-8 characters, then it has to start with a Byte Order Mark. diff --git a/lib/libc/gen/syslog.c b/lib/libc/gen/syslog.c deleted file mode 100644 index 5ece67ddd..000000000 --- a/lib/libc/gen/syslog.c +++ /dev/null @@ -1,586 +0,0 @@ -/* $NetBSD: syslog.c,v 1.54 2014/09/18 13:58:20 christos Exp $ */ - -/* - * Copyright (c) 1983, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)syslog.c 8.5 (Berkeley) 4/29/95"; -#else -__RCSID("$NetBSD: syslog.c,v 1.54 2014/09/18 13:58:20 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "reentrant.h" -#include "extern.h" - -#ifdef __weak_alias -__weak_alias(closelog,_closelog) -__weak_alias(openlog,_openlog) -__weak_alias(setlogmask,_setlogmask) -__weak_alias(syslog,_syslog) -__weak_alias(vsyslog,_vsyslog) -__weak_alias(syslogp,_syslogp) -__weak_alias(vsyslogp,_vsyslogp) -#endif - -static struct syslog_data sdata = SYSLOG_DATA_INIT; - -static void openlog_unlocked_r(const char *, int, int, - struct syslog_data *); -static void disconnectlog_r(struct syslog_data *); -static void connectlog_r(struct syslog_data *); - -#define LOG_SIGNAL_SAFE (int)0x80000000 - - -#ifdef _REENTRANT -static mutex_t syslog_mutex = MUTEX_INITIALIZER; -#endif - -/* - * syslog, vsyslog -- - * print message on log file; output is intended for syslogd(8). - */ -void -syslog(int pri, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsyslog(pri, fmt, ap); - va_end(ap); -} - -void -vsyslog(int pri, const char *fmt, va_list ap) -{ - vsyslog_r(pri, &sdata, fmt, ap); -} - -/* - * syslogp, vsyslogp -- - * like syslog but take additional arguments for MSGID and SD - */ -void -syslogp(int pri, const char *msgid, const char *sdfmt, const char *msgfmt, ...) -{ - va_list ap; - - va_start(ap, msgfmt); - vsyslogp(pri, msgid, sdfmt, msgfmt, ap); - va_end(ap); -} - -void -vsyslogp(int pri, const char *msgid, const char *sdfmt, const char *msgfmt, va_list ap) -{ - vsyslogp_r(pri, &sdata, msgid, sdfmt, msgfmt, ap); -} - -void -openlog(const char *ident, int logstat, int logfac) -{ - openlog_r(ident, logstat, logfac, &sdata); -} - -void -closelog(void) -{ - closelog_r(&sdata); -} - -/* setlogmask -- set the log mask level */ -int -setlogmask(int pmask) -{ - return setlogmask_r(pmask, &sdata); -} - -/* Reentrant version of syslog, i.e. syslog_r() */ - -void -syslog_r(int pri, struct syslog_data *data, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsyslog_r(pri, data, fmt, ap); - va_end(ap); -} - -void -syslogp_r(int pri, struct syslog_data *data, const char *msgid, - const char *sdfmt, const char *msgfmt, ...) -{ - va_list ap; - - va_start(ap, msgfmt); - vsyslogp_r(pri, data, msgid, sdfmt, msgfmt, ap); - va_end(ap); -} - -void -syslog_ss(int pri, struct syslog_data *data, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vsyslog_r(pri | LOG_SIGNAL_SAFE, data, fmt, ap); - va_end(ap); -} - -void -syslogp_ss(int pri, struct syslog_data *data, const char *msgid, - const char *sdfmt, const char *msgfmt, ...) -{ - va_list ap; - - va_start(ap, msgfmt); - vsyslogp_r(pri | LOG_SIGNAL_SAFE, data, msgid, sdfmt, msgfmt, ap); - va_end(ap); -} - -void -vsyslog_ss(int pri, struct syslog_data *data, const char *fmt, va_list ap) -{ - vsyslog_r(pri | LOG_SIGNAL_SAFE, data, fmt, ap); -} - -void -vsyslogp_ss(int pri, struct syslog_data *data, const char *msgid, - const char *sdfmt, const char *msgfmt, va_list ap) -{ - vsyslogp_r(pri | LOG_SIGNAL_SAFE, data, msgid, sdfmt, msgfmt, ap); -} - - -void -vsyslog_r(int pri, struct syslog_data *data, const char *fmt, va_list ap) -{ - vsyslogp_r(pri, data, NULL, NULL, fmt, ap); -} - -void -vsyslogp_r(int pri, struct syslog_data *data, const char *msgid, - const char *sdfmt, const char *msgfmt, va_list ap) -{ - static const char BRCOSP[] = "]: "; - static const char CRLF[] = "\r\n"; - size_t cnt, prlen, tries; - char ch, *p, *t; - struct timeval tv; - struct tm tmnow; - time_t now; - int fd, saved_errno; -#define TBUF_LEN 2048 -#define FMT_LEN 1024 -#define MAXTRIES 10 - char tbuf[TBUF_LEN], fmt_cpy[FMT_LEN], fmt_cat[FMT_LEN] = ""; - size_t tbuf_left, fmt_left, msgsdlen; - char *fmt = fmt_cat; - int signal_safe = pri & LOG_SIGNAL_SAFE; - struct iovec iov[7]; /* prog + [ + pid + ]: + fmt + crlf */ - int opened, iovcnt; - - pri &= ~LOG_SIGNAL_SAFE; - -#define INTERNALLOG LOG_ERR|LOG_CONS|LOG_PERROR|LOG_PID - /* Check for invalid bits. */ - if (pri & ~(LOG_PRIMASK|LOG_FACMASK)) { - syslog_r(INTERNALLOG | signal_safe, data, - "syslog_r: unknown facility/priority: %x", pri); - pri &= LOG_PRIMASK|LOG_FACMASK; - } - - /* Check priority against setlogmask values. */ - if (!(LOG_MASK(LOG_PRI(pri)) & data->log_mask)) - return; - - saved_errno = errno; - - /* Set default facility if none specified. */ - if ((pri & LOG_FACMASK) == 0) - pri |= data->log_fac; - - /* Build the message. */ - p = tbuf; - tbuf_left = TBUF_LEN; - -#define DEC() \ - do { \ - if (prlen >= tbuf_left) \ - prlen = tbuf_left - 1; \ - p += prlen; \ - tbuf_left -= prlen; \ - } while (/*CONSTCOND*/0) - - prlen = snprintf_ss(p, tbuf_left, "<%d>1 ", pri); - DEC(); - - if (!signal_safe && (gettimeofday(&tv, NULL) != -1)) { - /* strftime() implies tzset(), localtime_r() doesn't. */ - tzset(); - now = (time_t) tv.tv_sec; - localtime_r(&now, &tmnow); - - prlen = strftime(p, tbuf_left, "%FT%T", &tmnow); - DEC(); - prlen = snprintf(p, tbuf_left, ".%06ld", (long)tv.tv_usec); - DEC(); - prlen = strftime(p, tbuf_left-1, "%z", &tmnow); - /* strftime gives eg. "+0200", but we need "+02:00" */ - if (prlen == 5) { - p[prlen+1] = p[prlen]; - p[prlen] = p[prlen-1]; - p[prlen-1] = p[prlen-2]; - p[prlen-2] = ':'; - prlen += 1; - } - } else { - prlen = snprintf_ss(p, tbuf_left, "-"); -#if 0 - /* - * if gmtime_r() was signal-safe we could output - * the UTC-time: - */ - gmtime_r(&now, &tmnow); - prlen = strftime(p, tbuf_left, "%FT%TZ", &tmnow); -#endif - } - -#if !defined(__minix) - if (data == &sdata) - mutex_lock(&syslog_mutex); -#endif /* !defined(__minix) */ - - if (data->log_hostname[0] == '\0' && gethostname(data->log_hostname, - sizeof(data->log_hostname)) == -1) { - /* can this really happen? */ - data->log_hostname[0] = '-'; - data->log_hostname[1] = '\0'; - } - - DEC(); - prlen = snprintf_ss(p, tbuf_left, " %s ", data->log_hostname); - - if (data->log_tag == NULL) - data->log_tag = getprogname(); - - DEC(); - prlen = snprintf_ss(p, tbuf_left, "%s ", - data->log_tag ? data->log_tag : "-"); - -#if !defined(__minix) - if (data == &sdata) - mutex_unlock(&syslog_mutex); -#endif /* !defined(__minix) */ - - if (data->log_stat & (LOG_PERROR|LOG_CONS)) { - iovcnt = 0; - iov[iovcnt].iov_base = p; - iov[iovcnt].iov_len = prlen - 1; - iovcnt++; - } - DEC(); - - if (data->log_stat & LOG_PID) { - prlen = snprintf_ss(p, tbuf_left, "%d ", getpid()); - if (data->log_stat & (LOG_PERROR|LOG_CONS)) { - iov[iovcnt].iov_base = __UNCONST("["); - iov[iovcnt].iov_len = 1; - iovcnt++; - iov[iovcnt].iov_base = p; - iov[iovcnt].iov_len = prlen - 1; - iovcnt++; - iov[iovcnt].iov_base = __UNCONST(BRCOSP); - iov[iovcnt].iov_len = 3; - iovcnt++; - } - } else { - prlen = snprintf_ss(p, tbuf_left, "- "); - if (data->log_stat & (LOG_PERROR|LOG_CONS)) { - iov[iovcnt].iov_base = __UNCONST(BRCOSP + 1); - iov[iovcnt].iov_len = 2; - iovcnt++; - } - } - DEC(); - - /* - * concat the format strings, then use one vsnprintf() - */ - if (msgid != NULL && *msgid != '\0') { - strlcat(fmt_cat, msgid, FMT_LEN); - strlcat(fmt_cat, " ", FMT_LEN); - } else - strlcat(fmt_cat, "- ", FMT_LEN); - - if (sdfmt != NULL && *sdfmt != '\0') { - strlcat(fmt_cat, sdfmt, FMT_LEN); - } else - strlcat(fmt_cat, "-", FMT_LEN); - - if (data->log_stat & (LOG_PERROR|LOG_CONS)) - msgsdlen = strlen(fmt_cat) + 1; - else - msgsdlen = 0; /* XXX: GCC */ - - if (msgfmt != NULL && *msgfmt != '\0') { - strlcat(fmt_cat, " ", FMT_LEN); - strlcat(fmt_cat, msgfmt, FMT_LEN); - } - - /* - * We wouldn't need this mess if printf handled %m, or if - * strerror() had been invented before syslog(). - */ - for (t = fmt_cpy, fmt_left = FMT_LEN; (ch = *fmt) != '\0'; ++fmt) { - if (ch == '%' && fmt[1] == 'm') { - char ebuf[128]; - ++fmt; - if (signal_safe || - strerror_r(saved_errno, ebuf, sizeof(ebuf))) - prlen = snprintf_ss(t, fmt_left, "Error %d", - saved_errno); - else - prlen = snprintf_ss(t, fmt_left, "%s", ebuf); - if (prlen >= fmt_left) - prlen = fmt_left - 1; - t += prlen; - fmt_left -= prlen; - } else if (ch == '%' && fmt[1] == '%' && fmt_left > 2) { - *t++ = '%'; - *t++ = '%'; - fmt++; - fmt_left -= 2; - } else { - if (fmt_left > 1) { - *t++ = ch; - fmt_left--; - } - } - } - *t = '\0'; - - if (signal_safe) - prlen = vsnprintf_ss(p, tbuf_left, fmt_cpy, ap); - else - prlen = vsnprintf(p, tbuf_left, fmt_cpy, ap); - - if (data->log_stat & (LOG_PERROR|LOG_CONS)) { - iov[iovcnt].iov_base = p + msgsdlen; - iov[iovcnt].iov_len = prlen - msgsdlen; - iovcnt++; - } - - DEC(); - cnt = p - tbuf; - - /* Output to stderr if requested. */ - if (data->log_stat & LOG_PERROR) { - iov[iovcnt].iov_base = __UNCONST(CRLF + 1); - iov[iovcnt].iov_len = 1; - (void)writev(STDERR_FILENO, iov, iovcnt + 1); - } - - /* Get connected, output the message to the local logger. */ -#if !defined(__minix) - if (data == &sdata) - mutex_lock(&syslog_mutex); -#endif /* !defined(__minix) */ - opened = !data->log_opened; - if (opened) - openlog_unlocked_r(data->log_tag, data->log_stat, 0, data); - connectlog_r(data); - - /* - * If the send() failed, there are two likely scenarios: - * 1) syslogd was restarted - * 2) /dev/log is out of socket buffer space - * We attempt to reconnect to /dev/log to take care of - * case #1 and keep send()ing data to cover case #2 - * to give syslogd a chance to empty its socket buffer. - */ - for (tries = 0; tries < MAXTRIES; tries++) { - if (send(data->log_file, tbuf, cnt, 0) != -1) - break; - if (errno != ENOBUFS) { - disconnectlog_r(data); - connectlog_r(data); - } else - (void)usleep(1); - } - - /* - * Output the message to the console; try not to block - * as a blocking console should not stop other processes. - * Make sure the error reported is the one from the syslogd failure. - */ - if (tries == MAXTRIES && (data->log_stat & LOG_CONS) && - (fd = open(_PATH_CONSOLE, - O_WRONLY | O_NONBLOCK | O_CLOEXEC, 0)) >= 0) { - iov[iovcnt].iov_base = __UNCONST(CRLF); - iov[iovcnt].iov_len = 2; - (void)writev(fd, iov, iovcnt + 1); - (void)close(fd); - } - -#if !defined(__minix) - if (data == &sdata) - mutex_unlock(&syslog_mutex); -#endif /* !defined(__minix) */ - - if (data != &sdata && opened) { - /* preserve log tag */ - const char *ident = data->log_tag; - closelog_r(data); - data->log_tag = ident; - } -} - -static void -disconnectlog_r(struct syslog_data *data) -{ - /* - * If the user closed the FD and opened another in the same slot, - * that's their problem. They should close it before calling on - * system services. - */ - if (data->log_file != -1) { - (void)close(data->log_file); - data->log_file = -1; - } - data->log_connected = 0; /* retry connect */ -} - -static void -connectlog_r(struct syslog_data *data) -{ - /* AF_UNIX address of local logger */ - static const struct sockaddr_un sun = { - .sun_family = AF_LOCAL, - .sun_len = sizeof(sun), - .sun_path = _PATH_LOG, - }; - - if (data->log_file == -1 || fcntl(data->log_file, F_GETFL, 0) == -1) { - if ((data->log_file = socket(AF_UNIX, SOCK_DGRAM | SOCK_CLOEXEC, - 0)) == -1) - return; - data->log_connected = 0; - } - if (!data->log_connected) { - if (connect(data->log_file, - (const struct sockaddr *)(const void *)&sun, - (socklen_t)sizeof(sun)) == -1) - { - (void)close(data->log_file); - data->log_file = -1; - } else - data->log_connected = 1; - } -} - -static void -openlog_unlocked_r(const char *ident, int logstat, int logfac, - struct syslog_data *data) -{ - if (ident != NULL) - data->log_tag = ident; - data->log_stat = logstat; - if (logfac != 0 && (logfac &~ LOG_FACMASK) == 0) - data->log_fac = logfac; - - if (data->log_stat & LOG_NDELAY) /* open immediately */ - connectlog_r(data); - - data->log_opened = 1; -} - -void -openlog_r(const char *ident, int logstat, int logfac, struct syslog_data *data) -{ -#if !defined(__minix) - if (data == &sdata) - mutex_lock(&syslog_mutex); -#endif /* !defined(__minix) */ - openlog_unlocked_r(ident, logstat, logfac, data); -#if !defined(__minix) - if (data == &sdata) - mutex_unlock(&syslog_mutex); -#endif /* !defined(__minix) */ -} - -void -closelog_r(struct syslog_data *data) -{ -#if !defined(__minix) - if (data == &sdata) - mutex_lock(&syslog_mutex); -#endif /* !defined(__minix) */ - (void)close(data->log_file); - data->log_file = -1; - data->log_connected = 0; - data->log_tag = NULL; -#if !defined(__minix) - if (data == &sdata) - mutex_unlock(&syslog_mutex); -#endif /* !defined(__minix) */ -} - -int -setlogmask_r(int pmask, struct syslog_data *data) -{ - int omask; - - omask = data->log_mask; - if (pmask != 0) - data->log_mask = pmask; - return omask; -} diff --git a/lib/libc/gen/telldir.c b/lib/libc/gen/telldir.c deleted file mode 100644 index 1bbe14390..000000000 --- a/lib/libc/gen/telldir.c +++ /dev/null @@ -1,122 +0,0 @@ -/* $NetBSD: telldir.c,v 1.20 2013/03/06 11:27:28 yamt Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)telldir.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: telldir.c,v 1.20 2013/03/06 11:27:28 yamt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" -#include "extern.h" -#include - -#include -#include -#include -#include - -#include "dirent_private.h" - -#ifdef __weak_alias -__weak_alias(telldir,_telldir) -#endif - -long -telldir(DIR *dirp) -{ - long rv; -#ifdef _REENTRANT - if (__isthreaded) { - mutex_lock((mutex_t *)dirp->dd_lock); - rv = _telldir_unlocked(dirp); - mutex_unlock((mutex_t *)dirp->dd_lock); - } else -#endif - rv = _telldir_unlocked(dirp); - return rv; -} - -/* - * return a pointer into a directory - */ -long -_telldir_unlocked(DIR *dirp) -{ - struct dirpos *lp; - - for (lp = dirp->dd_internal; lp; lp = lp->dp_next) - if (lp->dp_seek == dirp->dd_seek && - lp->dp_loc == dirp->dd_loc) - return (intptr_t)lp; - - if ((lp = malloc(sizeof(*lp))) == NULL) - return (-1); - - lp->dp_seek = dirp->dd_seek; - lp->dp_loc = dirp->dd_loc; - lp->dp_next = dirp->dd_internal; - dirp->dd_internal = lp; - - return (intptr_t)lp; -} - -/* - * seek to an entry in a directory. - * Only values returned by "telldir" should be passed to seekdir. - */ -void -_seekdir_unlocked(DIR *dirp, long loc) -{ - struct dirpos *lp; - - _DIAGASSERT(dirp != NULL); - - for (lp = dirp->dd_internal; lp; lp = lp->dp_next) - if ((intptr_t)lp == loc) - break; - - if (lp == NULL) - return; - - if (lp->dp_loc == dirp->dd_loc && lp->dp_seek == dirp->dd_seek) - return; - - dirp->dd_seek = lseek(dirp->dd_fd, lp->dp_seek, SEEK_SET); - dirp->dd_loc = 0; - while (dirp->dd_loc < lp->dp_loc) - if (_readdir_unlocked(dirp, 0) == NULL) - break; -} diff --git a/lib/libc/gen/time.3 b/lib/libc/gen/time.3 deleted file mode 100644 index b361f4db6..000000000 --- a/lib/libc/gen/time.3 +++ /dev/null @@ -1,107 +0,0 @@ -.\" $NetBSD: time.3,v 1.16 2011/11/05 18:17:29 christos Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)time.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd November 5, 2011 -.Dt TIME 3 -.Os -.Sh NAME -.Nm time -.Nd get time of day -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In time.h -.Ft time_t -.Fn time "time_t *tloc" -.Sh DESCRIPTION -The -.Fn time -function -returns the value of time in seconds since 0 hours, 0 minutes, -0 seconds, January 1, 1970, Coordinated Universal Time. -.Pp -A copy of the time value may be saved to the area indicated by the -pointer -.Fa tloc . -If -.Fa tloc -is a -.Dv NULL -pointer, no value is stored. -.Pp -Upon successful completion, -.Fn time -returns the value of time. -Otherwise a value of -.Po -.Po Fa time_t Pc \-1 -.Pc -is returned and the global variable -.Va errno -is set to indicate the error. -.Sh ERRORS -No errors are defined. -.Sh SEE ALSO -.Xr gettimeofday 2 , -.Xr ctime 3 -.Sh STANDARDS -The -.Fn time -function conforms to -.St -p1003.1-90 . -.Sh HISTORY -A -.Fn time -function appeared in -.At v2 . -It returned a 32-bit value measuring sixtieths of a second, leading to -rollover every 2.26 years. -In -.At v6 , -the precision of -.Fn time -was changed to seconds, allowing 135.6 years between rollovers. -.Pp -In -.Nx 6.0 -the -.Vt time_t -type was changed to be 64 bits wide, including on 32-bit machines, -making rollover a concern for the far distant future only. -Note however that any code making the incorrect assumption that -.Vt time_t -is the same as -.Vt long -will fail on 32-bit machines in 2038. diff --git a/lib/libc/gen/time.c b/lib/libc/gen/time.c deleted file mode 100644 index 47107ab29..000000000 --- a/lib/libc/gen/time.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: time.c,v 1.12 2012/03/13 21:13:37 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: time.c,v 1.12 2012/03/13 21:13:37 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include - -time_t -time(time_t *t) -{ - struct timeval tt; - - if (gettimeofday(&tt, NULL) == -1) - return (time_t)-1; - if (t != NULL) - *t = (time_t)tt.tv_sec; - return (time_t)tt.tv_sec; -} diff --git a/lib/libc/gen/times.3 b/lib/libc/gen/times.3 deleted file mode 100644 index f14d9eb2d..000000000 --- a/lib/libc/gen/times.3 +++ /dev/null @@ -1,151 +0,0 @@ -.\" $NetBSD: times.3,v 1.15 2003/08/07 16:42:58 agc Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)times.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt TIMES 3 -.Os -.Sh NAME -.Nm times -.Nd process times -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/times.h -.Ft clock_t -.Fn times "struct tms *tp" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by -.Xr getrusage 2 -and -.Xr gettimeofday 2 . -.Ef -.Pp -The -.Fn times -function returns the value of time in clock ticks since 0 hours, 0 -minutes, 0 seconds, January 1, 1970, Coordinated Universal Time (UTC). -.Pp -The number of clock ticks per second may be determined by calling -.Xr sysconf 3 -with the -.Dv _SC_CLK_TCK -request. -It is generally (but not always) between 60 and 1024. -.Pp -Note that at the common rate of 100 ticks per second on many -.Nx -ports, and with a 32-bit unsigned clock_t, this value first wrapped in 1971. -.Pp -The -.Fn times -call also fills in the structure pointed to by -.Fa tp -with time-accounting information. -.Pp -The -.Fa tms -structure is defined as follows: -.Bd -literal -offset indent -typedef struct { - clock_t tms_utime; - clock_t tms_stime; - clock_t tms_cutime; - clock_t tms_cstime; -} -.Ed -.Pp -The elements of this structure are defined as follows: -.Bl -tag -width tms_cutime -.It Fa tms_utime -The -.Tn CPU -time charged for the execution of user instructions. -.It Fa tms_stime -The -.Tn CPU -time charged for execution by the system on behalf of -the process. -.It Fa tms_cutime -The sum of the -.Fa tms_utime s -and -.Fa tms_cutime s -of the child processes. -.It Fa tms_cstime -The sum of the -.Fa tms_stime Ns s -and -.Fa tms_cstime Ns s -of the child processes. -.El -.Pp -All times are measured in clock ticks, as defined above. -Note that at 100 ticks per second, -and with a 32-bit unsigned clock_t, -the values wrap after 497 days. -.Pp -The times of a terminated child process are included in the -.Fa tms_cutime -and -.Fa tms_cstime -elements of the parent when one of the -.Xr wait 2 -functions returns the process ID of the terminated child to the parent. -If an error occurs, -.Fn times -returns the value -.Pq (clock_t)\-1 , -and sets -.Va errno -to indicate the error. -.Sh ERRORS -The -.Fn times -function -may fail and set the global variable -.Va errno -for any of the errors specified for the library -routines -.Xr getrusage 2 -and -.Xr gettimeofday 2 . -.Sh SEE ALSO -.Xr time 1 , -.Xr getrusage 2 , -.Xr gettimeofday 2 , -.Xr wait 2 , -.Xr sysconf 3 -.Sh STANDARDS -The -.Fn times -function conforms to -.St -p1003.1-90 . diff --git a/lib/libc/gen/times.c b/lib/libc/gen/times.c deleted file mode 100644 index 55b05a18b..000000000 --- a/lib/libc/gen/times.c +++ /dev/null @@ -1,92 +0,0 @@ -/* $NetBSD: times.c,v 1.15 2009/01/11 02:46:27 christos Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)times.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: times.c,v 1.15 2009/01/11 02:46:27 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include - -/* - * Convert usec to clock ticks; could do (usec * CLK_TCK) / 1000000, - * but this would overflow if we switch to nanosec. - */ -#define CONVTCK(r) \ - (clock_t)(r.tv_sec * clk_tck + r.tv_usec / (1000000 / (uint)clk_tck)) - -#ifndef __times_rusage -#define __times_rusage struct rusage -#endif -#ifndef __times_timeval -#define __times_timeval struct timeval -#endif - -clock_t -times(struct tms *tp) -{ - __times_rusage ru; - __times_timeval t; - static clock_t clk_tck; - - _DIAGASSERT(tp != NULL); - - /* - * we use a local copy of CLK_TCK because it expands to a - * moderately expensive function call. - */ - if (clk_tck == 0) - clk_tck = (clock_t)CLK_TCK; - - if (getrusage(RUSAGE_SELF, &ru) < 0) - return ((clock_t)-1); - tp->tms_utime = CONVTCK(ru.ru_utime); - tp->tms_stime = CONVTCK(ru.ru_stime); - if (getrusage(RUSAGE_CHILDREN, &ru) < 0) - return ((clock_t)-1); - tp->tms_cutime = CONVTCK(ru.ru_utime); - tp->tms_cstime = CONVTCK(ru.ru_stime); - if (gettimeofday(&t, (struct timezone *)0)) - return ((clock_t)-1); - return ((clock_t)(CONVTCK(t))); -} diff --git a/lib/libc/gen/timezone.3 b/lib/libc/gen/timezone.3 deleted file mode 100644 index 6a202dad8..000000000 --- a/lib/libc/gen/timezone.3 +++ /dev/null @@ -1,75 +0,0 @@ -.\" $NetBSD: timezone.3,v 1.12 2003/08/07 16:42:58 agc Exp $ -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)timezone.3 8.2 (Berkeley) 4/19/94 -.\" -.Dd April 19, 1994 -.Dt TIMEZONE 3 -.Os -.Sh NAME -.Nm timezone -.Nd return the timezone abbreviation -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.Ft char * -.Fn timezone "int zone" "int dst" -.Sh DESCRIPTION -.Bf -symbolic -.\" This interface is available from the compatibility library, libcompat; -This interface is available for compatibility only and will disappear in a -future software release; -it is impossible to reliably map timezone's arguments to a time zone -abbreviation. -See -.Xr ctime 3 ; -see -.Xr tzset 3 -for the new definition of this interface. -.Ef -.Pp -The -.Fn timezone -function returns a pointer to a time zone abbreviation for the specified -.Ar zone -and -.Ar dst -values. -.Ar Zone -is the number of minutes west of GMT and -.Ar dst -is non-zero if daylight savings time is in effect. -.Sh SEE ALSO -.Xr ctime 3 , -.Xr tzset 3 -.Sh HISTORY -A -.Fn timezone -function appeared in -.At v7 . diff --git a/lib/libc/gen/toascii.3 b/lib/libc/gen/toascii.3 deleted file mode 100644 index e2c0e0f62..000000000 --- a/lib/libc/gen/toascii.3 +++ /dev/null @@ -1,83 +0,0 @@ -.\" $NetBSD: toascii.3,v 1.13 2010/04/30 04:46:18 jruoho Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)toascii.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 30, 2010 -.Dt TOASCII 3 -.Os -.Sh NAME -.Nm toascii -.Nd convert a byte to 7-bit ASCII -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn toascii "int c" -.Sh DESCRIPTION -The -.Fn toascii -function returns the argument with all but the lower 7 bits cleared. -.Sh RETURN VALUES -The -.Fn toascii -function always returns a valid ASCII character. -The result is a non-negative integer in the -range from 0 to 127, inclusive. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr tolower 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn toascii -function conforms to -.St -xpg4 -and -.St -p1003.1-2001 . -The -.St -p1003.1-2008 -revision however marked it as obsolete, noting that -.Fn toascii -cannot be used portably in a localized application. diff --git a/lib/libc/gen/toascii.c b/lib/libc/gen/toascii.c deleted file mode 100644 index c8f76afad..000000000 --- a/lib/libc/gen/toascii.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: toascii.c,v 1.3 2012/06/25 22:32:44 abs Exp $ */ - -/* - * Copyright (c) 1989 The Regents of the University of California. - * All rights reserved. - * (c) UNIX System Laboratories, Inc. - * All or some portions of this file are derived from material licensed - * to the University of California by American Telephone and Telegraph - * Co. or Unix System Laboratories, Inc. and are reproduced herein with - * the permission of UNIX System Laboratories, Inc. - * - * 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. - * - * from: @(#)isctype.c 5.2 (Berkeley) 6/1/90 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: toascii.c,v 1.3 2012/06/25 22:32:44 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include - -#undef toascii -int -toascii(int c) -{ - return ((c) & 0177); -} diff --git a/lib/libc/gen/tolower.3 b/lib/libc/gen/tolower.3 deleted file mode 100644 index 253a55e2a..000000000 --- a/lib/libc/gen/tolower.3 +++ /dev/null @@ -1,102 +0,0 @@ -.\" $NetBSD: tolower.3,v 1.14 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1989, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)tolower.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt TOLOWER 3 -.Os -.Sh NAME -.Nm tolower -.Nd upper case to lower case letter conversion -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn tolower "int c" -.Sh DESCRIPTION -The -.Fn tolower -function converts an upper-case letter to the corresponding lower-case -letter. -.Sh RETURN VALUES -If the argument is an upper-case letter, the -.Fn tolower -function returns the corresponding lower-case letter if there is -one; otherwise the argument is returned unchanged. -.\" In the -.\" .Em ``C'' -.\" locale, -.\" .Fn tolower -.\" maps only the characters for which -.\" .Xr isupper -.\" is true to the corresponding characters for which -.\" .Xr islower -.\" is true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr toupper 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn tolower -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn tolower -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/tolower_.c b/lib/libc/gen/tolower_.c deleted file mode 100644 index 11ee962e2..000000000 --- a/lib/libc/gen/tolower_.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: tolower_.c,v 1.14 2013/04/13 10:16:27 joerg Exp $ */ - -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include -#if defined(LIBC_RCS) && !defined(lint) -__RCSID("$NetBSD: tolower_.c,v 1.14 2013/04/13 10:16:27 joerg Exp $"); -#endif /* LIBC_RCS and not lint */ - -#include -#include -#include "ctype_local.h" - -#if EOF != -1 -#error "EOF != -1" -#endif - -const short _C_tolower_tab_[1 + _CTYPE_NUM_CHARS] = { - EOF, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, - 0x68, 0x69, 0x6a, 0x6b, 0x6c, 0x6d, 0x6e, 0x6f, - 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, - 0x78, 0x79, 0x7a, 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; - -#ifdef __BUILD_LEGACY -#ifdef __weak_alias -__weak_alias(_C_tolower_, _C_tolower_tab_) -#endif -#endif - -const short *_tolower_tab_ = &_C_tolower_tab_[0]; diff --git a/lib/libc/gen/toupper.3 b/lib/libc/gen/toupper.3 deleted file mode 100644 index b927a5460..000000000 --- a/lib/libc/gen/toupper.3 +++ /dev/null @@ -1,101 +0,0 @@ -.\" $NetBSD: toupper.3,v 1.17 2008/04/17 16:25:36 apb Exp $ -.\" -.\" Copyright (c) 1989, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)toupper.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd April 17, 2008 -.Dt TOUPPER 3 -.Os -.Sh NAME -.Nm toupper -.Nd lower case to upper case letter conversion -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ctype.h -.Ft int -.Fn toupper "int c" -.Sh DESCRIPTION -The -.Fn toupper -function converts a lower-case letter to the corresponding -upper-case letter. -.Sh RETURN VALUES -If the argument is a lower-case letter, the -.Fn toupper -function returns the corresponding upper-case letter if there is -one; otherwise the argument is returned unchanged. -.\" In the -.\" .Em ``C'' -.\" locale, -.\" .Fn toupper -.\" maps only the characters for which -.\" .Xr islower -.\" is true to the corresponding characters for which -.\" .Xr isupper -.\" is true. -.Sh SEE ALSO -.Xr ctype 3 , -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isascii 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 , -.Xr stdio 3 , -.Xr toascii 3 , -.Xr ascii 7 -.Sh STANDARDS -The -.Fn toupper -function conforms to -.St -ansiC . -.Sh CAVEATS -The argument to -.Fn toupper -must be -.Dv EOF -or representable as an -.Vt unsigned char ; -otherwise, the behavior is undefined. -See the -.Sx CAVEATS -section of -.Xr ctype 3 -for more details. diff --git a/lib/libc/gen/toupper_.c b/lib/libc/gen/toupper_.c deleted file mode 100644 index 46d038497..000000000 --- a/lib/libc/gen/toupper_.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: toupper_.c,v 1.14 2013/04/13 10:16:27 joerg Exp $ */ - -/* - * Written by J.T. Conklin . - * Public domain. - */ - -#include -#if defined(LIBC_RCS) && !defined(lint) -__RCSID("$NetBSD: toupper_.c,v 1.14 2013/04/13 10:16:27 joerg Exp $"); -#endif /* LIBC_RCS and not lint */ - -#include -#include -#include "ctype_local.h" - -#if EOF != -1 -#error "EOF != -1" -#endif - -const short _C_toupper_tab_[1 + _CTYPE_NUM_CHARS] = { - EOF, - 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, - 0x48, 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, - 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, - 0x58, 0x59, 0x5a, 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff -}; - -#ifdef __BUILD_LEGACY -#ifdef __weak_alias -__weak_alias(_C_toupper_, _C_toupper_tab_) -#endif -#endif - -const short *_toupper_tab_ = &_C_toupper_tab_[0]; diff --git a/lib/libc/gen/ttyname.3 b/lib/libc/gen/ttyname.3 deleted file mode 100644 index eddfa0175..000000000 --- a/lib/libc/gen/ttyname.3 +++ /dev/null @@ -1,204 +0,0 @@ -.\" $NetBSD: ttyname.3,v 1.24 2012/06/03 21:42:46 joerg Exp $ -.\" -.\" Copyright (c) 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ttyname.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 1, 2012 -.Dt TTYNAME 3 -.Os -.Sh NAME -.Nm ttyname , -.Nm ttyname_r , -.Nm isatty , -.Nm ttyslot -.Nd get name of associated terminal (tty) from file descriptor -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft char * -.Fn ttyname "int fd" -.Ft int -.Fn ttyname_r "int fd" "char *buf" "size_t len" -.Ft int -.Fn isatty "int fd" -.In stdlib.h -.Ft int -.Fn ttyslot "void" -.Sh DESCRIPTION -These functions operate on the system file descriptors for terminal -type devices. -These descriptors are not related to the standard -.Tn I/O -.Dv FILE -typedef, but refer to the special device files found in -.Pa /dev -and named -.Pa /dev/tty Ns Em xx -and for which an entry exists in the initialization file -.Pa /etc/ttys -(see -.Xr ttys 5 ) , -or for pseudo-terminal devices created in ptyfs and named -.Pa /dev/pts/ Ns Em n . -.Pp -The -.Fn isatty -function -determines if the file descriptor -.Fa fd -refers to a valid terminal type device. -.Pp -The -.Fn ttyname -function gets the related device name of a file descriptor for -which -.Fn isatty -is true. -The -.Fn ttyname_r -is the reentrant version of the above, and it places the results in -.Fa buf . -If there is not enough space to place the results (indicated by -.Fa len ) , -then it returns an error. -.Pp -The -.Fn ttyslot -function -fetches the current process' control terminal number from the -.Xr ttys 5 -file entry. -If the terminal is a pseudo-terminal, and there is no special entry -in the -.Xr ttys 5 -file for it, the slot number returned is 1 + (last slot number) + -minor(tty). -This will return a consistent and unique number for each pseudo-terminal -device without requiring one to enumerate all of them in -.Xr ttys 5 . -.Sh IMPLEMENTATION NOTES -As an optimisation, these functions attempt to obtain information about -all devices from the -.Pa /var/run/dev.cdb -database, if it exists. -If the database exists but is out of date, then these functions -may produce incorrect results. -The database should be updated using the -.Xr dev_mkdb 8 -command. -.Sh RETURN VALUES -The -.Fn ttyname -function returns the NUL-terminated name if the device is found and -.Fn isatty -is true; otherwise -a -.Dv NULL -pointer is returned and -.Va errno -is set to indicate the error. -.Pp -The -.Fn ttyname_r -functions returns 0 on success and an error code on failure. -.Pp -The -.Fn isatty -function returns 1 if -.Fa fd -is associated with a terminal device; otherwise it returns 0 and -.Va errno -is set to indicate the error. -.Pp -The -.Fn ttyslot -function -returns the unit number of the device file if found; otherwise -the value zero is returned. -.Sh FILES -.Bl -tag -width /etc/ttys -compact -.It Pa /dev/\(** -.It Pa /etc/ttys -.El -.Sh ERRORS -The -.Fn ttyname , -.Fn ttyname_r , -and -.Fn isatty -functions will fail if: -.Bl -tag -width Er -.It Bq Er EBADF -The -.Fa fd -argument is not a valid file descriptor. -.It Bq Er ENOTTY -The -.Fa fd -argument does not refer to a terminal device. -.El -.Pp -The -.Fn ttyname_r -function will also fail if: -.Bl -tag -width Er -.It Bq Er ENOENT -The terminal device is not found. -This can happen if the device node has been removed after it was opened. -.It Bq Er ERANGE -The buffer provided is not large enough to fit the result. -.El -.Sh SEE ALSO -.Xr ioctl 2 , -.Xr ttys 5 , -.Xr dev_mkdb 8 -.Sh STANDARDS -The -.Fn ttyname -and -.Fn isatty -functions conform to -.St -p1003.1-90 . -.Sh HISTORY -.Fn isatty , -.Fn ttyname , -and -.Fn ttyslot -functions appeared in -.At v7 . -.\" Use of the .Pa /var/run/dev.cdb file was added in netBSD 6.0. -.Sh BUGS -The -.Fn ttyname -function leaves its result in an internal static object and returns -a pointer to that object. -Subsequent calls to -.Fn ttyname -will modify the same object. diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c deleted file mode 100644 index 878e6792d..000000000 --- a/lib/libc/gen/ttyname.c +++ /dev/null @@ -1,102 +0,0 @@ -/* $NetBSD: ttyname.c,v 1.26 2012/06/12 18:17:04 joerg Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ttyname.c 8.2 (Berkeley) 1/27/94"; -#else -__RCSID("$NetBSD: ttyname.c,v 1.26 2012/06/12 18:17:04 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(ttyname,_ttyname) -__weak_alias(ttyname_r,_ttyname_r) -#endif - -int -ttyname_r(int fd, char *buf, size_t len) -{ - struct stat sb; - struct termios ttyb; - struct ptmget ptm; - - _DIAGASSERT(fd != -1); - - /* If it is a pty, deal with it quickly */ - if (ioctl(fd, TIOCPTSNAME, &ptm) != -1) { - if (strlcpy(buf, ptm.sn, len) >= len) { - return ERANGE; - } - return 0; - } - - /* Must be a terminal. */ - if (tcgetattr(fd, &ttyb) == -1) - return errno; - - if (fstat(fd, &sb)) - return errno; - - if (strlcpy(buf, _PATH_DEV, len) >= len) - return ERANGE; - buf += strlen(_PATH_DEV); - len -= strlen(_PATH_DEV); - return devname_r(sb.st_rdev, sb.st_mode & S_IFMT, buf, len); -} - -char * -ttyname(int fd) -{ - static char buf[PATH_MAX]; - int rv; - - rv = ttyname_r(fd, buf, sizeof(buf)); - if (rv != 0) { - errno = rv; - return NULL; - } - return buf; -} diff --git a/lib/libc/gen/ttyslot.c b/lib/libc/gen/ttyslot.c deleted file mode 100644 index 4fc89ee5e..000000000 --- a/lib/libc/gen/ttyslot.c +++ /dev/null @@ -1,98 +0,0 @@ -/* $NetBSD: ttyslot.c,v 1.13 2009/01/11 02:46:27 christos Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ttyslot.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: ttyslot.c,v 1.13 2009/01/11 02:46:27 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(ttyslot,_ttyslot) -#endif - -int -ttyslot(void) -{ - struct ttyent *ttyp; - int slot = 0, ispty = 0; - char *p; - int cnt; - char *name; - struct ptmget ptm; - - setttyent(); - for (cnt = 0; cnt < 3; ++cnt) { - if (ioctl(cnt, TIOCPTSNAME, &ptm) != -1) { -#if !defined(__minix) - ispty = 1; -#endif /* !defined(__minix) */ - name = ptm.sn; - } else if ((name = ttyname(cnt)) != NULL) { - ispty = 0; - } else - continue; - - if ((p = strstr(name, "/pts/")) != NULL) - ++p; - else if ((p = strrchr(name, '/')) != NULL) - ++p; - else - p = name; - - for (slot = 1; (ttyp = getttyent()) != NULL; ++slot) - if (!strcmp(ttyp->ty_name, p)) { - endttyent(); - return slot; - } - break; - } - endttyent(); - if (ispty) { - struct stat st; - if (fstat(cnt, &st) == -1) - return 0; - return slot + (int)minor(st.st_rdev) + 1; - } - return 0; -} diff --git a/lib/libc/gen/ualarm.3 b/lib/libc/gen/ualarm.3 deleted file mode 100644 index 39b91ae09..000000000 --- a/lib/libc/gen/ualarm.3 +++ /dev/null @@ -1,103 +0,0 @@ -.\" $NetBSD: ualarm.3,v 1.19 2011/05/02 17:34:05 jruoho Exp $ -.\" -.\" Copyright (c) 1986, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)ualarm.3 8.2 (Berkeley) 4/19/94 -.\" -.Dd May 2, 2011 -.Dt UALARM 3 -.Os -.Sh NAME -.Nm ualarm -.Nd schedule signal after specified time -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft useconds_t -.Fn ualarm "useconds_t microseconds" "useconds_t interval" -.Sh DESCRIPTION -.Bf -symbolic -This is a simplified interface to -.Xr setitimer 2 . -.Ef -.Pp -The -.Fn ualarm -function -waits a count of -.Ar microseconds -before asserting the terminating signal -.Dv SIGALRM . -System activity or time used in processing the call may cause a slight -delay. -.Pp -If the -.Fa interval -argument is non-zero, the -.Dv SIGALRM -signal will be sent -to the process every -.Fa interval -microseconds after the timer expires (e.g. after -.Fa microseconds -microseconds have passed). -.Sh RETURN VALUES -When the signal has successfully been caught, -.Fn ualarm -returns the amount of time left on the clock. -The maximum number of -.Ar microseconds -allowed -is 2147483647. -If there is an error setting the timer, -.Fn ualarm -returns ((useconds_t) -1). -.Sh SEE ALSO -.Xr getitimer 2 , -.Xr setitimer 2 , -.Xr sigaction 2 , -.Xr sigsuspend 2 , -.Xr alarm 3 , -.Xr signal 3 , -.Xr sigvec 3 , -.Xr sleep 3 , -.Xr usleep 3 -.Sh STANDARDS -The -.Fn ualarm -function conforms to -.St -p1003.1-2001 . -However, the later -.St -p1003.1-2008 -revision removed the function from the specification. -.Sh HISTORY -The -.Fn ualarm -function appeared in -.Bx 4.3 . diff --git a/lib/libc/gen/ualarm.c b/lib/libc/gen/ualarm.c deleted file mode 100644 index 74c655bf5..000000000 --- a/lib/libc/gen/ualarm.c +++ /dev/null @@ -1,72 +0,0 @@ -/* $NetBSD: ualarm.c,v 1.11 2012/06/25 22:32:44 abs Exp $ */ - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)ualarm.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: ualarm.c,v 1.11 2012/06/25 22:32:44 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(ualarm,_ualarm) -#endif - -#define USPS 1000000 /* # of microseconds in a second */ - -/* - * Generate a SIGALRM signal in ``usecs'' microseconds. - * If ``reload'' is non-zero, keep generating SIGALRM - * every ``reload'' microseconds after the first signal. - */ -useconds_t -ualarm(useconds_t usecs, useconds_t reload) -{ - struct itimerval new, old; - - new.it_interval.tv_usec = reload % USPS; - new.it_interval.tv_sec = reload / USPS; - - new.it_value.tv_usec = usecs % USPS; - new.it_value.tv_sec = usecs / USPS; - - if (setitimer(ITIMER_REAL, &new, &old) == 0) - return (useconds_t)(old.it_value.tv_sec * USPS + - old.it_value.tv_usec); - - return (useconds_t)-1; -} diff --git a/lib/libc/gen/ulimit.3 b/lib/libc/gen/ulimit.3 deleted file mode 100644 index 5312050cf..000000000 --- a/lib/libc/gen/ulimit.3 +++ /dev/null @@ -1,119 +0,0 @@ -.\" $NetBSD: ulimit.3,v 1.9 2010/04/30 05:09:23 jruoho Exp $ -.\" -.\" Copyright (c) 1999 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd April 30, 2010 -.Dt ULIMIT 3 -.Os -.Sh NAME -.Nm ulimit -.Nd get and set process limits -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In ulimit.h -.Ft long int -.Fn ulimit "int cmd" ... -.Sh DESCRIPTION -The -.Fn ulimit -function provides a method to query or alter resource limits of the calling -process. -The method to be performed is specified by the -.Fa cmd -argument; possible values are: -.Bl -tag -width UL_GETFSIZEXX -.It Li UL_GETFSIZE -Return the soft file size limit of the process. -The value returned is in units of 512-byte blocks. -If the result cannot be represented in an object of type -.Fa long int , -the result is unspecified. -.It Li UL_SETFSIZE -Set the hard and soft file size limits of the process to the value of the -second argument passed, which is in units of 512-byte blocks, and which is -expected to be of type -.Fa long int . -The new file size limit of the process is returned. -Any process may decrease the limit, but raising it is only permitted if -the caller is the super-user. -.El -.Pp -If successful, the -.Fn ulimit -function will not change the setting of -.Va errno . -.Sh RETURN VALUES -If successful, the -.Fn ulimit -function returns the value of the requested limit. -Otherwise, it returns \-1, sets -.Va errno -to indicate an error, and the limit is not changed. -Therefore, to detect an error condition applications should set -.Va errno -to 0, call -.Fn ulimit , -and check if \-1 is returned and -.Va errno -is non-zero. -.Sh ERRORS -The -.Fn ulimit -function will fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa cmd -argument is not valid. -.It Bq Er EPERM -It was attempted to increase a limit, and the caller is not the super-user. -.El -.Sh SEE ALSO -.Xr getrlimit 2 , -.Xr setrlimit 2 -.Sh STANDARDS -The -.Fn ulimit -function conforms to -.St -xsh5 -and -.St -p1003.1-2001 . -It was marked as obsolete in the -.St -p1003.1-2008 -revision, which recommended the use of -.Xr getrlimit 2 -and -.Xr setrlimit 2 -instead, noting that because -.Fn ulimit -uses the type -.Vt long -rather than -.Vt rlim_t , -it may not be sufficient for file sizes on many current systems. diff --git a/lib/libc/gen/ulimit.c b/lib/libc/gen/ulimit.c deleted file mode 100644 index ba61a22f9..000000000 --- a/lib/libc/gen/ulimit.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: ulimit.c,v 1.3 2008/04/28 20:22:59 martin Exp $ */ - -/*- - * Copyright (c) 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ulimit.c,v 1.3 2008/04/28 20:22:59 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - -long int -ulimit(int cmd, ...) -{ - va_list ap; - struct rlimit rlimit; - long int new_limit, result; - - va_start(ap, cmd); - - result = -1L; - switch (cmd) { - case UL_GETFSIZE: - if (getrlimit(RLIMIT_FSIZE, &rlimit) == 0) - result = (long int)(rlimit.rlim_cur / 512); - break; - case UL_SETFSIZE: - new_limit = va_arg(ap, long int); - rlimit.rlim_cur = rlimit.rlim_max = (rlim_t)new_limit * 512; - if (setrlimit(RLIMIT_FSIZE, &rlimit) == 0) - result = new_limit; - break; - default: - errno = EINVAL; - } - - va_end(ap); - - return (result); -} diff --git a/lib/libc/gen/uname.3 b/lib/libc/gen/uname.3 deleted file mode 100644 index 8de5a4d0e..000000000 --- a/lib/libc/gen/uname.3 +++ /dev/null @@ -1,114 +0,0 @@ -.\" $NetBSD: uname.3,v 1.13 2014/06/14 14:32:43 apb Exp $ -.\" -.\" Copyright (c) 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)uname.3 8.1 (Berkeley) 1/4/94 -.\" -.Dd June 14, 2014 -.Dt UNAME 3 -.Os -.Sh NAME -.Nm uname -.Nd get system identification -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/utsname.h -.Ft int -.Fn uname "struct utsname *name" -.Sh DESCRIPTION -The -.Fn uname -function stores nul-terminated strings of information identifying -the current system into the structure referenced by -.Fa name . -.Pp -The -.Em utsname -structure is defined in the -.In sys/utsname.h -header file, and contains the following members: -.Bl -tag -width nodenameXXXX -offset indent -.It Va sysname -Name of the operating system implementation. -Equivalent to the -.Xr sysctl 7 -.Va kern.ostype -variable. -.It Va nodename -Network name of this machine. -Equivalent to the -.Xr sysctl 7 -.Va kern.hostname -variable. -.It Va release -Release level of the operating system. -Equivalent to the -.Xr sysctl 7 -.Va kern.osrelease -variable. -.It Va version -Version level of the operating system. -Equivalent to the -.Xr sysctl 7 -.Va kern.version -variable, except that very long values are truncated, -and newlines are converted to spaces. -.It Va machine -Machine hardware platform. -Equivalent to the -.Xr sysctl 7 -.Va hw.machine -variable. -.El -.Sh RETURN VALUES -If -.Nm uname -is successful, 0 is returned, otherwise, \-1 is returned and -.Va errno -is set appropriately. -.Sh ERRORS -The -.Fn uname -function may fail and set -.Va errno -for any of the errors specified for the library functions -.Xr sysctl 3 . -.Sh SEE ALSO -.Xr uname 1 , -.Xr sysctl 3 -.Sh STANDARDS -The -.Fn uname -function conforms to -.St -p1003.1-90 . -.Sh HISTORY -The -.Nm uname -function first appeared in -.Bx 4.4 . diff --git a/lib/libc/gen/uname.c b/lib/libc/gen/uname.c deleted file mode 100644 index de3c886f8..000000000 --- a/lib/libc/gen/uname.c +++ /dev/null @@ -1,114 +0,0 @@ -/* $NetBSD: uname.c,v 1.12 2014/06/14 13:09:37 apb Exp $ */ - -/*- - * Copyright (c) 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)uname.c 8.1 (Berkeley) 1/4/94"; -#else -__RCSID("$NetBSD: uname.c,v 1.12 2014/06/14 13:09:37 apb Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include - -#ifdef __weak_alias -__weak_alias(uname,_uname) -#endif - -int -uname(struct utsname *name) -{ - int mib[2]; - size_t len; - char *p; - - _DIAGASSERT(name != NULL); - - mib[0] = CTL_KERN; - mib[1] = KERN_OSTYPE; - len = sizeof(name->sysname); - if (sysctl(mib, 2, &name->sysname, &len, NULL, 0) == -1) - goto error; - - mib[0] = CTL_KERN; - mib[1] = KERN_HOSTNAME; - len = sizeof(name->nodename); - if (sysctl(mib, 2, &name->nodename, &len, NULL, 0) == -1) - goto error; - - mib[0] = CTL_KERN; - mib[1] = KERN_OSRELEASE; - len = sizeof(name->release); - if (sysctl(mib, 2, &name->release, &len, NULL, 0) == -1) - goto error; - - mib[0] = CTL_KERN; - mib[1] = KERN_VERSION; - len = sizeof(name->version); - if (sysctl(mib, 2, &name->version, &len, NULL, 0) == -1) { - if (errno == ENOMEM) { - /* - * string is too long for {struct utsname}.version. - * Just use the truncated string. - * XXX: We could mark the truncation with "..." - */ - name->version[sizeof(name->version) - 1] = '\0'; - } - else goto error; - } - - /* The version may have newlines in it, turn them into spaces. */ - for (p = name->version; len--; ++p) { - if (*p == '\n' || *p == '\t') { - if (len > 1) - *p = ' '; - else - *p = '\0'; - } - } - - mib[0] = CTL_HW; - mib[1] = HW_MACHINE; - len = sizeof(name->machine); - if (sysctl(mib, 2, &name->machine, &len, NULL, 0) == -1) - goto error; - return (0); - -error: - return (-1); -} diff --git a/lib/libc/gen/unvis.3 b/lib/libc/gen/unvis.3 deleted file mode 100644 index b856a730e..000000000 --- a/lib/libc/gen/unvis.3 +++ /dev/null @@ -1,259 +0,0 @@ -.\" $NetBSD: unvis.3,v 1.27 2012/12/15 07:34:36 wiz Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)unvis.3 8.2 (Berkeley) 12/11/93 -.\" -.Dd March 12, 2011 -.Dt UNVIS 3 -.Os -.Sh NAME -.Nm unvis , -.Nm strunvis -.Nd decode a visual representation of characters -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In vis.h -.Ft int -.Fn unvis "char *cp" "int c" "int *astate" "int flag" -.Ft int -.Fn strunvis "char *dst" "const char *src" -.Ft int -.Fn strnunvis "char *dst" "size_t dlen" "const char *src" -.Ft int -.Fn strunvisx "char *dst" "const char *src" "int flag" -.Ft int -.Fn strnunvisx "char *dst" "size_t dlen" "const char *src" "int flag" -.Sh DESCRIPTION -The -.Fn unvis , -.Fn strunvis -and -.Fn strunvisx -functions -are used to decode a visual representation of characters, as produced -by the -.Xr vis 3 -function, back into -the original form. -.Pp -The -.Fn unvis -function is called with successive characters in -.Ar c -until a valid sequence is recognized, at which time the decoded -character is available at the character pointed to by -.Ar cp . -.Pp -The -.Fn strunvis -function decodes the characters pointed to by -.Ar src -into the buffer pointed to by -.Ar dst . -The -.Fn strunvis -function simply copies -.Ar src -to -.Ar dst , -decoding any escape sequences along the way, -and returns the number of characters placed into -.Ar dst , -or \-1 if an -invalid escape sequence was detected. -The size of -.Ar dst -should be equal to the size of -.Ar src -(that is, no expansion takes place during decoding). -.Pp -The -.Fn strunvisx -function does the same as the -.Fn strunvis -function, -but it allows you to add a flag that specifies the style the string -.Ar src -is encoded with. -Currently, the supported flags are: -.Dv VIS_HTTPSTYLE -and -.Dv VIS_MIMESTYLE . -.Pp -The -.Fn unvis -function implements a state machine that can be used to decode an -arbitrary stream of bytes. -All state associated with the bytes being decoded is stored outside the -.Fn unvis -function (that is, a pointer to the state is passed in), so -calls decoding different streams can be freely intermixed. -To start decoding a stream of bytes, first initialize an integer to zero. -Call -.Fn unvis -with each successive byte, along with a pointer -to this integer, and a pointer to a destination character. -The -.Fn unvis -function has several return codes that must be handled properly. -They are: -.Bl -tag -width UNVIS_VALIDPUSH -.It Li \&0 No (zero) -Another character is necessary; nothing has been recognized yet. -.It Dv UNVIS_VALID -A valid character has been recognized and is available at the location -pointed to by -.Fa cp . -.It Dv UNVIS_VALIDPUSH -A valid character has been recognized and is available at the location -pointed to by -.Fa cp ; -however, the character currently passed in should be passed in again. -.It Dv UNVIS_NOCHAR -A valid sequence was detected, but no character was produced. -This return code is necessary to indicate a logical break between characters. -.It Dv UNVIS_SYNBAD -An invalid escape sequence was detected, or the decoder is in an unknown state. -The decoder is placed into the starting state. -.El -.Pp -When all bytes in the stream have been processed, call -.Fn unvis -one more time with flag set to -.Dv UNVIS_END -to extract any remaining character (the character passed in is ignored). -.Pp -The -.Fa flag -argument is also used to specify the encoding style of the source. -If set to -.Dv VIS_HTTPSTYLE -or -.Dv VIS_HTTP1808 , -.Fn unvis -will decode URI strings as specified in RFC 1808. -If set to -.Dv VIS_HTTP1866 , -.Fn unvis -will decode entity references and numeric character references -as specified in RFC 1866. -If set to -.Dv VIS_MIMESTYLE , -.Fn unvis -will decode MIME Quoted-Printable strings as specified in RFC 2045. -If set to -.Dv VIS_NOESCAPE , -.Fn unvis -will not decode -.Ql \e -quoted characters. -.Pp -The following code fragment illustrates a proper use of -.Fn unvis . -.Bd -literal -offset indent -int state = 0; -char out; - -while ((ch = getchar()) != EOF) { -again: - switch(unvis(\*[Am]out, ch, \*[Am]state, 0)) { - case 0: - case UNVIS_NOCHAR: - break; - case UNVIS_VALID: - (void)putchar(out); - break; - case UNVIS_VALIDPUSH: - (void)putchar(out); - goto again; - case UNVIS_SYNBAD: - errx(EXIT_FAILURE, "Bad character sequence!"); - } -} -if (unvis(\*[Am]out, '\e0', \*[Am]state, UNVIS_END) == UNVIS_VALID) - (void)putchar(out); -.Ed -.Sh ERRORS -The functions -.Fn strunvis , -.Fn strnunvis , -.Fn strunvisx , -and -.Fn strnunvisx -will return \-1 on error and set -.Va errno -to: -.Bl -tag -width Er -.It Bq Er EINVAL -An invalid escape sequence was detected, or the decoder is in an unknown state. -.El -.Pp -In addition the functions -.Fn strnunvis -and -.Fn strnunvisx -will can also set -.Va errno -on error to: -.Bl -tag -width Er -.It Bq Er ENOSPC -Not enough space to perform the conversion. -.El -.Sh SEE ALSO -.Xr unvis 1 , -.Xr vis 1 , -.Xr vis 3 -.Rs -.%A R. Fielding -.%T Relative Uniform Resource Locators -.%O RFC1808 -.Re -.Sh HISTORY -The -.Fn unvis -function -first appeared in -.Bx 4.4 . -The -.Fn strnunvis -and -.Fn strnunvisx -functions appeared in -.Nx 6.0 . -.Sh BUGS -The names -.Dv VIS_HTTP1808 -and -.Dv VIS_HTTP1866 -are wrong. -Percent-encoding was defined in RFC 1738, the original RFC for URL. -RFC 1866 defines HTML 2.0, an application of SGML, from which it -inherits concepts of numeric character references and entity -references. diff --git a/lib/libc/gen/unvis.c b/lib/libc/gen/unvis.c deleted file mode 100644 index 30fad8154..000000000 --- a/lib/libc/gen/unvis.c +++ /dev/null @@ -1,559 +0,0 @@ -/* $NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $ */ - -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(strnunvisx,_strnunvisx) -#endif - -#if !HAVE_VIS -/* - * decode driven by state machine - */ -#define S_GROUND 0 /* haven't seen escape char */ -#define S_START 1 /* start decoding special sequence */ -#define S_META 2 /* metachar started (M) */ -#define S_META1 3 /* metachar more, regular char (-) */ -#define S_CTRL 4 /* control char started (^) */ -#define S_OCTAL2 5 /* octal digit 2 */ -#define S_OCTAL3 6 /* octal digit 3 */ -#define S_HEX 7 /* mandatory hex digit */ -#define S_HEX1 8 /* http hex digit */ -#define S_HEX2 9 /* http hex digit 2 */ -#define S_MIME1 10 /* mime hex digit 1 */ -#define S_MIME2 11 /* mime hex digit 2 */ -#define S_EATCRNL 12 /* mime eating CRNL */ -#define S_AMP 13 /* seen & */ -#define S_NUMBER 14 /* collecting number */ -#define S_STRING 15 /* collecting string */ - -#define isoctal(c) (((u_char)(c)) >= '0' && ((u_char)(c)) <= '7') -#define xtod(c) (isdigit(c) ? (c - '0') : ((tolower(c) - 'a') + 10)) -#define XTOD(c) (isdigit(c) ? (c - '0') : ((c - 'A') + 10)) - -/* - * RFC 1866 - */ -static const struct nv { - char name[7]; - uint8_t value; -} nv[] = { - { "AElig", 198 }, /* capital AE diphthong (ligature) */ - { "Aacute", 193 }, /* capital A, acute accent */ - { "Acirc", 194 }, /* capital A, circumflex accent */ - { "Agrave", 192 }, /* capital A, grave accent */ - { "Aring", 197 }, /* capital A, ring */ - { "Atilde", 195 }, /* capital A, tilde */ - { "Auml", 196 }, /* capital A, dieresis or umlaut mark */ - { "Ccedil", 199 }, /* capital C, cedilla */ - { "ETH", 208 }, /* capital Eth, Icelandic */ - { "Eacute", 201 }, /* capital E, acute accent */ - { "Ecirc", 202 }, /* capital E, circumflex accent */ - { "Egrave", 200 }, /* capital E, grave accent */ - { "Euml", 203 }, /* capital E, dieresis or umlaut mark */ - { "Iacute", 205 }, /* capital I, acute accent */ - { "Icirc", 206 }, /* capital I, circumflex accent */ - { "Igrave", 204 }, /* capital I, grave accent */ - { "Iuml", 207 }, /* capital I, dieresis or umlaut mark */ - { "Ntilde", 209 }, /* capital N, tilde */ - { "Oacute", 211 }, /* capital O, acute accent */ - { "Ocirc", 212 }, /* capital O, circumflex accent */ - { "Ograve", 210 }, /* capital O, grave accent */ - { "Oslash", 216 }, /* capital O, slash */ - { "Otilde", 213 }, /* capital O, tilde */ - { "Ouml", 214 }, /* capital O, dieresis or umlaut mark */ - { "THORN", 222 }, /* capital THORN, Icelandic */ - { "Uacute", 218 }, /* capital U, acute accent */ - { "Ucirc", 219 }, /* capital U, circumflex accent */ - { "Ugrave", 217 }, /* capital U, grave accent */ - { "Uuml", 220 }, /* capital U, dieresis or umlaut mark */ - { "Yacute", 221 }, /* capital Y, acute accent */ - { "aacute", 225 }, /* small a, acute accent */ - { "acirc", 226 }, /* small a, circumflex accent */ - { "acute", 180 }, /* acute accent */ - { "aelig", 230 }, /* small ae diphthong (ligature) */ - { "agrave", 224 }, /* small a, grave accent */ - { "amp", 38 }, /* ampersand */ - { "aring", 229 }, /* small a, ring */ - { "atilde", 227 }, /* small a, tilde */ - { "auml", 228 }, /* small a, dieresis or umlaut mark */ - { "brvbar", 166 }, /* broken (vertical) bar */ - { "ccedil", 231 }, /* small c, cedilla */ - { "cedil", 184 }, /* cedilla */ - { "cent", 162 }, /* cent sign */ - { "copy", 169 }, /* copyright sign */ - { "curren", 164 }, /* general currency sign */ - { "deg", 176 }, /* degree sign */ - { "divide", 247 }, /* divide sign */ - { "eacute", 233 }, /* small e, acute accent */ - { "ecirc", 234 }, /* small e, circumflex accent */ - { "egrave", 232 }, /* small e, grave accent */ - { "eth", 240 }, /* small eth, Icelandic */ - { "euml", 235 }, /* small e, dieresis or umlaut mark */ - { "frac12", 189 }, /* fraction one-half */ - { "frac14", 188 }, /* fraction one-quarter */ - { "frac34", 190 }, /* fraction three-quarters */ - { "gt", 62 }, /* greater than */ - { "iacute", 237 }, /* small i, acute accent */ - { "icirc", 238 }, /* small i, circumflex accent */ - { "iexcl", 161 }, /* inverted exclamation mark */ - { "igrave", 236 }, /* small i, grave accent */ - { "iquest", 191 }, /* inverted question mark */ - { "iuml", 239 }, /* small i, dieresis or umlaut mark */ - { "laquo", 171 }, /* angle quotation mark, left */ - { "lt", 60 }, /* less than */ - { "macr", 175 }, /* macron */ - { "micro", 181 }, /* micro sign */ - { "middot", 183 }, /* middle dot */ - { "nbsp", 160 }, /* no-break space */ - { "not", 172 }, /* not sign */ - { "ntilde", 241 }, /* small n, tilde */ - { "oacute", 243 }, /* small o, acute accent */ - { "ocirc", 244 }, /* small o, circumflex accent */ - { "ograve", 242 }, /* small o, grave accent */ - { "ordf", 170 }, /* ordinal indicator, feminine */ - { "ordm", 186 }, /* ordinal indicator, masculine */ - { "oslash", 248 }, /* small o, slash */ - { "otilde", 245 }, /* small o, tilde */ - { "ouml", 246 }, /* small o, dieresis or umlaut mark */ - { "para", 182 }, /* pilcrow (paragraph sign) */ - { "plusmn", 177 }, /* plus-or-minus sign */ - { "pound", 163 }, /* pound sterling sign */ - { "quot", 34 }, /* double quote */ - { "raquo", 187 }, /* angle quotation mark, right */ - { "reg", 174 }, /* registered sign */ - { "sect", 167 }, /* section sign */ - { "shy", 173 }, /* soft hyphen */ - { "sup1", 185 }, /* superscript one */ - { "sup2", 178 }, /* superscript two */ - { "sup3", 179 }, /* superscript three */ - { "szlig", 223 }, /* small sharp s, German (sz ligature) */ - { "thorn", 254 }, /* small thorn, Icelandic */ - { "times", 215 }, /* multiply sign */ - { "uacute", 250 }, /* small u, acute accent */ - { "ucirc", 251 }, /* small u, circumflex accent */ - { "ugrave", 249 }, /* small u, grave accent */ - { "uml", 168 }, /* umlaut (dieresis) */ - { "uuml", 252 }, /* small u, dieresis or umlaut mark */ - { "yacute", 253 }, /* small y, acute accent */ - { "yen", 165 }, /* yen sign */ - { "yuml", 255 }, /* small y, dieresis or umlaut mark */ -}; - -/* - * unvis - decode characters previously encoded by vis - */ -int -unvis(char *cp, int c, int *astate, int flag) -{ - unsigned char uc = (unsigned char)c; - unsigned char st, ia, is, lc; - -/* - * Bottom 8 bits of astate hold the state machine state. - * Top 8 bits hold the current character in the http 1866 nv string decoding - */ -#define GS(a) ((a) & 0xff) -#define SS(a, b) (((uint32_t)(a) << 24) | (b)) -#define GI(a) ((uint32_t)(a) >> 24) - - _DIAGASSERT(cp != NULL); - _DIAGASSERT(astate != NULL); - st = GS(*astate); - - if (flag & UNVIS_END) { - switch (st) { - case S_OCTAL2: - case S_OCTAL3: - case S_HEX2: - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case S_GROUND: - return UNVIS_NOCHAR; - default: - return UNVIS_SYNBAD; - } - } - - switch (st) { - - case S_GROUND: - *cp = 0; - if ((flag & VIS_NOESCAPE) == 0 && c == '\\') { - *astate = SS(0, S_START); - return UNVIS_NOCHAR; - } - if ((flag & VIS_HTTP1808) && c == '%') { - *astate = SS(0, S_HEX1); - return UNVIS_NOCHAR; - } - if ((flag & VIS_HTTP1866) && c == '&') { - *astate = SS(0, S_AMP); - return UNVIS_NOCHAR; - } - if ((flag & VIS_MIMESTYLE) && c == '=') { - *astate = SS(0, S_MIME1); - return UNVIS_NOCHAR; - } - *cp = c; - return UNVIS_VALID; - - case S_START: - switch(c) { - case '\\': - *cp = c; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case '0': case '1': case '2': case '3': - case '4': case '5': case '6': case '7': - *cp = (c - '0'); - *astate = SS(0, S_OCTAL2); - return UNVIS_NOCHAR; - case 'M': - *cp = (char)0200; - *astate = SS(0, S_META); - return UNVIS_NOCHAR; - case '^': - *astate = SS(0, S_CTRL); - return UNVIS_NOCHAR; - case 'n': - *cp = '\n'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 'r': - *cp = '\r'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 'b': - *cp = '\b'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 'a': - *cp = '\007'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 'v': - *cp = '\v'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 't': - *cp = '\t'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 'f': - *cp = '\f'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 's': - *cp = ' '; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 'E': - *cp = '\033'; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - case 'x': - *astate = SS(0, S_HEX); - return UNVIS_NOCHAR; - case '\n': - /* - * hidden newline - */ - *astate = SS(0, S_GROUND); - return UNVIS_NOCHAR; - case '$': - /* - * hidden marker - */ - *astate = SS(0, S_GROUND); - return UNVIS_NOCHAR; - default: - if (isgraph(c)) { - *cp = c; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - } - } - goto bad; - - case S_META: - if (c == '-') - *astate = SS(0, S_META1); - else if (c == '^') - *astate = SS(0, S_CTRL); - else - goto bad; - return UNVIS_NOCHAR; - - case S_META1: - *astate = SS(0, S_GROUND); - *cp |= c; - return UNVIS_VALID; - - case S_CTRL: - if (c == '?') - *cp |= 0177; - else - *cp |= c & 037; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - - case S_OCTAL2: /* second possible octal digit */ - if (isoctal(uc)) { - /* - * yes - and maybe a third - */ - *cp = (*cp << 3) + (c - '0'); - *astate = SS(0, S_OCTAL3); - return UNVIS_NOCHAR; - } - /* - * no - done with current sequence, push back passed char - */ - *astate = SS(0, S_GROUND); - return UNVIS_VALIDPUSH; - - case S_OCTAL3: /* third possible octal digit */ - *astate = SS(0, S_GROUND); - if (isoctal(uc)) { - *cp = (*cp << 3) + (c - '0'); - return UNVIS_VALID; - } - /* - * we were done, push back passed char - */ - return UNVIS_VALIDPUSH; - - case S_HEX: - if (!isxdigit(uc)) - goto bad; - /*FALLTHROUGH*/ - case S_HEX1: - if (isxdigit(uc)) { - *cp = xtod(uc); - *astate = SS(0, S_HEX2); - return UNVIS_NOCHAR; - } - /* - * no - done with current sequence, push back passed char - */ - *astate = SS(0, S_GROUND); - return UNVIS_VALIDPUSH; - - case S_HEX2: - *astate = S_GROUND; - if (isxdigit(uc)) { - *cp = xtod(uc) | (*cp << 4); - return UNVIS_VALID; - } - return UNVIS_VALIDPUSH; - - case S_MIME1: - if (uc == '\n' || uc == '\r') { - *astate = SS(0, S_EATCRNL); - return UNVIS_NOCHAR; - } - if (isxdigit(uc) && (isdigit(uc) || isupper(uc))) { - *cp = XTOD(uc); - *astate = SS(0, S_MIME2); - return UNVIS_NOCHAR; - } - goto bad; - - case S_MIME2: - if (isxdigit(uc) && (isdigit(uc) || isupper(uc))) { - *astate = SS(0, S_GROUND); - *cp = XTOD(uc) | (*cp << 4); - return UNVIS_VALID; - } - goto bad; - - case S_EATCRNL: - switch (uc) { - case '\r': - case '\n': - return UNVIS_NOCHAR; - case '=': - *astate = SS(0, S_MIME1); - return UNVIS_NOCHAR; - default: - *cp = uc; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - } - - case S_AMP: - *cp = 0; - if (uc == '#') { - *astate = SS(0, S_NUMBER); - return UNVIS_NOCHAR; - } - *astate = SS(0, S_STRING); - /*FALLTHROUGH*/ - - case S_STRING: - ia = *cp; /* index in the array */ - is = GI(*astate); /* index in the string */ - lc = is == 0 ? 0 : nv[ia].name[is - 1]; /* last character */ - - if (uc == ';') - uc = '\0'; - - for (; ia < __arraycount(nv); ia++) { - if (is != 0 && nv[ia].name[is - 1] != lc) - goto bad; - if (nv[ia].name[is] == uc) - break; - } - - if (ia == __arraycount(nv)) - goto bad; - - if (uc != 0) { - *cp = ia; - *astate = SS(is + 1, S_STRING); - return UNVIS_NOCHAR; - } - - *cp = nv[ia].value; - *astate = SS(0, S_GROUND); - return UNVIS_VALID; - - case S_NUMBER: - if (uc == ';') - return UNVIS_VALID; - if (!isdigit(uc)) - goto bad; - *cp += (*cp * 10) + uc - '0'; - return UNVIS_NOCHAR; - - default: - bad: - /* - * decoder in unknown state - (probably uninitialized) - */ - *astate = SS(0, S_GROUND); - return UNVIS_SYNBAD; - } -} - -/* - * strnunvisx - decode src into dst - * - * Number of chars decoded into dst is returned, -1 on error. - * Dst is null terminated. - */ - -int -strnunvisx(char *dst, size_t dlen, const char *src, int flag) -{ - char c; - char t = '\0', *start = dst; - int state = 0; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); -#define CHECKSPACE() \ - do { \ - if (dlen-- == 0) { \ - errno = ENOSPC; \ - return -1; \ - } \ - } while (/*CONSTCOND*/0) - - while ((c = *src++) != '\0') { - again: - switch (unvis(&t, c, &state, flag)) { - case UNVIS_VALID: - CHECKSPACE(); - *dst++ = t; - break; - case UNVIS_VALIDPUSH: - CHECKSPACE(); - *dst++ = t; - goto again; - case 0: - case UNVIS_NOCHAR: - break; - case UNVIS_SYNBAD: - errno = EINVAL; - return -1; - default: - _DIAGASSERT(/*CONSTCOND*/0); - errno = EINVAL; - return -1; - } - } - if (unvis(&t, c, &state, UNVIS_END) == UNVIS_VALID) { - CHECKSPACE(); - *dst++ = t; - } - CHECKSPACE(); - *dst = '\0'; - return (int)(dst - start); -} - -int -strunvisx(char *dst, const char *src, int flag) -{ - return strnunvisx(dst, (size_t)~0, src, flag); -} - -int -strunvis(char *dst, const char *src) -{ - return strnunvisx(dst, (size_t)~0, src, 0); -} - -int -strnunvis(char *dst, size_t dlen, const char *src) -{ - return strnunvisx(dst, dlen, src, 0); -} -#endif diff --git a/lib/libc/gen/usleep.3 b/lib/libc/gen/usleep.3 deleted file mode 100644 index 12ae2e2d7..000000000 --- a/lib/libc/gen/usleep.3 +++ /dev/null @@ -1,104 +0,0 @@ -.\" $NetBSD: usleep.3,v 1.19 2010/04/29 17:29:56 jruoho Exp $ -.\" -.\" Copyright (c) 1986, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)usleep.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 29, 2010 -.Dt USLEEP 3 -.Os -.Sh NAME -.Nm usleep -.Nd suspend execution for interval of microseconds -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn usleep "useconds_t microseconds" -.Sh DESCRIPTION -The -.Fn usleep -function -suspends execution of the calling process -until either the number of microseconds specified by -.Fa microseconds -have elapsed or a signal is delivered to the calling process and its -action is to invoke a signal catching function or to terminate the -process. -The suspension time may be longer than requested due to the -scheduling of other activity by the system. -.Pp -The -.Fa microseconds -argument must be less than 1,000,000. -If the value of -.Fa microseconds -is 0, then the call has no effect. -.Sh RETURN VALUES -On successful completion, -.Fn usleep -returns 0. -Otherwise, it returns \-1 and sets -.Va errno -to indicate the error. -.Sh ERRORS -The -.Fn usleep -function may fail if: -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa microseconds -interval specified 1,000,000 or more microseconds. -.El -.Sh SEE ALSO -.Xr nanosleep 2 , -.Xr sleep 3 -.Sh STANDARDS -The -.Fn usleep -function conforms to -.St -xpg4.2 . -It later appeared in the -.Tn POSIX -standard, but in -.St -p1003.1-2004 -it was marked as legacy and the use of -.Xr nanosleep 2 -was recommended instead. -The -.St -p1003.1-2008 -revision removed -.Fn usleep -from the specification. -.Sh HISTORY -The -.Fn usleep -function appeared in -.Bx 4.3 . diff --git a/lib/libc/gen/usleep.c b/lib/libc/gen/usleep.c deleted file mode 100644 index 8a7dcfb88..000000000 --- a/lib/libc/gen/usleep.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: usleep.c,v 1.20 2012/06/25 22:32:44 abs Exp $ */ - -/*- - * Copyright (c) 1997 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: usleep.c,v 1.20 2012/06/25 22:32:44 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(usleep,_usleep) -#endif - -int -usleep(useconds_t useconds) -{ - struct timespec ts; - - if (useconds == 0) - return (0); - - if (useconds >= 1000000) { - errno = EINVAL; - return (-1); - } - - ts.tv_sec = 0; - ts.tv_nsec = useconds * 1000; - - nanosleep(&ts, NULL); - - return (0); -} diff --git a/lib/libc/gen/utime.3 b/lib/libc/gen/utime.3 deleted file mode 100644 index 365088950..000000000 --- a/lib/libc/gen/utime.3 +++ /dev/null @@ -1,149 +0,0 @@ -.\" $NetBSD: utime.3,v 1.22 2014/10/19 16:47:51 njoly Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)utime.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd April 29, 2010 -.Dt UTIME 3 -.Os -.Sh NAME -.Nm utime -.Nd set file times -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In utime.h -.Ft int -.Fn utime "const char *file" "const struct utimbuf *timep" -.Sh DESCRIPTION -.Bf -symbolic -This interface is obsoleted by -.Xr utimes 2 . -.Ef -.Pp -The -.Fn utime -function sets the access and modification times of the named file. -.Pp -If -.Fa timep -is -.Dv NULL , -the access and modification times are set to the current time. -The calling process must be the owner of the file or have permission to -write the file. -.Pp -If -.Fa timep -is -.Pf non- Dv NULL , -.Fa time -is assumed to be a pointer to a utimbuf structure, as defined in -.In utime.h : -.Bd -literal -offset indent -struct utimbuf { - time_t actime; /* Access time */ - time_t modtime; /* Modification time */ -}; -.Ed -.Pp -The access time is set to the value of the actime member, and the -modification time is set to the value of the modtime member. -The times are measured in seconds since 0 hours, 0 minutes, 0 -seconds, January 1, 1970 Coordinated Universal Time (UTC). -The calling process must be the owner of the file or be the super-user. -.Pp -In either case, the inode-change-time of the file is set to the current -time. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, a value of \-1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Fn utime -will fail if: -.Bl -tag -width Er -.It Bq Er EACCES -Search permission is denied for a component of the path prefix; -or the -.Fa times -argument is -.Dv NULL -and the effective user ID of the process does not -match the owner of the file, and is not the super-user, and write -access is denied. -.It Bq Er EFAULT -.Fa file -or -.Fa times -points outside the process's allocated address space. -.It Bq Er EINVAL -The pathname contains a character with the high-order bit set. -.It Bq Er EIO -An I/O error occurred while reading or writing the affected inode. -.It Bq Er ELOOP -Too many symbolic links were encountered in translating the pathname. -.It Bq Er ENAMETOOLONG -A component of a pathname exceeded -.Brq Dv NAME_MAX -characters, -or an entire path name exceeded -.Brq Dv PATH_MAX -characters. -.It Bq Er ENOENT -The named file does not exist. -.It Bq Er ENOTDIR -A component of the path prefix is not a directory. -.It Bq Er EPERM -The -.Fa times -argument is not -.Dv NULL -and the calling process's effective user ID -does not match the owner of the file and is not the super-user. -.It Bq Er EROFS -The file system containing the file is mounted read-only. -.El -.Sh SEE ALSO -.Xr stat 2 , -.Xr utimes 2 -.Sh STANDARDS -The -.Fn utime -function conforms to -.St -p1003.1-90 . -It was however marked as legacy in the -.St -p1003.1-2008 -revision of the standard. -.Sh HISTORY -A -.Fn utime -function appeared in -.At v7 . diff --git a/lib/libc/gen/utime.c b/lib/libc/gen/utime.c deleted file mode 100644 index d41aac74c..000000000 --- a/lib/libc/gen/utime.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: utime.c,v 1.14 2012/06/25 22:32:44 abs Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)utime.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: utime.c,v 1.14 2012/06/25 22:32:44 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include - -int -utime(const char *path, const struct utimbuf *times) -{ - struct timeval tv[2], *tvp; - - _DIAGASSERT(path != NULL); - - if (times == (struct utimbuf *) NULL) - tvp = NULL; - else { - tv[0].tv_sec = times->actime; - tv[1].tv_sec = times->modtime; - tv[0].tv_usec = tv[1].tv_usec = 0; - tvp = tv; - } - return (utimes(path, tvp)); -} diff --git a/lib/libc/gen/utimens.c b/lib/libc/gen/utimens.c deleted file mode 100644 index 9fb9beeb8..000000000 --- a/lib/libc/gen/utimens.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: utimens.c,v 1.1 2012/11/03 19:39:21 christos Exp $ */ - -/*- - * Copyright (c) 2012 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: utimens.c,v 1.1 2012/11/03 19:39:21 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#define _INCOMPLETE_XOPEN_C063 -#include -#include - -int -utimens(const char *path, const struct timespec *times) -{ - return utimensat(AT_FDCWD, path, times, 0); -} - -int -lutimens(const char *path, const struct timespec *times) -{ - return utimensat(AT_FDCWD, path, times, AT_SYMLINK_NOFOLLOW); -} diff --git a/lib/libc/gen/utmp.c b/lib/libc/gen/utmp.c deleted file mode 100644 index 9fb0799db..000000000 --- a/lib/libc/gen/utmp.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $NetBSD: utmp.c,v 1.10 2011/10/15 23:00:02 christos Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: utmp.c,v 1.10 2011/10/15 23:00:02 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -static struct utmp utmp; -static FILE *ut; -static char utfile[MAXPATHLEN] = _PATH_UTMP; - -void -setutent(void) -{ - if (ut == NULL) - return; - (void)fseeko(ut, (off_t)0, SEEK_SET); -} - -struct utmp * -getutent(void) -{ - if (ut == NULL) { - struct stat st; - off_t numentries; - if ((ut = fopen(utfile, "re")) == NULL) - return NULL; - if (fstat(fileno(ut), &st) == -1) - goto out; - /* - * If we have a an old version utmp file bail. - */ - numentries = st.st_size / sizeof(utmp); - if ((off_t)(numentries * sizeof(utmp)) != st.st_size) - goto out; - } - if (fread(&utmp, sizeof(utmp), 1, ut) == 1) - return &utmp; -out: - (void)fclose(ut); - return NULL; -} - -void -endutent(void) -{ - if (ut != NULL) { - (void)fclose(ut); - ut = NULL; - } -} - -int -utmpname(const char *fname) -{ - size_t len = strlen(fname); - - if (len >= sizeof(utfile)) - return 0; - - /* must not end in x! */ - if (fname[len - 1] == 'x') - return 0; - - (void)strlcpy(utfile, fname, sizeof(utfile)); - endutent(); - return 1; -} diff --git a/lib/libc/gen/utmpx.c b/lib/libc/gen/utmpx.c deleted file mode 100644 index edc13f7c5..000000000 --- a/lib/libc/gen/utmpx.c +++ /dev/null @@ -1,488 +0,0 @@ -/* $NetBSD: utmpx.c,v 1.35 2015/05/23 11:48:13 christos Exp $ */ - -/*- - * Copyright (c) 2002 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: utmpx.c,v 1.35 2015/05/23 11:48:13 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -static FILE *fp; -static int readonly = 0; -static int version = 1; -static struct utmpx ut; -static char utfile[MAXPATHLEN] = _PATH_UTMPX; - -static struct utmpx *utmp_update(const struct utmpx *); - -static const char vers[] = "utmpx-2.00"; - -struct otimeval { - long tv_sec; - long tv_usec; -}; - -static void -old2new(struct utmpx *utx) -{ - struct otimeval otv; - struct timeval *tv = &utx->ut_tv; - (void)memcpy(&otv, tv, sizeof(otv)); - tv->tv_sec = otv.tv_sec; - tv->tv_usec = (suseconds_t)otv.tv_usec; -} - -static void -new2old(struct utmpx *utx) -{ - struct otimeval otv; - struct timeval *tv = &utx->ut_tv; - - otv.tv_sec = (long)tv->tv_sec; - otv.tv_usec = (long)tv->tv_usec; - (void)memcpy(tv, &otv, sizeof(otv)); -} - -void -setutxent(void) -{ - - (void)memset(&ut, 0, sizeof(ut)); - if (fp == NULL) - return; - (void)fseeko(fp, (off_t)sizeof(ut), SEEK_SET); -} - - -void -endutxent(void) -{ - - (void)memset(&ut, 0, sizeof(ut)); - if (fp != NULL) { - (void)fclose(fp); - fp = NULL; - readonly = 0; - } -} - - -struct utmpx * -getutxent(void) -{ - - if (fp == NULL) { - struct stat st; - - if ((fp = fopen(utfile, "re+")) == NULL) - if ((fp = fopen(utfile, "we+")) == NULL) { - if ((fp = fopen(utfile, "re")) == NULL) - goto fail; - else - readonly = 1; - } - - - /* get file size in order to check if new file */ - if (fstat(fileno(fp), &st) == -1) - goto failclose; - - if (st.st_size == 0) { - /* new file, add signature record */ - (void)memset(&ut, 0, sizeof(ut)); - ut.ut_type = SIGNATURE; - (void)memcpy(ut.ut_user, vers, sizeof(vers)); - if (fwrite(&ut, sizeof(ut), 1, fp) != 1) - goto failclose; - } else { - /* old file, read signature record */ - if (fread(&ut, sizeof(ut), 1, fp) != 1) - goto failclose; - if (memcmp(ut.ut_user, vers, 5) != 0 || - ut.ut_type != SIGNATURE) - goto failclose; - } - version = ut.ut_user[6] - '0'; - } - - if (fread(&ut, sizeof(ut), 1, fp) != 1) - goto fail; - if (version == 1) - old2new(&ut); - - return &ut; -failclose: - (void)fclose(fp); -fail: - (void)memset(&ut, 0, sizeof(ut)); - return NULL; -} - - -struct utmpx * -getutxid(const struct utmpx *utx) -{ - - _DIAGASSERT(utx != NULL); - - if (utx->ut_type == EMPTY) - return NULL; - - do { - if (ut.ut_type == EMPTY) - continue; - switch (utx->ut_type) { - case EMPTY: - return NULL; - case RUN_LVL: - case BOOT_TIME: - case OLD_TIME: - case NEW_TIME: - if (ut.ut_type == utx->ut_type) - return &ut; - break; - case INIT_PROCESS: - case LOGIN_PROCESS: - case USER_PROCESS: - case DEAD_PROCESS: - switch (ut.ut_type) { - case INIT_PROCESS: - case LOGIN_PROCESS: - case USER_PROCESS: - case DEAD_PROCESS: - if (memcmp(ut.ut_id, utx->ut_id, - sizeof(ut.ut_id)) == 0) - return &ut; - break; - default: - break; - } - break; - default: - return NULL; - } - } while (getutxent() != NULL); - return NULL; -} - - -struct utmpx * -getutxline(const struct utmpx *utx) -{ - - _DIAGASSERT(utx != NULL); - - do { - switch (ut.ut_type) { - case EMPTY: - break; - case LOGIN_PROCESS: - case USER_PROCESS: - if (strncmp(ut.ut_line, utx->ut_line, - sizeof(ut.ut_line)) == 0) - return &ut; - break; - default: - break; - } - } while (getutxent() != NULL); - return NULL; -} - - -struct utmpx * -pututxline(const struct utmpx *utx) -{ - struct utmpx temp, *u = NULL; - int gotlock = 0; - - _DIAGASSERT(utx != NULL); - - if (utx == NULL) - return NULL; - - if (strcmp(_PATH_UTMPX, utfile) == 0) { - if (geteuid() == 0) { - if (fp != NULL && readonly) - endutxent(); - } else { - if (fp == NULL || readonly) - return utmp_update(utx); - } - } - - - (void)memcpy(&temp, utx, sizeof(temp)); - - if (fp == NULL) { - (void)getutxent(); - if (fp == NULL || readonly) - return NULL; - } - - if (getutxid(&temp) == NULL) { - setutxent(); - if (getutxid(&temp) == NULL) { - if (lockf(fileno(fp), F_LOCK, (off_t)0) == -1) - return NULL; - gotlock++; - if (fseeko(fp, (off_t)0, SEEK_END) == -1) - goto fail; - } - } - - if (!gotlock) { - /* we are not appending */ - if (fseeko(fp, -(off_t)sizeof(ut), SEEK_CUR) == -1) - return NULL; - } - - if (version == 1) - new2old(&temp); - if (fwrite(&temp, sizeof (temp), 1, fp) != 1) - goto fail; - - if (fflush(fp) == -1) - goto fail; - - u = memcpy(&ut, &temp, sizeof(ut)); -fail: - if (gotlock) { - if (lockf(fileno(fp), F_ULOCK, (off_t)0) == -1) - return NULL; - } - return u; -} - - -static struct utmpx * -utmp_update(const struct utmpx *utx) -{ - char buf[sizeof(*utx) * 4 + 1]; - pid_t pid; - int status; - - _DIAGASSERT(utx != NULL); - - (void)strvisx(buf, (const char *)(const void *)utx, sizeof(*utx), - VIS_WHITE | VIS_NOLOCALE); - switch (pid = fork()) { - case 0: - (void)execl(_PATH_UTMP_UPDATE, - strrchr(_PATH_UTMP_UPDATE, '/') + 1, buf, NULL); - _exit(1); - /*NOTREACHED*/ - case -1: - return NULL; - default: - if (waitpid(pid, &status, 0) == -1) - return NULL; - if (WIFEXITED(status) && WEXITSTATUS(status) == 0) - return memcpy(&ut, utx, sizeof(ut)); - return NULL; - } - -} - -/* - * The following are extensions and not part of the X/Open spec. - */ -int -updwtmpx(const char *file, const struct utmpx *utx) -{ - int fd; - int saved_errno; - - _DIAGASSERT(file != NULL); - _DIAGASSERT(utx != NULL); - - fd = open(file, O_WRONLY|O_APPEND|O_SHLOCK|O_CLOEXEC); - - if (fd == -1) { - if ((fd = open(file, O_CREAT|O_WRONLY|O_EXLOCK|O_CLOEXEC, 0644)) == -1) - return -1; - (void)memset(&ut, 0, sizeof(ut)); - ut.ut_type = SIGNATURE; - (void)memcpy(ut.ut_user, vers, sizeof(vers)); - if (write(fd, &ut, sizeof(ut)) == -1) - goto failed; - } - if (write(fd, utx, sizeof(*utx)) == -1) - goto failed; - if (close(fd) == -1) - return -1; - return 0; - - failed: - saved_errno = errno; - (void) close(fd); - errno = saved_errno; - return -1; -} - - -int -utmpxname(const char *fname) -{ - size_t len; - - _DIAGASSERT(fname != NULL); - - len = strlen(fname); - - if (len >= sizeof(utfile)) - return 0; - - /* must end in x! */ - if (fname[len - 1] != 'x') - return 0; - - (void)strlcpy(utfile, fname, sizeof(utfile)); - endutxent(); - return 1; -} - - -void -getutmp(const struct utmpx *ux, struct utmp *u) -{ - - _DIAGASSERT(ux != NULL); - _DIAGASSERT(u != NULL); - - (void)memcpy(u->ut_name, ux->ut_name, sizeof(u->ut_name)); - (void)memcpy(u->ut_line, ux->ut_line, sizeof(u->ut_line)); - (void)memcpy(u->ut_host, ux->ut_host, sizeof(u->ut_host)); - u->ut_time = ux->ut_tv.tv_sec; -} - -void -getutmpx(const struct utmp *u, struct utmpx *ux) -{ - - _DIAGASSERT(ux != NULL); - _DIAGASSERT(u != NULL); - - (void)memcpy(ux->ut_name, u->ut_name, sizeof(u->ut_name)); - (void)memcpy(ux->ut_line, u->ut_line, sizeof(u->ut_line)); - (void)memcpy(ux->ut_host, u->ut_host, sizeof(u->ut_host)); - ux->ut_tv.tv_sec = u->ut_time; - ux->ut_tv.tv_usec = 0; - (void)memset(&ux->ut_ss, 0, sizeof(ux->ut_ss)); - ux->ut_pid = 0; - ux->ut_type = USER_PROCESS; - ux->ut_session = 0; - ux->ut_exit.e_termination = 0; - ux->ut_exit.e_exit = 0; -} - -struct lastlogx * -getlastlogx(const char *fname, uid_t uid, struct lastlogx *ll) -{ - DBT key, data; - DB *db; - - _DIAGASSERT(fname != NULL); - _DIAGASSERT(ll != NULL); - - db = dbopen(fname, O_RDONLY|O_SHLOCK|O_CLOEXEC, 0, DB_HASH, NULL); - - if (db == NULL) - return NULL; - - key.data = &uid; - key.size = sizeof(uid); - - if ((db->get)(db, &key, &data, 0) != 0) - goto error; - - if (data.size != sizeof(*ll)) { - errno = EFTYPE; - goto error; - } - - if (ll == NULL) - if ((ll = malloc(sizeof(*ll))) == NULL) - goto done; - - (void)memcpy(ll, data.data, sizeof(*ll)); - goto done; -error: - ll = NULL; -done: - (db->close)(db); - return ll; -} - -int -updlastlogx(const char *fname, uid_t uid, struct lastlogx *ll) -{ - DBT key, data; - int error = 0; - DB *db; - - _DIAGASSERT(fname != NULL); - _DIAGASSERT(ll != NULL); - - db = dbopen(fname, O_RDWR|O_CREAT|O_EXLOCK|O_CLOEXEC, 0644, DB_HASH, NULL); - - if (db == NULL) - return -1; - - key.data = &uid; - key.size = sizeof(uid); - data.data = ll; - data.size = sizeof(*ll); - if ((db->put)(db, &key, &data, 0) != 0) - error = -1; - - (db->close)(db); - return error; -} diff --git a/lib/libc/gen/valloc.3 b/lib/libc/gen/valloc.3 deleted file mode 100644 index 2c49a0de7..000000000 --- a/lib/libc/gen/valloc.3 +++ /dev/null @@ -1,77 +0,0 @@ -.\" $NetBSD: valloc.3,v 1.14 2010/05/08 11:22:58 wiz Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)valloc.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd May 6, 2010 -.Dt VALLOC 3 -.Os -.Sh NAME -.Nm valloc -.Nd aligned memory allocation function -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In stdlib.h -.Ft void * -.Fn valloc "size_t size" -.Sh DESCRIPTION -.Bf -symbolic -The -.Fn valloc -function is obsoleted by the current version of -.Xr malloc 3 , -which aligns page-sized and larger allocations. -.Ef -.Pp -The -.Fn valloc -function -allocates -.Fa size -bytes aligned on a page boundary. -It is implemented by calling -.Xr malloc 3 -with a slightly larger request, saving the true beginning of the block -allocated, and returning a properly aligned pointer. -.Sh RETURN VALUES -The -.Fn valloc -function returns -a pointer to the allocated space if successful; otherwise -a null pointer is returned -.Sh HISTORY -The -.Fn valloc -function appeared in -.Bx 3.0 . -.Sh BUGS -A -.Fn vfree -function has not been implemented. diff --git a/lib/libc/gen/valloc.c b/lib/libc/gen/valloc.c deleted file mode 100644 index 6a175faf0..000000000 --- a/lib/libc/gen/valloc.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: valloc.c,v 1.11 2012/06/25 22:32:44 abs Exp $ */ - -/* - * Copyright (c) 1980, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)valloc.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: valloc.c,v 1.11 2012/06/25 22:32:44 abs Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(valloc,_valloc) -#endif - -void * -valloc(size_t i) -{ - long valsiz = getpagesize(), j; - void *cp = malloc((size_t)(i + (valsiz-1))); - - j = ((long)cp + (valsiz-1)) &~ (valsiz-1); - return ((void *)j); -} diff --git a/lib/libc/gen/verr.c b/lib/libc/gen/verr.c deleted file mode 100644 index bfa9b365a..000000000 --- a/lib/libc/gen/verr.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: verr.c,v 1.16 2014/01/16 17:21:38 christos Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: verr.c,v 1.16 2014/01/16 17:21:38 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(verr, _verr) -#endif - -#if !HAVE_ERR_H -__dead void -verr(int eval, const char *fmt, va_list ap) -{ - verrc(eval, errno, fmt, ap); -} -#endif diff --git a/lib/libc/gen/verrc.c b/lib/libc/gen/verrc.c deleted file mode 100644 index 6670e1709..000000000 --- a/lib/libc/gen/verrc.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: verrc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: verrc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(verrc, _verrc) -#endif - -#if !HAVE_ERR_H || !HAVE_DECL_ERRC -__dead void -verrc(int eval, int code, const char *fmt, va_list ap) -{ - (void)fprintf(stderr, "%s: ", getprogname()); - if (fmt != NULL) { - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, ": "); - } - (void)fprintf(stderr, "%s\n", strerror(code)); - exit(eval); -} -#endif diff --git a/lib/libc/gen/verrx.c b/lib/libc/gen/verrx.c deleted file mode 100644 index e220a4b5f..000000000 --- a/lib/libc/gen/verrx.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: verrx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: verrx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(verrx, _verrx) -#endif - -#if !HAVE_ERR_H -__dead void -verrx(int eval, const char *fmt, va_list ap) -{ - (void)fprintf(stderr, "%s: ", getprogname()); - if (fmt != NULL) - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, "\n"); - exit(eval); -} -#endif diff --git a/lib/libc/gen/vis.3 b/lib/libc/gen/vis.3 deleted file mode 100644 index 77c711ede..000000000 --- a/lib/libc/gen/vis.3 +++ /dev/null @@ -1,540 +0,0 @@ -.\" $NetBSD: vis.3,v 1.43 2015/05/23 11:47:56 christos Exp $ -.\" -.\" Copyright (c) 1989, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)vis.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd May 23, 2015 -.Dt VIS 3 -.Os -.Sh NAME -.Nm vis , -.Nm nvis , -.Nm strvis , -.Nm strnvis , -.Nm strvisx , -.Nm strnvisx , -.Nm strenvisx , -.Nm svis , -.Nm snvis , -.Nm strsvis , -.Nm strsnvis , -.Nm strsvisx , -.Nm strsnvisx , -.Nm strsenvisx -.Nd visually encode characters -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In vis.h -.Ft char * -.Fn vis "char *dst" "int c" "int flag" "int nextc" -.Ft char * -.Fn nvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" -.Ft int -.Fn strvis "char *dst" "const char *src" "int flag" -.Ft int -.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag" -.Ft int -.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag" -.Ft int -.Fn strnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" -.Ft int -.Fn strenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "int *cerr_ptr" -.Ft char * -.Fn svis "char *dst" "int c" "int flag" "int nextc" "const char *extra" -.Ft char * -.Fn snvis "char *dst" "size_t dlen" "int c" "int flag" "int nextc" "const char *extra" -.Ft int -.Fn strsvis "char *dst" "const char *src" "int flag" "const char *extra" -.Ft int -.Fn strsnvis "char *dst" "size_t dlen" "const char *src" "int flag" "const char *extra" -.Ft int -.Fn strsvisx "char *dst" "const char *src" "size_t len" "int flag" "const char *extra" -.Ft int -.Fn strsnvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" -.Ft int -.Fn strsenvisx "char *dst" "size_t dlen" "const char *src" "size_t len" "int flag" "const char *extra" "int *cerr_ptr" -.Sh DESCRIPTION -The -.Fn vis -function -copies into -.Fa dst -a string which represents the character -.Fa c . -If -.Fa c -needs no encoding, it is copied in unaltered. -The string is null terminated, and a pointer to the end of the string is -returned. -The maximum length of any encoding is four -bytes (not including the trailing -.Dv NUL ) ; -thus, when -encoding a set of characters into a buffer, the size of the buffer should -be four times the number of bytes encoded, plus one for the trailing -.Dv NUL . -The flag parameter is used for altering the default range of -characters considered for encoding and for altering the visual -representation. -The additional character, -.Fa nextc , -is only used when selecting the -.Dv VIS_CSTYLE -encoding format (explained below). -.Pp -The -.Fn strvis , -.Fn strnvis , -.Fn strvisx , -and -.Fn strnvisx -functions copy into -.Fa dst -a visual representation of -the string -.Fa src . -The -.Fn strvis -and -.Fn strnvis -functions encode characters from -.Fa src -up to the -first -.Dv NUL . -The -.Fn strvisx -and -.Fn strnvisx -functions encode exactly -.Fa len -characters from -.Fa src -(this -is useful for encoding a block of data that may contain -.Dv NUL Ns 's ) . -Both forms -.Dv NUL -terminate -.Fa dst . -The size of -.Fa dst -must be four times the number -of bytes encoded from -.Fa src -(plus one for the -.Dv NUL ) . -Both -forms return the number of characters in -.Fa dst -(not including the trailing -.Dv NUL ) . -The -.Dq Nm n -versions of the functions also take an additional argument -.Fa dlen -that indicates the length of the -.Fa dst -buffer. -If -.Fa dlen -is not large enough to fit the converted string then the -.Fn strnvis -and -.Fn strnvisx -functions return \-1 and set -.Va errno -to -.Dv ENOSPC . -The -.Fn strenvisx -function takes an additional argument, -.Fa cerr_ptr , -that is used to pass in and out a multibyte conversion error flag. -This is useful when processing single characters at a time when -it is possible that the locale may be set to something other -than the locale of the characters in the input data. -.Pp -The functions -.Fn svis , -.Fn snvis , -.Fn strsvis , -.Fn strsnvis , -.Fn strsvisx , -.Fn strsnvisx , -and -.Fn strsenvisx -correspond to -.Fn vis , -.Fn nvis , -.Fn strvis , -.Fn strnvis , -.Fn strvisx , -.Fn strnvisx , -and -.Fn strenvisx -but have an additional argument -.Fa extra , -pointing to a -.Dv NUL -terminated list of characters. -These characters will be copied encoded or backslash-escaped into -.Fa dst . -These functions are useful e.g. to remove the special meaning -of certain characters to shells. -.Pp -The encoding is a unique, invertible representation composed entirely of -graphic characters; it can be decoded back into the original form using -the -.Xr unvis 3 , -.Xr strunvis 3 -or -.Xr strnunvis 3 -functions. -.Pp -There are two parameters that can be controlled: the range of -characters that are encoded (applies only to -.Fn vis , -.Fn nvis , -.Fn strvis , -.Fn strnvis , -.Fn strvisx , -and -.Fn strnvisx ) , -and the type of representation used. -By default, all non-graphic characters, -except space, tab, and newline are encoded (see -.Xr isgraph 3 ) . -The following flags -alter this: -.Bl -tag -width VIS_WHITEX -.It Dv VIS_GLOB -Also encode the magic characters -.Ql ( * , -.Ql \&? , -.Ql \&[ , -and -.Ql # ) -recognized by -.Xr glob 3 . -.It Dv VIS_SHELL -Also encode the meta characters used by shells (in addition to the glob -characters): -.Ql ( ' , -.Ql ` , -.Ql \&" , -.Ql \&; , -.Ql & , -.Ql < , -.Ql > , -.Ql \&( , -.Ql \&) , -.Ql \&| , -.Ql \&] , -.Ql \e , -.Ql $ , -.Ql \&! , -.Ql \&^ , -and -.Ql ~ ) . -.It Dv VIS_SP -Also encode space. -.It Dv VIS_TAB -Also encode tab. -.It Dv VIS_NL -Also encode newline. -.It Dv VIS_WHITE -Synonym for -.Dv VIS_SP | VIS_TAB | VIS_NL . -.It Dv VIS_META -Synonym for -.Dv VIS_WHITE | VIS_GLOB | VIS_SHELL . -.It Dv VIS_SAFE -Only encode -.Dq unsafe -characters. -Unsafe means control characters which may cause common terminals to perform -unexpected functions. -Currently this form allows space, tab, newline, backspace, bell, and -return \(em in addition to all graphic characters \(em unencoded. -.El -.Pp -(The above flags have no effect for -.Fn svis , -.Fn snvis , -.Fn strsvis , -.Fn strsnvis , -.Fn strsvisx , -and -.Fn strsnvisx . -When using these functions, place all graphic characters to be -encoded in an array pointed to by -.Fa extra . -In general, the backslash character should be included in this array, see the -warning on the use of the -.Dv VIS_NOSLASH -flag below). -.Pp -There are four forms of encoding. -All forms use the backslash character -.Ql \e -to introduce a special -sequence; two backslashes are used to represent a real backslash, -except -.Dv VIS_HTTPSTYLE -that uses -.Ql % , -or -.Dv VIS_MIMESTYLE -that uses -.Ql = . -These are the visual formats: -.Bl -tag -width VIS_CSTYLE -.It (default) -Use an -.Ql M -to represent meta characters (characters with the 8th -bit set), and use caret -.Ql ^ -to represent control characters (see -.Xr iscntrl 3 ) . -The following formats are used: -.Bl -tag -width xxxxx -.It Dv \e^C -Represents the control character -.Ql C . -Spans characters -.Ql \e000 -through -.Ql \e037 , -and -.Ql \e177 -(as -.Ql \e^? ) . -.It Dv \eM-C -Represents character -.Ql C -with the 8th bit set. -Spans characters -.Ql \e241 -through -.Ql \e376 . -.It Dv \eM^C -Represents control character -.Ql C -with the 8th bit set. -Spans characters -.Ql \e200 -through -.Ql \e237 , -and -.Ql \e377 -(as -.Ql \eM^? ) . -.It Dv \e040 -Represents -.Tn ASCII -space. -.It Dv \e240 -Represents Meta-space. -.El -.Pp -.It Dv VIS_CSTYLE -Use C-style backslash sequences to represent standard non-printable -characters. -The following sequences are used to represent the indicated characters: -.Bd -unfilled -offset indent -.Li \ea Tn \(em BEL No (007) -.Li \eb Tn \(em BS No (010) -.Li \ef Tn \(em NP No (014) -.Li \en Tn \(em NL No (012) -.Li \er Tn \(em CR No (015) -.Li \es Tn \(em SP No (040) -.Li \et Tn \(em HT No (011) -.Li \ev Tn \(em VT No (013) -.Li \e0 Tn \(em NUL No (000) -.Ed -.Pp -When using this format, the -.Fa nextc -parameter is looked at to determine if a -.Dv NUL -character can be encoded as -.Ql \e0 -instead of -.Ql \e000 . -If -.Fa nextc -is an octal digit, the latter representation is used to -avoid ambiguity. -.It Dv VIS_OCTAL -Use a three digit octal sequence. -The form is -.Ql \eddd -where -.Em d -represents an octal digit. -.It Dv VIS_HTTPSTYLE -Use URI encoding as described in RFC 1738. -The form is -.Ql %xx -where -.Em x -represents a lower case hexadecimal digit. -.It Dv VIS_MIMESTYLE -Use MIME Quoted-Printable encoding as described in RFC 2045, only don't -break lines and don't handle CRLF. -The form is -.Ql =XX -where -.Em X -represents an upper case hexadecimal digit. -.El -.Pp -There is one additional flag, -.Dv VIS_NOSLASH , -which inhibits the -doubling of backslashes and the backslash before the default -format (that is, control characters are represented by -.Ql ^C -and -meta characters as -.Ql M-C ) . -With this flag set, the encoding is -ambiguous and non-invertible. -.Sh MULTIBYTE CHARACTER SUPPORT -These functions support multibyte character input. -The encoding conversion is influenced by the setting of the -.Ev LC_CTYPE -environment variable which defines the set of characters -that can be copied without encoding. -.Pp -If -.Dv VIS_NOLOCALE -is set, processing is done assuming the C locale and overriding -any other environment settings. -.Pp -When 8-bit data is present in the input, -.Ev LC_CTYPE -must be set to the correct locale or to the C locale. -If the locales of the data and the conversion are mismatched, -multibyte character recognition may fail and encoding will be performed -byte-by-byte instead. -.Pp -As noted above, -.Fa dst -must be four times the number of bytes processed from -.Fa src . -But note that each multibyte character can be up to -.Dv MB_LEN_MAX -bytes -.\" (see -.\" .Xr multibyte 3 ) -so in terms of multibyte characters, -.Fa dst -must be four times -.Dv MB_LEN_MAX -times the number of characters processed from -.Fa src . -.Sh ENVIRONMENT -.Bl -tag -width ".Ev LC_CTYPE" -.It Ev LC_CTYPE -Specify the locale of the input data. -Set to C if the input data locale is unknown. -.El -.Sh ERRORS -The functions -.Fn nvis -and -.Fn snvis -will return -.Dv NULL -and the functions -.Fn strnvis , -.Fn strnvisx , -.Fn strsnvis , -and -.Fn strsnvisx , -will return \-1 when the -.Fa dlen -destination buffer size is not enough to perform the conversion while -setting -.Va errno -to: -.Bl -tag -width ".Bq Er ENOSPC" -.It Bq Er ENOSPC -The destination buffer size is not large enough to perform the conversion. -.El -.Sh SEE ALSO -.Xr unvis 1 , -.Xr vis 1 , -.Xr glob 3 , -.\" .Xr multibyte 3 , -.Xr unvis 3 -.Rs -.%A T. Berners-Lee -.%T Uniform Resource Locators (URL) -.%O "RFC 1738" -.Re -.Rs -.%T "Multipurpose Internet Mail Extensions (MIME) Part One: Format of Internet Message Bodies" -.%O "RFC 2045" -.Re -.Sh HISTORY -The -.Fn vis , -.Fn strvis , -and -.Fn strvisx -functions first appeared in -.Bx 4.4 . -The -.Fn svis , -.Fn strsvis , -and -.Fn strsvisx -functions appeared in -.Nx 1.5 . -The buffer size limited versions of the functions -.Po Fn nvis , -.Fn strnvis , -.Fn strnvisx , -.Fn snvis , -.Fn strsnvis , -and -.Fn strsnvisx Pc -appeared in -.Nx 6.0 -and -.Fx 9.2 . -Myltibyte character support was added in -.Nx 7.0 -and -.Fx 9.2 . diff --git a/lib/libc/gen/vis.c b/lib/libc/gen/vis.c deleted file mode 100644 index a453d0603..000000000 --- a/lib/libc/gen/vis.c +++ /dev/null @@ -1,744 +0,0 @@ -/* $NetBSD: vis.c,v 1.70 2015/05/26 21:42:46 christos Exp $ */ - -/*- - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/*- - * Copyright (c) 1999, 2005 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vis.c,v 1.70 2015/05/26 21:42:46 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ -#ifdef __FBSDID -__FBSDID("$FreeBSD$"); -#define _DIAGASSERT(x) assert(x) -#endif - -#include "namespace.h" -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(strvisx,_strvisx) -#endif - -#if !HAVE_VIS || !HAVE_SVIS -#include -#include -#include -#include - -/* - * The reason for going through the trouble to deal with character encodings - * in vis(3), is that we use this to safe encode output of commands. This - * safe encoding varies depending on the character set. For example if we - * display ps output in French, we don't want to display French characters - * as M-foo. - */ - -static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *); - -#undef BELL -#define BELL L'\a' - -#if defined(LC_C_LOCALE) -#define iscgraph(c) isgraph_l(c, LC_C_LOCALE) -#else -/* Keep it simple for now, no locale stuff */ -#define iscgraph(c) isgraph(c) -#ifdef notyet -#include -static int -iscgraph(int c) { - int rv; - char *ol; - - ol = setlocale(LC_CTYPE, "C"); - rv = isgraph(c); - if (ol) - setlocale(LC_CTYPE, ol); - return rv; -} -#endif -#endif - -#define ISGRAPH(flags, c) \ - (((flags) & VIS_NOLOCALE) ? iscgraph(c) : iswgraph(c)) - -#define iswoctal(c) (((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7') -#define iswwhite(c) (c == L' ' || c == L'\t' || c == L'\n') -#define iswsafe(c) (c == L'\b' || c == BELL || c == L'\r') -#define xtoa(c) L"0123456789abcdef"[c] -#define XTOA(c) L"0123456789ABCDEF"[c] - -#define MAXEXTRAS 30 - -static const wchar_t char_shell[] = L"'`\";&<>()|{}]\\$!^~"; -static const wchar_t char_glob[] = L"*?[#"; - -#if !HAVE_NBTOOL_CONFIG_H -#ifndef __minix -/* - * On NetBSD MB_LEN_MAX is currently 32 which does not fit on any integer - * integral type and it is probably wrong, since currently the maximum - * number of bytes and character needs is 6. Until this is fixed, the - * loops below are using sizeof(uint64_t) - 1 instead of MB_LEN_MAX, and - * the assertion is commented out. - */ -#ifdef __FreeBSD__ -/* - * On FreeBSD including for CTASSERT only works in kernel - * mode. - */ -#ifndef CTASSERT -#define CTASSERT(x) _CTASSERT(x, __LINE__) -#define _CTASSERT(x, y) __CTASSERT(x, y) -#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1] -#endif -#endif /* __FreeBSD__ */ -CTASSERT(MB_LEN_MAX <= sizeof(uint64_t)); -#endif /* !__minix */ -#endif - -/* - * This is do_hvis, for HTTP style (RFC 1808) - */ -static wchar_t * -do_hvis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra) -{ - if (iswalnum(c) - /* safe */ - || c == L'$' || c == L'-' || c == L'_' || c == L'.' || c == L'+' - /* extra */ - || c == L'!' || c == L'*' || c == L'\'' || c == L'(' || c == L')' - || c == L',') - dst = do_svis(dst, c, flags, nextc, extra); - else { - *dst++ = L'%'; - *dst++ = xtoa(((unsigned int)c >> 4) & 0xf); - *dst++ = xtoa((unsigned int)c & 0xf); - } - - return dst; -} - -/* - * This is do_mvis, for Quoted-Printable MIME (RFC 2045) - * NB: No handling of long lines or CRLF. - */ -static wchar_t * -do_mvis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra) -{ - if ((c != L'\n') && - /* Space at the end of the line */ - ((iswspace(c) && (nextc == L'\r' || nextc == L'\n')) || - /* Out of range */ - (!iswspace(c) && (c < 33 || (c > 60 && c < 62) || c > 126)) || - /* Specific char to be escaped */ - wcschr(L"#$@[\\]^`{|}~", c) != NULL)) { - *dst++ = L'='; - *dst++ = XTOA(((unsigned int)c >> 4) & 0xf); - *dst++ = XTOA((unsigned int)c & 0xf); - } else - dst = do_svis(dst, c, flags, nextc, extra); - return dst; -} - -/* - * Output single byte of multibyte character. - */ -static wchar_t * -do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra) -{ - if (flags & VIS_CSTYLE) { - switch (c) { - case L'\n': - *dst++ = L'\\'; *dst++ = L'n'; - return dst; - case L'\r': - *dst++ = L'\\'; *dst++ = L'r'; - return dst; - case L'\b': - *dst++ = L'\\'; *dst++ = L'b'; - return dst; - case BELL: - *dst++ = L'\\'; *dst++ = L'a'; - return dst; - case L'\v': - *dst++ = L'\\'; *dst++ = L'v'; - return dst; - case L'\t': - *dst++ = L'\\'; *dst++ = L't'; - return dst; - case L'\f': - *dst++ = L'\\'; *dst++ = L'f'; - return dst; - case L' ': - *dst++ = L'\\'; *dst++ = L's'; - return dst; - case L'\0': - *dst++ = L'\\'; *dst++ = L'0'; - if (iswoctal(nextc)) { - *dst++ = L'0'; - *dst++ = L'0'; - } - return dst; - /* We cannot encode these characters in VIS_CSTYLE - * because they special meaning */ - case L'n': - case L'r': - case L'b': - case L'a': - case L'v': - case L't': - case L'f': - case L's': - case L'0': - case L'M': - case L'^': - case L'$': /* vis(1) -l */ - break; - default: - if (ISGRAPH(flags, c) && !iswoctal(c)) { - *dst++ = L'\\'; - *dst++ = c; - return dst; - } - } - } - if (iswextra || ((c & 0177) == L' ') || (flags & VIS_OCTAL)) { - *dst++ = L'\\'; - *dst++ = (u_char)(((u_int32_t)(u_char)c >> 6) & 03) + L'0'; - *dst++ = (u_char)(((u_int32_t)(u_char)c >> 3) & 07) + L'0'; - *dst++ = (c & 07) + L'0'; - } else { - if ((flags & VIS_NOSLASH) == 0) - *dst++ = L'\\'; - - if (c & 0200) { - c &= 0177; - *dst++ = L'M'; - } - - if (iswcntrl(c)) { - *dst++ = L'^'; - if (c == 0177) - *dst++ = L'?'; - else - *dst++ = c + L'@'; - } else { - *dst++ = L'-'; - *dst++ = c; - } - } - - return dst; -} - -/* - * This is do_vis, the central code of vis. - * dst: Pointer to the destination buffer - * c: Character to encode - * flags: Flags word - * nextc: The character following 'c' - * extra: Pointer to the list of extra characters to be - * backslash-protected. - */ -static wchar_t * -do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra) -{ - int iswextra, i, shft; - uint64_t bmsk, wmsk; - - iswextra = wcschr(extra, c) != NULL; - if (!iswextra && (ISGRAPH(flags, c) || iswwhite(c) || - ((flags & VIS_SAFE) && iswsafe(c)))) { - *dst++ = c; - return dst; - } - - /* See comment in istrsenvisx() output loop, below. */ - wmsk = 0; - for (i = sizeof(wmsk) - 1; i >= 0; i--) { - shft = i * NBBY; - bmsk = (uint64_t)0xffLL << shft; - wmsk |= bmsk; - if ((c & wmsk) || i == 0) - dst = do_mbyte(dst, (wint_t)( - (uint64_t)(c & bmsk) >> shft), - flags, nextc, iswextra); - } - - return dst; -} - -typedef wchar_t *(*visfun_t)(wchar_t *, wint_t, int, wint_t, const wchar_t *); - -/* - * Return the appropriate encoding function depending on the flags given. - */ -static visfun_t -getvisfun(int flags) -{ - if (flags & VIS_HTTPSTYLE) - return do_hvis; - if (flags & VIS_MIMESTYLE) - return do_mvis; - return do_svis; -} - -/* - * Expand list of extra characters to not visually encode. - */ -static wchar_t * -makeextralist(int flags, const char *src) -{ - wchar_t *dst, *d; - size_t len; - const wchar_t *s; - - len = strlen(src); - if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL) - return NULL; - - if ((flags & VIS_NOLOCALE) || mbstowcs(dst, src, len) == (size_t)-1) { - size_t i; - for (i = 0; i < len; i++) - dst[i] = (wchar_t)(u_char)src[i]; - d = dst + len; - } else - d = dst + wcslen(dst); - - if (flags & VIS_GLOB) - for (s = char_glob; *s; *d++ = *s++) - continue; - - if (flags & VIS_SHELL) - for (s = char_shell; *s; *d++ = *s++) - continue; - - if (flags & VIS_SP) *d++ = L' '; - if (flags & VIS_TAB) *d++ = L'\t'; - if (flags & VIS_NL) *d++ = L'\n'; - if ((flags & VIS_NOSLASH) == 0) *d++ = L'\\'; - *d = L'\0'; - - return dst; -} - -/* - * istrsenvisx() - * The main internal function. - * All user-visible functions call this one. - */ -static int -istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength, - int flags, const char *mbextra, int *cerr_ptr) -{ - wchar_t *dst, *src, *pdst, *psrc, *start, *extra; - size_t len, olen; - uint64_t bmsk, wmsk; - wint_t c; - visfun_t f; - int clen = 0, cerr, error = -1, i, shft; - ssize_t mbslength, maxolen; - - _DIAGASSERT(mbdst != NULL); - _DIAGASSERT(mbsrc != NULL || mblength == 0); - _DIAGASSERT(mbextra != NULL); - - /* - * Input (mbsrc) is a char string considered to be multibyte - * characters. The input loop will read this string pulling - * one character, possibly multiple bytes, from mbsrc and - * converting each to wchar_t in src. - * - * The vis conversion will be done using the wide char - * wchar_t string. - * - * This will then be converted back to a multibyte string to - * return to the caller. - */ - - /* Allocate space for the wide char strings */ - psrc = pdst = extra = NULL; - if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL) - return -1; - if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL) - goto out; - dst = pdst; - src = psrc; - - if (flags & VIS_NOLOCALE) { - /* Do one byte at a time conversion */ - cerr = 1; - } else { - /* Use caller's multibyte conversion error flag. */ - cerr = cerr_ptr ? *cerr_ptr : 0; - } - - /* - * Input loop. - * Handle up to mblength characters (not bytes). We do not - * stop at NULs because we may be processing a block of data - * that includes NULs. - */ - mbslength = (ssize_t)mblength; - /* - * When inputing a single character, must also read in the - * next character for nextc, the look-ahead character. - */ - if (mbslength == 1) - mbslength++; - while (mbslength > 0) { - /* Convert one multibyte character to wchar_t. */ - if (!cerr) - clen = mbtowc(src, mbsrc, MB_LEN_MAX); - if (cerr || clen < 0) { - /* Conversion error, process as a byte instead. */ - *src = (wint_t)(u_char)*mbsrc; - clen = 1; - cerr = 1; - } - if (clen == 0) - /* - * NUL in input gives 0 return value. process - * as single NUL byte and keep going. - */ - clen = 1; - /* Advance buffer character pointer. */ - src++; - /* Advance input pointer by number of bytes read. */ - mbsrc += clen; - /* Decrement input byte count. */ - mbslength -= clen; - } - len = src - psrc; - src = psrc; - /* - * In the single character input case, we will have actually - * processed two characters, c and nextc. Reset len back to - * just a single character. - */ - if (mblength < len) - len = mblength; - - /* Convert extra argument to list of characters for this mode. */ - extra = makeextralist(flags, mbextra); - if (!extra) { - if (dlen && *dlen == 0) { - errno = ENOSPC; - goto out; - } - *mbdst = '\0'; /* can't create extra, return "" */ - error = 0; - goto out; - } - - /* Look up which processing function to call. */ - f = getvisfun(flags); - - /* - * Main processing loop. - * Call do_Xvis processing function one character at a time - * with next character available for look-ahead. - */ - for (start = dst; len > 0; len--) { - c = *src++; - dst = (*f)(dst, c, flags, len >= 1 ? *src : L'\0', extra); - if (dst == NULL) { - errno = ENOSPC; - goto out; - } - } - - /* Terminate the string in the buffer. */ - *dst = L'\0'; - - /* - * Output loop. - * Convert wchar_t string back to multibyte output string. - * If we have hit a multi-byte conversion error on input, - * output byte-by-byte here. Else use wctomb(). - */ - len = wcslen(start); - maxolen = dlen ? *dlen : (wcslen(start) * MB_LEN_MAX + 1); - olen = 0; - for (dst = start; len > 0; len--) { - if (!cerr) - clen = wctomb(mbdst, *dst); - if (cerr || clen < 0) { - /* - * Conversion error, process as a byte(s) instead. - * Examine each byte and higher-order bytes for - * data. E.g., - * 0x000000000000a264 -> a2 64 - * 0x000000001f00a264 -> 1f 00 a2 64 - */ - clen = 0; - wmsk = 0; - for (i = sizeof(wmsk) - 1; i >= 0; i--) { - shft = i * NBBY; - bmsk = (uint64_t)0xffLL << shft; - wmsk |= bmsk; - if ((*dst & wmsk) || i == 0) - mbdst[clen++] = (char)( - (uint64_t)(*dst & bmsk) >> - shft); - } - cerr = 1; - } - /* If this character would exceed our output limit, stop. */ - if (olen + clen > (size_t)maxolen) - break; - /* Advance output pointer by number of bytes written. */ - mbdst += clen; - /* Advance buffer character pointer. */ - dst++; - /* Incrment output character count. */ - olen += clen; - } - - /* Terminate the output string. */ - *mbdst = '\0'; - - if (flags & VIS_NOLOCALE) { - /* Pass conversion error flag out. */ - if (cerr_ptr) - *cerr_ptr = cerr; - } - - free(extra); - free(pdst); - free(psrc); - - return (int)olen; -out: - free(extra); - free(pdst); - free(psrc); - return error; -} - -static int -istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc, - int flags, const char *mbextra, int *cerr_ptr) -{ - return istrsenvisx(mbdst, dlen, mbsrc, - mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr); -} - -#endif - -#if !HAVE_SVIS -/* - * The "svis" variants all take an "extra" arg that is a pointer - * to a NUL-terminated list of characters to be encoded, too. - * These functions are useful e. g. to encode strings in such a - * way so that they are not interpreted by a shell. - */ - -char * -svis(char *mbdst, int c, int flags, int nextc, const char *mbextra) -{ - char cc[2]; - int ret; - - cc[0] = c; - cc[1] = nextc; - - ret = istrsenvisx(mbdst, NULL, cc, 1, flags, mbextra, NULL); - if (ret < 0) - return NULL; - return mbdst + ret; -} - -char * -snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra) -{ - char cc[2]; - int ret; - - cc[0] = c; - cc[1] = nextc; - - ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, mbextra, NULL); - if (ret < 0) - return NULL; - return mbdst + ret; -} - -int -strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra) -{ - return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL); -} - -int -strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra) -{ - return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL); -} - -int -strsvisx(char *mbdst, const char *mbsrc, size_t len, int flags, const char *mbextra) -{ - return istrsenvisx(mbdst, NULL, mbsrc, len, flags, mbextra, NULL); -} - -int -strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags, - const char *mbextra) -{ - return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL); -} - -int -strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags, - const char *mbextra, int *cerr_ptr) -{ - return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr); -} -#endif - -#if !HAVE_VIS -/* - * vis - visually encode characters - */ -char * -vis(char *mbdst, int c, int flags, int nextc) -{ - char cc[2]; - int ret; - - cc[0] = c; - cc[1] = nextc; - - ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL); - if (ret < 0) - return NULL; - return mbdst + ret; -} - -char * -nvis(char *mbdst, size_t dlen, int c, int flags, int nextc) -{ - char cc[2]; - int ret; - - cc[0] = c; - cc[1] = nextc; - - ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, "", NULL); - if (ret < 0) - return NULL; - return mbdst + ret; -} - -/* - * strvis - visually encode characters from src into dst - * - * Dst must be 4 times the size of src to account for possible - * expansion. The length of dst, not including the trailing NULL, - * is returned. - */ - -int -strvis(char *mbdst, const char *mbsrc, int flags) -{ - return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL); -} - -int -strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags) -{ - return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL); -} - -/* - * strvisx - visually encode characters from src into dst - * - * Dst must be 4 times the size of src to account for possible - * expansion. The length of dst, not including the trailing NULL, - * is returned. - * - * Strvisx encodes exactly len characters from src into dst. - * This is useful for encoding a block of data. - */ - -int -strvisx(char *mbdst, const char *mbsrc, size_t len, int flags) -{ - return istrsenvisx(mbdst, NULL, mbsrc, len, flags, "", NULL); -} - -int -strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags) -{ - return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", NULL); -} - -int -strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags, - int *cerr_ptr) -{ - return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr); -} -#endif diff --git a/lib/libc/gen/vwarn.c b/lib/libc/gen/vwarn.c deleted file mode 100644 index 5a89358a3..000000000 --- a/lib/libc/gen/vwarn.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: vwarn.c,v 1.16 2014/01/16 17:21:38 christos Exp $ */ - -/*- - * Copyright (c) 2014 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vwarn.c,v 1.16 2014/01/16 17:21:38 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(vwarn, _vwarn) -#endif - -#if !HAVE_ERR_H -void -vwarn(const char *fmt, va_list ap) -{ - vwarnc(errno, fmt, ap); -} -#endif diff --git a/lib/libc/gen/vwarnc.c b/lib/libc/gen/vwarnc.c deleted file mode 100644 index 20d4f3e36..000000000 --- a/lib/libc/gen/vwarnc.c +++ /dev/null @@ -1,67 +0,0 @@ -/* $NetBSD: vwarnc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: vwarnc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(vwarnc, _vwarnc) -#endif - -#if !HAVE_ERR_H || !HAVE_DECL_VWARNC -void -vwarnc(int code, const char *fmt, va_list ap) -{ - (void)fprintf(stderr, "%s: ", getprogname()); - if (fmt != NULL) { - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, ": "); - } - (void)fprintf(stderr, "%s\n", strerror(code)); -} -#endif diff --git a/lib/libc/gen/vwarnx.c b/lib/libc/gen/vwarnx.c deleted file mode 100644 index eedf550f0..000000000 --- a/lib/libc/gen/vwarnx.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: vwarnx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: vwarnx.c,v 1.15 2011/07/17 20:54:34 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(vwarnx, _vwarnx) -#endif - -#if !HAVE_ERR_H -void -vwarnx(const char *fmt, va_list ap) -{ - (void)fprintf(stderr, "%s: ", getprogname()); - if (fmt != NULL) - (void)vfprintf(stderr, fmt, ap); - (void)fprintf(stderr, "\n"); -} -#endif diff --git a/lib/libc/gen/wait.c b/lib/libc/gen/wait.c deleted file mode 100644 index 776e276b2..000000000 --- a/lib/libc/gen/wait.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: wait.c,v 1.9 2012/03/20 16:36:05 matt Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)wait.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: wait.c,v 1.9 2012/03/20 16:36:05 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(wait,_wait) -#endif - - -pid_t -wait(int *istat) -{ - return (wait4(WAIT_ANY, istat, 0, (struct rusage *)NULL)); -} diff --git a/lib/libc/gen/wait3.c b/lib/libc/gen/wait3.c deleted file mode 100644 index 9dfbeaa2e..000000000 --- a/lib/libc/gen/wait3.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: wait3.c,v 1.10 2012/03/20 16:36:05 matt Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)wait3.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: wait3.c,v 1.10 2012/03/20 16:36:05 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -pid_t -wait3(int *istat, int options, struct rusage *rup) -{ - return (wait4(WAIT_ANY, istat, options, rup)); -} diff --git a/lib/libc/gen/waitpid.c b/lib/libc/gen/waitpid.c deleted file mode 100644 index 46a831793..000000000 --- a/lib/libc/gen/waitpid.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: waitpid.c,v 1.9 2003/08/07 16:43:01 agc Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)waitpid.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: waitpid.c,v 1.9 2003/08/07 16:43:01 agc Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(waitpid,_waitpid) -#endif - -pid_t -waitpid(pid_t pid, int *istat, int options) -{ - return (wait4(pid, istat, options, (struct rusage *)0)); -} diff --git a/lib/libc/gen/warn.c b/lib/libc/gen/warn.c deleted file mode 100644 index 2f784662e..000000000 --- a/lib/libc/gen/warn.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: warn.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: warn.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(warn, _warn) -#endif - -#if !HAVE_ERR_H -void -warn(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vwarn(fmt, ap); - va_end(ap); -} -#endif diff --git a/lib/libc/gen/warnc.c b/lib/libc/gen/warnc.c deleted file mode 100644 index 38d588ed6..000000000 --- a/lib/libc/gen/warnc.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: warnc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: warnc.c,v 1.3 2014/06/06 11:38:41 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(warnc, _warnc) -#endif - -#if !HAVE_ERR_H || !HAVE_DECL_WARNC -void -warnc(int code, const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vwarnc(code, fmt, ap); - va_end(ap); -} -#endif diff --git a/lib/libc/gen/warnx.c b/lib/libc/gen/warnx.c deleted file mode 100644 index e703c5332..000000000 --- a/lib/libc/gen/warnx.c +++ /dev/null @@ -1,63 +0,0 @@ -/* $NetBSD: warnx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)err.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: warnx.c,v 1.14 2007/06/18 14:13:54 ginsbach Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(warnx, _warnx) -#endif - -#if !HAVE_ERR_H -void -warnx(const char *fmt, ...) -{ - va_list ap; - - va_start(ap, fmt); - vwarnx(fmt, ap); - va_end(ap); -} -#endif diff --git a/lib/libc/gen/wordexp.3 b/lib/libc/gen/wordexp.3 deleted file mode 100644 index 62eae0a97..000000000 --- a/lib/libc/gen/wordexp.3 +++ /dev/null @@ -1,226 +0,0 @@ -.\" $NetBSD: wordexp.3,v 1.2 2006/04/24 20:27:34 jld Exp $ -.\" -.\" Copyright (c) 2002 Tim J. Robbins -.\" 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: /repoman/r/ncvs/src/lib/libc/gen/wordexp.3,v 1.6 2003/09/08 19:57:14 ru Exp $ -.\" -.Dd July 13, 2004 -.Dt WORDEXP 3 -.Os -.Sh NAME -.Nm wordexp -.Nd "perform shell-style word expansions" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wordexp.h -.Ft int -.Fn wordexp "const char * restrict words" "wordexp_t * restrict pwordexp" "int flags" -.Ft void -.Fn wordfree "wordexp_t *pwordexp" -.Sh DESCRIPTION -The -.Fn wordexp -function performs shell-style word expansion on -.Fa words -and places the list of expanded words into the structure pointed to by -.Fa pwordexp . -.Pp -The -.Fa flags -argument is the bitwise inclusive OR of any of the following constants: -.Bl -tag -width ".Dv WRDE_SHOWERR" -.It Dv WRDE_APPEND -Append the words to those generated by a previous call to -.Fn wordexp . -.It Dv WRDE_DOOFFS -As many -.Dv NULL -pointers as are specified by the -.Va we_offs -member of -.Fa we -are added to the front of -.Va we_wordv . -.It Dv WRDE_NOCMD -Disallow command substitution in -.Fa words . -See the note in -.Sx BUGS -before using this. -.It Dv WRDE_REUSE -The -.Fa we -argument was passed to a previous successful call to -.Fn wordexp -but has not been passed to -.Fn wordfree . -The implementation may reuse the space allocated to it. -.It Dv WRDE_SHOWERR -Do not redirect shell error messages to -.Pa /dev/null . -.It Dv WRDE_UNDEF -Report error on an attempt to expand an undefined shell variable. -.El -.Pp -The structure type -.Nm wordexp_t -includes the following members: -.Bd -literal -offset indent -size_t we_wordc -char **we_wordv -size_t we_offs -.Ed -.Pp -The -.Fa we_wordc -member is the count of generated words. -.Pp -The -.Fa we_wordv -member points to a list of pointers to expanded words. -.Pp -The -.Fa we_offs -member is the number of slots to reserve at the beginning of the -.Fa we_wordv -member. -.Pp -It is the caller's responsibility to allocate the storage pointed to by -.Fa pwordexp . -The -.Fn wordexp -function allocates other space as needed, including memory -pointed to by the -.Fa we_wordv -member. -.Pp -The -.Fn wordfree -function frees the memory allocated by -.Fn wordexp . -.Sh IMPLEMENTATION NOTES -The -.Fn wordexp -function is implemented as a wrapper around the undocumented -.Ic wordexp -shell built-in command. -.Sh RETURN VALUES -The -.Fn wordexp -function returns zero if successful, otherwise it returns one of the following -error codes: -.Bl -tag -width ".Dv WRDE_NOSPACE" -.It Dv WRDE_BADCHAR -The -.Fa words -argument contains one of the following unquoted characters: -.Aq newline , -.Ql | , -.Ql \*[Am] , -.Ql \&; , -.Ql \*[Lt] , -.Ql \*[Gt] , -.Ql \&( , -.Ql \&) , -.Ql { , -.Ql } . -.It Dv WRDE_BADVAL -An attempt was made to expand an undefined shell variable and -.Dv WRDE_UNDEF -is set in -.Fa flags . -.It Dv WRDE_CMDSUB -An attempt was made to use command substitution and -.Dv WRDE_NOCMD -is set in -.Fa flags . -.It Dv WRDE_NOSPACE -Not enough memory to store the result. -.It Dv WRDE_SYNTAX -Shell syntax error in -.Fa words . -.It Dv WRDE_ERRNO -An internal error occured and -.Va errno -is set to indicate the error. -.El -.Pp -The -.Fn wordfree -function returns no value. -.Sh ENVIRONMENT -.Bl -tag -width ".Ev IFS" -.It Ev IFS -Field separator. -.El -.Sh EXAMPLES -Invoke the editor on all -.Pa .c -files in the current directory -and -.Pa /etc/motd -(error checking omitted): -.Bd -literal -offset indent -wordexp_t we; - -wordexp("${EDITOR:-vi} *.c /etc/motd", \*[Am]we, 0); -execvp(we-\*[Gt]we_wordv[0], we-\*[Gt]we_wordv); -.Ed -.Sh DIAGNOSTICS -Diagnostic messages from the shell are written to the standard error output -if -.Dv WRDE_SHOWERR -is set in -.Fa flags . -.Sh SEE ALSO -.Xr sh 1 , -.Xr fnmatch 3 , -.Xr glob 3 , -.Xr popen 3 , -.Xr system 3 -.Sh STANDARDS -The -.Fn wordexp -and -.Fn wordfree -functions conform to -.St -p1003.1-2001 . -Their first release was in -.St -p1003.2-92 . -The return value -.Dv WRDE_ERRNO -is an extension. -.Sh BUGS -Do not pass untrusted user data to -.Fn wordexp , -regardless of whether the -.Dv WRDE_NOCMD -flag is set. -The -.Fn wordexp -function attempts to detect input that would cause commands to be -executed before passing it to the shell -but it does not use the same parser so it may be fooled. diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c deleted file mode 100644 index a05db38eb..000000000 --- a/lib/libc/gen/wordexp.c +++ /dev/null @@ -1,346 +0,0 @@ -/* $NetBSD: wordexp.c,v 1.3 2009/02/12 04:10:52 lukem Exp $ */ - -/*- - * Copyright (c) 2002 Tim J. Robbins. - * 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 "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -__FBSDID("$FreeBSD: /repoman/r/ncvs/src/lib/libc/gen/wordexp.c,v 1.5 2004/04/09 11:32:32 tjr Exp $"); -#else -__RCSID("$NetBSD: wordexp.c,v 1.3 2009/02/12 04:10:52 lukem Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -static int we_askshell(const char *, wordexp_t *, int); -static int we_check(const char *, int); - -/* - * wordexp -- - * Perform shell word expansion on `words' and place the resulting list - * of words in `we'. See wordexp(3). - * - */ -int -wordexp(const char * __restrict words, wordexp_t * __restrict we, int flags) -{ - int error; - - _DIAGASSERT(we != NULL); - _DIAGASSERT(words != NULL); - if (flags & WRDE_REUSE) - wordfree(we); - if ((flags & WRDE_APPEND) == 0) { - we->we_wordc = 0; - we->we_wordv = NULL; - we->we_strings = NULL; - we->we_nbytes = 0; - } - if ((error = we_check(words, flags)) != 0) { - wordfree(we); - return (error); - } - if ((error = we_askshell(words, we, flags)) != 0) { - wordfree(we); - return (error); - } - return (0); -} - -/* - * we_askshell -- - * Use the `wordexp' /bin/sh builtin function to do most of the work - * in expanding the word string. This function is complicated by - * memory management. - */ -static int -we_askshell(const char *words, wordexp_t *we, int flags) -{ - int pdes[2]; /* Pipe to child */ - size_t nwords, nbytes; /* Number of words, bytes from child */ - int i; /* Handy integer */ - unsigned int ui; /* For array iteration */ - size_t sofs; /* Offset into we->we_strings */ - size_t vofs; /* Offset into we->we_wordv */ - pid_t pid; /* Process ID of child */ - int status; /* Child exit status */ - const char *ifs; /* IFS env. var. */ - char *np, *p; /* Handy pointers */ - char *nstrings; /* Temporary for realloc() */ - char **nwv; /* Temporary for realloc() */ - FILE *fp; /* Stream to read pipe */ - extern char **environ; - char *cmd; - - if ((ifs = getenv("IFS")) == NULL) - ifs = " \t\n"; - if (asprintf(&cmd, "wordexp%c%s\n", *ifs, words) < 0) - return (WRDE_NOSPACE); - if (pipe(pdes) < 0) { - free(cmd); - return (WRDE_ERRNO); - } - if ((fp = fdopen(pdes[0], "r")) == NULL) { - free(cmd); - return (WRDE_ERRNO); - } - if ((pid = fork()) < 0) { - free(cmd); - fclose(fp); - close(pdes[1]); - return (WRDE_ERRNO); - } - else if (pid == 0) { - /* - * We are the child; just get /bin/sh to run the wordexp - * builtin on `words'. - */ - int devnull; - - close(pdes[0]); - if (pdes[1] != STDOUT_FILENO) { - if (dup2(pdes[1], STDOUT_FILENO) < 0) - _exit(1); - close(pdes[1]); - } - if ((flags & WRDE_SHOWERR) == 0) { - if ((devnull = open(_PATH_DEVNULL, O_RDWR, 0666)) < 0) - _exit(1); - if (dup2(devnull, STDERR_FILENO) < 0) - _exit(1); - close(devnull); - } - execle(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u", - "-c", cmd, (char *)NULL, environ); - _exit(1); - } - - /* - * We are the parent; read the output of the shell wordexp function, - * which is a decimal word count, an null, a decimal byte count, - * (not including terminating null bytes), a null and then followed - * by the expanded words separated by nulls. - */ - free(cmd); - close(pdes[1]); - /* read the word count */ - nwords = 0; - while ((i = getc(fp)) != EOF) { - if (i == '\0') - break; - nwords *= 10; - nwords += (i - '0'); - } - /* read the byte count */ - nbytes = 0; - while ((i = getc(fp)) != EOF) { - if (i == '\0') - break; - nbytes *= 10; - nbytes += (i - '0'); - } - if (i == EOF) { - fclose(fp); - waitpid(pid, &status, 0); - return (flags & WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX); - } - nbytes += nwords; - - /* - * Allocate or reallocate (when flags & WRDE_APPEND) the word vector - * and string storage buffers for the expanded words we're about to - * read from the child. - */ - sofs = we->we_nbytes; - vofs = we->we_wordc; - if ((flags & (WRDE_DOOFFS|WRDE_APPEND)) == (WRDE_DOOFFS|WRDE_APPEND)) - vofs += we->we_offs; - we->we_wordc += nwords; - we->we_nbytes += nbytes; - if ((nwv = realloc(we->we_wordv, (we->we_wordc + 1 + - (flags & WRDE_DOOFFS ? we->we_offs : 0)) * - sizeof(char *))) == NULL) { - fclose(fp); - waitpid(pid, &status, 0); - return (WRDE_NOSPACE); - } - we->we_wordv = nwv; - if ((nstrings = realloc(we->we_strings, we->we_nbytes)) == NULL) { - fclose(fp); - waitpid(pid, &status, 0); - return (WRDE_NOSPACE); - } - for (ui = 0; ui < vofs; ui++) - if (we->we_wordv[ui] != NULL) - we->we_wordv[ui] += nstrings - we->we_strings; - we->we_strings = nstrings; - - if (fread(we->we_strings + sofs, sizeof(char), nbytes, fp) != nbytes) { - fclose(fp); - waitpid(pid, &status, 0); - return (flags & WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX); - } - - if (waitpid(pid, &status, 0) < 0 || !WIFEXITED(status) || - WEXITSTATUS(status) != 0) { - fclose(fp); - return (flags & WRDE_UNDEF ? WRDE_BADVAL : WRDE_SYNTAX); - } - fclose(fp); - - /* - * Break the null-terminated expanded word strings out into - * the vector. - */ - if (vofs == 0 && flags & WRDE_DOOFFS) - while (vofs < we->we_offs) - we->we_wordv[vofs++] = NULL; - p = we->we_strings + sofs; - while (nwords-- != 0) { - we->we_wordv[vofs++] = p; - if ((np = memchr(p, '\0', nbytes)) == NULL) - return (WRDE_NOSPACE); /* XXX */ - nbytes -= np - p + 1; - p = np + 1; - } - we->we_wordv[vofs] = NULL; - - return (0); -} - -/* - * we_check -- - * Check that the string contains none of the following unquoted - * special characters: |&;<>(){} - * or command substitutions when WRDE_NOCMD is set in flags. - */ -static int -we_check(const char *words, int flags) -{ - char c; - int dquote, level, quote, squote; - - quote = squote = dquote = 0; - while ((c = *words++) != '\0') { - switch (c) { - case '\\': - quote ^= 1; - continue; - case '\'': - if (quote + dquote == 0) - squote ^= 1; - break; - case '"': - if (quote + squote == 0) - dquote ^= 1; - break; - case '`': - if (quote + squote == 0 && flags & WRDE_NOCMD) - return (WRDE_CMDSUB); - while ((c = *words++) != '\0' && c != '`') - if (c == '\\' && (c = *words++) == '\0') - break; - if (c == '\0') - return (WRDE_SYNTAX); - break; - case '|': case '&': case ';': case '<': case '>': - case '{': case '}': case '(': case ')': case '\n': - if (quote + squote + dquote == 0) - return (WRDE_BADCHAR); - break; - case '$': - if ((c = *words++) == '\0') - break; - else if (quote + squote == 0 && c == '(') { - if (flags & WRDE_NOCMD && *words != '(') - return (WRDE_CMDSUB); - level = 1; - while ((c = *words++) != '\0') { - if (c == '\\') { - if ((c = *words++) == '\0') - break; - } else if (c == '(') - level++; - else if (c == ')' && --level == 0) - break; - } - if (c == '\0' || level != 0) - return (WRDE_SYNTAX); - } else if (quote + squote == 0 && c == '{') { - level = 1; - while ((c = *words++) != '\0') { - if (c == '\\') { - if ((c = *words++) == '\0') - break; - } else if (c == '{') - level++; - else if (c == '}' && --level == 0) - break; - } - if (c == '\0' || level != 0) - return (WRDE_SYNTAX); - } else - c = *--words; - break; - default: - break; - } - quote = 0; - } - if (quote + squote + dquote != 0) - return (WRDE_SYNTAX); - - return (0); -} - -/* - * wordfree -- - * Free the result of wordexp(). See wordexp(3). - * - */ -void -wordfree(wordexp_t *we) -{ - _DIAGASSERT(we != NULL); - free(we->we_wordv); - free(we->we_strings); - we->we_wordv = NULL; - we->we_strings = NULL; - we->we_nbytes = 0; - we->we_wordc = 0; -} diff --git a/lib/libc/gmon/Makefile.inc b/lib/libc/gmon/Makefile.inc deleted file mode 100644 index eff0810d8..000000000 --- a/lib/libc/gmon/Makefile.inc +++ /dev/null @@ -1,27 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.11 2014/09/17 11:37:28 joerg Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -# gmon sources -.PATH: ${.CURDIR}/gmon ${ARCHDIR}/gmon - -.-include "${ARCHDIR}/gmon/Makefile.inc" - -SRCS+= gmon.c mcount.c -MAN+= moncontrol.3 -MLINKS+=moncontrol.3 monstartup.3 - -.if (${MACHINE_CPU} == "mips") -# Turn off as(1) warnings on MIPS, since warnings are fatal with WARNS>0 -# and mcount.c causes warnings from as(1). -# mcount.c should be fixed and this test removed. -# -COPTS.mcount.c+=${${ACTIVE_CXX} == "gcc":? -Wa,--no-warn :} -.endif - - -# mcount and gmon cannot be compiled with profiling -mcount.po: mcount.o - cp mcount.o mcount.po - -gmon.po: gmon.o - cp gmon.o gmon.po diff --git a/lib/libc/gmon/gmon.c b/lib/libc/gmon/gmon.c deleted file mode 100644 index 28c19bd04..000000000 --- a/lib/libc/gmon/gmon.c +++ /dev/null @@ -1,553 +0,0 @@ -/* $NetBSD: gmon.c,v 1.35 2014/09/18 13:58:20 christos Exp $ */ - -/* - * Copyright (c) 2003, 2004 Wasabi Systems, Inc. - * All rights reserved. - * - * Written by Nathan J. Williams for Wasabi Systems, Inc. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed for the NetBSD Project by - * Wasabi Systems, Inc. - * 4. The name of Wasabi Systems, Inc. may not be used to endorse - * or promote products derived from this software without specific prior - * written permission. - * - * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``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 WASABI SYSTEMS, INC - * 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. - */ - -/*- - * Copyright (c) 1983, 1992, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if !defined(lint) && defined(LIBC_SCCS) -#if 0 -static char sccsid[] = "@(#)gmon.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: gmon.c,v 1.35 2014/09/18 13:58:20 christos Exp $"); -#endif -#endif - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include "extern.h" -#include "reentrant.h" - -struct gmonparam _gmonparam = { .state = GMON_PROF_OFF }; - -#ifdef _REENTRANT -struct gmonparam *_gmonfree; -struct gmonparam *_gmoninuse; -mutex_t _gmonlock = MUTEX_INITIALIZER; -thread_key_t _gmonkey; -struct gmonparam _gmondummy; -#endif - -static u_int s_scale; -/* see profil(2) where this is describe (incorrectly) */ -#define SCALE_1_TO_1 0x10000L - -void moncontrol(int); -void monstartup(u_long, u_long); -void _mcleanup(void); -static int hertz(void); - -#ifdef _REENTRANT -static void _m_gmon_destructor(void *); -struct gmonparam *_m_gmon_alloc(void) - __attribute__((__no_instrument_function__)); -static void _m_gmon_merge(void); -static void _m_gmon_merge_two(struct gmonparam *, struct gmonparam *); -#endif - -void -monstartup(u_long lowpc, u_long highpc) -{ - u_long o; - char *cp; - struct gmonparam *p = &_gmonparam; - - /* - * round lowpc and highpc to multiples of the density we're using - * so the rest of the scaling (here and in gprof) stays in ints. - */ - p->lowpc = rounddown(lowpc, HISTFRACTION * sizeof(HISTCOUNTER)); - p->highpc = roundup(highpc, HISTFRACTION * sizeof(HISTCOUNTER)); - p->textsize = p->highpc - p->lowpc; - p->kcountsize = p->textsize / HISTFRACTION; - p->hashfraction = HASHFRACTION; - p->fromssize = p->textsize / p->hashfraction; - p->tolimit = p->textsize * ARCDENSITY / 100; - if (p->tolimit < MINARCS) - p->tolimit = MINARCS; - else if (p->tolimit > MAXARCS) - p->tolimit = MAXARCS; - p->tossize = p->tolimit * sizeof(struct tostruct); - - cp = sbrk((intptr_t)(p->kcountsize + p->fromssize + p->tossize)); - if (cp == (char *)-1) { - warnx("%s: out of memory", __func__); - return; - } -#ifdef notdef - (void)memset(cp, 0, p->kcountsize + p->fromssize + p->tossize); -#endif - p->tos = (struct tostruct *)(void *)cp; - cp += (size_t)p->tossize; - p->kcount = (u_short *)(void *)cp; - cp += (size_t)p->kcountsize; - p->froms = (u_short *)(void *)cp; - - __minbrk = sbrk((intptr_t)0); - p->tos[0].link = 0; - - o = p->highpc - p->lowpc; - if (p->kcountsize < o) { -#ifndef notdef - s_scale = ((float)p->kcountsize / o ) * SCALE_1_TO_1; -#else /* avoid floating point */ - u_long quot = o / p->kcountsize; - - if (quot >= 0x10000) - s_scale = 1; - else if (quot >= 0x100) - s_scale = 0x10000 / quot; - else if (o >= 0x800000) - s_scale = 0x1000000 / (o / (p->kcountsize >> 8)); - else - s_scale = 0x1000000 / ((o << 8) / p->kcountsize); -#endif - } else - s_scale = SCALE_1_TO_1; - -#ifdef _REENTRANT - _gmondummy.state = GMON_PROF_BUSY; - thr_keycreate(&_gmonkey, _m_gmon_destructor); -#endif - moncontrol(1); -} - -#ifdef _REENTRANT -static void -_m_gmon_destructor(void *arg) -{ - struct gmonparam *p = arg, *q, **prev; - - if (p == &_gmondummy) - return; - - thr_setspecific(_gmonkey, &_gmondummy); - - mutex_lock(&_gmonlock); - /* XXX eww, linear list traversal. */ - for (q = _gmoninuse, prev = &_gmoninuse; - q != NULL; - prev = (struct gmonparam **)(void *)&q->kcount, /* XXX */ - q = (struct gmonparam *)(void *)q->kcount) { - if (q == p) - *prev = (struct gmonparam *)(void *)q->kcount; - } - p->kcount = (u_short *)(void *)_gmonfree; - _gmonfree = p; - mutex_unlock(&_gmonlock); - - thr_setspecific(_gmonkey, NULL); -} - -struct gmonparam * -_m_gmon_alloc(void) -{ - struct gmonparam *p; - char *cp; - - mutex_lock(&_gmonlock); - if (_gmonfree != NULL) { - p = _gmonfree; - _gmonfree = (struct gmonparam *)(void *)p->kcount; - p->kcount = (u_short *)(void *)_gmoninuse; - _gmoninuse = p; - } else { - mutex_unlock(&_gmonlock); - cp = mmap(NULL, - (size_t)(sizeof (struct gmonparam) + - _gmonparam.fromssize + _gmonparam.tossize), - PROT_READ|PROT_WRITE, MAP_ANON|MAP_PRIVATE, -1, (off_t)0); - p = (void *)cp; - *p = _gmonparam; - p->kcount = NULL; - cp += sizeof (struct gmonparam); - memset(cp, 0, (size_t)(p->fromssize + p->tossize)); - p->froms = (u_short *)(void *)cp; - p->tos = (struct tostruct *)(void *)(cp + p->fromssize); - mutex_lock(&_gmonlock); - p->kcount = (u_short *)(void *)_gmoninuse; - _gmoninuse = p; - } - mutex_unlock(&_gmonlock); - thr_setspecific(_gmonkey, p); - - return p; -} - -static void -_m_gmon_merge_two(struct gmonparam *p, struct gmonparam *q) -{ - u_long fromindex; - u_short *frompcindex, qtoindex, toindex; - u_long selfpc; - u_long endfrom; - long count; - struct tostruct *top; - - endfrom = (q->fromssize / sizeof(*q->froms)); - for (fromindex = 0; fromindex < endfrom; fromindex++) { - if (q->froms[fromindex] == 0) - continue; - for (qtoindex = q->froms[fromindex]; qtoindex != 0; - qtoindex = q->tos[qtoindex].link) { - selfpc = q->tos[qtoindex].selfpc; - count = q->tos[qtoindex].count; - /* cribbed from mcount */ - frompcindex = &p->froms[fromindex]; - toindex = *frompcindex; - if (toindex == 0) { - /* - * first time traversing this arc - */ - toindex = ++p->tos[0].link; - if (toindex >= p->tolimit) - /* halt further profiling */ - goto overflow; - - *frompcindex = (u_short)toindex; - top = &p->tos[(size_t)toindex]; - top->selfpc = selfpc; - top->count = count; - top->link = 0; - goto done; - } - top = &p->tos[(size_t)toindex]; - if (top->selfpc == selfpc) { - /* - * arc at front of chain; usual case. - */ - top->count+= count; - goto done; - } - /* - * have to go looking down chain for it. - * top points to what we are looking at, - * we know it is not at the head of the chain. - */ - for (; /* goto done */; ) { - if (top->link == 0) { - /* - * top is end of the chain and - * none of the chain had - * top->selfpc == selfpc. so - * we allocate a new tostruct - * and link it to the head of - * the chain. - */ - toindex = ++p->tos[0].link; - if (toindex >= p->tolimit) - goto overflow; - - top = &p->tos[(size_t)toindex]; - top->selfpc = selfpc; - top->count = count; - top->link = *frompcindex; - *frompcindex = (u_short)toindex; - goto done; - } - /* - * otherwise, check the next arc on the chain. - */ - top = &p->tos[top->link]; - if (top->selfpc == selfpc) { - /* - * there it is. - * add to its count. - */ - top->count += count; - goto done; - } - - } - - done: ; - } - - } - overflow: ; - -} - -static void -_m_gmon_merge(void) -{ - struct gmonparam *q; - - mutex_lock(&_gmonlock); - - for (q = _gmonfree; q != NULL; - q = (struct gmonparam *)(void *)q->kcount) - _m_gmon_merge_two(&_gmonparam, q); - - for (q = _gmoninuse; q != NULL; - q = (struct gmonparam *)(void *)q->kcount) { - q->state = GMON_PROF_OFF; - _m_gmon_merge_two(&_gmonparam, q); - } - - mutex_unlock(&_gmonlock); -} -#endif - -void -_mcleanup(void) -{ - int fd; - int fromindex; - int endfrom; - u_long frompc; - int toindex; - struct rawarc rawarc; - struct gmonparam *p = &_gmonparam; - struct gmonhdr gmonhdr, *hdr; - struct clockinfo clockinfo; -#if !defined(__minix) - int mib[2]; - size_t size; -#endif /* !defined(__minix) */ - char *profdir; - const char *proffile; - char buf[PATH_MAX]; -#ifdef DEBUG - int logfd, len; - char buf2[200]; -#endif - - /* - * We disallow writing to the profiling file, if we are a - * set{u,g}id program and our effective {u,g}id does not match - * our real one. - */ - if (issetugid() && (geteuid() != getuid() || getegid() != getgid())) { - warnx("%s: Profiling of set{u,g}id binaries is not" - " allowed", __func__); - return; - } - - if (p->state == GMON_PROF_ERROR) - warnx("%s: tos overflow", __func__); - -#if defined(__minix) - clockinfo.profhz = sysconf(_SC_CLK_TCK); -#else - size = sizeof(clockinfo); - mib[0] = CTL_KERN; - mib[1] = KERN_CLOCKRATE; - if (sysctl(mib, 2, &clockinfo, &size, NULL, 0) < 0) { - /* - * Best guess - */ - clockinfo.profhz = hertz(); - } else if (clockinfo.profhz == 0) { - if (clockinfo.hz != 0) - clockinfo.profhz = clockinfo.hz; - else - clockinfo.profhz = hertz(); - } -#endif /* defined(__minix) */ - - moncontrol(0); - - if ((profdir = getenv("PROFDIR")) != NULL) { - /* If PROFDIR contains a null value, no profiling - output is produced */ - if (*profdir == '\0') - return; - - if (snprintf(buf, sizeof buf, "%s/%d.%s", - profdir, getpid(), getprogname()) >= (int)(sizeof buf)) { - warnx("%s: internal buffer overflow, PROFDIR too long", - __func__); - return; - } - - proffile = buf; - } else { - proffile = "gmon.out"; - } - -#define OPEN_FLAGS (O_CREAT | O_TRUNC | O_WRONLY | O_CLOEXEC) - fd = open(proffile, OPEN_FLAGS, 0666); - if (fd < 0) { - warn("%s: Cannot open `%s'", __func__, proffile); - return; - } -#ifdef DEBUG - logfd = open("gmon.log", OPEN_FLAGS, 0664); - if (logfd < 0) { - warn("%s: Cannot open `%s'", __func__, "gmon.log"); - (void)close(fd); - return; - } - len = snprintf(buf2, sizeof buf2, "[mcleanup1] kcount %p ssiz %lu\n", - p->kcount, p->kcountsize); - (void)write(logfd, buf2, (size_t)len); -#endif -#ifdef _REENTRANT - _m_gmon_merge(); -#endif - hdr = (struct gmonhdr *)&gmonhdr; - hdr->lpc = p->lowpc; - hdr->hpc = p->highpc; - hdr->ncnt = (int)(p->kcountsize + sizeof(gmonhdr)); - hdr->version = GMONVERSION; - hdr->profrate = clockinfo.profhz; - (void)write(fd, hdr, sizeof *hdr); - (void)write(fd, p->kcount, (size_t)p->kcountsize); - endfrom = (int)(p->fromssize / sizeof(*p->froms)); - for (fromindex = 0; fromindex < endfrom; fromindex++) { - if (p->froms[fromindex] == 0) - continue; - - frompc = p->lowpc; - frompc += fromindex * p->hashfraction * sizeof(*p->froms); - for (toindex = p->froms[fromindex]; toindex != 0; - toindex = p->tos[toindex].link) { -#ifdef DEBUG - len = snprintf(buf2, sizeof buf2, - "[mcleanup2] frompc 0x%lx selfpc 0x%lx count %lu\n" , - (u_long)frompc, (u_long)p->tos[toindex].selfpc, - (u_long)p->tos[toindex].count); - (void)write(logfd, buf2, (size_t)len); -#endif - rawarc.raw_frompc = frompc; - rawarc.raw_selfpc = p->tos[toindex].selfpc; - rawarc.raw_count = p->tos[toindex].count; - (void)write(fd, &rawarc, sizeof rawarc); - } - } - (void)close(fd); -#ifdef DEBUG - (void)close(logfd); -#endif -} - -/* - * Control profiling - * profiling is what mcount checks to see if - * all the data structures are ready. - */ -void -moncontrol(int mode) -{ - struct gmonparam *p = &_gmonparam; - - if (mode) { - /* start */ - profil((char *)(void *)p->kcount, (size_t)p->kcountsize, - p->lowpc, s_scale); - p->state = GMON_PROF_ON; - } else { - /* stop */ - profil(NULL, 0, (u_long)0, 0); - p->state = GMON_PROF_OFF; - } -} - -#if !defined(__minix) -/* - * discover the tick frequency of the machine - * if something goes wrong, we return 0, an impossible hertz. - */ -static int -hertz(void) -{ - struct itimerspec tim; - timer_t t; - int rv = 0; - - tim.it_interval.tv_sec = 0; - tim.it_interval.tv_nsec = 1; - tim.it_value.tv_sec = 0; - tim.it_value.tv_nsec = 0; - - if (timer_create(CLOCK_REALTIME, NULL, &t) == -1) - return 0; - - if (timer_settime(t, 0, &tim, NULL) == -1) - goto out; - - if (timer_gettime(t, &tim) == -1) - goto out; - - if (tim.it_interval.tv_nsec < 2) - goto out; - - rv = (int)(1000000000LL / tim.it_interval.tv_nsec); -out: - (void)timer_delete(t); - return rv; -} -#endif /* !defined(__minix) */ diff --git a/lib/libc/gmon/moncontrol.3 b/lib/libc/gmon/moncontrol.3 deleted file mode 100644 index bc3dc3257..000000000 --- a/lib/libc/gmon/moncontrol.3 +++ /dev/null @@ -1,115 +0,0 @@ -.\" $NetBSD: moncontrol.3,v 1.10 2009/04/11 15:33:27 joerg Exp $ -.\" -.\" Copyright (c) 1980, 1991, 1992, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)moncontrol.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd June 4, 1993 -.Dt MONCONTROL 3 -.Os -.Sh NAME -.Nm moncontrol , -.Nm monstartup -.Nd control execution profile -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.Fn moncontrol "int mode" -.Fn monstartup "u_long *lowpc" "u_long *highpc" -.Sh DESCRIPTION -An executable program compiled using the -.Fl pg -option to -.Xr cc 1 -automatically includes calls to collect statistics for the -.Xr gprof 1 -call-graph execution profiler. -In typical operation, profiling begins at program startup -and ends when the program calls exit. -When the program exits, the profiling data are written to the file -.Em gmon.out , -then -.Xr gprof 1 -can be used to examine the results. -.Pp -.Fn moncontrol -selectively controls profiling within a program. -When the program starts, profiling begins. -To stop the collection of histogram ticks and call counts use -.Fn moncontrol 0 ; -to resume the collection of histogram ticks and call counts use -.Fn moncontrol 1 . -This feature allows the cost of particular operations to be measured. -Note that an output file will be produced on program exit -regardless of the state of -.Fn moncontrol . -.Pp -Programs that are not loaded with -.Fl pg -may selectively collect profiling statistics by calling -.Fn monstartup -with the range of addresses to be profiled. -.Fa lowpc -and -.Fa highpc -specify the address range that is to be sampled; -the lowest address sampled is that of -.Fa lowpc -and the highest is just below -.Fa highpc . -Only functions in that range that have been compiled with the -.Fl pg -option to -.Xr cc 1 -will appear in the call graph part of the output; -however, all functions in that address range will -have their execution time measured. -Profiling begins on return from -.Fn monstartup . -.Sh ENVIRONMENT -.Bl -tag -width "PROFDIR" -.It Ev PROFDIR -Directory to place the output file(s) in. -When this is set, instead of writing the profiling output to -.Pa gmon.out , -a filename is generated from the process id and name of the program -(e.g., -.Pa 123.a.out ) . -If you are profiling a program that forks, -or otherwise creates multiple copies, -setting this is the only reasonable way to get all profiling data. -.El -.Sh FILES -.Bl -tag -width ".Pa gmon.out" -compact -.It Pa gmon.out -execution data file -.El -.Sh SEE ALSO -.Xr cc 1 , -.Xr gprof 1 , -.Xr profil 2 diff --git a/lib/libc/hash/Makefile.inc b/lib/libc/hash/Makefile.inc deleted file mode 100644 index beecbf416..000000000 --- a/lib/libc/hash/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.12 2012/07/08 01:21:12 rmind Exp $ -# $OpenBSD: Makefile.inc,v 1.5 1997/07/17 06:02:42 millert Exp $ - -# hash functions -.PATH: ${ARCHDIR}/hash ${.CURDIR}/hash - -.include "${.CURDIR}/hash/md2/Makefile.inc" -.include "${.CURDIR}/hash/rmd160/Makefile.inc" -.include "${.CURDIR}/hash/sha1/Makefile.inc" -.include "${.CURDIR}/hash/sha2/Makefile.inc" - -.include "${.CURDIR}/hash/murmurhash/Makefile.inc" diff --git a/lib/libc/hash/hashhl.c b/lib/libc/hash/hashhl.c deleted file mode 100644 index 2d79e230a..000000000 --- a/lib/libc/hash/hashhl.c +++ /dev/null @@ -1,144 +0,0 @@ -/* $NetBSD: hashhl.c,v 1.7 2014/09/24 13:18:52 christos Exp $ */ - -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - */ - -/* - * Modified September 24, 2005 by Elad Efrat - * Modified April 29, 1997 by Jason R. Thorpe - */ - -#ifdef HASH_ALGORITHM - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -/* - * Do all the name mangling before we include "namespace.h" - */ -#define CONCAT(x,y) __CONCAT(x,y) - -#ifndef HASH_FNPREFIX -#define HASH_FNPREFIX HASH_ALGORITHM -#endif /* !HASH_FNPREFIX */ - -#define FNPREFIX(x) CONCAT(HASH_FNPREFIX,x) -#define HASH_CTX CONCAT(HASH_ALGORITHM,_CTX) -#define HASH_LEN CONCAT(HASH_ALGORITHM,_DIGEST_LENGTH) -#define HASH_STRLEN CONCAT(HASH_ALGORITHM,_DIGEST_STRING_LENGTH) - -#if !defined(_KERNEL) && defined(__weak_alias) && !defined(HAVE_NBTOOL_CONFIG_H) -#define WA(a,b) __weak_alias(a,b) -WA(FNPREFIX(End),CONCAT(_,FNPREFIX(End))) -WA(FNPREFIX(FileChunk),CONCAT(_,FNPREFIX(FileChunk))) -WA(FNPREFIX(File),CONCAT(_,FNPREFIX(File))) -WA(FNPREFIX(Data),CONCAT(_,FNPREFIX(Data))) -#undef WA -#endif - -#include "namespace.h" -#include HASH_INCLUDE - -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifndef MIN -#define MIN(x,y) ((x)<(y)?(x):(y)) -#endif /* !MIN */ - -char * -FNPREFIX(End)(HASH_CTX *ctx, char *buf) -{ - int i; - unsigned char digest[HASH_LEN]; - static const char hex[]="0123456789abcdef"; - - _DIAGASSERT(ctx != 0); - - if (buf == NULL) - buf = malloc((size_t)HASH_STRLEN); - if (buf == NULL) - return (NULL); - - FNPREFIX(Final)(digest, ctx); - - for (i = 0; i < HASH_LEN; i++) { - buf[i+i] = hex[(u_int32_t)digest[i] >> 4]; - buf[i+i+1] = hex[digest[i] & 0x0f]; - } - - buf[i+i] = '\0'; - return (buf); -} - -char * -FNPREFIX(FileChunk)(const char *filename, char *buf, off_t off, off_t len) -{ - struct stat sb; - u_char buffer[BUFSIZ]; - HASH_CTX ctx; - int fd, save_errno; - ssize_t nr; - - FNPREFIX(Init)(&ctx); - - if ((fd = open(filename, O_RDONLY | O_CLOEXEC)) < 0) - return (NULL); - if (len == 0) { - if (fstat(fd, &sb) == -1) { - close(fd); - return (NULL); - } - len = sb.st_size; - } - if (off > 0 && lseek(fd, off, SEEK_SET) < 0) { - close(fd); - return (NULL); - } - - while ((nr = read(fd, buffer, (size_t) MIN((off_t)sizeof(buffer), len))) - > 0) { - FNPREFIX(Update)(&ctx, buffer, (unsigned int)nr); - if (len > 0 && (len -= nr) == 0) - break; - } - - save_errno = errno; - close(fd); - errno = save_errno; - return (nr < 0 ? NULL : FNPREFIX(End)(&ctx, buf)); -} - -char * -FNPREFIX(File)(const char *filename, char *buf) -{ - return (FNPREFIX(FileChunk)(filename, buf, (off_t)0, (off_t)0)); -} - -char * -FNPREFIX(Data)(const unsigned char *data, size_t len, char *buf) -{ - HASH_CTX ctx; - - _DIAGASSERT(data != 0); - - FNPREFIX(Init)(&ctx); - FNPREFIX(Update)(&ctx, data, (unsigned int)len); - return (FNPREFIX(End)(&ctx, buf)); -} - -#endif /* HASH_ALGORITHM */ diff --git a/lib/libc/hash/md2/Makefile.inc b/lib/libc/hash/md2/Makefile.inc deleted file mode 100644 index 8e1adf531..000000000 --- a/lib/libc/hash/md2/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2005/09/24 20:51:14 elad Exp $ - -# hash functions -.PATH: ${.CURDIR}/hash/md2 - -SRCS+= md2.c md2hl.c - -MAN+= md2.3 - -MLINKS+=md2.3 MD2Init.3 md2.3 MD2Update.3 md2.3 MD2Final.3 -MLINKS+=md2.3 MD2End.3 md2.3 MD2File.3 md2.3 MD2Data.3 -MLINKS+=md2.3 MD2Transform.3 md2.3 MD2FileChunk.3 diff --git a/lib/libc/hash/md2/md2.3 b/lib/libc/hash/md2/md2.3 deleted file mode 100644 index e6f819cf9..000000000 --- a/lib/libc/hash/md2/md2.3 +++ /dev/null @@ -1,123 +0,0 @@ -.\" $NetBSD: md2.3,v 1.1 2005/09/24 20:51:14 elad Exp $ -.\" -.\" ---------------------------------------------------------------------------- -.\" "THE BEER-WARE LICENSE" (Revision 42): -.\" 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 -.\" ---------------------------------------------------------------------------- -.\" -.\" from FreeBSD Id: mdX.3,v 1.7 1996/10/22 16:28:56 phk Exp -.\" -.Dd September 24, 2005 -.Dt MD2 3 -.Os -.Sh NAME -.Nm MD2Init , -.Nm MD2Update , -.Nm MD2Final , -.Nm MD2End , -.Nm MD2File , -.Nm MD2Data -.Nd calculate the RSA Data Security, Inc., -.Dq MD2 -message digest -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In mdX.h -.Ft void -.Fn MD2Init "MD2_CTX *context" -.Ft void -.Fn MD2Update "MD2_CTX *context" "const unsigned char *data" "unsigned int len" -.Ft void -.Fn MD2Final "unsigned char digest[16]" "MD2_CTX *context" -.Ft "char *" -.Fn MD2End "MD2_CTX *context" "char *buf" -.Ft "char *" -.Fn MD2File "const char *filename" "char *buf" -.Ft "char *" -.Fn MD2Data "const unsigned char *data" "unsigned int len" "char *buf" -.Sh DESCRIPTION -The MD2 functions calculate a 128-bit cryptographic checksum (digest) -for any number of input bytes. -A cryptographic checksum is a one-way -hash-function, that is, you cannot find (except by exhaustive search) -the input corresponding to a particular output. -This net result is -a ``fingerprint'' of the input-data, which doesn't disclose the actual -input. -.Pp -The MD2 routines should not be used for any security-related purpose. -.Pp -The -.Fn MD2Init , -.Fn MD2Update , -and -.Fn MD2Final -functions are the core functions. -Allocate an MD2_CTX, initialize it with -.Fn MD2Init , -run over the data with -.Fn MD2Update , -and finally extract the result using -.Fn MD2Final . -.Pp -.Fn MD2End -is a wrapper for -.Fn MD2Final -which converts the return value to a 33-character -(including the terminating '\e0') -.Tn ASCII -string which represents the 128 bits in hexadecimal. -.Pp -.Fn MD2File -calculates the digest of a file, and uses -.Fn MD2End -to return the result. -If the file cannot be opened, a null pointer is returned. -.Fn MD2Data -calculates the digest of a chunk of data in memory, and uses -.Fn MD2End -to return the result. -.Pp -When using -.Fn MD2End , -.Fn MD2File , -or -.Fn MD2Data , -the -.Ar buf -argument can be a null pointer, in which case the returned string -is allocated with -.Xr malloc 3 -and subsequently must be explicitly deallocated using -.Xr free 3 -after use. -If the -.Ar buf -argument is non-null it must point to at least 33 characters of buffer space. -.Sh SEE ALSO -.Xr md2 3 , -.Rs -.%A B. Kaliski -.%T The MD2 Message-Digest Algorithm -.%O RFC 1319 -.Re -.Rs -.%A RSA Laboratories -.%T Frequently Asked Questions About today's Cryptography -.Re -.Sh HISTORY -These functions appeared in -.Nx 1.3 . -.Sh AUTHORS -The original MD2 routines were developed by -.Tn RSA -Data Security, Inc., and published in the above references. -This code is a public domain implementation by Andrew Brown. -.Sh BUGS -No method is known to exist which finds two files having the same hash value, -nor to find a file with a specific hash value. -There is on the other hand no guarantee that such a method doesn't exist. diff --git a/lib/libc/hash/md2/md2.c b/lib/libc/hash/md2/md2.c deleted file mode 100644 index b353a7918..000000000 --- a/lib/libc/hash/md2/md2.c +++ /dev/null @@ -1,184 +0,0 @@ -/* $NetBSD: md2.c,v 1.7 2012/06/25 22:32:44 abs Exp $ */ - -/* - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Brown. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: md2.c,v 1.7 2012/06/25 22:32:44 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include - -#include -#include -#include - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#if !HAVE_MD2_H - -/* cut-n-pasted from rfc1319 */ -static unsigned char S[256] = { - 41, 46, 67, 201, 162, 216, 124, 1, 61, 54, 84, 161, 236, 240, 6, - 19, 98, 167, 5, 243, 192, 199, 115, 140, 152, 147, 43, 217, 188, - 76, 130, 202, 30, 155, 87, 60, 253, 212, 224, 22, 103, 66, 111, 24, - 138, 23, 229, 18, 190, 78, 196, 214, 218, 158, 222, 73, 160, 251, - 245, 142, 187, 47, 238, 122, 169, 104, 121, 145, 21, 178, 7, 63, - 148, 194, 16, 137, 11, 34, 95, 33, 128, 127, 93, 154, 90, 144, 50, - 39, 53, 62, 204, 231, 191, 247, 151, 3, 255, 25, 48, 179, 72, 165, - 181, 209, 215, 94, 146, 42, 172, 86, 170, 198, 79, 184, 56, 210, - 150, 164, 125, 182, 118, 252, 107, 226, 156, 116, 4, 241, 69, 157, - 112, 89, 100, 113, 135, 32, 134, 91, 207, 101, 230, 45, 168, 2, 27, - 96, 37, 173, 174, 176, 185, 246, 28, 70, 97, 105, 52, 64, 126, 15, - 85, 71, 163, 35, 221, 81, 175, 58, 195, 92, 249, 206, 186, 197, - 234, 38, 44, 83, 13, 110, 133, 40, 132, 9, 211, 223, 205, 244, 65, - 129, 77, 82, 106, 220, 55, 200, 108, 193, 171, 250, 36, 225, 123, - 8, 12, 189, 177, 74, 120, 136, 149, 139, 227, 99, 232, 109, 233, - 203, 213, 254, 59, 0, 29, 57, 242, 239, 183, 14, 102, 88, 208, 228, - 166, 119, 114, 248, 235, 117, 75, 10, 49, 68, 80, 180, 143, 237, - 31, 26, 219, 153, 141, 51, 159, 17, 131, 20 -}; - -/* cut-n-pasted from rfc1319 */ -static const unsigned char *pad[] = { - (const unsigned char *)"", - (const unsigned char *)"\001", - (const unsigned char *)"\002\002", - (const unsigned char *)"\003\003\003", - (const unsigned char *)"\004\004\004\004", - (const unsigned char *)"\005\005\005\005\005", - (const unsigned char *)"\006\006\006\006\006\006", - (const unsigned char *)"\007\007\007\007\007\007\007", - (const unsigned char *)"\010\010\010\010\010\010\010\010", - (const unsigned char *)"\011\011\011\011\011\011\011\011\011", - (const unsigned char *)"\012\012\012\012\012\012\012\012\012\012", - (const unsigned char *)"\013\013\013\013\013\013\013\013\013\013\013", - (const unsigned char *) - "\014\014\014\014\014\014\014\014\014\014\014\014", - (const unsigned char *) - "\015\015\015\015\015\015\015\015\015\015\015\015\015", - (const unsigned char *) - "\016\016\016\016\016\016\016\016\016\016\016\016\016\016", - (const unsigned char *) - "\017\017\017\017\017\017\017\017\017\017\017\017\017\017\017", - (const unsigned char *) - "\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020\020" -}; - -/* - * XXX This should not be visible, but due to an accident, it is - * XXX so it must remain so. - */ -/*static*/ void MD2Transform __P((MD2_CTX *)); - -#ifdef __weak_alias -__weak_alias(MD2Init,_MD2Init) -__weak_alias(MD2Update,_MD2Update) -__weak_alias(MD2Final,_MD2Final) -__weak_alias(MD2Transform,_MD2Transform) -#endif - -void -MD2Init(MD2_CTX *context) -{ - _DIAGASSERT(context != 0); - - context->i = 16; - memset(&context->C[0], 0, sizeof(context->C)); - memset(&context->X[0], 0, sizeof(context->X)); -} - -void -MD2Update(MD2_CTX *context, const unsigned char *input, unsigned int inputLen) -{ - unsigned int idx, piece; - - _DIAGASSERT(context != 0); - _DIAGASSERT(input != 0); - - for (idx = 0; idx < inputLen; idx += piece) { - piece = 32 - context->i; - if ((inputLen - idx) < piece) - piece = inputLen - idx; - memcpy(&context->X[context->i], &input[idx], (size_t)piece); - if ((context->i += piece) == 32) - MD2Transform(context); /* resets i */ - } -} - -void -MD2Final(unsigned char digest[16], MD2_CTX *context) -{ - unsigned int padlen; - - _DIAGASSERT(digest != 0); - _DIAGASSERT(context != 0); - - /* padlen should be 1..16 */ - padlen = 32 - context->i; - - /* add padding */ - MD2Update(context, pad[padlen], padlen); - - /* add checksum */ - MD2Update(context, &context->C[0], (unsigned int) sizeof(context->C)); - - /* copy out final digest */ - memcpy(digest, &context->X[0], (size_t)16); - - /* reset the context */ - MD2Init(context); -} - -/*static*/ void -MD2Transform(MD2_CTX *context) -{ - uint32_t l, j, k, t; - - /* set block "3" and update "checksum" */ - for (l = context->C[15], j = 0; j < 16; j++) { - context->X[32 + j] = context->X[j] ^ context->X[16 + j]; - l = context->C[j] ^= S[context->X[16 + j] ^ l]; - } - - /* mangle input block */ - for (t = j = 0; j < 18; t = (t + j) % 256, j++) - for (k = 0; k < 48; k++) - t = context->X[k] = (context->X[k] ^ S[t]); - - /* reset input pointer */ - context->i = 16; -} - -#endif /* !HAVE_MD2_H */ diff --git a/lib/libc/hash/md2/md2hl.c b/lib/libc/hash/md2/md2hl.c deleted file mode 100644 index 64eb2bef9..000000000 --- a/lib/libc/hash/md2/md2hl.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: md2hl.c,v 1.4 2008/04/13 02:04:31 dholland Exp $ */ - -/* - * Derived from code written by Jason R. Thorpe , - * April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: md2hl.c,v 1.4 2008/04/13 02:04:31 dholland Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define HASH_ALGORITHM MD2 -#define HASH_INCLUDE - -#include "../hashhl.c" diff --git a/lib/libc/hash/murmurhash/Makefile.inc b/lib/libc/hash/murmurhash/Makefile.inc deleted file mode 100644 index e109fc6e5..000000000 --- a/lib/libc/hash/murmurhash/Makefile.inc +++ /dev/null @@ -1,5 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2012/07/08 11:43:47 rmind Exp $ - -.PATH: ${.CURDIR}/hash/murmurhash - -SRCS+= murmurhash.c diff --git a/lib/libc/hash/rmd160/Makefile.inc b/lib/libc/hash/rmd160/Makefile.inc deleted file mode 100644 index 0caf265e0..000000000 --- a/lib/libc/hash/rmd160/Makefile.inc +++ /dev/null @@ -1,13 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2005/09/24 19:04:52 elad Exp $ - -# hash functions -.PATH: ${.CURDIR}/hash/rmd160 - -SRCS+= rmd160.c rmd160hl.c - -MAN+= rmd160.3 - -MLINKS+=rmd160.3 RMD160Init.3 rmd160.3 RMD160Update.3 -MLINKS+=rmd160.3 RMD160Final.3 rmd160.3 RMD160Transform.3 -MLINKS+=rmd160.3 RMD160End.3 rmd160.3 RMD160File.3 -MLINKS+=rmd160.3 RMD160Data.3 diff --git a/lib/libc/hash/rmd160/rmd160.3 b/lib/libc/hash/rmd160/rmd160.3 deleted file mode 100644 index f9d64e09e..000000000 --- a/lib/libc/hash/rmd160/rmd160.3 +++ /dev/null @@ -1,225 +0,0 @@ -.\" $NetBSD: rmd160.3,v 1.3 2010/04/05 21:26:30 joerg Exp $ -.\" $OpenBSD: rmd160.3,v 1.12 2000/04/18 03:01:29 aaron Exp $ -.\" -.\" Copyright (c) 1997 Todd C. Miller -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. The name of the author may not be used to endorse or promote products -.\" derived from this software without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, -.\" INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY -.\" AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL -.\" THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, -.\" EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, -.\" PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; -.\" OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, -.\" WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR -.\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF -.\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -.\" -.\" See http://www.esat.kuleuven.ac.be/~bosselae/ripemd160.html -.\" for detailed information about RIPEMD-160. -.\" -.Dd July 16, 1997 -.Dt RMD160 3 -.Os -.Sh NAME -.Nm RMD160Init , -.Nm RMD160Update , -.Nm RMD160Final , -.Nm RMD160Transform , -.Nm RMD160End , -.Nm RMD160File , -.Nm RMD160Data -.Nd calculate the ``RIPEMD-160'' message digest -.Sh SYNOPSIS -.In sys/types.h -.In rmd160.h -.Ft void -.Fn RMD160Init "RMD160_CTX *context" -.Ft void -.Fn RMD160Update "RMD160_CTX *context" "const u_char *data" "u_int nbytes" -.Ft void -.Fn RMD160Final "u_char digest[20]" "RMD160_CTX *context" -.Ft void -.Fn RMD160Transform "uint32_t state[5]" "const uint32_t block[16]" -.Ft "char *" -.Fn RMD160End "RMD160_CTX *context" "char *buf" -.Ft "char *" -.Fn RMD160File "char *filename" "char *buf" -.Ft "char *" -.Fn RMD160Data "u_char *data" "size_t len" "char *buf" -.Sh DESCRIPTION -The RMD160 functions implement the 160-bit RIPE message digest hash algorithm -(RMD-160). -RMD-160 is used to generate a condensed representation -of a message called a message digest. -The algorithm takes a -message less than 2^64 bits as input and produces a 160-bit digest -suitable for use as a digital signature. -.Pp -The RMD160 functions are considered to be more secure than the -.Xr md4 3 -and -.Xr md5 3 -functions and at least as secure as the -.Xr sha1 3 -function. -All share a similar interface. -.Pp -The -.Fn RMD160Init -function initializes a RMD160_CTX -.Ar context -for use with -.Fn RMD160Update , -and -.Fn RMD160Final . -The -.Fn RMD160Update -function adds -.Ar data -of length -.Ar nbytes -to the RMD160_CTX specified by -.Ar context . -.Fn RMD160Final -is called when all data has been added via -.Fn RMD160Update -and stores a message digest in the -.Ar digest -parameter. -When a null pointer is passed to -.Fn RMD160Final -as first argument only the final padding will be applied and the -current context can still be used with -.Fn RMD160Update . -.Pp -The -.Fn RMD160Transform -function is used by -.Fn RMD160Update -to hash 512-bit blocks and forms the core of the algorithm. -Most programs should use the interface provided by -.Fn RMD160Init , -.Fn RMD160Update -and -.Fn RMD160Final -instead of calling -.Fn RMD160Transform -directly. -.Pp -The -.Fn RMD160End -function is a front end for -.Fn RMD160Final -which converts the digest into an -.Tn ASCII -representation of the 160 bit digest in hexadecimal. -.Pp -The -.Fn RMD160File -function calculates the digest for a file and returns the result via -.Fn RMD160End . -If -.Fn RMD160File -is unable to open the file a NULL pointer is returned. -.Pp -The -.Fn RMD160Data -function -calculates the digest of an arbitrary string and returns the result via -.Fn RMD160End . -.Pp -For each of the -.Fn RMD160End , -.Fn RMD160File , -and -.Fn RMD160Data -functions the -.Ar buf -parameter should either be a string of at least 41 characters in -size or a NULL pointer. -In the latter case, space will be dynamically allocated via -.Xr malloc 3 -and should be freed using -.Xr free 3 -when it is no longer needed. -.Sh EXAMPLES -The follow code fragment will calculate the digest for -the string "abc" which is ``0x8eb208f7e05d987a9b044a8e98c6b087f15a0bfc''. -.Bd -literal -offset indent -RMD160_CTX rmd; -u_char results[20]; -char *buf; -int n; - -buf = "abc"; -n = strlen(buf); -RMD160Init(\*[Am]rmd); -RMD160Update(\*[Am]rmd, (u_char *)buf, n); -RMD160Final(results, \*[Am]rmd); - -/* Print the digest as one long hex value */ -printf("0x"); -for (n = 0; n \*[Lt] 20; n++) - printf("%02x", results[n]); -putchar('\en'); -.Ed -.Pp -Alternately, the helper functions could be used in the following way: -.Bd -literal -offset indent -RMD160_CTX rmd; -u_char output[41]; -char *buf = "abc"; - -printf("0x%s\en", RMD160Data(buf, strlen(buf), output)); -.Ed -.Sh SEE ALSO -.Xr rmd160 1 , -.Xr md4 3 , -.Xr md5 3 , -.Xr sha1 3 -.Pp -.Rs -.%A H. Dobbertin, A. Bosselaers, B. Preneel -.%T RIPEMD-160, a strengthened version of RIPEMD -.Re -.Rs -.%T Information technology - Security techniques - Hash-functions - Part 3: Dedicated hash-functions -.%O ISO/IEC 10118-3 -.Re -.Rs -.%A H. Dobbertin, A. Bosselaers, B. Preneel -.%T The RIPEMD-160 cryptographic hash function -.%J Dr. Dobb's Journal -.%V Vol. 22, No. 1 -.%D January 1997 -.%P pp. 24-28 -.Re -.Sh HISTORY -The RMD-160 functions appeared in -.Ox 2.1 . -.Sh AUTHORS -This implementation of RMD-160 was written by Antoon Bosselaers. -.Pp -The -.Fn RMD160End , -.Fn RMD160File , -and -.Fn RMD160Data -helper functions are derived from code written by Poul-Henning Kamp. -.Sh BUGS -If a message digest is to be copied to a multi-byte type (ie: -an array of five 32-bit integers) it will be necessary to -perform byte swapping on little endian machines such as the i386, alpha, -and VAX. diff --git a/lib/libc/hash/rmd160/rmd160hl.c b/lib/libc/hash/rmd160/rmd160hl.c deleted file mode 100644 index 85cc8373c..000000000 --- a/lib/libc/hash/rmd160/rmd160hl.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: rmd160hl.c,v 1.6 2008/04/13 02:04:32 dholland Exp $ */ - -/* - * Derived from code written by Jason R. Thorpe , - * April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: rmd160hl.c,v 1.6 2008/04/13 02:04:32 dholland Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define HASH_ALGORITHM RMD160 -#define HASH_INCLUDE - -#include "../hashhl.c" diff --git a/lib/libc/hash/sha1/Makefile.inc b/lib/libc/hash/sha1/Makefile.inc deleted file mode 100644 index 99c35cf29..000000000 --- a/lib/libc/hash/sha1/Makefile.inc +++ /dev/null @@ -1,12 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2006/10/27 18:29:21 drochner Exp $ - -# hash functions -.PATH: ${.CURDIR}/hash/sha1 - -SRCS+= sha1.c sha1hl.c - -MAN+= sha1.3 - -MLINKS+=sha1.3 SHA1Init.3 sha1.3 SHA1Update.3 sha1.3 SHA1Final.3 -MLINKS+=sha1.3 SHA1End.3 sha2.3 SHA1File.3 sha1.3 SHA1Data.3 -MLINKS+=sha1.3 SHA1Transform.3 sha1.3 SHA1FileChunk.3 diff --git a/lib/libc/hash/sha1/sha1.3 b/lib/libc/hash/sha1/sha1.3 deleted file mode 100644 index 762fd03c5..000000000 --- a/lib/libc/hash/sha1/sha1.3 +++ /dev/null @@ -1,203 +0,0 @@ -.\" $NetBSD: sha1.3,v 1.6 2010/04/05 21:27:01 joerg Exp $ -.\" $OpenBSD: sha1.3,v 1.9 1998/03/07 22:18:12 millert Exp $ -.\" -.\" Copyright (c) 1997, 2004 Todd C. Miller -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" See http://csrc.nist.gov/fips/fip180-1.txt for the detailed standard -.\" -.Dd July 10, 1997 -.Dt SHA1 3 -.Os -.Sh NAME -.Nm SHA1Init , -.Nm SHA1Update , -.Nm SHA1Final , -.Nm SHA1Transform , -.Nm SHA1End , -.Nm SHA1File , -.Nm SHA1Data -.Nd calculate the NIST Secure Hash Algorithm -.Sh SYNOPSIS -.In sys/types.h -.In sha1.h -.Ft void -.Fn SHA1Init "SHA1_CTX *context" -.Ft void -.Fn SHA1Update "SHA1_CTX *context" "const uint8_t *data" "u_int len" -.Ft void -.Fn SHA1Final "uint8_t digest[20]" "SHA1_CTX *context" -.Ft void -.Fn SHA1Transform "uint32_t state[5]" "uint8_t buffer[64]" -.Ft "char *" -.Fn SHA1End "SHA1_CTX *context" "char *buf" -.Ft "char *" -.Fn SHA1File "char *filename" "char *buf" -.Ft "char *" -.Fn SHA1Data "uint8_t *data" "size_t len" "char *buf" -.Sh DESCRIPTION -The SHA1 functions implement the NIST Secure Hash Algorithm (SHA-1), -FIPS PUB 180-1. -SHA-1 is used to generate a condensed representation -of a message called a message digest. -The algorithm takes a -message less than 2^64 bits as input and produces a 160-bit digest -suitable for use as a digital signature. -.Pp -The SHA1 functions are considered to be more secure than the -.Xr md4 3 -and -.Xr md5 3 -functions with which they share a similar interface. -.Pp -The -.Fn SHA1Init -function initializes a SHA1_CTX -.Ar context -for use with -.Fn SHA1Update , -and -.Fn SHA1Final . -The -.Fn SHA1Update -function adds -.Ar data -of length -.Ar len -to the SHA1_CTX specified by -.Ar context . -.Fn SHA1Final -is called when all data has been added via -.Fn SHA1Update -and stores a message digest in the -.Ar digest -parameter. -When a null pointer is passed to -.Fn SHA1Final -as first argument only the final padding will be applied and the -current context can still be used with -.Fn SHA1Update . -.Pp -The -.Fn SHA1Transform -function is used by -.Fn SHA1Update -to hash 512-bit blocks and forms the core of the algorithm. -Most programs should use the interface provided by -.Fn SHA1Init , -.Fn SHA1Update -and -.Fn SHA1Final -instead of calling -.Fn SHA1Transform -directly. -.Pp -The -.Fn SHA1End -function is a front end for -.Fn SHA1Final -which converts the digest into an -.Tn ASCII -representation of the 160 bit digest in hexadecimal. -.Pp -The -.Fn SHA1File -function calculates the digest for a file and returns the result via -.Fn SHA1End . -If -.Fn SHA1File -is unable to open the file a NULL pointer is returned. -.Pp -The -.Fn SHA1Data -function -calculates the digest of an arbitrary string and returns the result via -.Fn SHA1End . -.Pp -For each of the -.Fn SHA1End , -.Fn SHA1File , -and -.Fn SHA1Data -functions the -.Ar buf -parameter should either be a string of at least 41 characters in -size or a NULL pointer. -In the latter case, space will be dynamically -allocated via -.Xr malloc 3 -and should be freed using -.Xr free 3 -when it is no longer needed. -.Sh EXAMPLES -The follow code fragment will calculate the digest for -the string "abc" which is ``0xa9993e36476816aba3e25717850c26c9cd0d89d''. -.Bd -literal -offset indent -SHA1_CTX sha; -uint8_t results[20]; -char *buf; -int n; - -buf = "abc"; -n = strlen(buf); -SHA1Init(\*[Am]sha); -SHA1Update(\*[Am]sha, (uint8_t *)buf, n); -SHA1Final(results, \*[Am]sha); - -/* Print the digest as one long hex value */ -printf("0x"); -for (n = 0; n \*[Lt] 20; n++) - printf("%02x", results[n]); -putchar('\en'); -.Ed -.Pp -Alternately, the helper functions could be used in the following way: -.Bd -literal -offset indent -SHA1_CTX sha; -uint8_t output[41]; -char *buf = "abc"; - -printf("0x%s", SHA1Data(buf, strlen(buf), output)); -.Ed -.Sh SEE ALSO -.\" .Xr sha1 1 , -.Xr md5 1 , -.Xr md4 3 , -.Xr md5 3 -.Pp -.Rs -.%A J. Burrows -.%T The Secure Hash Standard -.%O FIPS PUB 180-1 -.Re -.Sh HISTORY -The SHA-1 functions appeared in -.Nx 1.4 . -.Sh AUTHORS -This implementation of SHA-1 was written by Steve Reid. -.Pp -The -.Fn SHA1End , -.Fn SHA1File , -and -.Fn SHA1Data -helper functions are derived from code written by Poul-Henning Kamp. -.Sh BUGS -This implementation of SHA-1 has not been validated by NIST -and as such is not in official compliance with the standard. -.Pp -If a message digest is to be copied to a multi-byte type (ie: -an array of five 32-bit integers) it will be necessary to -perform byte swapping on little endian machines such as the i386, alpha, -and VAX. diff --git a/lib/libc/hash/sha1/sha1hl.c b/lib/libc/hash/sha1/sha1hl.c deleted file mode 100644 index a73f4df82..000000000 --- a/lib/libc/hash/sha1/sha1hl.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: sha1hl.c,v 1.4 2008/04/13 02:04:32 dholland Exp $ */ - -/* - * Derived from code written by Jason R. Thorpe , - * April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sha1hl.c,v 1.4 2008/04/13 02:04:32 dholland Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define HASH_ALGORITHM SHA1 -#define HASH_INCLUDE - -#include "../hashhl.c" diff --git a/lib/libc/hash/sha2/Makefile.inc b/lib/libc/hash/sha2/Makefile.inc deleted file mode 100644 index 4d13c2fdc..000000000 --- a/lib/libc/hash/sha2/Makefile.inc +++ /dev/null @@ -1,21 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.4 2009/05/26 08:04:11 joerg Exp $ - -# hash functions -.PATH: ${.CURDIR}/hash/sha2 - -SRCS+= sha2.c sha224hl.c sha256hl.c sha384hl.c sha512hl.c - -MAN+= sha2.3 - -MLINKS+=sha2.3 SHA224_Init.3 sha2.3 SHA224_Update.3 sha2.3 SHA224_Final.3 -MLINKS+=sha2.3 SHA224_End.3 sha2.3 SHA224_File.3 sha2.3 SHA224_Data.3 -MLINKS+=sha2.3 SHA224_Transform.3 sha2.3 SHA224_FileChunk.3 -MLINKS+=sha2.3 SHA256_Init.3 sha2.3 SHA256_Update.3 sha2.3 SHA256_Final.3 -MLINKS+=sha2.3 SHA256_End.3 sha2.3 SHA256_File.3 sha2.3 SHA256_Data.3 -MLINKS+=sha2.3 SHA256_Transform.3 sha2.3 SHA256_FileChunk.3 -MLINKS+=sha2.3 SHA384_Init.3 sha2.3 SHA384_Update.3 sha2.3 SHA384_Final.3 -MLINKS+=sha2.3 SHA384_End.3 sha2.3 SHA384_File.3 sha2.3 SHA384_Data.3 -MLINKS+=sha2.3 SHA384_Transform.3 sha2.3 SHA384_FileChunk.3 -MLINKS+=sha2.3 SHA512_Init.3 sha2.3 SHA512_Update.3 sha2.3 SHA512_Final.3 -MLINKS+=sha2.3 SHA512_End.3 sha2.3 SHA512_File.3 sha2.3 SHA512_Data.3 -MLINKS+=sha2.3 SHA512_Transform.3 sha2.3 SHA512_FileChunk.3 diff --git a/lib/libc/hash/sha2/sha2.3 b/lib/libc/hash/sha2/sha2.3 deleted file mode 100644 index 8192cf57e..000000000 --- a/lib/libc/hash/sha2/sha2.3 +++ /dev/null @@ -1,304 +0,0 @@ -.\" $NetBSD: sha2.3,v 1.5 2009/05/26 08:04:12 joerg Exp $ -.\" $OpenBSD: sha2.3,v 1.11 2004/06/22 01:57:29 jfb Exp $ -.\" -.\" Copyright (c) 2003, 2004 Todd C. Miller -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Sponsored in part by the Defense Advanced Research Projects -.\" Agency (DARPA) and Air Force Research Laboratory, Air Force -.\" Materiel Command, USAF, under agreement number F39502-99-1-0512. -.\" -.\" See http://www.nist.gov/sha/ for the detailed standard -.\" -.Dd May 20, 2009 -.Dt SHA2 3 -.Os -.Sh NAME -.Nm SHA256_Init , -.Nm SHA256_Update , -.Nm SHA256_Pad , -.Nm SHA256_Final , -.Nm SHA256_Transform , -.Nm SHA256_End , -.Nm SHA256_File , -.Nm SHA256_FileChunk , -.Nm SHA256_Data -.Nd calculate the NIST Secure Hash Standard (version 2) -.Sh SYNOPSIS -.In sys/types.h -.In sha2.h -.Ft void -.Fn SHA224_Init "SHA224_CTX *context" -.Ft void -.Fn SHA224_Update "SHA224_CTX *context" "const uint8_t *data" "size_t len" -.Ft void -.Fn SHA224_Pad "SHA224_CTX *context" -.Ft void -.Fn SHA224_Final "uint8_t digest[SHA224_DIGEST_LENGTH]" "SHA224_CTX *context" -.Ft void -.Fn SHA224_Transform "uint32_t state[8]" "const uint8_t buffer[SHA224_BLOCK_LENGTH]" -.Ft "char *" -.Fn SHA224_End "SHA224_CTX *context" "char *buf" -.Ft "char *" -.Fn SHA224_File "const char *filename" "char *buf" -.Ft "char *" -.Fn SHA224_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" -.Ft "char *" -.Fn SHA224_Data "uint8_t *data" "size_t len" "char *buf" -.Ft void -.Fn SHA256_Init "SHA256_CTX *context" -.Ft void -.Fn SHA256_Update "SHA256_CTX *context" "const uint8_t *data" "size_t len" -.Ft void -.Fn SHA256_Pad "SHA256_CTX *context" -.Ft void -.Fn SHA256_Final "uint8_t digest[SHA256_DIGEST_LENGTH]" "SHA256_CTX *context" -.Ft void -.Fn SHA256_Transform "uint32_t state[8]" "const uint8_t buffer[SHA256_BLOCK_LENGTH]" -.Ft "char *" -.Fn SHA256_End "SHA256_CTX *context" "char *buf" -.Ft "char *" -.Fn SHA256_File "const char *filename" "char *buf" -.Ft "char *" -.Fn SHA256_FileChunk "const char *filename" "char *buf" "off_t offset" "off_t length" -.Ft "char *" -.Fn SHA256_Data "uint8_t *data" "size_t len" "char *buf" -.Ft void -.Fn SHA384_Init "SHA384_CTX *context" -.Ft void -.Fn SHA384_Update "SHA384_CTX *context" "const uint8_t *data" "size_t len" -.Ft void -.Fn SHA384_Pad "SHA384_CTX *context" -.Ft void -.Fn SHA384_Final "uint8_t digest[SHA384_DIGEST_LENGTH]" "SHA384_CTX *context" -.Ft void -.Fn SHA384_Transform "uint64_t state[8]" "const uint8_t buffer[SHA384_BLOCK_LENGTH]" -.Ft "char *" -.Fn SHA384_End "SHA384_CTX *context" "char *buf" -.Ft "char *" -.Fn SHA384_File "char *filename" "char *buf" -.Ft "char *" -.Fn SHA384_FileChunk "char *filename" "char *buf" "off_t offset" "off_t length" -.Ft "char *" -.Fn SHA384_Data "uint8_t *data" "size_t len" "char *buf" -.Ft void -.Fn SHA512_Init "SHA512_CTX *context" -.Ft void -.Fn SHA512_Update "SHA512_CTX *context" "const uint8_t *data" "size_t len" -.Ft void -.Fn SHA512_Pad "SHA512_CTX *context" -.Ft void -.Fn SHA512_Final "uint8_t digest[SHA512_DIGEST_LENGTH]" "SHA512_CTX *context" -.Ft void -.Fn SHA512_Transform "uint64_t state[8]" "const uint8_t buffer[SHA512_BLOCK_LENGTH]" -.Ft "char *" -.Fn SHA512_End "SHA512_CTX *context" "char *buf" -.Ft "char *" -.Fn SHA512_File "char *filename" "char *buf" -.Ft "char *" -.Fn SHA512_FileChunk "char *filename" "char *buf" "off_t offset" "off_t length" -.Ft "char *" -.Fn SHA512_Data "uint8_t *data" "size_t len" "char *buf" -.Sh DESCRIPTION -The SHA2 functions implement the NIST Secure Hash Standard, -FIPS PUB 180-2. -The SHA2 functions are used to generate a condensed representation of a -message called a message digest, suitable for use as a digital signature. -There are four families of functions, with names corresponding to -the number of bits in the resulting message digest. -The SHA-224 and SHA-256 functions are limited to processing a message of less -than 2^64 bits as input. -The SHA-384 and SHA-512 functions can process a message of at most 2^128 - 1 -bits as input. -.Pp -The SHA2 functions are considered to be more secure than the -.Xr sha1 3 -functions with which they share a similar interface. -The 224, 256, 384, and 512-bit versions of SHA2 share the same interface. -For brevity, only the 256-bit variants are described below. -.Pp -The -.Fn SHA256_Init -function initializes a SHA256_CTX -.Ar context -for use with -.Fn SHA256_Update , -and -.Fn SHA256_Final . -The -.Fn SHA256_Update -function adds -.Ar data -of length -.Ar len -to the SHA256_CTX specified by -.Ar context . -.Fn SHA256_Final -is called when all data has been added via -.Fn SHA256_Update -and stores a message digest in the -.Ar digest -parameter. -.Pp -The -.Fn SHA256_Pad -function can be used to apply padding to the message digest as in -.Fn SHA256_Final , -but the current context can still be used with -.Fn SHA256_Update . -.Pp -The -.Fn SHA256_Transform -function is used by -.Fn SHA256_Update -to hash 512-bit blocks and forms the core of the algorithm. -Most programs should use the interface provided by -.Fn SHA256_Init , -.Fn SHA256_Update , -and -.Fn SHA256_Final -instead of calling -.Fn SHA256_Transform -directly. -.Pp -The -.Fn SHA256_End -function is a front end for -.Fn SHA256_Final -which converts the digest into an -.Tn ASCII -representation of the digest in hexadecimal. -.Pp -The -.Fn SHA256_File -function calculates the digest for a file and returns the result via -.Fn SHA256_End . -If -.Fn SHA256_File -is unable to open the file, a -.Dv NULL -pointer is returned. -.Pp -.Fn SHA256_FileChunk -behaves like -.Fn SHA256_File -but calculates the digest only for that portion of the file starting at -.Fa offset -and continuing for -.Fa length -bytes or until end of file is reached, whichever comes first. -A zero -.Fa length -can be specified to read until end of file. -A negative -.Fa length -or -.Fa offset -will be ignored. -.Pp -The -.Fn SHA256_Data -function -calculates the digest of an arbitrary string and returns the result via -.Fn SHA256_End . -.Pp -For each of the -.Fn SHA256_End , -.Fn SHA256_File , -.Fn SHA256_FileChunk , -and -.Fn SHA256_Data -functions the -.Ar buf -parameter should either be a string large enough to hold the resulting digest -(e.g., -.Ev SHA224_DIGEST_STRING_LENGTH , -.Ev SHA256_DIGEST_STRING_LENGTH , -.Ev SHA384_DIGEST_STRING_LENGTH , -or -.Ev SHA512_DIGEST_STRING_LENGTH , -depending on the function being used) -or a -.Dv NULL -pointer. -In the latter case, space will be dynamically allocated via -.Xr malloc 3 -and should be freed using -.Xr free 3 -when it is no longer needed. -.Sh EXAMPLES -The following code fragment will calculate the SHA-256 digest for the string -.Qq abc , -which is -.Dq 0xba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad . -.Bd -literal -offset indent -SHA256_CTX ctx; -uint8_t results[SHA256_DIGEST_LENGTH]; -char *buf; -int n; - -buf = "abc"; -n = strlen(buf); -SHA256_Init(\*[Am]ctx); -SHA256_Update(\*[Am]ctx, (uint8_t *)buf, n); -SHA256_Final(results, \*[Am]ctx); - -/* Print the digest as one long hex value */ -printf("0x"); -for (n = 0; n \*[Lt] SHA256_DIGEST_LENGTH; n++) - printf("%02x", results[n]); -putchar('\en'); -.Ed -.Pp -Alternately, the helper functions could be used in the following way: -.Bd -literal -offset indent -SHA256_CTX ctx; -uint8_t output[SHA256_DIGEST_STRING_LENGTH]; -char *buf = "abc"; - -printf("0x%s\en", SHA256_Data(buf, strlen(buf), output)); -.Ed -.Sh SEE ALSO -.Xr cksum 1 , -.Xr md4 3 , -.Xr md5 3 , -.Xr rmd160 3 , -.Xr sha1 3 -.Rs -.%T Secure Hash Standard -.%O FIPS PUB 180-2 -.Re -.Sh HISTORY -The SHA2 functions appeared in -.Ox 3.4 -and -.Nx 3.0 . -.Sh AUTHORS -This implementation of the SHA functions was written by Aaron D. Gifford. -.Pp -The -.Fn SHA256_End , -.Fn SHA256_File , -.Fn SHA256_FileChunk , -and -.Fn SHA256_Data -helper functions are derived from code written by Poul-Henning Kamp. -.Sh CAVEATS -This implementation of the Secure Hash Standard has not been validated by -NIST and as such is not in official compliance with the standard. -.Pp -If a message digest is to be copied to a multi-byte type (i.e.: -an array of five 32-bit integers) it will be necessary to -perform byte swapping on little endian machines such as the i386, alpha, -and vax. diff --git a/lib/libc/hash/sha2/sha224hl.c b/lib/libc/hash/sha2/sha224hl.c deleted file mode 100644 index 8f5379c72..000000000 --- a/lib/libc/hash/sha2/sha224hl.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: sha224hl.c,v 1.2 2014/12/11 21:54:13 riastradh Exp $ */ - -/* - * Derived from code written by Jason R. Thorpe , - * May 20, 2009. - * Public domain. - */ - -#include -__RCSID("$NetBSD: sha224hl.c,v 1.2 2014/12/11 21:54:13 riastradh Exp $"); - -#define HASH_ALGORITHM SHA224 -#define HASH_FNPREFIX SHA224_ -#define HASH_INCLUDE - -#include "../hashhl.c" diff --git a/lib/libc/hash/sha2/sha256hl.c b/lib/libc/hash/sha2/sha256hl.c deleted file mode 100644 index 960f4daad..000000000 --- a/lib/libc/hash/sha2/sha256hl.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: sha256hl.c,v 1.8 2008/04/13 02:04:32 dholland Exp $ */ - -/* - * Derived from code written by Jason R. Thorpe , - * April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sha256hl.c,v 1.8 2008/04/13 02:04:32 dholland Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define HASH_ALGORITHM SHA256 -#define HASH_FNPREFIX SHA256_ -#define HASH_INCLUDE - -#include "../hashhl.c" diff --git a/lib/libc/hash/sha2/sha384hl.c b/lib/libc/hash/sha2/sha384hl.c deleted file mode 100644 index c503d8b7a..000000000 --- a/lib/libc/hash/sha2/sha384hl.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: sha384hl.c,v 1.8 2008/04/13 02:04:32 dholland Exp $ */ - -/* - * Derived from code written by Jason R. Thorpe , - * April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sha384hl.c,v 1.8 2008/04/13 02:04:32 dholland Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define HASH_ALGORITHM SHA384 -#define HASH_FNPREFIX SHA384_ -#define HASH_INCLUDE - -#include "../hashhl.c" diff --git a/lib/libc/hash/sha2/sha512hl.c b/lib/libc/hash/sha2/sha512hl.c deleted file mode 100644 index bc46b16fa..000000000 --- a/lib/libc/hash/sha2/sha512hl.c +++ /dev/null @@ -1,18 +0,0 @@ -/* $NetBSD: sha512hl.c,v 1.8 2008/04/13 02:04:32 dholland Exp $ */ - -/* - * Derived from code written by Jason R. Thorpe , - * April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sha512hl.c,v 1.8 2008/04/13 02:04:32 dholland Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define HASH_ALGORITHM SHA512 -#define HASH_FNPREFIX SHA512_ -#define HASH_INCLUDE - -#include "../hashhl.c" diff --git a/lib/libc/iconv/Makefile.inc b/lib/libc/iconv/Makefile.inc deleted file mode 100644 index c53d3bedc..000000000 --- a/lib/libc/iconv/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2012/01/20 16:31:29 joerg Exp $ - -.PATH: ${ARCHDIR}/iconv ${.CURDIR}/iconv - -SRCS+= iconv.c -MAN+= iconv.3 -MLINKS+=iconv.3 iconv_open.3 iconv.3 iconv_close.3 - -CPPFLAGS.iconv.c+= -I${LIBCDIR}/citrus diff --git a/lib/libc/iconv/iconv.3 b/lib/libc/iconv/iconv.3 deleted file mode 100644 index a65feab0e..000000000 --- a/lib/libc/iconv/iconv.3 +++ /dev/null @@ -1,277 +0,0 @@ -.\" $NetBSD: iconv.3,v 1.21 2013/05/12 10:44:23 wiz Exp $ -.\" -.\" Copyright (c)2003 Citrus Project, -.\" 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. -.\" -.Dd March 11, 2013 -.Dt ICONV 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm iconv_open , -.Nm iconv_close , -.Nm iconv -.Nd codeset conversion functions -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In iconv.h -.Ft iconv_t -.Fn iconv_open "const char *dstname" "const char *srcname" -.Ft int -.Fn iconv_close "iconv_t cd" -.Ft size_t -.Fn iconv "iconv_t cd" "const char ** restrict src" "size_t * restrict srcleft" "char ** restrict dst" "size_t * restrict dstleft" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn iconv_open -function opens a converter from the codeset -.Fa srcname -to the codeset -.Fa dstname -and returns its descriptor. -.Pp -The -.Fn iconv_close -function closes the specified converter -.Fa cd . -.Pp -The -.Fn iconv -function converts the string in the buffer -.Fa *src -of length -.Fa *srcleft -bytes and stores the converted string in the buffer -.Fa *dst -of size -.Fa *dstleft -bytes. -After calling -.Fn iconv , -the values pointed to by -.Fa src , -.Fa srcleft , -.Fa dst , -and -.Fa dstleft -are updated as follows: -.Bl -tag -width 01234567 -offset indent -.It Fa *src -Pointer to the byte just after the last character fetched. -.It Fa *srcleft -Number of remaining bytes in the source buffer. -.It Fa *dst -Pointer to the byte just after the last character stored. -.It Fa *dstleft -Number of remainder bytes in the destination buffer. -.El -.Pp -If the string pointed to by -.Fa *src -contains a byte sequence which is not a valid character in the source -codeset, the conversion stops just after the last successful conversion. -If the output buffer is too small to store the converted -character, the conversion also stops in the same way. -In these cases, the values pointed to by -.Fa src , -.Fa srcleft , -.Fa dst , -and -.Fa dstleft -are updated to the state just after the last successful conversion. -.Pp -If the string pointed to by -.Fa *src -contains a character which is valid under the source codeset but -can not be converted to the destination codeset, -the character is replaced by an -.Dq invalid character -which depends on the destination codeset, e.g., -.Sq \&? , -and the conversion is continued. -.Fn iconv -returns the number of such -.Dq invalid conversions . -.Pp -If -.Fa src -or -.Fa *src -is -.Dv NULL -and the source and/or destination codesets are stateful, -.Fn iconv -places these into their initial state. -.Bl -enum -offset indent -.It -If both -.Fa dst -and -.Fa *dst -are -.No non- Ns Dv NULL , -.Fn iconv -stores the shift sequence for the destination switching to the initial state -in the buffer pointed to by -.Fa *dst . -The buffer size is specified by the value pointed to by -.Fa dstleft -as above. -.Fn iconv -will fail if the buffer is too small to store the shift sequence. -.It -On the other hand, -.Fa dst -or -.Fa *dst -may be -.Dv NULL . -In this case, the shift sequence for the destination switching -to the initial state is discarded. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -Upon successful completion of -.Fn iconv_open , -it returns a conversion descriptor. -Otherwise, -.Fn iconv_open -returns (iconv_t)\-1 and sets -.Va errno -to indicate the error. -.Pp -Upon successful completion of -.Fn iconv_close , -it returns 0. -Otherwise, -.Fn iconv_close -returns \-1 and sets errno to indicate the error. -.Pp -Upon successful completion of -.Fn iconv , -it returns the number of -.Dq invalid -conversions. -Otherwise, -.Fn iconv -returns (size_t)\-1 and sets errno to indicate the error. -.\" ---------------------------------------------------------------------- -.Sh ERRORS -The -.Fn iconv_open -function may cause an error in the following cases: -.Bl -tag -width Er -.It Bq Er EINVAL -There is no converter specified by -.Fa srcname -and -.Fa dstname . -.It Bq Er ENOMEM -Memory is exhausted. -.El -.Pp -The -.Fn iconv_close -function may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EBADF -The conversion descriptor specified by -.Fa cd -is invalid. -.El -.Pp -The -.Fn iconv -function may cause an error in the following cases: -.Bl -tag -width Er -.It Bq Er E2BIG -The output buffer pointed to by -.Fa *dst -is too small to store the result string. -.It Bq Er EBADF -The conversion descriptor specified by -.Fa cd -is invalid. -.It Bq Er EILSEQ -The string pointed to by -.Fa *src -contains a byte sequence which does not describe a valid character of -the source codeset. -.It Bq Er EINVAL -The string pointed to by -.Fa *src -terminates with an incomplete character or shift sequence. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr iconv 1 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -.Fn iconv_open , -.Fn iconv_close , -and -.Fn iconv -conform to -.St -p1003.1-2001 . -.Pp -Historically, the definition of -.Ft iconv -has not been consistent across operating systems. -This is due to an unfortunate historical mistake, documented in -.Lk https://www5.opengroup.org/sophocles2/show_mail.tpl?&source=L&listname=austin-group-l&id=7404 "this e-mail". -The standards page for the header file -.In iconv.h -defined the second argument of -.Fn iconv -as -.Ft char ** , -but the standards page for the -.Fn iconv -implementation defined it as -.Ft const char ** . -The standards committee later chose to change the function definition to -follow the header file definition -.Pq without const , -even though the version with const is arguably more correct. -.Nx -has always used the const form. -It was decided to reject the committee's regression and become -.Pq technically -incompatible. -GNU libiconv has taken the -.Lk http://www.gnu.org/savannah-checkouts/gnu/libiconv/documentation/libiconv-1.14/ "same route". -Most third party software affected by this issue already handles it -during configuration. -.\" ---------------------------------------------------------------------- -.Sh BUGS -If -.Fn iconv -is aborted due to the occurrence of some error, -the -.Dq invalid conversion -count mentioned above is unfortunately lost. diff --git a/lib/libc/iconv/iconv.c b/lib/libc/iconv/iconv.c deleted file mode 100644 index 4bb4a7915..000000000 --- a/lib/libc/iconv/iconv.c +++ /dev/null @@ -1,151 +0,0 @@ -/* $NetBSD: iconv.c,v 1.13 2012/01/20 16:31:29 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: iconv.c,v 1.13 2012/01/20 16:31:29 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include - -#ifdef __weak_alias -__weak_alias(iconv, _iconv) -__weak_alias(iconv_open, _iconv_open) -__weak_alias(iconv_close, _iconv_close) -#endif - -#include -#include "citrus_types.h" -#include "citrus_module.h" -#include "citrus_esdb.h" -#include "citrus_hash.h" -#include "citrus_iconv.h" - -#define ISBADF(_h_) (!(_h_) || (_h_) == (iconv_t)-1) - - -iconv_t -iconv_open(const char *out, const char *in) -{ - int ret; - struct _citrus_iconv *handle; - - ret = _citrus_iconv_open(&handle, _PATH_ICONV, in, out); - if (ret) { - errno = ret == ENOENT? EINVAL : ret; - return ((iconv_t)-1); - } - - return ((iconv_t)(void *)handle); -} - -int -iconv_close(iconv_t handle) -{ - if (ISBADF(handle)) { - errno = EBADF; - return (-1); - } - - _citrus_iconv_close((struct _citrus_iconv *)(void *)handle); - - return (0); -} - -size_t -iconv(iconv_t handle, const char **in, size_t *szin, char **out, size_t *szout) -{ - int err; - size_t ret; - - if (ISBADF(handle)) { - errno = EBADF; - return ((size_t)-1); - } - - err = _citrus_iconv_convert( - (struct _citrus_iconv *)(void *)handle, in, szin, out, szout, - 0, &ret); - if (err) { - errno = err; - ret = (size_t)-1; - } - - return (ret); -} - -size_t -__iconv(iconv_t handle, const char **in, size_t *szin, char **out, - size_t *szout, u_int32_t flags, size_t *invalids) -{ - int err; - size_t ret; - - if (ISBADF(handle)) { - errno = EBADF; - return ((size_t)-1); - } - - err = _citrus_iconv_convert( - (struct _citrus_iconv *)(void *)handle, in, szin, out, szout, - flags, &ret); - if (invalids) - *invalids = ret; - if (err) { - errno = err; - ret = (size_t)-1; - } - - return (ret); -} - -int -__iconv_get_list(char ***rlist, size_t *rsz) -{ - int ret; - - ret = _citrus_esdb_get_list(rlist, rsz); - if (ret) { - errno = ret; - return -1; - } - - return 0; -} - -void -__iconv_free_list(char **list, size_t sz) -{ - _citrus_esdb_free_list(list, sz); -} diff --git a/lib/libc/include/env.h b/lib/libc/include/env.h deleted file mode 100644 index 72d506adc..000000000 --- a/lib/libc/include/env.h +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: env.h,v 1.3 2015/01/20 18:31:25 christos Exp $ */ - -/*- - * Copyright (c) 2010 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matthias Scheler. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -#include - -#include "reentrant.h" - -extern ssize_t __getenvslot(const char *name, size_t l_name, bool allocate); -extern char *__findenvvar(const char *name, size_t l_name); - -#ifdef _REENTRANT -extern bool __readlockenv(void); -extern bool __writelockenv(void); -extern bool __unlockenv(void); -#else -static __inline bool -__readlockenv(void) -{ - return true; -} - -static __inline bool -__writelockenv(void) -{ - return true; -} - -static __inline bool -__unlockenv(void) -{ - return true; -} -#endif - -extern char **environ; diff --git a/lib/libc/include/extern.h b/lib/libc/include/extern.h deleted file mode 100644 index a66f0f782..000000000 --- a/lib/libc/include/extern.h +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: extern.h,v 1.23 2013/08/19 13:03:12 joerg Exp $ */ - -/* - * Copyright (c) 1997 Christos Zoulas. 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 ``AS IS'' AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. - * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT - * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF - * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include - -#ifndef __LOCALE_T_DECLARED -typedef struct _locale *locale_t; -#define __LOCALE_T_DECLARED -#endif /* __LOCALE_T_DECLARED */ - -__BEGIN_DECLS -extern char *__minbrk; -int __getcwd(char *, size_t); -int __getlogin(char *, size_t); -int __setlogin(const char *); -void _resumecontext(void) __dead; -__dso_hidden int _strerror_lr(int, char *, size_t, locale_t); -const char *__strerror(int , char *, size_t); -const char *__strsignal(int , char *, size_t); -char *__dtoa(double, int, int, int *, int *, char **); -void __freedtoa(char *); -int __sysctl(const int *, unsigned int, void *, size_t *, const void *, size_t); - -struct sigaction; -int __sigaction_sigtramp(int, const struct sigaction *, - struct sigaction *, const void *, int); - -#ifdef WIDE_DOUBLE -char *__hdtoa(double, const char *, int, int *, int *, char **); -char *__hldtoa(long double, const char *, int, int *, int *, char **); -char *__ldtoa(long double *, int, int, int *, int *, char **); -#endif - -#ifndef __LIBC12_SOURCE__ -struct syslog_data; -void syslog_ss(int, struct syslog_data *, const char *, ...) - __RENAME(__syslog_ss60) __printflike(3, 4); -void vsyslog_ss(int, struct syslog_data *, const char *, va_list) - __RENAME(__vsyslog_ss60) __printflike(3, 0); -void syslogp_ss(int, struct syslog_data *, const char *, const char *, - const char *, ...) __RENAME(__syslogp_ss60) __printflike(5, 0); -void vsyslogp_ss(int, struct syslog_data *, const char *, const char *, - const char *, va_list) __RENAME(__vsyslogp_ss60) __printflike(5, 0); -#endif - -void _malloc_prefork(void); -void _malloc_postfork(void); - -int _sys_setcontext(const ucontext_t *); - -__END_DECLS diff --git a/lib/libc/include/fd_setsize.h b/lib/libc/include/fd_setsize.h deleted file mode 100644 index 235b1ad1c..000000000 --- a/lib/libc/include/fd_setsize.h +++ /dev/null @@ -1,9 +0,0 @@ -#ifndef _FD_SETSIZE_H -#define _FD_SETSIZE_H - -/* - * If you need a bigger FD_SETSIZE, this is NOT the place to set it. - * This file is a fallback for BIND ports which don't specify their own. - */ - -#endif /* _FD_SETSIZE_H */ diff --git a/lib/libc/include/isc/assertions.h b/lib/libc/include/isc/assertions.h deleted file mode 100644 index 7db7361d0..000000000 --- a/lib/libc/include/isc/assertions.h +++ /dev/null @@ -1,132 +0,0 @@ -/* $NetBSD: assertions.h,v 1.5 2009/04/12 17:07:16 christos Exp $ */ - -/* - * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 1997-2001 Internet Software Consortium. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Id: assertions.h,v 1.5 2008/11/14 02:36:51 marka Exp - */ - -#ifndef ASSERTIONS_H -#define ASSERTIONS_H 1 - -typedef enum { - assert_require, assert_ensure, assert_insist, assert_invariant -} assertion_type; - -typedef void (*assertion_failure_callback)(const char *, int, assertion_type, - const char *, int); - -/* coverity[+kill] */ -extern assertion_failure_callback __assertion_failed; -void set_assertion_failure_callback(assertion_failure_callback f); -const char *assertion_type_to_text(assertion_type type); - -#if defined(CHECK_ALL) || defined(__COVERITY__) -#define CHECK_REQUIRE 1 -#define CHECK_ENSURE 1 -#define CHECK_INSIST 1 -#define CHECK_INVARIANT 1 -#endif - -#if defined(CHECK_NONE) && !defined(__COVERITY__) -#define CHECK_REQUIRE 0 -#define CHECK_ENSURE 0 -#define CHECK_INSIST 0 -#define CHECK_INVARIANT 0 -#endif - -#ifdef _DIAGNOSTIC -#ifndef CHECK_REQUIRE -#define CHECK_REQUIRE 1 -#endif - -#ifndef CHECK_ENSURE -#define CHECK_ENSURE 1 -#endif - -#ifndef CHECK_INSIST -#define CHECK_INSIST 1 -#endif - -#ifndef CHECK_INVARIANT -#define CHECK_INVARIANT 1 -#endif -#endif /* _DIAGNOSTIC */ - -#if CHECK_REQUIRE != 0 -#define REQUIRE(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_require, \ - #cond, 0), 0))) -#define REQUIRE_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_require, \ - #cond, 1), 0))) -#else -#define REQUIRE(cond) ((void) (cond)) -#define REQUIRE_ERR(cond) ((void) (cond)) -#endif /* CHECK_REQUIRE */ - -#if CHECK_ENSURE != 0 -#define ENSURE(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \ - #cond, 0), 0))) -#define ENSURE_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_ensure, \ - #cond, 1), 0))) -#else -#define ENSURE(cond) ((void) (cond)) -#define ENSURE_ERR(cond) ((void) (cond)) -#endif /* CHECK_ENSURE */ - -#if CHECK_INSIST != 0 -#define INSIST(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \ - #cond, 0), 0))) -#define INSIST_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_insist, \ - #cond, 1), 0))) -#else -#if !defined(__lint__) -#define INSIST(cond) ((void) (cond)) -#define INSIST_ERR(cond) ((void) (cond)) -#else /* !__lint__ */ -#define INSIST(cond) -#define INSIST_ERR(cond) -#endif /* !__lint__ */ -#endif /* CHECK_INSIST */ - -#if CHECK_INVARIANT != 0 -#define INVARIANT(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \ - #cond, 0), 0))) -#define INVARIANT_ERR(cond) \ - ((void) ((cond) || \ - ((__assertion_failed)(__FILE__, __LINE__, assert_invariant, \ - #cond, 1), 0))) -#else -#define INVARIANT(cond) ((void) (cond)) -#define INVARIANT_ERR(cond) ((void) (cond)) -#endif /* CHECK_INVARIANT */ -#endif /* ASSERTIONS_H */ -/*! \file */ diff --git a/lib/libc/include/isc/dst.h b/lib/libc/include/isc/dst.h deleted file mode 100644 index a25cf011d..000000000 --- a/lib/libc/include/isc/dst.h +++ /dev/null @@ -1,170 +0,0 @@ -/* $NetBSD: dst.h,v 1.2 2014/08/03 19:14:24 wiz Exp $ */ - -#ifndef DST_H -#define DST_H - -#ifndef HAS_DST_KEY -typedef struct dst_key { - char *dk_key_name; /*%< name of the key */ - int dk_key_size; /*%< this is the size of the key in bits */ - int dk_proto; /*%< what protocols this key can be used for */ - int dk_alg; /*%< algorithm number from key record */ - u_int32_t dk_flags; /*%< and the flags of the public key */ - u_int16_t dk_id; /*%< identifier of the key */ -} DST_KEY; -#endif /* HAS_DST_KEY */ -/* - * do not taint namespace - */ -#define dst_bsafe_init __dst_bsafe_init -#define dst_buffer_to_key __dst_buffer_to_key -#define dst_check_algorithm __dst_check_algorithm -#define dst_compare_keys __dst_compare_keys -#define dst_cylink_init __dst_cylink_init -#define dst_dnskey_to_key __dst_dnskey_to_key -#define dst_eay_dss_init __dst_eay_dss_init -#define dst_free_key __dst_free_key -#define dst_generate_key __dst_generate_key -#define dst_hmac_md5_init __dst_hmac_md5_init -#define dst_init __dst_init -#define dst_key_to_buffer __dst_key_to_buffer -#define dst_key_to_dnskey __dst_key_to_dnskey -#define dst_read_key __dst_read_key -#define dst_rsaref_init __dst_rsaref_init -#define dst_s_build_filename __dst_s_build_filename -#define dst_s_calculate_bits __dst_s_calculate_bits -#define dst_s_conv_bignum_b64_to_u8 __dst_s_conv_bignum_b64_to_u8 -#define dst_s_conv_bignum_u8_to_b64 __dst_s_conv_bignum_u8_to_b64 -#define dst_s_dns_key_id __dst_s_dns_key_id -#define dst_s_dump __dst_s_dump -#define dst_s_filename_length __dst_s_filename_length -#define dst_s_fopen __dst_s_fopen -#define dst_s_get_int16 __dst_s_get_int16 -#define dst_s_get_int32 __dst_s_get_int32 -#define dst_s_id_calc __dst_s_id_calc -#define dst_s_put_int16 __dst_s_put_int16 -#define dst_s_put_int32 __dst_s_put_int32 -#define dst_s_quick_random __dst_s_quick_random -#define dst_s_quick_random_set __dst_s_quick_random_set -#define dst_s_random __dst_s_random -#define dst_s_semi_random __dst_s_semi_random -#define dst_s_verify_str __dst_s_verify_str -#define dst_sig_size __dst_sig_size -#define dst_sign_data __dst_sign_data -#define dst_verify_data __dst_verify_data -#define dst_write_key __dst_write_key - -/* - * DST Crypto API definitions - */ -void dst_init(void); -int dst_check_algorithm(const int); - - -int dst_sign_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */ - DST_KEY *, /*!< the key to use */ - void **, /*!< pointer to state structure */ - const u_char *, /*!< data to be signed */ - const int, /*!< length of input data */ - u_char *, /*!< buffer to write signature to */ - const int); /*!< size of output buffer */ -int dst_verify_data(const int, /*!< specifies INIT/UPDATE/FINAL/ALL */ - DST_KEY *, /*!< the key to use */ - void **, /*!< pointer to state structure */ - const u_char *, /*!< data to be verified */ - const int, /*!< length of input data */ - const u_char *, /*!< buffer containing signature */ - const int); /*!< length of signature */ -DST_KEY *dst_read_key(const char *, /*!< name of key */ - const u_int16_t, /*!< key tag identifier */ - const int, /*!< key algorithm */ - const int); /*!< Private/PublicKey wanted */ -int dst_write_key(const DST_KEY *, /*!< key to write out */ - const int); /*!< Public/Private */ -DST_KEY *dst_dnskey_to_key(const char *, /*!< KEY record name */ - const u_char *, /*!< KEY RDATA */ - const int); /*!< size of input buffer */ -int dst_key_to_dnskey(const DST_KEY *, /*!< key to translate */ - u_char *, /*!< output buffer */ - const int); /*!< size of out_storage */ -DST_KEY *dst_buffer_to_key(const char *, /*!< name of the key */ - const int, /*!< algorithm */ - const int, /*!< dns flags */ - const int, /*!< dns protocol */ - const u_char *, /*!< key in dns wire fmt */ - const int); /*!< size of key */ -int dst_key_to_buffer(DST_KEY *, u_char *, int); - -DST_KEY *dst_generate_key(const char *, /*!< name of new key */ - const int, /*!< key algorithm to generate */ - const int, /*!< size of new key */ - const int, /*!< alg dependent parameter */ - const int, /*!< key DNS flags */ - const int); /*!< key DNS protocol */ -DST_KEY *dst_free_key(DST_KEY *); -int dst_compare_keys(const DST_KEY *, const DST_KEY *); - -int dst_sig_size(DST_KEY *); - - -/* support for dns key tags/ids */ -u_int16_t dst_s_dns_key_id(const u_char *, const int); -u_int16_t dst_s_id_calc(const u_char *, const int); - -/* Used by callers as well as by the library. */ -#define RAW_KEY_SIZE 8192 /*%< large enough to store any key */ -/* DST_API control flags */ -/* These are used used in functions dst_sign_data and dst_verify_data */ -#define SIG_MODE_INIT 1 /*%< initialize digest */ -#define SIG_MODE_UPDATE 2 /*%< add data to digest */ -#define SIG_MODE_FINAL 4 /*%< generate/verify signature */ -#define SIG_MODE_ALL (SIG_MODE_INIT|SIG_MODE_UPDATE|SIG_MODE_FINAL) - -/* Flags for dst_read_private_key() */ -#define DST_FORCE_READ 0x1000000 -#define DST_CAN_SIGN 0x010F -#define DST_NO_AUTHEN 0x8000 -#define DST_EXTEND_FLAG 0x1000 -#define DST_STANDARD 0 -#define DST_PRIVATE 0x2000000 -#define DST_PUBLIC 0x4000000 -#define DST_RAND_SEMI 1 -#define DST_RAND_STD 2 -#define DST_RAND_KEY 3 -#define DST_RAND_DSS 4 - - -/* DST algorithm codes */ -#define KEY_RSA 1 -#define KEY_DH 2 -#define KEY_DSA 3 -#define KEY_PRIVATE 254 -#define KEY_EXPAND 255 -#define KEY_HMAC_MD5 157 -#define KEY_HMAC_SHA1 158 -#define UNKNOWN_KEYALG 0 -#define DST_MAX_ALGS KEY_HMAC_SHA1 - -/* DST constants to locations in KEY record changes in new KEY record */ -#define DST_FLAGS_SIZE 2 -#define DST_KEY_PROT 2 -#define DST_KEY_ALG 3 -#define DST_EXT_FLAG 4 -#define DST_KEY_START 4 - -#ifndef SIGN_F_NOKEY -#define SIGN_F_NOKEY 0xC000 -#endif - -/* error codes from dst routines */ -#define SIGN_INIT_FAILURE (-23) -#define SIGN_UPDATE_FAILURE (-24) -#define SIGN_FINAL_FAILURE (-25) -#define VERIFY_INIT_FAILURE (-26) -#define VERIFY_UPDATE_FAILURE (-27) -#define VERIFY_FINAL_FAILURE (-28) -#define MISSING_KEY_OR_SIGNATURE (-30) -#define UNSUPPORTED_KEYALG (-31) - -#endif /* DST_H */ -/*! \file */ diff --git a/lib/libc/include/isc/eventlib.h b/lib/libc/include/isc/eventlib.h deleted file mode 100644 index 4e9cc2e40..000000000 --- a/lib/libc/include/isc/eventlib.h +++ /dev/null @@ -1,206 +0,0 @@ -/* $NetBSD: eventlib.h,v 1.3 2009/04/12 17:07:16 christos Exp $ */ - -/* - * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 1995-1999, 2001, 2003 Internet Software Consortium. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -/* eventlib.h - exported interfaces for eventlib - * vix 09sep95 [initial] - * - * Id: eventlib.h,v 1.7 2008/11/14 02:36:51 marka Exp - */ - -#ifndef _EVENTLIB_H -#define _EVENTLIB_H - -#include -#include -#include -#include - -#ifndef __P -# define __EVENTLIB_P_DEFINED -# ifdef __STDC__ -# define __P(x) x -# else -# define __P(x) () -# endif -#endif - -/* In the absence of branded types... */ -typedef struct { void *opaque; } evConnID; -typedef struct { void *opaque; } evFileID; -typedef struct { void *opaque; } evStreamID; -typedef struct { void *opaque; } evTimerID; -typedef struct { void *opaque; } evWaitID; -typedef struct { void *opaque; } evContext; -typedef struct { void *opaque; } evEvent; - -#define evInitID(id) ((id)->opaque = NULL) -#define evTestID(id) ((id).opaque != NULL) - -typedef void (*evConnFunc)__P((evContext, void *, int, const void *, int, - const void *, int)); -typedef void (*evFileFunc)__P((evContext, void *, int, int)); -typedef void (*evStreamFunc)__P((evContext, void *, int, int)); -typedef void (*evTimerFunc)__P((evContext, void *, - struct timespec, struct timespec)); -typedef void (*evWaitFunc)__P((evContext, void *, const void *)); - -typedef struct { unsigned char mask[256/8]; } evByteMask; -#define EV_BYTEMASK_BYTE(b) ((b) / 8) -#define EV_BYTEMASK_MASK(b) (1 << ((b) % 8)) -#define EV_BYTEMASK_SET(bm, b) \ - ((bm).mask[EV_BYTEMASK_BYTE(b)] |= EV_BYTEMASK_MASK(b)) -#define EV_BYTEMASK_CLR(bm, b) \ - ((bm).mask[EV_BYTEMASK_BYTE(b)] &= ~EV_BYTEMASK_MASK(b)) -#define EV_BYTEMASK_TST(bm, b) \ - ((bm).mask[EV_BYTEMASK_BYTE(b)] & EV_BYTEMASK_MASK(b)) - -#define EV_POLL 1 -#define EV_WAIT 2 -#define EV_NULL 4 - -#define EV_READ 1 -#define EV_WRITE 2 -#define EV_EXCEPT 4 - -#define EV_WASNONBLOCKING 8 /* Internal library use. */ - -/* eventlib.c */ -#define evCreate __evCreate -#define evSetDebug __evSetDebug -#define evDestroy __evDestroy -#define evGetNext __evGetNext -#define evDispatch __evDispatch -#define evDrop __evDrop -#define evMainLoop __evMainLoop -#define evHighestFD __evHighestFD -#define evGetOption __evGetOption -#define evSetOption __evSetOption - -int evCreate __P((evContext *)); -void evSetDebug __P((evContext, int, FILE *)); -int evDestroy __P((evContext)); -int evGetNext __P((evContext, evEvent *, int)); -int evDispatch __P((evContext, evEvent)); -void evDrop __P((evContext, evEvent)); -int evMainLoop __P((evContext)); -int evHighestFD __P((evContext)); -int evGetOption __P((evContext *, const char *, int *)); -int evSetOption __P((evContext *, const char *, int)); - -/* ev_connects.c */ -#define evListen __evListen -#define evConnect __evConnect -#define evCancelConn __evCancelConn -#define evHold __evHold -#define evUnhold __evUnhold -#define evTryAccept __evTryAccept - -int evListen __P((evContext, int, int, evConnFunc, void *, evConnID *)); -int evConnect __P((evContext, int, const void *, int, - evConnFunc, void *, evConnID *)); -int evCancelConn __P((evContext, evConnID)); -int evHold __P((evContext, evConnID)); -int evUnhold __P((evContext, evConnID)); -int evTryAccept __P((evContext, evConnID, int *)); - -/* ev_files.c */ -#define evSelectFD __evSelectFD -#define evDeselectFD __evDeselectFD - -int evSelectFD __P((evContext, int, int, evFileFunc, void *, evFileID *)); -int evDeselectFD __P((evContext, evFileID)); - -/* ev_streams.c */ -#define evConsIovec __evConsIovec -#define evWrite __evWrite -#define evRead __evRead -#define evTimeRW __evTimeRW -#define evUntimeRW __evUntimeRW -#define evCancelRW __evCancelRW - -struct iovec evConsIovec __P((void *, size_t)); -int evWrite __P((evContext, int, const struct iovec *, int, - evStreamFunc func, void *, evStreamID *)); -int evRead __P((evContext, int, const struct iovec *, int, - evStreamFunc func, void *, evStreamID *)); -int evTimeRW __P((evContext, evStreamID, evTimerID timer)); -int evUntimeRW __P((evContext, evStreamID)); -int evCancelRW __P((evContext, evStreamID)); - -/* ev_timers.c */ -#define evConsTime __evConsTime -#define evAddTime __evAddTime -#define evSubTime __evSubTime -#define evCmpTime __evCmpTime -#define evTimeSpec __evTimeSpec -#define evTimeVal __evTimeVal - -#define evNowTime __evNowTime -#define evUTCTime __evUTCTime -#define evLastEventTime __evLastEventTime -#define evSetTimer __evSetTimer -#define evClearTimer __evClearTimer -#define evConfigTimer __evConfigTimer -#define evResetTimer __evResetTimer -#define evSetIdleTimer __evSetIdleTimer -#define evClearIdleTimer __evClearIdleTimer -#define evResetIdleTimer __evResetIdleTimer -#define evTouchIdleTimer __evTouchIdleTimer - -struct timespec evConsTime __P((time_t sec, long nsec)); -struct timespec evAddTime __P((struct timespec, struct timespec)); -struct timespec evSubTime __P((struct timespec, struct timespec)); -struct timespec evNowTime __P((void)); -struct timespec evUTCTime __P((void)); -struct timespec evLastEventTime __P((evContext)); -struct timespec evTimeSpec __P((struct timeval)); -struct timeval evTimeVal __P((struct timespec)); -int evCmpTime __P((struct timespec, struct timespec)); -int evSetTimer __P((evContext, evTimerFunc, void *, struct timespec, - struct timespec, evTimerID *)); -int evClearTimer __P((evContext, evTimerID)); -int evConfigTimer __P((evContext, evTimerID, const char *param, - int value)); -int evResetTimer __P((evContext, evTimerID, evTimerFunc, void *, - struct timespec, struct timespec)); -int evSetIdleTimer __P((evContext, evTimerFunc, void *, struct timespec, - evTimerID *)); -int evClearIdleTimer __P((evContext, evTimerID)); -int evResetIdleTimer __P((evContext, evTimerID, evTimerFunc, void *, - struct timespec)); -int evTouchIdleTimer __P((evContext, evTimerID)); - -/* ev_waits.c */ -#define evWaitFor __evWaitFor -#define evDo __evDo -#define evUnwait __evUnwait -#define evDefer __evDefer - -int evWaitFor __P((evContext, const void *, evWaitFunc, void *, evWaitID *)); -int evDo __P((evContext, const void *)); -int evUnwait __P((evContext, evWaitID)); -int evDefer __P((evContext, evWaitFunc, void *)); - -#ifdef __EVENTLIB_P_DEFINED -# undef __P -#endif - -#endif /*_EVENTLIB_H*/ - -/*! \file */ diff --git a/lib/libc/include/isc/heap.h b/lib/libc/include/isc/heap.h deleted file mode 100644 index 30cec98f2..000000000 --- a/lib/libc/include/isc/heap.h +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: heap.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -typedef int (*heap_higher_priority_func)(void *, void *); -typedef void (*heap_index_func)(void *, int); -typedef void (*heap_for_each_func)(void *, void *); - -typedef struct heap_context { - int array_size; - int array_size_increment; - int heap_size; - void **heap; - heap_higher_priority_func higher_priority; - heap_index_func index; -} *heap_context; - -#define heap_new __heap_new -#define heap_free __heap_free -#define heap_insert __heap_insert -#define heap_delete __heap_delete -#define heap_increased __heap_increased -#define heap_decreased __heap_decreased -#define heap_element __heap_element -#define heap_for_each __heap_for_each - -heap_context heap_new(heap_higher_priority_func, heap_index_func, int); -int heap_free(heap_context); -int heap_insert(heap_context, void *); -int heap_delete(heap_context, int); -int heap_increased(heap_context, int); -int heap_decreased(heap_context, int); -void * heap_element(heap_context, int); -int heap_for_each(heap_context, heap_for_each_func, void *); - -/*! \file */ diff --git a/lib/libc/include/isc/list.h b/lib/libc/include/isc/list.h deleted file mode 100644 index 46f2e79be..000000000 --- a/lib/libc/include/isc/list.h +++ /dev/null @@ -1,120 +0,0 @@ -/* $NetBSD: list.h,v 1.5 2009/04/12 17:07:16 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef LIST_H -#define LIST_H 1 -#include - -#define LIST(type) struct { type *head, *tail; } -#define INIT_LIST(list) \ - do { (list).head = NULL; (list).tail = NULL; } while (/*CONSTCOND*/0) - -#define LINK(type) struct { type *prev, *next; } -#define INIT_LINK_TYPE(elt, link, type) \ - do { \ - (elt)->link.prev = (type *)(-1); \ - (elt)->link.next = (type *)(-1); \ - } while (/*CONSTCOND*/0) -#define INIT_LINK(elt, link) \ - INIT_LINK_TYPE(elt, link, void) -#define LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1) && \ - (void *)((elt)->link.next) != (void *)(-1)) - -#define HEAD(list) ((list).head) -#define TAIL(list) ((list).tail) -#define EMPTY(list) ((list).head == NULL) - -#define PREPEND(list, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((list).head != NULL) \ - (list).head->link.prev = (elt); \ - else \ - (list).tail = (elt); \ - (elt)->link.prev = NULL; \ - (elt)->link.next = (list).head; \ - (list).head = (elt); \ - } while (/*CONSTCOND*/0) - -#define APPEND(list, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((list).tail != NULL) \ - (list).tail->link.next = (elt); \ - else \ - (list).head = (elt); \ - (elt)->link.prev = (list).tail; \ - (elt)->link.next = NULL; \ - (list).tail = (elt); \ - } while (/*CONSTCOND*/0) - -#define UNLINK_TYPE(list, elt, link, type) \ - do { \ - INSIST(LINKED(elt, link));\ - if ((elt)->link.next != NULL) \ - (elt)->link.next->link.prev = (elt)->link.prev; \ - else { \ - INSIST((list).tail == (elt)); \ - (list).tail = (elt)->link.prev; \ - } \ - if ((elt)->link.prev != NULL) \ - (elt)->link.prev->link.next = (elt)->link.next; \ - else { \ - INSIST((list).head == (elt)); \ - (list).head = (elt)->link.next; \ - } \ - INIT_LINK_TYPE(elt, link, type); \ - } while (/*CONSTCOND*/0) -#define UNLINK(list, elt, link) \ - UNLINK_TYPE(list, elt, link, void) - -#define PREV(elt, link) ((elt)->link.prev) -#define NEXT(elt, link) ((elt)->link.next) - -#define INSERT_BEFORE(list, before, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((before)->link.prev == NULL) \ - PREPEND(list, elt, link); \ - else { \ - (elt)->link.prev = (before)->link.prev; \ - (before)->link.prev = (elt); \ - (elt)->link.prev->link.next = (elt); \ - (elt)->link.next = (before); \ - } \ - } while (/*CONSTCOND*/0) - -#define INSERT_AFTER(list, after, elt, link) \ - do { \ - INSIST(!LINKED(elt, link));\ - if ((after)->link.next == NULL) \ - APPEND(list, elt, link); \ - else { \ - (elt)->link.next = (after)->link.next; \ - (after)->link.next = (elt); \ - (elt)->link.next->link.prev = (elt); \ - (elt)->link.prev = (after); \ - } \ - } while (/*CONSTCOND*/0) - -#define ENQUEUE(list, elt, link) APPEND(list, elt, link) -#define DEQUEUE(list, elt, link) UNLINK(list, elt, link) - -#endif /* LIST_H */ -/*! \file */ diff --git a/lib/libc/include/isc/memcluster.h b/lib/libc/include/isc/memcluster.h deleted file mode 100644 index 3c1b489cb..000000000 --- a/lib/libc/include/isc/memcluster.h +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: memcluster.h,v 1.1.1.4 2009/04/12 16:35:44 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1997,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#ifndef MEMCLUSTER_H -#define MEMCLUSTER_H - -#include - -#define meminit __meminit -#ifdef MEMCLUSTER_DEBUG -#define memget(s) __memget_debug(s, __FILE__, __LINE__) -#define memput(p, s) __memput_debug(p, s, __FILE__, __LINE__) -#else /*MEMCLUSTER_DEBUG*/ -#ifdef MEMCLUSTER_RECORD -#define memget(s) __memget_record(s, __FILE__, __LINE__) -#define memput(p, s) __memput_record(p, s, __FILE__, __LINE__) -#else /*MEMCLUSTER_RECORD*/ -#define memget __memget -#define memput __memput -#endif /*MEMCLUSTER_RECORD*/ -#endif /*MEMCLUSTER_DEBUG*/ -#define memstats __memstats -#define memactive __memactive - -int meminit(size_t, size_t); -void * __memget(size_t); -void __memput(void *, size_t); -void * __memget_debug(size_t, const char *, int); -void __memput_debug(void *, size_t, const char *, int); -void * __memget_record(size_t, const char *, int); -void __memput_record(void *, size_t, const char *, int); -void memstats(FILE *); -int memactive(void); - -#endif /* MEMCLUSTER_H */ -/*! \file */ diff --git a/lib/libc/include/namespace.h b/lib/libc/include/namespace.h deleted file mode 100644 index 309a686f3..000000000 --- a/lib/libc/include/namespace.h +++ /dev/null @@ -1,939 +0,0 @@ -/* $NetBSD: namespace.h,v 1.179 2015/09/10 14:05:06 christos Exp $ */ - -/*- - * Copyright (c) 1997-2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef _NAMESPACE_H_ -#define _NAMESPACE_H_ - -#include - -#ifndef __lint__ -#define aio_suspend _aio_suspend -#define brk _brk -#define catclose _catclose -#define catgets _catgets -#define catopen _catopen -#define catopen_l _catopen_l -#define daylight _daylight -#define difftime _difftime -#define devname_r _devname_r -#define err _err -#define errc _errc -#define errx _errx -#ifdef _REENTRANT -#define fileno _fileno -#endif /* _REENTRANT */ -#define fork _fork -#define fseeko _fseeko -#define ftello _ftello -#define getcontext _getcontext -#define getenv_r _getenv_r -#define imaxabs _imaxabs -#define imaxdiv _imaxdiv -#define inet_aton _inet_aton -#define inet_pton _inet_pton -#define pipe _pipe -#define sbrk _sbrk -#define strerror_l _strerror_l -#define strerror_r _strerror_r -#define strlcat _strlcat -#define strlcpy _strlcpy -#define strtod_l _strtod_l -#define strtof _strtof -#define strtof_l _strtof_l -#define strtoi _strtoi -#define strtoi_l _strtoi_l -#define strtoimax _strtoimax -#define strtoimax_l _strtoimax_l -#define strtold _strtold -#define strtold_l _strtold_l -#define strtoll _strtoll -#define strtoll_l _strtoll_l -#define strtou _strtou -#define strtou_l _strtou_l -#define strtoull _strtoull -#define strtoull_l _strtoull_l -#define strtoumax _strtoumax -#define strtoumax_l _strtoumax_l -#define sys_errlist _sys_errlist -#define sys_nerr _sys_nerr -#define sys_siglist _sys_siglist -#define sys_nsig _sys_nsig -#define sysconf __sysconf -#define verr _verr -#define verrc _verrc -#define verrx _verrx -#define vwarn _vwarn -#define vwarnc _vwarnc -#define vwarnx _vwarnx -#define warn _warn -#define warnc _warnc -#define warnx _warnx - -#ifdef __weak_alias -#define MD2Data _MD2Data -#define MD2End _MD2End -#define MD2FileChunk _MD2FileChunk -#define MD2File _MD2File -#define MD2Final _MD2Final -#define MD2Init _MD2Init -#define MD2Transform _MD2Transform -#define MD2Update _MD2Update -#define MD4Data _MD4Data -#define MD4End _MD4End -#define MD4FileChunk _MD4FileChunk -#define MD4File _MD4File -#define MD4Final _MD4Final -#define MD4Init _MD4Init -#define MD4Transform _MD4Transform -#define MD4Update _MD4Update -#define MD5Data _MD5Data -#define MD5End _MD5End -#define MD5FileChunk _MD5FileChunk -#define MD5File _MD5File -#define MD5Final _MD5Final -#define MD5Init _MD5Init -#define MD5Transform _MD5Transform -#define MD5Update _MD5Update -#define RMD160Data _RMD160Data -#define RMD160End _RMD160End -#define RMD160FileChunk _RMD160FileChunk -#define RMD160File _RMD160File -#define RMD160Final _RMD160Final -#define RMD160Init _RMD160Init -#define RMD160Transform _RMD160Transform -#define RMD160Update _RMD160Update -#define SHA1Data _SHA1Data -#define SHA1End _SHA1End -#define SHA1FileChunk _SHA1FileChunk -#define SHA1File _SHA1File -#define SHA1Final _SHA1Final -#define SHA1Init _SHA1Init -#define SHA1Transform _SHA1Transform -#define SHA1Update _SHA1Update -#define SHA224_Data _SHA224_Data -#define SHA224_End _SHA224_End -#define SHA224_FileChunk _SHA224_FileChunk -#define SHA224_File _SHA224_File -#define SHA224_Final _SHA224_Final -#define SHA224_Init _SHA224_Init -#define SHA224_Transform _SHA224_Transform -#define SHA224_Update _SHA224_Update -#define SHA256_Data _SHA256_Data -#define SHA256_End _SHA256_End -#define SHA256_FileChunk _SHA256_FileChunk -#define SHA256_File _SHA256_File -#define SHA256_Final _SHA256_Final -#define SHA256_Init _SHA256_Init -#define SHA256_Transform _SHA256_Transform -#define SHA256_Update _SHA256_Update -#define SHA384_Data _SHA384_Data -#define SHA384_End _SHA384_End -#define SHA384_FileChunk _SHA384_FileChunk -#define SHA384_File _SHA384_File -#define SHA384_Final _SHA384_Final -#define SHA384_Init _SHA384_Init -#define SHA384_Transform _SHA384_Transform -#define SHA384_Update _SHA384_Update -#define SHA512_Data _SHA512_Data -#define SHA512_End _SHA512_End -#define SHA512_FileChunk _SHA512_FileChunk -#define SHA512_File _SHA512_File -#define SHA512_Final _SHA512_Final -#define SHA512_Init _SHA512_Init -#define SHA512_Transform _SHA512_Transform -#define SHA512_Update _SHA512_Update -#define a64l _a64l -#define adjtime _adjtime -#define alarm _alarm -#define allocaddrinfo _allocaddrinfo -#define alphasort _alphasort -#define arc4random _arc4random -#define arc4random_addrandom _arc4random_addrandom -#define arc4random_buf _arc4random_buf -#define arc4random_stir _arc4random_stir -#define arc4random_uniform _arc4random_uniform -#define asctime_r _asctime_r -#define asprintf _asprintf -#define asprintf_l _asprintf_l -#define asysctl _asysctl -#define asysctlbyname _asysctlbyname -#define atoll _atoll -#define authnone_create _authnone_create -#define authunix_create _authunix_create -#define authunix_create_default _authunix_create_default -#define basename _basename -#define bindresvport _bindresvport -#define bindresvport_sa _bindresvport_sa -#define bm_comp _bm_comp -#define bm_exec _bm_exec -#define bm_free _bm_free -#define callrpc _callrpc -#define cdbr_close _cdbr_close -#define cdbr_find _cdbr_find -#define cdbr_get _cdbr_get -#define cdbr_open _cdbr_open -#define cdbr_open_mem _cdbr_open_mem -#define cdbw_close _cdbw_close -#define cdbw_open _cdbw_open -#define cdbw_put _cdbw_put -#define cdbw_put_data _cdbw_put_data -#define cdbw_put_key _cdbw_put_key -#define cdbw_output _cdbw_output -#define cfgetispeed _cfgetispeed -#define cfgetospeed _cfgetospeed -#define cfmakeraw _cfmakeraw -#define cfsetispeed _cfsetispeed -#define cfsetospeed _cfsetospeed -#define cfsetspeed _cfsetspeed -#define cgetcap _cgetcap -#define cgetclose _cgetclose -#define cgetent _cgetent -#define cgetfirst _cgetfirst -#define cgetmatch _cgetmatch -#define cgetnext _cgetnext -#define cgetnum _cgetnum -#define cgetset _cgetset -#define cgetstr _cgetstr -#define cgetustr _cgetustr -#define clnt_broadcast _clnt_broadcast -#define clnt_create _clnt_create -#define clnt_create_vers _clnt_create_vers -#define clnt_dg_create _clnt_dg_create -#define clnt_pcreateerror _clnt_pcreateerror -#define clnt_perrno _clnt_perrno -#define clnt_perror _clnt_perror -#define clnt_raw_create _clnt_raw_create -#define clnt_tli_create _clnt_tli_create -#define clnt_tp_create _clnt_tp_create -#define clnt_spcreateerror _clnt_spcreateerror -#define clnt_sperrno _clnt_sperrno -#define clnt_sperror _clnt_sperror -#define clnt_vc_create _clnt_vc_create -#define clntraw_create _clntraw_create -#define clnttcp_create _clnttcp_create -#define clntudp_bufcreate _clntudp_bufcreate -#define clntudp_create _clntudp_create -#define clock_gettime _clock_gettime -#define clock_getres _clock_getres -#define clock_settime _clock_settime -#define closedir _closedir -#define closelog _closelog -#define closelog_r _closelog_r -#define confstr _confstr -#define consttime_memequal _consttime_memequal -#define csetexpandtc _csetexpandtc -#define ctermid _ctermid -#define ctime_r _ctime_r -#define ctime_rz _ctime_rz -#define daemon _daemon -#define dbopen _dbopen -#define devname _devname -#define difftime _difftime -#define dirname _dirname -#define dn_expand _dn_expand -#define dprintf_l _dprintf_l -#define drand48 _drand48 -#define duplocale _duplocale -#define endfsent _endfsent -#define endgrent _endgrent -#define endhostent _endhostent -#define endnetconfig _endnetconfig -#define endnetent _endnetent -#define endnetgrent _endnetgrent -#define endnetpath _endnetpath -#define endprotoent _endprotoent -#define endprotoent_r _endprotoent_r -#define endpwent _endpwent -#define endrpcent _endrpcent -#define endservent _endservent -#define endservent_r _endservent_r -#define endttyent _endttyent -#define endusershell _endusershell -#define erand48 _erand48 -#define ether_aton _ether_aton -#define ether_hostton _ether_hostton -#define ether_line _ether_line -#define ether_ntoa _ether_ntoa -#define ether_ntohost _ether_ntohost -#define execl _execl -#define execle _execle -#define execlp _execlp -#define execlpe _execlpe -#define execv _execv -#define execvp _execvp -#define execvpe _execvpe -#define explicit_memset _explicit_memset -#define fdiscard _fdiscard -#define fdopen _fdopen -#define fgetln _fgetln -#define fgetwln _fgetwln -#define fhstatvfs _fhstatvfs -#define flockfile _flockfile -#define ftrylockfile _ftrylockfile -#define funlockfile _funlockfile -#define fnmatch _fnmatch -#define fparseln _fparseln -#define fprintf_l _fprintf_l -#define fpgetmask _fpgetmask -#define fpgetprec _fpgetprec -#define fpgetround _fpgetround -#define fpgetsticky _fpgetsticky -#define fpsetmask _fpsetmask -#define fpsetprec _fpsetprec -#define fpsetround _fpsetround -#define fpsetsticky _fpsetsticky -#define freenetconfigent _freenetconfigent -#define freeaddrinfo _freeaddrinfo -#define freeifaddrs _freeifaddrs -#define freelocale _freelocale -#define fscanf_l _fscanf_l -#define fstatvfs _fstatvfs -#define ftok _ftok -#define ftruncate _ftruncate -#define fts_children _fts_children -#define fts_close _fts_close -#define fts_open _fts_open -#define fts_read _fts_read -#define fts_set _fts_set -#define fwprintf_l _fwprintf_l -#define fwscanf_l _fwscanf_l -#define gai_strerror _gai_strerror -#define get_myaddress _get_myaddress -#define getaddrinfo _getaddrinfo -#define getbsize _getbsize -#define getcwd _getcwd -#define getdelim _getdelim -#define getdevmajor _getdevmajor -#define getdiskbyname _getdiskbyname -#define getdomainname _getdomainname -#define getfsent _getfsent -#define getfsfile _getfsfile -#define getfsspec _getfsspec -#define getgrent _getgrent -#define getgrent_r _getgrent_r -#define getgrgid _getgrgid -#define getgrgid_r _getgrgid_r -#define getgrnam _getgrnam -#define getgrnam_r _getgrnam_r -#define getgrouplist _getgrouplist -#define getgroupmembership _getgroupmembership -#define gethostbyaddr _gethostbyaddr -#define gethostbyname _gethostbyname -#define gethostent _gethostent -#define gethostname _gethostname -#define getifaddrs _getifaddrs -#define getline _getline -#define getloadavg _getloadavg -#define getlogin _getlogin -#define getlogin_r _getlogin_r -#define getmntinfo _getmntinfo -#define getmode _getmode -#define getnameinfo _getnameinfo -#define getnetbyaddr _getnetbyaddr -#define getnetbyname _getnetbyname -#define getnetconfig _getnetconfig -#define getnetconfigent _getnetconfigent -#define getnetent _getnetent -#define getnetgrent _getnetgrent -#define getnetpath _getnetpath -#define getopt _getopt -#define getopt_long _getopt_long -#define getpagesize _getpagesize -#define getpass _getpass -#define getpassfd _getpassfd -#define getpass_r _getpass_r -#define getprogname _getprogname -#define getprotobyname _getprotobyname -#define getprotobyname_r _getprotobyname_r -#define getprotobynumber _getprotobynumber -#define getprotobynumber_r _getprotobynumber_r -#define getprotoent _getprotoent -#define getprotoent_r _getprotoent_r -#define getpwent _getpwent -#define getpwent_r _getpwent_r -#define getpwnam _getpwnam -#define getpwnam_r _getpwnam_r -#define getpwuid _getpwuid -#define getpwuid_r _getpwuid_r -#define getrpcbyname _getrpcbyname -#define getrpcbyname_r _getrpcbyname_r -#define getrpcbynumber _getrpcbynumber -#define getrpcbynumber_r _getrpcbynumber_r -#define getrpcent _getrpcent -#define getrpcent_r _getrpcent_r -#define getrpcport _getrpcport -#define getservbyname _getservbyname -#define getservbyname_r _getservbyname_r -#define getservbyport _getservbyport -#define getservbyport_r _getservbyport_r -#define getservent _getservent -#define getservent_r _getservent_r -#define getsubopt _getsubopt -#define getttyent _getttyent -#define getttynam _getttynam -#define getusershell _getusershell -#define glob _glob -#define globfree _globfree -#define gmtime_r _gmtime_r -#define group_from_gid _group_from_gid -#define heapsort _heapsort -#define herror _herror -#define hes_error _hes_error -#define hes_free _hes_free -#define hes_init _hes_init -#define hes_resolve _hes_resolve -#define hes_to_bind _hes_to_bind -#define hesiod_end _hesiod_end -#define hesiod_free_list _hesiod_free_list -#define hesiod_init _hesiod_init -#define hesiod_resolve _hesiod_resolve -#define hesiod_to_bind _hesiod_to_bind -#define iconv _iconv -#define iconv_open _iconv_open -#define iconv_close _iconv_close -#define if_freenameindex _if_freenameindex -#define if_indextoname _if_indextoname -#define if_nameindex _if_nameindex -#define if_nametoindex _if_nametoindex -#define in6addr_any _in6addr_any -#define in6addr_linklocal_allnodes _in6addr_linklocal_allnodes -#define in6addr_linklocal_allrouters _in6addr_linklocal_allrouters -#define in6addr_loopback _in6addr_loopback -#define in6addr_nodelocal_allnodes _in6addr_nodelocal_allnodes -#define inet6_option_alloc _inet6_option_alloc -#define inet6_option_append _inet6_option_append -#define inet6_option_find _inet6_option_find -#define inet6_option_init _inet6_option_init -#define inet6_option_next _inet6_option_next -#define inet6_option_space _inet6_option_space -#define inet6_opt_init _inet6_opt_init -#define inet6_opt_append _inet6_opt_append -#define inet6_opt_finish _inet6_opt_finish -#define inet6_opt_set_val _inet6_opt_set_val -#define inet6_opt_next _inet6_opt_next -#define inet6_opt_find _inet6_opt_find -#define inet6_opt_get_val _inet6_opt_get_val -#define inet6_rthdr_add _inet6_rthdr_add -#define inet6_rthdr_getaddr _inet6_rthdr_getaddr -#define inet6_rthdr_getflags _inet6_rthdr_getflags -#define inet6_rthdr_init _inet6_rthdr_init -#define inet6_rthdr_lasthop _inet6_rthdr_lasthop -#define inet6_rthdr_segments _inet6_rthdr_segments -#define inet6_rthdr_space _inet6_rthdr_space -#define inet6_rth_space _inet6_rth_space -#define inet6_rth_init _inet6_rth_init -#define inet6_rth_add _inet6_rth_add -#define inet6_rth_reverse _inet6_rth_reverse -#define inet6_rth_segments _inet6_rth_segments -#define inet6_rth_getaddr _inet6_rth_getaddr -#define inet_cidr_ntop _inet_cidr_ntop -#define inet_cidr_pton _inet_cidr_pton -#define inet_lnaof _inet_lnaof -#define inet_makeaddr _inet_makeaddr -#define inet_net_ntop _inet_net_ntop -#define inet_net_pton _inet_net_pton -#define inet_neta _inet_neta -#define inet_netof _inet_netof -#define inet_network _inet_network -#define inet_nsap_addr _inet_nsap_addr -#define inet_nsap_ntoa _inet_nsap_ntoa -#define inet_ntoa _inet_ntoa -#define inet_ntop _inet_ntop -#define initgroups _initgroups -#define initstate _initstate -#define innetgr _innetgr -#define isatty _isatty -#define jrand48 _jrand48 -#define kill _kill -#define l64a _l64a -#define l64a_r _l64a_r -#define lcong48 _lcong48 -#define llabs _llabs -#define lldiv _lldiv -#define localtime_r _localtime_r -#define localtime_rz _localtime_rz -#define lockf _lockf -#define lrand48 _lrand48 -#define lseek _lseek -#define membar_producer _membar_producer -#define mergesort _mergesort -#define mi_vector_hash _mi_vector_hash -#define mkstemp _mkstemp -#define mktime_z _mktime_z -#define mmap _mmap -#define mpool_close _mpool_close -#define mpool_filter _mpool_filter -#define mpool_get _mpool_get -#define mpool_new _mpool_new -#define mpool_open _mpool_open -#define mpool_put _mpool_put -#define mpool_sync _mpool_sync -#define mq_timedreceive _mq_timedreceive -#define mq_timedsend _mq_timedsend -#define mrand48 _mrand48 -#define murmurhash2 _murmurhash2 -#define nc_perror _nc_perror -#define nc_sperror _nc_sperror -#define nanosleep _nanosleep -#define newlocale _newlocale -#define nice _nice -#if 0 -#define nlist _nlist -#endif -#define nl_langinfo_l _nl_langinfo_l -#define nrand48 _nrand48 -#define ntp_adjtime _ntp_adjtime -#define nsdispatch _nsdispatch -#define offtime _offtime -#define opendir _opendir -#define fdopendir _fdopendir -#define openlog _openlog -#define openlog_r _openlog_r -#define pause _pause -#define pclose _pclose -#define pmap_getmaps _pmap_getmaps -#define pmap_getport _pmap_getport -#define pmap_rmtcall _pmap_rmtcall -#define pmap_set _pmap_set -#define pmap_unset _pmap_unset -#define pollts _pollts -#define popen _popen -#define posix2time _posix2time -#define posix2time_z _posix2time_z -#define pread _pread -#define printf_l _printf_l -#define pselect _pselect -#define posix_fallocate _posix_fallocate -#define psignal _psignal -#define pthread_atfork _pthread_atfork -#define ptree_init ptree_init -#define ptree_insert_node ptree_insert_node -#define ptree_insert_mask_node ptree_insert_mask_node -#define ptree_find_filtered_node ptree_find_filtered_node -#define ptree_remove_node ptree_remove_node -#define ptree_iterate ptree_iterate -#define putenv _putenv -#define pwcache_groupdb _pwcache_groupdb -#define pwcache_userdb _pwcache_userdb -#define pwrite _pwrite -#define qabs _qabs -#define qdiv _qdiv -#define radixsort _radixsort -#define random _random -#define randomid _randomid -#define randomid_new _randomid_new -#define randomid_delete _randomid_delete -#define read _read -#define readdir _readdir -#define readdir_r _readdir_r -#define readlink _readlink -#define reallocarr _reallocarr -#define realpath _realpath -#define regcomp _regcomp -#define regerror _regerror -#define regexec _regexec -#define regfree _regfree -#define registerrpc _registerrpc -#define res_init _res_init -#define res_mkquery _res_mkquery -#define res_query _res_query -#define res_search _res_search -#define rewinddir _rewinddir -#define rpc_broadcast _rpc_broadcast -#define rpc_broadcast_exp _rpc_broadcast_exp -#define rpc_call _rpc_call -#define rpc_control _rpc_control -#define rpc_reg _rpc_reg -#define rpcb_getmaps _rpcb_getmaps -#define rpcb_gettime _rpcb_gettime -#define rpcb_rmtcall _rpcb_rmtcall -#define rpcb_set _rpcb_set -#define rpcb_taddr2uaddr _rpcb_taddr2uaddr -#define rpcb_uaddr2taddr _rpcb_uaddr2taddr -#define rpcb_unset _rpcb_unset -#define scandir _scandir -#define scanf_l _scanf_l -#define seed48 _seed48 -#define seekdir _seekdir -#define select _select -#define send _send -#define setdomainname _setdomainname -#define setenv _setenv -#define setfsent _setfsent -#define setgrent _setgrent -#define setgroupent _setgroupent -#define sethostent _sethostent -#define sethostname _sethostname -#define setlogin _setlogin -#define setlogmask _setlogmask -#define setlogmask_r _setlogmask_r -#define setmode _setmode -#define setnetconfig _setnetconfig -#define setnetent _setnetent -#define setnetgrent _setnetgrent -#define setpassent _setpassent -#define setnetpath _setnetpath -#define setproctitle _setproctitle -#define setprotoent _setprotoent -#define setprotoent_r _setprotoent_r -#define setpwent _setpwent -#define setrpcent _setrpcent -#define setservent _setservent -#define setservent_r _setservent_r -#define setstate _setstate -#define setttyent _setttyent -#define setttyentpath _setttyentpath -#define settimeofday _settimeofday -#define setusershell _setusershell -#define shm_open _shm_open -#define shm_unlink _shm_unlink -#define shquote _shquote -#define siginterrupt _siginterrupt -#define signal _signal -#define sigtimedwait _sigtimedwait -#define sl_add _sl_add -#define sl_create _sl_create -#define sl_delete _sl_delete -#define sl_find _sl_find -#define sl_free _sl_free -#define sl_init _sl_init -#define sleep _sleep -#ifndef snprintf -#define snprintf _snprintf -#endif -#define snprintf_l _snprintf_l -#define snprintf_ss _snprintf_ss -#define sprintf_l _sprintf_l -#define sradixsort _sradixsort -#define srand48 _srand48 -#define srandom _srandom -#define sscanf_l _sscanf_l -#define statvfs(a, b) _statvfs(a, b) -#define strcasecmp _strcasecmp -#define strcoll_l _strcoll_l -#define strdup _strdup -#define stresep _stresep -#define strftime_l _strftime_l -#define strftime_lz _strftime_lz -#define strftime_z _strftime_z -#define strndup _strndup -#define strncasecmp _strncasecmp -#define strptime _strptime -#define strptime_l _strptime_l -#define strsep _strsep -#define strsignal _strsignal -#define strsuftoll _strsuftoll -#define strsuftollx _strsuftollx -#define strtok_r _strtok_r -#define strnunvisx _strnunvisx -#define strvisx _strvisx -#define strxfrm_l _strxfrm_l -#define svc_auth_reg _svc_auth_reg -#define svc_create _svc_create -#define svc_dg_create _svc_dg_create -#define svc_exit _svc_exit -#define svc_fd_create _svc_fd_create -#define svc_getreq _svc_getreq -#define svc_getreqset _svc_getreqset -#define svc_getreq_common _svc_getreq_common -#define svc_raw_create _svc_raw_create -#define svc_register _svc_register -#define svc_reg _svc_reg -#define svc_run _svc_run -#define svc_sendreply _svc_sendreply -#define svc_tli_create _svc_tli_create -#define svc_tp_create _svc_tp_create -#define svc_unregister _svc_unregister -#define svc_unreg _svc_unreg -#define svc_vc_create _svc_vc_create -#define svcerr_auth _svcerr_auth -#define svcerr_decode _svcerr_decode -#define svcerr_noproc _svcerr_noproc -#define svcerr_noprog _svcerr_noprog -#define svcerr_progvers _svcerr_progvers -#define svcerr_systemerr _svcerr_systemerr -#define svcerr_weakauth _svcerr_weakauth -#define svcfd_create _svcfd_create -#define svcraw_create _svcraw_create -#define svctcp_create _svctcp_create -#define svcudp_bufcreate _svcudp_bufcreate -#define svcudp_create _svcudp_create -#define svcudp_enablecache _svcudp_enablecache -#define sysarch _sys_sysarch -#define swprintf_l _swprintf_l -#define swscanf_l _swscanf_l -#define sysctl _sysctl -#define sysctlbyname _sysctlbyname -#define sysctlgetmibinfo _sysctlgetmibinfo -#define sysctlnametomib _sysctlnametomib -#define syslog _syslog -#define syslog_r _syslog_r -#define syslog_ss _syslog_ss -#define syslogp _syslogp -#define syslogp_r _syslogp_r -#define syslogp_ss _syslogp_ss -#define taddr2uaddr _taddr2uaddr -#define tcdrain _tcdrain -#define tcflow _tcflow -#define tcflush _tcflush -#define tcgetattr _tcgetattr -#define tcgetpgrp _tcgetpgrp -#define tcgetsid _tcgetsid -#define tcsendbreak _tcsendbreak -#define tcsetattr _tcsetattr -#define tcsetpgrp _tcsetpgrp -#define telldir _telldir -#define time _time -#define time2posix _time2posix -#define timegm _timegm -#define timelocal _timelocal -#define timeoff _timeoff -#define times _times -#define ttyname _ttyname -#define ttyname_r _ttyname_r -#define ttyslot _ttyslot -#define tzname _tzname -#define tzset _tzset -#define tzsetwall _tzsetwall -#define uaddr2taddr _uaddr2taddr -#define ualarm _ualarm -#define uname _uname -#define unsetenv _unsetenv -#define user_from_uid _user_from_uid -#define usleep _usleep -#define utime _utime -#define uuid_create_nil _uuid_create_nil -#define uuid_is_nil _uuid_is_nil -#define valloc _valloc -#define vasprintf _vasprintf -#define vasprintf_l _vasprintf_l -#define vdprintf _vdprintf -#ifndef vsnprintf -#define vsnprintf _vsnprintf -#endif -#define vdprintf_l _vdprintf_l -#define vdprintf_l _vdprintf_l -#define vfprintf_l _vfprintf_l -#define vfwprintf_l _vfwprintf_l -#define vprintf_l _vprintf_l -#define vscanf_l _vscanf_l -#define vsscanf_l _vsscanf_l -#define vswscanf_l _vswscanf_l -#define vsnprintf_l _vsnprintf_l -#define vsnprintf_ss _vsnprintf_ss -#define vsprintf_l _vsprintf_l -#define vswprintf_l _vswprintf_l -#define vwprintf_l _vwprintf_l -#define vwscanf_l _vwscanf_l -#define vsyslog _vsyslog -#define vsyslog_r _vsyslog_r -#define vsyslog_ss _vsyslog_ss -#define vsyslogp _vsyslogp -#define vsyslogp_r _vsyslogp_r -#define vsyslogp_ss _vsyslogp_ss -#define wait _wait -#define wait3 _wait3 -#define wait4 _wait4 -#define waitpid _waitpid -#define wcscasecmp _wcscasecmp -#define wcscasecmp_l _wcscasecmp_l -#define wcsdup _wcsdup -#define wcsftime_l _wcsftime_l -#define wcsncasecmp _wcsncasecmp -#define wcsncasecmp_l _wcsncasecmp_l -#define wcstof _wcstof -#define wcstof_l _wcstof_l -#define wcstod _wcstod -#define wcstod_l _wcstod_l -#define wcstold _wcstold -#define wcstold_l _wcstold_l -#define wcwidth _wcwidth -#define wcwidth_l _wcwidth_l -#define wprintf_l _wprintf_l -#define wscanf_l _wscanf_l -#define xdr_accepted_reply _xdr_accepted_reply -#define xdr_array _xdr_array -#define xdr_authunix_parms _xdr_authunix_parms -#define xdr_bool _xdr_bool -#define xdr_bytes _xdr_bytes -#define xdr_callhdr _xdr_callhdr -#define xdr_callmsg _xdr_callmsg -#define xdr_char _xdr_char -#define xdr_datum _xdr_datum -#define xdr_des_block _xdr_des_block -#define xdr_domainname _xdr_domainname -#define xdr_double _xdr_double -#define xdr_enum _xdr_enum -#define xdr_float _xdr_float -#define xdr_free _xdr_free -#define xdr_hyper _xdr_hyper -#define xdr_int _xdr_int -#define xdr_int16_t _xdr_int16_t -#define xdr_int32_t _xdr_int32_t -#define xdr_int64_t _xdr_int64_t -#define xdr_long _xdr_long -#define xdr_longlong_t _xdr_longlong_t -#define xdr_mapname _xdr_mapname -#define xdr_netbuf _xdr_netbuf -#define xdr_netobj _xdr_netobj -#define xdr_opaque _xdr_opaque -#define xdr_opaque_auth _xdr_opaque_auth -#define xdr_peername _xdr_peername -#define xdr_pmap _xdr_pmap -#define xdr_pmaplist _xdr_pmaplist -#define xdr_pointer _xdr_pointer -#define xdr_reference _xdr_reference -#define xdr_rejected_reply _xdr_rejected_reply -#define xdr_replymsg _xdr_replymsg -#define xdr_rmtcall_args _xdr_rmtcall_args -#define xdr_rmtcallres _xdr_rmtcallres -#define xdr_rpcb _xdr_rpcb -#define xdr_rpcb_entry _xdr_rpcb_entry -#define xdr_rpcb_entry_list_ptr _xdr_rpcb_entry_list_ptr -#define xdr_rpcb_rmtcallargs _xdr_rpcb_rmtcallargs -#define xdr_rpcb_rmtcallres _xdr_rpcb_rmtcallres -#define xdr_rpcb_stat _xdr_rpcb_stat -#define xdr_rpcb_stat_byvers _xdr_rpcb_stat_byvers -#define xdr_rpcblist _xdr_rpcblist -#define xdr_rpcblist_ptr _xdr_rpcblist_ptr -#define xdr_rpcbs_addrlist _xdr_rpcbs_addrlist -#define xdr_rpcbs_addrlist_ptr _xdr_rpcbs_addrlist_ptr -#define xdr_rpcbs_proc _xdr_rpcbs_proc -#define xdr_rpcbs_rmtcalllist _xdr_rpcbs_rmtcalllist -#define xdr_rpcbs_rmtcalllist_ptr _xdr_rpcbs_rmtcalllist_ptr -#define xdr_rpcbs _xdr_rpcbs -#define xdr_rpcbs _xdr_rpcbs -#define xdr_short _xdr_short -#define xdr_sizeof _xdr_sizeof -#define xdr_string _xdr_string -#define xdr_u_char _xdr_u_char -#define xdr_u_hyper _xdr_u_hyper -#define xdr_u_int _xdr_u_int -#define xdr_u_int16_t _xdr_u_int16_t -#define xdr_u_int32_t _xdr_u_int32_t -#define xdr_u_int64_t _xdr_u_int64_t -#define xdr_u_long _xdr_u_long -#define xdr_u_longlong_t _xdr_u_longlong_t -#define xdr_u_short _xdr_u_short -#define xdr_union _xdr_union -#define xdr_vector _xdr_vector -#define xdr_void _xdr_void -#define xdr_wrapstring _xdr_wrapstring -#define xdr_yp_inaddr _xdr_yp_inaddr -#define xdr_ypall _xdr_ypall -#define xdr_ypbind_resp _xdr_ypbind_resp -#define xdr_ypbind_setdom _xdr_ypbind_setdom -#define xdr_ypdomain_wrap_string _xdr_ypdomain_wrap_string -#define xdr_ypmap_parms _xdr_ypmap_parms -#define xdr_ypmap_wrap_string _xdr_ypmap_wrap_string -#define xdr_ypmaplist _xdr_ypmaplist -#define xdr_ypowner_wrap_string _xdr_ypowner_wrap_string -#define xdr_yppushresp_xfr _xdr_yppushresp_xfr -#define xdr_ypreq_key _xdr_ypreq_key -#define xdr_ypreq_nokey _xdr_ypreq_nokey -#define xdr_ypreq_xfr _xdr_ypreq_xfr -#define xdr_ypresp_key_val _xdr_ypresp_key_val -#define xdr_ypresp_maplist _xdr_ypresp_maplist -#define xdr_ypresp_master _xdr_ypresp_master -#define xdr_ypresp_order _xdr_ypresp_order -#define xdr_ypresp_val _xdr_ypresp_val -#define xdrmem_create _xdrmem_create -#define xdrrec_create _xdrrec_create -#define xdrrec_endofrecord _xdrrec_endofrecord -#define xdrrec_eof _xdrrec_eof -#define xdrrec_skiprecord _xdrrec_skiprecord -#define xdrstdio_create _xdrstdio_create -#define xprt_register _xprt_register -#define xprt_unregister _xprt_unregister -#define yp_all _yp_all -#define yp_bind _yp_bind -#define yp_first _yp_first -#define yp_get_default_domain _yp_get_default_domain -#define yp_maplist _yp_maplist -#define yp_master _yp_master -#define yp_match _yp_match -#define yp_next _yp_next -#define yp_order _yp_order -#define yp_unbind _yp_unbind -#define yperr_string _yperr_string -#define ypprot_err _ypprot_err -#define yp_setbindtries _yp_setbindtries -#define dlopen __dlopen -#define dlclose __dlclose -#define dlsym __dlsym -#define dlerror __dlerror -#define dladdr __dladdr -#define fmtcheck __fmtcheck - -/* RB trees */ -#define rb_tree_init _rb_tree_init -#define rb_tree_find_node _rb_tree_find_node -#define rb_tree_find_node_geq _rb_tree_find_node_geq -#define rb_tree_find_node_leq _rb_tree_find_node_leq -#define rb_tree_insert_node _rb_tree_insert_node -#define rb_tree_remove_node _rb_tree_remove_node -#define rb_tree_iterate _rb_tree_iterate -#ifdef RBDEBUG -#define rb_tree_check _rb_tree_check -#define rb_tree_depths _rb_tree_depths -#endif - -/* rpc locks */ -#define authdes_lock __rpc_authdes_lock -#define authnone_lock __rpc_authnone_lock -#define authsvc_lock __rpc_authsvc_lock -#define clnt_fd_lock __rpc_clnt_fd_lock -#define clntraw_lock __rpc_clntraw_lock -#define dname_lock __rpc_dname_lock -#define dupreq_lock __rpc_dupreq_lock -#define keyserv_lock __rpc_keyserv_lock -#define libnsl_trace_lock __rpc_libnsl_trace_lock -#define loopnconf_lock __rpc_loopnconf_lock -#define ops_lock __rpc_ops_lock -#define portnum_lock __rpc_portnum_lock -#define proglst_lock __rpc_proglst_lock -#define rpcbaddr_cache_lock __rpc_rpcbaddr_cache_lock -#define rpcsoc_lock __rpc_rpcsoc_lock -#define svc_fd_lock __rpc_svc_fd_lock -#define svc_lock __rpc_svc_lock -#define svcraw_lock __rpc_svcraw_lock -#define xprtlist_lock __rpc_xprtlist_lock - -#define __learn_tree ___learn_tree - -#if defined(__minix) -#define sprofile _sprofile /* LSC: Is this really needed? */ - -/* Needed to allow RS and VM to provide their own implementations. */ -#define munmap _munmap - -#endif /* defined(__minix) */ -#endif /* __weak_alias */ -#endif /* !__lint__ */ - -#endif /* _NAMESPACE_H_ */ diff --git a/lib/libc/include/pathnames.h b/lib/libc/include/pathnames.h deleted file mode 100644 index 5705c6838..000000000 --- a/lib/libc/include/pathnames.h +++ /dev/null @@ -1,33 +0,0 @@ -/* $NetBSD: pathnames.h,v 1.6 2008/05/29 14:51:25 mrg Exp $ */ - -/* - * Copyright (c) 1997 Matthew R. Green - * 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 ``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. - */ - -#ifdef RESCUEDIR -#define _PATH_BIN_RCMD RESCUEDIR "/rcmd" -#else -#define _PATH_BIN_RCMD "/bin/rcmd" -#endif diff --git a/lib/libc/include/port_after.h b/lib/libc/include/port_after.h deleted file mode 100644 index e69de29bb..000000000 diff --git a/lib/libc/include/port_before.h b/lib/libc/include/port_before.h deleted file mode 100644 index c87338979..000000000 --- a/lib/libc/include/port_before.h +++ /dev/null @@ -1,15 +0,0 @@ -#include "namespace.h" -#include -#define ISC_FORMAT_PRINTF(a,b) __attribute__((__format__(__printf__,a,b))) -#define ISC_SOCKLEN_T socklen_t -#ifdef __minix -#define DE_CONST(c,v) v = __UNCONST(c) -#else -#define DE_CONST(c,v) v = ((c) ? \ - strchr((const void *)(c), *(const char *)(const void *)(c)) : NULL) -#endif -#ifndef lint -#define UNUSED(a) (void)&a -#else -#define UNUSED(a) a = a -#endif diff --git a/lib/libc/include/reentrant.h b/lib/libc/include/reentrant.h deleted file mode 100644 index 55be7f022..000000000 --- a/lib/libc/include/reentrant.h +++ /dev/null @@ -1,353 +0,0 @@ -/* $NetBSD: reentrant.h,v 1.18 2015/01/20 18:31:25 christos Exp $ */ - -/*- - * Copyright (c) 1997, 1998, 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin, by Nathan J. Williams, and by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/* - * Requirements: - * - * 1. The thread safe mechanism should be lightweight so the library can - * be used by non-threaded applications without unreasonable overhead. - * - * 2. There should be no dependency on a thread engine for non-threaded - * applications. - * - * 3. There should be no dependency on any particular thread engine. - * - * 4. The library should be able to be compiled without support for thread - * safety. - * - * - * Rationale: - * - * One approach for thread safety is to provide discrete versions of the - * library: one thread safe, the other not. The disadvantage of this is - * that libc is rather large, and two copies of a library which are 99%+ - * identical is not an efficent use of resources. - * - * Another approach is to provide a single thread safe library. However, - * it should not add significant run time or code size overhead to non- - * threaded applications. - * - * Since the NetBSD C library is used in other projects, it should be - * easy to replace the mutual exclusion primitives with ones provided by - * another system. Similarly, it should also be easy to remove all - * support for thread safety completely if the target environment does - * not support threads. - * - * - * Implementation Details: - * - * The thread primitives used by the library (mutex_t, mutex_lock, etc.) - * are macros which expand to the cooresponding primitives provided by - * the thread engine or to nothing. The latter is used so that code is - * not unreasonably cluttered with #ifdefs when all thread safe support - * is removed. - * - * The thread macros can be directly mapped to the mutex primitives from - * pthreads, however it should be reasonably easy to wrap another mutex - * implementation so it presents a similar interface. - * - * The thread functions operate by dispatching to symbols which are, by - * default, weak-aliased to no-op functions in thread-stub/thread-stub.c - * (some uses of thread operations are conditional on __isthreaded, but - * not all of them are). - * - * When the thread library is linked in, it provides strong-alias versions - * of those symbols which dispatch to its own real thread operations. - * - */ - -#if !defined(__minix) || !defined(_LIBC_REENTRANT_H) -#ifdef __minix -/* - * If _REENTRANT is not defined, the header may not be included more than once. - * This is probably a NetBSD libc bug, but for now we solve it for MINIX3 only. - */ -#define _LIBC_REENTRANT_H -#endif /* __minix */ - -/* - * Abstract thread interface for thread-safe libraries. These routines - * will use stubs in libc if the application is not linked against the - * pthread library, and the real function in the pthread library if it - * is. - */ - -#ifndef __minix - -#include -#include - -#define mutex_t pthread_mutex_t -#define MUTEX_INITIALIZER PTHREAD_MUTEX_INITIALIZER - -#define mutexattr_t pthread_mutexattr_t - -#define MUTEX_TYPE_NORMAL PTHREAD_MUTEX_NORMAL -#define MUTEX_TYPE_ERRORCHECK PTHREAD_MUTEX_ERRORCHECK -#define MUTEX_TYPE_RECURSIVE PTHREAD_MUTEX_RECURSIVE - -#define cond_t pthread_cond_t -#define COND_INITIALIZER PTHREAD_COND_INITIALIZER - -#define condattr_t pthread_condattr_t - -#define rwlock_t pthread_rwlock_t -#define RWLOCK_INITIALIZER PTHREAD_RWLOCK_INITIALIZER - -#define rwlockattr_t pthread_rwlockattr_t - -#define thread_key_t pthread_key_t - -#define thr_t pthread_t - -#define thrattr_t pthread_attr_t - -#define once_t pthread_once_t -#define ONCE_INITIALIZER PTHREAD_ONCE_INIT - -#else /* __minix */ - -typedef struct { - int pto_done; -} once_t; -#define ONCE_INITIALIZER { .pto_done = 0 } - -#endif /* __minix */ - -#ifdef _REENTRANT - -#ifndef __LIBC_THREAD_STUBS - -__BEGIN_DECLS -int __libc_mutex_init(mutex_t *, const mutexattr_t *); -int __libc_mutex_lock(mutex_t *); -int __libc_mutex_trylock(mutex_t *); -int __libc_mutex_unlock(mutex_t *); -int __libc_mutex_destroy(mutex_t *); - -int __libc_mutexattr_init(mutexattr_t *); -int __libc_mutexattr_settype(mutexattr_t *, int); -int __libc_mutexattr_destroy(mutexattr_t *); -__END_DECLS - -#define mutex_init(m, a) __libc_mutex_init((m), (a)) -#define mutex_lock(m) __libc_mutex_lock((m)) -#define mutex_trylock(m) __libc_mutex_trylock((m)) -#define mutex_unlock(m) __libc_mutex_unlock((m)) -#define mutex_destroy(m) __libc_mutex_destroy((m)) - -#define mutexattr_init(ma) __libc_mutexattr_init((ma)) -#define mutexattr_settype(ma, t) __libc_mutexattr_settype((ma), (t)) -#define mutexattr_destroy(ma) __libc_mutexattr_destroy((ma)) - -__BEGIN_DECLS -int __libc_cond_init(cond_t *, const condattr_t *); -int __libc_cond_signal(cond_t *); -int __libc_cond_broadcast(cond_t *); -int __libc_cond_wait(cond_t *, mutex_t *); -#ifndef __LIBC12_SOURCE__ -int __libc_cond_timedwait(cond_t *, mutex_t *, const struct timespec *); -#endif -int __libc_cond_destroy(cond_t *); -__END_DECLS - -#define cond_init(c, t, a) __libc_cond_init((c), (a)) -#define cond_signal(c) __libc_cond_signal((c)) -#define cond_broadcast(c) __libc_cond_broadcast((c)) -#define cond_wait(c, m) __libc_cond_wait((c), (m)) -#define cond_timedwait(c, m, t) __libc_cond_timedwait((c), (m), (t)) -#define cond_destroy(c) __libc_cond_destroy((c)) - -__BEGIN_DECLS -int __libc_rwlock_init(rwlock_t *, const rwlockattr_t *); -int __libc_rwlock_rdlock(rwlock_t *); -int __libc_rwlock_wrlock(rwlock_t *); -int __libc_rwlock_tryrdlock(rwlock_t *); -int __libc_rwlock_trywrlock(rwlock_t *); -int __libc_rwlock_unlock(rwlock_t *); -int __libc_rwlock_destroy(rwlock_t *); -__END_DECLS - -#define rwlock_init(l, a) __libc_rwlock_init((l), (a)) -#define rwlock_rdlock(l) __libc_rwlock_rdlock((l)) -#define rwlock_wrlock(l) __libc_rwlock_wrlock((l)) -#define rwlock_tryrdlock(l) __libc_rwlock_tryrdlock((l)) -#define rwlock_trywrlock(l) __libc_rwlock_trywrlock((l)) -#define rwlock_unlock(l) __libc_rwlock_unlock((l)) -#define rwlock_destroy(l) __libc_rwlock_destroy((l)) - -__BEGIN_DECLS -int __libc_thr_keycreate(thread_key_t *, void (*)(void *)); -int __libc_thr_setspecific(thread_key_t, const void *); -void *__libc_thr_getspecific(thread_key_t); -int __libc_thr_keydelete(thread_key_t); -__END_DECLS - -#define thr_keycreate(k, d) __libc_thr_keycreate((k), (d)) -#define thr_setspecific(k, p) __libc_thr_setspecific((k), (p)) -#define thr_getspecific(k) __libc_thr_getspecific((k)) -#define thr_keydelete(k) __libc_thr_keydelete((k)) - -__BEGIN_DECLS -int __libc_thr_once(once_t *, void (*)(void)); -int __libc_thr_sigsetmask(int, const sigset_t *, sigset_t *); -thr_t __libc_thr_self(void); -int __libc_thr_yield(void); -void __libc_thr_create(thr_t *, const thrattr_t *, - void *(*)(void *), void *); -void __libc_thr_exit(void *) __attribute__((__noreturn__)); -int *__libc_thr_errno(void); -int __libc_thr_setcancelstate(int, int *); -unsigned int __libc_thr_curcpu(void); - -extern int __isthreaded; -__END_DECLS - -#define thr_once(o, f) __libc_thr_once((o), (f)) -#define thr_sigsetmask(f, n, o) __libc_thr_sigsetmask((f), (n), (o)) -#define thr_self() __libc_thr_self() -#define thr_yield() __libc_thr_yield() -#define thr_create(tp, ta, f, a) __libc_thr_create((tp), (ta), (f), (a)) -#define thr_exit(v) __libc_thr_exit((v)) -#define thr_errno() __libc_thr_errno() -#define thr_enabled() (__isthreaded) -#define thr_setcancelstate(n, o) __libc_thr_setcancelstate((n),(o)) -#define thr_curcpu() __libc_thr_curcpu() - -#else /* __LIBC_THREAD_STUBS */ - -__BEGIN_DECLS -void __libc_thr_init_stub(void); - -int __libc_mutex_init_stub(mutex_t *, const mutexattr_t *); -int __libc_mutex_lock_stub(mutex_t *); -int __libc_mutex_trylock_stub(mutex_t *); -int __libc_mutex_unlock_stub(mutex_t *); -int __libc_mutex_destroy_stub(mutex_t *); - -int __libc_mutexattr_init_stub(mutexattr_t *); -int __libc_mutexattr_destroy_stub(mutexattr_t *); -int __libc_mutexattr_settype_stub(mutexattr_t *, int); - -int __libc_cond_init_stub(cond_t *, const condattr_t *); -int __libc_cond_signal_stub(cond_t *); -int __libc_cond_broadcast_stub(cond_t *); -int __libc_cond_wait_stub(cond_t *, mutex_t *); -int __libc_cond_timedwait_stub(cond_t *, mutex_t *, - const struct timespec *); -int __libc_cond_destroy_stub(cond_t *); - -int __libc_rwlock_init_stub(rwlock_t *, const rwlockattr_t *); -int __libc_rwlock_rdlock_stub(rwlock_t *); -int __libc_rwlock_wrlock_stub(rwlock_t *); -int __libc_rwlock_tryrdlock_stub(rwlock_t *); -int __libc_rwlock_trywrlock_stub(rwlock_t *); -int __libc_rwlock_unlock_stub(rwlock_t *); -int __libc_rwlock_destroy_stub(rwlock_t *); - -int __libc_thr_keycreate_stub(thread_key_t *, void (*)(void *)); -int __libc_thr_setspecific_stub(thread_key_t, const void *); -void *__libc_thr_getspecific_stub(thread_key_t); -int __libc_thr_keydelete_stub(thread_key_t); - -int __libc_thr_once_stub(once_t *, void (*)(void)); -int __libc_thr_sigsetmask_stub(int, const sigset_t *, sigset_t *); -thr_t __libc_thr_self_stub(void); -int __libc_thr_yield_stub(void); -int __libc_thr_create_stub(thr_t *, const thrattr_t *, - void *(*)(void *), void *); -void __libc_thr_exit_stub(void *) __dead; -int *__libc_thr_errno_stub(void); -int __libc_thr_setcancelstate_stub(int, int *); -int __libc_thr_equal_stub(pthread_t, pthread_t); -unsigned int __libc_thr_curcpu_stub(void); -__END_DECLS - -#endif /* __LIBC_THREAD_STUBS */ - -#define FLOCKFILE(fp) __flockfile_internal(fp, 1) -#define FUNLOCKFILE(fp) __funlockfile_internal(fp, 1) - -#else /* _REENTRANT */ - -#ifndef __empty -#define __empty do {} while (/*CONSTCOND*/0) -#endif -#define mutex_init(m, a) __empty -#define mutex_lock(m) __empty -#define mutex_trylock(m) __empty -#define mutex_unlock(m) __empty -#define mutex_destroy(m) __empty - -#define cond_init(c, t, a) __empty -#define cond_signal(c) __empty -#define cond_broadcast(c) __empty -#define cond_wait(c, m) __empty -#define cond_timedwait(c, m, t) __empty -#define cond_destroy(c) __empty - -#define rwlock_init(l, a) __empty -#define rwlock_rdlock(l) __empty -#define rwlock_wrlock(l) __empty -#define rwlock_tryrdlock(l) __empty -#define rwlock_trywrlock(l) __empty -#define rwlock_unlock(l) __empty -#define rwlock_destroy(l) __empty - -#define thr_keycreate(k, d) /*LINTED*/0 -#define thr_setspecific(k, p) __empty -#define thr_getspecific(k) /*LINTED*/0 -#define thr_keydelete(k) __empty - -#define mutexattr_init(ma) __empty -#define mutexattr_settype(ma, t) __empty -#define mutexattr_destroy(ma) __empty - -static inline int -thr_once(once_t *once_control, void (*routine)(void)) -{ - if (__predict_false(once_control->pto_done == 0)) { - (*routine)(); - once_control->pto_done = 1; - } - return 0; -} -#define thr_sigsetmask(f, n, o) __empty -#define thr_self() __empty -#define thr_errno() __empty -#define thr_curcpu() ((unsigned int)0) - -#define FLOCKFILE(fp) __empty -#define FUNLOCKFILE(fp) __empty - -#endif /* _REENTRANT */ - -#endif /* !defined(__minix) || !defined(_LIBC_REENTRANT_H) */ diff --git a/lib/libc/include/resolv_mt.h b/lib/libc/include/resolv_mt.h deleted file mode 100644 index 73a8dcc18..000000000 --- a/lib/libc/include/resolv_mt.h +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: resolv_mt.h,v 1.1.1.3 2009/04/12 16:35:44 christos Exp $ */ - -#ifndef _RESOLV_MT_H -#define _RESOLV_MT_H - -#include -#include -#include -#include - -/* Access functions for the libresolv private interface */ - -int __res_enable_mt(void); -int __res_disable_mt(void); - -/* Per-thread context */ - -typedef struct { -int no_hosts_fallback_private; -int retry_save; -int retry_private; -char inet_nsap_ntoa_tmpbuf[255*3]; -char sym_ntos_unname[20]; -char sym_ntop_unname[20]; -char p_option_nbuf[40]; -char p_time_nbuf[40]; -char precsize_ntoa_retbuf[sizeof "90000000.00"]; -char loc_ntoa_tmpbuf[sizeof -"1000 60 60.000 N 1000 60 60.000 W -12345678.00m 90000000.00m 90000000.00m 90000000.00m"]; -char p_secstodate_output[15]; -} mtctxres_t; - -/* Thread-specific data (TSD) */ - -mtctxres_t *___mtctxres(void); -#define mtctxres (___mtctxres()) - -/* Various static data that should be TSD */ - -#define sym_ntos_unname (mtctxres->sym_ntos_unname) -#define sym_ntop_unname (mtctxres->sym_ntop_unname) -#define inet_nsap_ntoa_tmpbuf (mtctxres->inet_nsap_ntoa_tmpbuf) -#define p_option_nbuf (mtctxres->p_option_nbuf) -#define p_time_nbuf (mtctxres->p_time_nbuf) -#define precsize_ntoa_retbuf (mtctxres->precsize_ntoa_retbuf) -#define loc_ntoa_tmpbuf (mtctxres->loc_ntoa_tmpbuf) -#define p_secstodate_output (mtctxres->p_secstodate_output) - -#endif /* _RESOLV_MT_H */ diff --git a/lib/libc/inet/Makefile.inc b/lib/libc/inet/Makefile.inc deleted file mode 100644 index 28cf81625..000000000 --- a/lib/libc/inet/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2014/01/16 20:31:43 christos Exp $ - -# net sources -.PATH: ${.CURDIR}/inet - -SRCS+= inet_addr.c inet_cidr_ntop.c \ - inet_cidr_pton.c inet_lnaof.c inet_makeaddr.c \ - inet_net_ntop.c inet_net_pton.c inet_neta.c inet_netof.c \ - inet_network.c inet_ntoa.c inet_ntop.c inet_pton.c nsap_addr.c diff --git a/lib/libc/inet/inet.3 b/lib/libc/inet/inet.3 deleted file mode 100644 index d028c5e7b..000000000 --- a/lib/libc/inet/inet.3 +++ /dev/null @@ -1,401 +0,0 @@ -.\" $NetBSD: inet.3,v 1.5 2012/07/25 14:51:15 ginsbach Exp $ -.\" -.\" Copyright (c) 1983, 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)inet.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd July 25, 2012 -.Dt INET 3 -.Os -.Sh NAME -.Nm inet_addr , -.Nm inet_aton , -.Nm inet_lnaof , -.Nm inet_makeaddr , -.Nm inet_netof , -.Nm inet_network , -.Nm inet_ntoa , -.Nm inet_ntop , -.Nm inet_pton , -.Nm addr , -.Nm ntoa , -.Nm network -.Nd Internet address manipulation routines -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In arpa/inet.h -.Ft in_addr_t -.Fn inet_addr "const char *cp" -.Ft int -.Fn inet_aton "const char *cp" "struct in_addr *addr" -.Ft in_addr_t -.Fn inet_lnaof "struct in_addr in" -.Ft struct in_addr -.Fn inet_makeaddr "in_addr_t net" "in_addr_t lna" -.Ft in_addr_t -.Fn inet_netof "struct in_addr in" -.Ft in_addr_t -.Fn inet_network "const char *cp" -.Ft char * -.Fn inet_ntoa "struct in_addr in" -.Ft const char * -.Fn inet_ntop "int af" "const void * restrict src" "char * restrict dst" "socklen_t size" -.Ft int -.Fn inet_pton "int af" "const char * restrict src" "void * restrict dst" -.Sh DESCRIPTION -The routines -.Fn inet_aton , -.Fn inet_addr -and -.Fn inet_network -interpret character strings representing -numbers expressed in the Internet standard -.Qq dotted quad -notation. -.Pp -The -.Fn inet_pton -function converts a presentation format address (that is, printable form -as held in a character string) to network format (usually a -.Ft struct in_addr -or some other internal binary representation, in network byte order). -It returns 1 if the address was valid for the specified address family, or -0 if the address wasn't parsable in the specified address family, or -1 -if some system error occurred (in which case -.Va errno -will have been set). -This function is presently valid for -.Dv AF_INET -and -.Dv AF_INET6 . -.Pp -The -.Fn inet_aton -routine interprets the specified character string as an Internet address, -placing the address into the structure provided. -It returns 1 if the string was successfully interpreted, -or 0 if the string is invalid. -.Pp -The -.Fn inet_addr -and -.Fn inet_network -functions return numbers suitable for use -as Internet addresses and Internet network -numbers, respectively. -.Pp -The function -.Fn inet_ntop -converts an address from network format (usually a -.Ft struct in_addr -or some other binary form, in network byte order) to presentation format -(suitable for external display purposes). -It returns NULL if a system error occurs (in which case, -.Va errno -will have been set), or it returns a pointer to the destination string. -The -.Ar size -parameter is the size of the -.Ar buf -argument. -.Pp -The routine -.Fn inet_ntoa -takes an Internet address and returns an -.Tn ASCII -string representing the address in -.Qq dotted quad -notation. -.Pp -The routine -.Fn inet_makeaddr -takes an Internet network number and a local network address (both in -host order) and constructs an Internet address from it. -Note that to convert only a single value to a -.Ft struct in_addr -form that value should be passed as the first parameter and -.Ql 0L -should be given for the second parameter. -.Pp -The routines -.Fn inet_netof -and -.Fn inet_lnaof -break apart Internet host addresses, returning the network number and -local network address part, respectively (both in host order). -.Pp -All Internet addresses are returned in network -order (bytes ordered from left to right). -All network numbers and local address parts are -returned as machine format integer values. -.Sh INTERNET ADDRESSES (IP VERSION 4) -Values specified using the -.Qq dotted quad -notation take one -of the following forms: -.Bd -literal -offset indent -a.b.c.d -a.b.c -a.b -a -.Ed -.Pp -When four parts are specified, each is interpreted -as a byte of data and assigned, from left to right, -to the four bytes of an Internet address. -Note that when an Internet address is viewed as a 32-bit -integer quantity on a system that uses little-endian -byte order (e.g. -.Tn Intel i386, i486 -and -.Tn Pentium -processors) the bytes referred to above appear as -.Dq Li d.c.b.a . -That is, little-endian bytes are ordered from right to left. -.Pp -When a three part address is specified, the last -part is interpreted as a 16-bit quantity and placed -in the right-most two bytes of the network address. -This makes the three part address format convenient -for specifying Class B network addresses as -.Dq Li 128.net.host . -.Pp -When a two part address is supplied, the last part -is interpreted as a 24-bit quantity and placed in -the right most three bytes of the network address. -This makes the two part address format convenient -for specifying Class A network addresses as -.Dq Li net.host . -.Pp -When only one part is given, the value is stored -directly in the network address without any byte -rearrangement. -.Pp -All numbers supplied as -.Dq parts -in a -.Qq dotted quad -notation -may be decimal, octal, or hexadecimal, as specified -in the C language (i.e., a leading 0x or 0X implies -hexadecimal; otherwise, a leading 0 implies octal; -otherwise, the number is interpreted as decimal). -.Sh INTERNET ADDRESSES (IP VERSION 6) -In order to support scoped IPv6 addresses, -the use of -.Xr getaddrinfo 3 -and -.Xr getnameinfo 3 -is recommended rather than the functions presented here. -.Pp -The presentation format of an IPv6 address is given in RFC 2373: -.Pp -There are three conventional forms for representing IPv6 addresses as -text strings: -.Bl -enum -.It -The preferred form is x:x:x:x:x:x:x:x, where the 'x's are the -hexadecimal values of the eight 16-bit pieces of the address. -Examples: -.Bd -literal -offset indent -FEDC:BA98:7654:3210:FEDC:BA98:7654:3210 -1080:0:0:0:8:800:200C:417A -.Ed -.Pp -Note that it is not necessary to write the leading zeros in an -individual field, but there must be at least one numeral in -every field (except for the case described in 2). -.It -Due to the method of allocating certain styles of IPv6 -addresses, it will be common for addresses to contain long -strings of zero bits. -In order to make writing addresses -containing zero bits easier, a special syntax is available to -compress the zeros. -The use of ``::'' indicates multiple groups of 16-bits of zeros. -The ``::'' can only appear once in an address. -The ``::'' can also be used to compress the leading -and/or trailing zeros in an address. -.Pp -For example the following addresses: -.Bd -literal -offset indent -1080:0:0:0:8:800:200C:417A a unicast address -FF01:0:0:0:0:0:0:43 a multicast address -0:0:0:0:0:0:0:1 the loopback address -0:0:0:0:0:0:0:0 the unspecified addresses -.Ed -.Pp -may be represented as: -.Bd -literal -offset indent -1080::8:800:200C:417A a unicast address -FF01::43 a multicast address -::1 the loopback address -:: the unspecified addresses -.Ed -.It -An alternative form that is sometimes more convenient when -dealing with a mixed environment of IPv4 and IPv6 nodes is -x:x:x:x:x:x:d.d.d.d, where the 'x's are the hexadecimal values -of the six high-order 16-bit pieces of the address, and the 'd's -are the decimal values of the four low-order 8-bit pieces of the -address (standard IPv4 representation). -Examples: -.Bd -literal -offset indent -0:0:0:0:0:0:13.1.68.3 -0:0:0:0:0:FFFF:129.144.52.38 -.Ed -.Pp -or in compressed form: -.Bd -literal -offset indent -::13.1.68.3 -::FFFF:129.144.52.38 -.Ed -.El -.Sh DIAGNOSTICS -The constant -.Dv INADDR_NONE -is returned by -.Fn inet_addr -and -.Fn inet_network -for malformed requests. -.Sh ERRORS -The -.Fn inet_ntop -and -.Fn inet_pton -functions may fail with -.Bl -tag -width Er -.It Bq Er EAFNOSUPPORT -The value of -.Fa af -was not -.Dv AF_INET -or -.Dv AF_INET6 . -.El -.Pp -The -.Fn inet_ntop -function may fail with -.Bl -tag -width Er -.It Bq Er ENOSPC -The -.Fa size -indicated for -.Fa dst -was too small to store the presentation form of the network address. -.El -.Sh SEE ALSO -.Xr byteorder 3 , -.Xr gethostbyname 3 , -.Xr getnetent 3 , -.Xr inet_net 3 , -.Xr hosts 5 , -.Xr networks 5 -.Rs -.%R RFC 2373 -.%D July 1998 -.%T "IP Version 6 Addressing Architecture" -.Re -.Rs -.%R RFC 3493 -.%D February 2003 -.%T "Basic Socket Interface Extensions for IPv6" -.Re -.Sh STANDARDS -The -.Fn inet_ntop -and -.Fn inet_pton -functions conform to -.St -p1003.1-2001 . -Note that -.Fn inet_pton -does not accept 1-, 2-, or 3-part dotted addresses; all four parts -must be specified. -Additionally all four parts of a dotted address must be decimal. -This is a narrower input set than that accepted by -.Fn inet_aton . -.Sh HISTORY -The -.Fn inet_addr , -.Fn inet_network , -.Fn inet_makeaddr , -.Fn inet_lnaof -and -.Fn inet_netof -functions appeared in -.Bx 4.2 . -They were changed to use -.Vt in_addr_t -in place of -.Vt unsigned long -in -.Nx 2.0 . -The -.Fn inet_aton -and -.Fn inet_ntoa -functions appeared in -.Bx 4.3 . -The -.Fn inet_pton -and -.Fn inet_ntop -functions appeared in BIND 4.9.4 and thence -.Nx 1.3 ; -they were also in -.St -xns5.2 . -.Sh BUGS -The value -.Dv INADDR_NONE -(0xffffffff) is a valid broadcast address, but -.Fn inet_addr -cannot return that value without indicating failure. -The newer -.Fn inet_aton -function does not share this problem. -.Pp -The problem of host byte ordering versus network byte ordering is -confusing. -.Pp -The string returned by -.Fn inet_ntoa -resides in a static memory area. -.Pp -The function -.Fn inet_addr -should return a -.Vt struct in_addr . -.Pp -The function -.Fn inet_network -does not support byte rearrangement for one, two, and three -part addresses. diff --git a/lib/libc/inet/inet6_option_space.3 b/lib/libc/inet/inet6_option_space.3 deleted file mode 100644 index c6407ae3f..000000000 --- a/lib/libc/inet/inet6_option_space.3 +++ /dev/null @@ -1,448 +0,0 @@ -.\" $NetBSD: inet6_option_space.3,v 1.3 2010/03/22 19:30:54 joerg Exp $ -.\" $KAME: inet6_option_space.3,v 1.7 2000/05/17 14:32:13 itojun Exp $ -.\" -.\" Copyright (c) 1983, 1987, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd December 10, 1999 -.Dt INET6_OPTION_SPACE 3 -.Os -.\" -.Sh NAME -.Nm inet6_option_space , -.Nm inet6_option_init , -.Nm inet6_option_append , -.Nm inet6_option_alloc , -.Nm inet6_option_next , -.Nm inet6_option_find -.Nd IPv6 Hop-by-Hop and Destination Options manipulation -.\" -.Sh SYNOPSIS -.In netinet/in.h -.Ft "int" -.Fn inet6_option_space "int nbytes" -.Ft "int" -.Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type" -.Ft "int" -.Fn inet6_option_append "struct cmsghdr *cmsg" "const uint8_t *typep" "int multx" "int plusy" -.Ft "uint8_t *" -.Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy" -.Ft "int" -.Fn inet6_option_next "const struct cmsghdr *cmsg" "uint8_t **tptrp" -.Ft "int" -.Fn inet6_option_find "const struct cmsghdr *cmsg" "uint8_t **tptrp" "int type" -.\" -.Sh DESCRIPTION -.\" -Building and parsing the Hop-by-Hop and Destination options is -complicated due to alignment constraints, padding and -ancillary data manipulation. -RFC 2292 defines a set of functions to help the application. -The function prototypes for -these functions are all in the -.In netinet/in.h -header. -.\" -.Ss inet6_option_space -.Fn inet6_option_space -returns the number of bytes required to hold an option when it is stored as -ancillary data, including the -.Li cmsghdr -structure at the beginning, -and any padding at the end -.Po -to make its size a multiple of 8 bytes -.Pc . -The argument is the size of the structure defining the option, -which must include any pad bytes at the beginning -.Po -the value -.Li y -in the alignment term -.Dq Li xn + y -.Pc , -the type byte, the length byte, and the option data. -.Pp -Note: If multiple options are stored in a single ancillary data -object, which is the recommended technique, this function -overestimates the amount of space required by the size of -.Li N-1 -.Li cmsghdr -structures, -where -.Li N -is the number of options to be stored in the object. -This is of little consequence, since it is assumed that most -Hop-by-Hop option headers and Destination option headers carry only -one option -.Pq appendix B of [RFC 2460] . -.\" -.Ss inet6_option_init -.Fn inet6_option_init -is called once per ancillary data object that will -contain either Hop-by-Hop or Destination options. -It returns -.Li 0 -on success or -.Li -1 -on an error. -.Pp -.Fa bp -is a pointer to previously allocated space that will contain the -ancillary data object. -It must be large enough to contain all the -individual options to be added by later calls to -.Fn inet6_option_append -and -.Fn inet6_option_alloc . -.Pp -.Fa cmsgp -is a pointer to a pointer to a -.Li cmsghdr -structure. -.Fa *cmsgp -is initialized by this function to point to the -.Li cmsghdr -structure constructed by this function in the buffer pointed to by -.Fa bp . -.Pp -.Fa type -is either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -This -.Fa type -is stored in the -.Li cmsg_type -member of the -.Li cmsghdr -structure pointed to by -.Fa *cmsgp . -.\" -.Ss inet6_option_append -This function appends a Hop-by-Hop option or a Destination option -into an ancillary data object that has been initialized by -.Fn inet6_option_init . -This function returns -.Li 0 -if it succeeds or -.Li -1 -on an error. -.Pp -.Fa cmsg -is a pointer to the -.Li cmsghdr -structure that must have been -initialized by -.Fn inet6_option_init . -.Pp -.Fa typep -is a pointer to the 8-bit option type. -It is assumed that this -field is immediately followed by the 8-bit option data length field, -which is then followed immediately by the option data. -The caller -initializes these three fields -.Pq the type-length-value, or TLV -before calling this function. -.Pp -The option type must have a value from -.Li 2 -to -.Li 255 , -inclusive. -.Po -.Li 0 -and -.Li 1 -are reserved for the -.Li Pad1 -and -.Li PadN -options, respectively. -.Pc -.Pp -The option data length must have a value between -.Li 0 -and -.Li 255 , -inclusive, and is the length of the option data that follows. -.Pp -.Fa multx -is the value -.Li x -in the alignment term -.Dq Li xn + y . -It must have a value of -.Li 1 , -.Li 2 , -.Li 4 , -or -.Li 8 . -.Pp -.Fa plusy -is the value -.Li y -in the alignment term -.Dq Li xn + y . -It must have a value between -.Li 0 -and -.Li 7 , -inclusive. -.\" -.Ss inet6_option_alloc -This function appends a Hop-by-Hop option or a Destination option -into an ancillary data object that has been initialized by -.Fn inet6_option_init . -This function returns a pointer to the 8-bit -option type field that starts the option on success, or -.Dv NULL -on an error. -.Pp -The difference between this function and -.Fn inet6_option_append -is that the latter copies the contents of a previously built option into -the ancillary data object while the current function returns a -pointer to the space in the data object where the option's TLV must -then be built by the caller. -.Pp -.Fa cmsg -is a pointer to the -.Li cmsghdr -structure that must have been -initialized by -.Fn inet6_option_init . -.Pp -.Fa datalen -is the value of the option data length byte for this option. -This value is required as an argument to allow the function to -determine if padding must be appended at the end of the option. -.Po -The -.Fn inet6_option_append -function does not need a data length argument -since the option data length must already be stored by the caller. -.Pc -.Pp -.Fa multx -is the value -.Li x -in the alignment term -.Dq Li xn + y . -It must have a value of -.Li 1 , -.Li 2 , -.Li 4 , -or -.Li 8 . -.Pp -.Fa plusy -is the value -.Li y -in the alignment term -.Dq Li xn + y . -It must have a value between -.Li 0 -and -.Li 7 , -inclusive. -.\" -.Ss inet6_option_next -This function processes the next Hop-by-Hop option or Destination -option in an ancillary data object. -If another option remains to be -processed, the return value of the function is -.Li 0 -and -.Fa *tptrp -points to -the 8-bit option type field -.Po -which is followed by the 8-bit option -data length, followed by the option data -.Pc . -If no more options remain -to be processed, the return value is -.Li -1 -and -.Fa *tptrp -is -.Dv NULL . -If an error occurs, the return value is -.Li -1 -and -.Fa *tptrp -is not -.Dv NULL . -.Pp -.Fa cmsg -is a pointer to -.Li cmsghdr -structure of which -.Li cmsg_level -equals -.Dv IPPROTO_IPV6 -and -.Li cmsg_type -equals either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -.Pp -.Fa tptrp -is a pointer to a pointer to an 8-bit byte and -.Fa *tptrp -is used -by the function to remember its place in the ancillary data object -each time the function is called. -The first time this function is -called for a given ancillary data object, -.Fa *tptrp -must be set to -.Dv NULL . -.Pp -Each time this function returns success, -.Fa *tptrp -points to the 8-bit -option type field for the next option to be processed. -.\" -.Ss inet6_option_find -This function is similar to the previously described -.Fn inet6_option_next -function, except this function lets the caller -specify the option type to be searched for, instead of always -returning the next option in the ancillary data object. -.Fa cmsg -is a -pointer to -.Li cmsghdr -structure of which -.Li cmsg_level -equals -.Dv IPPROTO_IPV6 -and -.Li cmsg_type -equals either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -.Pp -.Fa tptrp -is a pointer to a pointer to an 8-bit byte and -.Fa *tptrp -is used -by the function to remember its place in the ancillary data object -each time the function is called. -The first time this function is -called for a given ancillary data object, -.Fa *tptrp -must be set to -.Dv NULL . -.Pa -This function starts searching for an option of the specified type -beginning after the value of -.Fa *tptrp . -If an option of the specified -type is located, this function returns -.Li 0 -and -.Fa *tptrp -points to the 8- -bit option type field for the option of the specified type. -If an -option of the specified type is not located, the return value is -.Li -1 -and -.Fa *tptrp -is -.Dv NULL . -If an error occurs, the return value is -.Li -1 -and -.Fa *tptrp -is not -.Dv NULL . -.\" -.Sh EXAMPLES -RFC 2292 gives comprehensive examples in chapter 6. -.\" -.Sh DIAGNOSTICS -.Fn inet6_option_init -and -.Fn inet6_option_append -return -.Li 0 -on success or -.Li -1 -on an error. -.Pp -.Fn inet6_option_alloc -returns -.Dv NULL -on an error. -.Pp -On errors, -.Fn inet6_option_next -and -.Fn inet6_option_find -return -.Li -1 -setting -.Fa *tptrp -to non -.Dv NULL -value. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%T "Advanced Sockets API for IPv6" -.%N RFC 2292 -.%D February 1998 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC 2460 -.%D December 1998 -.Re -.\" -.Sh STANDARDS -The functions -are documented in -.Dq Advanced Sockets API for IPv6 -.Pq RFC 2292 . -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. -.\" -.Sh BUGS -The text was shamelessly copied from RFC 2292. diff --git a/lib/libc/inet/inet6_rthdr_space.3 b/lib/libc/inet/inet6_rthdr_space.3 deleted file mode 100644 index 50f852cc4..000000000 --- a/lib/libc/inet/inet6_rthdr_space.3 +++ /dev/null @@ -1,321 +0,0 @@ -.\" $NetBSD: inet6_rthdr_space.3,v 1.2 2010/03/22 19:30:54 joerg Exp $ -.\" $KAME: inet6_rthdr_space.3,v 1.8 2000/05/17 14:30:15 itojun Exp $ -.\" -.\" Copyright (c) 1983, 1987, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd December 10, 1999 -.Dt INET6_RTHDR_SPACE 3 -.Os -.\" -.Sh NAME -.Nm inet6_rthdr_space , -.Nm inet6_rthdr_init , -.Nm inet6_rthdr_add , -.Nm inet6_rthdr_lasthop , -.Nm inet6_rthdr_reverse , -.Nm inet6_rthdr_segments , -.Nm inet6_rthdr_getaddr , -.Nm inet6_rthdr_getflags -.Nd IPv6 Routing Header Options manipulation -.\" -.Sh SYNOPSIS -.In netinet/in.h -.Ft size_t -.Fn inet6_rthdr_space "int type" "int segments" -.Ft "struct cmsghdr *" -.Fn inet6_rthdr_init "void *bp" "int type" -.Ft int -.Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags" -.Ft int -.Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags" -.Ft int -.Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out" -.Ft int -.Fn inet6_rthdr_segments "const struct cmsghdr *cmsg" -.Ft "struct in6_addr *" -.Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index" -.Ft int -.Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index" -.\" -.Sh DESCRIPTION -RFC 2292 IPv6 advanced API defines eight -functions that the application calls to build and examine a Routing -header. -Four functions build a Routing header: -.Bl -hang -.It Fn inet6_rthdr_space -return #bytes required for ancillary data -.It Fn inet6_rthdr_init -initialize ancillary data for Routing header -.It Fn inet6_rthdr_add -add IPv6 address \*[Am] flags to Routing header -.It Fn inet6_rthdr_lasthop -specify the flags for the final hop -.El -.Pp -Four functions deal with a returned Routing header: -.Bl -hang -.It Fn inet6_rthdr_reverse -reverse a Routing header -.It Fn inet6_rthdr_segments -return #segments in a Routing header -.It Fn inet6_rthdr_getaddr -fetch one address from a Routing header -.It Fn inet6_rthdr_getflags -fetch one flag from a Routing header -.El -.Pp -The function prototypes for these functions are all in the -.In netinet/in.h -header. -.\" -.Ss inet6_rthdr_space -This function returns the number of bytes required to hold a Routing -header of the specified -.Fa type -containing the specified number of -.Fa segments -.Pq addresses . -For an IPv6 Type 0 Routing header, the number -of segments must be between 1 and 23, inclusive. -The return value -includes the size of the cmsghdr structure that precedes the Routing -header, and any required padding. -.Pp -If the return value is 0, then either the type of the Routing header -is not supported by this implementation or the number of segments is -invalid for this type of Routing header. -.Pp -Note: This function returns the size but does not allocate the space -required for the ancillary data. -This allows an application to -allocate a larger buffer, if other ancillary data objects are -desired, since all the ancillary data objects must be specified to -.Xr sendmsg 2 -as a single -.Li msg_control -buffer. -.\" -.Ss inet6_rthdr_init -This function initializes the buffer pointed to by -.Fa bp -to contain a -.Li cmsghdr -structure followed by a Routing header of the specified -.Fa type . -The -.Li cmsg_len -member of the -.Li cmsghdr -structure is initialized to the -size of the structure plus the amount of space required by the -Routing header. -The -.Li cmsg_level -and -.Li cmsg_type -members are also initialized as required. -.Pp -The caller must allocate the buffer and its size can be determined by -calling -.Fn inet6_rthdr_space . -.Pp -Upon success the return value is the pointer to the -.Li cmsghdr -structure, and this is then used as the first argument to the next -two functions. -Upon an error the return value is -.Dv NULL . -.\" -.Ss inet6_rthdr_add -This function adds the address pointed to by -.Fa addr -to the end of the -Routing header being constructed and sets the type of this hop to the -value of -.Fa flags . -For an IPv6 Type 0 Routing header, -.Fa flags -must be -either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -If successful, the -.Li cmsg_len -member of the -.Li cmsghdr -structure is -updated to account for the new address in the Routing header and the -return value of the function is 0. -Upon an error the return value of -the function is -1. -.\" -.Ss inet6_rthdr_lasthop -This function specifies the Strict/Loose flag for the final hop of a -Routing header. -For an IPv6 Type 0 Routing header, -.Fa flags -must be either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -The return value of the function is 0 upon success, or -1 upon an error. -.Pp -Notice that a Routing header specifying -.Li N -intermediate nodes requires -.Li N+1 -Strict/Loose flags. -This requires -.Li N -calls to -.Fn inet6_rthdr_add -followed by one call to -.Fn inet6_rthdr_lasthop . -.\" -.Ss inet6_rthdr_reverse -This function takes a Routing header that was received as ancillary -data -.Po -pointed to by the first argument, -.Fa in -.Pc -and writes a new Routing -header that sends datagrams along the reverse of that route. -Both -arguments are allowed to point to the same buffer -.Pq that is, the reversal can occur in place . -.Pp -The return value of the function is 0 on success, or -1 upon an -error. -.\" -.Ss inet6_rthdr_segments -This function returns the number of segments -.Pq addresses -contained in -the Routing header described by -.Fa cmsg . -On success the return value is -between 1 and 23, inclusive. -The return value of the function is -1 upon an error. -.\" -.Ss inet6_rthdr_getaddr -This function returns a pointer to the IPv6 address specified by -.Fa index -.Po -which must have a value between 1 and the value returned by -.Fn inet6_rthdr_segments -.Pc -in the Routing header described by -.Fa cmsg . -An -application should first call -.Fn inet6_rthdr_segments -to obtain the number of segments in the Routing header. -.Pp -Upon an error the return value of the function is -.Dv NULL . -.\" -.Ss inet6_rthdr_getflags -This function returns the flags value specified by -.Fa index -.Po -which must -have a value between 0 and the value returned by -.Fn inet6_rthdr_segments -.Pc -in the Routing header described by -.Fa cmsg . -For an IPv6 Type 0 Routing header the return value will be either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -Upon an error the return value of the function is -1. -.Pp -Note: Addresses are indexed starting at 1, and flags starting at 0, -to maintain consistency with the terminology and figures in RFC 2460. -.\" -.Sh EXAMPLES -RFC 2292 gives comprehensive examples in chapter 8. -.\" -.Sh DIAGNOSTICS -.Fn inet6_rthdr_space -returns 0 on errors. -.Pp -.Fn inet6_rthdr_add , -.Fn inet6_rthdr_lasthop -and -.Fn inet6_rthdr_reverse -return 0 on success, and returns -1 on error. -.Pp -.Fn inet6_rthdr_init -and -.Fn inet6_rthdr_getaddr -return -.Dv NULL -on error. -.Pp -.Fn inet6_rthdr_segments -and -.Fn inet6_rthdr_getflags -return -1 on error. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%T "Advanced Sockets API for IPv6" -.%N RFC 2292 -.%D February 1998 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC 2460 -.%D December 1998 -.Re -.\" -.Sh STANDARDS -The functions -are documented in -.Dq Advanced Sockets API for IPv6 -.Pq RFC 2292 . -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. -.\" -.Sh BUGS -The text was shamelessly copied from RFC 2292. -.Pp -.Fn inet6_rthdr_reverse -is not implemented yet. diff --git a/lib/libc/inet/inet_cidr_ntop.c b/lib/libc/inet/inet_cidr_ntop.c deleted file mode 100644 index 0f9202586..000000000 --- a/lib/libc/inet/inet_cidr_ntop.c +++ /dev/null @@ -1,277 +0,0 @@ -/* $NetBSD: inet_cidr_ntop.c,v 1.8 2012/03/13 21:13:38 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1998,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: inet_cidr_ntop.c,v 1.7 2006/10/11 02:18:18 marka Exp"; -#else -__RCSID("$NetBSD: inet_cidr_ntop.c,v 1.8 2012/03/13 21:13:38 christos Exp $"); -#endif -#endif - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef __weak_alias -__weak_alias(inet_cidr_ntop,_inet_cidr_ntop) -#endif - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - -static char * -inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size); -static char * -inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size); - -/*% - * char * - * inet_cidr_ntop(af, src, bits, dst, size) - * convert network address from network to presentation format. - * "src"'s size is determined from its "af". - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * 192.5.5.1/28 has a nonzero host part, which means it isn't a network - * as called for by inet_net_ntop() but it can be a host address with - * an included netmask. - * author: - * Paul Vixie (ISC), October 1998 - */ -char * -inet_cidr_ntop(int af, const void *src, int bits, char *dst, size_t size) { - switch (af) { - case AF_INET: - return (inet_cidr_ntop_ipv4(src, bits, dst, size)); - case AF_INET6: - return (inet_cidr_ntop_ipv6(src, bits, dst, size)); - default: - errno = EAFNOSUPPORT; - return (NULL); - } -} - -static int -decoct(const u_char *src, size_t bytes, char *dst, size_t size) { - char *odst = dst; - char *t; - size_t b; - - for (b = 1; b <= bytes; b++) { - if (size < sizeof "255.") - return (0); - t = dst; - dst += SPRINTF((dst, "%u", *src++)); - if (b != bytes) { - *dst++ = '.'; - *dst = '\0'; - } - size -= (size_t)(dst - t); - } - _DIAGASSERT(__type_fit(int, dst - odst)); - return (int)(dst - odst); -} - -/*% - * static char * - * inet_cidr_ntop_ipv4(src, bits, dst, size) - * convert IPv4 network address from network to presentation format. - * "src"'s size is determined from its "af". - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * network byte order assumed. this means 192.5.5.240/28 has - * 0b11110000 in its fourth octet. - * author: - * Paul Vixie (ISC), October 1998 - */ -static char * -inet_cidr_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) { - char *odst = dst; - size_t len = 4; - size_t b; - size_t bytes; - - if ((bits < -1) || (bits > 32)) { - errno = EINVAL; - return (NULL); - } - - /* Find number of significant bytes in address. */ - if (bits == -1) - len = 4; - else - for (len = 1, b = 1 ; b < 4U; b++) - if (*(src + b)) - len = b + 1; - - /* Format whole octets plus nonzero trailing octets. */ - bytes = (((bits <= 0) ? 1 : bits) + 7) / 8; - if (len > bytes) - bytes = len; - b = decoct(src, bytes, dst, size); - if (b == 0U) - goto emsgsize; - dst += b; - size -= b; - - if (bits != -1) { - /* Format CIDR /width. */ - if (size < sizeof "/32") - goto emsgsize; - dst += SPRINTF((dst, "/%u", bits)); - } - - return (odst); - - emsgsize: - errno = EMSGSIZE; - return (NULL); -} - -static char * -inet_cidr_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) { - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255/128"]; - char *tp; - struct { int base, len; } best, cur; - u_int words[NS_IN6ADDRSZ / NS_INT16SZ]; - int i; - - if ((bits < -1) || (bits > 128)) { - errno = EINVAL; - return (NULL); - } - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof words); - for (i = 0; i < NS_IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - best.len = 0; - cur.base = -1; - cur.len = 0; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) - *tp++ = ':'; - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && (best.len == 6 || - (best.len == 7 && words[7] != 0x0001) || - (best.len == 5 && words[5] == 0xffff))) { - size_t n; - - if (src[15] || bits == -1 || bits > 120) - n = 4; - else if (src[14] || bits > 112) - n = 3; - else - n = 2; - n = decoct(src+12, n, tp, sizeof tmp - (tp - tmp)); - if (n == 0) { - errno = EMSGSIZE; - return (NULL); - } - tp += strlen(tp); - break; - } - tp += SPRINTF((tp, "%x", words[i])); - } - - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == - (NS_IN6ADDRSZ / NS_INT16SZ)) - *tp++ = ':'; - *tp = '\0'; - - if (bits != -1) - tp += SPRINTF((tp, "/%u", bits)); - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) { - errno = EMSGSIZE; - return (NULL); - } - strcpy(dst, tmp); - return (dst); -} - -/*! \file */ diff --git a/lib/libc/inet/inet_cidr_pton.c b/lib/libc/inet/inet_cidr_pton.c deleted file mode 100644 index 2911f45f2..000000000 --- a/lib/libc/inet/inet_cidr_pton.c +++ /dev/null @@ -1,290 +0,0 @@ -/* $NetBSD: inet_cidr_pton.c,v 1.8 2012/03/20 17:08:13 matt Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1998,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: inet_cidr_pton.c,v 1.6 2005/04/27 04:56:19 sra Exp"; -#else -__RCSID("$NetBSD: inet_cidr_pton.c,v 1.8 2012/03/20 17:08:13 matt Exp $"); -#endif -#endif - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - -#ifdef __weak_alias -__weak_alias(inet_cidr_pton,_inet_cidr_pton) -#endif - -static int inet_cidr_pton_ipv4(const char *src, u_char *dst, - int *bits, int ipv6); -static int inet_cidr_pton_ipv6(const char *src, u_char *dst, int *bits); - -static int getbits(const char *, int ipv6); - -/*% - * int - * inet_cidr_pton(af, src, dst, *bits) - * convert network address from presentation to network format. - * accepts inet_pton()'s input for this "af" plus trailing "/CIDR". - * "dst" is assumed large enough for its "af". "bits" is set to the - * /CIDR prefix length, which can have defaults (like /32 for IPv4). - * return: - * -1 if an error occurred (inspect errno; ENOENT means bad format). - * 0 if successful conversion occurred. - * note: - * 192.5.5.1/28 has a nonzero host part, which means it isn't a network - * as called for by inet_net_pton() but it can be a host address with - * an included netmask. - * author: - * Paul Vixie (ISC), October 1998 - */ -int -inet_cidr_pton(int af, const char *src, void *dst, int *bits) { - switch (af) { - case AF_INET: - return (inet_cidr_pton_ipv4(src, dst, bits, 0)); - case AF_INET6: - return (inet_cidr_pton_ipv6(src, dst, bits)); - default: - errno = EAFNOSUPPORT; - return (-1); - } -} - -static const char digits[] = "0123456789"; - -static int -inet_cidr_pton_ipv4(const char *src, u_char *dst, int *pbits, int ipv6) { - const u_char *odst = dst; - int ch, bits; - ptrdiff_t n, tmp; - size_t size = 4; - - /* Get the mantissa. */ - while (ch = *src++, (isascii(ch) && isdigit(ch))) { - tmp = 0; - do { - n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); - tmp *= 10; - tmp += n; - if (tmp > 255) - goto enoent; - } while ((ch = *src++) != '\0' && isascii(ch) && isdigit(ch)); - if (size-- == 0U) - goto emsgsize; - *dst++ = (u_char) tmp; - if (ch == '\0' || ch == '/') - break; - if (ch != '.') - goto enoent; - } - - /* Get the prefix length if any. */ - bits = -1; - if (ch == '/' && dst > odst) { - bits = getbits(src, ipv6); - if (bits == -2) - goto enoent; - } else if (ch != '\0') - goto enoent; - - /* Prefix length can default to /32 only if all four octets spec'd. */ - if (bits == -1) { - if (dst - odst == 4) - bits = ipv6 ? 128 : 32; - else - goto enoent; - } - - /* If nothing was written to the destination, we found no address. */ - if (dst == odst) - goto enoent; - - /* If prefix length overspecifies mantissa, life is bad. */ - if (((bits - (ipv6 ? 96 : 0)) / 8) > (dst - odst)) - goto enoent; - - /* Extend address to four octets. */ - while (size-- > 0U) - *dst++ = 0; - - *pbits = bits; - return (0); - - enoent: - errno = ENOENT; - return (-1); - - emsgsize: - errno = EMSGSIZE; - return (-1); -} - -static int -inet_cidr_pton_ipv6(const char *src, u_char *dst, int *pbits) { - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - u_int val; - int bits; - - memset((tp = tmp), '\0', NS_IN6ADDRSZ); - endp = tp + NS_IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - saw_xdigit = 0; - val = 0; - bits = -1; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (int)(pch - xdigits); - if (val > 0xffff) - return (0); - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - return (0); - colonp = tp; - continue; - } else if (*src == '\0') { - return (0); - } - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - saw_xdigit = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && - inet_cidr_pton_ipv4(curtok, tp, &bits, 1) == 0) { - tp += NS_INADDRSZ; - saw_xdigit = 0; - break; /*%< '\\0' was seen by inet_pton4(). */ - } - if (ch == '/') { - bits = getbits(src, 1); - if (bits == -2) - goto enoent; - break; - } - goto enoent; - } - if (saw_xdigit) { - if (tp + NS_INT16SZ > endp) - goto emsgsize; - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const ptrdiff_t n = tp - colonp; - int i; - - if (tp == endp) - goto enoent; - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - - memcpy(dst, tmp, NS_IN6ADDRSZ); - - *pbits = bits; - return (0); - - enoent: - errno = ENOENT; - return (-1); - - emsgsize: - errno = EMSGSIZE; - return (-1); -} - -static int -getbits(const char *src, int ipv6) { - int bits = 0; - char *cp, ch; - - if (*src == '\0') /*%< syntax */ - return (-2); - do { - ch = *src++; - cp = strchr(digits, ch); - if (cp == NULL) /*%< syntax */ - return (-2); - bits *= 10; - bits += (int)(cp - digits); - if (bits == 0 && *src != '\0') /*%< no leading zeros */ - return (-2); - if (bits > (ipv6 ? 128 : 32)) /*%< range error */ - return (-2); - } while (*src != '\0'); - - return (bits); -} - -/*! \file */ diff --git a/lib/libc/inet/inet_lnaof.c b/lib/libc/inet/inet_lnaof.c deleted file mode 100644 index 3f66cbef7..000000000 --- a/lib/libc/inet/inet_lnaof.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: inet_lnaof.c,v 1.1 2004/05/20 23:13:02 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)inet_lnaof.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: inet_lnaof.c,v 1.1 2004/05/20 23:13:02 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(inet_lnaof,_inet_lnaof) -#endif - -/* - * Return the local network address portion of an - * internet address; handles class a/b/c network - * number formats. - */ -in_addr_t -inet_lnaof(struct in_addr in) -{ - in_addr_t i = ntohl(in.s_addr); - - if (IN_CLASSA(i)) - return ((i)&IN_CLASSA_HOST); - else if (IN_CLASSB(i)) - return ((i)&IN_CLASSB_HOST); - else - return ((i)&IN_CLASSC_HOST); -} diff --git a/lib/libc/inet/inet_makeaddr.c b/lib/libc/inet/inet_makeaddr.c deleted file mode 100644 index 0dfdd439b..000000000 --- a/lib/libc/inet/inet_makeaddr.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: inet_makeaddr.c,v 1.1 2004/05/20 23:13:02 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)inet_makeaddr.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: inet_makeaddr.c,v 1.1 2004/05/20 23:13:02 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(inet_makeaddr,_inet_makeaddr) -#endif - -/* - * Formulate an Internet address from network + host. Used in - * building addresses stored in the ifnet structure. - */ -struct in_addr -inet_makeaddr(in_addr_t net, in_addr_t host) -{ - in_addr_t addr; - struct in_addr ret; - - if (net < 128) - addr = (net << IN_CLASSA_NSHIFT) | (host & IN_CLASSA_HOST); - else if (net < 65536) - addr = (net << IN_CLASSB_NSHIFT) | (host & IN_CLASSB_HOST); - else if (net < 16777216L) - addr = (net << IN_CLASSC_NSHIFT) | (host & IN_CLASSC_HOST); - else - addr = net | host; - ret.s_addr = htonl(addr); - return ret; -} diff --git a/lib/libc/inet/inet_net.3 b/lib/libc/inet/inet_net.3 deleted file mode 100644 index 3d9b6ef5f..000000000 --- a/lib/libc/inet/inet_net.3 +++ /dev/null @@ -1,198 +0,0 @@ -.\" $NetBSD: inet_net.3,v 1.5 2012/07/20 20:48:59 wiz Exp $ -.\" -.\" Copyright (c) 1997 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Luke Mewburn. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd July 20, 2012 -.Dt INET_NET 3 -.Os -.Sh NAME -.Nm inet_net_ntop , -.Nm inet_net_pton -.Nd Internet network number manipulation routines -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/socket.h -.In netinet/in.h -.In arpa/inet.h -.Ft char * -.Fn inet_net_ntop "int af" "const void *src" "int bits" "char *dst" "size_t size" -.Ft int -.Fn inet_net_pton "int af" "const char *src" "void *dst" "size_t size" -.Sh DESCRIPTION -The -.Fn inet_net_ntop -function converts an Internet network number from network format (usually a -.Vt struct in_addr -or some other binary form, in network byte order) to CIDR presentation format -(suitable for external display purposes). -The -.Fa bits -argument is the number of bits in -.Fa src -that are the network number. -It returns -.Dv NULL -if an error occurs (in which case -.Va errno -will have been set), or it returns a pointer to the destination string. -.Pp -The -.Fn inet_net_pton -function converts a presentation format Internet network number (that is, -printable form as held in a character string) to network format (usually a -.Vt struct in_addr -or some other internal binary representation, in network byte order). -It returns the number of bits (either computed based on the class, or -specified with /CIDR), or \-1 if a failure occurred -(in which case -.Va errno -will have been set). -.Pp -The currently supported values for -.Fa af -are -.Dv AF_INET -and -.Dv AF_INET6 . -The -.Fa size -argument is the size of the result buffer -.Fa dst . -.Sh NETWORK NUMBERS (IP VERSION 4) -Internet network numbers may be specified in one of the following forms: -.Bd -literal -offset indent -a.b.c.d/bits -a.b.c.d -a.b.c -a.b -a -.Ed -.Pp -When four parts are specified, each is interpreted -as a byte of data and assigned, from left to right, -to the four bytes of an Internet network number. -Note that when an Internet network number is viewed as a 32-bit -integer quantity on a system that uses little-endian -byte order (such as the -.Tn Intel 386 , 486 , -and -.Tn Pentium -processors) the bytes referred to above appear as -.Dq Li d.c.b.a . -That is, little-endian bytes are ordered from right to left. -.Pp -When a three part number is specified, the last -part is interpreted as a 16-bit quantity and placed -in the rightmost two bytes of the Internet network number. -This makes the three part number format convenient -for specifying Class B network numbers as -.Dq Li 128.net.host . -.Pp -When a two part number is supplied, the last part -is interpreted as a 24-bit quantity and placed in -the rightmost three bytes of the Internet network number. -This makes the two part number format convenient -for specifying Class A network numbers as -.Dq Li net.host . -.Pp -When only one part is given, the value is stored -directly in the Internet network number without any byte -rearrangement. -.Pp -All numbers supplied as -.Dq parts -in a -.Ql \&. -notation -may be decimal, octal, or hexadecimal, as specified -in the C language (i.e., a leading 0x or 0X implies -hexadecimal; otherwise, a leading 0 implies octal; -otherwise, the number is interpreted as decimal). -.\" -.\" .Sh NETWORK NUMBERS (IP VERSION 6) -.\" XXX - document this! -.\" -.Sh ERRORS -The -.Fn inet_net_ntop -and -.Fn inet_net_pton -functions may fail with -.Bl -tag -width Er -.It Bq Er EAFNOSUPPORT -The value of -.Fa af -was not -.Dv AF_INET -or -.Dv AF_INET6 . -.It Bq Er EMSGSIZE -The conversion of -.Fa src -overflows -.Fa size -of -.Fa dst . -.El -.Pp -The -.Fn inet_net_ntop -function may fail with -.Bl -tag -width Er -.It Bq Er EINVAL -The -.Fa bits -argument contains an invalid number of bits -for the requested address family. -.El -.Pp -The -.Fn inet_net_pton -function may fail with -.Bl -tag -width Er -.It Bq Er ENOENT -The -.Fa src -was not a valid Internet network number. -.El -.Sh SEE ALSO -.Xr byteorder 3 , -.Xr inet 3 , -.Xr networks 5 -.Sh HISTORY -The -.Fn inet_net_ntop -and -.Fn inet_net_pton -functions appeared in BIND 4.9.4 and thence -.Nx 1.3 . -Support for -.Dv AF_INET6 -appeared in -.Nx 1.6 . diff --git a/lib/libc/inet/inet_net_ntop.c b/lib/libc/inet/inet_net_ntop.c deleted file mode 100644 index 41b2813f5..000000000 --- a/lib/libc/inet/inet_net_ntop.c +++ /dev/null @@ -1,279 +0,0 @@ -/* - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef -static const char rcsid[] = "Id: inet_net_ntop.c,v 1.1.2.1 2002/08/02 02:17:21 marka Exp "; -#else -__RCSID("$NetBSD: inet_net_ntop.c,v 1.3 2012/03/20 17:08:13 matt Exp $"); -#endif -#endif - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef __weak_alias -__weak_alias(inet_net_ntop,_inet_net_ntop) -#endif - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) sprintf x -#endif - -static char * inet_net_ntop_ipv4(const u_char *src, int bits, - char *dst, size_t size); -static char * inet_net_ntop_ipv6(const u_char *src, int bits, - char *dst, size_t size); - -/* - * char * - * inet_net_ntop(af, src, bits, dst, size) - * convert network number from network to presentation format. - * generates CIDR style result always. - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * author: - * Paul Vixie (ISC), July 1996 - */ -char * -inet_net_ntop(int af, const void *src, int bits, char *dst, size_t size) -{ - switch (af) { - case AF_INET: - return (inet_net_ntop_ipv4(src, bits, dst, size)); - case AF_INET6: - return (inet_net_ntop_ipv6(src, bits, dst, size)); - default: - errno = EAFNOSUPPORT; - return (NULL); - } -} - -/* - * static char * - * inet_net_ntop_ipv4(src, bits, dst, size) - * convert IPv4 network number from network to presentation format. - * generates CIDR style result always. - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * network byte order assumed. this means 192.5.5.240/28 has - * 0b11110000 in its fourth octet. - * author: - * Paul Vixie (ISC), July 1996 - */ -static char * -inet_net_ntop_ipv4(const u_char *src, int bits, char *dst, size_t size) -{ - char *odst = dst; - char *t; - u_int m; - int b; - - if (bits < 0 || bits > 32) { - errno = EINVAL; - return (NULL); - } - - if (bits == 0) { - if (size < sizeof "0") - goto emsgsize; - *dst++ = '0'; - size--; - *dst = '\0'; - } - - /* Format whole octets. */ - for (b = bits / 8; b > 0; b--) { - if (size <= sizeof "255.") - goto emsgsize; - t = dst; - dst += SPRINTF((dst, "%u", *src++)); - if (b > 1) { - *dst++ = '.'; - *dst = '\0'; - } - size -= (size_t)(dst - t); - } - - /* Format partial octet. */ - b = bits % 8; - if (b > 0) { - if (size <= sizeof ".255") - goto emsgsize; - t = dst; - if (dst != odst) - *dst++ = '.'; - m = ((1 << b) - 1) << (8 - b); - dst += SPRINTF((dst, "%u", *src & m)); - size -= (size_t)(dst - t); - } - - /* Format CIDR /width. */ - if (size <= sizeof "/32") - goto emsgsize; - dst += SPRINTF((dst, "/%u", bits)); - return (odst); - - emsgsize: - errno = EMSGSIZE; - return (NULL); -} - -/* - * static char * - * inet_net_ntop_ipv6(src, bits, fakebits, dst, size) - * convert IPv6 network number from network to presentation format. - * generates CIDR style result always. Picks the shortest representation - * unless the IP is really IPv4. - * always prints specified number of bits (bits). - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * network byte order assumed. this means 192.5.5.240/28 has - * 0x11110000 in its fourth octet. - * author: - * Vadim Kogan (UCB), June 2001 - * Original version (IPv4) by Paul Vixie (ISC), July 1996 - */ - -static char * -inet_net_ntop_ipv6(const u_char *src, int bits, char *dst, size_t size) -{ - u_int m; - int b; - size_t p; - size_t zero_s, zero_l, tmp_zero_s, tmp_zero_l; - size_t i; - int is_ipv4 = 0; - unsigned char inbuf[16]; - char outbuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255/128")]; - char *cp; - size_t words; - u_char *s; - - if (bits < 0 || bits > 128) { - errno = EINVAL; - return (NULL); - } - - cp = outbuf; - - if (bits == 0) { - *cp++ = ':'; - *cp++ = ':'; - *cp = '\0'; - } else { - /* Copy src to private buffer. Zero host part. */ - p = (bits + 7) / 8; - memcpy(inbuf, src, p); - memset(inbuf + p, 0, 16 - p); - b = bits % 8; - if (b != 0) { - m = ~0 << (8 - b); - inbuf[p-1] &= m; - } - - s = inbuf; - - /* how many words need to be displayed in output */ - words = (bits + 15) / 16; - if (words == 1) - words = 2; - - /* Find the longest substring of zero's */ - zero_s = zero_l = tmp_zero_s = tmp_zero_l = 0; - for (i = 0; i < (words * 2); i += 2) { - if ((s[i] | s[i+1]) == 0) { - if (tmp_zero_l == 0) - tmp_zero_s = i / 2; - tmp_zero_l++; - } else { - if (tmp_zero_l && zero_l < tmp_zero_l) { - zero_s = tmp_zero_s; - zero_l = tmp_zero_l; - tmp_zero_l = 0; - } - } - } - - if (tmp_zero_l && zero_l < tmp_zero_l) { - zero_s = tmp_zero_s; - zero_l = tmp_zero_l; - } - - if (zero_l != words && zero_s == 0 && ((zero_l == 6) || - ((zero_l == 5 && s[10] == 0xff && s[11] == 0xff) || - ((zero_l == 7 && s[14] != 0 && s[15] != 1))))) - is_ipv4 = 1; - - /* Format whole words. */ - for (p = 0; p < words; p++) { - if (zero_l != 0 && p >= zero_s && p < zero_s + zero_l) { - /* Time to skip some zeros */ - if (p == zero_s) - *cp++ = ':'; - if (p == words - 1) - *cp++ = ':'; - s++; - s++; - continue; - } - - if (is_ipv4 && p > 5 ) { - *cp++ = (p == 6) ? ':' : '.'; - cp += SPRINTF((cp, "%u", *s++)); - /* we can potentially drop the last octet */ - if (p != 7 || bits > 120) { - *cp++ = '.'; - cp += SPRINTF((cp, "%u", *s++)); - } - } else { - if (cp != outbuf) - *cp++ = ':'; - cp += SPRINTF((cp, "%x", *s * 256 + s[1])); - s += 2; - } - } - } - /* Format CIDR /width. */ - (void)SPRINTF((cp, "/%u", bits)); - if (strlen(outbuf) + 1 > size) - goto emsgsize; - strcpy(dst, outbuf); - - return (dst); - -emsgsize: - errno = EMSGSIZE; - return (NULL); -} diff --git a/lib/libc/inet/inet_net_pton.c b/lib/libc/inet/inet_net_pton.c deleted file mode 100644 index 57b978289..000000000 --- a/lib/libc/inet/inet_net_pton.c +++ /dev/null @@ -1,420 +0,0 @@ -/* - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: inet_net_pton.c,v 1.4.2.1 2002/08/02 02:17:21 marka Exp "; -#else -__RCSID("$NetBSD: inet_net_pton.c,v 1.4 2012/03/20 17:08:13 matt Exp $"); -#endif -#endif - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef __weak_alias -__weak_alias(inet_net_pton,_inet_net_pton) -#endif - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - - -/* - * static int - * inet_net_pton_ipv4(src, dst, size) - * convert IPv4 network number from presentation to network format. - * accepts hex octets, hex strings, decimal octets, and /CIDR. - * "size" is in bytes and describes "dst". - * return: - * number of bits, either imputed classfully or specified with /CIDR, - * or -1 if some failure occurred (check errno). ENOENT means it was - * not an IPv4 network specification. - * note: - * network byte order assumed. this means 192.5.5.240/28 has - * 0b11110000 in its fourth octet. - * author: - * Paul Vixie (ISC), June 1996 - */ -static int -inet_net_pton_ipv4(const char *src, u_char *dst, size_t size) -{ - static const char xdigits[] = "0123456789abcdef"; - static const char digits[] = "0123456789"; - int ch, dirty, bits; - ptrdiff_t n, tmp; - const u_char *odst = dst; - - tmp = 0; - ch = *src++; - if (ch == '0' && (src[0] == 'x' || src[0] == 'X') - && isascii((u_char)(src[1])) - && isxdigit((u_char)(src[1]))) { - /* Hexadecimal: Eat nybble string. */ - if (size == 0) - goto emsgsize; - dirty = 0; - src++; /* skip x or X. */ - while ((ch = *src++) != '\0' && isascii((u_char)ch) - && isxdigit((u_char)ch)) { - if (isupper((u_char)ch)) - ch = tolower((u_char)ch); - n = strchr(xdigits, ch) - xdigits; - INSIST(n >= 0 && n <= 15); - if (dirty == 0) - tmp = n; - else - tmp = (tmp << 4) | n; - if (++dirty == 2) { - if (size-- == 0) - goto emsgsize; - *dst++ = (u_char) tmp; - dirty = 0; - } - } - if (dirty) { /* Odd trailing nybble? */ - if (size-- == 0) - goto emsgsize; - *dst++ = (u_char) (tmp << 4); - } - } else if (isascii((u_char)ch) && isdigit((u_char)ch)) { - /* Decimal: eat dotted digit string. */ - for (;;) { - tmp = 0; - do { - n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); - tmp *= 10; - tmp += n; - if (tmp > 255) - goto enoent; - } while ((ch = *src++) != '\0' && - isascii((u_char)ch) && isdigit((u_char)ch)); - if (size-- == 0) - goto emsgsize; - *dst++ = (u_char) tmp; - if (ch == '\0' || ch == '/') - break; - if (ch != '.') - goto enoent; - ch = *src++; - if (!isascii((u_char)ch) || !isdigit((u_char)ch)) - goto enoent; - } - } else - goto enoent; - - bits = -1; - if (ch == '/' && isascii((u_char)(src[0])) && - isdigit((u_char)(src[0])) && dst > odst) { - /* CIDR width specifier. Nothing can follow it. */ - ch = *src++; /* Skip over the /. */ - bits = 0; - do { - n = strchr(digits, ch) - digits; - INSIST(n >= 0 && n <= 9); - bits *= 10; - bits += (int)n; - if (bits > 32) - goto emsgsize; - } while ((ch = *src++) != '\0' && isascii((u_char)ch) - && isdigit((u_char)ch)); - if (ch != '\0') - goto enoent; - } - - /* Firey death and destruction unless we prefetched EOS. */ - if (ch != '\0') - goto enoent; - - /* If nothing was written to the destination, we found no address. */ - if (dst == odst) - goto enoent; - /* If no CIDR spec was given, infer width from net class. */ - if (bits == -1) { - if (*odst >= 240) /* Class E */ - bits = 32; - else if (*odst >= 224) /* Class D */ - bits = 4; - else if (*odst >= 192) /* Class C */ - bits = 24; - else if (*odst >= 128) /* Class B */ - bits = 16; - else /* Class A */ - bits = 8; - /* If imputed mask is narrower than specified octets, widen. */ - if (bits >= 8 && bits < ((dst - odst) * 8)) - bits = (int)(dst - odst) * 8; - } - /* Extend network to cover the actual mask. */ - while (bits > ((dst - odst) * 8)) { - if (size-- == 0) - goto emsgsize; - *dst++ = '\0'; - } - return (bits); - - enoent: - errno = ENOENT; - return (-1); - - emsgsize: - errno = EMSGSIZE; - return (-1); -} - -static int -getbits(const char *src, int *bitsp) -{ - static const char digits[] = "0123456789"; - int n; - int val; - char ch; - - val = 0; - n = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - pch = strchr(digits, ch); - if (pch != NULL) { - if (n++ != 0 && val == 0) /* no leading zeros */ - return (0); - val *= 10; - val += (int)(pch - digits); - if (val > 128) /* range */ - return (0); - continue; - } - return (0); - } - if (n == 0) - return (0); - *bitsp = val; - return (1); -} - -static int -getv4(const char *src, u_char *dst, int *bitsp) -{ - static const char digits[] = "0123456789"; - u_char *odst = dst; - int n; - u_int val; - char ch; - - val = 0; - n = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - pch = strchr(digits, ch); - if (pch != NULL) { - if (n++ != 0 && val == 0) /* no leading zeros */ - return (0); - val *= 10; - val += (int)(pch - digits); - if (val > 255) /* range */ - return (0); - continue; - } - if (ch == '.' || ch == '/') { - if (dst - odst > 3) /* too many octets? */ - return (0); - *dst++ = val; - if (ch == '/') - return (getbits(src, bitsp)); - val = 0; - n = 0; - continue; - } - return (0); - } - if (n == 0) - return (0); - if (dst - odst > 3) /* too many octets? */ - return (0); - *dst++ = val; - return (1); -} - -static int -inet_net_pton_ipv6(const char *src, u_char *dst, size_t size) -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, saw_xdigit; - u_int val; - int digits; - int bits; - size_t bytes; - int words; - int ipv4; - - memset((tp = tmp), '\0', NS_IN6ADDRSZ); - endp = tp + NS_IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - goto enoent; - curtok = src; - saw_xdigit = 0; - val = 0; - digits = 0; - bits = -1; - ipv4 = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (int)(pch - xdigits); - if (++digits > 4) - goto enoent; - saw_xdigit = 1; - continue; - } - if (ch == ':') { - curtok = src; - if (!saw_xdigit) { - if (colonp) - goto enoent; - colonp = tp; - continue; - } else if (*src == '\0') - goto enoent; - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - saw_xdigit = 0; - digits = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && - getv4(curtok, tp, &bits) > 0) { - tp += NS_INADDRSZ; - saw_xdigit = 0; - ipv4 = 1; - break; /* '\0' was seen by inet_pton4(). */ - } - if (ch == '/' && getbits(src, &bits) > 0) - break; - goto enoent; - } - if (saw_xdigit) { - if (tp + NS_INT16SZ > endp) - goto enoent; - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - } - if (bits == -1) - bits = 128; - - words = (bits + 15) / 16; - if (words < 2) - words = 2; - if (ipv4) - words = 8; - endp = tmp + 2 * words; - - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const ptrdiff_t n = tp - colonp; - int i; - - if (tp == endp) - goto enoent; - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - goto enoent; - - bytes = (bits + 7) / 8; - if (bytes > size) - goto emsgsize; - memcpy(dst, tmp, bytes); - return (bits); - - enoent: - errno = ENOENT; - return (-1); - - emsgsize: - errno = EMSGSIZE; - return (-1); -} - -/* - * int - * inet_net_pton(af, src, dst, size) - * convert network number from presentation to network format. - * accepts hex octets, hex strings, decimal octets, and /CIDR. - * "size" is in bytes and describes "dst". - * return: - * number of bits, either imputed classfully or specified with /CIDR, - * or -1 if some failure occurred (check errno). ENOENT means it was - * not a valid network specification. - * author: - * Paul Vixie (ISC), June 1996 - */ -int -inet_net_pton(int af, const char *src, void *dst, size_t size) -{ - switch (af) { - case AF_INET: - return (inet_net_pton_ipv4(src, dst, size)); - case AF_INET6: - return (inet_net_pton_ipv6(src, dst, size)); - default: - errno = EAFNOSUPPORT; - return (-1); - } -} diff --git a/lib/libc/inet/inet_neta.c b/lib/libc/inet/inet_neta.c deleted file mode 100644 index 41692aa90..000000000 --- a/lib/libc/inet/inet_neta.c +++ /dev/null @@ -1,95 +0,0 @@ -/* $NetBSD: inet_neta.c,v 1.3 2012/06/25 22:32:44 abs Exp $ */ - -/* - * Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: inet_neta.c,v 8.2 1996/08/08 06:54:44 vixie Exp "; -#else -__RCSID("$NetBSD: inet_neta.c,v 1.3 2012/06/25 22:32:44 abs Exp $"); -#endif -#endif - -#include "namespace.h" -#include -#include -#include -#include - -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(inet_neta,_inet_neta) -#endif - -/* - * char * - * inet_neta(src, dst, size) - * format a u_long network number into presentation format. - * return: - * pointer to dst, or NULL if an error occurred (check errno). - * note: - * format of ``src'' is as for inet_network(). - * author: - * Paul Vixie (ISC), July 1996 - */ -char * -inet_neta(u_long src, char *dst, size_t size) -{ - char *odst = dst; - char *ep; - int advance; - - _DIAGASSERT(dst != NULL); - - if (src == 0x00000000) { - if (size < sizeof "0.0.0.0") - goto emsgsize; - strlcpy(dst, "0.0.0.0", size); - return dst; - } - ep = dst + size; - if (ep <= dst) - goto emsgsize; - while (src & 0xffffffffUL) { - u_char b = (u_char)((src & 0xff000000UL) >> 24); - - src <<= 8; - if (b || src) { - advance = snprintf(dst, (size_t)(ep - dst), "%u", b); - if (advance <= 0 || advance >= ep - dst) - goto emsgsize; - dst += advance; - if (src != 0L) { - if (dst + 1 >= ep) - goto emsgsize; - *dst++ = '.'; - *dst = '\0'; - } - } - } - return (odst); - - emsgsize: - errno = EMSGSIZE; - return (NULL); -} diff --git a/lib/libc/inet/inet_netof.c b/lib/libc/inet/inet_netof.c deleted file mode 100644 index 4758f3e38..000000000 --- a/lib/libc/inet/inet_netof.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: inet_netof.c,v 1.1 2004/05/20 23:13:02 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)inet_netof.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: inet_netof.c,v 1.1 2004/05/20 23:13:02 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(inet_netof,_inet_netof) -#endif - -/* - * Return the network number from an internet - * address; handles class a/b/c network #'s. - */ -in_addr_t -inet_netof(struct in_addr in) -{ - in_addr_t i = ntohl(in.s_addr); - - if (IN_CLASSA(i)) - return (((i)&IN_CLASSA_NET) >> IN_CLASSA_NSHIFT); - else if (IN_CLASSB(i)) - return (((i)&IN_CLASSB_NET) >> IN_CLASSB_NSHIFT); - else - return (((i)&IN_CLASSC_NET) >> IN_CLASSC_NSHIFT); -} diff --git a/lib/libc/inet/inet_network.c b/lib/libc/inet/inet_network.c deleted file mode 100644 index 135675d58..000000000 --- a/lib/libc/inet/inet_network.c +++ /dev/null @@ -1,114 +0,0 @@ -/* $NetBSD: inet_network.c,v 1.4 2008/01/20 04:56:08 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)inet_network.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: inet_network.c,v 1.4 2008/01/20 04:56:08 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include -#ifdef _DIAGNOSTIC -#include /* for NULL */ -#endif - -#ifdef __weak_alias -__weak_alias(inet_network,_inet_network) -#endif - -/* - * Internet network address interpretation routine. - * The library routines call this routine to interpret - * network numbers. - */ -in_addr_t -inet_network(const char *cp) -{ - in_addr_t val; - size_t i, n; - u_char c; - in_addr_t parts[4], *pp = parts; - int digit, base; - - _DIAGASSERT(cp != NULL); - -again: - val = 0; base = 10; digit = 0; - if (*cp == '0') - digit = 1, base = 8, cp++; - if (*cp == 'x' || *cp == 'X') - digit = 0, base = 16, cp++; - while ((c = *cp) != 0) { - if (isdigit(c)) { - if (base == 8 && (c == '8' || c == '9')) - return (INADDR_NONE); - val = (val * base) + (c - '0'); - cp++; - digit = 1; - continue; - } - if (base == 16 && isxdigit(c)) { - val = (val << 4) + (c + 10 - (islower(c) ? 'a' : 'A')); - cp++; - digit = 1; - continue; - } - break; - } - if (!digit) - return (INADDR_NONE); - if (pp >= parts + 4 || val > 0xff) - return (INADDR_NONE); - if (*cp == '.') { - *pp++ = val, cp++; - goto again; - } - if (*cp && !isspace((u_char) *cp)) - return (INADDR_NONE); - *pp++ = val; - n = pp - parts; - if (n > 4) - return (INADDR_NONE); - for (val = 0, i = 0; i < n; i++) { - val <<= 8; - val |= parts[i] & 0xff; - } - return (val); -} diff --git a/lib/libc/inet/inet_ntoa.c b/lib/libc/inet/inet_ntoa.c deleted file mode 100644 index 6ed023b41..000000000 --- a/lib/libc/inet/inet_ntoa.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: inet_ntoa.c,v 1.2 2012/03/13 21:13:38 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)inet_ntoa.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: inet_ntoa.c,v 1.2 2012/03/13 21:13:38 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(inet_ntoa,_inet_ntoa) -#endif - -/* - * Convert network-format internet address - * to base 256 d.d.d.d representation. - */ -/*const*/ char * -inet_ntoa(struct in_addr in) { - static char ret[18]; - - strlcpy(ret, "[inet_ntoa error]", sizeof(ret)); - (void) inet_ntop(AF_INET, &in, ret, (socklen_t)sizeof ret); - return ret; -} diff --git a/lib/libc/inet/inet_ntop.c b/lib/libc/inet/inet_ntop.c deleted file mode 100644 index d27a5b150..000000000 --- a/lib/libc/inet/inet_ntop.c +++ /dev/null @@ -1,231 +0,0 @@ -/* $NetBSD: inet_ntop.c,v 1.11 2014/02/10 16:30:54 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: inet_ntop.c,v 1.5 2005/11/03 22:59:52 marka Exp"; -#else -__RCSID("$NetBSD: inet_ntop.c,v 1.11 2014/02/10 16:30:54 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef __weak_alias -__weak_alias(inet_ntop,_inet_ntop) -#endif - -/*% - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static const char *inet_ntop4(const u_char *src, char *dst, socklen_t size); -static const char *inet_ntop6(const u_char *src, char *dst, socklen_t size); - -/* char * - * inet_ntop(af, src, dst, size) - * convert a network format address to presentation format. - * return: - * pointer to presentation format address (`dst'), or NULL (see errno). - * author: - * Paul Vixie, 1996. - */ -const char * -inet_ntop(int af, const void *src, char *dst, socklen_t size) -{ - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); - - switch (af) { - case AF_INET: - return inet_ntop4(src, dst, size); - case AF_INET6: - return inet_ntop6(src, dst, size); - default: - errno = EAFNOSUPPORT; - return NULL; - } - /* NOTREACHED */ -} - -/* const char * - * inet_ntop4(src, dst, size) - * format an IPv4 address, more or less like inet_ntoa() - * return: - * `dst' (as a const) - * notes: - * (1) uses no statics - * (2) takes a u_char* not an in_addr as input - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop4(const u_char *src, char *dst, socklen_t size) -{ - char tmp[sizeof "255.255.255.255"]; - int l; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); - - l = snprintf(tmp, sizeof(tmp), "%u.%u.%u.%u", - src[0], src[1], src[2], src[3]); - if (l <= 0 || (socklen_t) l >= size) - return NULL; - strlcpy(dst, tmp, size); - return dst; -} - -/* const char * - * inet_ntop6(src, dst, size) - * convert IPv6 binary address into presentation (printable) format - * author: - * Paul Vixie, 1996. - */ -static const char * -inet_ntop6(const u_char *src, char *dst, socklen_t size) -{ - /* - * Note that int32_t and int16_t need only be "at least" large enough - * to contain a value of the specified size. On some systems, like - * Crays, there is no such thing as an integer variable with 16 bits. - * Keep this in mind if you think this function should have been coded - * to use pointer overlays. All the world's not a VAX. - */ - char tmp[sizeof "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"]; - char *tp, *ep; - struct { int base, len; } best, cur; - u_int words[NS_IN6ADDRSZ / NS_INT16SZ]; - int i; - int advance; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); - - /* - * Preprocess: - * Copy the input (bytewise) array into a wordwise array. - * Find the longest run of 0x00's in src[] for :: shorthanding. - */ - memset(words, '\0', sizeof words); - for (i = 0; i < NS_IN6ADDRSZ; i++) - words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3)); - best.base = -1; - best.len = 0; - cur.base = -1; - cur.len = 0; - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - if (words[i] == 0) { - if (cur.base == -1) - cur.base = i, cur.len = 1; - else - cur.len++; - } else { - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - cur.base = -1; - } - } - } - if (cur.base != -1) { - if (best.base == -1 || cur.len > best.len) - best = cur; - } - if (best.base != -1 && best.len < 2) - best.base = -1; - - /* - * Format the result. - */ - tp = tmp; - ep = tmp + sizeof(tmp); - for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) { - /* Are we inside the best run of 0x00's? */ - if (best.base != -1 && i >= best.base && - i < (best.base + best.len)) { - if (i == best.base) - *tp++ = ':'; - continue; - } - /* Are we following an initial run of 0x00s or any real hex? */ - if (i != 0) { - if (tp + 1 >= ep) - goto out; - *tp++ = ':'; - } - /* Is this address an encapsulated IPv4? */ - if (i == 6 && best.base == 0 && - (best.len == 6 || - (best.len == 7 && words[7] != 0x0001) || - (best.len == 5 && words[5] == 0xffff))) { - if (!inet_ntop4(src + 12, tp, (socklen_t)(ep - tp))) - goto out; - tp += strlen(tp); - break; - } - advance = snprintf(tp, (size_t)(ep - tp), "%x", words[i]); - if (advance <= 0 || advance >= ep - tp) - goto out; - tp += advance; - } - /* Was it a trailing run of 0x00's? */ - if (best.base != -1 && (best.base + best.len) == - (NS_IN6ADDRSZ / NS_INT16SZ)) { - if (tp + 1 >= ep) - goto out; - *tp++ = ':'; - } - if (tp + 1 >= ep) - goto out; - *tp++ = '\0'; - - /* - * Check for overflow, copy, and we're done. - */ - if ((size_t)(tp - tmp) > size) - goto out; - strlcpy(dst, tmp, size); - return dst; -out: - errno = ENOSPC; - return NULL; -} - -/*! \file */ diff --git a/lib/libc/inet/inet_pton.c b/lib/libc/inet/inet_pton.c deleted file mode 100644 index c1e9a698a..000000000 --- a/lib/libc/inet/inet_pton.c +++ /dev/null @@ -1,310 +0,0 @@ -/* $NetBSD: inet_pton.c,v 1.8 2012/03/13 21:13:38 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: inet_pton.c,v 1.5 2005/07/28 06:51:47 marka Exp"; -#else -__RCSID("$NetBSD: inet_pton.c,v 1.8 2012/03/13 21:13:38 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef __weak_alias -__weak_alias(inet_pton,_inet_pton) -#endif - -/*% - * WARNING: Don't even consider trying to compile this on a system where - * sizeof(int) < 4. sizeof(int) > 4 is fine; all the world's not a VAX. - */ - -static int inet_pton4(const char *src, u_char *dst, int pton); -static int inet_pton6(const char *src, u_char *dst); - -/* int - * inet_pton(af, src, dst) - * convert from presentation format (which usually means ASCII printable) - * to network format (which is usually some kind of binary format). - * return: - * 1 if the address was valid for the specified address family - * 0 if the address wasn't valid (`dst' is untouched in this case) - * -1 if some other error occurred (`dst' is untouched in this case, too) - * author: - * Paul Vixie, 1996. - */ -int -inet_pton(int af, const char *src, void *dst) -{ - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); - - switch (af) { - case AF_INET: - return (inet_pton4(src, dst, 1)); - case AF_INET6: - return (inet_pton6(src, dst)); - default: - errno = EAFNOSUPPORT; - return (-1); - } - /* NOTREACHED */ -} - -/* int - * inet_pton4(src, dst, pton) - * when last arg is 0: inet_aton(). with hexadecimal, octal and shorthand. - * when last arg is 1: inet_pton(). decimal dotted-quad only. - * return: - * 1 if `src' is a valid input, else 0. - * notice: - * does not touch `dst' unless it's returning 1. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton4(const char *src, u_char *dst, int pton) -{ - u_int32_t val; - u_int digit, base; - ptrdiff_t n; - unsigned char c; - u_int parts[4]; - u_int *pp = parts; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); - - c = *src; - for (;;) { - /* - * Collect number up to ``.''. - * Values are specified as for C: - * 0x=hex, 0=octal, isdigit=decimal. - */ - if (!isdigit(c)) - return (0); - val = 0; base = 10; - if (c == '0') { - c = *++src; - if (c == 'x' || c == 'X') - base = 16, c = *++src; - else if (isdigit(c) && c != '9') - base = 8; - } - /* inet_pton() takes decimal only */ - if (pton && base != 10) - return (0); - for (;;) { - if (isdigit(c)) { - digit = c - '0'; - if (digit >= base) - break; - val = (val * base) + digit; - c = *++src; - } else if (base == 16 && isxdigit(c)) { - digit = c + 10 - (islower(c) ? 'a' : 'A'); - if (digit >= 16) - break; - val = (val << 4) | digit; - c = *++src; - } else - break; - } - if (c == '.') { - /* - * Internet format: - * a.b.c.d - * a.b.c (with c treated as 16 bits) - * a.b (with b treated as 24 bits) - * a (with a treated as 32 bits) - */ - if (pp >= parts + 3) - return (0); - *pp++ = val; - c = *++src; - } else - break; - } - /* - * Check for trailing characters. - */ - if (c != '\0' && !isspace(c)) - return (0); - /* - * Concoct the address according to - * the number of parts specified. - */ - n = pp - parts + 1; - /* inet_pton() takes dotted-quad only. it does not take shorthand. */ - if (pton && n != 4) - return (0); - switch (n) { - - case 0: - return (0); /* initial nondigit */ - - case 1: /* a -- 32 bits */ - break; - - case 2: /* a.b -- 8.24 bits */ - if (parts[0] > 0xff || val > 0xffffff) - return (0); - val |= parts[0] << 24; - break; - - case 3: /* a.b.c -- 8.8.16 bits */ - if ((parts[0] | parts[1]) > 0xff || val > 0xffff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16); - break; - - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if ((parts[0] | parts[1] | parts[2] | val) > 0xff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; - } - if (dst) { - val = htonl(val); - memcpy(dst, &val, NS_INADDRSZ); - } - return (1); -} - -/* int - * inet_pton6(src, dst) - * convert presentation level address to network order binary form. - * return: - * 1 if `src' is a valid [RFC1884 2.2] address, else 0. - * notice: - * (1) does not touch `dst' unless it's returning 1. - * (2) :: in a full address is silently ignored. - * credit: - * inspired by Mark Andrews. - * author: - * Paul Vixie, 1996. - */ -static int -inet_pton6(const char *src, u_char *dst) -{ - static const char xdigits_l[] = "0123456789abcdef", - xdigits_u[] = "0123456789ABCDEF"; - u_char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp; - const char *xdigits, *curtok; - int ch, seen_xdigits; - u_int val; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); - - memset((tp = tmp), '\0', NS_IN6ADDRSZ); - endp = tp + NS_IN6ADDRSZ; - colonp = NULL; - /* Leading :: requires some special handling. */ - if (*src == ':') - if (*++src != ':') - return (0); - curtok = src; - seen_xdigits = 0; - val = 0; - while ((ch = *src++) != '\0') { - const char *pch; - - if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL) - pch = strchr((xdigits = xdigits_u), ch); - if (pch != NULL) { - val <<= 4; - val |= (int)(pch - xdigits); - if (++seen_xdigits > 4) - return (0); - continue; - } - if (ch == ':') { - curtok = src; - if (!seen_xdigits) { - if (colonp) - return (0); - colonp = tp; - continue; - } else if (*src == '\0') - return (0); - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - seen_xdigits = 0; - val = 0; - continue; - } - if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) && - inet_pton4(curtok, tp, 1) > 0) { - tp += NS_INADDRSZ; - seen_xdigits = 0; - break; /*%< '\\0' was seen by inet_pton4(). */ - } - return (0); - } - if (seen_xdigits) { - if (tp + NS_INT16SZ > endp) - return (0); - *tp++ = (u_char) (val >> 8) & 0xff; - *tp++ = (u_char) val & 0xff; - } - if (colonp != NULL) { - /* - * Since some memmove()'s erroneously fail to handle - * overlapping regions, we'll do the shift by hand. - */ - const ptrdiff_t n = tp - colonp; - int i; - - if (tp == endp) - return (0); - for (i = 1; i <= n; i++) { - endp[- i] = colonp[n - i]; - colonp[n - i] = 0; - } - tp = endp; - } - if (tp != endp) - return (0); - memcpy(dst, tmp, NS_IN6ADDRSZ); - return (1); -} - -/*! \file */ diff --git a/lib/libc/inet/nsap_addr.c b/lib/libc/inet/nsap_addr.c deleted file mode 100644 index 8633205a9..000000000 --- a/lib/libc/inet/nsap_addr.c +++ /dev/null @@ -1,130 +0,0 @@ -/* $NetBSD: nsap_addr.c,v 1.6 2009/04/12 17:07:17 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: nsap_addr.c,v 1.5 2005/07/28 06:51:48 marka Exp"; -#else -__RCSID("$NetBSD: nsap_addr.c,v 1.6 2009/04/12 17:07:17 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef __weak_alias -__weak_alias(inet_nsap_addr,_inet_nsap_addr) -__weak_alias(inet_nsap_ntoa,_inet_nsap_ntoa) -#endif - -static char -xtob(int c) { - return (c - (((c >= '0') && (c <= '9')) ? '0' : '7')); -} - -u_int -inet_nsap_addr(const char *ascii, u_char *binary, int maxlen) { - u_char c, nib; - u_int len = 0; - - _DIAGASSERT(ascii != NULL); - _DIAGASSERT(binary != NULL); - - if (ascii[0] != '0' || (ascii[1] != 'x' && ascii[1] != 'X')) - return (0); - ascii += 2; - - while ((c = *ascii++) != '\0' && len < (u_int)maxlen) { - if (c == '.' || c == '+' || c == '/') - continue; - if (!isascii(c)) - return (0); - if (islower(c)) - c = toupper(c); - if (isxdigit(c)) { - nib = xtob(c); - c = *ascii++; - if (c != '\0') { - c = toupper(c); - if (isxdigit(c)) { - *binary++ = (nib << 4) | xtob(c); - len++; - } else - return (0); - } - else - return (0); - } - else - return (0); - } - return (len); -} - -char * -inet_nsap_ntoa(int binlen, const u_char *binary, char *ascii) { - int nib; - int i; - char *tmpbuf = inet_nsap_ntoa_tmpbuf; - char *start; - - _DIAGASSERT(binary != NULL); - - if (ascii) - start = ascii; - else { - ascii = tmpbuf; - start = tmpbuf; - } - - *ascii++ = '0'; - *ascii++ = 'x'; - - if (binlen > 255) - binlen = 255; - - for (i = 0; i < binlen; i++) { - nib = (u_int32_t)*binary >> 4; - *ascii++ = nib + (nib < 10 ? '0' : '7'); - nib = *binary++ & 0x0f; - *ascii++ = nib + (nib < 10 ? '0' : '7'); - if (((i % 2) == 0 && (i + 1) < binlen)) - *ascii++ = '.'; - } - *ascii = '\0'; - return (start); -} - -/*! \file */ diff --git a/lib/libc/isc/Makefile.inc b/lib/libc/isc/Makefile.inc deleted file mode 100644 index e7947d41a..000000000 --- a/lib/libc/isc/Makefile.inc +++ /dev/null @@ -1,6 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2004/05/20 19:52:14 christos Exp $ - -# net sources -.PATH: ${.CURDIR}/isc - -SRCS+= assertions.c ev_timers.c ev_streams.c diff --git a/lib/libc/isc/assertions.c b/lib/libc/isc/assertions.c deleted file mode 100644 index 5e8ee7b3f..000000000 --- a/lib/libc/isc/assertions.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $NetBSD: assertions.c,v 1.7 2011/09/16 16:05:58 joerg Exp $ */ - -/* - * Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC") - * Copyright (C) 1997, 1999, 2001 Internet Software Consortium. - * - * Permission to use, copy, modify, and/or distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH - * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY - * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, - * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM - * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE - * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR - * PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#if !defined(LINT) && !defined(CODECENTER) && !defined(lint) -#ifdef notdef -static const char rcsid[] = "Id: assertions.c,v 1.5 2008/11/14 02:36:51 marka Exp"; -#else -__RCSID("$NetBSD: assertions.c,v 1.7 2011/09/16 16:05:58 joerg Exp $"); -#endif -#endif - -#include "port_before.h" - -#include -#include -#include -#include - -#include - -#include "port_after.h" - -/* - * Forward. - */ - -__dead static void default_assertion_failed(const char *, int, assertion_type, - const char *, int); - -/* - * Public. - */ - -assertion_failure_callback __assertion_failed = default_assertion_failed; - -void -set_assertion_failure_callback(assertion_failure_callback f) { - if (f == NULL) - __assertion_failed = default_assertion_failed; - else - __assertion_failed = f; -} - -const char * -assertion_type_to_text(assertion_type type) { - const char *result; - - switch (type) { - case assert_require: - result = "REQUIRE"; - break; - case assert_ensure: - result = "ENSURE"; - break; - case assert_insist: - result = "INSIST"; - break; - case assert_invariant: - result = "INVARIANT"; - break; - default: - result = NULL; - } - return (result); -} - -/* - * Private. - */ - -/* coverity[+kill] */ -static void -default_assertion_failed(const char *file, int line, assertion_type type, - const char *cond, int print_errno) -{ - fprintf(stderr, "%s:%d: %s(%s)%s%s failed.\n", - file, line, assertion_type_to_text(type), cond, - (print_errno) ? ": " : "", - (print_errno) ? strerror(errno) : ""); - abort(); - /* NOTREACHED */ -} - -/*! \file */ diff --git a/lib/libc/isc/ev_streams.c b/lib/libc/isc/ev_streams.c deleted file mode 100644 index 2804b9f5b..000000000 --- a/lib/libc/isc/ev_streams.c +++ /dev/null @@ -1,319 +0,0 @@ -/* $NetBSD: ev_streams.c,v 1.6 2009/04/12 17:07:17 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* ev_streams.c - implement asynch stream file IO for the eventlib - * vix 04mar96 [initial] - */ - -#include -#if !defined(LINT) && !defined(CODECENTER) && !defined(lint) -#ifdef notdef -static const char rcsid[] = "Id: ev_streams.c,v 1.5 2005/04/27 04:56:36 sra Exp"; -#else -__RCSID("$NetBSD: ev_streams.c,v 1.6 2009/04/12 17:07:17 christos Exp $"); -#endif -#endif - -#include "port_before.h" -#include "fd_setsize.h" - -#include -#include - -#include - -#include -#include -#include "eventlib_p.h" - -#include "port_after.h" - -#ifndef _LIBC -static int copyvec(evStream *str, const struct iovec *iov, int iocnt); -static void consume(evStream *str, size_t bytes); -static void done(evContext opaqueCtx, evStream *str); -static void writable(evContext opaqueCtx, void *uap, int fd, int evmask); -static void readable(evContext opaqueCtx, void *uap, int fd, int evmask); -#endif - -struct iovec -evConsIovec(void *buf, size_t cnt) { - struct iovec ret; - - memset(&ret, 0xf5, sizeof ret); - ret.iov_base = buf; - ret.iov_len = cnt; - return (ret); -} - -#ifndef _LIBC -int -evWrite(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt, - evStreamFunc func, void *uap, evStreamID *id) -{ - evContext_p *ctx = opaqueCtx.opaque; - evStream *new; - int save; - - OKNEW(new); - new->func = func; - new->uap = uap; - new->fd = fd; - new->flags = 0; - if (evSelectFD(opaqueCtx, fd, EV_WRITE, writable, new, &new->file) < 0) - goto free; - if (copyvec(new, iov, iocnt) < 0) - goto free; - new->prevDone = NULL; - new->nextDone = NULL; - if (ctx->streams != NULL) - ctx->streams->prev = new; - new->prev = NULL; - new->next = ctx->streams; - ctx->streams = new; - if (id != NULL) - id->opaque = new; - return (0); - free: - save = errno; - FREE(new); - errno = save; - return (-1); -} - -int -evRead(evContext opaqueCtx, int fd, const struct iovec *iov, int iocnt, - evStreamFunc func, void *uap, evStreamID *id) -{ - evContext_p *ctx = opaqueCtx.opaque; - evStream *new; - int save; - - OKNEW(new); - new->func = func; - new->uap = uap; - new->fd = fd; - new->flags = 0; - if (evSelectFD(opaqueCtx, fd, EV_READ, readable, new, &new->file) < 0) - goto free; - if (copyvec(new, iov, iocnt) < 0) - goto free; - new->prevDone = NULL; - new->nextDone = NULL; - if (ctx->streams != NULL) - ctx->streams->prev = new; - new->prev = NULL; - new->next = ctx->streams; - ctx->streams = new; - if (id) - id->opaque = new; - return (0); - free: - save = errno; - FREE(new); - errno = save; - return (-1); -} - -int -evTimeRW(evContext opaqueCtx, evStreamID id, evTimerID timer) /*ARGSUSED*/ { - evStream *str = id.opaque; - - UNUSED(opaqueCtx); - - str->timer = timer; - str->flags |= EV_STR_TIMEROK; - return (0); -} - -int -evUntimeRW(evContext opaqueCtx, evStreamID id) /*ARGSUSED*/ { - evStream *str = id.opaque; - - UNUSED(opaqueCtx); - - str->flags &= ~EV_STR_TIMEROK; - return (0); -} - -int -evCancelRW(evContext opaqueCtx, evStreamID id) { - evContext_p *ctx = opaqueCtx.opaque; - evStream *old = id.opaque; - - /* - * The streams list is doubly threaded. First, there's ctx->streams - * that's used by evDestroy() to find and cancel all streams. Second, - * there's ctx->strDone (head) and ctx->strLast (tail) which thread - * through the potentially smaller number of "IO completed" streams, - * used in evGetNext() to avoid scanning the entire list. - */ - - /* Unlink from ctx->streams. */ - if (old->prev != NULL) - old->prev->next = old->next; - else - ctx->streams = old->next; - if (old->next != NULL) - old->next->prev = old->prev; - - /* - * If 'old' is on the ctx->strDone list, remove it. Update - * ctx->strLast if necessary. - */ - if (old->prevDone == NULL && old->nextDone == NULL) { - /* - * Either 'old' is the only item on the done list, or it's - * not on the done list. If the former, then we unlink it - * from the list. If the latter, we leave the list alone. - */ - if (ctx->strDone == old) { - ctx->strDone = NULL; - ctx->strLast = NULL; - } - } else { - if (old->prevDone != NULL) - old->prevDone->nextDone = old->nextDone; - else - ctx->strDone = old->nextDone; - if (old->nextDone != NULL) - old->nextDone->prevDone = old->prevDone; - else - ctx->strLast = old->prevDone; - } - - /* Deallocate the stream. */ - if (old->file.opaque) - evDeselectFD(opaqueCtx, old->file); - memput(old->iovOrig, sizeof (struct iovec) * old->iovOrigCount); - FREE(old); - return (0); -} - -/* Copy a scatter/gather vector and initialize a stream handler's IO. */ -static int -copyvec(evStream *str, const struct iovec *iov, int iocnt) { - int i; - - str->iovOrig = (struct iovec *)memget(sizeof(struct iovec) * iocnt); - if (str->iovOrig == NULL) { - errno = ENOMEM; - return (-1); - } - str->ioTotal = 0; - for (i = 0; i < iocnt; i++) { - str->iovOrig[i] = iov[i]; - str->ioTotal += iov[i].iov_len; - } - str->iovOrigCount = iocnt; - str->iovCur = str->iovOrig; - str->iovCurCount = str->iovOrigCount; - str->ioDone = 0; - return (0); -} - -/* Pull off or truncate lead iovec(s). */ -static void -consume(evStream *str, size_t bytes) { - while (bytes > 0U) { - if (bytes < (size_t)str->iovCur->iov_len) { - str->iovCur->iov_len -= bytes; - str->iovCur->iov_base = (void *) - ((u_char *)str->iovCur->iov_base + bytes); - str->ioDone += bytes; - bytes = 0; - } else { - bytes -= str->iovCur->iov_len; - str->ioDone += str->iovCur->iov_len; - str->iovCur++; - str->iovCurCount--; - } - } -} - -/* Add a stream to Done list and deselect the FD. */ -static void -done(evContext opaqueCtx, evStream *str) { - evContext_p *ctx = opaqueCtx.opaque; - - if (ctx->strLast != NULL) { - str->prevDone = ctx->strLast; - ctx->strLast->nextDone = str; - ctx->strLast = str; - } else { - INSIST(ctx->strDone == NULL); - ctx->strDone = ctx->strLast = str; - } - evDeselectFD(opaqueCtx, str->file); - str->file.opaque = NULL; - /* evDrop() will call evCancelRW() on us. */ -} - -/* Dribble out some bytes on the stream. (Called by evDispatch().) */ -static void -writable(evContext opaqueCtx, void *uap, int fd, int evmask) { - evStream *str = uap; - int bytes; - - UNUSED(evmask); - - bytes = writev(fd, str->iovCur, str->iovCurCount); - if (bytes > 0) { - if ((str->flags & EV_STR_TIMEROK) != 0) - evTouchIdleTimer(opaqueCtx, str->timer); - consume(str, bytes); - } else { - if (bytes < 0 && errno != EINTR) { - str->ioDone = -1; - str->ioErrno = errno; - } - } - if (str->ioDone == -1 || str->ioDone == str->ioTotal) - done(opaqueCtx, str); -} - -/* Scoop up some bytes from the stream. (Called by evDispatch().) */ -static void -readable(evContext opaqueCtx, void *uap, int fd, int evmask) { - evStream *str = uap; - int bytes; - - UNUSED(evmask); - - bytes = readv(fd, str->iovCur, str->iovCurCount); - if (bytes > 0) { - if ((str->flags & EV_STR_TIMEROK) != 0) - evTouchIdleTimer(opaqueCtx, str->timer); - consume(str, bytes); - } else { - if (bytes == 0) - str->ioDone = 0; - else { - if (errno != EINTR) { - str->ioDone = -1; - str->ioErrno = errno; - } - } - } - if (str->ioDone <= 0 || str->ioDone == str->ioTotal) - done(opaqueCtx, str); -} -#endif - -/*! \file */ diff --git a/lib/libc/isc/ev_timers.c b/lib/libc/isc/ev_timers.c deleted file mode 100644 index 40521a78d..000000000 --- a/lib/libc/isc/ev_timers.c +++ /dev/null @@ -1,519 +0,0 @@ -/* $NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-1999 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* ev_timers.c - implement timers for the eventlib - * vix 09sep95 [initial] - */ - -#include -#if !defined(LINT) && !defined(CODECENTER) && !defined(lint) -#ifdef notdef -static const char rcsid[] = "Id: ev_timers.c,v 1.6 2005/04/27 04:56:36 sra Exp"; -#else -__RCSID("$NetBSD: ev_timers.c,v 1.11 2012/03/21 00:34:54 christos Exp $"); -#endif -#endif - -/* Import. */ - -#include "port_before.h" -#include "fd_setsize.h" - -#include - -#include -#include -#include "eventlib_p.h" - -#include "port_after.h" - -/* Constants. */ - -#define MILLION 1000000 -#define BILLION 1000000000 - -/* Forward. */ - -#ifndef _LIBC -static int due_sooner(void *, void *); -static void set_index(void *, int); -static void free_timer(void *, void *); -static void print_timer(void *, void *); -static void idle_timeout(evContext, void *, struct timespec, struct timespec); - -/* Private type. */ - -typedef struct { - evTimerFunc func; - void * uap; - struct timespec lastTouched; - struct timespec max_idle; - evTimer * timer; -} idle_timer; -#endif - -/* Public. */ - -struct timespec -evConsTime(time_t sec, long nsec) { - struct timespec x; - - x.tv_sec = sec; - x.tv_nsec = nsec; - return (x); -} - -struct timespec -evAddTime(struct timespec addend1, struct timespec addend2) { - struct timespec x; - - x.tv_sec = addend1.tv_sec + addend2.tv_sec; - x.tv_nsec = addend1.tv_nsec + addend2.tv_nsec; - if (x.tv_nsec >= BILLION) { - x.tv_sec++; - x.tv_nsec -= BILLION; - } - return (x); -} - -struct timespec -evSubTime(struct timespec minuend, struct timespec subtrahend) { - struct timespec x; - - x.tv_sec = minuend.tv_sec - subtrahend.tv_sec; - if (minuend.tv_nsec >= subtrahend.tv_nsec) - x.tv_nsec = minuend.tv_nsec - subtrahend.tv_nsec; - else { - x.tv_nsec = BILLION - subtrahend.tv_nsec + minuend.tv_nsec; - x.tv_sec--; - } - return (x); -} - -int -evCmpTime(struct timespec a, struct timespec b) { -#define SGN(x) ((x) < 0 ? (-1) : (x) > 0 ? (1) : (0)); - time_t s = a.tv_sec - b.tv_sec; - long n; - - if (s != 0) - return SGN(s); - - n = a.tv_nsec - b.tv_nsec; - return SGN(n); -} - -struct timespec -evNowTime(void) -{ - struct timeval now; -#ifdef CLOCK_REALTIME - struct timespec tsnow; - int m = CLOCK_REALTIME; - -#ifdef CLOCK_MONOTONIC -#ifndef _LIBC - if (__evOptMonoTime) - m = CLOCK_MONOTONIC; -#endif -#endif - if (clock_gettime(m, &tsnow) == 0) - return (tsnow); -#endif - if (gettimeofday(&now, NULL) < 0) - return (evConsTime((time_t)0, 0L)); - return (evTimeSpec(now)); -} - -struct timespec -evUTCTime(void) { - struct timeval now; -#ifdef CLOCK_REALTIME - struct timespec tsnow; - if (clock_gettime(CLOCK_REALTIME, &tsnow) == 0) - return (tsnow); -#endif - if (gettimeofday(&now, NULL) < 0) - return (evConsTime((time_t)0, 0L)); - return (evTimeSpec(now)); -} - -#ifndef _LIBC -struct timespec -evLastEventTime(evContext opaqueCtx) { - evContext_p *ctx = opaqueCtx.opaque; - - return (ctx->lastEventTime); -} -#endif - -struct timespec -evTimeSpec(struct timeval tv) { - struct timespec ts; - - ts.tv_sec = tv.tv_sec; - ts.tv_nsec = tv.tv_usec * 1000; - return (ts); -} - -struct timeval -evTimeVal(struct timespec ts) { - struct timeval tv; - - tv.tv_sec = ts.tv_sec; - tv.tv_usec = (suseconds_t)(ts.tv_nsec / 1000); - return (tv); -} - -#ifndef _LIBC -int -evSetTimer(evContext opaqueCtx, - evTimerFunc func, - void *uap, - struct timespec due, - struct timespec inter, - evTimerID *opaqueID -) { - evContext_p *ctx = opaqueCtx.opaque; - evTimer *id; - - evPrintf(ctx, 1, -"evSetTimer(ctx %p, func %p, uap %p, due %ld.%09ld, inter %ld.%09ld)\n", - ctx, func, uap, - (long)due.tv_sec, due.tv_nsec, - (long)inter.tv_sec, inter.tv_nsec); - -#ifdef __hpux - /* - * tv_sec and tv_nsec are unsigned. - */ - if (due.tv_nsec >= BILLION) - EV_ERR(EINVAL); - - if (inter.tv_nsec >= BILLION) - EV_ERR(EINVAL); -#else - if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION) - EV_ERR(EINVAL); - - if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION) - EV_ERR(EINVAL); -#endif - - /* due={0,0} is a magic cookie meaning "now." */ - if (due.tv_sec == (time_t)0 && due.tv_nsec == 0L) - due = evNowTime(); - - /* Allocate and fill. */ - OKNEW(id); - id->func = func; - id->uap = uap; - id->due = due; - id->inter = inter; - - if (heap_insert(ctx->timers, id) < 0) - return (-1); - - /* Remember the ID if the caller provided us a place for it. */ - if (opaqueID) - opaqueID->opaque = id; - - if (ctx->debug > 7) { - evPrintf(ctx, 7, "timers after evSetTimer:\n"); - (void) heap_for_each(ctx->timers, print_timer, (void *)ctx); - } - - return (0); -} - -int -evClearTimer(evContext opaqueCtx, evTimerID id) { - evContext_p *ctx = opaqueCtx.opaque; - evTimer *del = id.opaque; - - if (ctx->cur != NULL && - ctx->cur->type == Timer && - ctx->cur->u.timer.this == del) { - evPrintf(ctx, 8, "deferring delete of timer (executing)\n"); - /* - * Setting the interval to zero ensures that evDrop() will - * clean up the timer. - */ - del->inter = evConsTime(0, 0); - return (0); - } - - if (heap_element(ctx->timers, del->index) != del) - EV_ERR(ENOENT); - - if (heap_delete(ctx->timers, del->index) < 0) - return (-1); - FREE(del); - - if (ctx->debug > 7) { - evPrintf(ctx, 7, "timers after evClearTimer:\n"); - (void) heap_for_each(ctx->timers, print_timer, (void *)ctx); - } - - return (0); -} - -int -evConfigTimer(evContext opaqueCtx, - evTimerID id, - const char *param, - int value -) { - evContext_p *ctx = opaqueCtx.opaque; - evTimer *timer = id.opaque; - int result=0; - - UNUSED(value); - - if (heap_element(ctx->timers, timer->index) != timer) - EV_ERR(ENOENT); - - if (strcmp(param, "rate") == 0) - timer->mode |= EV_TMR_RATE; - else if (strcmp(param, "interval") == 0) - timer->mode &= ~EV_TMR_RATE; - else - EV_ERR(EINVAL); - - return (result); -} - -int -evResetTimer(evContext opaqueCtx, - evTimerID id, - evTimerFunc func, - void *uap, - struct timespec due, - struct timespec inter -) { - evContext_p *ctx = opaqueCtx.opaque; - evTimer *timer = id.opaque; - struct timespec old_due; - int result=0; - - if (heap_element(ctx->timers, timer->index) != timer) - EV_ERR(ENOENT); - -#ifdef __hpux - /* - * tv_sec and tv_nsec are unsigned. - */ - if (due.tv_nsec >= BILLION) - EV_ERR(EINVAL); - - if (inter.tv_nsec >= BILLION) - EV_ERR(EINVAL); -#else - if (due.tv_sec < 0 || due.tv_nsec < 0 || due.tv_nsec >= BILLION) - EV_ERR(EINVAL); - - if (inter.tv_sec < 0 || inter.tv_nsec < 0 || inter.tv_nsec >= BILLION) - EV_ERR(EINVAL); -#endif - - old_due = timer->due; - - timer->func = func; - timer->uap = uap; - timer->due = due; - timer->inter = inter; - - switch (evCmpTime(due, old_due)) { - case -1: - result = heap_increased(ctx->timers, timer->index); - break; - case 0: - result = 0; - break; - case 1: - result = heap_decreased(ctx->timers, timer->index); - break; - } - - if (ctx->debug > 7) { - evPrintf(ctx, 7, "timers after evResetTimer:\n"); - (void) heap_for_each(ctx->timers, print_timer, (void *)ctx); - } - - return (result); -} - -int -evSetIdleTimer(evContext opaqueCtx, - evTimerFunc func, - void *uap, - struct timespec max_idle, - evTimerID *opaqueID -) { - evContext_p *ctx = opaqueCtx.opaque; - idle_timer *tt; - - /* Allocate and fill. */ - OKNEW(tt); - tt->func = func; - tt->uap = uap; - tt->lastTouched = ctx->lastEventTime; - tt->max_idle = max_idle; - - if (evSetTimer(opaqueCtx, idle_timeout, tt, - evAddTime(ctx->lastEventTime, max_idle), - max_idle, opaqueID) < 0) { - FREE(tt); - return (-1); - } - - tt->timer = opaqueID->opaque; - - return (0); -} - -int -evClearIdleTimer(evContext opaqueCtx, evTimerID id) { - evTimer *del = id.opaque; - idle_timer *tt = del->uap; - - FREE(tt); - return (evClearTimer(opaqueCtx, id)); -} - -int -evResetIdleTimer(evContext opaqueCtx, - evTimerID opaqueID, - evTimerFunc func, - void *uap, - struct timespec max_idle -) { - evContext_p *ctx = opaqueCtx.opaque; - evTimer *timer = opaqueID.opaque; - idle_timer *tt = timer->uap; - - tt->func = func; - tt->uap = uap; - tt->lastTouched = ctx->lastEventTime; - tt->max_idle = max_idle; - - return (evResetTimer(opaqueCtx, opaqueID, idle_timeout, tt, - evAddTime(ctx->lastEventTime, max_idle), - max_idle)); -} - -int -evTouchIdleTimer(evContext opaqueCtx, evTimerID id) { - evContext_p *ctx = opaqueCtx.opaque; - evTimer *t = id.opaque; - idle_timer *tt = t->uap; - - tt->lastTouched = ctx->lastEventTime; - - return (0); -} - -/* Public to the rest of eventlib. */ - -heap_context -evCreateTimers(const evContext_p *ctx) { - - UNUSED(ctx); - - return (heap_new(due_sooner, set_index, 2048)); -} - -void -evDestroyTimers(const evContext_p *ctx) { - (void) heap_for_each(ctx->timers, free_timer, NULL); - (void) heap_free(ctx->timers); -} - -/* Private. */ - -static int -due_sooner(void *a, void *b) { - evTimer *a_timer, *b_timer; - - a_timer = a; - b_timer = b; - return (evCmpTime(a_timer->due, b_timer->due) < 0); -} - -static void -set_index(void *what, int idx) { - evTimer *timer; - - timer = what; - timer->index = idx; -} - -static void -free_timer(void *what, void *uap) { - evTimer *t = what; - - UNUSED(uap); - - FREE(t); -} - -static void -print_timer(void *what, void *uap) { - evTimer *cur = what; - evContext_p *ctx = uap; - - cur = what; - evPrintf(ctx, 7, - " func %p, uap %p, due %ld.%09ld, inter %ld.%09ld\n", - cur->func, cur->uap, - (long)cur->due.tv_sec, cur->due.tv_nsec, - (long)cur->inter.tv_sec, cur->inter.tv_nsec); -} - -static void -idle_timeout(evContext opaqueCtx, - void *uap, - struct timespec due, - struct timespec inter -) { - evContext_p *ctx = opaqueCtx.opaque; - idle_timer *this = uap; - struct timespec idle; - - UNUSED(due); - UNUSED(inter); - - idle = evSubTime(ctx->lastEventTime, this->lastTouched); - if (evCmpTime(idle, this->max_idle) >= 0) { - (this->func)(opaqueCtx, this->uap, this->timer->due, - this->max_idle); - /* - * Setting the interval to zero will cause the timer to - * be cleaned up in evDrop(). - */ - this->timer->inter = evConsTime(0L, 0L); - FREE(this); - } else { - /* evDrop() will reschedule the timer. */ - this->timer->inter = evSubTime(this->max_idle, idle); - } -} -#endif - -/*! \file */ diff --git a/lib/libc/isc/eventlib_p.h b/lib/libc/isc/eventlib_p.h deleted file mode 100644 index 4d6b78855..000000000 --- a/lib/libc/isc/eventlib_p.h +++ /dev/null @@ -1,283 +0,0 @@ -/* $NetBSD: eventlib_p.h,v 1.3 2009/04/12 17:07:17 christos Exp $ */ - -/* - * Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995-1999 by Internet Software Consortium - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/*! \file - * \brief private interfaces for eventlib - * \author vix 09sep95 [initial] - * - * Id: eventlib_p.h,v 1.9 2006/03/09 23:57:56 marka Exp - */ - -#ifndef _EVENTLIB_P_H -#define _EVENTLIB_P_H - -#include -#include -#include -#include -#include - -#define EVENTLIB_DEBUG 1 - -#include -#include -#include -#include -#include - -#include -#include -#include - -#define EV_MASK_ALL (EV_READ | EV_WRITE | EV_EXCEPT) -#define EV_ERR(e) return (errno = (e), -1) -#define OK(x) if ((x) < 0) EV_ERR(errno); else (void)NULL -#define OKFREE(x, y) if ((x) < 0) { FREE((y)); EV_ERR(errno); } \ - else (void)NULL - -#define NEW(p) if (((p) = memget(sizeof *(p))) != NULL) \ - FILL(p); \ - else \ - (void)NULL; -#define OKNEW(p) if (!((p) = memget(sizeof *(p)))) { \ - errno = ENOMEM; \ - return (-1); \ - } else \ - FILL(p) -#define FREE(p) memput((p), sizeof *(p)) - -#if EVENTLIB_DEBUG -#define FILL(p) memset((p), 0xF5, sizeof *(p)) -#else -#define FILL(p) -#endif - -#ifdef USE_POLL -#ifdef HAVE_STROPTS_H -#include -#endif -#include -#endif /* USE_POLL */ - -typedef struct evConn { - evConnFunc func; - void * uap; - int fd; - int flags; -#define EV_CONN_LISTEN 0x0001 /*%< Connection is a listener. */ -#define EV_CONN_SELECTED 0x0002 /*%< evSelectFD(conn->file). */ -#define EV_CONN_BLOCK 0x0004 /*%< Listener fd was blocking. */ - evFileID file; - struct evConn * prev; - struct evConn * next; -} evConn; - -typedef struct evAccept { - int fd; - union { - struct sockaddr sa; - struct sockaddr_in in; -#ifndef NO_SOCKADDR_UN - struct sockaddr_un un; -#endif - } la; - ISC_SOCKLEN_T lalen; - union { - struct sockaddr sa; - struct sockaddr_in in; -#ifndef NO_SOCKADDR_UN - struct sockaddr_un un; -#endif - } ra; - ISC_SOCKLEN_T ralen; - int ioErrno; - evConn * conn; - LINK(struct evAccept) link; -} evAccept; - -typedef struct evFile { - evFileFunc func; - void * uap; - int fd; - int eventmask; - int preemptive; - struct evFile * prev; - struct evFile * next; - struct evFile * fdprev; - struct evFile * fdnext; -} evFile; - -typedef struct evStream { - evStreamFunc func; - void * uap; - evFileID file; - evTimerID timer; - int flags; -#define EV_STR_TIMEROK 0x0001 /*%< IFF timer valid. */ - int fd; - struct iovec * iovOrig; - int iovOrigCount; - struct iovec * iovCur; - int iovCurCount; - int ioTotal; - int ioDone; - int ioErrno; - struct evStream *prevDone, *nextDone; - struct evStream *prev, *next; -} evStream; - -typedef struct evTimer { - evTimerFunc func; - void * uap; - struct timespec due, inter; - int index; - int mode; -#define EV_TMR_RATE 1 -} evTimer; - -typedef struct evWait { - evWaitFunc func; - void * uap; - const void * tag; - struct evWait * next; -} evWait; - -typedef struct evWaitList { - evWait * first; - evWait * last; - struct evWaitList * prev; - struct evWaitList * next; -} evWaitList; - -typedef struct evEvent_p { - enum { Accept, File, Stream, Timer, Wait, Free, Null } type; - union { - struct { evAccept *this; } accept; - struct { evFile *this; int eventmask; } file; - struct { evStream *this; } stream; - struct { evTimer *this; } timer; - struct { evWait *this; } wait; - struct { struct evEvent_p *next; } free; - struct { const void *placeholder; } null; - } u; -} evEvent_p; - -#ifdef USE_POLL -typedef struct { - void *ctx; /* pointer to the evContext_p */ - uint32_t type; /* READ, WRITE, EXCEPT, nonblk */ - uint32_t result; /* 1 => revents, 0 => events */ -} __evEmulMask; - -#define emulMaskInit(ctx, field, ev, lastnext) \ - ctx->field.ctx = ctx; \ - ctx->field.type = ev; \ - ctx->field.result = lastnext; - -extern short *__fd_eventfield(int fd, __evEmulMask *maskp); -extern short __poll_event(__evEmulMask *maskp); -extern void __fd_clr(int fd, __evEmulMask *maskp); -extern void __fd_set(int fd, __evEmulMask *maskp); - -#undef FD_ZERO -#define FD_ZERO(maskp) - -#undef FD_SET -#define FD_SET(fd, maskp) \ - __fd_set(fd, maskp) - -#undef FD_CLR -#define FD_CLR(fd, maskp) \ - __fd_clr(fd, maskp) - -#undef FD_ISSET -#define FD_ISSET(fd, maskp) \ - ((*__fd_eventfield(fd, maskp) & __poll_event(maskp)) != 0) - -#endif /* USE_POLL */ - -typedef struct { - /* Global. */ - const evEvent_p *cur; - /* Debugging. */ - int debug; - FILE *output; - /* Connections. */ - evConn *conns; - LIST(evAccept) accepts; - /* Files. */ - evFile *files, *fdNext; -#ifndef USE_POLL - fd_set rdLast, rdNext; - fd_set wrLast, wrNext; - fd_set exLast, exNext; - fd_set nonblockBefore; - int fdMax, fdCount, highestFD; - evFile *fdTable[FD_SETSIZE]; -#else - struct pollfd *pollfds; /* Allocated as needed */ - evFile **fdTable; /* Ditto */ - int maxnfds; /* # elements in above */ - int firstfd; /* First active fd */ - int fdMax; /* Last active fd */ - int fdCount; /* # fd:s with I/O */ - int highestFD; /* max fd allowed by OS */ - __evEmulMask rdLast, rdNext; - __evEmulMask wrLast, wrNext; - __evEmulMask exLast, exNext; - __evEmulMask nonblockBefore; -#endif /* USE_POLL */ -#ifdef EVENTLIB_TIME_CHECKS - struct timespec lastSelectTime; - int lastFdCount; -#endif - /* Streams. */ - evStream *streams; - evStream *strDone, *strLast; - /* Timers. */ - struct timespec lastEventTime; - heap_context timers; - /* Waits. */ - evWaitList *waitLists; - evWaitList waitDone; -} evContext_p; - -/* eventlib.c */ -#define evPrintf __evPrintf -void evPrintf(const evContext_p *ctx, int level, const char *fmt, ...) - ISC_FORMAT_PRINTF(3, 4); - -#ifdef USE_POLL -extern int evPollfdRealloc(evContext_p *ctx, int pollfd_chunk_size, int fd); -#endif /* USE_POLL */ - -/* ev_timers.c */ -#define evCreateTimers __evCreateTimers -heap_context evCreateTimers(const evContext_p *); -#define evDestroyTimers __evDestroyTimers -void evDestroyTimers(const evContext_p *); - -/* ev_waits.c */ -#define evFreeWait __evFreeWait -evWait *evFreeWait(evContext_p *ctx, evWait *old); - -/* Global options */ -extern int __evOptMonoTime; - -#endif /*_EVENTLIB_P_H*/ diff --git a/lib/libc/libcincludes.mk b/lib/libc/libcincludes.mk deleted file mode 100644 index 32b0b3125..000000000 --- a/lib/libc/libcincludes.mk +++ /dev/null @@ -1,20 +0,0 @@ -# $NetBSD: libcincludes.mk,v 1.2 2014/08/10 23:39:08 matt Exp $ - -# Makefile fragment shared across several parts that want to look -# inside libc's include tree. - -LIBC_MACHINE_ARCH?= ${MACHINE_ARCH} -LIBC_MACHINE_CPU?= ${MACHINE_CPU} - -.if defined(LIBC_MACHINE_ARCH) && \ - exists(${NETBSDSRCDIR}/lib/libc/arch/${LIBC_MACHINE_ARCH}/SYS.h) -ARCHSUBDIR= ${LIBC_MACHINE_ARCH} -.elif exists(${NETBSDSRCDIR}/lib/libc/arch/${LIBC_MACHINE_CPU}/SYS.h) -ARCHSUBDIR= ${LIBC_MACHINE_CPU} -.else -.BEGIN: - @echo no ARCHDIR for ${LIBC_MACHINE_ARCH} nor ${LIBC_MACHINE_CPU} - @false -.endif - -ARCHDIR= ${NETBSDSRCDIR}/lib/libc/arch/${ARCHSUBDIR} diff --git a/lib/libc/locale/Makefile.inc b/lib/libc/locale/Makefile.inc deleted file mode 100644 index b6cd592fc..000000000 --- a/lib/libc/locale/Makefile.inc +++ /dev/null @@ -1,55 +0,0 @@ -# from: @(#)Makefile.inc 5.1 (Berkeley) 2/18/91 -# $NetBSD: Makefile.inc,v 1.64 2013/08/18 20:03:48 joerg Exp $ - -# locale sources -.PATH: ${ARCHDIR}/locale ${.CURDIR}/locale - -SRCS+= setlocale.c __mb_cur_max.c \ - duplocale.c global_locale.c fix_grouping.c \ - freelocale.c localeconv.c newlocale.c nl_langinfo.c \ - generic_lc_all.c dummy_lc_collate.c \ - wcstol.c wcstoll.c wcstoimax.c wcstoul.c wcstoull.c wcstoumax.c \ - wcstod.c wcstof.c wcstold.c wcscoll.c wcsxfrm.c wcsftime.c - -# citrus multibyte locale support -# we have quirk for libc.a - see the last part of lib/libc/Makefile -CPPFLAGS+= -DWITH_RUNE -I${.CURDIR} -SRCS+= _wctrans.c _wctype.c rune.c runetable.c \ - multibyte_c90.c multibyte_amd1.c iswctype_mb.c -CPPFLAGS.rune.c+= -I${LIBCDIR}/citrus -CPPFLAGS.runetable.c+= -I${LIBCDIR}/citrus -CPPFLAGS.multibyte_c90.c+= -I${LIBCDIR}/citrus -CPPFLAGS.multibyte_amd1.c+= -I${LIBCDIR}/citrus - -MAN+= setlocale.3 nl_langinfo.3 - -MAN+= mbtowc.3 mbstowcs.3 wctomb.3 wcstombs.3 mblen.3 \ - -MAN+= btowc.3 mbrtowc.3 mbsrtowcs.3 \ - wctob.3 wcrtomb.3 wcsrtombs.3 \ - mbrlen.3 mbsinit.3 - -MAN+= iswalnum.3 wctype.3 iswctype.3 \ - towlower.3 wctrans.3 towctrans.3 \ - wcwidth.3 - -MAN+= wcstol.3 wcstod.3 \ - wcscoll.3 wcsxfrm.3 \ - wcsftime.3 - -MLINKS+=setlocale.3 localeconv.3 - -MLINKS+=iswalnum.3 iswalpha.3 iswalnum.3 iswblank.3 \ - iswalnum.3 iswcntrl.3 iswalnum.3 iswdigit.3 \ - iswalnum.3 iswgraph.3 iswalnum.3 iswlower.3 \ - iswalnum.3 iswprint.3 iswalnum.3 iswpunct.3 \ - iswalnum.3 iswspace.3 iswalnum.3 iswupper.3 \ - iswalnum.3 iswxdigit.3 - -MLINKS+=towlower.3 towupper.3 - -MLINKS+=wcstod.3 wcstof.3 wcstod.3 wcstold.3 -MLINKS+=wcstol.3 wcstoll.3 wcstol.3 wcstoimax.3 \ - wcstol.3 wcstoul.3 wcstol.3 wcstoull.3 wcstol.3 wcstoumax.3 - -COPTS.wcsftime.c = -Wno-format-nonliteral diff --git a/lib/libc/locale/__mb_cur_max.c b/lib/libc/locale/__mb_cur_max.c deleted file mode 100644 index 08c8f1d49..000000000 --- a/lib/libc/locale/__mb_cur_max.c +++ /dev/null @@ -1,39 +0,0 @@ -/* $NetBSD: __mb_cur_max.c,v 1.2 2001/01/25 01:25:06 itojun Exp $ */ - -/*- - * Copyright (c)1999 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: __mb_cur_max.c,v 1.2 2001/01/25 01:25:06 itojun Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -size_t __mb_cur_max = 1; -size_t __mb_len_max_runtime = MB_LEN_MAX; - diff --git a/lib/libc/locale/__wctoint.h b/lib/libc/locale/__wctoint.h deleted file mode 100644 index c5b695f12..000000000 --- a/lib/libc/locale/__wctoint.h +++ /dev/null @@ -1,79 +0,0 @@ -/* $NetBSD: __wctoint.h,v 1.1 2001/09/28 11:25:37 yamt Exp $ */ - -/*- - * Copyright (c)2001 Citrus Project, - * 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. - * - * $Citrus: xpg4dl/FreeBSD/lib/libc/locale/__wctoint.h,v 1.1 2001/09/21 13:52:32 yamt Exp $ - */ - - -__inline static int -__wctoint(wchar_t wc) -{ - int n; - - /* XXX I expect compiler to optimize this. :D */ - switch (wc) { - case L'0': n = 0; break; - case L'1': n = 1; break; - case L'2': n = 2; break; - case L'3': n = 3; break; - case L'4': n = 4; break; - case L'5': n = 5; break; - case L'6': n = 6; break; - case L'7': n = 7; break; - case L'8': n = 8; break; - case L'9': n = 9; break; - case L'A': case L'a': n = 10; break; - case L'B': case L'b': n = 11; break; - case L'C': case L'c': n = 12; break; - case L'D': case L'd': n = 13; break; - case L'E': case L'e': n = 14; break; - case L'F': case L'f': n = 15; break; - case L'G': case L'g': n = 16; break; - case L'H': case L'h': n = 17; break; - case L'I': case L'i': n = 18; break; - case L'J': case L'j': n = 19; break; - case L'K': case L'k': n = 20; break; - case L'L': case L'l': n = 21; break; - case L'M': case L'm': n = 22; break; - case L'N': case L'n': n = 23; break; - case L'O': case L'o': n = 24; break; - case L'P': case L'p': n = 25; break; - case L'Q': case L'q': n = 26; break; - case L'R': case L'r': n = 27; break; - case L'S': case L's': n = 28; break; - case L'T': case L't': n = 29; break; - case L'U': case L'u': n = 30; break; - case L'V': case L'v': n = 31; break; - case L'W': case L'w': n = 32; break; - case L'X': case L'x': n = 33; break; - case L'Y': case L'y': n = 34; break; - case L'Z': case L'z': n = 35; break; - default: n = -1; break; /* error */ - } - - return n; -} diff --git a/lib/libc/locale/_wcstod.h b/lib/libc/locale/_wcstod.h deleted file mode 100644 index 1b3cc4a5c..000000000 --- a/lib/libc/locale/_wcstod.h +++ /dev/null @@ -1,146 +0,0 @@ -/* $NetBSD: _wcstod.h,v 1.4 2013/05/17 12:55:57 joerg Exp $ */ - -/*- - * Copyright (c) 2002 Tim J. Robbins - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * aINre 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. - * - * Original version ID: - * FreeBSD: /repoman/r/ncvs/src/lib/libc/locale/wcstod.c,v 1.4 2004/04/07 09:47:56 tjr Exp - * NetBSD: wcstod.c,v 1.8 2006/04/13 01:25:13 tnozaki Exp - */ - -/* - * function template for wcstof, wcstod, wcstold. - * - * parameters: - * _FUNCNAME : function name - * _RETURN_TYPE : return type - * _STRTOD_FUNC : real conversion function - */ -#ifndef __WCSTOD_H_ -#define __WCSTOD_H_ - -#include -#include "setlocale_local.h" -#define INT_NAME_(pre, middle, post) pre ## middle ## post -#define INT_NAME(pre, middle, post) INT_NAME_(pre, middle, post) - -/* - * Convert a string to a double-precision number. - * - * This is the wide-character counterpart of strto{f,d,ld}(). So that - * we do not have to duplicate the code of strto{f,d,ld}() here, - * we convert the supplied wide-character string to multibyte and - * call strto{f,d,ld}() on the result. - * This assumes that the multibyte encoding is compatible with ASCII - * for at least the digits, radix character and letters. - */ -static _RETURN_TYPE -INT_NAME(_int_, _FUNCNAME, _l)(const wchar_t * __restrict nptr, - wchar_t ** __restrict endptr, locale_t loc) -{ - const wchar_t *src, *start; - _RETURN_TYPE val; - char *buf, *end; - size_t bufsiz, len; - - _DIAGASSERT(nptr != NULL); - /* endptr may be null */ - - src = nptr; - while (iswspace_l((wint_t)*src, loc) != 0) - ++src; - if (*src == L'\0') - goto no_convert; - - /* - * Convert the supplied numeric wide-char. string to multibyte. - * - * We could attempt to find the end of the numeric portion of the - * wide-char. string to avoid converting unneeded characters but - * choose not to bother; optimising the uncommon case where - * the input string contains a lot of text after the number - * duplicates a lot of strto{f,d,ld}()'s functionality and - * slows down the most common cases. - */ - start = src; - len = wcstombs_l(NULL, src, 0, loc); - if (len == (size_t)-1) - /* errno = EILSEQ */ - goto no_convert; - - _DIAGASSERT(len > 0); - - bufsiz = len; - buf = (void *)malloc(bufsiz + 1); - if (buf == NULL) - /* errno = ENOMEM */ - goto no_convert; - - len = wcstombs_l(buf, src, bufsiz + 1, loc); - - _DIAGASSERT(len == bufsiz); - _DIAGASSERT(buf[len] == '\0'); - - /* Let strto{f,d,ld}() do most of the work for us. */ - val = _STRTOD_FUNC(buf, &end, loc); - if (buf == end) { - free(buf); - goto no_convert; - } - - /* - * We only know where the number ended in the _multibyte_ - * representation of the string. If the caller wants to know - * where it ended, count multibyte characters to find the - * corresponding position in the wide-char string. - */ - if (endptr != NULL) - /* XXX Assume each wide char is one byte. */ - *endptr = __UNCONST(start + (size_t)(end - buf)); - - free(buf); - - return val; - -no_convert: - if (endptr != NULL) - *endptr = __UNCONST(nptr); - return 0; -} - -_RETURN_TYPE -INT_NAME(, _FUNCNAME, )(const wchar_t * __restrict nptr, - wchar_t ** __restrict endptr) -{ - return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, _current_locale()); -} - -_RETURN_TYPE -INT_NAME(, _FUNCNAME, _l)(const wchar_t * __restrict nptr, - wchar_t ** __restrict endptr, locale_t loc) -{ - return INT_NAME(_int_, _FUNCNAME, _l)(nptr, endptr, loc); -} -#endif /*__WCSTOD_H_*/ diff --git a/lib/libc/locale/_wcstol.h b/lib/libc/locale/_wcstol.h deleted file mode 100644 index 1dc24c4f5..000000000 --- a/lib/libc/locale/_wcstol.h +++ /dev/null @@ -1,161 +0,0 @@ -/* $NetBSD: _wcstol.h,v 1.6 2013/05/17 12:55:57 joerg Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * Original version ID: - * @(#)strtol.c 8.1 (Berkeley) 6/4/93 - * NetBSD: wcstol.c,v 1.1 2001/09/27 16:30:36 yamt Exp - * Citrus: xpg4dl/FreeBSD/lib/libc/locale/wcstol.c,v 1.2 2001/09/21 16:11:41 yamt Exp - */ - -/* - * function template for wcstol, wcstoll and wcstoimax. - * - * parameters: - * _FUNCNAME : function name - * __INT : return type - * __INT_MIN : lower limit of the return type - * __INT_MAX : upper limit of the return type - */ - -#include -#include "setlocale_local.h" -#define INT_FUNCNAME_(pre, name, post) pre ## name ## post -#define INT_FUNCNAME(pre, name, post) INT_FUNCNAME_(pre, name, post) - -static __INT -INT_FUNCNAME(_int_, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr, - int base, locale_t loc) -{ - const wchar_t *s; - __INT acc, cutoff; - wint_t wc; - int i; - int neg, any, cutlim; - - _DIAGASSERT(nptr != NULL); - /* endptr may be NULL */ - -#ifdef __GNUC__ - (void)&acc; (void)&cutoff; -#endif - - /* check base value */ - if (base && (base < 2 || base > 36)) { - errno = EINVAL; - return 0; - } - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - s = nptr; - do { - wc = (wchar_t) *s++; - } while (iswspace_l(wc, loc)); - if (wc == L'-') { - neg = 1; - wc = *s++; - } else { - neg = 0; - if (wc == L'+') - wc = *s++; - } - if ((base == 0 || base == 16) && - wc == L'0' && (*s == L'x' || *s == L'X')) { - wc = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = wc == L'0' ? 8 : 10; - - /* - * See strtol for comments as to the logic used. - */ - cutoff = neg ? __INT_MIN : __INT_MAX; - cutlim = (int)(cutoff % base); - cutoff /= base; - if (neg) { - if (cutlim > 0) { - cutlim -= base; - cutoff += 1; - } - cutlim = -cutlim; - } - for (acc = 0, any = 0;; wc = (wchar_t) *s++) { - i = __wctoint(wc); - if (i == -1) - break; - if (i >= base) - break; - if (any < 0) - continue; - if (neg) { - if (acc < cutoff || (acc == cutoff && i > cutlim)) { - any = -1; - acc = __INT_MIN; - errno = ERANGE; - } else { - any = 1; - acc *= base; - acc -= i; - } - } else { - if (acc > cutoff || (acc == cutoff && i > cutlim)) { - any = -1; - acc = __INT_MAX; - errno = ERANGE; - } else { - any = 1; - acc *= base; - acc += i; - } - } - } - if (endptr != 0) - *endptr = __UNCONST(any ? s - 1 : nptr); - return (acc); -} - -__INT -_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, - _current_locale()); -} - -__INT -INT_FUNCNAME(, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr, - int base, locale_t loc) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc); -} diff --git a/lib/libc/locale/_wcstoul.h b/lib/libc/locale/_wcstoul.h deleted file mode 100644 index 98e7ca73c..000000000 --- a/lib/libc/locale/_wcstoul.h +++ /dev/null @@ -1,137 +0,0 @@ -/* $NetBSD: _wcstoul.h,v 1.6 2013/05/17 12:55:57 joerg Exp $ */ - -/* - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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. - * - * Original version ID: - * @(#)strtoul.c 8.1 (Berkeley) 6/4/93 - * Citrus: xpg4dl/FreeBSD/lib/libc/locale/wcstoul.c,v 1.2 2001/09/21 16:11:41 yamt Exp - * NetBSD: wcstoul.c,v 1.1 2001/09/27 16:30:37 yamt Exp - */ - -/* - * function template for wcstoul, wcstoull and wcstoumax. - * - * parameters: - * _FUNCNAME : function name - * __UINT : return type - * __UINT_MAX : upper limit of the return type - */ - -#include -#include "setlocale_local.h" -#define INT_FUNCNAME_(pre, name, post) pre ## name ## post -#define INT_FUNCNAME(pre, name, post) INT_FUNCNAME_(pre, name, post) - -static __UINT -INT_FUNCNAME(_int_, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr, - int base, locale_t loc) -{ - const wchar_t *s; - __UINT acc, cutoff; - wint_t wc; - int i; - int neg, any, cutlim; - - _DIAGASSERT(nptr != NULL); - /* endptr may be NULL */ - - if (base && (base < 2 || base > 36)) { - errno = EINVAL; - return 0; - } - - /* - * Skip white space and pick up leading +/- sign if any. - * If base is 0, allow 0x for hex and 0 for octal, else - * assume decimal; if base is already 16, allow 0x. - */ - s = nptr; - do { - wc = (wchar_t) *s++; - } while (iswspace_l(wc, loc)); - if (wc == L'-') { - neg = 1; - wc = *s++; - } else { - neg = 0; - if (wc == L'+') - wc = *s++; - } - if ((base == 0 || base == 16) && - wc == L'0' && (*s == L'x' || *s == L'X')) { - wc = s[1]; - s += 2; - base = 16; - } - if (base == 0) - base = wc == L'0' ? 8 : 10; - - /* - * See strtoul for comments as to the logic used. - */ - cutoff = __UINT_MAX / (__UINT)base; - cutlim = (int)(__UINT_MAX % (__UINT)base); - for (acc = 0, any = 0;; wc = (wchar_t) *s++) { - i = __wctoint(wc); - if (i == (wint_t)-1) - break; - if (i >= base) - break; - if (any < 0) - continue; - if (acc > cutoff || (acc == cutoff && i > cutlim)) { - any = -1; - acc = __UINT_MAX; - errno = ERANGE; - } else { - any = 1; - acc *= (__UINT)base; - acc += i; - } - } - if (neg && any > 0) - acc = -acc; - if (endptr != 0) - *endptr = __UNCONST(any ? s - 1 : nptr); - return (acc); -} - -__UINT -_FUNCNAME(const wchar_t *nptr, wchar_t **endptr, int base) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, - _current_locale()); -} - -__UINT -INT_FUNCNAME(, _FUNCNAME, _l)(const wchar_t *nptr, wchar_t **endptr, - int base, locale_t loc) -{ - return INT_FUNCNAME(_int_, _FUNCNAME, _l)(nptr, endptr, base, loc); -} diff --git a/lib/libc/locale/_wctrans.c b/lib/libc/locale/_wctrans.c deleted file mode 100644 index c432c4ef6..000000000 --- a/lib/libc/locale/_wctrans.c +++ /dev/null @@ -1,106 +0,0 @@ -/* $NetBSD: _wctrans.c,v 1.17 2010/06/13 04:14:57 tnozaki Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _wctrans.c,v 1.17 2010/06/13 04:14:57 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#include "runetype_local.h" -#include "_wctrans_local.h" - -/* - * _towctrans_ext: - * translate a character (extended part) - */ -wint_t -_towctrans_ext(wint_t c, struct _WCTransEntry const *te) -{ - __nbrune_t c0; - uint32_t x; - _RuneRange *rr; - _RuneEntry *base, *re; - - _DIAGASSERT(te != NULL); - - if (c == WEOF) - return (c); - - c0 = (__nbrune_t)c; /* XXX assumes wchar_t = int */ - rr = te->te_extmap; - base = rr->rr_rune_ranges; - for (x = rr->rr_nranges; x != 0; x >>= 1) { - re = base + (x >> 1); - if (re->re_min <= c0 && re->re_max >= c0) - return (re->re_map + c0 - re->re_min); - else if (c0 >= re->re_max) { - base = re + 1; - x--; - } - } - - return (c); -} diff --git a/lib/libc/locale/_wctrans_local.h b/lib/libc/locale/_wctrans_local.h deleted file mode 100644 index d288ce767..000000000 --- a/lib/libc/locale/_wctrans_local.h +++ /dev/null @@ -1,60 +0,0 @@ -/* $NetBSD: _wctrans_local.h,v 1.9 2010/06/02 15:47:25 tnozaki Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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. - */ - -#ifndef _WCTRANS_LOCAL_H_ -#define _WCTRANS_LOCAL_H_ - -__BEGIN_DECLS -wint_t _towctrans_ext(wint_t, _WCTransEntry const *); -__END_DECLS - -static __inline wint_t -_towctrans_priv(wint_t c, _WCTransEntry const *te) -{ - return (_RUNE_ISCACHED(c) - ? (wint_t)te->te_cached[(size_t)c] - : _towctrans_ext(c, te)); -} - -static __inline struct _WCTransEntry * -_wctrans_lower(_RuneLocale *rl) -{ - _DIAGASSERT(rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name != NULL); - - return (&rl->rl_wctrans[_WCTRANS_INDEX_LOWER]); -} - -static __inline struct _WCTransEntry * -_wctrans_upper(_RuneLocale *rl) -{ - _DIAGASSERT(rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_name != NULL); - - return (&rl->rl_wctrans[_WCTRANS_INDEX_UPPER]); -} - -#endif /*_WCTRANS_LOCAL_H_*/ diff --git a/lib/libc/locale/_wctype.c b/lib/libc/locale/_wctype.c deleted file mode 100644 index 5e22ceb62..000000000 --- a/lib/libc/locale/_wctype.c +++ /dev/null @@ -1,112 +0,0 @@ -/* $NetBSD: _wctype.c,v 1.9 2010/06/13 04:14:57 tnozaki Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: _wctype.c,v 1.9 2010/06/13 04:14:57 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include "runetype_local.h" -#include "_wctrans_local.h" -#include "_wctype_local.h" - -_RuneType -_runetype_priv(_RuneLocale const *rl, wint_t wc) -{ - __nbrune_t wc0; - _RuneRange const *rr; - _RuneEntry *base, *re; - uint32_t x; - - _DIAGASSERT(rl != NULL); - - if (wc == WEOF) - return 0U; - if (_RUNE_ISCACHED(wc)) - return rl->rl_runetype[(size_t)wc]; - wc0 = (__nbrune_t)wc; - rr = &rl->rl_runetype_ext; - _DIAGASSERT(rr != NULL); - base = rr->rr_rune_ranges; - for (x = rr->rr_nranges; x != (uint32_t)0; x >>= 1) { - re = base + (x >> 1); - if (re->re_min <= wc0 && re->re_max >= wc0) { - if (re->re_rune_types) - return re->re_rune_types[wc0 - re->re_min]; - else - return re->re_map; - } else if (wc0 > re->re_max) { - base = re + 1; - --x; - } - } - return (_RuneType)0U; -} - -int -_iswctype_priv(_RuneLocale const *rl, - wint_t wc, _WCTypeEntry const *te) -{ - return !!(_runetype_priv(rl, wc) & te->te_mask); -} diff --git a/lib/libc/locale/_wctype_local.h b/lib/libc/locale/_wctype_local.h deleted file mode 100644 index 8c0322445..000000000 --- a/lib/libc/locale/_wctype_local.h +++ /dev/null @@ -1,37 +0,0 @@ -/* $NetBSD: _wctype_local.h,v 1.3 2010/06/02 15:47:25 tnozaki Exp $ */ - -/*- - * Copyright (c) 2008 Citrus Project, - * 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. - */ - -#ifndef _WCTYPE_LOCAL_H_ -#define _WCTYPE_LOCAL_H_ - -__BEGIN_DECLS -_RuneType _runetype_priv(_RuneLocale const *, wint_t); -int _iswctype_priv(_RuneLocale const *, wint_t, _WCTypeEntry const *); -__END_DECLS - -#endif /*_WCTYPE_LOCAL_H_*/ diff --git a/lib/libc/locale/aliasname_local.h b/lib/libc/locale/aliasname_local.h deleted file mode 100644 index bad619b7d..000000000 --- a/lib/libc/locale/aliasname_local.h +++ /dev/null @@ -1,74 +0,0 @@ -/* $NetBSD: aliasname_local.h,v 1.3 2009/01/11 02:46:28 christos Exp $ */ - -/*- - * Copyright (c)2002 YAMAMOTO Takashi, - * 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. - */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _ALIASNAME_LOCAL_H_ -#define _ALIASNAME_LOCAL_H_ - -const char *__unaliasname(const char *, const char *, void *, size_t); - -static __inline int -__isforcemapping(const char *name) -{ - /* don't use strcasecmp, it owes locale. */ - return - name[0] == '/' && - (name[1] == 'F' || name[1] == 'f') && - (name[2] == 'O' || name[2] == 'o') && - (name[3] == 'R' || name[3] == 'r') && - (name[4] == 'C' || name[4] == 'c') && - (name[5] == 'E' || name[5] == 'e') && - name[6] == '\0'; -} - -#endif /*_ALIASNAME_LOCAL_H_*/ diff --git a/lib/libc/locale/btowc.3 b/lib/libc/locale/btowc.3 deleted file mode 100644 index 003531d50..000000000 --- a/lib/libc/locale/btowc.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" $NetBSD: btowc.3,v 1.4 2004/01/24 16:58:54 wiz Exp $ -.\" -.\" Copyright (c)2003 Citrus Project, -.\" 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. -.\" -.Dd March 3, 2003 -.Dt BTOWC 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm btowc -.Nd convert a single byte character to a wide character -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wchar.h -.Ft wint_t -.Fn btowc "int c" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn btowc -function converts a single byte character -.Fa c -in the initial shift state of the current locale to a corresponding -wide character. -.Pp -The behaviour of -.Fn btowc -is affected by the -.Dv LC_CTYPE -category of the current locale. -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -The -.Fn btowc -function returns: -.Bl -tag -width 012345678901 -.It Dv WEOF -If -.Fa c -is -.Dv EOF -or if (unsigned char) -.Fa c -does not correspond to a valid single byte character representation. -.It (otherwise) -A wide character corresponding to -.Fa c . -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -No errors are defined. -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mbrtowc 3 , -.Xr setlocale 3 , -.Xr wctob 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn btowc -function conforms to -.St -isoC-amd1 . diff --git a/lib/libc/locale/ctype_local.h b/lib/libc/locale/ctype_local.h deleted file mode 100644 index b8a230c72..000000000 --- a/lib/libc/locale/ctype_local.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: ctype_local.h,v 1.5 2013/04/13 10:21:20 joerg Exp $ */ - -/*- - * Copyright (c) 2010 Citrus Project, - * 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. - */ -#ifndef _CTYPE_LOCAL_H_ -#define _CTYPE_LOCAL_H_ - -#include - -#define _CTYPE_NUM_CHARS (1 << CHAR_BIT) -#define _CTYPE_CACHE_SIZE (1 << 8) - -#define _COMPAT_U 0x01 -#define _COMPAT_L 0x02 -#define _COMPAT_N 0x04 -#define _COMPAT_S 0x08 -#define _COMPAT_P 0x10 -#define _COMPAT_C 0x20 -#define _COMPAT_X 0x40 -#define _COMPAT_B 0x80 - -extern const unsigned short _C_ctype_tab_[]; -extern const short _C_toupper_tab_[]; -extern const short _C_tolower_tab_[]; - -#ifdef __BUILD_LEGACY -extern const unsigned char *_ctype_; -extern const unsigned char _C_compat_bsdctype[]; -#endif - -#endif /*_CTYPE_LOCAL_H_*/ diff --git a/lib/libc/locale/dummy_lc_collate.c b/lib/libc/locale/dummy_lc_collate.c deleted file mode 100644 index 10c952c5f..000000000 --- a/lib/libc/locale/dummy_lc_collate.c +++ /dev/null @@ -1,53 +0,0 @@ -/* $NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: dummy_lc_collate.c,v 1.3 2012/03/04 21:14:56 tnozaki Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include - -#include "setlocale_local.h" - -/* - * macro required by dummy_lc_template.h - */ -#define _PREFIX(name) __CONCAT(_dummy_LC_COLLATE_,name) - -#define _CATEGORY_ID LC_COLLATE -#define _CATEGORY_NAME "LC_COLLATE" - -#include "dummy_lc_template.h" diff --git a/lib/libc/locale/dummy_lc_template.h b/lib/libc/locale/dummy_lc_template.h deleted file mode 100644 index ac9e3de1b..000000000 --- a/lib/libc/locale/dummy_lc_template.h +++ /dev/null @@ -1,54 +0,0 @@ -/* $NetBSD: dummy_lc_template.h,v 1.4 2013/04/14 23:30:16 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _DUMMY_LC_TEMPLATE_H_ -#define _DUMMY_LC_TEMPLATE_H_ - -#include "generic_lc_template_decl.h" - -const char * -_PREFIX(setlocale)(const char * __restrict name, - struct _locale * __restrict locale) -{ - if (name != NULL) { - if (*name == '\0') - name = _get_locale_env(_CATEGORY_NAME); - if (strcmp(name, locale->part_name[(size_t)_CATEGORY_ID])) { - if (!strcmp(_C_LOCALE, name)) - name = _C_LOCALE; - else if (!strcmp(_POSIX_LOCALE, name)) - name = _POSIX_LOCALE; - else - return NULL; - locale->part_name[(size_t)_CATEGORY_ID] = name; - } - } - return locale->part_name[(size_t)_CATEGORY_ID]; -} - -#endif /*_DUMMY_LC_TEMPLATE_H_*/ diff --git a/lib/libc/locale/duplocale.c b/lib/libc/locale/duplocale.c deleted file mode 100644 index 6217fdaf1..000000000 --- a/lib/libc/locale/duplocale.c +++ /dev/null @@ -1,52 +0,0 @@ -/* $NetBSD: duplocale.c,v 1.1 2013/04/30 00:45:05 joerg Exp $ */ - -/*- - * Copyright (c)2008, 2011 Citrus Project, - * 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 -__RCSID("$NetBSD: duplocale.c,v 1.1 2013/04/30 00:45:05 joerg Exp $"); - -#include "namespace.h" - -#include -#include -#include - -#include "setlocale_local.h" - -__weak_alias(duplocale, _duplocale) - -locale_t -duplocale(locale_t src) -{ - struct _locale *dst; - - dst = malloc(sizeof(*dst)); - if (dst != NULL) - memcpy(dst, src, sizeof(*dst)); - - return dst; -} diff --git a/lib/libc/locale/fix_grouping.c b/lib/libc/locale/fix_grouping.c deleted file mode 100644 index 8fe5911b0..000000000 --- a/lib/libc/locale/fix_grouping.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $ */ - -/* - * Copyright (c) 2001 Alexey Zelkin - * 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. - * - * Original version ID: - * FreeBSD: fix_grouping.c,v 1.8 2003/06/26 10:46:16 phantom Exp - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fix_grouping.c,v 1.6 2012/03/21 14:11:24 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include "fix_grouping.h" - -#ifndef NBCHAR_MAX -#define NBCHAR_MAX (char)CHAR_MAX -#endif - -#ifndef __UNCONST -#define __UNCONST(a) ((void *)(unsigned long)(const void *)(a)) -#endif - -static const char nogrouping[] = { NBCHAR_MAX, '\0' }; - -/* don't use libc's isdigit, it owes locale. */ -#define isdigit(c) (c >= '0' && c <= '9') - -/* - * Internal helper used to convert grouping sequences from string - * representation into POSIX specified form, i.e. - * - * "3;3;-1" -> "\003\003\177\000" - */ - -const char * -__fix_locale_grouping_str(const char *str) -{ - char *src, *dst; - char n; - - if (str == NULL || *str == '\0') { - return nogrouping; - } - - for (src = __UNCONST(str), dst = __UNCONST(str); *src != '\0'; src++) { - - /* input string examples: "3;3", "3;2;-1" */ - if (*src == ';') - continue; - - if (*src == '-' && *(src+1) == '1') { - *dst++ = NBCHAR_MAX; - src++; - continue; - } - - if (!isdigit((unsigned char)*src)) { - /* broken grouping string */ - return nogrouping; - } - - /* assume all numbers <= 99 */ - n = *src - '0'; - if (isdigit((unsigned char)*(src+1))) { - src++; - n *= 10; - n += *src - '0'; - } - - *dst = n; - /* NOTE: assume all input started with "0" as 'no grouping' */ - if (*dst == '\0') - return (dst == __UNCONST(str)) ? nogrouping : str; - dst++; - } - *dst = '\0'; - return str; -} diff --git a/lib/libc/locale/fix_grouping.h b/lib/libc/locale/fix_grouping.h deleted file mode 100644 index 7da873372..000000000 --- a/lib/libc/locale/fix_grouping.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: fix_grouping.h,v 1.2 2009/01/11 02:46:28 christos Exp $ */ - -/*- - * Copyright (c) 2008 Citrus Project, - * 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. - */ - -#ifndef _FIX_GROUPING_H_ -#define _FIX_GROUPING_H_ - -__BEGIN_DECLS -const char *__fix_locale_grouping_str(const char *); -__END_DECLS - -#endif /*_FIX_GROUPING_H_*/ diff --git a/lib/libc/locale/freelocale.c b/lib/libc/locale/freelocale.c deleted file mode 100644 index 8d408cc6e..000000000 --- a/lib/libc/locale/freelocale.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: freelocale.c,v 1.2 2013/05/17 12:55:57 joerg Exp $ */ - -/*- - * Copyright (c)2008, 2011 Citrus Project, - * 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 -__RCSID("$NetBSD: freelocale.c,v 1.2 2013/05/17 12:55:57 joerg Exp $"); - -#include "namespace.h" - -#define __SETLOCALE_SOURCE__ -#include -#include -#include - -#include "setlocale_local.h" - -__weak_alias(freelocale, _freelocale) - -void -freelocale(locale_t locale) -{ - - _DIAGASSERT(locale != LC_GLOBAL_LOCALE); - _DIAGASSERT(locale != LC_C_LOCALE); - _DIAGASSERT(locale != NULL); - free(locale); -} diff --git a/lib/libc/locale/generic_lc_all.c b/lib/libc/locale/generic_lc_all.c deleted file mode 100644 index 1c7f43e74..000000000 --- a/lib/libc/locale/generic_lc_all.c +++ /dev/null @@ -1,117 +0,0 @@ -/* $NetBSD: generic_lc_all.c,v 1.5 2013/04/14 23:30:16 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: generic_lc_all.c,v 1.5 2013/04/14 23:30:16 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include - -#include "setlocale_local.h" - -/* - * macro required by all template headers - */ -#define _PREFIX(name) __CONCAT(_generic_LC_ALL_, name) - -#include "generic_lc_template_decl.h" - -const char * -_generic_LC_ALL_setlocale(const char * __restrict name, - struct _locale * __restrict locale) -{ - _locale_set_t sl; - char head[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)], *tail; - const char *tokens[_LC_LAST], *s, *t; - int load_locale_success, i, j; - - sl = _find_category(1); - _DIAGASSERT(sl != NULL); - load_locale_success = 0; - if (name != NULL) { - strlcpy(&head[0], name, sizeof(head)); - tokens[1] = &head[0]; - tail = strchr(tokens[1], '/'); - if (tail == NULL) { - for (i = 2; i < _LC_LAST; ++i) - tokens[i] = tokens[1]; - } else { - *tail++ = '\0'; - for (i = 2; i < _LC_LAST - 1; ++i) { - tokens[i] = (const char *)tail; - tail = strchr(tokens[i], '/'); - if (tail == NULL) - return NULL; - *tail++ = '\0'; - } - tokens[_LC_LAST - 1] = (const char *)tail; - tail = strchr(tokens[i], '/'); - if (tail != NULL) - return NULL; - } - if ((*sl)(tokens[1], locale) != NULL) - load_locale_success = 1; - } - s = (*sl)(NULL, locale); - _DIAGASSERT(s != NULL); - strlcpy(&locale->query[0], s, sizeof(locale->query)); - for (i = 2, j = 0; i < _LC_LAST; ++i) { - sl = _find_category(i); - _DIAGASSERT(sl != NULL); - if (name != NULL) { - if ((*sl)(tokens[i], locale) != NULL) - load_locale_success = 1; - } - t = (*sl)(NULL, locale); - _DIAGASSERT(t != NULL); - if (j == 0) { - if (!strcmp(s, t)) - continue; - for (j = 2; j < i; ++j) { - strlcat(&locale->query[0], "/", - sizeof(locale->query)); - strlcat(&locale->query[0], s, - sizeof(locale->query)); - } - } - strlcat(&locale->query[0], "/", sizeof(locale->query)); - strlcat(&locale->query[0], t, sizeof(locale->query)); - } - if (name != NULL && !load_locale_success) - return NULL; - return (const char *)&locale->query[0]; -} - diff --git a/lib/libc/locale/generic_lc_template_decl.h b/lib/libc/locale/generic_lc_template_decl.h deleted file mode 100644 index c90eb8353..000000000 --- a/lib/libc/locale/generic_lc_template_decl.h +++ /dev/null @@ -1,35 +0,0 @@ -/* $NetBSD: generic_lc_template_decl.h,v 1.4 2013/04/14 23:30:16 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _GENERIC_LC_TEMPLATE_DECL_H_ -#define _GENERIC_LC_TEMPLATE_DECL_H_ - -const char * _PREFIX(setlocale)(const char * __restrict, - struct _locale * __restrict); - -#endif /*_GENERIC_LC_TEMPLATE_DECL_H_*/ diff --git a/lib/libc/locale/global_locale.c b/lib/libc/locale/global_locale.c deleted file mode 100644 index 2dc016112..000000000 --- a/lib/libc/locale/global_locale.c +++ /dev/null @@ -1,200 +0,0 @@ -/* $NetBSD: global_locale.c,v 1.21 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: global_locale.c,v 1.21 2013/09/13 13:13:32 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include - -#include "runetype_local.h" -#include "setlocale_local.h" - -#ifndef NBCHAR_MAX -#define NBCHAR_MAX (char)CHAR_MAX -#endif - -static const _MessagesLocale _DefaultMessagesLocale = { - "^[Yy]", - "^[Nn]", - "yes", - "no" -}; - -static const _MonetaryLocale _DefaultMonetaryLocale = { - "", - "", - "", - "", - "", - "", - "", - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX, - (char)CHAR_MAX -}; - -static const _NumericLocale _DefaultNumericLocale = { - ".", - "", - "" -}; - -static const _TimeLocale _DefaultTimeLocale = -{ - { - "Sun","Mon","Tue","Wed","Thu","Fri","Sat", - }, - { - "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", - "Friday", "Saturday" - }, - { - "Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" - }, - { - "January", "February", "March", "April", "May", "June", "July", - "August", "September", "October", "November", "December" - }, - { - "AM", "PM" - }, - "%a %b %e %H:%M:%S %Y", - "%m/%d/%y", - "%H:%M:%S", - "%I:%M:%S %p" -}; - -static const char _lc_C_locale_name[] = _C_LOCALE; - -__dso_hidden const struct _locale_cache_t _C_cache = { - .ldata = { - .decimal_point = __UNCONST("."), - .thousands_sep = __UNCONST(""), - .grouping = __UNCONST(""), - .int_curr_symbol = __UNCONST(""), - .currency_symbol = __UNCONST(""), - .mon_decimal_point = __UNCONST(""), - .mon_thousands_sep = __UNCONST(""), - .mon_grouping = __UNCONST(""), - .positive_sign = __UNCONST(""), - .negative_sign = __UNCONST(""), - .int_frac_digits = NBCHAR_MAX, - .frac_digits = NBCHAR_MAX, - .p_cs_precedes = NBCHAR_MAX, - .p_sep_by_space = NBCHAR_MAX, - .n_cs_precedes = NBCHAR_MAX, - .n_sep_by_space = NBCHAR_MAX, - .p_sign_posn = NBCHAR_MAX, - .n_sign_posn = NBCHAR_MAX, - .int_p_cs_precedes = NBCHAR_MAX, - .int_n_cs_precedes = NBCHAR_MAX, - .int_p_sep_by_space = NBCHAR_MAX, - .int_n_sep_by_space = NBCHAR_MAX, - .int_p_sign_posn = NBCHAR_MAX, - .int_n_sign_posn = NBCHAR_MAX, - }, - .monetary_name = _lc_C_locale_name, - .numeric_name = _lc_C_locale_name, -}; - -__dso_protected struct _locale _lc_global_locale = { - .cache = &_C_cache, - .query = { _C_LOCALE }, - .part_name = { - [(size_t)LC_ALL ] = _lc_C_locale_name, - [(size_t)LC_COLLATE ] = _lc_C_locale_name, - [(size_t)LC_CTYPE ] = _lc_C_locale_name, - [(size_t)LC_MONETARY] = _lc_C_locale_name, - [(size_t)LC_NUMERIC ] = _lc_C_locale_name, - [(size_t)LC_TIME ] = _lc_C_locale_name, - [(size_t)LC_MESSAGES] = _lc_C_locale_name, - }, - .part_impl = { - [(size_t)LC_ALL ] = (_locale_part_t)NULL, - [(size_t)LC_COLLATE ] = (_locale_part_t)NULL, - [(size_t)LC_CTYPE ] = (_locale_part_t) - __UNCONST(&_DefaultRuneLocale), - [(size_t)LC_MONETARY] = (_locale_part_t) - __UNCONST(&_DefaultMonetaryLocale), - [(size_t)LC_NUMERIC ] = (_locale_part_t) - __UNCONST(&_DefaultNumericLocale), - [(size_t)LC_MESSAGES] = (_locale_part_t) - __UNCONST(&_DefaultMessagesLocale), - [(size_t)LC_TIME] = (_locale_part_t) - __UNCONST(&_DefaultTimeLocale), - }, -}; - -__dso_protected const struct _locale _lc_C_locale = { - .cache = &_C_cache, - .query = { _C_LOCALE }, - .part_name = { - [(size_t)LC_ALL ] = _lc_C_locale_name, - [(size_t)LC_COLLATE ] = _lc_C_locale_name, - [(size_t)LC_CTYPE ] = _lc_C_locale_name, - [(size_t)LC_MONETARY] = _lc_C_locale_name, - [(size_t)LC_NUMERIC ] = _lc_C_locale_name, - [(size_t)LC_TIME ] = _lc_C_locale_name, - [(size_t)LC_MESSAGES] = _lc_C_locale_name, - }, - .part_impl = { - [(size_t)LC_ALL ] = (_locale_part_t)NULL, - [(size_t)LC_COLLATE ] = (_locale_part_t)NULL, - [(size_t)LC_CTYPE ] = (_locale_part_t) - __UNCONST(&_DefaultRuneLocale), - [(size_t)LC_MONETARY] = (_locale_part_t) - __UNCONST(&_DefaultMonetaryLocale), - [(size_t)LC_NUMERIC ] = (_locale_part_t) - __UNCONST(&_DefaultNumericLocale), - [(size_t)LC_MESSAGES] = (_locale_part_t) - __UNCONST(&_DefaultMessagesLocale), - [(size_t)LC_TIME] = (_locale_part_t) - __UNCONST(&_DefaultTimeLocale), - }, -}; diff --git a/lib/libc/locale/iswalnum.3 b/lib/libc/locale/iswalnum.3 deleted file mode 100644 index d986995a1..000000000 --- a/lib/libc/locale/iswalnum.3 +++ /dev/null @@ -1,116 +0,0 @@ -.\" $NetBSD: iswalnum.3,v 1.9 2004/01/24 16:58:54 wiz Exp $ -.\" -.\" Copyright (c) 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)isalnum.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd December 22, 2000 -.Dt ISWALNUM 3 -.Os -.Sh NAME -.Nm iswalnum , -.Nm iswalpha , -.Nm iswblank , -.Nm iswcntrl , -.Nm iswdigit , -.Nm iswgraph , -.Nm iswlower , -.Nm iswprint , -.Nm iswpunct , -.Nm iswspace , -.Nm iswupper , -.Nm iswxdigit -.Nd wide character classification utilities -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wctype.h -.Ft int -.Fn iswalnum "wint_t wc" -.Ft int -.Fn iswalpha "wint_t wc" -.Ft int -.Fn iswblank "wint_t wc" -.Ft int -.Fn iswcntrl "wint_t wc" -.Ft int -.Fn iswdigit "wint_t wc" -.Ft int -.Fn iswgraph "wint_t wc" -.Ft int -.Fn iswlower "wint_t wc" -.Ft int -.Fn iswprint "wint_t wc" -.Ft int -.Fn iswpunct "wint_t wc" -.Ft int -.Fn iswspace "wint_t wc" -.Ft int -.Fn iswupper "wint_t wc" -.Ft int -.Fn iswxdigit "wint_t wc" -.Sh DESCRIPTION -The functions are character classification utility functions, -for use with wide characters -.Po -.Fa wchar_t -or -.Fa wint_t -.Pc . -See the description of singlebyte classification functions, like -.Xr isalnum 3 , -for details. -.Sh RETURN VALUES -The functions return zero if the character tests false and -return non-zero if the character tests true. -.Sh SEE ALSO -.Xr isalnum 3 , -.Xr isalpha 3 , -.Xr isblank 3 , -.Xr iscntrl 3 , -.Xr isdigit 3 , -.Xr isgraph 3 , -.Xr islower 3 , -.Xr isprint 3 , -.Xr ispunct 3 , -.Xr isspace 3 , -.Xr isupper 3 , -.Xr isxdigit 3 -.Sh STANDARDS -The functions conform to -.St -isoC-99 . -.Sh CAVEATS -The argument to these functions must be -.Dv WEOF -or a valid -.Fa wchar_t -value with the current locale; otherwise, the result is undefined. diff --git a/lib/libc/locale/iswctype.3 b/lib/libc/locale/iswctype.3 deleted file mode 100644 index 6225844ae..000000000 --- a/lib/libc/locale/iswctype.3 +++ /dev/null @@ -1,99 +0,0 @@ -.\" $NetBSD: iswctype.3,v 1.7 2007/05/21 15:20:40 tnozaki Exp $ -.\" -.\" Copyright (c)2003 Citrus Project, -.\" 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. -.\" -.Dd March 4, 2003 -.Dt ISWCTYPE 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm iswctype -.Nd test a character for character class identifier -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wctype.h -.Ft int -.Fn iswctype "wint_t wc" "wctype_t charclass" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn iswctype -function returns a boolean value that indicates whether a wide character -.Fa wc -is in -.Fa charclass . -.Pp -The behaviour of -.Fn iswctype -is undefined if the -.Fn iswctype -function is called with an invalid -.Fa charclass -(changes of -.Dv LC_CTYPE -category invalidate -.Fa charclass ) -or invalid wide character -.Fa wc . -.Pp -The behaviour of -.Fn iswctype -is affected by the -.Dv LC_CTYPE -category of the current locale. -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -The -.Fn iswctype -returns: -.Bl -tag -width 012345678901 -.It 0 -.Fa wc -is not in -.Fa charclass . -.It non-zero -.Fa wc -is in -.Fa charclass . -.El -.Pp -.\" ---------------------------------------------------------------------- -.Sh ERRORS -No errors are defined. -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr setlocale 3 , -.Xr towctrans 3 , -.Xr wctrans 3 , -.Xr wctype 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn iswctype -function conforms to -.St -isoC-amd1 . diff --git a/lib/libc/locale/iswctype_mb.c b/lib/libc/locale/iswctype_mb.c deleted file mode 100644 index b0ee10a91..000000000 --- a/lib/libc/locale/iswctype_mb.c +++ /dev/null @@ -1,235 +0,0 @@ -/* $NetBSD: iswctype_mb.c,v 1.13 2013/05/17 12:55:57 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: iswctype_mb.c,v 1.13 2013/05/17 12:55:57 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include - -#include "setlocale_local.h" - -#include "runetype_local.h" -#include "_wctype_local.h" -#include "_wctrans_local.h" - -#define _RUNE_LOCALE(loc) ((_RuneLocale const *) \ - (loc)->part_impl[(size_t)LC_CTYPE]) - -#define _ISWCTYPE_FUNC(name, index) \ -int \ -isw##name##_l(wint_t wc, locale_t loc) \ -{ \ - _RuneLocale const *rl; \ - _WCTypeEntry const *te; \ - \ - rl = _RUNE_LOCALE(loc); \ - te = &rl->rl_wctype[index]; \ - return _iswctype_priv(rl, wc, te); \ -} \ -int \ -isw##name(wint_t wc) \ -{ \ - return isw##name##_l(wc, _current_locale()); \ -} - -_ISWCTYPE_FUNC(alnum, _WCTYPE_INDEX_ALNUM) -_ISWCTYPE_FUNC(alpha, _WCTYPE_INDEX_ALPHA) -_ISWCTYPE_FUNC(blank, _WCTYPE_INDEX_BLANK) -_ISWCTYPE_FUNC(cntrl, _WCTYPE_INDEX_CNTRL) -_ISWCTYPE_FUNC(digit, _WCTYPE_INDEX_DIGIT) -_ISWCTYPE_FUNC(graph, _WCTYPE_INDEX_GRAPH) -_ISWCTYPE_FUNC(lower, _WCTYPE_INDEX_LOWER) -_ISWCTYPE_FUNC(print, _WCTYPE_INDEX_PRINT) -_ISWCTYPE_FUNC(punct, _WCTYPE_INDEX_PUNCT) -_ISWCTYPE_FUNC(space, _WCTYPE_INDEX_SPACE) -_ISWCTYPE_FUNC(upper, _WCTYPE_INDEX_UPPER) -_ISWCTYPE_FUNC(xdigit, _WCTYPE_INDEX_XDIGIT) - -#define _TOWCTRANS_FUNC(name, index) \ -wint_t \ -tow##name##_l(wint_t wc, locale_t loc) \ -{ \ - _RuneLocale const *rl; \ - _WCTransEntry const *te; \ - \ - rl = _RUNE_LOCALE(loc); \ - te = &rl->rl_wctrans[index]; \ - return _towctrans_priv(wc, te); \ -} \ -wint_t \ -tow##name(wint_t wc) \ -{ \ - return tow##name##_l(wc, _current_locale()); \ -} -_TOWCTRANS_FUNC(upper, _WCTRANS_INDEX_UPPER) -_TOWCTRANS_FUNC(lower, _WCTRANS_INDEX_LOWER) - -wctype_t -wctype_l(const char *charclass, locale_t loc) -{ - _RuneLocale const *rl; - size_t i; - - rl = _RUNE_LOCALE(loc); - for (i = 0; i < _WCTYPE_NINDEXES; ++i) { - if (!strcmp(rl->rl_wctype[i].te_name, charclass)) - return (wctype_t)__UNCONST(&rl->rl_wctype[i]); - } - return (wctype_t)NULL; -} - -wctype_t -wctype(const char *charclass) -{ - return wctype_l(charclass, _current_locale()); -} - -wctrans_t -wctrans_l(const char *charmap, locale_t loc) -{ - _RuneLocale const *rl; - size_t i; - - rl = _RUNE_LOCALE(loc); - for (i = 0; i < _WCTRANS_NINDEXES; ++i) { - _DIAGASSERT(rl->rl_wctrans[i].te_name != NULL); - if (!strcmp(rl->rl_wctrans[i].te_name, charmap)) - return (wctrans_t)__UNCONST(&rl->rl_wctype[i]); - } - return (wctrans_t)NULL; -} - -wctrans_t -wctrans(const char *charmap) -{ - return wctrans_l(charmap, _current_locale()); -} - -int -iswctype_l(wint_t wc, wctype_t charclass, locale_t loc) -{ - _RuneLocale const *rl; - _WCTypeEntry const *te; - - if (charclass == NULL) { - errno = EINVAL; - return 0; - } - - rl = _RUNE_LOCALE(loc); - te = (_WCTypeEntry const *)(void *)charclass; - return _iswctype_priv(rl, wc, te); -} - -int -iswctype(wint_t wc, wctype_t charclass) -{ - return iswctype_l(wc, charclass, _current_locale()); -} - -wint_t -towctrans(wint_t wc, wctrans_t charmap) -{ - _WCTransEntry const *te; - - if (charmap == NULL) { - errno = EINVAL; - return wc; - } - te = (_WCTransEntry const *)(void *)charmap; - return _towctrans_priv(wc, te); -} - -/* ARGSUSED */ -wint_t -towctrans_l(wint_t wc, wctrans_t charmap, locale_t loc) -{ - return towctrans(wc, charmap); -} - -__weak_alias(wcwidth,_wcwidth) -__weak_alias(wcwidth_l,_wcwidth_l) - -int -wcwidth_l(wchar_t wc, locale_t loc) -{ - _RuneLocale const *rl; - _RuneType x; - - if (wc == L'\0') - return 0; - - rl = _RUNE_LOCALE(loc); - x = _runetype_priv(rl, wc); - if (x & _RUNETYPE_R) - return ((unsigned)x & _RUNETYPE_SWM) >> _RUNETYPE_SWS; - return -1; -} - -int -wcwidth(wchar_t wc) -{ - return wcwidth_l(wc, _current_locale()); -} - -int -wcswidth_l(const wchar_t * __restrict ws, size_t wn, locale_t loc) -{ - _RuneLocale const *rl; - _RuneType x; - int width; - - _DIAGASSERT(ws != NULL); - - rl = _RUNE_LOCALE(loc); - width = 0; - while (wn > 0 && *ws != L'\0') { - x = _runetype_priv(rl, *ws); - if ((x & _RUNETYPE_R) == 0) - return -1; - width += ((unsigned)x & _RUNETYPE_SWM) >> _RUNETYPE_SWS; - ++ws, --wn; - } - return width; -} - -int -wcswidth(const wchar_t * __restrict ws, size_t wn) -{ - return wcswidth_l(ws, wn, _current_locale()); -} diff --git a/lib/libc/locale/localeconv.c b/lib/libc/locale/localeconv.c deleted file mode 100644 index 6ec10571a..000000000 --- a/lib/libc/locale/localeconv.c +++ /dev/null @@ -1,51 +0,0 @@ -/* $NetBSD: localeconv.c,v 1.22 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: localeconv.c,v 1.22 2013/09/13 13:13:32 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#define __SETLOCALE_SOURCE__ -#include - -#include "setlocale_local.h" - -struct lconv * -localeconv(void) -{ - return localeconv_l(_current_locale()); -} - -struct lconv * -localeconv_l(locale_t loc) -{ - return __UNCONST(&loc->cache->ldata); -} diff --git a/lib/libc/locale/localeio.h b/lib/libc/locale/localeio.h deleted file mode 100644 index 815729eb6..000000000 --- a/lib/libc/locale/localeio.h +++ /dev/null @@ -1,36 +0,0 @@ -/* $NetBSD: localeio.h,v 1.4 2010/06/19 13:26:52 tnozaki Exp $ */ -/* - * Copyright (c) 2008, The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Brian Ginsbach. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -__BEGIN_DECLS -int _localeio_map_file(const char * __restrict, - void ** __restrict, size_t * __restrict); -void _localeio_unmap_file(void *, size_t); -int __loadlocale(const char *, size_t, size_t, size_t, void *); -__END_DECLS diff --git a/lib/libc/locale/mblen.3 b/lib/libc/locale/mblen.3 deleted file mode 100644 index e40f9a434..000000000 --- a/lib/libc/locale/mblen.3 +++ /dev/null @@ -1,180 +0,0 @@ -.\" $NetBSD: mblen.3,v 1.6 2006/10/14 07:51:01 wiz Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd February 3, 2002 -.Dt MBLEN 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm mblen -.Nd get number of bytes in a multibyte character -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In stdlib.h -.Ft int -.Fn mblen "const char *s" "size_t n" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn mblen -function usually determines the number of bytes in -a multibyte character pointed to by -.Fa s -and returns it. -This function shall only examine max n bytes of the array beginning from -.Fa s . -.Pp -In state-dependent encodings, -.Fa s -may point the special sequence bytes to change the shift-state. -Although such sequence bytes corresponds to no individual -wide-character code, -the -.Fn mblen -changes the own state by them and treats them -as if they are a part of the subsequent multibyte character. -.Pp -Unlike -.Xr mbrlen 3 , -the first -.Fa n -bytes pointed to by -.Fa s -need to form an entire multibyte character. -Otherwise, this function causes an error. -.Pp -.Fn mblen -is equivalent to the following call, except the internal state of the -.Xr mbtowc 3 -function is not affected: -.Bd -literal -offset indent -mbtowc(NULL, s, n); -.Ed -.Pp -Calling any other functions in -.Lb libc -never changes the internal -state of -.Fn mblen , -except for calling -.Xr setlocale 3 -with the -.Dv LC_CTYPE -category changed to that of the current locale. -Such -.Xr setlocale 3 -calls cause the internal state of this function to be indeterminate. -.Pp -The behaviour of -.Fn mblen -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -These are the special cases: -.Bl -tag -width 0123456789 -.It "s == NULL" -.Fn mblen -initializes its own internal state to an initial state, and -determines whether the current encoding is state-dependent. -This function returns 0 if the encoding is state-independent, -otherwise non-zero. -.It "n == 0" -In this case, -the first -.Fa n -bytes of the array pointed to by -.Fa s -never form a complete character. -Thus, -.Fn mblen -always fails. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -Normally, -.Fn mblen -returns: -.Bl -tag -width 0123456789 -.It "0" -.Fa s -points to a nul byte -.Pq Sq \e0 . -.It "positive" -The value returned is -a number of bytes for the valid multibyte character pointed to by -.Fa s . -There are no cases that this value is greater than -.Fa n -or the value of the -.Dv MB_CUR_MAX -macro. -.It "-1" -.Fa s -points to an invalid or incomplete multibyte character. -The -.Fn mblen -also sets -.Va errno -to indicate the error. -.El -.Pp -When -.Fa s -is equal to -.Dv NULL , -the -.Fn mblen -returns: -.Bl -tag -width 0123456789 -.It "0" -The current encoding is state-independent. -.It "non-zero" -The current encoding is state-dependent. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn mblen -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa s -points to an invalid or incomplete multibyte character. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mbrlen 3 , -.Xr mbtowc 3 , -.Xr setlocale 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn mblen -function conforms to -.St -ansiC . diff --git a/lib/libc/locale/mbrlen.3 b/lib/libc/locale/mbrlen.3 deleted file mode 100644 index 34cd0e47f..000000000 --- a/lib/libc/locale/mbrlen.3 +++ /dev/null @@ -1,206 +0,0 @@ -.\" $NetBSD: mbrlen.3,v 1.9 2008/02/28 19:36:51 tnozaki Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd February 3, 2002 -.Dt MBRLEN 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm mbrlen -.Nd get number of bytes in a multibyte character (restartable) -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn mbrlen "const char * restrict s" "size_t n" "mbstate_t * restrict ps" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn mbrlen -function usually determines the number of bytes in -a multibyte character pointed to by -.Fa s -and returns it. -This function shall only examine max n bytes of the array beginning from -.Fa s . -.Pp -.Fn mbrlen -is equivalent to the following call (except -.Fa ps -is evaluated only once): -.Bd -literal -offset indent -mbrtowc(NULL, s, n, (ps != NULL) ? ps : \*[Am]internal); -.Ed -.Pp -Here, -.Fa internal -is an internal state object. -.Pp -In state-dependent encodings, -.Fa s -may point to the special sequence bytes to change the shift-state. -Although such sequence bytes corresponds to no individual -wide-character code, these affect the conversion state object pointed -to by -.Fa ps , -and the -.Fn mbrlen -treats the special sequence bytes -as if these are a part of the subsequent multibyte character. -.Pp -Unlike -.Xr mblen 3 , -.Fn mbrlen -may accept the byte sequence when it is not a complete character -but possibly contains part of a valid character. -In this case, this function will accept all such bytes -and save them into the conversion state object pointed to by -.Fa ps . -They will be used on subsequent calls of this function to restart -the conversion suspended. -.Pp -The behaviour of -.Fn mbrlen -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -These are the special cases: -.Bl -tag -width 0123456789 -.It "s == NULL" -.Fn mbrlen -sets the conversion state object pointed to by -.Fa ps -to an initial state and always returns 0. -Unlike -.Xr mblen 3 , -the value returned does not indicate whether the current encoding of -the locale is state-dependent. -.Pp -In this case, -.Fn mbrlen -ignores -.Fa n . -.It "n == 0" -In this case, -the first -.Fa n -bytes of the array pointed to by -.Fa s -never form a complete character. -Thus, -.Fn mbrlen -always returns (size_t)-2. -.It "ps == NULL" -.Fn mbrlen -uses its own internal state object to keep the conversion state, -instead of -.Fa ps -mentioned in this manual page. -.Pp -Calling any other functions in -.Lb libc -never changes the internal -state of -.Fn mbrlen , -except for calling -.Xr setlocale 3 -with a changing -.Dv LC_CTYPE -category of the current locale. -Such -.Xr setlocale 3 -calls cause the internal state of this function to be indeterminate. -This internal state is initialized at startup time of the program. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -The -.Fn mbrlen -returns: -.Bl -tag -width 0123456789 -.It "0" -.Fa s -points to a nul byte -.Pq Sq \e0 . -.It "positive" -The value returned is -a number of bytes for the valid multibyte character pointed to by -.Fa s . -There are no cases that this value is greater than -.Fa n -or the value of the -.Dv MB_CUR_MAX -macro. -.It "(size_t)-2" -.Fa s -points to the byte sequence which possibly contains part of a valid -multibyte character, but which is incomplete. -When -.Fa n -is at least -.Dv MB_CUR_MAX , -this case can only occur if the array pointed to by -.Fa s -contains a redundant shift sequence. -.It "(size_t)-1" -.Fa s -points to an illegal byte sequence which does not form a valid multibyte -character. -In this case, -.Fn mbrtowc -sets -.Va errno -to indicate the error. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn mbrlen -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa s -points to an invalid multibyte character. -.It Bq Er EINVAL -.Fa ps -points to an invalid or uninitialized mbstate_t object. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mblen 3 , -.Xr mbrtowc 3 , -.Xr setlocale 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn mbrlen -function conforms to -.St -isoC-amd1 . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/mbrtowc.3 b/lib/libc/locale/mbrtowc.3 deleted file mode 100644 index 80f7a5979..000000000 --- a/lib/libc/locale/mbrtowc.3 +++ /dev/null @@ -1,196 +0,0 @@ -.\" $NetBSD: mbrtowc.3,v 1.8 2006/10/16 09:10:29 wiz Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd February 4, 2002 -.Dt MBRTOWC 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm mbrtowc -.Nd converts a multibyte character to a wide character (restartable) -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn mbrtowc "wchar_t * restrict pwc" "const char * restrict s" "size_t n" \ -"mbstate_t * restrict ps" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn mbrtowc -usually converts the multibyte character pointed to by -.Fa s -to a wide character, and stores the wide character -to the wchar_t object pointed to by -.Fa pwc -if -.Fa pwc -is -.Pf non- Dv NULL -and -.Fa s -points to a valid character. -The conversion happens in accordance with, and changes the conversion -state described in the mbstate_t object pointed to by -.Fa ps . -This function may examine at most -.Fa n -bytes of the array beginning from -.Fa s . -.Pp -If -.Fa s -points to a valid character and the character corresponds to a nul wide -character, then the -.Fn mbrtowc -places the mbstate_t object pointed to by -.Fa ps -to an initial conversion state. -.Pp -Unlike -.Xr mbtowc 3 , -the -.Fn mbrtowc -may accept the byte sequence pointed to by -.Fa s -not forming a complete multibyte character -but which may be part of a valid character. -In this case, this function will accept all such bytes -and save them into the conversion state object pointed to by -.Fa ps . -They will be used at subsequent calls of this function to restart -the conversion suspended. -.Pp -The behaviour of -.Fn mbrtowc -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -These are the special cases: -.Bl -tag -width 012345678901 -.It "s == NULL" -.Fn mbrtowc -sets the conversion state object pointed to by -.Fa ps -to an initial state and always returns 0. -Unlike -.Xr mbtowc 3 , -the value returned does not indicate whether the current encoding of -the locale is state-dependent. -.Pp -In this case, -.Fn mbrtowc -ignores -.Fa pwc -and -.Fa n , -and is equivalent to the following call: -.Bd -literal -offset indent -mbrtowc(NULL, "", 1, ps); -.Ed -.It "pwc == NULL" -The conversion from a multibyte character to a wide character has -taken place and the conversion state may be affected, but the resulting -wide character is discarded. -.It "ps == NULL" -.Fn mbrtowc -uses its own internal state object to keep the conversion state, -instead of -.Fa ps -mentioned in this manual page. -.Pp -Calling any other functions in -.Lb libc -never changes the internal state of -.Fn mbrtowc , -which is initialized at startup time of the program. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -In the usual cases, -.Fn mbrtowc -returns: -.Bl -tag -width 012345678901 -.It 0 -The next bytes pointed to by -.Fa s -form a nul character. -.It positive -If -.Fa s -points to a valid character, -.Fn mbrtowc -returns the number of bytes in the character. -.It (size_t)-2 -.Fa s -points to a byte sequence which possibly contains part of a valid -multibyte character, but which is incomplete. -When -.Fa n -is at least -.Dv MB_CUR_MAX , -this case can only occur if the array pointed to by -.Fa s -contains a redundant shift sequence. -.It (size_t)-1 -.Fa s -points to an illegal byte sequence which does not form a valid multibyte -character. -In this case, -.Fn mbrtowc -sets -.Va errno -to indicate the error. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn mbrtowc -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa s -points to an invalid or incomplete multibyte character. -.It Bq Er EINVAL -.Fa ps -points to an invalid or uninitialized mbstate_t object. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mbrlen 3 , -.Xr mbtowc 3 , -.Xr setlocale 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn mbrtowc -function conforms to -.St -isoC-amd1 . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/mbsinit.3 b/lib/libc/locale/mbsinit.3 deleted file mode 100644 index 63ef147b7..000000000 --- a/lib/libc/locale/mbsinit.3 +++ /dev/null @@ -1,74 +0,0 @@ -.\" $NetBSD: mbsinit.3,v 1.6 2006/10/16 08:42:16 wiz Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd February 3, 2002 -.Dt MBSINIT 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm mbsinit -.Nd determines whether the state object is in the initial state -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wchar.h -.Ft int -.Fn mbsinit "const mbstate_t *ps" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn mbsinit -determines whether the state object pointed to by -.Fa ps -is the initial conversion state, or not. -.Pp -.Fa ps -may be a null pointer. -In this case, -.Fn mbsinit -will always return non-zero. -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -.Fn mbsinit -returns: -.Bl -tag -width 0123456789 -.It 0 -The current state is not the initial state. -.It non-zero -The current state is the initial state or -.Fa ps -is a null pointer. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -No errors are defined. -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn mbsinit -conforms to -.St -isoC-amd1 . diff --git a/lib/libc/locale/mbsrtowcs.3 b/lib/libc/locale/mbsrtowcs.3 deleted file mode 100644 index a353420c4..000000000 --- a/lib/libc/locale/mbsrtowcs.3 +++ /dev/null @@ -1,181 +0,0 @@ -.\" $NetBSD: mbsrtowcs.3,v 1.12 2010/12/16 17:42:27 wiz Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd February 4, 2002 -.Dt MBSRTOWCS 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm mbsrtowcs -.Nd converts a multibyte character string to a wide-character string \ -(restartable) -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn mbsrtowcs "wchar_t * restrict pwcs" "const char ** restrict s" "size_t n" \ -"mbstate_t * restrict ps" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn mbsrtowcs -converts the multibyte character string indirectly pointed to by -.Fa s -to the corresponding wide-character string, and stores it in the -array pointed to by -.Fa pwcs . -The conversion stops due to the following reasons: -.Bl -bullet -.It -The conversion reaches a nul byte. -In this case, the nul byte is also converted. -.It -The -.Fn mbsrtowcs -has already stored -.Fa n -wide characters. -.It -The conversion encounters an invalid character. -.El -.Pp -Each character will be converted as if -.Xr mbrtowc 3 -is continuously called. -.Pp -After conversion, -if -.Fa pwcs -is not a null pointer, -the pointer object pointed to by -.Fa s -is a null pointer (if the conversion is stopped due to reaching a -nul byte) or the first byte of the character just after the last -character converted. -.Pp -If -.Fa pwcs -is not a null pointer and the conversion is stopped due to reaching -a nul byte, the -.Fn mbsrtowcs -places the state object pointed to by -.Fa ps -to an initial state after the conversion has taken place. -.Pp -The behaviour of -.Fn mbsrtowcs -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -These are the special cases: -.Bl -tag -width 012345678901 -.It "s == NULL || *s == NULL" -Undefined (may cause the program to crash). -.It "pwcs == NULL" -The conversion has taken place, but the resulting wide-character string -was discarded. -In this case, the pointer object pointed to by -.Fa s -is not modified and -.Fa n -is ignored. -.It "ps == NULL" -The -.Fn mbsrtowcs -uses its own internal state object to keep the conversion state, -instead of -.Fa ps -mentioned in this manual page. -.Pp -Calling any other functions in -.Lb libc -never changes the internal state of -.Fn mbsrtowcs , -which is initialized at startup time of the program. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -.Fn mbsrtowcs -returns: -.Bl -tag -width 012345678901 -.It 0 or positive -The value returned is the number of elements stored in the array -pointed to by -.Fa pwcs , -except for a terminating nul wide character (if any). -If -.Fa pwcs -is not -.Dv NULL -and the value returned is equal to -.Fa n , -the wide-character string pointed to by -.Fa pwcs -is not nul-terminated. -If -.Fa pwcs -is a null pointer, the value returned is the number of elements to contain -the whole string converted, except for a terminating nul wide character. -.It (size_t)-1 -The array indirectly pointed to by -.Fa s -contains a byte sequence forming invalid character. -In this case, -.Fn mbsrtowcs -sets -.Va errno -to indicate the error. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn mbsrtowcs -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -The pointer pointed to by -.Fa s -points to an invalid or incomplete multibyte character. -.It Bq Er EINVAL -.Fa ps -points to an invalid or uninitialized mbstate_t object. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mbrtowc 3 , -.Xr mbstowcs 3 , -.Xr setlocale 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn mbsrtowcs -function conforms to -.St -isoC-amd1 . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/mbstowcs.3 b/lib/libc/locale/mbstowcs.3 deleted file mode 100644 index f0435fcae..000000000 --- a/lib/libc/locale/mbstowcs.3 +++ /dev/null @@ -1,129 +0,0 @@ -.\" $NetBSD: mbstowcs.3,v 1.12 2011/03/16 09:32:12 mbalmer Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd March 16, 2011 -.Dt MBSTOWCS 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm mbstowcs -.Nd converts a multibyte character string to a wide-character string -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In stdlib.h -.Ft size_t -.Fn mbstowcs "wchar_t * restrict pwcs" "const char * restrict s" "size_t n" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -.Fn mbstowcs -converts a nul-terminated multibyte character string pointed to by -.Fa s -to the corresponding wide-character string and stores it in the array -pointed to by -.Fa pwcs . -This function may modify the first at most -.Fa n -elements of the array pointed to by -.Fa pwcs . -Each character will be converted as if -.Xr mbtowc 3 -is continuously called, except the internal state of -.Xr mbtowc 3 -will not be affected. -.Pp -For state-dependent encoding, -.Fn mbstowcs -implies the multibyte character string pointed to by -.Fa s -always begins with an initial state. -.Pp -These are the special cases: -.Bl -tag -width 012345678901 -.It pwcs == NULL -.Fn mbstowcs -returns the number of elements to store the whole wide-character string -corresponding to the multibyte character string pointed to by -.Fa s . -In this case, -.Fa n -is ignored. -.It s == NULL -Undefined (may cause the program to crash). -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -.Fn mbstowcs -returns: -.Bl -tag -width 012345678901 -.It 0 or positive -Number of elements stored in the array pointed to by -.Fa pwcs . -There are no cases that the value returned is greater than -.Fa n -(unless -.Fa pwcs -is a null pointer) or the value of the -.Dv MB_CUR_MAX -macro. -If the return value is equal to -.Fa n , -the string pointed to by -.Fa pwcs -will not be nul-terminated. -.It (size_t)-1 -.Fa s -points to a string containing an invalid or incomplete multibyte character. -The -.Fn mbstowcs -also sets -.Va errno -to indicate the error. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn mbstowcs -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa s -points to a string containing an invalid or incomplete multibyte character. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mbtowc 3 , -.Xr setlocale 3 , -.Xr wcstombs 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn mbstowcs -function conforms to -.St -ansiC . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/mbtowc.3 b/lib/libc/locale/mbtowc.3 deleted file mode 100644 index 317fb3344..000000000 --- a/lib/libc/locale/mbtowc.3 +++ /dev/null @@ -1,182 +0,0 @@ -.\" $NetBSD: mbtowc.3,v 1.8 2006/10/16 09:10:29 wiz Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd February 3, 2002 -.Dt MBTOWC 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm mbtowc -.Nd converts a multibyte character to a wide character -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In stdlib.h -.Ft int -.Fn mbtowc "wchar_t * restrict pwc" "const char * restrict s" "size_t n" -.Sh DESCRIPTION -.Fn mbtowc -usually converts the multibyte character pointed to by -.Fa s -to a wide character, and stores it in the wchar_t object pointed to by -.Fa pwc -if -.Fa pwc -is -.Pf non- Dv NULL -and -.Fa s -points to a valid character. -This function may inspect at most n bytes of the array beginning from -.Fa s . -.Pp -In state-dependent encodings, -.Fa s -may point to the special sequence bytes to change the shift-state. -Although such sequence bytes correspond to no individual -wide-character code, -.Fn mbtowc -changes its own state by the sequence bytes and treats them -as if they are a part of the subsequence multibyte character. -.Pp -Unlike -.Xr mbrtowc 3 , -the first -.Fa n -bytes pointed to by -.Fa s -need to form an entire multibyte character. -Otherwise, this function causes an error. -.Pp -Calling any other functions in -.Lb libc -never changes the internal state of -.Fn mbtowc , -except for calling -.Xr setlocale 3 -with changing the -.Dv LC_CTYPE -category of the current locale. -Such -.Xr setlocale 3 -call causes the internal state of this function to be indeterminate. -.Pp -The behaviour of -.Fn mbtowc -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -There are special cases: -.Bl -tag -width 012345678901 -.It s == NULL -.Fn mbtowc -initializes its own internal state to an initial state, and -determines whether the current encoding is state-dependent. -This function returns 0 if the encoding is state-independent, -otherwise non-zero. -In this case, -.Fa pwc -is completely ignored. -.It pwc == NULL -.Fn mbtowc -executes the conversion as if -.Fa pwc -is non-NULL, but a result of the conversion is discarded. -.It n == 0 -In this case, -the first -.Fa n -bytes of the array pointed to by -.Fa s -never form a complete character. -Thus, the -.Fn mbtowc -always fails. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -Normally, the -.Fn mbtowc -returns: -.Bl -tag -width 012345678901 -.It 0 -.Fa s -points to a nul byte -.Pq Sq \e0 . -.It positive -Number of bytes for the valid multibyte character pointed to by -.Fa s . -There are no cases that the value returned is greater than -the value of the -.Dv MB_CUR_MAX -macro. -.It -1 -.Fa s -points to an invalid or an incomplete multibyte character. -The -.Fn mbtowc -also sets -.Va errno -to indicate the error. -.El -.Pp -When -.Fa s -is equal to -.Dv NULL , -.Fn mbtowc -returns: -.Bl -tag -width 0123456789 -.It 0 -The current encoding is state-independent. -.It non-zero -The current encoding is state-dependent. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn mbtowc -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa s -points to an invalid or incomplete multibyte character. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mblen 3 , -.Xr mbrtowc 3 , -.Xr setlocale 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn mbtowc -function conforms to -.St -ansiC . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/multibyte.h b/lib/libc/locale/multibyte.h deleted file mode 100644 index f22c31c3f..000000000 --- a/lib/libc/locale/multibyte.h +++ /dev/null @@ -1,125 +0,0 @@ -/* $NetBSD: multibyte.h,v 1.6 2013/08/18 20:03:48 joerg Exp $ */ - -/*- - * Copyright (c)2002 Citrus Project, - * 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. - */ - -#ifndef _MULTIBYTE_H_ -#define _MULTIBYTE_H_ - -/* mbstate_t private */ - -#ifdef _BSD_MBSTATE_T_ -typedef _BSD_MBSTATE_T_ mbstate_t; -#undef _BSD_MBSTATE_T_ -#endif - -typedef struct _RuneStatePriv { - _RuneLocale *__runelocale; - char __private __attribute__((__aligned__)); -} _RuneStatePriv; - -typedef union _RuneState { - mbstate_t __pad; - struct _RuneStatePriv __priv; -#define rs_runelocale __priv.__runelocale -#define rs_private __priv.__private -} _RuneState; -#define _PRIVSIZE (sizeof(mbstate_t)-offsetof(_RuneStatePriv, __private)) - -#define _RUNE_LOCALE(loc) \ - ((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE])) - -#define _CITRUS_CTYPE(loc) \ - (((_RuneLocale *)((loc)->part_impl[(size_t)LC_CTYPE]))->rl_citrus_ctype) - -/* */ - -static __inline _RuneState * -_ps_to_runestate(mbstate_t *ps) -{ - return (_RuneState *)(void *)ps; -} - -static __inline _RuneState const * -_ps_to_runestate_const(mbstate_t const *ps) -{ - return (_RuneState const *)(void const *)ps; -} - -static __inline _RuneLocale * -_ps_to_runelocale(mbstate_t const *ps) -{ - return _ps_to_runestate_const(ps)->rs_runelocale; -} - -static __inline _citrus_ctype_t -_ps_to_ctype(mbstate_t const *ps, locale_t loc) -{ - if (!ps) - return _CITRUS_CTYPE(loc); - - _DIAGASSERT(_ps_to_runelocale(ps) != NULL); - - return _ps_to_runelocale(ps)->rl_citrus_ctype; -} - -static __inline void * -_ps_to_private(mbstate_t *ps) -{ - if (ps == NULL) - return NULL; - return (void *)&_ps_to_runestate(ps)->rs_private; -} - -static __inline void const * -_ps_to_private_const(mbstate_t const *ps) -{ - if (ps == NULL) - return NULL; - return (void const *)&_ps_to_runestate_const(ps)->rs_private; -} - -static __inline void -_init_ps(_RuneLocale *rl, mbstate_t *ps) -{ - size_t dum; - _ps_to_runestate(ps)->rs_runelocale = rl; - _citrus_ctype_mbrtowc(rl->rl_citrus_ctype, NULL, NULL, 0, - _ps_to_private(ps), &dum); -} - -static __inline void -_fixup_ps(_RuneLocale *rl, mbstate_t *ps, int forceinit) -{ - /* for future multi-locale facility */ - _DIAGASSERT(rl != NULL); - - if (ps != NULL && (_ps_to_runelocale(ps) == NULL || forceinit)) { - _init_ps(rl, ps); - } -} - -#endif /*_MULTIBYTE_H_*/ diff --git a/lib/libc/locale/multibyte_amd1.c b/lib/libc/locale/multibyte_amd1.c deleted file mode 100644 index e733f90fa..000000000 --- a/lib/libc/locale/multibyte_amd1.c +++ /dev/null @@ -1,258 +0,0 @@ -/* $NetBSD: multibyte_amd1.c,v 1.14 2013/08/18 20:03:48 joerg Exp $ */ - -/*- - * Copyright (c)2002, 2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: multibyte_amd1.c,v 1.14 2013/08/18 20:03:48 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include - -#include "setlocale_local.h" - -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "runetype_local.h" -#include "multibyte.h" - -size_t -mbrlen_l(const char *s, size_t n, mbstate_t *ps, locale_t loc) -{ - size_t ret; - int err0; - - _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL); - - err0 = _citrus_ctype_mbrlen(_ps_to_ctype(ps, loc), s, n, - _ps_to_private(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -mbrlen(const char *s, size_t n, mbstate_t *ps) -{ - return mbrlen_l(s, n, ps, _current_locale()); -} - -int -mbsinit_l(const mbstate_t *ps, locale_t loc) -{ - int ret; - int err0; - _RuneLocale *rl; - - if (ps == NULL) - return 1; - - if (_ps_to_runelocale(ps) == NULL) - rl = _RUNE_LOCALE(loc); - else - rl = _ps_to_runelocale(ps); - - /* mbsinit should cause no error... */ - err0 = _citrus_ctype_mbsinit(rl->rl_citrus_ctype, - _ps_to_private_const(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -int -mbsinit(const mbstate_t *ps) -{ - return mbsinit_l(ps, _current_locale()); -} - -size_t -mbrtowc_l(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps, locale_t loc) -{ - size_t ret; - int err0; - - _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL); - - err0 = _citrus_ctype_mbrtowc(_ps_to_ctype(ps, loc), pwc, s, n, - _ps_to_private(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -mbrtowc(wchar_t *pwc, const char *s, size_t n, mbstate_t *ps) -{ - return mbrtowc_l(pwc, s, n, ps, _current_locale()); -} - -size_t -mbsrtowcs_l(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps, - locale_t loc) -{ - size_t ret; - int err0; - - _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL); - - err0 = _citrus_ctype_mbsrtowcs(_ps_to_ctype(ps, loc), pwcs, s, n, - _ps_to_private(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -mbsrtowcs(wchar_t *pwcs, const char **s, size_t n, mbstate_t *ps) -{ - return mbsrtowcs_l(pwcs, s, n, ps, _current_locale()); -} - -size_t -mbsnrtowcs_l(wchar_t *pwcs, const char **s, size_t in, size_t n, mbstate_t *ps, - locale_t loc) -{ - size_t ret; - int err0; - - _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL); - - err0 = _citrus_ctype_mbsnrtowcs(_ps_to_ctype(ps, loc), pwcs, s, in, n, - _ps_to_private(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -mbsnrtowcs(wchar_t *pwcs, const char **s, size_t in, size_t n, mbstate_t *ps) -{ - return mbsnrtowcs_l(pwcs, s, in, n, ps, _current_locale()); -} - -size_t -wcrtomb_l(char *s, wchar_t wc, mbstate_t *ps, locale_t loc) -{ - size_t ret; - int err0; - - _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL); - - err0 = _citrus_ctype_wcrtomb(_ps_to_ctype(ps, loc), s, wc, - _ps_to_private(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -wcrtomb(char *s, wchar_t wc, mbstate_t *ps) -{ - return wcrtomb_l(s, wc, ps, _current_locale()); -} - -size_t -wcsrtombs_l(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps, - locale_t loc) -{ - size_t ret; - int err0; - - _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL); - - err0 = _citrus_ctype_wcsrtombs(_ps_to_ctype(ps, loc), s, ppwcs, n, - _ps_to_private(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -wcsrtombs(char *s, const wchar_t **ppwcs, size_t n, mbstate_t *ps) -{ - return wcsrtombs_l(s, ppwcs, n, ps, _current_locale()); -} - -wint_t -btowc_l(int c, locale_t loc) -{ - wint_t ret; - int err0; - - err0 = _citrus_ctype_btowc(_CITRUS_CTYPE(loc), c, &ret); - if (err0) - errno = err0; - - return ret; -} - -wint_t -btowc(int c) -{ - return btowc_l(c, _current_locale()); -} - -int -wctob_l(wint_t wc, locale_t loc) -{ - int ret; - int err0; - - err0 = _citrus_ctype_wctob(_CITRUS_CTYPE(loc), wc, &ret); - if (err0) - errno = err0; - - return ret; -} - -int -wctob(wint_t wc) -{ - return wctob_l(wc, _current_locale()); -} - -size_t -_mb_cur_max_l(locale_t loc) -{ - - return _citrus_ctype_get_mb_cur_max(_CITRUS_CTYPE(loc)); -} diff --git a/lib/libc/locale/multibyte_c90.c b/lib/libc/locale/multibyte_c90.c deleted file mode 100644 index 2e0deb859..000000000 --- a/lib/libc/locale/multibyte_c90.c +++ /dev/null @@ -1,167 +0,0 @@ -/* $NetBSD: multibyte_c90.c,v 1.12 2013/08/18 20:03:48 joerg Exp $ */ - -/*- - * Copyright (c)2002, 2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: multibyte_c90.c,v 1.12 2013/08/18 20:03:48 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include - -#include "setlocale_local.h" - -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "runetype_local.h" -#include "multibyte.h" - -int -mblen_l(const char *s, size_t n, locale_t loc) -{ - int ret; - int err0; - - err0 = _citrus_ctype_mblen(_CITRUS_CTYPE(loc), s, n, &ret); - if (err0) - errno = err0; - - return ret; -} - - -int -mblen(const char *s, size_t n) -{ - return mblen_l(s, n, _current_locale()); -} - -size_t -mbstowcs_l(wchar_t *pwcs, const char *s, size_t n, locale_t loc) -{ - size_t ret; - int err0; - - err0 = _citrus_ctype_mbstowcs(_CITRUS_CTYPE(loc), pwcs, s, n, &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -mbstowcs(wchar_t *pwcs, const char *s, size_t n) -{ - return mbstowcs_l(pwcs, s, n, _current_locale()); -} - -int -mbtowc_l(wchar_t *pw, const char *s, size_t n, locale_t loc) -{ - int ret; - int err0; - - err0 = _citrus_ctype_mbtowc(_CITRUS_CTYPE(loc), pw, s, n, &ret); - if (err0) - errno = err0; - - return ret; -} - -int -mbtowc(wchar_t *pw, const char *s, size_t n) -{ - return mbtowc_l(pw, s, n, _current_locale()); -} - -size_t -wcstombs_l(char *s, const wchar_t *wcs, size_t n, locale_t loc) -{ - size_t ret; - int err0; - - err0 = _citrus_ctype_wcstombs(_CITRUS_CTYPE(loc), s, wcs, n, &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -wcstombs(char *s, const wchar_t *wcs, size_t n) -{ - return wcstombs_l(s, wcs, n, _current_locale()); -} - -size_t -wcsnrtombs_l(char *s, const wchar_t **ppwcs, size_t in, size_t n, mbstate_t *ps, - locale_t loc) -{ - size_t ret; - int err0; - - _fixup_ps(_RUNE_LOCALE(loc), ps, s == NULL); - - err0 = _citrus_ctype_wcsnrtombs(_ps_to_ctype(ps, loc), s, ppwcs, in, n, - _ps_to_private(ps), &ret); - if (err0) - errno = err0; - - return ret; -} - -size_t -wcsnrtombs(char *s, const wchar_t **ppwcs, size_t in, size_t n, mbstate_t *ps) -{ - return wcsnrtombs_l(s, ppwcs, in, n, ps, _current_locale()); -} - -int -wctomb_l(char *s, wchar_t wc, locale_t loc) -{ - int ret; - int err0; - - err0 = _citrus_ctype_wctomb(_CITRUS_CTYPE(loc), s, wc, &ret); - if (err0) - errno = err0; - - return ret; -} - -int -wctomb(char *s, wchar_t wc) -{ - return wctomb_l(s, wc, _current_locale()); -} diff --git a/lib/libc/locale/nb_lc_messages_misc.h b/lib/libc/locale/nb_lc_messages_misc.h deleted file mode 100644 index c3f01d770..000000000 --- a/lib/libc/locale/nb_lc_messages_misc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: nb_lc_messages_misc.h,v 1.7 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _NB_LC_MESSAGES_MISC_H_ -#define _NB_LC_MESSAGES_MISC_H_ - -/* - * macro required by nb_lc_template(_decl).h - */ -#define _CATEGORY_TYPE _MessagesLocale - -/* ARGSUSED */ -static __inline void -_PREFIX(update_global)(_MessagesLocale *data) -{ -} - -/* - * macro required by nb_lc_template.h - */ -#define _CATEGORY_ID LC_MESSAGES -#define _CATEGORY_NAME "LC_MESSAGES" - -#endif /*_NB_LC_MESSAGES_MISC_H_*/ diff --git a/lib/libc/locale/nb_lc_monetary_misc.h b/lib/libc/locale/nb_lc_monetary_misc.h deleted file mode 100644 index 7d66b09bf..000000000 --- a/lib/libc/locale/nb_lc_monetary_misc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: nb_lc_monetary_misc.h,v 1.7 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _NB_LC_MONETARY_MISC_H_ -#define _NB_LC_MONETARY_MISC_H_ - -/* - * macro required by nb_lc_template(_decl).h - */ -#define _CATEGORY_TYPE _MonetaryLocale - -/* ARGSUSED */ -static __inline void -_PREFIX(update_global)(_MonetaryLocale *data) -{ -} - -/* - * macro required by nb_lc_template.h - */ -#define _CATEGORY_ID LC_MONETARY -#define _CATEGORY_NAME "LC_MONETARY" - -#endif /*_RUNE_LC_MONETARY_MISC_H_*/ diff --git a/lib/libc/locale/nb_lc_numeric_misc.h b/lib/libc/locale/nb_lc_numeric_misc.h deleted file mode 100644 index 34ba80d68..000000000 --- a/lib/libc/locale/nb_lc_numeric_misc.h +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: nb_lc_numeric_misc.h,v 1.7 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _NB_LC_NUMERIC_MISC_H_ -#define _NB_LC_NUMERIC_MISC_H_ - -/* - * macro required by nb_lc_template(_decl).h - */ -#define _CATEGORY_TYPE _NumericLocale - -/* ARGSUSED */ -static __inline void -_PREFIX(update_global)(_NumericLocale *data) -{ -} - -/* - * macro required by nb_lc_template.h - */ -#define _CATEGORY_ID LC_NUMERIC -#define _CATEGORY_NAME "LC_NUMERIC" - -#endif /*_NB_LC_NUMERIC_MISC_H_*/ diff --git a/lib/libc/locale/nb_lc_template.h b/lib/libc/locale/nb_lc_template.h deleted file mode 100644 index e60aead83..000000000 --- a/lib/libc/locale/nb_lc_template.h +++ /dev/null @@ -1,244 +0,0 @@ -/* $NetBSD: nb_lc_template.h,v 1.8 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)1999, 2008 Citrus Project, - * 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. - */ - -/*- - * Copyright (c) 1998 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Paul Kranenburg. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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. - */ - -#ifndef _NB_LC_TEMPLATE_H_ -#define _NB_LC_TEMPLATE_H_ - -#define _nb_part_t _PREFIX(part_t) -#define _nb_part_cache _PREFIX(part_cache) -#define _nb_mutex _PREFIX(mutex) - -typedef struct _nb_part_t { - char name[_LOCALENAME_LEN_MAX]; - _CATEGORY_TYPE *impl; - SIMPLEQ_ENTRY(_nb_part_t) entry; -} _nb_part_t; - -static SIMPLEQ_HEAD(, _nb_part_t) _nb_part_cache = - SIMPLEQ_HEAD_INITIALIZER(_nb_part_cache); - -#ifdef _REENTRANT -static mutex_t _nb_mutex = MUTEX_INITIALIZER; -#endif - -static int -_PREFIX(load_sub)(const char * __restrict name, const char * __restrict real, - const char ** __restrict out_name, _CATEGORY_TYPE ** __restrict out_impl, - int force) -{ - const char *cached_name; - _CATEGORY_TYPE *cached_impl; - _nb_part_t *p; - int ret; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(out_name != NULL); - _DIAGASSERT(out_impl != NULL); - - if (!strcmp(_C_LOCALE, name)) { - cached_name = _lc_C_locale.part_name[_CATEGORY_ID]; - cached_impl = _lc_C_locale.part_impl[_CATEGORY_ID]; - } else if (!strcmp(_POSIX_LOCALE, name)) { - cached_name = _POSIX_LOCALE; - cached_impl = _lc_C_locale.part_impl[_CATEGORY_ID]; - } else { - SIMPLEQ_FOREACH(p, &_nb_part_cache, entry) { - if (!strcmp((const char *)&p->name[0], name)) { - cached_name = p->name; - cached_impl = p->impl; - goto found; - } - } - p = malloc(sizeof(*p)); - if (p == NULL) - return ENOMEM; - if (force) { - p->impl = _lc_C_locale.part_impl[_CATEGORY_ID]; - } else { - _DIAGASSERT(_PathLocale != NULL); - ret = _PREFIX(create_impl)((const char *)_PathLocale, - name, &p->impl); - if (ret) { - free(p); - return ret; - } - } - strlcpy(&p->name[0], name, sizeof(p->name)); - SIMPLEQ_INSERT_TAIL(&_nb_part_cache, p, entry); - cached_name = p->name; - cached_impl = p->impl; - } -found: - if (real != NULL) { - p = malloc(sizeof(*p)); - if (p == NULL) - return ENOMEM; - strlcpy(&p->name[0], real, sizeof(p->name)); - cached_name = p->name; - p->impl = cached_impl; - SIMPLEQ_INSERT_TAIL(&_nb_part_cache, p, entry); - } - *out_name = cached_name; - *out_impl = cached_impl; - return 0; -} - -static __inline int -_PREFIX(load)(const char * __restrict name, - const char ** __restrict out_name, _CATEGORY_TYPE ** __restrict out_impl) -{ - int ret, force; - char path[PATH_MAX + 1], loccat[PATH_MAX + 1], buf[PATH_MAX + 1]; - const char *aliaspath, *alias; - -#define _LOAD_SUB_ALIAS(key) \ -do { \ - alias = __unaliasname(aliaspath, key, &buf[0], sizeof(buf)); \ - if (alias != NULL) { \ - ret = (force = !__isforcemapping(alias)) \ - ? _PREFIX(load_sub)(name, NULL, out_name, out_impl, \ - force) \ - : _PREFIX(load_sub)(alias, name, out_name, out_impl, \ - force); \ - _DIAGASSERT(!ret || !force); \ - goto done; \ - } \ -} while (/*CONSTCOND*/0) - - /* (1) non-aliased file */ - mutex_lock(&_nb_mutex); - ret = _PREFIX(load_sub)(name, NULL, out_name, out_impl, 0); - if (ret != ENOENT) - goto done; - - /* (2) lookup locname/catname type alias */ - _DIAGASSERT(_PathLocale != NULL); - snprintf(&path[0], sizeof(path), - "%s/" _LOCALE_ALIAS_NAME, _PathLocale); - aliaspath = (const char *)&path[0]; - snprintf(&loccat[0], sizeof(loccat), - "%s/" _CATEGORY_NAME, name); - _LOAD_SUB_ALIAS((const char *)&loccat[0]); - - /* (3) lookup locname type alias */ - _LOAD_SUB_ALIAS(name); - -done: - mutex_unlock(&_nb_mutex); - return ret; -} - -const char * -_PREFIX(setlocale)(const char * __restrict name, - struct _locale * __restrict locale) -{ - const char *loaded_name; - _CATEGORY_TYPE *loaded_impl; - - /* name may be NULL */ - _DIAGASSERT(locale != NULL); - - if (name != NULL) { - if (*name == '\0') - name = _get_locale_env(_CATEGORY_NAME); - _DIAGASSERT(name != NULL); - _DIAGASSERT(locale->part_name[(size_t)_CATEGORY_ID] != NULL); - if (strcmp(name, locale->part_name[(size_t)_CATEGORY_ID])) { - if (_PREFIX(load)(name, &loaded_name, &loaded_impl)) - return NULL; - locale->part_name[(size_t)_CATEGORY_ID] = loaded_name; - locale->part_impl[(size_t)_CATEGORY_ID] = loaded_impl; - if (locale == &_lc_global_locale) - _PREFIX(update_global)(loaded_impl); - } - } - return locale->part_name[(size_t)_CATEGORY_ID]; -} - -#endif /*_NB_LC_TEMPLATE_H_*/ diff --git a/lib/libc/locale/nb_lc_template_decl.h b/lib/libc/locale/nb_lc_template_decl.h deleted file mode 100644 index bf7cb5d99..000000000 --- a/lib/libc/locale/nb_lc_template_decl.h +++ /dev/null @@ -1,41 +0,0 @@ -/* $NetBSD: nb_lc_template_decl.h,v 1.4 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _NB_LC_TEMPLATE_DECL_H_ -#define _NB_LC_TEMPLATE_DECL_H_ - -#include "generic_lc_template_decl.h" - -static __inline int -_PREFIX(create_impl)(const char * __restrict, - const char * __restrict, _CATEGORY_TYPE ** __restrict); - -static __inline void -_PREFIX(update_global)(_CATEGORY_TYPE *); - -#endif /*_NB_LC_TEMPLATE_DECL_H_*/ diff --git a/lib/libc/locale/nb_lc_time_misc.h b/lib/libc/locale/nb_lc_time_misc.h deleted file mode 100644 index c286f0905..000000000 --- a/lib/libc/locale/nb_lc_time_misc.h +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: nb_lc_time_misc.h,v 1.8 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _NB_LC_TIME_MISC_H_ -#define _NB_LC_TIME_MISC_H_ - -/* - * macro required by nb_lc_template(_decl).h - */ -#define _CATEGORY_TYPE _TimeLocale - -#define ABDAY_IDX(idx) ((size_t)idx - (size_t)ABDAY_1) -#define DAY_IDX(idx) ((size_t)idx - (size_t)DAY_1) -#define ABMON_IDX(idx) ((size_t)idx - (size_t)ABMON_1) -#define MON_IDX(idx) ((size_t)idx - (size_t)MON_1) -#define AM_PM_IDX(idx) ((size_t)idx - (size_t)AM_STR) - -/* ARGSUSED */ -static __inline void -_PREFIX(update_global)(_TimeLocale *data) -{ -} - -/* - * macro required by nb_lc_template.h - */ -#define _CATEGORY_ID LC_TIME -#define _CATEGORY_NAME "LC_TIME" - -#endif /*_NB_LC_TIME_MISC_H_*/ diff --git a/lib/libc/locale/newlocale.c b/lib/libc/locale/newlocale.c deleted file mode 100644 index 7955e3b20..000000000 --- a/lib/libc/locale/newlocale.c +++ /dev/null @@ -1,105 +0,0 @@ -/* $NetBSD: newlocale.c,v 1.3 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008, 2011 Citrus Project, - * 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 -__RCSID("$NetBSD: newlocale.c,v 1.3 2013/09/13 13:13:32 joerg Exp $"); - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -__weak_alias(newlocale, _newlocale) - -locale_t -newlocale(int mask, const char *name, locale_t src) -{ - struct _locale *dst; - char head[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)], *tail; - const char *tokens[_LC_LAST - 1]; - _locale_set_t l; - int i, howmany, categories[_LC_LAST - 1]; - - if (name == NULL) - name = _C_LOCALE; - dst = malloc(sizeof(*dst)); - if (dst == NULL) - return (locale_t)NULL; - if (src == NULL) - src = _current_locale(); - memcpy(dst, src, sizeof(*src)); - strlcpy(&head[0], name, sizeof(head)); - tokens[0] = (const char *)&head[0]; - tail = strchr(tokens[0], '/'); - if (tail == NULL) { - for (i = 1; i < _LC_LAST; ++i) { - if (mask & (1 << i)) { - l = _find_category(i); - _DIAGASSERT(l != NULL); - (*l)(tokens[0], dst); - } - } - } else { - *tail++ = '\0'; - howmany = 0; - for (i = 1; i < _LC_LAST; ++i) { - if (mask & (1 << i)) - categories[howmany++] = i; - } - if (howmany-- > 0) { - for (i = 1; i < howmany; ++i) { - tokens[i] = (const char *)tail; - tail = strchr(tokens[i], '/'); - if (tail == NULL) { - free(dst); - return NULL; - } - } - tokens[howmany] = tail; - tail = strchr(tokens[howmany], '/'); - if (tail != NULL) { - free(dst); - return NULL; - } - for (i = 0; i <= howmany; ++i) { - l = _find_category(categories[i]); - _DIAGASSERT(l != NULL); - (*l)(tokens[i], dst); - } - } - } - if (_setlocale_cache(dst, NULL)) { - free(dst); - return NULL; - } - return (locale_t)dst; -} diff --git a/lib/libc/locale/nl_langinfo.3 b/lib/libc/locale/nl_langinfo.3 deleted file mode 100644 index d58bf6b69..000000000 --- a/lib/libc/locale/nl_langinfo.3 +++ /dev/null @@ -1,149 +0,0 @@ -.\" $NetBSD: nl_langinfo.3,v 1.20 2011/04/14 05:50:49 jruoho Exp $ -.\" -.\" Written by J.T. Conklin . -.\" Public domain. -.\" -.Dd April 14, 2011 -.Dt NL_LANGINFO 3 -.Os -.Sh NAME -.Nm nl_langinfo -.Nd get locale information -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In langinfo.h -.Ft char * -.Fn nl_langinfo "nl_item item" -.Sh DESCRIPTION -The -.Fn nl_langinfo -function returns a pointer to a string containing information -set by the program's locale. -.Pp -The names and values of -.Fa item -are defined in -.In langinfo.h . -The entries under Category indicate in which -.Xr setlocale 3 -category each item is defined. -.Bl -column ERA_D_T_FMT LC_MESSAGES -.It Sy Constant Ta Sy Category Ta Sy Meaning -.It CODESET LC_CTYPE Codeset name -.It D_T_FMT LC_TIME String for formatting date and time -.It D_FMT LC_TIME Date format string -.It T_FMT LC_TIME Time format string -.It T_FMT_AMPM LC_TIME A.M. or P.M. time format string -.It AM_STR LC_TIME Ante-meridiem affix -.It PM_STR LC_TIME Post-meridiem affix -.It DAY_1 LC_TIME Name of the first day of the week (e.g.: Sunday) -.It DAY_2 LC_TIME Name of the second day of the week (e.g.: Monday) -.It DAY_3 LC_TIME Name of the third day of the week (e.g.: Tuesday) -.It DAY_4 LC_TIME Name of the fourth day of the week (e.g.: Wednesday) -.It DAY_5 LC_TIME Name of the fifth day of the week (e.g.: Thursday) -.It DAY_6 LC_TIME Name of the sixth day of the week (e.g.: Friday) -.It DAY_7 LC_TIME Name of the seventh day of the week (e.g.: Saturday) -.It ABDAY_1 LC_TIME Abbreviated name of the first day of the week -.It ABDAY_2 LC_TIME Abbreviated name of the second day of the week -.It ABDAY_3 LC_TIME Abbreviated name of the third day of the week -.It ABDAY_4 LC_TIME Abbreviated name of the fourth day of the week -.It ABDAY_5 LC_TIME Abbreviated name of the fifth day of the week -.It ABDAY_6 LC_TIME Abbreviated name of the sixth day of the week -.It ABDAY_7 LC_TIME Abbreviated name of the seventh day of the week -.It MON_1 LC_TIME Name of the first month of the year -.It MON_2 LC_TIME Name of the second month -.It MON_3 LC_TIME Name of the third month -.It MON_4 LC_TIME Name of the fourth month -.It MON_5 LC_TIME Name of the fifth month -.It MON_6 LC_TIME Name of the sixth month -.It MON_7 LC_TIME Name of the seventh month -.It MON_8 LC_TIME Name of the eighth month -.It MON_9 LC_TIME Name of the ninth month -.It MON_10 LC_TIME Name of the tenth month -.It MON_11 LC_TIME Name of the eleventh month -.It MON_12 LC_TIME Name of the twelfth month -.It ABMON_1 LC_TIME Abbreviated name of the first month -.It ABMON_2 LC_TIME Abbreviated name of the second month -.It ABMON_3 LC_TIME Abbreviated name of the third month -.It ABMON_4 LC_TIME Abbreviated name of the fourth month -.It ABMON_5 LC_TIME Abbreviated name of the fifth month -.It ABMON_6 LC_TIME Abbreviated name of the sixth month -.It ABMON_7 LC_TIME Abbreviated name of the seventh month -.It ABMON_8 LC_TIME Abbreviated name of the eighth month -.It ABMON_9 LC_TIME Abbreviated name of the ninth month -.It ABMON_10 LC_TIME Abbreviated name of the tenth month -.It ABMON_11 LC_TIME Abbreviated name of the eleventh month -.It ABMON_12 LC_TIME Abbreviated name of the twelfth month -.It ERA LC_TIME Era description segments -.It ERA_D_FMT LC_TIME Era date format string -.It ERA_D_T_FMT LC_TIME Era date and time format string -.It ERA_T_FMT LC_TIME Era time format string -.It ALT_DIGITS LC_TIME Alternative symbols for digits -.It RADIXCHAR LC_NUMERIC Radix character -.It THOUSEP LC_NUMERIC Separator for thousands -.It YESEXPR LC_MESSAGES Affirmative response expression -.It NOEXPR LC_MESSAGES Negative response expression -.\".It CRNCYSTR LC_MONETARY Local currency symbol -.El -.Sh RETURN VALUES -.Fn nl_langinfo -returns a pointer to an empty string if -.Fa item -is invalid. -.Sh EXAMPLES -The following example uses -.Fn nl_langinfo -to obtain the date and time format for the current locale: -.Pp -.Bd -literal -offset indent -#include \*[Lt]time.h\*[Gt] -#include \*[Lt]langinfo.h\*[Gt] -#include \*[Lt]locale.h\*[Gt] - -int main(void) -{ - char datestring[100]; - struct tm *tm; - time_t t; - char *ptr; - - t = time(NULL); - tm = localtime(\*[Am]t); - (void)setlocale(LC_ALL, ""); - ptr = nl_langinfo(D_T_FMT); - strftime(datestring, sizeof(datestring), ptr, tm); - printf("%s\en", datestring); - return (0); -} -.Ed -.\" .Pp -.\" The following example uses -.\" .Fn nl_langinfo -.\" to obtain the setting of the currency symbol for the current locale: -.\" .Pp -.\" .Bd -.\" #include \*[Lt]langinfo.h\*[Gt] -.\" #include \*[Lt]locale.h\*[Gt] -.\" int main(void) -.\" { -.\" char *ptr; -.\" (void)setlocale(LC_ALL, ""); -.\" ptr = nl_langinfo(CRNCYSTR); -.\" printf("%s", ptr); -.\" } -.\" .Ed -.Sh SEE ALSO -.Xr setlocale 3 , -.Xr tm 3 , -.Xr nls 7 -.Sh STANDARDS -The -.Fn nl_langinfo -function conforms to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Fn nl_langinfo -function appeared in -.Nx 1.0 . diff --git a/lib/libc/locale/nl_langinfo.c b/lib/libc/locale/nl_langinfo.c deleted file mode 100644 index 7d0c2f906..000000000 --- a/lib/libc/locale/nl_langinfo.c +++ /dev/null @@ -1,194 +0,0 @@ -/* $NetBSD: nl_langinfo.c,v 1.17 2013/08/20 19:58:30 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -__RCSID("$NetBSD: nl_langinfo.c,v 1.17 2013/08/20 19:58:30 joerg Exp $"); - -#include "namespace.h" -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include - -#include "runetype_local.h" -#include "setlocale_local.h" - -static const char langinfo_category[] = { - [ D_T_FMT ] = LC_TIME, - [ D_FMT ] = LC_TIME, - [ T_FMT ] = LC_TIME, - [ T_FMT_AMPM ] = LC_TIME, - [ AM_STR ] = LC_TIME, - [ PM_STR ] = LC_TIME, - [ DAY_1 ] = LC_TIME, - [ DAY_2 ] = LC_TIME, - [ DAY_3 ] = LC_TIME, - [ DAY_4 ] = LC_TIME, - [ DAY_5 ] = LC_TIME, - [ DAY_6 ] = LC_TIME, - [ DAY_7 ] = LC_TIME, - [ ABDAY_1 ] = LC_TIME, - [ ABDAY_2 ] = LC_TIME, - [ ABDAY_3 ] = LC_TIME, - [ ABDAY_4 ] = LC_TIME, - [ ABDAY_5 ] = LC_TIME, - [ ABDAY_6 ] = LC_TIME, - [ ABDAY_7 ] = LC_TIME, - [ MON_1 ] = LC_TIME, - [ MON_2 ] = LC_TIME, - [ MON_3 ] = LC_TIME, - [ MON_4 ] = LC_TIME, - [ MON_5 ] = LC_TIME, - [ MON_6 ] = LC_TIME, - [ MON_7 ] = LC_TIME, - [ MON_8 ] = LC_TIME, - [ MON_9 ] = LC_TIME, - [ MON_10 ] = LC_TIME, - [ MON_11 ] = LC_TIME, - [ MON_12 ] = LC_TIME, - [ ABMON_1 ] = LC_TIME, - [ ABMON_2 ] = LC_TIME, - [ ABMON_3 ] = LC_TIME, - [ ABMON_4 ] = LC_TIME, - [ ABMON_5 ] = LC_TIME, - [ ABMON_6 ] = LC_TIME, - [ ABMON_7 ] = LC_TIME, - [ ABMON_8 ] = LC_TIME, - [ ABMON_9 ] = LC_TIME, - [ ABMON_10 ] = LC_TIME, - [ ABMON_11 ] = LC_TIME, - [ ABMON_12 ] = LC_TIME, - [ RADIXCHAR ] = LC_NUMERIC, - [ THOUSEP ] = LC_NUMERIC, - [ YESSTR ] = LC_MESSAGES, - [ YESEXPR ] = LC_MESSAGES, - [ NOSTR ] = LC_MESSAGES, - [ NOEXPR ] = LC_MESSAGES, - [ CRNCYSTR ] = 0, - [ CODESET ] = LC_CTYPE, - [ ERA ] = 0, - [ ERA_D_FMT ] = 0, - [ ERA_D_T_FMT ] = 0, - [ ERA_T_FMT ] = 0, - [ ALT_DIGITS ] = 0, -}; - -static const uint16_t langinfo_offset[] = { - [ D_T_FMT ] = offsetof(_TimeLocale, d_t_fmt), - [ D_FMT ] = offsetof(_TimeLocale, d_fmt), - [ T_FMT ] = offsetof(_TimeLocale, t_fmt), - [ T_FMT_AMPM ] = offsetof(_TimeLocale, t_fmt_ampm), - [ AM_STR ] = offsetof(_TimeLocale, am_pm[0]), - [ PM_STR ] = offsetof(_TimeLocale, am_pm[1]), - [ DAY_1 ] = offsetof(_TimeLocale, day[0]), - [ DAY_2 ] = offsetof(_TimeLocale, day[1]), - [ DAY_3 ] = offsetof(_TimeLocale, day[2]), - [ DAY_4 ] = offsetof(_TimeLocale, day[3]), - [ DAY_5 ] = offsetof(_TimeLocale, day[4]), - [ DAY_6 ] = offsetof(_TimeLocale, day[5]), - [ DAY_7 ] = offsetof(_TimeLocale, day[6]), - [ ABDAY_1 ] = offsetof(_TimeLocale, abday[0]), - [ ABDAY_2 ] = offsetof(_TimeLocale, abday[1]), - [ ABDAY_3 ] = offsetof(_TimeLocale, abday[2]), - [ ABDAY_4 ] = offsetof(_TimeLocale, abday[3]), - [ ABDAY_5 ] = offsetof(_TimeLocale, abday[4]), - [ ABDAY_6 ] = offsetof(_TimeLocale, abday[5]), - [ ABDAY_7 ] = offsetof(_TimeLocale, abday[6]), - [ MON_1 ] = offsetof(_TimeLocale, mon[0]), - [ MON_2 ] = offsetof(_TimeLocale, mon[1]), - [ MON_3 ] = offsetof(_TimeLocale, mon[2]), - [ MON_4 ] = offsetof(_TimeLocale, mon[3]), - [ MON_5 ] = offsetof(_TimeLocale, mon[4]), - [ MON_6 ] = offsetof(_TimeLocale, mon[5]), - [ MON_7 ] = offsetof(_TimeLocale, mon[6]), - [ MON_8 ] = offsetof(_TimeLocale, mon[7]), - [ MON_9 ] = offsetof(_TimeLocale, mon[8]), - [ MON_10 ] = offsetof(_TimeLocale, mon[9]), - [ MON_11 ] = offsetof(_TimeLocale, mon[10]), - [ MON_12 ] = offsetof(_TimeLocale, mon[11]), - [ ABMON_1 ] = offsetof(_TimeLocale, abmon[0]), - [ ABMON_2 ] = offsetof(_TimeLocale, abmon[1]), - [ ABMON_3 ] = offsetof(_TimeLocale, abmon[2]), - [ ABMON_4 ] = offsetof(_TimeLocale, abmon[3]), - [ ABMON_5 ] = offsetof(_TimeLocale, abmon[4]), - [ ABMON_6 ] = offsetof(_TimeLocale, abmon[5]), - [ ABMON_7 ] = offsetof(_TimeLocale, abmon[6]), - [ ABMON_8 ] = offsetof(_TimeLocale, abmon[7]), - [ ABMON_9 ] = offsetof(_TimeLocale, abmon[8]), - [ ABMON_10 ] = offsetof(_TimeLocale, abmon[9]), - [ ABMON_11 ] = offsetof(_TimeLocale, abmon[10]), - [ ABMON_12 ] = offsetof(_TimeLocale, abmon[11]), - [ RADIXCHAR ] = offsetof(_NumericLocale, decimal_point), - [ THOUSEP ] = offsetof(_NumericLocale, thousands_sep), - [ YESSTR ] = offsetof(_MessagesLocale, yesstr), - [ YESEXPR ] = offsetof(_MessagesLocale, yesexpr), - [ NOSTR ] = offsetof(_MessagesLocale, nostr), - [ NOEXPR ] = offsetof(_MessagesLocale, noexpr), - [ CRNCYSTR ] = 0, - [ CODESET ] = offsetof(_RuneLocale, rl_codeset), - [ ERA ] = 0, - [ ERA_D_FMT ] = 0, - [ ERA_D_T_FMT ] = 0, - [ ERA_T_FMT ] = 0, - [ ALT_DIGITS ] = 0, -}; - -__weak_alias(nl_langinfo_l, _nl_langinfo_l) - -char * -nl_langinfo(nl_item item) -{ - - return nl_langinfo_l(item, _current_locale()); -} - -char * -nl_langinfo_l(nl_item item, locale_t loc) -{ - char *s; - int category; - size_t offset; - - if (item < 0 || item >= (long)__arraycount(langinfo_category)) - return __UNCONST(""); /* Outside the defined range */ - - category = langinfo_category[item]; - if (category == 0) - return __UNCONST(""); /* Not in use */ - offset = langinfo_offset[item]; - - memcpy(&s, (char *)loc->part_impl[category] + offset, sizeof(s)); - if (s == NULL) - return __UNCONST(""); - else - return s; -} diff --git a/lib/libc/locale/rune.c b/lib/libc/locale/rune.c deleted file mode 100644 index 75f641f92..000000000 --- a/lib/libc/locale/rune.c +++ /dev/null @@ -1,350 +0,0 @@ -/* $NetBSD: rune.c,v 1.46 2013/04/13 10:21:20 joerg Exp $ */ -/*- - * Copyright (c)2010 Citrus Project, - * 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 -#include -#include -#include -#include -#include -#define __SETLOCALE_SOURCE__ -#include -#include -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -#include "citrus_module.h" -#include "citrus_ctype.h" - -#include "runetype_local.h" - -#include "multibyte.h" - -#include "_wctype_local.h" -#include "_wctrans_local.h" - -typedef struct { - _RuneLocale rl; - unsigned short rlp_ctype_tab [_CTYPE_NUM_CHARS + 1]; - short rlp_tolower_tab[_CTYPE_NUM_CHARS + 1]; - short rlp_toupper_tab[_CTYPE_NUM_CHARS + 1]; - char rlp_codeset[33]; /* XXX */ - -#ifdef __BUILD_LEGACY - unsigned char rlp_compat_bsdctype[_CTYPE_NUM_CHARS + 1]; -#endif -} _RuneLocalePriv; - -static __inline void -_rune_wctype_init(_RuneLocale *rl) -{ - memcpy(&rl->rl_wctype, &_DefaultRuneLocale.rl_wctype, - sizeof(rl->rl_wctype)); -} - -static __inline void -_rune_wctrans_init(_RuneLocale *rl) -{ - rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_name = "tolower"; - rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_cached = &rl->rl_maplower[0]; - rl->rl_wctrans[_WCTRANS_INDEX_LOWER].te_extmap = &rl->rl_maplower_ext; - rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_name = "toupper"; - rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_cached = &rl->rl_mapupper[0]; - rl->rl_wctrans[_WCTRANS_INDEX_UPPER].te_extmap = &rl->rl_mapupper_ext; -} - -static __inline void -_rune_init_priv(_RuneLocalePriv *rlp) -{ -#if _CTYPE_CACHE_SIZE != _CTYPE_NUM_CHARS - int i; - - for (i = _CTYPE_CACHE_SIZE; i < _CTYPE_NUM_CHARS; ++i) { - rlp->rlp_ctype_tab [i + 1] = 0; - rlp->rlp_tolower_tab[i + 1] = i; - rlp->rlp_toupper_tab[i + 1] = i; - -#ifdef __BUILD_LEGACY - rlp->rlp_compat_bsdctype[i + 1] = 0; -#endif - } -#endif - rlp->rlp_ctype_tab [0] = 0; - rlp->rlp_tolower_tab[0] = EOF; - rlp->rlp_toupper_tab[0] = EOF; - - rlp->rl.rl_ctype_tab = (const unsigned short *)&rlp->rlp_ctype_tab[0]; - rlp->rl.rl_tolower_tab = (const short *)&rlp->rlp_tolower_tab[0]; - rlp->rl.rl_toupper_tab = (const short *)&rlp->rlp_toupper_tab[0]; - rlp->rl.rl_codeset = (const char *)&rlp->rlp_codeset[0]; - - _rune_wctype_init(&rlp->rl); - _rune_wctrans_init(&rlp->rl); - -#ifdef __BUILD_LEGACY - rlp->rlp_compat_bsdctype[0] = 0; - rlp->rl.rl_compat_bsdctype = (const unsigned char *) - &rlp->rlp_compat_bsdctype[0]; -#endif -} - -static __inline void -_rune_find_codeset(char *s, size_t n, - char *var, size_t *plenvar) -{ - size_t lenvar; - const char *endvar; - -#define _RUNE_CODESET_LEN (sizeof(_RUNE_CODESET)-1) - - lenvar = *plenvar; - for (/**/; lenvar > _RUNE_CODESET_LEN; ++var, --lenvar) { - if (!memcmp(var, _RUNE_CODESET, _RUNE_CODESET_LEN)) { - *var = '\0'; - *plenvar -= lenvar; - endvar = &var[_RUNE_CODESET_LEN]; - while (n-- > 1 && lenvar-- > _RUNE_CODESET_LEN) { - if (*endvar == ' ' || *endvar == '\t') - break; - *s++ = *endvar++; - } - break; - } - } - *s = '\0'; -} - -#ifdef __BUILD_LEGACY -static __inline int -_runetype_to_bsdctype(_RuneType bits) -{ - int ret; - - if (bits == (_RuneType)0) - return 0; - ret = 0; - if (bits & _RUNETYPE_U) - ret |= _COMPAT_U; - if (bits & _RUNETYPE_L) - ret |= _COMPAT_L; - if (bits & _RUNETYPE_D) - ret |= _COMPAT_N; - if (bits & _RUNETYPE_S) - ret |= _COMPAT_S; - if (bits & _RUNETYPE_P) - ret |= _COMPAT_P; - if (bits & _RUNETYPE_C) - ret |= _COMPAT_C; - if ((bits & (_RUNETYPE_X | _RUNETYPE_D)) == _RUNETYPE_X) - ret |= _COMPAT_X; - if ((bits & (_RUNETYPE_R | _RUNETYPE_G)) == _RUNETYPE_R) - ret |= _COMPAT_B; - return ret; -} -#endif /* __BUILD_LEGACY */ - -static __inline int -_rune_read_file(const char * __restrict var, size_t lenvar, - _RuneLocale ** __restrict prl) -{ - int ret, i; - const _FileRuneLocale *frl; - const _FileRuneEntry *fre; - const uint32_t *frune; - _RuneLocalePriv *rlp; - _RuneLocale *rl; - _RuneEntry *re; - uint32_t *rune; - uint32_t runetype_len, maplower_len, mapupper_len, variable_len; - size_t len, n; - - if (lenvar < sizeof(*frl)) - return EFTYPE; - lenvar -= sizeof(*frl); - frl = (const _FileRuneLocale *)(const void *)var; - if (memcmp(_RUNECT10_MAGIC, &frl->frl_magic[0], sizeof(frl->frl_magic))) - return EFTYPE; - - runetype_len = be32toh(frl->frl_runetype_ext.frr_nranges); - maplower_len = be32toh(frl->frl_maplower_ext.frr_nranges); - mapupper_len = be32toh(frl->frl_mapupper_ext.frr_nranges); - len = runetype_len + maplower_len + mapupper_len; - - fre = (const _FileRuneEntry *)(const void *)(frl + 1); - frune = (const uint32_t *)(const void *)(fre + len); - - variable_len = be32toh((uint32_t)frl->frl_variable_len); - - n = len * sizeof(*fre); - if (lenvar < n) - return EFTYPE; - lenvar -= n; - - n = sizeof(*rlp) + (len * sizeof(*re)) + lenvar; - rlp = (_RuneLocalePriv *)malloc(n); - if (rlp == NULL) - return ENOMEM; - _rune_init_priv(rlp); - - rl = &rlp->rl; - re = (_RuneEntry *)(void *)(rlp + 1); - rune = (uint32_t *)(void *)(re + len); - - for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) { - rl->rl_runetype[i] = be32toh(frl->frl_runetype[i]); - rl->rl_maplower[i] = be32toh((uint32_t)frl->frl_maplower[i]); - rl->rl_mapupper[i] = be32toh((uint32_t)frl->frl_mapupper[i]); - } - -#define READ_RANGE(name) \ -do { \ - const _FileRuneEntry *end_fre; \ - const uint32_t *end_frune; \ - \ - rl->rl_##name##_ext.rr_nranges = name##_len; \ - rl->rl_##name##_ext.rr_rune_ranges = re; \ - \ - end_fre = fre + name##_len; \ - while (fre < end_fre) { \ - re->re_min = be32toh((uint32_t)fre->fre_min); \ - re->re_max = be32toh((uint32_t)fre->fre_max); \ - re->re_map = be32toh((uint32_t)fre->fre_map); \ - if (re->re_map != 0) { \ - re->re_rune_types = NULL; \ - } else { \ - re->re_rune_types = rune; \ - len = re->re_max - re->re_min + 1; \ - n = len * sizeof(*frune); \ - if (lenvar < n) { \ - ret = EFTYPE; \ - goto err; \ - } \ - lenvar -= n; \ - end_frune = frune + len; \ - while (frune < end_frune) \ - *rune++ = be32toh(*frune++); \ - } \ - ++fre, ++re; \ - } \ -} while (/*CONSTCOND*/0) - - READ_RANGE(runetype); - READ_RANGE(maplower); - READ_RANGE(mapupper); - - if (lenvar < variable_len) { - ret = EFTYPE; - goto err; - } - - memcpy((void *)rune, (void const *)frune, variable_len); - rl->rl_variable_len = variable_len; - rl->rl_variable = (void *)rune; - - _rune_find_codeset(rlp->rlp_codeset, sizeof(rlp->rlp_codeset), - (char *)rl->rl_variable, &rl->rl_variable_len); - - ret = _citrus_ctype_open(&rl->rl_citrus_ctype, frl->frl_encoding, - rl->rl_variable, rl->rl_variable_len, _PRIVSIZE); - if (ret) - goto err; - if (__mb_len_max_runtime < - _citrus_ctype_get_mb_cur_max(rl->rl_citrus_ctype)) { - ret = EINVAL; - goto err; - } - - for (i = 0; i < _CTYPE_CACHE_SIZE; ++i) { - wint_t wc; - _RuneType rc; - - ret = _citrus_ctype_btowc(rl->rl_citrus_ctype, i, &wc); - if (ret) - goto err; - if (wc == WEOF) { - rlp->rlp_ctype_tab[i + 1] = 0; - rlp->rlp_tolower_tab[i + 1] = i; - rlp->rlp_toupper_tab[i + 1] = i; - } else { - rc = _runetype_priv(rl, wc); - rlp->rlp_ctype_tab[i + 1] = (unsigned short) - ((rc & ~_RUNETYPE_SWM) >> 8); - -#ifdef __BUILD_LEGACY - rlp->rlp_compat_bsdctype[i + 1] - = _runetype_to_bsdctype(rc); -#endif - -#define CONVERT_MAP(name) \ -do { \ - wint_t map; \ - int c; \ - \ - map = _towctrans_priv(wc, _wctrans_##name(rl)); \ - if (map == wc || (_citrus_ctype_wctob(rl->rl_citrus_ctype, \ - map, &c) || c == EOF)) \ - c = i; \ - rlp->rlp_to##name##_tab[i + 1] = (short)c; \ -} while (/*CONSTCOND*/0) - - CONVERT_MAP(lower); - CONVERT_MAP(upper); - } - } - *prl = rl; - return 0; - -err: - free(rlp); - return ret; -} - -int -_rune_load(const char * __restrict var, size_t lenvar, - _RuneLocale ** __restrict prl) -{ - int ret; - - _DIAGASSERT(var != NULL || lenvar < 1); - _DIAGASSERT(prl != NULL); - - if (lenvar < 1) - return EFTYPE; - switch (*var) { - case 'R': - ret = _rune_read_file(var, lenvar, prl); - break; - default: - ret = EFTYPE; - } - return ret; -} diff --git a/lib/libc/locale/runetable.c b/lib/libc/locale/runetable.c deleted file mode 100644 index a484f60d6..000000000 --- a/lib/libc/locale/runetable.c +++ /dev/null @@ -1,353 +0,0 @@ -/* $NetBSD: runetable.c,v 1.29 2013/08/18 20:03:48 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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. - * - * $FreeBSD: src/lib/libc/locale/table.c,v 1.13 2000/02/08 07:43:25 obrien Exp $ - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)table.c 8.1 (Berkeley) 6/27/93"; -#else -__RCSID("$NetBSD: runetable.c,v 1.29 2013/08/18 20:03:48 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include "citrus_module.h" -#include "citrus_ctype.h" -#include "runetype_local.h" - -__dso_hidden const _RuneLocale _DefaultRuneLocale = { - { /*00*/ _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - /*08*/ _RUNETYPE_C, - _RUNETYPE_C|_RUNETYPE_S|_RUNETYPE_B, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C|_RUNETYPE_S, - _RUNETYPE_C, - _RUNETYPE_C, - /*10*/ _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - /*18*/ _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - _RUNETYPE_C, - /*20*/ _RUNETYPE_S|_RUNETYPE_B|_RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*28*/ _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*30*/ _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|0, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|1, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|2, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|3, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|4, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|5, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|6, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|7, - /*38*/ _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|8, - _RUNETYPE_D|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_X|_RUNETYPE_SW1|9, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*40*/ _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|10, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|11, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|12, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|13, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|14, - _RUNETYPE_U|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|15, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*48*/ _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*50*/ _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*58*/ _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_U|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - /*60*/ _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|10, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|11, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|12, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|13, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|14, - _RUNETYPE_L|_RUNETYPE_X|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1|15, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*68*/ _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*70*/ _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - /*78*/ _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_L|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_A|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_P|_RUNETYPE_R|_RUNETYPE_G|_RUNETYPE_SW1, - _RUNETYPE_C, -#ifdef ALL_80_TO_FF_SW1 - /*80*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*90*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*A0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*B0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*C0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*D0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*E0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - /*F0*/ _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, - _RUNETYPE_R|_RUNETYPE_SW1, _RUNETYPE_R|_RUNETYPE_SW1, -#endif - }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', - 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', - 'x', 'y', 'z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - }, - { 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, - 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f, - 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, - 0x18, 0x19, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, - 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, - 0x28, 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, - 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, - 0x38, 0x39, 0x3a, 0x3b, 0x3c, 0x3d, 0x3e, 0x3f, - 0x40, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0x5b, 0x5c, 0x5d, 0x5e, 0x5f, - 0x60, 'A', 'B', 'C', 'D', 'E', 'F', 'G', - 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', - 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', - 'X', 'Y', 'Z', 0x7b, 0x7c, 0x7d, 0x7e, 0x7f, - 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, - 0x88, 0x89, 0x8a, 0x8b, 0x8c, 0x8d, 0x8e, 0x8f, - 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, - 0x98, 0x99, 0x9a, 0x9b, 0x9c, 0x9d, 0x9e, 0x9f, - 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, - 0xa8, 0xa9, 0xaa, 0xab, 0xac, 0xad, 0xae, 0xaf, - 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, - 0xb8, 0xb9, 0xba, 0xbb, 0xbc, 0xbd, 0xbe, 0xbf, - 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, - 0xc8, 0xc9, 0xca, 0xcb, 0xcc, 0xcd, 0xce, 0xcf, - 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, - 0xd8, 0xd9, 0xda, 0xdb, 0xdc, 0xdd, 0xde, 0xdf, - 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, - 0xe8, 0xe9, 0xea, 0xeb, 0xec, 0xed, 0xee, 0xef, - 0xf0, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, - 0xf8, 0xf9, 0xfa, 0xfb, 0xfc, 0xfd, 0xfe, 0xff, - }, - { 0, NULL }, - { 0, NULL }, - { 0, NULL }, - NULL, 0, - "646", - &_citrus_ctype_default, - { - { "towlower", - __UNCONST(&_DefaultRuneLocale.rl_maplower[0]), - __UNCONST(&_DefaultRuneLocale.rl_maplower_ext) - }, - { "towupper", - __UNCONST(&_DefaultRuneLocale.rl_mapupper[0]), - __UNCONST(&_DefaultRuneLocale.rl_mapupper_ext) - }, - }, - { - { "alnum", _RUNETYPE_A|_RUNETYPE_D }, - { "alpha", _RUNETYPE_A }, - { "blank", _RUNETYPE_B }, - { "cntrl", _RUNETYPE_C }, - { "digit", _RUNETYPE_D }, - { "graph", _RUNETYPE_G }, - { "lower", _RUNETYPE_L }, - { "print", _RUNETYPE_R }, - { "punct", _RUNETYPE_P }, - { "space", _RUNETYPE_S }, - { "upper", _RUNETYPE_U }, - { "xdigit", _RUNETYPE_X }, - }, - _C_ctype_tab_, - _C_tolower_tab_, - _C_toupper_tab_, - -#ifdef __BUILD_LEGACY - _C_compat_bsdctype, -#endif -}; diff --git a/lib/libc/locale/runetype_file.h b/lib/libc/locale/runetype_file.h deleted file mode 100644 index 67d59dbf8..000000000 --- a/lib/libc/locale/runetype_file.h +++ /dev/null @@ -1,136 +0,0 @@ -/* $NetBSD: runetype_file.h,v 1.3 2010/06/20 02:23:15 tnozaki Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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. - * - * @(#)runetype.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _RUNETYPE_FILE_H_ -#define _RUNETYPE_FILE_H_ - -#include -#include - -#include "ctype_local.h" - -/* for cross host tools on older systems */ -#ifndef UINT32_C -/* assumes sizeof(unsigned int)>=4 */ -#define UINT32_C(c) ((uint32_t)(c##U)) -#endif - -typedef uint32_t __nbrune_t; -typedef uint64_t __runepad_t; - -#define _DEFAULT_INVALID_RUNE ((__nbrune_t)-3) - -/* - * The lower 8 bits of runetype[] contain the digit value of the rune. - */ -typedef uint32_t _RuneType; -#define _RUNETYPE_A UINT32_C(0x00000100) /* Alpha */ -#define _RUNETYPE_C UINT32_C(0x00000200) /* Control */ -#define _RUNETYPE_D UINT32_C(0x00000400) /* Digit */ -#define _RUNETYPE_G UINT32_C(0x00000800) /* Graph */ -#define _RUNETYPE_L UINT32_C(0x00001000) /* Lower */ -#define _RUNETYPE_P UINT32_C(0x00002000) /* Punct */ -#define _RUNETYPE_S UINT32_C(0x00004000) /* Space */ -#define _RUNETYPE_U UINT32_C(0x00008000) /* Upper */ -#define _RUNETYPE_X UINT32_C(0x00010000) /* X digit */ -#define _RUNETYPE_B UINT32_C(0x00020000) /* Blank */ -#define _RUNETYPE_R UINT32_C(0x00040000) /* Print */ -#define _RUNETYPE_I UINT32_C(0x00080000) /* Ideogram */ -#define _RUNETYPE_T UINT32_C(0x00100000) /* Special */ -#define _RUNETYPE_Q UINT32_C(0x00200000) /* Phonogram */ -#define _RUNETYPE_SWM UINT32_C(0xc0000000)/* Mask to get screen width data */ -#define _RUNETYPE_SWS 30 /* Bits to shift to get width */ -#define _RUNETYPE_SW0 UINT32_C(0x20000000) /* 0 width character */ -#define _RUNETYPE_SW1 UINT32_C(0x40000000) /* 1 width character */ -#define _RUNETYPE_SW2 UINT32_C(0x80000000) /* 2 width character */ -#define _RUNETYPE_SW3 UINT32_C(0xc0000000) /* 3 width character */ - -/* - * rune file format. network endian. - */ -typedef struct { - int32_t fre_min; /* First rune of the range */ - int32_t fre_max; /* Last rune (inclusive) of the range */ - int32_t fre_map; /* What first maps to in maps */ - uint32_t fre_pad1; /* backward compatibility */ - __runepad_t fre_pad2; /* backward compatibility */ -} __packed _FileRuneEntry; - - -typedef struct { - uint32_t frr_nranges; /* Number of ranges stored */ - uint32_t frr_pad1; /* backward compatibility */ - __runepad_t frr_pad2; /* backward compatibility */ -} __packed _FileRuneRange; - - -typedef struct { - char frl_magic[8]; /* Magic saying what version we are */ - char frl_encoding[32];/* ASCII name of this encoding */ - - __runepad_t frl_pad1; /* backward compatibility */ - __runepad_t frl_pad2; /* backward compatibility */ - int32_t frl_invalid_rune; - uint32_t frl_pad3; /* backward compatibility */ - - _RuneType frl_runetype[_CTYPE_CACHE_SIZE]; - int32_t frl_maplower[_CTYPE_CACHE_SIZE]; - int32_t frl_mapupper[_CTYPE_CACHE_SIZE]; - - /* - * The following are to deal with Runes larger than _CTYPE_CACHE_SIZE - 1. - * Their data is actually contiguous with this structure so as to make - * it easier to read/write from/to disk. - */ - _FileRuneRange frl_runetype_ext; - _FileRuneRange frl_maplower_ext; - _FileRuneRange frl_mapupper_ext; - - __runepad_t frl_pad4; /* backward compatibility */ - int32_t frl_variable_len;/* how long that data is */ - uint32_t frl_pad5; /* backward compatibility */ - - /* variable size data follows */ -} __packed _FileRuneLocale; - - -/* magic number for LC_CTYPE (rune)locale declaration */ -#define _RUNECT10_MAGIC "RuneCT10" /* Indicates version 0 of RuneLocale */ - -/* codeset tag */ -#define _RUNE_CODESET "CODESET=" - -#endif /* !_RUNETYPE_FILE_H_ */ diff --git a/lib/libc/locale/runetype_local.h b/lib/libc/locale/runetype_local.h deleted file mode 100644 index 675fea941..000000000 --- a/lib/libc/locale/runetype_local.h +++ /dev/null @@ -1,145 +0,0 @@ -/* $NetBSD: runetype_local.h,v 1.14 2013/08/18 20:03:48 joerg Exp $ */ - -/*- - * Copyright (c) 1993 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Paul Borman at Krystal Technologies. - * - * 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. - * - * @(#)rune.h 8.1 (Berkeley) 6/27/93 - * @(#)runetype.h 8.1 (Berkeley) 6/2/93 - */ - -#ifndef _RUNETYPE_LOCAL_H_ -#define _RUNETYPE_LOCAL_H_ - -#include -#include -#include - -#include "ctype_local.h" -#include "runetype_file.h" - -#define _RUNE_ISCACHED(c) ((c)>=0 && (c)<_CTYPE_CACHE_SIZE) - - -/* - * expanded rune locale declaration. local to the host. host endian. - */ -typedef struct { - __nbrune_t re_min; /* First rune of the range */ - __nbrune_t re_max; /* Last rune (inclusive) of the range */ - __nbrune_t re_map; /* What first maps to in maps */ - _RuneType *re_rune_types; /* Array of types in range */ -} _RuneEntry; - - -typedef struct { - uint32_t rr_nranges; /* Number of ranges stored */ - _RuneEntry *rr_rune_ranges; -} _RuneRange; - - -/* - * wctrans stuffs. - */ -typedef struct _WCTransEntry { - const char *te_name; - __nbrune_t *te_cached; - _RuneRange *te_extmap; -} _WCTransEntry; -#define _WCTRANS_INDEX_LOWER 0 -#define _WCTRANS_INDEX_UPPER 1 -#define _WCTRANS_NINDEXES 2 - -/* - * wctype stuffs. - */ -typedef struct _WCTypeEntry { - const char *te_name; - _RuneType te_mask; -} _WCTypeEntry; -#define _WCTYPE_INDEX_ALNUM 0 -#define _WCTYPE_INDEX_ALPHA 1 -#define _WCTYPE_INDEX_BLANK 2 -#define _WCTYPE_INDEX_CNTRL 3 -#define _WCTYPE_INDEX_DIGIT 4 -#define _WCTYPE_INDEX_GRAPH 5 -#define _WCTYPE_INDEX_LOWER 6 -#define _WCTYPE_INDEX_PRINT 7 -#define _WCTYPE_INDEX_PUNCT 8 -#define _WCTYPE_INDEX_SPACE 9 -#define _WCTYPE_INDEX_UPPER 10 -#define _WCTYPE_INDEX_XDIGIT 11 -#define _WCTYPE_NINDEXES 12 - -/* - * ctype stuffs - */ - -typedef struct _RuneLocale { - /* - * copied from _FileRuneLocale - */ - _RuneType rl_runetype[_CTYPE_CACHE_SIZE]; - __nbrune_t rl_maplower[_CTYPE_CACHE_SIZE]; - __nbrune_t rl_mapupper[_CTYPE_CACHE_SIZE]; - _RuneRange rl_runetype_ext; - _RuneRange rl_maplower_ext; - _RuneRange rl_mapupper_ext; - - void *rl_variable; - size_t rl_variable_len; - - /* - * the following portion is generated on the fly - */ - const char *rl_codeset; - struct _citrus_ctype_rec *rl_citrus_ctype; - _WCTransEntry rl_wctrans[_WCTRANS_NINDEXES]; - _WCTypeEntry rl_wctype[_WCTYPE_NINDEXES]; - - const unsigned short *rl_ctype_tab; - const short *rl_tolower_tab; - const short *rl_toupper_tab; - -#ifdef __BUILD_LEGACY - const unsigned char *rl_compat_bsdctype; -#endif -} _RuneLocale; - -/* - * global variables - */ -extern __dso_hidden const _RuneLocale _DefaultRuneLocale; - -__BEGIN_DECLS -int _rune_load(const char * __restrict, size_t, _RuneLocale ** __restrict); -__END_DECLS - -#endif /* !_RUNETYPE_LOCAL_H_ */ diff --git a/lib/libc/locale/setlocale.3 b/lib/libc/locale/setlocale.3 deleted file mode 100644 index 9d88b9929..000000000 --- a/lib/libc/locale/setlocale.3 +++ /dev/null @@ -1,407 +0,0 @@ -.\" $NetBSD: setlocale.3,v 1.21 2004/01/24 16:58:54 wiz Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Donn Seeley at BSDI. -.\" -.\" 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. -.\" -.\" @(#)setlocale.3 8.1 (Berkeley) 6/9/93 -.\" -.Dd May 30, 2003 -.Dt SETLOCALE 3 -.Os -.Sh NAME -.Nm setlocale , -.Nm localeconv -.Nd natural language formatting for C -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In locale.h -.Ft char * -.Fn setlocale "int category" "const char *locale" -.Ft struct lconv * -.Fn localeconv "void" -.Sh DESCRIPTION -The -.Fn setlocale -function sets the C library's notion -of natural language formatting style -for particular sets of routines. -Each such style is called a -.Sq locale -and is invoked using an appropriate name passed as a C string. -The -.Fn localeconv -routine returns the current locale's parameters -for formatting numbers. -.Pp -The -.Fn setlocale -function recognizes several categories of routines. -These are the categories and the sets of routines they select: -.Bl -tag -width LC_MONETARY -.It Dv LC_ALL -Set the entire locale generically. -.It Dv LC_COLLATE -Set a locale for string collation routines. -This controls alphabetic ordering in -.Fn strcoll -and -.Fn strxfrm . -.It Dv LC_CTYPE -Set a locale for the -.Xr ctype 3 -functions. -This controls recognition of upper and lower case, -alphabetic or non-alphabetic characters, -and so on. -The real work is done by the -.Fn setrunelocale -function. -.It Dv LC_MESSAGES -Set a locale for message catalogs. -This controls the selection of message catalogs by the -.Xr catgets 3 -and -.Xr gettext 3 -families of functions. -.It Dv LC_MONETARY -Set a locale for formatting monetary values; -this affects the -.Fn localeconv -function. -.It Dv LC_NUMERIC -Set a locale for formatting numbers. -This controls the formatting of decimal points -in input and output of floating point numbers -in functions such as -.Fn printf -and -.Fn scanf , -as well as values returned by -.Fn localeconv . -.It Dv LC_TIME -Set a locale for formatting dates and times using the -.Fn strftime -function. -.El -.Pp -Only three locales are defined by default, -the empty string -.Li "\&""\|"" -which denotes the native environment, and the -.Li "\&""C"" -and -.Li "\&""POSIX"" -locales, which denote the C language environment. -A -.Fa locale -argument of -.Dv NULL -causes -.Fn setlocale -to return the current locale. -By default, C programs start in the -.Li "\&""C"" -locale. -The format of the locale string is described in -.Xr nls 7 . -.Pp -The only function in the library that sets the locale is -.Fn setlocale ; -the locale is never changed as a side effect of some other routine. -.Pp -Changing the setting of -.Dv LC_MESSAGES -has no effect on catalogs that have already been opened by -.Xr catopen 3 . -.Pp -The -.Fn localeconv -function returns a pointer to a structure -which provides parameters for formatting numbers, -especially currency values: -.Bd -literal -offset indent -struct lconv { - char *decimal_point; - char *thousands_sep; - char *grouping; - char *int_curr_symbol; - char *currency_symbol; - char *mon_decimal_point; - char *mon_thousands_sep; - char *mon_grouping; - char *positive_sign; - char *negative_sign; - char int_frac_digits; - char frac_digits; - char p_cs_precedes; - char p_sep_by_space; - char n_cs_precedes; - char n_sep_by_space; - char p_sign_posn; - char n_sign_posn; - char int_p_cs_precedes; - char int_n_cs_precedes; - char int_p_sep_by_space; - char int_n_sep_by_space; - char int_p_sign_posn; - char int_n_sign_posn; -}; -.Ed -.Pp -The individual fields have the following meanings: -.Bl -tag -width int_p_sep_by_space -.It Fa decimal_point -The decimal point character, except for monetary values. -.It Fa thousands_sep -The separator between groups of digits -before the decimal point, except for monetary values. -.It Fa grouping -The sizes of the groups of digits, except for monetary values. -This is a pointer to a vector of integers, each of size -.Va char , -representing group size from low order digit groups -to high order (right to left). -The list may be terminated with 0 or -.Dv CHAR_MAX . -If the list is terminated with 0, -the last group size before the 0 is repeated to account for all the digits. -If the list is terminated with -.Dv CHAR_MAX , -no more grouping is performed. -.It Fa int_curr_symbol -The standardized (ISO 4217:1995) international currency symbol. -.It Fa currency_symbol -The local currency symbol. -.It Fa mon_decimal_point -The decimal point character for monetary values. -.It Fa mon_thousands_sep -The separator for digit groups in monetary values. -.It Fa mon_grouping -Like -.Fa grouping -but for monetary values. -.It Fa positive_sign -The character used to denote nonnegative monetary values, -usually the empty string. -.It Fa negative_sign -The character used to denote negative monetary values, -usually a minus sign. -.It Fa int_frac_digits -The number of digits after the decimal point -in an internationally formatted monetary value. -.It Fa frac_digits -The number of digits after the decimal point -in an locally formatted monetary value. -.It Fa p_cs_precedes -1 if the currency symbol precedes the monetary value -for nonnegative values, 0 if it follows. -.It Fa p_sep_by_space -1 if a space is inserted between the currency symbol -and the monetary value for nonnegative values, 0 otherwise. -.It Fa n_cs_precedes -Like -.Fa p_cs_precedes -but for negative values. -.It Fa n_sep_by_space -Like -.Fa p_sep_by_space -but for negative values. -.It Fa p_sign_posn -The location of the -.Fa positive_sign -with respect to a nonnegative quantity and the -.Fa currency_symbol . -.It Fa n_sign_posn -Like -.Fa p_sign_posn -but for negative currency values. -.It Fa int_p_cs_precedes -1 if the currency symbol precedes the internationally -formatted monetary value for nonnegative values, 0 if it follows. -.It Fa int_n_cs_precedes -Like -.Fa int_p_cs_precedes -but for negative values. -.It Fa int_p_sep_by_space -1 if a space is inserted between the currency symbol -and the internationally formatted monetary value for -nonnegative values, 0 otherwise. -.It Fa int_n_sep_by_space -Like -.Fa int_p_sep_by_space -but for negative values. -.It Fa int_p_sign_posn -The location of the -.Fa positive_sign -with respect to a nonnegative quantity and the -.Fa currency_symbol , -for internationally formatted nonnegative monetary values. -.It Fa int_n_sign_posn -Like -.Fa int_p_sign_posn -but for negative values. -.El -.Pp -The positional parameters in -.Fa p_sign_posn , -.Fa n_sign_posn , -.Fa int_p_sign_posn -and -.Fa int_n_sign_posn -are encoded as follows: -.Bl -tag -width 3n -compact -.It Li 0 -Parentheses around the entire string. -.It Li 1 -Before the string. -.It Li 2 -After the string. -.It Li 3 -Just before -.Fa currency_symbol . -.It Li 4 -Just after -.Fa currency_symbol . -.El -.Pp -Unless mentioned above, -an empty string as a value for a field -indicates a zero length result or -a value that is not in the current locale. -A -.Dv CHAR_MAX -result similarly denotes an unavailable value. -.Sh RETURN VALUES -The -.Fn setlocale -function returns -.Dv NULL -and fails to change the locale -if the given combination of -.Fa category -and -.Fa locale -makes no sense. -The -.Fn localeconv -function returns a pointer to a static object -which may be altered by later calls to -.Fn setlocale -or -.Fn localeconv . -.Sh EXAMPLES -The following code illustrates how a program can initialize the -international environment for one language, while selectively -modifying the program's locale such that regular expressions and -string operations can be applied to text recorded in a different -language: -.Bd -literal - setlocale(LC_ALL, "de"); - setlocale(LC_COLLATE, "fr"); -.Ed -.Pp -When a process is started, its current locale is set to the C or POSIX -locale. -An internationalized program that depends on locale data not defined in -the C or POSIX locale must invoke the setlocale subroutine in the -following manner before using any of the locale-specific information: -.Bd -literal - setlocale(LC_ALL, ""); -.Ed -.\" .Sh FILES XXX -.\" .Bl -tag -width /usr/share/locale/locale/category -compact XXX -.\" .It Pa $PATH_LOCALE/\fIlocale\fP/\fIcategory\fP XXX -.\" .It Pa /usr/share/locale/\fIlocale\fP/\fIcategory\fP XXX -.\" locale file for the locale \fIlocale\fP XXX -.\" and the category \fIcategory\fP. XXX -.\" .El -.Sh SEE ALSO -.Xr catopen 3 , -.Xr gettext 3 , -.Xr nl_langinfo 3 , -.Xr nls 7 -.\" .Xr strcoll 3 , XXX -.\" .Xr strxfrm 3 XXX -.Sh STANDARDS -The -.Fn setlocale -and -.Fn localeconv -functions conform to -.St -ansiC -and -.St -isoC-90 . -.Pp -The -.Fa int_p_cs_precedes , -.Fa int_n_cs_precedes , -.Fa int_p_sep_by_space , -.Fa int_n_sep_by_space , -.Fa int_p_sign_posn -and -.Fa int_n_sign_posn -members of -.Ft struct lconv -were introduced in -.St -isoC-99 . -.Sh HISTORY -The -.Fn setlocale -and -.Fn localeconv -functions first appeared in -.Bx 4.4 . -.Sh BUGS -The current implementation supports only the -.Li "\&""C"" -and -.Li "\&""POSIX"" -locales for all but the -.Dv LC_CTYPE -locale. -.Pp -In spite of the gnarly currency support in -.Fn localeconv , -the standards don't include any functions -for generalized currency formatting. -.Pp -.Dv LC_COLLATE -does not make sense for many languages. -Use of -.Dv LC_MONETARY -could lead to misleading results until we have a real time currency -conversion function. -.Dv LC_NUMERIC -and -.Dv LC_TIME -are personal choices and should not be wrapped up with the other categories. -.Pp -Multibyte locales aren't supported for static binaries. diff --git a/lib/libc/locale/setlocale.c b/lib/libc/locale/setlocale.c deleted file mode 100644 index c5d436574..000000000 --- a/lib/libc/locale/setlocale.c +++ /dev/null @@ -1,194 +0,0 @@ -/* $NetBSD: setlocale.c,v 1.64 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: setlocale.c,v 1.64 2013/09/13 13:13:32 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -const char *_PathLocale = NULL; - -static _locale_set_t all_categories[_LC_LAST] = { - [LC_ALL ] = &_generic_LC_ALL_setlocale, - [LC_COLLATE ] = &_dummy_LC_COLLATE_setlocale, - [LC_CTYPE ] = &_citrus_LC_CTYPE_setlocale, - [LC_MONETARY] = &_citrus_LC_MONETARY_setlocale, - [LC_NUMERIC ] = &_citrus_LC_NUMERIC_setlocale, - [LC_TIME ] = &_citrus_LC_TIME_setlocale, - [LC_MESSAGES] = &_citrus_LC_MESSAGES_setlocale, -}; - -/* XXX Consider locking the list. Race condition leaks memory. */ -static SLIST_HEAD(, _locale_cache_t) caches = { - __UNCONST(&_C_cache) -}; - -int -_setlocale_cache(locale_t loc, struct _locale_cache_t *cache) -{ - const char *monetary_name = loc->part_name[LC_MONETARY]; - const char *numeric_name = loc->part_name[LC_NUMERIC]; - _NumericLocale *numeric = loc->part_impl[LC_NUMERIC]; - _MonetaryLocale *monetary = loc->part_impl[LC_MONETARY]; - struct lconv *ldata; - - struct _locale_cache_t *old_cache; - - SLIST_FOREACH(old_cache, &caches, cache_link) { - if (monetary_name != old_cache->monetary_name && - strcmp(monetary_name, old_cache->monetary_name) != 0) - continue; - if (numeric_name != old_cache->numeric_name && - strcmp(numeric_name, old_cache->numeric_name) != 0) - continue; - loc->cache = old_cache; - free(cache); - return 0; - } - - if (cache == NULL) { - cache = malloc(sizeof(*cache)); - if (cache == NULL) - return -1; - } - - cache->monetary_name = monetary_name; - cache->numeric_name = numeric_name; - ldata = &cache->ldata; - - ldata->decimal_point = __UNCONST(numeric->decimal_point); - ldata->thousands_sep = __UNCONST(numeric->thousands_sep); - ldata->grouping = __UNCONST(numeric->grouping); - - ldata->int_curr_symbol = __UNCONST(monetary->int_curr_symbol); - ldata->currency_symbol = __UNCONST(monetary->currency_symbol); - ldata->mon_decimal_point = __UNCONST(monetary->mon_decimal_point); - ldata->mon_thousands_sep = __UNCONST(monetary->mon_thousands_sep); - ldata->mon_grouping = __UNCONST(monetary->mon_grouping); - ldata->positive_sign = __UNCONST(monetary->positive_sign); - ldata->negative_sign = __UNCONST(monetary->negative_sign); - - ldata->int_frac_digits = monetary->int_frac_digits; - ldata->frac_digits = monetary->frac_digits; - ldata->p_cs_precedes = monetary->p_cs_precedes; - ldata->p_sep_by_space = monetary->p_sep_by_space; - ldata->n_cs_precedes = monetary->n_cs_precedes; - ldata->n_sep_by_space = monetary->n_sep_by_space; - ldata->p_sign_posn = monetary->p_sign_posn; - ldata->n_sign_posn = monetary->n_sign_posn; - ldata->int_p_cs_precedes = monetary->int_p_cs_precedes; - ldata->int_n_cs_precedes = monetary->int_n_cs_precedes; - ldata->int_p_sep_by_space = monetary-> int_p_sep_by_space; - ldata->int_n_sep_by_space = monetary->int_n_sep_by_space; - ldata->int_p_sign_posn = monetary->int_p_sign_posn; - ldata->int_n_sign_posn = monetary->int_n_sign_posn; - SLIST_INSERT_HEAD(&caches, cache, cache_link); - - loc->cache = cache; - return 0; -} - -_locale_set_t -_find_category(int category) -{ - static int initialised; - - if (!initialised) { - if (issetugid() || ((_PathLocale == NULL && - (_PathLocale = getenv("PATH_LOCALE")) == NULL) || - *_PathLocale == '\0')) - _PathLocale = _PATH_LOCALE; - initialised = 1; - } - - if (category >= LC_ALL && category < _LC_LAST) - return all_categories[category]; - return NULL; -} - -const char * -_get_locale_env(const char *category) -{ - const char *name; - - /* 1. check LC_ALL */ - name = (const char *)getenv("LC_ALL"); - if (name == NULL || *name == '\0') { - /* 2. check LC_* */ - name = (const char *)getenv(category); - if (name == NULL || *name == '\0') { - /* 3. check LANG */ - name = getenv("LANG"); - } - } - if (name == NULL || *name == '\0' || strchr(name, '/')) - /* 4. if none is set, fall to "C" */ - name = _C_LOCALE; - return name; -} - -char * -__setlocale(int category, const char *name) -{ - _locale_set_t sl; - locale_t loc; - struct _locale_cache_t *cache; - const char *result; - - sl = _find_category(category); - if (sl == NULL) - return NULL; - cache = malloc(sizeof(*cache)); - if (cache == NULL) - return NULL; - loc = _current_locale(); - result = (*sl)(name, loc); - _setlocale_cache(loc, cache); - return __UNCONST(result); -} - -char * -setlocale(int category, const char *locale) -{ - - /* locale may be NULL */ - - __mb_len_max_runtime = MB_LEN_MAX; - return __setlocale(category, locale); -} diff --git a/lib/libc/locale/setlocale_local.h b/lib/libc/locale/setlocale_local.h deleted file mode 100644 index 0d03c06a4..000000000 --- a/lib/libc/locale/setlocale_local.h +++ /dev/null @@ -1,100 +0,0 @@ -/* $NetBSD: setlocale_local.h,v 1.15 2013/09/13 13:13:32 joerg Exp $ */ - -/*- - * Copyright (c)2008 Citrus Project, - * 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. - */ - -#ifndef _SETLOCALE_LOCAL_H_ -#define _SETLOCALE_LOCAL_H_ - -#include -#include - -#include "ctype_local.h" - -#define _LOCALENAME_LEN_MAX 33 - -#define _C_LOCALE "C" -#define _POSIX_LOCALE "POSIX" - -extern const char *_PathLocale; -#define _LOCALE_ALIAS_NAME "locale.alias" - -typedef void *_locale_part_t; - -struct _locale_cache_t { - SLIST_ENTRY(_locale_cache_t) cache_link; - const char *monetary_name; - const char *numeric_name; - struct lconv ldata; -}; - -struct _locale { - const struct _locale_cache_t *cache; - char query[_LOCALENAME_LEN_MAX * (_LC_LAST - 1)]; - const char *part_name[_LC_LAST]; - _locale_part_t part_impl[_LC_LAST]; -}; - -typedef const char *(*_locale_set_t)(const char * __restrict, - struct _locale * __restrict); - -__BEGIN_DECLS -_locale_set_t _find_category(int); -const char *_get_locale_env(const char *); -char *__setlocale(int, const char *); - -const char *_generic_LC_ALL_setlocale( - const char * __restrict, struct _locale * __restrict); -const char *_dummy_LC_COLLATE_setlocale( - const char * __restrict, struct _locale * __restrict); -const char *_citrus_LC_CTYPE_setlocale( - const char * __restrict, struct _locale * __restrict); -const char *_citrus_LC_MONETARY_setlocale( - const char * __restrict, struct _locale * __restrict); -const char *_citrus_LC_NUMERIC_setlocale( - const char * __restrict, struct _locale * __restrict); -const char *_citrus_LC_TIME_setlocale( - const char * __restrict, struct _locale * __restrict); -const char *_citrus_LC_MESSAGES_setlocale( - const char * __restrict, struct _locale * __restrict); - -int _setlocale_cache(locale_t, struct _locale_cache_t *); -__END_DECLS - -#ifdef _LIBC -extern __dso_protected struct _locale _lc_global_locale; -extern __dso_hidden const struct _locale_cache_t _C_cache; - -static __inline struct _locale * -_current_locale(void) -{ - return &_lc_global_locale; -} -#endif - -extern size_t __mb_len_max_runtime; - -#endif /*_SETLOCALE_LOCAL_H_*/ diff --git a/lib/libc/locale/towctrans.3 b/lib/libc/locale/towctrans.3 deleted file mode 100644 index 7772755ad..000000000 --- a/lib/libc/locale/towctrans.3 +++ /dev/null @@ -1,87 +0,0 @@ -.\" $NetBSD: towctrans.3,v 1.6 2005/06/27 14:18:36 wiz Exp $ -.\" -.\" Copyright (c)2003 Citrus Project, -.\" 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. -.\" -.Dd March 4, 2003 -.Dt TOWCTRANS 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm towctrans -.Nd convert a wide character with a specified map -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wctype.h -.Ft wint_t -.Fn towctrans "wint_t wc" "wctrans_t charmap" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn towctrans -function converts a wide character -.Fa wc -with a character mapping -.Fa charmap . -.Pp -The behaviour of -.Fn towctrans -is undefined if the -.Fn towctrans -function is called with an invalid -.Fa charmap -(changes of -.Dv LC_CTYPE -category invalidate -.Fa charmap ) -or invalid wide character -.Fa wc . -.Pp -The behaviour of -.Fn towctrans -is affected by the -.Dv LC_CTYPE -category of the current locale. -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -.Fn towctrans -returns the resulting character of the conversion. -.\" ---------------------------------------------------------------------- -.Sh ERRORS -No errors are defined. -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr iswctype 3 , -.Xr setlocale 3 , -.Xr wctrans 3 , -.Xr wctype 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn towctrans -function conforms to -.St -isoC-amd1 . diff --git a/lib/libc/locale/towlower.3 b/lib/libc/locale/towlower.3 deleted file mode 100644 index f6a675b10..000000000 --- a/lib/libc/locale/towlower.3 +++ /dev/null @@ -1,69 +0,0 @@ -.\" $NetBSD: towlower.3,v 1.7 2003/09/08 17:54:31 wiz Exp $ -.\" -.\" Copyright (c) 1989, 1991 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" the American National Standards Committee X3, on Information -.\" Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 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. -.\" -.\" @(#)tolower.3 5.2 (Berkeley) 6/29/91 -.\" -.Dd December 22, 2000 -.Dt TOWLOWER 3 -.Os -.Sh NAME -.Nm towlower -.Nd wide character case letter conversion utilities -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wctype.h -.Ft wint_t -.Fn towlower "wint_t wc" -.Ft wint_t -.Fn towupper "wint_t wc" -.Sh DESCRIPTION -The -.Fn towlower -function converts an upper-case wide character to the corresponding lower-case -letter. -The -.Fn towupper -function converts an lower-case wide character to the corresponding upper-case -letter. -.Sh RETURN VALUES -If the argument is an upper/lower-case letter, the -.Fn tolower -function returns the corresponding counterpart if there is -one; otherwise the argument is returned unchanged. -.Sh SEE ALSO -.Xr tolower 3 , -.Xr toupper 3 -.Sh STANDARDS -The functions conform to -.St -isoC-99 . diff --git a/lib/libc/locale/wcrtomb.3 b/lib/libc/locale/wcrtomb.3 deleted file mode 100644 index fb03f05f8..000000000 --- a/lib/libc/locale/wcrtomb.3 +++ /dev/null @@ -1,145 +0,0 @@ -.\" $NetBSD: wcrtomb.3,v 1.9 2007/02/20 08:33:25 wiz Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd February 4, 2002 -.Dt WCRTOMB 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm wcrtomb -.Nd converts a wide character to a multibyte character (restartable) -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn wcrtomb "char * restrict s" "wchar_t wc" "mbstate_t * restrict ps" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -.Fn wcrtomb -converts the wide character given by -.Fa wc -to the corresponding multibyte character, and stores it in the array -pointed to by -.Fa s -unless -.Fa s -is a null pointer. -This function will modify the first at most -.Dv MB_CUR_MAX -bytes of the array pointed to by -.Fa s . -.Pp -The behaviour of -.Fn wcrtomb -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -These are the special cases: -.Bl -tag -width 012345678901 -.It "wc == 0" -For state-dependent encodings, -.Fn wcrtomb -stores a nul byte preceded by special byte sequence (if any) -to return to an initial state in the array pointed to by -.Fa s , -and the state object pointed to by -.Fa ps -also returns to an initial state. -.It "s == NULL" -.Fn wcrtomb -just places -.Fa ps -into an initial state. -It is equivalent to the following call: -.Bd -literal -offset indent -wcrtomb(buf, L'\\0', ps); -.Ed -.Pp -Here, -.Fa buf -is a dummy buffer. -In this case, -.Fa wc -is ignored. -.It "ps == NULL" -.Fn mbrtowc -uses its own internal state object to keep the conversion state, -instead of -.Fa ps -mentioned in this manual page. -.Pp -Calling any other functions in -.Lb libc -never changes the internal -state of -.Fn mbrtowc , -which is initialized at startup time of the program. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -.Fn wcrtomb -returns: -.Bl -tag -width 012345678901 -.It "positive" -The number of bytes (including any shift sequences) -which are stored in the array. -.It "(size_t)-1" -.Fa wc -is not a valid wide character. -In this case, -.Fn wcrtomb -also sets -.Va errno -to indicate the error. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn wcrtomb -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa wc -is not a valid wide character. -.It Bq Er EINVAL -.Fa ps -points to an invalid or uninitialized mbstate_t object. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr setlocale 3 , -.Xr wctomb 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn wcrtomb -function conforms to -.St -isoC-amd1 . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/wcscoll.3 b/lib/libc/locale/wcscoll.3 deleted file mode 100644 index 1e238158e..000000000 --- a/lib/libc/locale/wcscoll.3 +++ /dev/null @@ -1,112 +0,0 @@ -.\" $NetBSD: wcscoll.3,v 1.3 2010/12/16 17:42:27 wiz Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strcoll.3 8.1 (Berkeley) 6/4/93 -.\" FreeBSD: src/lib/libc/string/strcoll.3,v 1.11 2001/10/01 16:09:00 ru Exp -.\" FreeBSD: /repoman/r/ncvs/src/lib/libc/string/wcscoll.3,v 1.2 2002/12/09 14:04:05 ru Exp -.\" -.Dd October 13, 2006 -.Dt WCSCOLL 3 -.Os -.Sh NAME -.Nm wcscoll -.Nd compare wide strings according to current collation -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wchar.h -.Ft int -.Fn wcscoll "const wchar_t *s1" "const wchar_t *s2" -.Sh DESCRIPTION -The -.Fn wcscoll -function compares the nul-terminated strings -.Fa s1 -and -.Fa s2 -according to the current locale collation order. -In the -.Dq Li C -locale, -.Fn wcscoll -is equivalent to -.Fn wcscmp . -.Sh RETURN VALUES -The -.Fn wcscoll -function returns an integer greater than, equal to, or less than -0, if -.Fa s1 -is greater than, equal to, or less than -.Fa s2 . -.Pp -No return value is reserved to indicate errors; -callers should set -.Va errno -to 0 before calling -.Fn wcscoll . -If it is non-zero upon return from -.Fn wcscoll , -an error has occurred. -.Sh ERRORS -The -.Fn wcscoll -function will fail if: -.Bl -tag -width Er -.It Bq Er EILSEQ -An invalid wide-character code was specified. -.It Bq Er ENOMEM -Cannot allocate enough memory for temporary buffers. -.El -.Sh SEE ALSO -.Xr setlocale 3 , -.Xr strcoll 3 , -.Xr wcscmp 3 , -.Xr wcsxfrm 3 -.Sh STANDARDS -The -.Fn wcscoll -function conforms to -.St -isoC-99 . -.Sh BUGS -The current implementation of -.Fn wcscoll -function disregards -.Dv LC_COLLATE -locales, and falls back to using the -.Fn wcscmp -function. diff --git a/lib/libc/locale/wcscoll.c b/lib/libc/locale/wcscoll.c deleted file mode 100644 index 00ac32328..000000000 --- a/lib/libc/locale/wcscoll.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: wcscoll.c,v 1.4 2013/05/17 12:55:57 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcscoll.c,v 1.4 2013/05/17 12:55:57 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include "setlocale_local.h" - -/* - * Compare strings with using collating information. - */ -int -wcscoll_l(const wchar_t *s1, const wchar_t *s2, locale_t loc) -{ - /* XXX: LC_COLLATE should be implemented. */ - /* LINTED */ (void)loc; - return (wcscmp(s1, s2)); -} - -int -wcscoll(const wchar_t *s1, const wchar_t *s2) -{ - return wcscoll_l(s1, s2, _current_locale()); -} diff --git a/lib/libc/locale/wcsftime.3 b/lib/libc/locale/wcsftime.3 deleted file mode 100644 index 4cd59849f..000000000 --- a/lib/libc/locale/wcsftime.3 +++ /dev/null @@ -1,70 +0,0 @@ -.\" $NetBSD: wcsftime.3,v 1.3 2011/04/14 05:50:49 jruoho Exp $ -.\" -.\" Copyright (c) 2002 Tim J. Robbins -.\" 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: /repoman/r/ncvs/src/lib/libc/locale/wcsftime.3,v 1.2 2002/11/29 17:35:09 ru Exp $ -.\" -.Dd April 14, 2011 -.Dt WCSFTIME 3 -.Os -.Sh NAME -.Nm wcsftime -.Nd "convert date and time to a wide-character string" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fo wcsftime -.Fa "wchar_t * restrict wcs" "size_t maxsize" -.Fa "const wchar_t * restrict format" "const struct tm * restrict timeptr" -.Fc -.Sh DESCRIPTION -The -.Fn wcsftime -function is equivalent to the -.Fn strftime -function except for the types of its arguments -and the return value indicating the number of wide characters. -Refer to -.Xr strftime 3 -for a detailed description. -.Sh COMPATIBILITY -Some early implementations of -.Fn wcsftime -had a -.Fa format -argument with type -.Vt "const char *" -instead of -.Vt "const wchar_t *" . -.Sh SEE ALSO -.Xr strftime 3 , -.Xr tm 3 -.Sh STANDARDS -The -.Fn wcsftime -function conforms to -.St -isoC-99 . diff --git a/lib/libc/locale/wcsftime.c b/lib/libc/locale/wcsftime.c deleted file mode 100644 index 72ef92ca6..000000000 --- a/lib/libc/locale/wcsftime.c +++ /dev/null @@ -1,116 +0,0 @@ -/* $NetBSD: wcsftime.c,v 1.5 2013/08/19 20:41:15 joerg Exp $ */ -/*- - * Copyright (c) 2002 Tim J. Robbins - * 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 -__RCSID("$NetBSD: wcsftime.c,v 1.5 2013/08/19 20:41:15 joerg Exp $"); - -#define __SETLOCALE_SOURCE__ -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#include "setlocale_local.h" - -__weak_alias(wcsftime_l, _wcsftime_l) - -/* - * Convert date and time to a wide-character string. - * - * This is the wide-character counterpart of strftime(). So that we do not - * have to duplicate the code of strftime(), we convert the format string to - * multibyte, call strftime(), then convert the result back into wide - * characters. - * - * This technique loses in the presence of stateful multibyte encoding if any - * of the conversions in the format string change conversion state. When - * stateful encoding is implemented, we will need to reset the state between - * format specifications in the format string. - */ -size_t -wcsftime(wchar_t *wcs, size_t maxsize, - const wchar_t *format, const struct tm *timeptr) -{ - return wcsftime_l(wcs, maxsize, format, timeptr, _current_locale()); -} - -size_t -wcsftime_l(wchar_t *wcs, size_t maxsize, - const wchar_t *format, const struct tm *timeptr, locale_t loc) -{ - char *dst, *dstp, *sformat; - size_t n, sflen; - int sverrno; - - sformat = dst = NULL; - - /* - * Convert the supplied format string to a multibyte representation - * for strftime(), which only handles single-byte characters. - */ - sflen = wcstombs_l(NULL, format, 0, loc); - if (sflen == (size_t)-1) - goto error; - if ((sformat = malloc(sflen + 1)) == NULL) - goto error; - wcstombs_l(sformat, format, sflen + 1, loc); - - /* - * Allocate memory for longest multibyte sequence that will fit - * into the caller's buffer and call strftime() to fill it. - * Then, copy and convert the result back into wide characters in - * the caller's buffer. - */ - if (SIZE_T_MAX / MB_CUR_MAX_L(loc) <= maxsize) { - /* maxsize is preposterously large - avoid int. overflow. */ - errno = EINVAL; - goto error; - } - dst = malloc(maxsize * MB_CUR_MAX_L(loc)); - if (dst == NULL) - goto error; - if (strftime_l(dst, maxsize, sformat, timeptr, loc) == 0) - goto error; - dstp = dst; - n = mbstowcs_l(wcs, dstp, maxsize, loc); - if (n == (size_t)-2 || n == (size_t)-1) - goto error; - - free(sformat); - free(dst); - return n; - -error: - sverrno = errno; - free(sformat); - free(dst); - errno = sverrno; - return 0; -} diff --git a/lib/libc/locale/wcsrtombs.3 b/lib/libc/locale/wcsrtombs.3 deleted file mode 100644 index 1f30eb9ad..000000000 --- a/lib/libc/locale/wcsrtombs.3 +++ /dev/null @@ -1,176 +0,0 @@ -.\" $NetBSD: wcsrtombs.3,v 1.13 2010/12/16 17:42:27 wiz Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd August 8, 2006 -.Dt WCSRTOMBS 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm wcsrtombs -.Nd converts a wide-character string to a multibyte character string \ -(restartable) -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn wcsrtombs "char * restrict s" "const wchar_t ** restrict pwcs" \ -"size_t n" "mbstate_t * restrict ps" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -The -.Fn wcsrtombs -converts the nul-terminated wide-character string indirectly pointed -to by -.Fa pwcs -to the corresponding multibyte character string, -and stores it in the array pointed to by -.Fa s . -The conversion stops due to the following reasons: -.Bl -bullet -.It -The conversion reaches a nul wide character. -In this case, the nul wide character is also converted. -.It -The -.Fn wcsrtombs -has already stored -.Fa n -bytes in the array pointed to by -.Fa s . -.It -The conversion encounters an invalid character. -.El -.Pp -Each character will be converted as if -.Xr wcrtomb 3 -is continuously called, except the internal state of -.Xr wcrtomb 3 -will not be affected. -.Pp -After conversion, -if -.Fa s -is not a null pointer, the pointer object pointed to by -.Fa pwcs -is a null pointer (if the conversion is stopped due to reaching a -nul wide character) or the first byte of the character just after -the last character converted. -.Pp -If -.Fa s -is not a null pointer and the conversion is stopped due to reaching -a nul wide character, -.Fn wcsrtombs -places the state object pointed to by -.Fa ps -to an initial state after the conversion is taken place. -.Pp -The behaviour of -.Fn wcsrtombs -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -These are the special cases: -.Bl -tag -width 012345678901 -.It "s == NULL" -.Fn wcsrtombs -returns the number of bytes to store the whole multibyte character string -corresponding to the wide-character string pointed to by -.Fa pwcs , -not including the terminating nul byte. -In this case, -.Fa n -is ignored. -.It "pwcs == NULL || *pwcs == NULL" -Undefined (may cause the program to crash). -.It "ps == NULL" -.Fn wcsrtombs -uses its own internal state object to keep the conversion state, -instead of -.Fa ps -mentioned in this manual page. -.Pp -Calling any other functions in -.Lb libc -never changes the internal -state of -.Fn wcsrtombs , -which is initialized at startup time of the program. -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -.Fn wcsrtombs -returns: -.Bl -tag -width 012345678901 -.It 0 or positive -Number of bytes stored in the array pointed to by -.Fa s , -except for a nul byte. -There are no cases that the value returned is greater than -.Fa n -(unless -.Fa s -is a null pointer). -If the return value is equal to -.Fa n , -the string pointed to by -.Fa s -will not be nul-terminated. -.It (size_t)-1 -.Fa pwcs -points to a string containing an invalid wide character. -The -.Fn wcsrtombs -also sets -.Va errno -to indicate the error. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn wcsrtombs -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa pwcs -points to a string containing an invalid wide character. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr setlocale 3 , -.Xr wcrtomb 3 , -.Xr wcstombs 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn wcsrtombs -function conforms to -.St -ansiC . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/wcstod.3 b/lib/libc/locale/wcstod.3 deleted file mode 100644 index 965527faf..000000000 --- a/lib/libc/locale/wcstod.3 +++ /dev/null @@ -1,78 +0,0 @@ -.\" $NetBSD: wcstod.3,v 1.5 2007/05/21 15:29:51 tnozaki Exp $ -.\" -.\" Copyright (c) 2002, 2003 Tim J. Robbins -.\" 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: wcstod.3,v 1.4 2003/05/22 13:02:27 ru Exp $ -.\" -.Dd February 22, 2003 -.Dt WCSTOD 3 -.Os -.Sh NAME -.Nm wcstof , -.Nm wcstod , -.Nm wcstold -.Nd convert string to -.Vt float , double , -or -.Vt "long double" -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wchar.h -.Ft float -.Fn wcstof "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" -.Ft "long double" -.Fn wcstold "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" -.Ft double -.Fn wcstod "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" -.Sh DESCRIPTION -The -.Fn wcstof , -.Fn wcstod , -and -.Fn wcstold -functions are the wide-character versions of the -.Fn strtof , -.Fn strtod , -and -.Fn strtold -functions. -Refer to -.Xr strtod 3 -for details. -.Sh SEE ALSO -.Xr strtod 3 , -.Xr wcstol 3 -.Sh STANDARDS -The -.Fn wcstod -function conforms to -.St -isoC-amd1 . -The -.Fn wcstof -and -.Fn wcstold -functions conform to -.St -isoC-99 . diff --git a/lib/libc/locale/wcstod.c b/lib/libc/locale/wcstod.c deleted file mode 100644 index 94cfd001c..000000000 --- a/lib/libc/locale/wcstod.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: wcstod.c,v 1.15 2013/04/18 22:23:17 joerg Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstod.c,v 1.15 2013/04/18 22:23:17 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include - -__weak_alias(wcstod,_wcstod) - -#define _FUNCNAME wcstod -#define _RETURN_TYPE double -#define _STRTOD_FUNC strtod_l - -#include "_wcstod.h" diff --git a/lib/libc/locale/wcstof.c b/lib/libc/locale/wcstof.c deleted file mode 100644 index 9052cd3d3..000000000 --- a/lib/libc/locale/wcstof.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: wcstof.c,v 1.4 2013/04/18 22:23:18 joerg Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstof.c,v 1.4 2013/04/18 22:23:18 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include - -__weak_alias(wcstof,_wcstof) - -#define _FUNCNAME wcstof -#define _RETURN_TYPE float -#define _STRTOD_FUNC strtof_l - -#include "_wcstod.h" diff --git a/lib/libc/locale/wcstoimax.c b/lib/libc/locale/wcstoimax.c deleted file mode 100644 index 7b5ea95aa..000000000 --- a/lib/libc/locale/wcstoimax.c +++ /dev/null @@ -1,49 +0,0 @@ -/* $NetBSD: wcstoimax.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstoimax.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include - -#include "__wctoint.h" - -#define _FUNCNAME wcstoimax -#define __INT intmax_t -#define __INT_MIN INTMAX_MIN -#define __INT_MAX INTMAX_MAX - -#include "_wcstol.h" diff --git a/lib/libc/locale/wcstol.3 b/lib/libc/locale/wcstol.3 deleted file mode 100644 index 549928592..000000000 --- a/lib/libc/locale/wcstol.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" $NetBSD: wcstol.3,v 1.3 2010/12/16 17:42:27 wiz Exp $ -.\" -.\" Copyright (c) 2002 Tim J. Robbins -.\" 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: src/lib/libc/locale/wcstol.3,v 1.4 2002/11/29 17:35:09 ru Exp $ -.\" -.Dd September 7, 2002 -.Dt WCSTOL 3 -.Os -.Sh NAME -.Nm wcstol , wcstoul , -.Nm wcstoll , wcstoull , -.Nm wcstoimax , wcstoumax -.Nd "convert a wide-character string value to a" -.Vt long , -.Vt "unsigned long" , -.Vt "long long" , -.Vt "unsigned long long" , -.Vt intmax_t -or -.Vt uintmax_t -integer -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wchar.h -.Ft long -.Fn wcstol "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" "int base" -.Ft "unsigned long" -.Fn wcstoul "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" "int base" -.Ft "long long" -.Fn wcstoll "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" "int base" -.Ft "unsigned long long" -.Fn wcstoull "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" "int base" -.In inttypes.h -.Ft intmax_t -.Fn wcstoimax "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" "int base" -.Ft uintmax_t -.Fn wcstoumax "const wchar_t * restrict nptr" "wchar_t ** restrict endptr" "int base" -.Sh DESCRIPTION -The -.Fn wcstol , -.Fn wcstoul , -.Fn wcstoll , -.Fn wcstoull , -.Fn wcstoimax -and -.Fn wcstoumax -functions are wide-character versions of the -.Fn strtol , -.Fn strtoul , -.Fn strtoll , -.Fn strtoull , -.Fn strtoimax -and -.Fn strtoumax -functions, respectively. -Refer to their manual pages (for example -.Xr strtol 3 ) -for details. -.Sh SEE ALSO -.Xr strtol 3 , -.Xr strtoul 3 -.Sh STANDARDS -The -.Fn wcstol , -.Fn wcstoul , -.Fn wcstoll , -.Fn wcstoull , -.Fn wcstoimax -and -.Fn wcstoumax -functions conform to -.St -isoC-99 . diff --git a/lib/libc/locale/wcstol.c b/lib/libc/locale/wcstol.c deleted file mode 100644 index 0bb35b7c0..000000000 --- a/lib/libc/locale/wcstol.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: wcstol.c,v 1.4 2007/03/10 00:12:23 hubertf Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstol.c,v 1.4 2007/03/10 00:12:23 hubertf Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include "__wctoint.h" - -#define _FUNCNAME wcstol -#define __INT long -#define __INT_MIN LONG_MIN -#define __INT_MAX LONG_MAX - -#include "_wcstol.h" diff --git a/lib/libc/locale/wcstold.c b/lib/libc/locale/wcstold.c deleted file mode 100644 index 35e4c9231..000000000 --- a/lib/libc/locale/wcstold.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: wcstold.c,v 1.4 2013/04/18 22:23:18 joerg Exp $ */ - -/*- - * Copyright (c)2006 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstold.c,v 1.4 2013/04/18 22:23:18 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include -#include -#include -#include - -__weak_alias(wcstold,_wcstold) - -#define _FUNCNAME wcstold -#define _RETURN_TYPE long double -#define _STRTOD_FUNC strtold_l - -#include "_wcstod.h" diff --git a/lib/libc/locale/wcstoll.c b/lib/libc/locale/wcstoll.c deleted file mode 100644 index 332d87622..000000000 --- a/lib/libc/locale/wcstoll.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: wcstoll.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstoll.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include "__wctoint.h" - -#define _FUNCNAME wcstoll -#define __INT /* LONGLONG */ long long int -#define __INT_MIN LLONG_MIN -#define __INT_MAX LLONG_MAX - -#include "_wcstol.h" diff --git a/lib/libc/locale/wcstombs.3 b/lib/libc/locale/wcstombs.3 deleted file mode 100644 index 0a93b8354..000000000 --- a/lib/libc/locale/wcstombs.3 +++ /dev/null @@ -1,133 +0,0 @@ -.\" $NetBSD: wcstombs.3,v 1.13 2011/03/16 09:32:12 mbalmer Exp $ -.\" -.\" Copyright (c)2002 Citrus Project, -.\" 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. -.\" -.Dd March 16, 2011 -.Dt WCSTOMBS 3 -.Os -.\" ---------------------------------------------------------------------- -.Sh NAME -.Nm wcstombs -.Nd converts a wide-character string to a multibyte character string -.\" ---------------------------------------------------------------------- -.Sh LIBRARY -.Lb libc -.\" ---------------------------------------------------------------------- -.Sh SYNOPSIS -.In stdlib.h -.Ft size_t -.Fn wcstombs "char * restrict s" "const wchar_t * restrict pwcs" "size_t n" -.\" ---------------------------------------------------------------------- -.Sh DESCRIPTION -.Fn wcstombs -converts the nul-terminated wide-character string pointed to by -.Fa pwcs -to the corresponding multibyte character string, -and stores it in the array pointed to by -.Fa s . -This function may modify the first at most -.Fa n -bytes of the array pointed to by -.Fa s . -Each character will be converted as if -.Xr wctomb 3 -is continuously called, except the internal state of -.Xr wctomb 3 -will not be affected. -.Pp -For state-dependent encoding, the -.Fn wcstombs -implies the result multibyte character string pointed to by -.Fa s -always to begin with an initial state. -.Pp -The behaviour of -.Fn wcstombs -is affected by the -.Dv LC_CTYPE -category of the current locale. -.Pp -These are the special cases: -.Bl -tag -width 012345678901 -.It s == NULL -The -.Fn wcstombs -returns the number of bytes to store the whole multibyte character string -corresponding to the wide-character string pointed to by -.Fa pwcs . -In this case, -.Fa n -is ignored. -.It pwcs == NULL -Undefined (may cause the program to crash). -.El -.\" ---------------------------------------------------------------------- -.Sh RETURN VALUES -.Fn wcstombs -returns: -.Bl -tag -width 012345678901 -.It 0 or positive -Number of bytes stored in the array pointed to by -.Fa s . -There are no cases that the value returned is greater than -.Fa n -(unless -.Fa s -is a null pointer). -If the return value is equal to -.Fa n , -the string pointed to by -.Fa s -will not be nul-terminated. -.It (size_t)-1 -.Fa pwcs -points to a string containing an invalid wide character. -.Fn wcstombs -also sets -.Va errno -to indicate the error. -.El -.\" ---------------------------------------------------------------------- -.Sh ERRORS -.Fn wcstombs -may cause an error in the following case: -.Bl -tag -width Er -.It Bq Er EILSEQ -.Fa pwcs -points to a string containing an invalid wide character. -.El -.\" ---------------------------------------------------------------------- -.Sh SEE ALSO -.Xr mbstowcs 3 , -.Xr setlocale 3 , -.Xr wctomb 3 -.\" ---------------------------------------------------------------------- -.Sh STANDARDS -The -.Fn wcstombs -function conforms to -.St -ansiC . -The restrict qualifier is added at -.St -isoC-99 . diff --git a/lib/libc/locale/wcstoul.c b/lib/libc/locale/wcstoul.c deleted file mode 100644 index a29d610b7..000000000 --- a/lib/libc/locale/wcstoul.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: wcstoul.c,v 1.4 2007/03/10 00:12:23 hubertf Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstoul.c,v 1.4 2007/03/10 00:12:23 hubertf Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include "__wctoint.h" - -#define _FUNCNAME wcstoul -#define __UINT unsigned long -#define __UINT_MAX ULONG_MAX - -#include "_wcstoul.h" diff --git a/lib/libc/locale/wcstoull.c b/lib/libc/locale/wcstoull.c deleted file mode 100644 index 6ef74023f..000000000 --- a/lib/libc/locale/wcstoull.c +++ /dev/null @@ -1,47 +0,0 @@ -/* $NetBSD: wcstoull.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstoull.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include - -#include "__wctoint.h" - -#define _FUNCNAME wcstoull -#define __UINT /* LONGLONG */ unsigned long long int -#define __UINT_MAX ULLONG_MAX - -#include "_wcstoul.h" diff --git a/lib/libc/locale/wcstoumax.c b/lib/libc/locale/wcstoumax.c deleted file mode 100644 index fc11ec515..000000000 --- a/lib/libc/locale/wcstoumax.c +++ /dev/null @@ -1,48 +0,0 @@ -/* $NetBSD: wcstoumax.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcstoumax.c,v 1.3 2007/03/10 00:12:23 hubertf Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include -#include -#include -#include - -#include "__wctoint.h" - -#define _FUNCNAME wcstoumax -#define __UINT uintmax_t -#define __UINT_MAX UINTMAX_MAX - -#include "_wcstoul.h" diff --git a/lib/libc/locale/wcsxfrm.3 b/lib/libc/locale/wcsxfrm.3 deleted file mode 100644 index 96d07cc6a..000000000 --- a/lib/libc/locale/wcsxfrm.3 +++ /dev/null @@ -1,107 +0,0 @@ -.\" $NetBSD: wcsxfrm.3,v 1.4 2010/12/16 17:42:27 wiz Exp $ -.\" -.\" Copyright (c) 1990, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Chris Torek and the American National Standards Committee X3, -.\" on Information Processing Systems. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)strxfrm.3 8.1 (Berkeley) 6/4/93 -.\" FreeBSD: src/lib/libc/string/strxfrm.3,v 1.16 2002/09/06 11:24:06 tjr Exp -.\" FreeBSD: /repoman/r/ncvs/src/lib/libc/string/wcsxfrm.3,v 1.2 2002/12/09 14:04:05 ru Exp -.\" -.Dd October 13, 2006 -.Dt WCSXFRM 3 -.Os -.Sh NAME -.Nm wcsxfrm -.Nd transform a wide string under locale -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In wchar.h -.Ft size_t -.Fn wcsxfrm "wchar_t * restrict dst" "const wchar_t * restrict src" "size_t n" -.Sh DESCRIPTION -The -.Fn wcsxfrm -function transforms a nul-terminated wide-character string pointed to by -.Fa src -according to the current locale collation order then copies the -transformed string into -.Fa dst . -No more than -.Fa n -wide characters are copied into -.Fa dst , -including the terminating nul character added. -If -.Fa n -is set to 0 -(it helps to determine an actual size needed for transformation), -.Fa dst -is permitted to be a null pointer. -.Pp -Comparing two strings using -.Fn wcscmp -after -.Fn wcsxfrm -is equivalent to comparing two original strings with -.Fn wcscoll . -.Sh RETURN VALUES -Upon successful completion, -.Fn wcsxfrm -returns the length of the transformed string not including -the terminating nul character. -If this value is -.Fa n -or more, the contents of -.Fa dst -are indeterminate. -.Sh SEE ALSO -.Xr setlocale 3 , -.Xr strxfrm 3 , -.Xr wcscmp 3 , -.Xr wcscoll 3 -.Sh STANDARDS -The -.Fn wcsxfrm -function conforms to -.St -isoC-99 . -.Sh BUGS -The current implementation of -.Fn wcsxfrm -function disregards -.Dv LC_COLLATE -locales, and falls back to using the -.Fn wcsncpy -function. diff --git a/lib/libc/locale/wcsxfrm.c b/lib/libc/locale/wcsxfrm.c deleted file mode 100644 index 2fc706c27..000000000 --- a/lib/libc/locale/wcsxfrm.c +++ /dev/null @@ -1,71 +0,0 @@ -/* $NetBSD: wcsxfrm.c,v 1.5 2013/05/17 12:55:57 joerg Exp $ */ - -/*- - * Copyright (c)2003 Citrus Project, - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: wcsxfrm.c,v 1.5 2013/05/17 12:55:57 joerg Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include "setlocale_local.h" - -/* - * Compare strings with using collating information. - */ -size_t -wcsxfrm_l(wchar_t *s1, const wchar_t *s2, size_t n, locale_t loc) -{ - size_t len; - - /* XXX: LC_COLLATE should be implemented. */ - /* LINTED */(void)loc; - - len = wcslen(s2); - if (len - -# MD4/MD5 sources -.PATH: ${ARCHDIR}/md ${.CURDIR}/md - -SRCS+= md4c.c md5c.c md4hl.c md5hl.c - -MAN+= md4.3 md5.3 - -MLINKS+=md4.3 MD4Init.3 md4.3 MD4Update.3 md4.3 MD4Final.3 -MLINKS+=md4.3 MD4End.3 md4.3 MD4File.3 md4.3 MD4Data.3 -MLINKS+=md5.3 MD5Init.3 md5.3 MD5Update.3 md5.3 MD5Final.3 -MLINKS+=md5.3 MD5End.3 md5.3 MD5File.3 md5.3 MD5Data.3 - -CLEANFILES+= md[45]hl.c md[45].3 - -.if ${MKMAN} != "no" -md4.3: mdX.3 - sed -e 's/mdX/md4/g' -e 's/MDX/MD4/g' $> > $@ - cat ${>:H}/md4.copyright >> $@ - -md5.3: mdX.3 - sed -e 's/mdX/md5/g' -e 's/MDX/MD5/g' $> > $@ - cat ${>:H}/md5.copyright >> $@ -.endif diff --git a/lib/libc/md/md2hl.c b/lib/libc/md/md2hl.c deleted file mode 100644 index 8d26581ab..000000000 --- a/lib/libc/md/md2hl.c +++ /dev/null @@ -1,24 +0,0 @@ -/* $NetBSD: md2hl.c,v 1.5 2005/06/12 05:34:34 lukem Exp $ */ - -/* - * Written by Jason R. Thorpe , April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: md2hl.c,v 1.5 2005/06/12 05:34:34 lukem Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define MDALGORITHM MD2 - -#include "namespace.h" -#include - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#if !HAVE_MD2_H -#include "mdXhl.c" -#endif diff --git a/lib/libc/md/md4.copyright b/lib/libc/md/md4.copyright deleted file mode 100644 index 5a395f0c2..000000000 --- a/lib/libc/md/md4.copyright +++ /dev/null @@ -1,21 +0,0 @@ -.\" $NetBSD: md4.copyright,v 1.1 1997/01/30 01:01:40 thorpej Exp $ -.\" from FreeBSD Id: md4.copyright,v 1.2 1996/10/09 21:00:43 wollman Exp -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. -.Pp -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD4 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD4 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. -.Pp -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. -.Pp -These notices must be retained in any copies of any part of this -documentation and/or software. diff --git a/lib/libc/md/md4hl.c b/lib/libc/md/md4hl.c deleted file mode 100644 index 4517bf10a..000000000 --- a/lib/libc/md/md4hl.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: md4hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $ */ - -/* - * Written by Jason R. Thorpe , April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: md4hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define MDALGORITHM MD4 -#define MDINCLUDE - -#include "mdXhl.c" diff --git a/lib/libc/md/md5.copyright b/lib/libc/md/md5.copyright deleted file mode 100644 index b7e1beed9..000000000 --- a/lib/libc/md/md5.copyright +++ /dev/null @@ -1,22 +0,0 @@ -.\" $NetBSD: md5.copyright,v 1.1 1997/01/30 01:01:41 thorpej Exp $ -.\" from FreeBSD Id: md5.copyright,v 1.2 1996/10/09 21:00:46 wollman Exp -Copyright (C) 1991-2, RSA Data Security, Inc. Created 1991. All -rights reserved. -.Pp -License to copy and use this software is granted provided that it -is identified as the "RSA Data Security, Inc. MD5 Message-Digest -Algorithm" in all material mentioning or referencing this software -or this function. -.Pp -License is also granted to make and use derivative works provided -that such works are identified as "derived from the RSA Data -Security, Inc. MD5 Message-Digest Algorithm" in all material -mentioning or referencing the derived work. -.Pp -RSA Data Security, Inc. makes no representations concerning either -the merchantability of this software or the suitability of this -software for any particular purpose. It is provided "as is" -without express or implied warranty of any kind. -.Pp -These notices must be retained in any copies of any part of this -documentation and/or software. diff --git a/lib/libc/md/md5hl.c b/lib/libc/md/md5hl.c deleted file mode 100644 index 7604efa05..000000000 --- a/lib/libc/md/md5hl.c +++ /dev/null @@ -1,16 +0,0 @@ -/* $NetBSD: md5hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $ */ - -/* - * Written by Jason R. Thorpe , April 29, 1997. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: md5hl.c,v 1.7 2005/09/26 03:01:41 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define MDALGORITHM MD5 -#define MDINCLUDE - -#include "mdXhl.c" diff --git a/lib/libc/md/mdX.3 b/lib/libc/md/mdX.3 deleted file mode 100644 index 39934b515..000000000 --- a/lib/libc/md/mdX.3 +++ /dev/null @@ -1,143 +0,0 @@ -.\" $NetBSD: mdX.3,v 1.10 2003/06/13 01:28:41 lukem Exp $ -.\" -.\" ---------------------------------------------------------------------------- -.\" "THE BEER-WARE LICENSE" (Revision 42): -.\" 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 -.\" ---------------------------------------------------------------------------- -.\" -.\" from FreeBSD Id: mdX.3,v 1.7 1996/10/22 16:28:56 phk Exp -.\" -.Dd June 13, 2003 -.Dt MDX 3 -.Os -.Sh NAME -.Nm MDXInit , -.Nm MDXUpdate , -.Nm MDXFinal , -.Nm MDXEnd , -.Nm MDXFile , -.Nm MDXData -.Nd calculate the RSA Data Security, Inc., -.Dq MDX -message digest -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In mdX.h -.Ft void -.Fn MDXInit "MDX_CTX *context" -.Ft void -.Fn MDXUpdate "MDX_CTX *context" "const unsigned char *data" "unsigned int len" -.Ft void -.Fn MDXFinal "unsigned char digest[16]" "MDX_CTX *context" -.Ft "char *" -.Fn MDXEnd "MDX_CTX *context" "char *buf" -.Ft "char *" -.Fn MDXFile "const char *filename" "char *buf" -.Ft "char *" -.Fn MDXData "const unsigned char *data" "unsigned int len" "char *buf" -.Sh DESCRIPTION -The MDX functions calculate a 128-bit cryptographic checksum (digest) -for any number of input bytes. -A cryptographic checksum is a one-way -hash-function, that is, you cannot find (except by exhaustive search) -the input corresponding to a particular output. -This net result is -a ``fingerprint'' of the input-data, which doesn't disclose the actual -input. -.Pp -MD2 is the slowest, MD4 is the fastest and MD5 is somewhere in the middle. -MD2 can only be used for Privacy-Enhanced Mail. -MD4 has been criticized for being too weak, so MD5 was developed in -response as ``MD4 with safety-belts''. -When in doubt, use MD5. -.Pp -The -.Fn MDXInit , -.Fn MDXUpdate , -and -.Fn MDXFinal -functions are the core functions. -Allocate an MDX_CTX, initialize it with -.Fn MDXInit , -run over the data with -.Fn MDXUpdate , -and finally extract the result using -.Fn MDXFinal . -.Pp -.Fn MDXEnd -is a wrapper for -.Fn MDXFinal -which converts the return value to a 33-character -(including the terminating '\e0') -.Tn ASCII -string which represents the 128 bits in hexadecimal. -.Pp -.Fn MDXFile -calculates the digest of a file, and uses -.Fn MDXEnd -to return the result. -If the file cannot be opened, a null pointer is returned. -.Fn MDXData -calculates the digest of a chunk of data in memory, and uses -.Fn MDXEnd -to return the result. -.Pp -When using -.Fn MDXEnd , -.Fn MDXFile , -or -.Fn MDXData , -the -.Ar buf -argument can be a null pointer, in which case the returned string -is allocated with -.Xr malloc 3 -and subsequently must be explicitly deallocated using -.Xr free 3 -after use. -If the -.Ar buf -argument is non-null it must point to at least 33 characters of buffer space. -.Sh SEE ALSO -.Xr md2 3 , -.Xr md4 3 , -.Xr md5 3 -.Rs -.%A B. Kaliski -.%T The MD2 Message-Digest Algorithm -.%O RFC 1319 -.Re -.Rs -.%A R. Rivest -.%T The MD4 Message-Digest Algorithm -.%O RFC 1186 -.Re -.Rs -.%A R. Rivest -.%T The MD5 Message-Digest Algorithm -.%O RFC 1321 -.Re -.Rs -.%A RSA Laboratories -.%T Frequently Asked Questions About today's Cryptography -.Re -.Sh HISTORY -These functions appeared in -.Nx 1.3 . -.Sh AUTHORS -The original MDX routines were developed by -.Tn RSA -Data Security, Inc., and published in the above references. -This code is derived directly from these implementations by Poul-Henning Kamp -.Aq Li phk@login.dkuug.dk -.Pp -Phk ristede runen. -.Sh BUGS -No method is known to exist which finds two files having the same hash value, -nor to find a file with a specific hash value. -There is on the other hand no guarantee that such a method doesn't exist. -.Sh COPYRIGHT diff --git a/lib/libc/md/mdXhl.c b/lib/libc/md/mdXhl.c deleted file mode 100644 index 0e3225e42..000000000 --- a/lib/libc/md/mdXhl.c +++ /dev/null @@ -1,109 +0,0 @@ -/* $NetBSD: mdXhl.c,v 1.13 2014/09/24 13:18:52 christos Exp $ */ - -/* - * ---------------------------------------------------------------------------- - * "THE BEER-WARE LICENSE" (Revision 42): - * 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 - * ---------------------------------------------------------------------------- - * - * from FreeBSD Id: mdXhl.c,v 1.8 1996/10/25 06:48:12 bde Exp - */ - -/* - * Modified April 29, 1997 by Jason R. Thorpe - */ - -#if HAVE_NBTOOL_CONFIG_H -#include "nbtool_config.h" -#endif - -#define CONCAT(x,y) __CONCAT(x,y) -#define MDNAME(x) CONCAT(MDALGORITHM,x) - -#if !defined(_KERNEL) && defined(__weak_alias) && !defined(HAVE_NBTOOL_CONFIG_H) -#define WA(a,b) __weak_alias(a,b) -WA(MDNAME(End),CONCAT(_,MDNAME(End))) -WA(MDNAME(File),CONCAT(_,MDNAME(File))) -WA(MDNAME(Data),CONCAT(_,MDNAME(Data))) -#undef WA -#endif - -#include "namespace.h" - -#include - -#include MDINCLUDE -#include -#include -#include -#include -#include -#include - -char * -MDNAME(End)(MDNAME(_CTX) *ctx, char *buf) -{ - int i; - unsigned char digest[16]; - static const char hex[]="0123456789abcdef"; - - _DIAGASSERT(ctx != 0); - - if (buf == NULL) - buf = malloc(33); - if (buf == NULL) - return (NULL); - - MDNAME(Final)(digest, ctx); - - for (i = 0; i < 16; i++) { - buf[i+i] = hex[(u_int32_t)digest[i] >> 4]; - buf[i+i+1] = hex[digest[i] & 0x0f]; - } - - buf[i+i] = '\0'; - return (buf); -} - -char * -MDNAME(File)(const char *filename, char *buf) -{ - unsigned char buffer[BUFSIZ]; - MDNAME(_CTX) ctx; - int f, j; - ssize_t i; - - _DIAGASSERT(filename != 0); - /* buf may be NULL */ - - MDNAME(Init)(&ctx); - f = open(filename, O_RDONLY | O_CLOEXEC, 0666); - if (f < 0) - return NULL; - - while ((i = read(f, buffer, sizeof(buffer))) > 0) - MDNAME(Update)(&ctx, buffer, (unsigned int)i); - - j = errno; - close(f); - errno = j; - - if (i < 0) - return NULL; - - return (MDNAME(End)(&ctx, buf)); -} - -char * -MDNAME(Data)(const unsigned char *data, unsigned int len, char *buf) -{ - MDNAME(_CTX) ctx; - - _DIAGASSERT(data != 0); - - MDNAME(Init)(&ctx); - MDNAME(Update)(&ctx, data, len); - return (MDNAME(End)(&ctx, buf)); -} diff --git a/lib/libc/misc/Makefile.inc b/lib/libc/misc/Makefile.inc deleted file mode 100644 index 08a246c2c..000000000 --- a/lib/libc/misc/Makefile.inc +++ /dev/null @@ -1,10 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.2 2013/01/29 19:14:02 matt Exp $ -# @(#)Makefile.inc 8.3 (Berkeley) 10/24/94 - -.PATH: ${ARCHDIR}/misc ${.CURDIR}/misc - -# constructor -SRCS+= initfini.c - -# for -fstack-protector -SRCS+= stack_protector.c diff --git a/lib/libc/misc/initfini.c b/lib/libc/misc/initfini.c deleted file mode 100644 index 8eef018ee..000000000 --- a/lib/libc/misc/initfini.c +++ /dev/null @@ -1,119 +0,0 @@ -/* $NetBSD: initfini.c,v 1.11 2013/08/19 22:14:37 matt Exp $ */ - -/*- - * Copyright (c) 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Andrew Doran. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__RCSID("$NetBSD: initfini.c,v 1.11 2013/08/19 22:14:37 matt Exp $"); - -#ifdef _LIBC -#include "namespace.h" -#endif - -#include -#include -#include -#include - -void _libc_init(void) __attribute__((__constructor__, __used__)); - -void __guard_setup(void); -void __libc_thr_init(void); -void __libc_atomic_init(void); -void __libc_atexit_init(void); -void __libc_env_init(void); - -#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) -__dso_hidden void __libc_static_tls_setup(void); -#endif - -#ifdef __weak_alias -__weak_alias(_dlauxinfo,___dlauxinfo) -static void *__libc_dlauxinfo; - -void *___dlauxinfo(void) __pure; - -void * -___dlauxinfo(void) -{ - return __libc_dlauxinfo; -} -#endif - -static bool libc_initialised; - -void _libc_init(void); - -/* - * Declare as common symbol to allow new libc with older binaries to - * not trigger an undefined reference. - */ -struct ps_strings *__ps_strings; - -/* - * _libc_init is called twice. The first time explicitly by crt0.o - * (for newer versions) and the second time as indirectly via _init(). - */ -void __section(".text.startup") -_libc_init(void) -{ - - if (libc_initialised) - return; - - libc_initialised = 1; - - if (__ps_strings != NULL) - __libc_dlauxinfo = __ps_strings->ps_argvstr + - __ps_strings->ps_nargvstr + __ps_strings->ps_nenvstr + 2; - - /* For -fstack-protector */ - __guard_setup(); - -#if defined(__minix) && defined(_REENTRANT) - /* Atomic operations */ - __libc_atomic_init(); -#endif /* defined(__minix) && defined(_REENTRANT) */ - -#if defined(__HAVE_TLS_VARIANT_I) || defined(__HAVE_TLS_VARIANT_II) - /* Initialize TLS for statically linked programs. */ - __libc_static_tls_setup(); -#endif - -#if defined(__minix) && defined(_REENTRANT) - /* Threads */ - __libc_thr_init(); -#endif /* defined(__minix) && defined(_REENTRANT) */ - - /* Initialize the atexit mutexes */ - __libc_atexit_init(); - - /* Initialize environment memory RB tree. */ - __libc_env_init(); -} diff --git a/lib/libc/misc/stack_protector.c b/lib/libc/misc/stack_protector.c deleted file mode 100644 index 34cf9cf6e..000000000 --- a/lib/libc/misc/stack_protector.c +++ /dev/null @@ -1,131 +0,0 @@ -/* $NetBSD: stack_protector.c,v 1.9 2013/08/19 22:14:37 matt Exp $ */ -/* $OpenBSD: stack_protector.c,v 1.10 2006/03/31 05:34:44 deraadt Exp $ */ - -/* - * Copyright (c) 2002 Hiroaki Etoh, Federico G. Schwindt, and Miodrag Vallat. - * 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 AUTHORS ``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 AUTHORS 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 -__RCSID("$NetBSD: stack_protector.c,v 1.9 2013/08/19 22:14:37 matt Exp $"); - -#ifdef _LIBC -#include "namespace.h" -#endif -#include -#include -#include -#include -#include -#include -#ifdef _LIBC -#include -#include "extern.h" -#else -#define __sysctl sysctl -void xprintf(const char *fmt, ...); -#include -#endif - -long __stack_chk_guard[8] = {0, 0, 0, 0, 0, 0, 0, 0}; -static void __fail(const char *) __attribute__((__noreturn__)); -__dead void __stack_chk_fail_local(void); -void __guard_setup(void); - -void __section(".text.startup") -__guard_setup(void) -{ -#if !defined(__minix) - static const int mib[2] = { CTL_KERN, KERN_ARND }; - size_t len; -#endif /* !defined(__minix) */ - - if (__stack_chk_guard[0] != 0) - return; - -#if !defined(__minix) - len = sizeof(__stack_chk_guard); - if (__sysctl(mib, (u_int)__arraycount(mib), __stack_chk_guard, &len, - NULL, 0) == -1 || len != sizeof(__stack_chk_guard)) { -#endif /* !defined(__minix) */ - /* If sysctl was unsuccessful, use the "terminator canary". */ - ((unsigned char *)(void *)__stack_chk_guard)[0] = 0; - ((unsigned char *)(void *)__stack_chk_guard)[1] = 0; - ((unsigned char *)(void *)__stack_chk_guard)[2] = '\n'; - ((unsigned char *)(void *)__stack_chk_guard)[3] = 255; -#if !defined(__minix) - } -#endif /* !defined(__minix) */ -} - -/*ARGSUSED*/ -static void -__fail(const char *msg) -{ -#ifdef _LIBC - struct syslog_data sdata = SYSLOG_DATA_INIT; -/* MINIX: #endif */ - struct sigaction sa; - sigset_t mask; - - /* Immediately block all signal handlers from running code */ - (void)sigfillset(&mask); - (void)sigdelset(&mask, SIGABRT); - (void)sigprocmask(SIG_BLOCK, &mask, NULL); - -/* MINIX: #ifdef _LIBC */ - /* This may fail on a chroot jail... */ - syslog_ss(LOG_CRIT, &sdata, "%s", msg); -#else - xprintf("%s: %s\n", getprogname(), msg); -#endif - -#if defined(__minix) && defined(_LIBC) - (void)memset(&sa, 0, sizeof(sa)); - (void)sigemptyset(&sa.sa_mask); - sa.sa_flags = 0; - sa.sa_handler = SIG_DFL; - (void)sigaction(SIGABRT, &sa, NULL); - (void)raise(SIGABRT); -#endif /* defined(__minix) && defined(_LIBC) */ - _exit(127); -} - -void -__stack_chk_fail(void) -{ - __fail("stack overflow detected; terminated"); -} - -void -__chk_fail(void) -{ - __fail("buffer overflow detected; terminated"); -} - -void -__stack_chk_fail_local(void) -{ - __stack_chk_fail(); -} diff --git a/lib/libc/nameser/Makefile.inc b/lib/libc/nameser/Makefile.inc deleted file mode 100644 index 317a1c3a5..000000000 --- a/lib/libc/nameser/Makefile.inc +++ /dev/null @@ -1,7 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.1 2004/05/20 20:02:26 christos Exp $ - -# net sources -.PATH: ${.CURDIR}/nameser - -SRCS+= ns_name.c ns_netint.c ns_parse.c ns_print.c \ - ns_samedomain.c ns_ttl.c diff --git a/lib/libc/nameser/ns_name.c b/lib/libc/nameser/ns_name.c deleted file mode 100644 index 3a48c21df..000000000 --- a/lib/libc/nameser/ns_name.c +++ /dev/null @@ -1,1175 +0,0 @@ -/* $NetBSD: ns_name.c,v 1.11 2014/03/07 01:07:01 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#ifndef lint -#ifdef notdef -static const char rcsid[] = "Id: ns_name.c,v 1.11 2009/01/23 19:59:16 each Exp"; -#else -__RCSID("$NetBSD: ns_name.c,v 1.11 2014/03/07 01:07:01 christos Exp $"); -#endif -#endif - -#include "port_before.h" - -#include - -#include -#include - -#include -#include -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) ((int)strlen(sprintf/**/x)) -#else -# define SPRINTF(x) (sprintf x) -#endif - -#define NS_TYPE_ELT 0x40 /*%< EDNS0 extended label type */ -#define DNS_LABELTYPE_BITSTRING 0x41 - -/* Data. */ - -static const char digits[] = "0123456789"; - -static const char digitvalue[256] = { - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*16*/ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*32*/ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*48*/ - 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, -1, -1, -1, -1, -1, -1, /*64*/ - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*80*/ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*96*/ - -1, 10, 11, 12, 13, 14, 15, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*112*/ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*128*/ - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /*256*/ -}; - -/* Forward. */ - -static int special(int); -static int printable(int); -static int dn_find(const u_char *, const u_char *, - const u_char * const *, - const u_char * const *); -static int encode_bitsring(const char **, const char *, - unsigned char **, unsigned char **, - unsigned const char *); -static int labellen(const u_char *); -static int decode_bitstring(const unsigned char **, - char *, const char *); - -/* Public. */ - -/*% - * Convert an encoded domain name to printable ascii as per RFC1035. - - * return: - *\li Number of bytes written to buffer, or -1 (with errno set) - * - * notes: - *\li The root is returned as "." - *\li All other domains are returned in non absolute form - */ -int -ns_name_ntop(const u_char *src, char *dst, size_t dstsiz) -{ - const u_char *cp; - char *dn, *eom; - u_char c; - u_int n; - int l; - - cp = src; - dn = dst; - eom = dst + dstsiz; - - while ((n = *cp++) != 0) { - if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) { - /* Some kind of compression pointer. */ - errno = EMSGSIZE; - return (-1); - } - if (dn != dst) { - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '.'; - } - if ((l = labellen(cp - 1)) < 0) { - errno = EMSGSIZE; /*%< XXX */ - return (-1); - } - if (dn + l >= eom) { - errno = EMSGSIZE; - return (-1); - } - if ((n & NS_CMPRSFLGS) == NS_TYPE_ELT) { - int m; - - if (n != DNS_LABELTYPE_BITSTRING) { - /* XXX: labellen should reject this case */ - errno = EINVAL; - return (-1); - } - if ((m = decode_bitstring(&cp, dn, eom)) < 0) - { - errno = EMSGSIZE; - return (-1); - } - dn += m; - continue; - } - for (; l > 0; l--) { - c = *cp++; - if (special(c)) { - if (dn + 1 >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '\\'; - *dn++ = (char)c; - } else if (!printable(c)) { - if (dn + 3 >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '\\'; - *dn++ = digits[c / 100]; - *dn++ = digits[(c % 100) / 10]; - *dn++ = digits[c % 10]; - } else { - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = (char)c; - } - } - } - if (dn == dst) { - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '.'; - } - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - *dn++ = '\0'; - _DIAGASSERT(__type_fit(int, dn - dst)); - return (int)(dn - dst); -} - -/*% - * Convert a ascii string into an encoded domain name as per RFC1035. - * - * return: - * - *\li -1 if it fails - *\li 1 if string was fully qualified - *\li 0 is string was not fully qualified - * - * notes: - *\li Enforces label and domain length limits. - */ -int -ns_name_pton(const char *src, u_char *dst, size_t dstsiz) { - return (ns_name_pton2(src, dst, dstsiz, NULL)); -} - -/* - * ns_name_pton2(src, dst, dstsiz, *dstlen) - * Convert a ascii string into an encoded domain name as per RFC1035. - * return: - * -1 if it fails - * 1 if string was fully qualified - * 0 is string was not fully qualified - * side effects: - * fills in *dstlen (if non-NULL) - * notes: - * Enforces label and domain length limits. - */ -int -ns_name_pton2(const char *src, u_char *dst, size_t dstsiz, size_t *dstlen) { - u_char *label, *bp, *eom; - int c, n, escaped, e = 0; - char *cp; - - escaped = 0; - bp = dst; - eom = dst + dstsiz; - label = bp++; - - while ((c = *src++) != 0) { - if (escaped) { - if (c == '[') { /*%< start a bit string label */ - if ((cp = strchr(src, ']')) == NULL) { - errno = EINVAL; /*%< ??? */ - return (-1); - } - if ((e = encode_bitsring(&src, cp + 2, - &label, &bp, eom)) - != 0) { - errno = e; - return (-1); - } - escaped = 0; - label = bp++; - if ((c = *src++) == 0) - goto done; - else if (c != '.') { - errno = EINVAL; - return (-1); - } - continue; - } - else if ((cp = strchr(digits, c)) != NULL) { - n = (int)(cp - digits) * 100; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - errno = EMSGSIZE; - return (-1); - } - n += (int)(cp - digits) * 10; - if ((c = *src++) == 0 || - (cp = strchr(digits, c)) == NULL) { - errno = EMSGSIZE; - return (-1); - } - n += (int)(cp - digits); - if (n > 255) { - errno = EMSGSIZE; - return (-1); - } - c = n; - } - escaped = 0; - } else if (c == '\\') { - escaped = 1; - continue; - } else if (c == '.') { - c = (int)(bp - label - 1); - if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */ - errno = EMSGSIZE; - return (-1); - } - if (label >= eom) { - errno = EMSGSIZE; - return (-1); - } - *label = c; - /* Fully qualified ? */ - if (*src == '\0') { - if (c != 0) { - if (bp >= eom) { - errno = EMSGSIZE; - return (-1); - } - *bp++ = '\0'; - } - if ((bp - dst) > MAXCDNAME) { - errno = EMSGSIZE; - return (-1); - } - if (dstlen != NULL) - *dstlen = (bp - dst); - return (1); - } - if (c == 0 || *src == '.') { - errno = EMSGSIZE; - return (-1); - } - label = bp++; - continue; - } - if (bp >= eom) { - errno = EMSGSIZE; - return (-1); - } - *bp++ = (u_char)c; - } - c = (int)(bp - label - 1); - if ((c & NS_CMPRSFLGS) != 0) { /*%< Label too big. */ - errno = EMSGSIZE; - return (-1); - } - done: - if (label >= eom) { - errno = EMSGSIZE; - return (-1); - } - *label = c; - if (c != 0) { - if (bp >= eom) { - errno = EMSGSIZE; - return (-1); - } - *bp++ = 0; - } - if ((bp - dst) > MAXCDNAME) { /*%< src too big */ - errno = EMSGSIZE; - return (-1); - } - if (dstlen != NULL) - *dstlen = (bp - dst); - return (0); -} - -/*% - * Convert a network strings labels into all lowercase. - * - * return: - *\li Number of bytes written to buffer, or -1 (with errno set) - * - * notes: - *\li Enforces label and domain length limits. - */ - -int -ns_name_ntol(const u_char *src, u_char *dst, size_t dstsiz) -{ - const u_char *cp; - u_char *dn, *eom; - u_char c; - u_int n; - int l; - - cp = src; - dn = dst; - eom = dst + dstsiz; - - if (dn >= eom) { - errno = EMSGSIZE; - return (-1); - } - while ((n = *cp++) != 0) { - if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) { - /* Some kind of compression pointer. */ - errno = EMSGSIZE; - return (-1); - } - *dn++ = n; - if ((l = labellen(cp - 1)) < 0) { - errno = EMSGSIZE; - return (-1); - } - if (dn + l >= eom) { - errno = EMSGSIZE; - return (-1); - } - for (; l > 0; l--) { - c = *cp++; - if (isascii(c) && isupper(c)) - *dn++ = tolower(c); - else - *dn++ = c; - } - } - *dn++ = '\0'; - _DIAGASSERT(__type_fit(int, dn - dst)); - return (int)(dn - dst); -} - -/*% - * Unpack a domain name from a message, source may be compressed. - * - * return: - *\li -1 if it fails, or consumed octets if it succeeds. - */ -int -ns_name_unpack(const u_char *msg, const u_char *eom, const u_char *src, - u_char *dst, size_t dstsiz) -{ - return (ns_name_unpack2(msg, eom, src, dst, dstsiz, NULL)); -} - -/* - * ns_name_unpack2(msg, eom, src, dst, dstsiz, *dstlen) - * Unpack a domain name from a message, source may be compressed. - * return: - * -1 if it fails, or consumed octets if it succeeds. - * side effect: - * fills in *dstlen (if non-NULL). - */ -int -ns_name_unpack2(const u_char *msg, const u_char *eom, const u_char *src, - u_char *dst, size_t dstsiz, size_t *dstlen) -{ - const u_char *srcp, *dstlim; - u_char *dstp; - int n, len, checked, l; - - len = -1; - checked = 0; - dstp = dst; - srcp = src; - dstlim = dst + dstsiz; - if (srcp < msg || srcp >= eom) { - errno = EMSGSIZE; - return (-1); - } - /* Fetch next label in domain name. */ - while ((n = *srcp++) != 0) { - /* Check for indirection. */ - switch (n & NS_CMPRSFLGS) { - case 0: - case NS_TYPE_ELT: - /* Limit checks. */ - if ((l = labellen(srcp - 1)) < 0) { - errno = EMSGSIZE; - return (-1); - } - if (dstp + l + 1 >= dstlim || srcp + l >= eom) { - errno = EMSGSIZE; - return (-1); - } - checked += l + 1; - *dstp++ = n; - memcpy(dstp, srcp, (size_t)l); - dstp += l; - srcp += l; - break; - - case NS_CMPRSFLGS: - if (srcp >= eom) { - errno = EMSGSIZE; - return (-1); - } - if (len < 0) { - _DIAGASSERT(__type_fit(int, srcp - src + 1)); - len = (int)(srcp - src + 1); - } - n = ((n & 0x3f) << 8) | (*srcp & 0xff); - if (n >= eom - msg) { /*%< Out of range. */ - errno = EMSGSIZE; - return (-1); - } - srcp = msg + n; - checked += 2; - /* - * Check for loops in the compressed name; - * if we've looked at the whole message, - * there must be a loop. - */ - if (checked >= eom - msg) { - errno = EMSGSIZE; - return (-1); - } - break; - - default: - errno = EMSGSIZE; - return (-1); /*%< flag error */ - } - } - *dstp++ = 0; - if (dstlen != NULL) - *dstlen = dstp - dst; - if (len < 0) { - _DIAGASSERT(__type_fit(int, srcp - src)); - len = (int)(srcp - src); - } - return len; -} - -/*% - * Pack domain name 'domain' into 'comp_dn'. - * - * return: - *\li Size of the compressed name, or -1. - * - * notes: - *\li 'dnptrs' is an array of pointers to previous compressed names. - *\li dnptrs[0] is a pointer to the beginning of the message. The array - * ends with NULL. - *\li 'lastdnptr' is a pointer to the end of the array pointed to - * by 'dnptrs'. - * - * Side effects: - *\li The list of pointers in dnptrs is updated for labels inserted into - * the message as we compress the name. If 'dnptr' is NULL, we don't - * try to compress names. If 'lastdnptr' is NULL, we don't update the - * list. - */ -int -ns_name_pack(const u_char *src, u_char *dst, int dstsiz, - const u_char **dnptrs, const u_char **lastdnptr) -{ - u_char *dstp; - const u_char **cpp, **lpp, *eob, *msg; - const u_char *srcp; - int n, l, first = 1; - - srcp = src; - dstp = dst; - eob = dstp + dstsiz; - lpp = cpp = NULL; - if (dnptrs != NULL) { - if ((msg = *dnptrs++) != NULL) { - for (cpp = dnptrs; *cpp != NULL; cpp++) - continue; - lpp = cpp; /*%< end of list to search */ - } - } else - msg = NULL; - - /* make sure the domain we are about to add is legal */ - l = 0; - do { - int l0; - - n = *srcp; - if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) { - errno = EMSGSIZE; - return (-1); - } - if ((l0 = labellen(srcp)) < 0) { - errno = EINVAL; - return (-1); - } - l += l0 + 1; - if (l > MAXCDNAME) { - errno = EMSGSIZE; - return (-1); - } - srcp += l0 + 1; - } while (n != 0); - - /* from here on we need to reset compression pointer array on error */ - srcp = src; - do { - /* Look to see if we can use pointers. */ - n = *srcp; - if (n != 0 && msg != NULL) { - l = dn_find(srcp, msg, (const u_char * const *)dnptrs, - (const u_char * const *)lpp); - if (l >= 0) { - if (dstp + 1 >= eob) { - goto cleanup; - } - *dstp++ = ((u_int32_t)l >> 8) | NS_CMPRSFLGS; - *dstp++ = l % 256; - _DIAGASSERT(__type_fit(int, dstp - dst)); - return (int)(dstp - dst); - } - /* Not found, save it. */ - if (lastdnptr != NULL && cpp < lastdnptr - 1 && - (dstp - msg) < 0x4000 && first) { - *cpp++ = dstp; - *cpp = NULL; - first = 0; - } - } - /* copy label to buffer */ - if ((n & NS_CMPRSFLGS) == NS_CMPRSFLGS) { - /* Should not happen. */ - goto cleanup; - } - n = labellen(srcp); - if (dstp + 1 + n >= eob) { - goto cleanup; - } - memcpy(dstp, srcp, (size_t)(n + 1)); - srcp += n + 1; - dstp += n + 1; - } while (n != 0); - - if (dstp > eob) { -cleanup: - if (msg != NULL) - *lpp = NULL; - errno = EMSGSIZE; - return (-1); - } - _DIAGASSERT(__type_fit(int, dstp - dst)); - return (int)(dstp - dst); -} - -/*% - * Expand compressed domain name to presentation format. - * - * return: - *\li Number of bytes read out of `src', or -1 (with errno set). - * - * note: - *\li Root domain returns as "." not "". - */ -int -ns_name_uncompress(const u_char *msg, const u_char *eom, const u_char *src, - char *dst, size_t dstsiz) -{ - u_char tmp[NS_MAXCDNAME]; - int n; - - if ((n = ns_name_unpack(msg, eom, src, tmp, sizeof tmp)) == -1) - return (-1); - if (ns_name_ntop(tmp, dst, dstsiz) == -1) - return (-1); - return (n); -} - -/*% - * Compress a domain name into wire format, using compression pointers. - * - * return: - *\li Number of bytes consumed in `dst' or -1 (with errno set). - * - * notes: - *\li 'dnptrs' is an array of pointers to previous compressed names. - *\li dnptrs[0] is a pointer to the beginning of the message. - *\li The list ends with NULL. 'lastdnptr' is a pointer to the end of the - * array pointed to by 'dnptrs'. Side effect is to update the list of - * pointers for labels inserted into the message as we compress the name. - *\li If 'dnptr' is NULL, we don't try to compress names. If 'lastdnptr' - * is NULL, we don't update the list. - */ -int -ns_name_compress(const char *src, u_char *dst, size_t dstsiz, - const u_char **dnptrs, const u_char **lastdnptr) -{ - u_char tmp[NS_MAXCDNAME]; - - if (ns_name_pton(src, tmp, sizeof tmp) == -1) - return (-1); - return (ns_name_pack(tmp, dst, (int)dstsiz, dnptrs, lastdnptr)); -} - -/*% - * Reset dnptrs so that there are no active references to pointers at or - * after src. - */ -void -ns_name_rollback(const u_char *src, const u_char **dnptrs, - const u_char **lastdnptr) -{ - while (dnptrs < lastdnptr && *dnptrs != NULL) { - if (*dnptrs >= src) { - *dnptrs = NULL; - break; - } - dnptrs++; - } -} - -/*% - * Advance *ptrptr to skip over the compressed name it points at. - * - * return: - *\li 0 on success, -1 (with errno set) on failure. - */ -int -ns_name_skip(const u_char **ptrptr, const u_char *eom) -{ - const u_char *cp; - u_int n; - int l; - - cp = *ptrptr; - while (cp < eom && (n = *cp++) != 0) { - /* Check for indirection. */ - switch (n & NS_CMPRSFLGS) { - case 0: /*%< normal case, n == len */ - cp += n; - continue; - case NS_TYPE_ELT: /*%< EDNS0 extended label */ - if ((l = labellen(cp - 1)) < 0) { - errno = EMSGSIZE; /*%< XXX */ - return (-1); - } - cp += l; - continue; - case NS_CMPRSFLGS: /*%< indirection */ - cp++; - break; - default: /*%< illegal type */ - errno = EMSGSIZE; - return (-1); - } - break; - } - if (cp > eom) { - errno = EMSGSIZE; - return (-1); - } - *ptrptr = cp; - return (0); -} - -/* Find the number of octets an nname takes up, including the root label. - * (This is basically ns_name_skip() without compression-pointer support.) - * ((NOTE: can only return zero if passed-in namesiz argument is zero.)) - */ -ssize_t -ns_name_length(ns_nname_ct nname, size_t namesiz) { - ns_nname_ct orig = nname; - u_int n; - - while (namesiz-- > 0 && (n = *nname++) != 0) { - if ((n & NS_CMPRSFLGS) != 0) { - errno = EISDIR; - return (-1); - } - if (n > namesiz) { - errno = EMSGSIZE; - return (-1); - } - nname += n; - namesiz -= n; - } - return (nname - orig); -} - -/* Compare two nname's for equality. Return -1 on error (setting errno). - */ -int -ns_name_eq(ns_nname_ct a, size_t as, ns_nname_ct b, size_t bs) { - ns_nname_ct ae = a + as, be = b + bs; - int ac, bc; - - while (ac = *a, bc = *b, ac != 0 && bc != 0) { - if ((ac & NS_CMPRSFLGS) != 0 || (bc & NS_CMPRSFLGS) != 0) { - errno = EISDIR; - return (-1); - } - if (a + ac >= ae || b + bc >= be) { - errno = EMSGSIZE; - return (-1); - } - if (ac != bc || strncasecmp((const char *) ++a, - (const char *) ++b, - (size_t)ac) != 0) - return (0); - a += ac, b += bc; - } - return (ac == 0 && bc == 0); -} - -/* Is domain "A" owned by (at or below) domain "B"? - */ -int -ns_name_owned(ns_namemap_ct a, int an, ns_namemap_ct b, int bn) { - /* If A is shorter, it cannot be owned by B. */ - if (an < bn) - return (0); - - /* If they are unequal before the length of the shorter, A cannot... */ - while (bn > 0) { - if (a->len != b->len || - strncasecmp((const char *) a->base, - (const char *) b->base, (size_t)a->len) != 0) - return (0); - a++, an--; - b++, bn--; - } - - /* A might be longer or not, but either way, B owns it. */ - return (1); -} - -/* Build an array of tuples from an nname, top-down order. - * Return the number of tuples (labels) thus discovered. - */ -int -ns_name_map(ns_nname_ct nname, size_t namelen, ns_namemap_t map, int mapsize) { - u_int n; - int l; - - n = *nname++; - namelen--; - - /* Root zone? */ - if (n == 0) { - /* Extra data follows name? */ - if (namelen > 0) { - errno = EMSGSIZE; - return (-1); - } - return (0); - } - - /* Compression pointer? */ - if ((n & NS_CMPRSFLGS) != 0) { - errno = EISDIR; - return (-1); - } - - /* Label too long? */ - if (n > namelen) { - errno = EMSGSIZE; - return (-1); - } - - /* Recurse to get rest of name done first. */ - l = ns_name_map(nname + n, namelen - n, map, mapsize); - if (l < 0) - return (-1); - - /* Too many labels? */ - if (l >= mapsize) { - errno = ENAMETOOLONG; - return (-1); - } - - /* We're on our way back up-stack, store current map data. */ - map[l].base = nname; - map[l].len = n; - return (l + 1); -} - -/* Count the labels in a domain name. Root counts, so COM. has two. This - * is to make the result comparable to the result of ns_name_map(). - */ -int -ns_name_labels(ns_nname_ct nname, size_t namesiz) { - int ret = 0; - u_int n; - - while (namesiz-- > 0 && (n = *nname++) != 0) { - if ((n & NS_CMPRSFLGS) != 0) { - errno = EISDIR; - return (-1); - } - if (n > namesiz) { - errno = EMSGSIZE; - return (-1); - } - nname += n; - namesiz -= n; - ret++; - } - return (ret + 1); -} - -/* Private. */ - -/*% - * Thinking in noninternationalized USASCII (per the DNS spec), - * is this characted special ("in need of quoting") ? - * - * return: - *\li boolean. - */ -static int -special(int ch) { - switch (ch) { - case 0x22: /*%< '"' */ - case 0x2E: /*%< '.' */ - case 0x3B: /*%< ';' */ - case 0x5C: /*%< '\\' */ - case 0x28: /*%< '(' */ - case 0x29: /*%< ')' */ - /* Special modifiers in zone files. */ - case 0x40: /*%< '@' */ - case 0x24: /*%< '$' */ - return (1); - default: - return (0); - } -} - -/*% - * Thinking in noninternationalized USASCII (per the DNS spec), - * is this character visible and not a space when printed ? - * - * return: - *\li boolean. - */ -static int -printable(int ch) { - return (ch > 0x20 && ch < 0x7f); -} - -/*% - * Thinking in noninternationalized USASCII (per the DNS spec), - * convert this character to lower case if it's upper case. - */ -static int -mklower(int ch) { - if (ch >= 0x41 && ch <= 0x5A) - return (ch + 0x20); - return (ch); -} - -/*% - * Search for the counted-label name in an array of compressed names. - * - * return: - *\li offset from msg if found, or -1. - * - * notes: - *\li dnptrs is the pointer to the first name on the list, - *\li not the pointer to the start of the message. - */ -static int -dn_find(const u_char *domain, const u_char *msg, - const u_char * const *dnptrs, - const u_char * const *lastdnptr) -{ - const u_char *dn, *cp, *sp; - const u_char * const *cpp; - u_int n; - - for (cpp = dnptrs; cpp < lastdnptr; cpp++) { - sp = *cpp; - /* - * terminate search on: - * root label - * compression pointer - * unusable offset - */ - while (*sp != 0 && (*sp & NS_CMPRSFLGS) == 0 && - (sp - msg) < 0x4000) { - dn = domain; - cp = sp; - while ((n = *cp++) != 0) { - /* - * check for indirection - */ - switch (n & NS_CMPRSFLGS) { - case 0: /*%< normal case, n == len */ - n = labellen(cp - 1); /*%< XXX */ - if (n != *dn++) - goto next; - - for (; n > 0; n--) - if (mklower(*dn++) != - mklower(*cp++)) - goto next; - /* Is next root for both ? */ - if (*dn == '\0' && *cp == '\0') { - _DIAGASSERT(__type_fit(int, - sp - msg)); - return (int)(sp - msg); - } - if (*dn) - continue; - goto next; - case NS_CMPRSFLGS: /*%< indirection */ - cp = msg + (((n & 0x3f) << 8) | *cp); - break; - - default: /*%< illegal type */ - errno = EMSGSIZE; - return (-1); - } - } - next: ; - sp += *sp + 1; - } - } - errno = ENOENT; - return (-1); -} - -static int -decode_bitstring(const unsigned char **cpp, char *dn, const char *eom) -{ - const unsigned char *cp = *cpp; - char *beg = dn, tc; - int b, blen, plen, i; - - if ((blen = (*cp & 0xff)) == 0) - blen = 256; - plen = (blen + 3) / 4; - plen += (int)sizeof("\\[x/]") + (blen > 99 ? 3 : (blen > 9) ? 2 : 1); - if (dn + plen >= eom) - return (-1); - - cp++; - i = SPRINTF((dn, "\\[x")); - if (i < 0) - return (-1); - dn += i; - for (b = blen; b > 7; b -= 8, cp++) { - i = SPRINTF((dn, "%02x", *cp & 0xff)); - if (i < 0) - return (-1); - dn += i; - } - if (b > 4) { - tc = *cp++; - i = SPRINTF((dn, "%02x", tc & (0xff << (8 - b)))); - if (i < 0) - return (-1); - dn += i; - } else if (b > 0) { - tc = *cp++; - i = SPRINTF((dn, "%1x", - (((u_int32_t)tc >> 4) & 0x0f) & (0x0f << (4 - b)))); - if (i < 0) - return (-1); - dn += i; - } - i = SPRINTF((dn, "/%d]", blen)); - if (i < 0) - return (-1); - dn += i; - - *cpp = cp; - _DIAGASSERT(__type_fit(int, dn - beg)); - return (int)(dn - beg); -} - -static int -encode_bitsring(const char **bp, const char *end, unsigned char **labelp, - unsigned char ** dst, unsigned const char *eom) -{ - int afterslash = 0; - const char *cp = *bp; - unsigned char *tp; - char c; - const char *beg_blen; - char *end_blen = NULL; - int value = 0, count = 0, tbcount = 0, blen = 0; - - beg_blen = end_blen = NULL; - - /* a bitstring must contain at least 2 characters */ - if (end - cp < 2) - return (EINVAL); - - /* XXX: currently, only hex strings are supported */ - if (*cp++ != 'x') - return (EINVAL); - if (!isxdigit((*cp) & 0xff)) /*%< reject '\[x/BLEN]' */ - return (EINVAL); - - for (tp = *dst + 1; cp < end && tp < eom; cp++) { - switch((c = *cp)) { - case ']': /*%< end of the bitstring */ - if (afterslash) { - if (beg_blen == NULL) - return (EINVAL); - blen = (int)strtol(beg_blen, &end_blen, 10); - if (*end_blen != ']') - return (EINVAL); - } - if (count) - *tp++ = ((value << 4) & 0xff); - cp++; /*%< skip ']' */ - goto done; - case '/': - afterslash = 1; - break; - default: - if (afterslash) { - if (!isdigit(c&0xff)) - return (EINVAL); - if (beg_blen == NULL) { - - if (c == '0') { - /* blen never begings with 0 */ - return (EINVAL); - } - beg_blen = cp; - } - } else { - if (!isxdigit(c&0xff)) - return (EINVAL); - value <<= 4; - value += digitvalue[(int)c]; - count += 4; - tbcount += 4; - if (tbcount > 256) - return (EINVAL); - if (count == 8) { - *tp++ = value; - count = 0; - } - } - break; - } - } - done: - if (cp >= end || tp >= eom) - return (EMSGSIZE); - - /* - * bit length validation: - * If a is present, the number of digits in the - * MUST be just sufficient to contain the number of bits specified - * by the . If there are insignificant bits in a final - * hexadecimal or octal digit, they MUST be zero. - * RFC2673, Section 3.2. - */ - if (blen > 0) { - int traillen; - - if (((blen + 3) & ~3) != tbcount) - return (EINVAL); - traillen = tbcount - blen; /*%< between 0 and 3 */ - if (((value << (8 - traillen)) & 0xff) != 0) - return (EINVAL); - } - else - blen = tbcount; - if (blen == 256) - blen = 0; - - /* encode the type and the significant bit fields */ - **labelp = DNS_LABELTYPE_BITSTRING; - **dst = blen; - - *bp = cp; - *dst = tp; - - return (0); -} - -static int -labellen(const u_char *lp) -{ - int bitlen; - u_char l = *lp; - - if ((l & NS_CMPRSFLGS) == NS_CMPRSFLGS) { - /* should be avoided by the caller */ - return (-1); - } - - if ((l & NS_CMPRSFLGS) == NS_TYPE_ELT) { - if (l == DNS_LABELTYPE_BITSTRING) { - if ((bitlen = *(lp + 1)) == 0) - bitlen = 256; - return ((bitlen + 7 ) / 8 + 1); - } - return (-1); /*%< unknwon ELT */ - } - return (l); -} - -/*! \file */ diff --git a/lib/libc/nameser/ns_netint.c b/lib/libc/nameser/ns_netint.c deleted file mode 100644 index 750699283..000000000 --- a/lib/libc/nameser/ns_netint.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: ns_netint.c,v 1.7 2012/03/13 21:13:39 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#ifndef lint -#ifdef notdef -static const char rcsid[] = "Id: ns_netint.c,v 1.3 2005/04/27 04:56:40 sra Exp"; -#else -__RCSID("$NetBSD: ns_netint.c,v 1.7 2012/03/13 21:13:39 christos Exp $"); -#endif -#endif - -/* Import. */ - -#include "port_before.h" - -#include - -#include "port_after.h" - -/* Public. */ - -uint16_t -ns_get16(const u_char *src) { - uint16_t dst; - - NS_GET16(dst, src); - return dst; -} - -uint32_t -ns_get32(const u_char *src) { - u_int32_t dst; - - NS_GET32(dst, src); - return dst; -} - -void -ns_put16(uint16_t src, u_char *dst) { - NS_PUT16(src, dst); -} - -void -ns_put32(uint32_t src, u_char *dst) { - NS_PUT32(src, dst); -} - -/*! \file */ diff --git a/lib/libc/nameser/ns_parse.c b/lib/libc/nameser/ns_parse.c deleted file mode 100644 index 0379a7d42..000000000 --- a/lib/libc/nameser/ns_parse.c +++ /dev/null @@ -1,285 +0,0 @@ -/* $NetBSD: ns_parse.c,v 1.9 2012/03/13 21:13:39 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#ifndef lint -#ifdef notdef -static const char rcsid[] = "Id: ns_parse.c,v 1.10 2009/01/23 19:59:16 each Exp"; -#else -__RCSID("$NetBSD: ns_parse.c,v 1.9 2012/03/13 21:13:39 christos Exp $"); -#endif -#endif - -/* Import. */ - -#include "port_before.h" - -#include - -#include -#include - -#include -#include -#include -#include - -#include "port_after.h" - -/* Forward. */ - -static void setsection(ns_msg *msg, ns_sect sect); - -/* Macros. */ - -#if !defined(SOLARIS2) || defined(__COVERITY__) -#define RETERR(err) do { errno = (err); return (-1); } while (/*NOTREACHED*//*CONSTCOND*/0) -#else -#define RETERR(err) \ - do { errno = (err); if (errno == errno) return (-1); } while (0) -#endif - -#define PARSE_FMT_PRESO 0 /* Parse using presentation-format names */ -#define PARSE_FMT_WIRE 1 /* Parse using network-format names */ - -/* Public. */ - -/* These need to be in the same order as the nres.h:ns_flag enum. */ -struct _ns_flagdata _ns_flagdata[16] = { - { 0x8000, 15 }, /*%< qr. */ - { 0x7800, 11 }, /*%< opcode. */ - { 0x0400, 10 }, /*%< aa. */ - { 0x0200, 9 }, /*%< tc. */ - { 0x0100, 8 }, /*%< rd. */ - { 0x0080, 7 }, /*%< ra. */ - { 0x0040, 6 }, /*%< z. */ - { 0x0020, 5 }, /*%< ad. */ - { 0x0010, 4 }, /*%< cd. */ - { 0x000f, 0 }, /*%< rcode. */ - { 0x0000, 0 }, /*%< expansion (1/6). */ - { 0x0000, 0 }, /*%< expansion (2/6). */ - { 0x0000, 0 }, /*%< expansion (3/6). */ - { 0x0000, 0 }, /*%< expansion (4/6). */ - { 0x0000, 0 }, /*%< expansion (5/6). */ - { 0x0000, 0 }, /*%< expansion (6/6). */ -}; - -int ns_msg_getflag(ns_msg handle, int flag) { - return((u_int32_t)((handle)._flags & _ns_flagdata[flag].mask) >> _ns_flagdata[flag].shift); -} - -int -ns_skiprr(const u_char *ptr, const u_char *eom, ns_sect section, int count) { - const u_char *optr = ptr; - - for (; count > 0; count--) { - int b, rdlength; - - b = dn_skipname(ptr, eom); - if (b < 0) - RETERR(EMSGSIZE); - ptr += b/*Name*/ + NS_INT16SZ/*Type*/ + NS_INT16SZ/*Class*/; - if (section != ns_s_qd) { - if (ptr + NS_INT32SZ + NS_INT16SZ > eom) - RETERR(EMSGSIZE); - ptr += NS_INT32SZ/*TTL*/; - NS_GET16(rdlength, ptr); - ptr += rdlength/*RData*/; - } - } - if (ptr > eom) - RETERR(EMSGSIZE); - _DIAGASSERT(__type_fit(int, ptr - optr)); - return (int)(ptr - optr); -} - -int -ns_initparse(const u_char *msg, int msglen, ns_msg *handle) { - const u_char *eom = msg + msglen; - int i; - - handle->_msg = msg; - handle->_eom = eom; - if (msg + NS_INT16SZ > eom) - RETERR(EMSGSIZE); - NS_GET16(handle->_id, msg); - if (msg + NS_INT16SZ > eom) - RETERR(EMSGSIZE); - NS_GET16(handle->_flags, msg); - for (i = 0; i < ns_s_max; i++) { - if (msg + NS_INT16SZ > eom) - RETERR(EMSGSIZE); - NS_GET16(handle->_counts[i], msg); - } - for (i = 0; i < ns_s_max; i++) - if (handle->_counts[i] == 0) - handle->_sections[i] = NULL; - else { - int b = ns_skiprr(msg, eom, (ns_sect)i, - handle->_counts[i]); - - if (b < 0) - return (-1); - handle->_sections[i] = msg; - msg += b; - } - if (msg != eom) - RETERR(EMSGSIZE); - setsection(handle, ns_s_max); - return (0); -} - -int -ns_parserr(ns_msg *handle, ns_sect section, int rrnum, ns_rr *rr) { - int b; - int tmp; - - /* Make section right. */ - tmp = section; - if (tmp < 0 || section >= ns_s_max) - RETERR(ENODEV); - if (section != handle->_sect) - setsection(handle, section); - - /* Make rrnum right. */ - if (rrnum == -1) - rrnum = handle->_rrnum; - if (rrnum < 0 || rrnum >= handle->_counts[(int)section]) - RETERR(ENODEV); - if (rrnum < handle->_rrnum) - setsection(handle, section); - if (rrnum > handle->_rrnum) { - b = ns_skiprr(handle->_msg_ptr, handle->_eom, section, - rrnum - handle->_rrnum); - - if (b < 0) - return (-1); - handle->_msg_ptr += b; - handle->_rrnum = rrnum; - } - - /* Do the parse. */ - b = dn_expand(handle->_msg, handle->_eom, - handle->_msg_ptr, rr->name, NS_MAXDNAME); - if (b < 0) - return (-1); - handle->_msg_ptr += b; - if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom) - RETERR(EMSGSIZE); - NS_GET16(rr->type, handle->_msg_ptr); - NS_GET16(rr->rr_class, handle->_msg_ptr); - if (section == ns_s_qd) { - rr->ttl = 0; - rr->rdlength = 0; - rr->rdata = NULL; - } else { - if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom) - RETERR(EMSGSIZE); - NS_GET32(rr->ttl, handle->_msg_ptr); - NS_GET16(rr->rdlength, handle->_msg_ptr); - if (handle->_msg_ptr + rr->rdlength > handle->_eom) - RETERR(EMSGSIZE); - rr->rdata = handle->_msg_ptr; - handle->_msg_ptr += rr->rdlength; - } - if (++handle->_rrnum > handle->_counts[(int)section]) - setsection(handle, (ns_sect)((int)section + 1)); - - /* All done. */ - return (0); -} - -/* - * This is identical to the above but uses network-format (uncompressed) names. - */ -int -ns_parserr2(ns_msg *handle, ns_sect section, int rrnum, ns_rr2 *rr) { - int b; - int tmp; - - /* Make section right. */ - tmp = section; - if (tmp < 0 || section >= ns_s_max) - RETERR(ENODEV); - if (section != handle->_sect) - setsection(handle, section); - - /* Make rrnum right. */ - if (rrnum == -1) - rrnum = handle->_rrnum; - if (rrnum < 0 || rrnum >= handle->_counts[(int)section]) - RETERR(ENODEV); - if (rrnum < handle->_rrnum) - setsection(handle, section); - if (rrnum > handle->_rrnum) { - b = ns_skiprr(handle->_msg_ptr, handle->_eom, section, - rrnum - handle->_rrnum); - - if (b < 0) - return (-1); - handle->_msg_ptr += b; - handle->_rrnum = rrnum; - } - - /* Do the parse. */ - b = ns_name_unpack2(handle->_msg, handle->_eom, handle->_msg_ptr, - rr->nname, NS_MAXNNAME, &rr->nnamel); - if (b < 0) - return (-1); - handle->_msg_ptr += b; - if (handle->_msg_ptr + NS_INT16SZ + NS_INT16SZ > handle->_eom) - RETERR(EMSGSIZE); - NS_GET16(rr->type, handle->_msg_ptr); - NS_GET16(rr->rr_class, handle->_msg_ptr); - if (section == ns_s_qd) { - rr->ttl = 0; - rr->rdlength = 0; - rr->rdata = NULL; - } else { - if (handle->_msg_ptr + NS_INT32SZ + NS_INT16SZ > handle->_eom) - RETERR(EMSGSIZE); - NS_GET32(rr->ttl, handle->_msg_ptr); - NS_GET16(rr->rdlength, handle->_msg_ptr); - if (handle->_msg_ptr + rr->rdlength > handle->_eom) - RETERR(EMSGSIZE); - rr->rdata = handle->_msg_ptr; - handle->_msg_ptr += rr->rdlength; - } - if (++handle->_rrnum > handle->_counts[(int)section]) - setsection(handle, (ns_sect)((int)section + 1)); - - /* All done. */ - return (0); -} - -/* Private. */ - -static void -setsection(ns_msg *msg, ns_sect sect) { - msg->_sect = sect; - if (sect == ns_s_max) { - msg->_rrnum = -1; - msg->_msg_ptr = NULL; - } else { - msg->_rrnum = 0; - msg->_msg_ptr = msg->_sections[(int)sect]; - } -} - -/*! \file */ diff --git a/lib/libc/nameser/ns_print.c b/lib/libc/nameser/ns_print.c deleted file mode 100644 index b6a18f5bd..000000000 --- a/lib/libc/nameser/ns_print.c +++ /dev/null @@ -1,1264 +0,0 @@ -/* $NetBSD: ns_print.c,v 1.11 2012/03/13 21:13:39 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#ifndef lint -#ifdef notdef -static const char rcsid[] = "Id: ns_print.c,v 1.12 2009/03/03 05:29:58 each Exp"; -#else -__RCSID("$NetBSD: ns_print.c,v 1.11 2012/03/13 21:13:39 christos Exp $"); -#endif -#endif - -/* Import. */ - -#include "port_before.h" - -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) ((int)strlen(sprintf/**/x)) -#else -# define SPRINTF(x) (sprintf x) -#endif - -/* Forward. */ - -static size_t prune_origin(const char *name, const char *origin); -static int charstr(const u_char *rdata, const u_char *edata, - char **buf, size_t *buflen); -static int addname(const u_char *msg, size_t msglen, - const u_char **p, const char *origin, - char **buf, size_t *buflen); -static void addlen(size_t len, char **buf, size_t *buflen); -static int addstr(const char *src, size_t len, - char **buf, size_t *buflen); -static int addtab(size_t len, size_t target, int spaced, - char **buf, size_t *buflen); - -/* Macros. */ - -#define T(x) \ - do { \ - if ((x) < 0) \ - return (-1); \ - } while (/*CONSTCOND*/0) - -static const char base32hex[] = - "0123456789ABCDEFGHIJKLMNOPQRSTUV=0123456789abcdefghijklmnopqrstuv"; - -/* Public. */ - -/*% - * Convert an RR to presentation format. - * - * return: - *\li Number of characters written to buf, or -1 (check errno). - */ -int -ns_sprintrr(const ns_msg *handle, const ns_rr *rr, - const char *name_ctx, const char *origin, - char *buf, size_t buflen) -{ - int n; - - n = ns_sprintrrf(ns_msg_base(*handle), ns_msg_size(*handle), - ns_rr_name(*rr), ns_rr_class(*rr), ns_rr_type(*rr), - ns_rr_ttl(*rr), ns_rr_rdata(*rr), ns_rr_rdlen(*rr), - name_ctx, origin, buf, buflen); - return (n); -} - -/*% - * Convert the fields of an RR into presentation format. - * - * return: - *\li Number of characters written to buf, or -1 (check errno). - */ -int -ns_sprintrrf(const u_char *msg, size_t msglen, - const char *name, ns_class class, ns_type type, - u_long ttl, const u_char *rdata, size_t rdlen, - const char *name_ctx, const char *origin, - char *buf, size_t buflen) -{ - const char *obuf = buf; - const u_char *edata = rdata + rdlen; - int spaced = 0; - - const char *comment; - char tmp[100]; - int len, x; - - /* - * Owner. - */ - if (name_ctx != NULL && ns_samename(name_ctx, name) == 1) { - T(addstr("\t\t\t", (size_t)3, &buf, &buflen)); - } else { - len = (int)prune_origin(name, origin); - if (*name == '\0') { - goto root; - } else if (len == 0) { - T(addstr("@\t\t\t", (size_t)4, &buf, &buflen)); - } else { - T(addstr(name, (size_t)len, &buf, &buflen)); - /* Origin not used or not root, and no trailing dot? */ - if (((origin == NULL || origin[0] == '\0') || - (origin[0] != '.' && origin[1] != '\0' && - name[len] == '\0')) && name[len - 1] != '.') { - root: - T(addstr(".", (size_t)1, &buf, &buflen)); - len++; - } - T(spaced = addtab((size_t)len, 24, spaced, &buf, &buflen)); - } - } - - /* - * TTL, Class, Type. - */ - T(x = ns_format_ttl(ttl, buf, buflen)); - addlen((size_t)x, &buf, &buflen); - len = SPRINTF((tmp, " %s %s", p_class(class), p_type(type))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - T(spaced = addtab((size_t)(x + len), (size_t)16, spaced, &buf, &buflen)); - - /* - * RData. - */ - switch (type) { - case ns_t_a: - if (rdlen != (size_t)NS_INADDRSZ) - goto formerr; - (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen); - addlen(strlen(buf), &buf, &buflen); - break; - - case ns_t_cname: - case ns_t_mb: - case ns_t_mg: - case ns_t_mr: - case ns_t_ns: - case ns_t_ptr: - case ns_t_dname: - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - break; - - case ns_t_hinfo: - case ns_t_isdn: - /* First word. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", (size_t)1, &buf, &buflen)); - - - /* Second word, optional in ISDN records. */ - if (type == ns_t_isdn && rdata == edata) - break; - - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - break; - - case ns_t_soa: { - u_long t; - - /* Server name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", (size_t)1, &buf, &buflen)); - - /* Administrator name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" (\n", (size_t)3, &buf, &buflen)); - spaced = 0; - - if ((edata - rdata) != 5*NS_INT32SZ) - goto formerr; - - /* Serial number. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen)); - len = SPRINTF((tmp, "%lu", t)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen)); - T(addstr("; serial\n", (size_t)9, &buf, &buflen)); - spaced = 0; - - /* Refresh interval. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen((size_t)len, &buf, &buflen); - T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen)); - T(addstr("; refresh\n", (size_t)10, &buf, &buflen)); - spaced = 0; - - /* Retry interval. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen((size_t)len, &buf, &buflen); - T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen)); - T(addstr("; retry\n", (size_t)8, &buf, &buflen)); - spaced = 0; - - /* Expiry. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen((size_t)len, &buf, &buflen); - T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen)); - T(addstr("; expiry\n", (size_t)9, &buf, &buflen)); - spaced = 0; - - /* Minimum TTL. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - T(addstr("\t\t\t\t\t", (size_t)5, &buf, &buflen)); - T(len = ns_format_ttl(t, buf, buflen)); - addlen((size_t)len, &buf, &buflen); - T(addstr(" )", (size_t)2, &buf, &buflen)); - T(spaced = addtab((size_t)len, (size_t)16, spaced, &buf, &buflen)); - T(addstr("; minimum\n", (size_t)10, &buf, &buflen)); - - break; - } - - case ns_t_mx: - case ns_t_afsdb: - case ns_t_rt: - case ns_t_kx: { - u_int t; - - if (rdlen < (size_t)NS_INT16SZ) - goto formerr; - - /* Priority. */ - t = ns_get16(rdata); - rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", t)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Target. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - break; - } - - case ns_t_px: { - u_int t; - - if (rdlen < (size_t)NS_INT16SZ) - goto formerr; - - /* Priority. */ - t = ns_get16(rdata); - rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", t)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Name1. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", (size_t)1, &buf, &buflen)); - - /* Name2. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - break; - } - - case ns_t_x25: - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - break; - - case ns_t_txt: - case ns_t_spf: - while (rdata < edata) { - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - if (rdata < edata) - T(addstr(" ", (size_t)1, &buf, &buflen)); - } - break; - - case ns_t_nsap: { - char t[2+255*3]; - - (void) inet_nsap_ntoa((int)rdlen, rdata, t); - T(addstr(t, strlen(t), &buf, &buflen)); - break; - } - - case ns_t_aaaa: - if (rdlen != (size_t)NS_IN6ADDRSZ) - goto formerr; - (void) inet_ntop(AF_INET6, rdata, buf, (socklen_t)buflen); - addlen(strlen(buf), &buf, &buflen); - break; - - case ns_t_loc: { - char t[255]; - - /* XXX protocol format checking? */ - (void) loc_ntoa(rdata, t); - T(addstr(t, strlen(t), &buf, &buflen)); - break; - } - - case ns_t_naptr: { - u_int order, preference; - char t[50]; - - if (rdlen < 2U*NS_INT16SZ) - goto formerr; - - /* Order, Precedence. */ - order = ns_get16(rdata); rdata += NS_INT16SZ; - preference = ns_get16(rdata); rdata += NS_INT16SZ; - len = SPRINTF((t, "%u %u ", order, preference)); - T(addstr(t, (size_t)len, &buf, &buflen)); - - /* Flags. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", (size_t)1, &buf, &buflen)); - - /* Service. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", (size_t)1, &buf, &buflen)); - - /* Regexp. */ - T(len = charstr(rdata, edata, &buf, &buflen)); - if (len < 0) - return (-1); - if (len == 0) - goto formerr; - rdata += len; - T(addstr(" ", (size_t)1, &buf, &buflen)); - - /* Server. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - break; - } - - case ns_t_srv: { - u_int priority, weight, port; - char t[50]; - - if (rdlen < 3U*NS_INT16SZ) - goto formerr; - - /* Priority, Weight, Port. */ - priority = ns_get16(rdata); rdata += NS_INT16SZ; - weight = ns_get16(rdata); rdata += NS_INT16SZ; - port = ns_get16(rdata); rdata += NS_INT16SZ; - len = SPRINTF((t, "%u %u %u ", priority, weight, port)); - T(addstr(t, (size_t)len, &buf, &buflen)); - - /* Server. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - break; - } - - case ns_t_minfo: - case ns_t_rp: - /* Name1. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", (size_t)1, &buf, &buflen)); - - /* Name2. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - break; - - case ns_t_wks: { - int n, lcnt; - - if (rdlen < 1U + NS_INT32SZ) - goto formerr; - - /* Address. */ - (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen); - addlen(strlen(buf), &buf, &buflen); - rdata += NS_INADDRSZ; - - /* Protocol. */ - len = SPRINTF((tmp, " %u ( ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata += NS_INT8SZ; - - /* Bit map. */ - n = 0; - lcnt = 0; - while (rdata < edata) { - u_int c = *rdata++; - do { - if (c & 0200) { - if (lcnt == 0) { - T(addstr("\n\t\t\t\t", (size_t)5, - &buf, &buflen)); - lcnt = 10; - spaced = 0; - } - len = SPRINTF((tmp, "%d ", n)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - lcnt--; - } - c <<= 1; - } while (++n & 07); - } - T(addstr(")", (size_t)1, &buf, &buflen)); - - break; - } - - case ns_t_key: - case ns_t_dnskey: { - char base64_key[NS_MD5RSA_MAX_BASE64]; - u_int keyflags, protocol, algorithm, key_id; - const char *leader; - int n; - - if (rdlen < 0U + NS_INT16SZ + NS_INT8SZ + NS_INT8SZ) - goto formerr; - - /* Key flags, Protocol, Algorithm. */ -#ifndef _LIBC - key_id = dst_s_dns_key_id(rdata, edata-rdata); -#else - key_id = 0; -#endif - keyflags = ns_get16(rdata); rdata += NS_INT16SZ; - protocol = *rdata++; - algorithm = *rdata++; - len = SPRINTF((tmp, "0x%04x %u %u", - keyflags, protocol, algorithm)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Public key data. */ - len = b64_ntop(rdata, (size_t)(edata - rdata), - base64_key, sizeof base64_key); - if (len < 0) - goto formerr; - if (len > 15) { - T(addstr(" (", (size_t)2, &buf, &buflen)); - leader = "\n\t\t"; - spaced = 0; - } else - leader = " "; - for (n = 0; n < len; n += 48) { - T(addstr(leader, strlen(leader), &buf, &buflen)); - T(addstr(base64_key + n, (size_t)MIN(len - n, 48), - &buf, &buflen)); - } - if (len > 15) - T(addstr(" )", (size_t)2, &buf, &buflen)); - n = SPRINTF((tmp, " ; key_tag= %u", key_id)); - T(addstr(tmp, (size_t)n, &buf, &buflen)); - - break; - } - - case ns_t_sig: - case ns_t_rrsig: { - char base64_key[NS_MD5RSA_MAX_BASE64]; - u_int typ, algorithm, labels, footprint; - const char *leader; - u_long t; - int n; - - if (rdlen < 22U) - goto formerr; - - /* Type covered, Algorithm, Label count, Original TTL. */ - typ = ns_get16(rdata); rdata += NS_INT16SZ; - algorithm = *rdata++; - labels = *rdata++; - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, "%s %d %d %lu ", - p_type((int)typ), algorithm, labels, t)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - if (labels > (u_int)dn_count_labels(name)) - goto formerr; - - /* Signature expiry. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, "%s ", p_secstodate(t))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Time signed. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, "%s ", p_secstodate(t))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Signature Footprint. */ - footprint = ns_get16(rdata); rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", footprint)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Signer's name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - /* Signature. */ - len = b64_ntop(rdata, (size_t)(edata - rdata), - base64_key, sizeof base64_key); - if (len > 15) { - T(addstr(" (", (size_t)2, &buf, &buflen)); - leader = "\n\t\t"; - spaced = 0; - } else - leader = " "; - if (len < 0) - goto formerr; - for (n = 0; n < len; n += 48) { - T(addstr(leader, strlen(leader), &buf, &buflen)); - T(addstr(base64_key + n, (size_t)MIN(len - n, 48), - &buf, &buflen)); - } - if (len > 15) - T(addstr(" )", (size_t)2, &buf, &buflen)); - break; - } - - case ns_t_nxt: { - ptrdiff_t n, c; - - /* Next domain name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - /* Type bit map. */ - n = edata - rdata; - for (c = 0; c < n*8; c++) - if (NS_NXT_BIT_ISSET(c, rdata)) { - len = SPRINTF((tmp, " %s", p_type((int)c))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - } - break; - } - - case ns_t_cert: { - u_int c_type, key_tag, alg; - int n; - size_t siz; - char base64_cert[8192], tmp1[40]; - const char *leader; - - c_type = ns_get16(rdata); rdata += NS_INT16SZ; - key_tag = ns_get16(rdata); rdata += NS_INT16SZ; - alg = (u_int) *rdata++; - - len = SPRINTF((tmp1, "%d %d %d ", c_type, key_tag, alg)); - T(addstr(tmp1, (size_t)len, &buf, &buflen)); - siz = (edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */ - if (siz > sizeof(base64_cert) * 3/4) { - const char *str = "record too long to print"; - T(addstr(str, strlen(str), &buf, &buflen)); - } - else { - len = b64_ntop(rdata, (size_t)(edata-rdata), - base64_cert, siz); - - if (len < 0) - goto formerr; - else if (len > 15) { - T(addstr(" (", (size_t)2, &buf, &buflen)); - leader = "\n\t\t"; - spaced = 0; - } - else - leader = " "; - - for (n = 0; n < len; n += 48) { - T(addstr(leader, strlen(leader), - &buf, &buflen)); - T(addstr(base64_cert + n, (size_t)MIN(len - n, 48), - &buf, &buflen)); - } - if (len > 15) - T(addstr(" )", (size_t)2, &buf, &buflen)); - } - break; - } - - case ns_t_tkey: { - /* KJD - need to complete this */ - u_long t; - int mode, err, keysize; - - /* Algorithm name. */ - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", (size_t)1, &buf, &buflen)); - - /* Inception. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, "%s ", p_secstodate(t))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Experation. */ - t = ns_get32(rdata); rdata += NS_INT32SZ; - len = SPRINTF((tmp, "%s ", p_secstodate(t))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* Mode , Error, Key Size. */ - /* Priority, Weight, Port. */ - mode = ns_get16(rdata); rdata += NS_INT16SZ; - err = ns_get16(rdata); rdata += NS_INT16SZ; - keysize = ns_get16(rdata); rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u %u %u ", mode, err, keysize)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - /* XXX need to dump key, print otherdata length & other data */ - break; - } - - case ns_t_tsig: { - /* BEW - need to complete this */ - int n; - - T(len = addname(msg, msglen, &rdata, origin, &buf, &buflen)); - T(addstr(" ", (size_t)1, &buf, &buflen)); - rdata += 8; /*%< time */ - n = ns_get16(rdata); rdata += INT16SZ; - rdata += n; /*%< sig */ - n = ns_get16(rdata); rdata += INT16SZ; /*%< original id */ - sprintf(buf, "%d", ns_get16(rdata)); - rdata += INT16SZ; - addlen(strlen(buf), &buf, &buflen); - break; - } - - case ns_t_a6: { - struct in6_addr a; - int pbyte, pbit; - - /* prefix length */ - if (rdlen == 0U) goto formerr; - len = SPRINTF((tmp, "%d ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - pbit = *rdata; - if (pbit > 128) goto formerr; - pbyte = (pbit & ~7) / 8; - rdata++; - - /* address suffix: provided only when prefix len != 128 */ - if (pbit < 128) { - if (rdata + pbyte >= edata) goto formerr; - memset(&a, 0, sizeof(a)); - memcpy(&a.s6_addr[pbyte], rdata, sizeof(a) - pbyte); - (void) inet_ntop(AF_INET6, &a, buf, (socklen_t)buflen); - addlen(strlen(buf), &buf, &buflen); - rdata += sizeof(a) - pbyte; - } - - /* prefix name: provided only when prefix len > 0 */ - if (pbit == 0) - break; - if (rdata >= edata) goto formerr; - T(addstr(" ", (size_t)1, &buf, &buflen)); - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - break; - } - - case ns_t_opt: { - len = SPRINTF((tmp, "%u bytes", class)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - break; - } - - case ns_t_ds: - case ns_t_dlv: - case ns_t_sshfp: { - u_int t; - - if (type == ns_t_ds || type == ns_t_dlv) { - if (rdlen < 4U) goto formerr; - t = ns_get16(rdata); - rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", t)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - } else - if (rdlen < 2U) goto formerr; - - len = SPRINTF((tmp, "%u ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - - len = SPRINTF((tmp, "%u ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - - while (rdata < edata) { - len = SPRINTF((tmp, "%02X", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - } - break; - } - - case ns_t_nsec3: - case ns_t_nsec3param: { - u_int t, w, l, j, k, c; - - len = SPRINTF((tmp, "%u ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - - len = SPRINTF((tmp, "%u ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - - t = ns_get16(rdata); - rdata += NS_INT16SZ; - len = SPRINTF((tmp, "%u ", t)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - t = *rdata++; - if (t == 0) { - T(addstr("-", 1, &buf, &buflen)); - } else { - while (t-- > 0) { - len = SPRINTF((tmp, "%02X", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - } - } - if (type == ns_t_nsec3param) - break; - T(addstr(" ", 1, &buf, &buflen)); - - t = *rdata++; - while (t > 0) { - switch (t) { - case 1: - tmp[0] = base32hex[(((uint32_t)rdata[0]>>3)&0x1f)]; - tmp[1] = base32hex[(((uint32_t)rdata[0]<<2)&0x1c)]; - tmp[2] = tmp[3] = tmp[4] = '='; - tmp[5] = tmp[6] = tmp[7] = '='; - break; - case 2: - tmp[0] = base32hex[(((uint32_t)rdata[0]>>3)&0x1f)]; - tmp[1] = base32hex[(((uint32_t)rdata[0]<<2)&0x1c)| - (((uint32_t)rdata[1]>>6)&0x03)]; - tmp[2] = base32hex[(((uint32_t)rdata[1]>>1)&0x1f)]; - tmp[3] = base32hex[(((uint32_t)rdata[1]<<4)&0x10)]; - tmp[4] = tmp[5] = tmp[6] = tmp[7] = '='; - break; - case 3: - tmp[0] = base32hex[(((uint32_t)rdata[0]>>3)&0x1f)]; - tmp[1] = base32hex[(((uint32_t)rdata[0]<<2)&0x1c)| - (((uint32_t)rdata[1]>>6)&0x03)]; - tmp[2] = base32hex[(((uint32_t)rdata[1]>>1)&0x1f)]; - tmp[3] = base32hex[(((uint32_t)rdata[1]<<4)&0x10)| - (((uint32_t)rdata[2]>>4)&0x0f)]; - tmp[4] = base32hex[(((uint32_t)rdata[2]<<1)&0x1e)]; - tmp[5] = tmp[6] = tmp[7] = '='; - break; - case 4: - tmp[0] = base32hex[(((uint32_t)rdata[0]>>3)&0x1f)]; - tmp[1] = base32hex[(((uint32_t)rdata[0]<<2)&0x1c)| - (((uint32_t)rdata[1]>>6)&0x03)]; - tmp[2] = base32hex[(((uint32_t)rdata[1]>>1)&0x1f)]; - tmp[3] = base32hex[(((uint32_t)rdata[1]<<4)&0x10)| - (((uint32_t)rdata[2]>>4)&0x0f)]; - tmp[4] = base32hex[(((uint32_t)rdata[2]<<1)&0x1e)| - (((uint32_t)rdata[3]>>7)&0x01)]; - tmp[5] = base32hex[(((uint32_t)rdata[3]>>2)&0x1f)]; - tmp[6] = base32hex[((uint32_t)rdata[3]<<3)&0x18]; - tmp[7] = '='; - break; - default: - tmp[0] = base32hex[(((uint32_t)rdata[0]>>3)&0x1f)]; - tmp[1] = base32hex[(((uint32_t)rdata[0]<<2)&0x1c)| - (((uint32_t)rdata[1]>>6)&0x03)]; - tmp[2] = base32hex[(((uint32_t)rdata[1]>>1)&0x1f)]; - tmp[3] = base32hex[(((uint32_t)rdata[1]<<4)&0x10)| - (((uint32_t)rdata[2]>>4)&0x0f)]; - tmp[4] = base32hex[(((uint32_t)rdata[2]<<1)&0x1e)| - (((uint32_t)rdata[3]>>7)&0x01)]; - tmp[5] = base32hex[(((uint32_t)rdata[3]>>2)&0x1f)]; - tmp[6] = base32hex[(((uint32_t)rdata[3]<<3)&0x18)| - (((uint32_t)rdata[4]>>5)&0x07)]; - tmp[7] = base32hex[(rdata[4]&0x1f)]; - break; - } - T(addstr(tmp, 8, &buf, &buflen)); - if (t >= 5) { - rdata += 5; - t -= 5; - } else { - rdata += t; - t -= t; - } - } - - while (rdata < edata) { - w = *rdata++; - l = *rdata++; - for (j = 0; j < l; j++) { - if (rdata[j] == 0) - continue; - for (k = 0; k < 8; k++) { - if ((rdata[j] & (0x80 >> k)) == 0) - continue; - c = w * 256 + j * 8 + k; - len = SPRINTF((tmp, " %s", p_type((ns_type)c))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - } - } - rdata += l; - } - break; - } - - case ns_t_nsec: { - u_int w, l, j, k, c; - - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - - while (rdata < edata) { - w = *rdata++; - l = *rdata++; - for (j = 0; j < l; j++) { - if (rdata[j] == 0) - continue; - for (k = 0; k < 8; k++) { - if ((rdata[j] & (0x80 >> k)) == 0) - continue; - c = w * 256 + j * 8 + k; - len = SPRINTF((tmp, " %s", p_type((ns_type)c))); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - } - } - rdata += l; - } - break; - } - - case ns_t_dhcid: { - int n; - unsigned int siz; - char base64_dhcid[8192]; - const char *leader; - - siz = (int)(edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */ - if (siz > sizeof(base64_dhcid) * 3/4) { - const char *str = "record too long to print"; - T(addstr(str, strlen(str), &buf, &buflen)); - } else { - len = b64_ntop(rdata, (size_t)(edata-rdata), - base64_dhcid, siz); - - if (len < 0) - goto formerr; - - else if (len > 15) { - T(addstr(" (", 2, &buf, &buflen)); - leader = "\n\t\t"; - spaced = 0; - } - else - leader = " "; - - for (n = 0; n < len; n += 48) { - T(addstr(leader, strlen(leader), - &buf, &buflen)); - T(addstr(base64_dhcid + n, - (size_t)MIN(len - n, 48), &buf, &buflen)); - } - if (len > 15) - T(addstr(" )", 2, &buf, &buflen)); - } - break; - } - - case ns_t_ipseckey: { - int n; - unsigned int siz; - char base64_key[8192]; - const char *leader; - - if (rdlen < 2) - goto formerr; - - switch (rdata[1]) { - case 0: - case 3: - if (rdlen < 3) - goto formerr; - break; - case 1: - if (rdlen < 7) - goto formerr; - break; - case 2: - if (rdlen < 19) - goto formerr; - break; - default: - comment = "unknown IPSECKEY gateway type"; - goto hexify; - } - - len = SPRINTF((tmp, "%u ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - - len = SPRINTF((tmp, "%u ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - - len = SPRINTF((tmp, "%u ", *rdata)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - - switch (rdata[-2]) { - case 0: - T(addstr(".", 1, &buf, &buflen)); - break; - case 1: - (void) inet_ntop(AF_INET, rdata, buf, (socklen_t)buflen); - addlen(strlen(buf), &buf, &buflen); - rdata += 4; - break; - case 2: - (void) inet_ntop(AF_INET6, rdata, buf, (socklen_t)buflen); - addlen(strlen(buf), &buf, &buflen); - rdata += 16; - break; - case 3: - T(addname(msg, msglen, &rdata, origin, &buf, &buflen)); - break; - } - - if (rdata >= edata) - break; - - siz = (int)(edata-rdata)*4/3 + 4; /* "+4" accounts for trailing \0 */ - if (siz > sizeof(base64_key) * 3/4) { - const char *str = "record too long to print"; - T(addstr(str, strlen(str), &buf, &buflen)); - } else { - len = b64_ntop(rdata, (size_t)(edata-rdata), - base64_key, siz); - - if (len < 0) - goto formerr; - - else if (len > 15) { - T(addstr(" (", 2, &buf, &buflen)); - leader = "\n\t\t"; - spaced = 0; - } - else - leader = " "; - - for (n = 0; n < len; n += 48) { - T(addstr(leader, strlen(leader), - &buf, &buflen)); - T(addstr(base64_key + n, - (size_t)MIN(len - n, 48), &buf, &buflen)); - } - if (len > 15) - T(addstr(" )", 2, &buf, &buflen)); - } - break; - } - - case ns_t_hip: { - unsigned int i, hip_len, algorithm, key_len; - char base64_key[NS_MD5RSA_MAX_BASE64]; - unsigned int siz; - const char *leader = "\n\t\t\t\t\t"; - - hip_len = *rdata++; - algorithm = *rdata++; - key_len = ns_get16(rdata); - rdata += NS_INT16SZ; - - siz = key_len*4/3 + 4; /* "+4" accounts for trailing \0 */ - if (siz > sizeof(base64_key) * 3/4) { - const char *str = "record too long to print"; - T(addstr(str, strlen(str), &buf, &buflen)); - } else { - len = sprintf(tmp, "( %u ", algorithm); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - - for (i = 0; i < hip_len; i++) { - len = sprintf(tmp, "%02X", *rdata); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - rdata++; - } - T(addstr(leader, strlen(leader), &buf, &buflen)); - - len = b64_ntop(rdata, key_len, base64_key, siz); - if (len < 0) - goto formerr; - - T(addstr(base64_key, (size_t)len, &buf, &buflen)); - - rdata += key_len; - while (rdata < edata) { - T(addstr(leader, strlen(leader), &buf, &buflen)); - T(addname(msg, msglen, &rdata, origin, - &buf, &buflen)); - } - T(addstr(" )", 2, &buf, &buflen)); - } - break; - } - - default: - comment = "unknown RR type"; - goto hexify; - } - _DIAGASSERT(__type_fit(int, buf - obuf)); - return (int)(buf - obuf); - formerr: - comment = "RR format error"; - hexify: { - int n, m; - char *p; - - len = SPRINTF((tmp, "\\# %u%s\t; %s", (unsigned)(edata - rdata), - rdlen != 0U ? " (" : "", comment)); - T(addstr(tmp, (size_t)len, &buf, &buflen)); - while (rdata < edata) { - p = tmp; - p += SPRINTF((p, "\n\t")); - spaced = 0; - n = MIN(16, (int)(edata - rdata)); - for (m = 0; m < n; m++) - p += SPRINTF((p, "%02x ", rdata[m])); - T(addstr(tmp, (size_t)(p - tmp), &buf, &buflen)); - if (n < 16) { - T(addstr(")", (size_t)1, &buf, &buflen)); - T(addtab((size_t)(p - tmp + 1), (size_t)48, spaced, &buf, &buflen)); - } - p = tmp; - p += SPRINTF((p, "; ")); - for (m = 0; m < n; m++) - *p++ = (isascii(rdata[m]) && isprint(rdata[m])) - ? rdata[m] - : '.'; - T(addstr(tmp, (size_t)(p - tmp), &buf, &buflen)); - rdata += n; - } - _DIAGASSERT(__type_fit(int, buf - obuf)); - return (int)(buf - obuf); - } -} - -/* Private. */ - -/*% - * size_t - * prune_origin(name, origin) - * Find out if the name is at or under the current origin. - * return: - * Number of characters in name before start of origin, - * or length of name if origin does not match. - * notes: - * This function should share code with samedomain(). - */ -static size_t -prune_origin(const char *name, const char *origin) { - const char *oname = name; - - while (*name != '\0') { - if (origin != NULL && ns_samename(name, origin) == 1) - return (name - oname - (name > oname)); - while (*name != '\0') { - if (*name == '\\') { - name++; - /* XXX need to handle \nnn form. */ - if (*name == '\0') - break; - } else if (*name == '.') { - name++; - break; - } - name++; - } - } - return (name - oname); -} - -/*% - * int - * charstr(rdata, edata, buf, buflen) - * Format a into the presentation buffer. - * return: - * Number of rdata octets consumed - * 0 for protocol format error - * -1 for output buffer error - * side effects: - * buffer is advanced on success. - */ -static int -charstr(const u_char *rdata, const u_char *edata, char **buf, size_t *buflen) { - const u_char *odata = rdata; - size_t save_buflen = *buflen; - char *save_buf = *buf; - - if (addstr("\"", (size_t)1, buf, buflen) < 0) - goto enospc; - if (rdata < edata) { - int n = *rdata; - - if (rdata + 1 + n <= edata) { - rdata++; - while (n-- > 0) { - if (strchr("\n\"\\", *rdata) != NULL) - if (addstr("\\", (size_t)1, buf, buflen) < 0) - goto enospc; - if (addstr((const char *)rdata, (size_t)1, - buf, buflen) < 0) - goto enospc; - rdata++; - } - } - } - if (addstr("\"", (size_t)1, buf, buflen) < 0) - goto enospc; - _DIAGASSERT(__type_fit(int, rdata - odata)); - return (int)(rdata - odata); - enospc: - errno = ENOSPC; - *buf = save_buf; - *buflen = save_buflen; - return (-1); -} - -static int -addname(const u_char *msg, size_t msglen, - const u_char **pp, const char *origin, - char **buf, size_t *buflen) -{ - size_t newlen, save_buflen = *buflen; - char *save_buf = *buf; - int n; - - n = dn_expand(msg, msg + msglen, *pp, *buf, (int)*buflen); - if (n < 0) - goto enospc; /*%< Guess. */ - newlen = prune_origin(*buf, origin); - if (**buf == '\0') { - goto root; - } else if (newlen == 0U) { - /* Use "@" instead of name. */ - if (newlen + 2 > *buflen) - goto enospc; /* No room for "@\0". */ - (*buf)[newlen++] = '@'; - (*buf)[newlen] = '\0'; - } else { - if (((origin == NULL || origin[0] == '\0') || - (origin[0] != '.' && origin[1] != '\0' && - (*buf)[newlen] == '\0')) && (*buf)[newlen - 1] != '.') { - /* No trailing dot. */ - root: - if (newlen + 2 > *buflen) - goto enospc; /* No room for ".\0". */ - (*buf)[newlen++] = '.'; - (*buf)[newlen] = '\0'; - } - } - *pp += n; - addlen(newlen, buf, buflen); - **buf = '\0'; - _DIAGASSERT(__type_fit(int, newlen)); - return (int)newlen; - enospc: - errno = ENOSPC; - *buf = save_buf; - *buflen = save_buflen; - return (-1); -} - -static void -addlen(size_t len, char **buf, size_t *buflen) { - INSIST(len <= *buflen); - *buf += len; - *buflen -= len; -} - -static int -addstr(const char *src, size_t len, char **buf, size_t *buflen) { - if (len >= *buflen) { - errno = ENOSPC; - return (-1); - } - memcpy(*buf, src, len); - addlen(len, buf, buflen); - **buf = '\0'; - return (0); -} - -static int -addtab(size_t len, size_t target, int spaced, char **buf, size_t *buflen) { - size_t save_buflen = *buflen; - char *save_buf = *buf; - ptrdiff_t t; - - if (spaced || len >= target - 1) { - T(addstr(" ", (size_t)2, buf, buflen)); - spaced = 1; - } else { - for (t = (target - len - 1) / 8; t >= 0; t--) - if (addstr("\t", (size_t)1, buf, buflen) < 0) { - *buflen = save_buflen; - *buf = save_buf; - return (-1); - } - spaced = 0; - } - return (spaced); -} - -/*! \file */ diff --git a/lib/libc/nameser/ns_samedomain.c b/lib/libc/nameser/ns_samedomain.c deleted file mode 100644 index 9b8f863ae..000000000 --- a/lib/libc/nameser/ns_samedomain.c +++ /dev/null @@ -1,216 +0,0 @@ -/* $NetBSD: ns_samedomain.c,v 1.8 2012/11/22 20:22:31 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1995,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#ifndef lint -#ifdef notdef -static const char rcsid[] = "Id: ns_samedomain.c,v 1.6 2005/04/27 04:56:40 sra Exp"; -#else -__RCSID("$NetBSD: ns_samedomain.c,v 1.8 2012/11/22 20:22:31 christos Exp $"); -#endif -#endif - -#include "port_before.h" - -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef _LIBRESOLV -/*% - * Check whether a name belongs to a domain. - * - * Inputs: - *\li a - the domain whose ancestory is being verified - *\li b - the potential ancestor we're checking against - * - * Return: - *\li boolean - is a at or below b? - * - * Notes: - *\li Trailing dots are first removed from name and domain. - * Always compare complete subdomains, not only whether the - * domain name is the trailing string of the given name. - * - *\li "host.foobar.top" lies in "foobar.top" and in "top" and in "" - * but NOT in "bar.top" - */ - -int -ns_samedomain(const char *a, const char *b) { - size_t la, lb, i; - int diff, escaped; - const char *cp; - - la = strlen(a); - lb = strlen(b); - - /* Ignore a trailing label separator (i.e. an unescaped dot) in 'a'. */ - if (la != 0U && a[la - 1] == '.') { - escaped = 0; - /* Note this loop doesn't get executed if la==1. */ - for (i = la - 1; i > 0; i--) - if (a[i - 1] == '\\') { - if (escaped) - escaped = 0; - else - escaped = 1; - } else - break; - if (!escaped) - la--; - } - - /* Ignore a trailing label separator (i.e. an unescaped dot) in 'b'. */ - if (lb != 0U && b[lb - 1] == '.') { - escaped = 0; - /* note this loop doesn't get executed if lb==1 */ - for (i = lb - 1; i > 0; i--) - if (b[i - 1] == '\\') { - if (escaped) - escaped = 0; - else - escaped = 1; - } else - break; - if (!escaped) - lb--; - } - - /* lb == 0 means 'b' is the root domain, so 'a' must be in 'b'. */ - if (lb == 0U) - return (1); - - /* 'b' longer than 'a' means 'a' can't be in 'b'. */ - if (lb > la) - return (0); - - /* 'a' and 'b' being equal at this point indicates sameness. */ - if (lb == la) - return (strncasecmp(a, b, lb) == 0); - - /* Ok, we know la > lb. */ - - diff = (int)(la - lb); - - /* - * If 'a' is only 1 character longer than 'b', then it can't be - * a subdomain of 'b' (because of the need for the '.' label - * separator). - */ - if (diff < 2) - return (0); - - /* - * If the character before the last 'lb' characters of 'b' - * isn't '.', then it can't be a match (this lets us avoid - * having "foobar.com" match "bar.com"). - */ - if (a[diff - 1] != '.') - return (0); - - /* - * We're not sure about that '.', however. It could be escaped - * and thus not a really a label separator. - */ - escaped = 0; - for (i = diff - 1; i > 0; i--) - if (a[i - 1] == '\\') { - if (escaped) - escaped = 0; - else - escaped = 1; - } else - break; - if (escaped) - return (0); - - /* Now compare aligned trailing substring. */ - cp = a + diff; - return (strncasecmp(cp, b, lb) == 0); -} - -/*% - * is "a" a subdomain of "b"? - */ -int -ns_subdomain(const char *a, const char *b) { - return (ns_samename(a, b) != 1 && ns_samedomain(a, b)); -} -#endif -#ifdef _LIBC -/*% - * make a canonical copy of domain name "src" - * - * notes: - * \code - * foo -> foo. - * foo. -> foo. - * foo.. -> foo. - * foo\. -> foo\.. - * foo\\. -> foo\\. - * \endcode - */ - -int -ns_makecanon(const char *src, char *dst, size_t dstsize) { - size_t n = strlen(src); - - if (n + sizeof "." > dstsize) { /*%< Note: sizeof == 2 */ - errno = EMSGSIZE; - return (-1); - } - strcpy(dst, src); - while (n >= 1U && dst[n - 1] == '.') /*%< Ends in "." */ - if (n >= 2U && dst[n - 2] == '\\' && /*%< Ends in "\." */ - (n < 3U || dst[n - 3] != '\\')) /*%< But not "\\." */ - break; - else - dst[--n] = '\0'; - dst[n++] = '.'; - dst[n] = '\0'; - return (0); -} - -/*% - * determine whether domain name "a" is the same as domain name "b" - * - * return: - *\li -1 on error - *\li 0 if names differ - *\li 1 if names are the same - */ - -int -ns_samename(const char *a, const char *b) { - char ta[NS_MAXDNAME], tb[NS_MAXDNAME]; - - if (ns_makecanon(a, ta, sizeof ta) < 0 || - ns_makecanon(b, tb, sizeof tb) < 0) - return (-1); - if (strcasecmp(ta, tb) == 0) - return (1); - else - return (0); -} -#endif -/*! \file */ diff --git a/lib/libc/nameser/ns_ttl.c b/lib/libc/nameser/ns_ttl.c deleted file mode 100644 index e895e5a5b..000000000 --- a/lib/libc/nameser/ns_ttl.c +++ /dev/null @@ -1,173 +0,0 @@ -/* $NetBSD: ns_ttl.c,v 1.8 2012/03/13 21:13:39 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996,1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#ifndef lint -#ifdef notdef -static const char rcsid[] = "Id: ns_ttl.c,v 1.4 2005/07/28 06:51:49 marka Exp"; -#else -__RCSID("$NetBSD: ns_ttl.c,v 1.8 2012/03/13 21:13:39 christos Exp $"); -#endif -#endif - -/* Import. */ - -#include "port_before.h" - -#include - -#include -#include -#include -#include -#include - -#include "port_after.h" - -#ifdef SPRINTF_CHAR -# define SPRINTF(x) strlen(sprintf/**/x) -#else -# define SPRINTF(x) ((size_t)sprintf x) -#endif - -/* Forward. */ - -static int fmt1(int t, char s, char **buf, size_t *buflen); - -/* Macros. */ - -#define T(x) if ((x) < 0) return (-1) - -/* Public. */ - -int -ns_format_ttl(u_long src, char *dst, size_t dstlen) { - char *odst = dst; - int secs, mins, hours, days, weeks, x; - char *p; - - secs = (int)(src % 60); src /= 60; - mins = (int)(src % 60); src /= 60; - hours = (int)(src % 24); src /= 24; - days = (int)(src % 7); src /= 7; - weeks = (int)src; src = 0; - - x = 0; - if (weeks) { - T(fmt1(weeks, 'W', &dst, &dstlen)); - x++; - } - if (days) { - T(fmt1(days, 'D', &dst, &dstlen)); - x++; - } - if (hours) { - T(fmt1(hours, 'H', &dst, &dstlen)); - x++; - } - if (mins) { - T(fmt1(mins, 'M', &dst, &dstlen)); - x++; - } - if (secs || !(weeks || days || hours || mins)) { - T(fmt1(secs, 'S', &dst, &dstlen)); - x++; - } - - if (x > 1) { - int ch; - - for (p = odst; (ch = *p) != '\0'; p++) - if (isascii(ch) && isupper(ch)) - *p = tolower(ch); - } - - _DIAGASSERT(__type_fit(int, dst - odst)); - return (int)(dst - odst); -} - -#ifndef _LIBC -int -ns_parse_ttl(const char *src, u_long *dst) { - u_long ttl, tmp; - int ch, digits, dirty; - - ttl = 0; - tmp = 0; - digits = 0; - dirty = 0; - while ((ch = *src++) != '\0') { - if (!isascii(ch) || !isprint(ch)) - goto einval; - if (isdigit(ch)) { - tmp *= 10; - tmp += (ch - '0'); - digits++; - continue; - } - if (digits == 0) - goto einval; - if (islower(ch)) - ch = toupper(ch); - switch (ch) { - case 'W': tmp *= 7; /*FALLTHROUGH*/ - case 'D': tmp *= 24; /*FALLTHROUGH*/ - case 'H': tmp *= 60; /*FALLTHROUGH*/ - case 'M': tmp *= 60; /*FALLTHROUGH*/ - case 'S': break; - default: goto einval; - } - ttl += tmp; - tmp = 0; - digits = 0; - dirty = 1; - } - if (digits > 0) { - if (dirty) - goto einval; - else - ttl += tmp; - } else if (!dirty) - goto einval; - *dst = ttl; - return (0); - - einval: - errno = EINVAL; - return (-1); -} -#endif - -/* Private. */ - -static int -fmt1(int t, char s, char **buf, size_t *buflen) { - char tmp[50]; - size_t len; - - len = SPRINTF((tmp, "%d%c", t, s)); - if (len + 1 > *buflen) - return (-1); - strcpy(*buf, tmp); - *buf += len; - *buflen -= len; - return (0); -} - -/*! \file */ diff --git a/lib/libc/net/Lint_htonl.c b/lib/libc/net/Lint_htonl.c deleted file mode 100644 index e1d7e03bf..000000000 --- a/lib/libc/net/Lint_htonl.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_htonl.c,v 1.4 2001/08/22 07:42:08 itojun Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include -#undef htonl - -/*ARGSUSED*/ -uint32_t -htonl(host32) - uint32_t host32; -{ - return (0); -} diff --git a/lib/libc/net/Lint_htons.c b/lib/libc/net/Lint_htons.c deleted file mode 100644 index f0b06b292..000000000 --- a/lib/libc/net/Lint_htons.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_htons.c,v 1.4 2001/08/22 07:42:09 itojun Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include -#undef htons - -/*ARGSUSED*//*NOSTRICT*/ -uint16_t -htons(host16) - uint16_t host16; -{ - return (0); -} diff --git a/lib/libc/net/Lint_ntohl.c b/lib/libc/net/Lint_ntohl.c deleted file mode 100644 index c2be9e467..000000000 --- a/lib/libc/net/Lint_ntohl.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_ntohl.c,v 1.4 2001/08/22 07:42:09 itojun Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include -#undef ntohl - -/*ARGSUSED*/ -uint32_t -ntohl(net32) - uint32_t net32; -{ - return (0); -} diff --git a/lib/libc/net/Lint_ntohs.c b/lib/libc/net/Lint_ntohs.c deleted file mode 100644 index 6841907e4..000000000 --- a/lib/libc/net/Lint_ntohs.c +++ /dev/null @@ -1,17 +0,0 @@ -/* $NetBSD: Lint_ntohs.c,v 1.4 2001/08/22 07:42:09 itojun Exp $ */ - -/* - * This file placed in the public domain. - * Chris Demetriou, November 5, 1997. - */ - -#include -#undef ntohs - -/*ARGSUSED*//*NOSTRICT*/ -uint16_t -ntohs(net16) - uint16_t net16; -{ - return (0); -} diff --git a/lib/libc/net/Makefile.inc b/lib/libc/net/Makefile.inc deleted file mode 100644 index fa29213c5..000000000 --- a/lib/libc/net/Makefile.inc +++ /dev/null @@ -1,146 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.86 2015/04/15 19:13:46 mrg Exp $ -# @(#)Makefile.inc 8.2 (Berkeley) 9/5/93 - -# net sources -.PATH: ${ARCHDIR}/net ${.CURDIR}/net - -SRCS+= base64.c ethers.c gethnamaddr.c getifaddrs.c \ - getnetnamadr.c getnetent.c getpeereid.c \ - getprotobyname.c getprotobynumber.c getprotoent.c \ - getprotobyname_r.c getprotobynumber_r.c getprotoent_r.c \ - getservbyname.c getservbyport.c getservent.c \ - getservbyname_r.c getservbyport_r.c getservent_r.c \ - iso_addr.c linkaddr.c \ - nsdispatch.c nslexer.l nsparser.y nsap_addr.c \ - rcmd.c recv.c send.c sethostent.c \ - sockatmark.c - -.if (${MKHESIOD} != "no") -SRCS+= hesiod.c -.endif - -SRCS+= getaddrinfo.c getnameinfo.c -.if (${USE_INET6} != "no") -SRCS+= ip6opt.c rthdr.c vars6.c inet6_scopeid.c -.endif -SRCS+= if_indextoname.c if_nameindex.c if_nametoindex.c - -LPREFIX=_nsyy -YPREFIX=_nsyy -YHEADER=1 - -CLEANFILES+=nsparser.c nslexer.c nsparser.h - -nslexer.c: nslexer.l nsparser.h - ${_MKTARGET_LEX} - ${LEX.l} -t ${.IMPSRC} | sed -e '/YY_BUF_SIZE/s/16384/1024/' >${.TARGET} - -# machine-dependent net sources -# m-d Makefile.inc must include sources for: -# htonl() htons() ntohl() ntohs() - -.include "${ARCHDIR}/net/Makefile.inc" - -MAN+= byteorder.3 ethers.3 gethostbyname.3 getifaddrs.3 \ - getnetent.3 getprotoent.3 getpeereid.3 \ - getservent.3 inet.3 inet_net.3 linkaddr.3 \ - nsdispatch.3 rcmd.3 resolver.3 sockatmark.3 - -.if (${MKHESIOD} != "no") -MAN+= hesiod.3 -.endif - -MLINKS+=byteorder.3 htonl.3 byteorder.3 htons.3 byteorder.3 ntohl.3 \ - byteorder.3 ntohs.3 -MLINKS+=ethers.3 ether_aton.3 ethers.3 ether_hostton.3 ethers.3 ether_line.3 \ - ethers.3 ether_ntoa.3 ethers.3 ether_ntohost.3 -MLINKS+=gethostbyname.3 endhostent.3 gethostbyname.3 gethostbyaddr.3 \ - gethostbyname.3 gethostent.3 gethostbyname.3 sethostent.3 \ - gethostbyname.3 herror.3 gethostbyname.3 hstrerror.3 \ - gethostbyname.3 gethostbyname2.3 -MLINKS+=getnetent.3 endnetent.3 getnetent.3 getnetbyaddr.3 \ - getnetent.3 getnetbyname.3 getnetent.3 setnetent.3 -MLINKS+=getprotoent.3 endprotoent.3 getprotoent.3 getprotobyname.3 \ - getprotoent.3 getprotobynumber.3 getprotoent.3 setprotoent.3 -MLINKS+=getservent.3 endservent.3 getservent.3 getservbyname.3 \ - getservent.3 getservbyport.3 getservent.3 setservent.3 -.if (${MKHESIOD} != "no") -MLINKS+=hesiod.3 hesiod_end.3 hesiod.3 hesiod_free_list.3 \ - hesiod.3 hesiod_init.3 hesiod.3 hesiod_resolve.3 \ - hesiod.3 hesiod_to_bind.3 -.endif -MLINKS+=inet.3 addr.3 inet.3 inet_addr.3 inet.3 inet_aton.3 \ - inet.3 inet_lnaof.3 inet.3 inet_makeaddr.3 inet.3 inet_netof.3 \ - inet.3 inet_network.3 inet.3 inet_ntoa.3 inet.3 network.3 \ - inet.3 ntoa.3 inet.3 inet_ntop.3 inet.3 inet_pton.3 -MLINKS+=inet_net.3 inet_net_ntop.3 inet_net.3 inet_net_pton.3 -MLINKS+=linkaddr.3 link_addr.3 linkaddr.3 link_ntoa.3 linkaddr.3 linkntoa.3 -MLINKS+=rcmd.3 iruserok.3 rcmd.3 rresvport.3 rcmd.3 ruserok.3 rcmd.3 orcmd.3 -MLINKS+=resolver.3 dn_comp.3 \ - resolver.3 dn_expand.3 \ - resolver.3 fp_nquery.3 \ - resolver.3 fp_resstat.3 \ - resolver.3 hostalias.3 \ - resolver.3 p_query.3 \ - resolver.3 res_close.3 \ - resolver.3 res_findzonecut.3 \ - resolver.3 res_getservers.3 \ - resolver.3 res_hostalias.3 \ - resolver.3 res_init.3 \ - resolver.3 res_isourserver.3 \ - resolver.3 res_mkquery.3 \ - resolver.3 res_nclose.3 \ - resolver.3 res_ndestroy.3 \ - resolver.3 res_ninit.3 \ - resolver.3 res_nmkquery.3 \ - resolver.3 res_nmkupdate.3 \ - resolver.3 res_nquery.3 \ - resolver.3 res_nquerydomain.3 \ - resolver.3 res_nsearch.3 \ - resolver.3 res_nsend.3 \ - resolver.3 res_nsendsigned.3 \ - resolver.3 res_nupdate.3 \ - resolver.3 res_ourserver_p.3 \ - resolver.3 res_pquery.3 \ - resolver.3 res_query.3 \ - resolver.3 res_querydomain.3 \ - resolver.3 res_search.3 \ - resolver.3 res_send.3 \ - resolver.3 res_setservers.3 \ - resolver.3 res_update.3 - -# IPv6 -MAN+= gai_strerror.3 getaddrinfo.3 getnameinfo.3 if_indextoname.3 \ - inet6_option_space.3 inet6_rthdr_space.3 \ - inet6_opt_init.3 inet6_rth_space.3 inet6_getscopeid.3 -MLINKS+=getaddrinfo.3 freeaddrinfo.3 \ - getaddrinfo.3 allocaddrinfo.3 \ - getifaddrs.3 freeifaddrs.3 \ - if_indextoname.3 if_nametoindex.3 if_indextoname.3 if_nameindex.3 \ - if_indextoname.3 if_freenameindex.3 \ - inet6_getscopeid.3 inet6_putscopeid.3 \ - inet6_option_space.3 inet6_option_init.3 \ - inet6_option_space.3 inet6_option_append.3 \ - inet6_option_space.3 inet6_option_alloc.3 \ - inet6_option_space.3 inet6_option_next.3 \ - inet6_option_space.3 inet6_option_find.3 \ - inet6_rthdr_space.3 inet6_rthdr_init.3 \ - inet6_rthdr_space.3 inet6_rthdr_add.3 \ - inet6_rthdr_space.3 inet6_rthdr_lasthop.3 \ - inet6_rthdr_space.3 inet6_rthdr_reverse.3 \ - inet6_rthdr_space.3 inet6_rthdr_segments.3 \ - inet6_rthdr_space.3 inet6_rthdr_getaddr.3 \ - inet6_rthdr_space.3 inet6_rthdr_getflags.3 \ - inet6_opt_init.3 inet6_opt_append.3 \ - inet6_opt_init.3 inet6_opt_finish.3 \ - inet6_opt_init.3 inet6_opt_set_val.3 \ - inet6_opt_init.3 inet6_opt_next.3 \ - inet6_opt_init.3 inet6_opt_find.3 \ - inet6_opt_init.3 inet6_opt_get_val.3 \ - inet6_rth_space.3 inet6_rth_init.3 \ - inet6_rth_space.3 inet6_rth_add.3 \ - inet6_rth_space.3 inet6_rth_reverse.3 \ - inet6_rth_space.3 inet6_rth_segments.3 \ - inet6_rth_space.3 inet6_rth_getaddr.3 \ - rcmd.3 rcmd_af.3 rcmd.3 iruserok_sa.3 rcmd.3 rresvport_af.3 \ - rcmd.3 orcmd_af.3 diff --git a/lib/libc/net/base64.c b/lib/libc/net/base64.c deleted file mode 100644 index 053cfd17c..000000000 --- a/lib/libc/net/base64.c +++ /dev/null @@ -1,350 +0,0 @@ -/* $NetBSD: base64.c,v 1.16 2014/11/24 15:43:21 christos Exp $ */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -/* - * Portions Copyright (c) 1995 by International Business Machines, Inc. - * - * International Business Machines, Inc. (hereinafter called IBM) grants - * permission under its copyrights to use, copy, modify, and distribute this - * Software with or without fee, provided that the above copyright notice and - * all paragraphs of this notice appear in all copies, and that the name of IBM - * not be used in connection with the marketing of any product incorporating - * the Software or modifications thereof, without specific, written prior - * permission. - * - * To the extent it has a right to do so, IBM grants an immunity from suit - * under its patents, if any, for the use, sale or manufacture of products to - * the extent that such products are used for performing Domain Name System - * dynamic updates in TCP/IP networks by means of the Software. No immunity is - * granted for any product per se or for any other function of any product. - * - * THE SOFTWARE IS PROVIDED "AS IS", AND IBM DISCLAIMS ALL WARRANTIES, - * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A - * PARTICULAR PURPOSE. IN NO EVENT SHALL IBM BE LIABLE FOR ANY SPECIAL, - * DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER ARISING - * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE, EVEN - * IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static const char rcsid[] = "Id: base64.c,v 1.4 2005/04/27 04:56:34 sra Exp"; -#else -__RCSID("$NetBSD: base64.c,v 1.16 2014/11/24 15:43:21 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "port_before.h" - -#include -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "port_after.h" - -#define Assert(Cond) if (!(Cond)) abort() - -static const char Base64[] = - "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; -static const char Pad64 = '='; - -/* (From RFC1521 and draft-ietf-dnssec-secext-03.txt) - The following encoding technique is taken from RFC1521 by Borenstein - and Freed. It is reproduced here in a slightly edited form for - convenience. - - A 65-character subset of US-ASCII is used, enabling 6 bits to be - represented per printable character. (The extra 65th character, "=", - is used to signify a special processing function.) - - The encoding process represents 24-bit groups of input bits as output - strings of 4 encoded characters. Proceeding from left to right, a - 24-bit input group is formed by concatenating 3 8-bit input groups. - These 24 bits are then treated as 4 concatenated 6-bit groups, each - of which is translated into a single digit in the base64 alphabet. - - Each 6-bit group is used as an index into an array of 64 printable - characters. The character referenced by the index is placed in the - output string. - - Table 1: The Base64 Alphabet - - Value Encoding Value Encoding Value Encoding Value Encoding - 0 A 17 R 34 i 51 z - 1 B 18 S 35 j 52 0 - 2 C 19 T 36 k 53 1 - 3 D 20 U 37 l 54 2 - 4 E 21 V 38 m 55 3 - 5 F 22 W 39 n 56 4 - 6 G 23 X 40 o 57 5 - 7 H 24 Y 41 p 58 6 - 8 I 25 Z 42 q 59 7 - 9 J 26 a 43 r 60 8 - 10 K 27 b 44 s 61 9 - 11 L 28 c 45 t 62 + - 12 M 29 d 46 u 63 / - 13 N 30 e 47 v - 14 O 31 f 48 w (pad) = - 15 P 32 g 49 x - 16 Q 33 h 50 y - - Special processing is performed if fewer than 24 bits are available - at the end of the data being encoded. A full encoding quantum is - always completed at the end of a quantity. When fewer than 24 input - bits are available in an input group, zero bits are added (on the - right) to form an integral number of 6-bit groups. Padding at the - end of the data is performed using the '=' character. - - Since all base64 input is an integral number of octets, only the - ------------------------------------------------- - following cases can arise: - - (1) the final quantum of encoding input is an integral - multiple of 24 bits; here, the final unit of encoded - output will be an integral multiple of 4 characters - with no "=" padding, - (2) the final quantum of encoding input is exactly 8 bits; - here, the final unit of encoded output will be two - characters followed by two "=" padding characters, or - (3) the final quantum of encoding input is exactly 16 bits; - here, the final unit of encoded output will be three - characters followed by one "=" padding character. - */ - -int -b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize) { - size_t datalength = 0; - u_char input[3]; - u_char output[4]; - size_t i; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(target != NULL); - - while (2U < srclength) { - input[0] = *src++; - input[1] = *src++; - input[2] = *src++; - srclength -= 3; - - output[0] = (uint32_t)input[0] >> 2; - output[1] = ((uint32_t)(input[0] & 0x03) << 4) + - ((uint32_t)input[1] >> 4); - output[2] = ((uint32_t)(input[1] & 0x0f) << 2) + - ((uint32_t)input[2] >> 6); - output[3] = input[2] & 0x3f; - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); - Assert(output[3] < 64); - - if (datalength + 4 > targsize) - return -1; - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - target[datalength++] = Base64[output[2]]; - target[datalength++] = Base64[output[3]]; - } - - /* Now we worry about padding. */ - if (0U != srclength) { - /* Get what's left. */ - input[0] = input[1] = input[2] = '\0'; - for (i = 0; i < srclength; i++) - input[i] = *src++; - - output[0] = (uint32_t)input[0] >> 2; - output[1] = ((uint32_t)(input[0] & 0x03) << 4) + - ((uint32_t)input[1] >> 4); - output[2] = ((uint32_t)(input[1] & 0x0f) << 2) + - ((uint32_t)input[2] >> 6); - Assert(output[0] < 64); - Assert(output[1] < 64); - Assert(output[2] < 64); - - if (datalength + 4 > targsize) - return -1; - target[datalength++] = Base64[output[0]]; - target[datalength++] = Base64[output[1]]; - if (srclength == 1U) - target[datalength++] = Pad64; - else - target[datalength++] = Base64[output[2]]; - target[datalength++] = Pad64; - } - if (datalength >= targsize) - return -1; - target[datalength] = '\0'; /*%< Returned value doesn't count \\0. */ - _DIAGASSERT(__type_fit(int, datalength)); - return (int)datalength; -} - -/* skips all whitespace anywhere. - converts characters, four at a time, starting at (or after) - src from base - 64 numbers into three 8 bit bytes in the target area. - it returns the number of data bytes stored at the target, or -1 on error. - */ - -int -b64_pton(char const *src, u_char *target, size_t targsize) -{ - size_t tarindex; - int state, ch; - u_char nextbyte; - char *pos; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(target != NULL); - - state = 0; - tarindex = 0; - - while ((ch = (u_char) *src++) != '\0') { - if (isspace(ch)) /*%< Skip whitespace anywhere. */ - continue; - - if (ch == Pad64) - break; - - pos = strchr(Base64, ch); - if (pos == NULL) /*%< A non-base64 character. */ - return -1; - - switch (state) { - case 0: - if (target) { - if (tarindex >= targsize) - return -1; - target[tarindex] = (u_char)(pos - Base64) << 2; - } - state = 1; - break; - case 1: - if (target) { - if (tarindex >= targsize) - return -1; - target[tarindex] |= - (uint32_t)(pos - Base64) >> 4; - nextbyte = (u_char)((pos - Base64) & 0x0f) << 4; - if (tarindex + 1 < targsize) - target[tarindex + 1] = nextbyte; - else if (nextbyte) - return -1; - } - tarindex++; - state = 2; - break; - case 2: - if (target) { - if (tarindex >= targsize) - return -1; - target[tarindex] |= - (uint32_t)(pos - Base64) >> 2; - nextbyte = (u_char)((pos - Base64) & 0x03) << 6; - if (tarindex + 1 < targsize) - target[tarindex + 1] = nextbyte; - else if (nextbyte) - return -1; - } - tarindex++; - state = 3; - break; - case 3: - if (target) { - if ((size_t)tarindex >= targsize) - return -1; - target[tarindex] |= (u_char)(pos - Base64); - } - tarindex++; - state = 0; - break; - default: - abort(); - } - } - - /* - * We are done decoding Base-64 chars. Let's see if we ended - * on a byte boundary, and/or with erroneous trailing characters. - */ - - if (ch == Pad64) { /*%< We got a pad char. */ - ch = *src++; /*%< Skip it, get next. */ - switch (state) { - case 0: /*%< Invalid = in first position */ - case 1: /*%< Invalid = in second position */ - return -1; - - case 2: /*%< Valid, means one byte of info */ - /* Skip any number of spaces. */ - for (; ch != '\0'; ch = (u_char) *src++) - if (!isspace(ch)) - break; - /* Make sure there is another trailing = sign. */ - if (ch != Pad64) - return -1; - ch = *src++; /*%< Skip the = */ - /* Fall through to "single trailing =" case. */ - /* FALLTHROUGH */ - - case 3: /*%< Valid, means two bytes of info */ - /* - * We know this char is an =. Is there anything but - * whitespace after it? - */ - for (; ch != '\0'; ch = (u_char) *src++) - if (!isspace(ch)) - return -1; - - /* - * Now make sure for cases 2 and 3 that the "extra" - * bits that slopped past the last full byte were - * zeros. If we don't check them, they become a - * subliminal channel. - */ - if (target && tarindex < targsize && - target[tarindex] != 0) - return -1; - } - } else { - /* - * We ended by seeing the end of the string. Make sure we - * have no partial bytes lying around. - */ - if (state != 0) - return -1; - } - - _DIAGASSERT(__type_fit(int, tarindex)); - return (int)tarindex; -} - -/*! \file */ diff --git a/lib/libc/net/byteorder.3 b/lib/libc/net/byteorder.3 deleted file mode 100644 index 68502eb96..000000000 --- a/lib/libc/net/byteorder.3 +++ /dev/null @@ -1,80 +0,0 @@ -.\" $NetBSD: byteorder.3,v 1.15 2011/05/03 04:07:39 jruoho Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)byteorder.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd May 3, 2011 -.Dt BYTEORDER 3 -.Os -.Sh NAME -.Nm htonl , -.Nm htons , -.Nm ntohl , -.Nm ntohs -.Nd convert values between host and network byte order -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In arpa/inet.h -.Ft uint32_t -.Fn htonl "uint32_t host32" -.Ft uint16_t -.Fn htons "uint16_t host16" -.Ft uint32_t -.Fn ntohl "uint32_t net32" -.Ft uint16_t -.Fn ntohs "uint16_t net16" -.Sh DESCRIPTION -These routines convert 16 and 32 bit quantities between network -byte order and host byte order. -.Pp -On machines which have a byte order which is the same as the network -order, these routines are defined as macros that expand to the value of -their argument. -.Pp -These routines are most often used in conjunction with Internet -addresses and ports as returned by -.Xr gethostbyname 3 -and -.Xr getservent 3 . -.Sh SEE ALSO -.Xr bswap 3 , -.Xr gethostbyname 3 , -.Xr getservent 3 -.Sh STANDARDS -The described functions conform to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Nm byteorder -functions appeared in -.Bx 4.2 . -.Sh BUGS -The `l' and `s' suffixes in the names are not meaningful in machines -where long integers are not 32 bits. diff --git a/lib/libc/net/ethers.3 b/lib/libc/net/ethers.3 deleted file mode 100644 index 212ed1fde..000000000 --- a/lib/libc/net/ethers.3 +++ /dev/null @@ -1,120 +0,0 @@ -.\" $NetBSD: ethers.3,v 1.13 2003/04/16 13:34:41 wiz Exp $ -.\" -.\" Written by roland@frob.com. Public domain. -.\" -.Dd November 2, 1997 -.Dt ETHERS 3 -.Os -.Sh NAME -.Nm ether_ntoa , -.Nm ether_aton , -.Nm ether_ntohost , -.Nm ether_hostton , -.Nm ether_line , -.Nd get ethers entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h -.In net/if.h -.In net/if_ether.h -.Ft char * -.Fn ether_ntoa "const struct ether_addr *e" -.Ft struct ether_addr * -.Fn ether_aton "const char *s" -.Ft int -.Fn ether_ntohost "char *hostname" "const struct ether_addr *e" -.Ft int -.Fn ether_hostton "const char *hostname" "struct ether_addr *e" -.Ft int -.Fn ether_line "const char *line" "struct ether_addr *e" "char *hostname" -.Sh DESCRIPTION -Ethernet addresses are represented by the -following structure: -.Bd -literal -offset indent -struct ether_addr { - u_char ether_addr_octet[6]; -}; -.Ed -.Pp -The -.Fn ether_ntoa -function converts this structure into an ASCII string of the form -``xx:xx:xx:xx:xx:xx'', consisting of 6 hexadecimal numbers separated -by colons. It returns a pointer to a static buffer that is reused for -each call. -The -.Fn ether_aton -converts an ASCII string of the same form and to a structure -containing the 6 octets of the address. It returns a pointer to a -static structure that is reused for each call. -.Pp -The -.Fn ether_ntohost -and -.Fn ether_hostton -functions interrogate the data base mapping host names to Ethernet -addresses, -.Pa /etc/ethers . -The -.Fn ether_ntohost -function looks up the given Ethernet address and writes the associated -host name into the character buffer passed. -The -.Fn ether_hostton -function looks up the given host name and writes the associated -Ethernet address into the structure passed. Both functions return -zero if they find the requested host name or address, and -1 if not. -Each call reads -.Pa /etc/ethers -from the beginning; if a + appears alone on a line in the file, then -.Fn ether_hostton -will consult the -.Pa ethers.byname -YP map, and -.Fn ether_ntohost -will consult the -.Pa ethers.byaddr -YP map. -.Pp -The -.Fn ether_line -function parses a line from the -.Pa /etc/ethers -file and fills in the passed ``struct ether_addr'' and character -buffer with the Ethernet address and host name on the line. It -returns zero if the line was successfully parsed and -1 if not. -.Pp -The -.Fa hostname -buffer for -.Fn ether_line -and -.Fn ether_ntohost -should be at least -.Dv MAXHOSTNAMELEN -+ 1 -characters long, to prevent a buffer overflow during parsing. -.Sh FILES -.Bl -tag -width /etc/ethers -compact -.It Pa /etc/ethers -.El -.Sh SEE ALSO -.Xr ethers 5 -.Sh HISTORY -The -.Fn ether_ntoa , -.Fn ether_aton , -.Fn ether_ntohost , -.Fn ether_hostton , -and -.Fn ether_line -functions were adopted from -.Tn SunOS -and appeared in -.Nx 1.0 . -.Sh BUGS -The data space used by these functions is static; if future use -requires the data, it should be copied before any subsequent calls to -these functions overwrite it. diff --git a/lib/libc/net/ethers.c b/lib/libc/net/ethers.c deleted file mode 100644 index 3cafbde36..000000000 --- a/lib/libc/net/ethers.c +++ /dev/null @@ -1,221 +0,0 @@ -/* $NetBSD: ethers.c,v 1.25 2014/09/18 13:58:20 christos Exp $ */ - -/* - * ethers(3N) a la Sun. - * - * Written by Roland McGrath 10/14/93. - * Public domain. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ethers.c,v 1.25 2014/09/18 13:58:20 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#ifdef YP -#include -#endif - -#ifdef __weak_alias -__weak_alias(ether_aton,_ether_aton) -__weak_alias(ether_hostton,_ether_hostton) -__weak_alias(ether_line,_ether_line) -__weak_alias(ether_ntoa,_ether_ntoa) -__weak_alias(ether_ntohost,_ether_ntohost) -#endif - -#ifndef _PATH_ETHERS -#define _PATH_ETHERS "/etc/ethers" -#endif - -char * -ether_ntoa(const struct ether_addr *e) -{ - static char a[18]; - - _DIAGASSERT(e != NULL); - - (void) snprintf(a, sizeof a, "%02x:%02x:%02x:%02x:%02x:%02x", - e->ether_addr_octet[0], e->ether_addr_octet[1], - e->ether_addr_octet[2], e->ether_addr_octet[3], - e->ether_addr_octet[4], e->ether_addr_octet[5]); - return a; -} - -struct ether_addr * -ether_aton(const char *s) -{ - static struct ether_addr n; - u_int i[6]; - - _DIAGASSERT(s != NULL); - - if (sscanf(s, " %x:%x:%x:%x:%x:%x ", &i[0], &i[1], - &i[2], &i[3], &i[4], &i[5]) == 6) { - n.ether_addr_octet[0] = (u_char)i[0]; - n.ether_addr_octet[1] = (u_char)i[1]; - n.ether_addr_octet[2] = (u_char)i[2]; - n.ether_addr_octet[3] = (u_char)i[3]; - n.ether_addr_octet[4] = (u_char)i[4]; - n.ether_addr_octet[5] = (u_char)i[5]; - return &n; - } - return NULL; -} - -int -ether_ntohost(char *hostname, const struct ether_addr *e) -{ - FILE *f; - char *p; - struct ether_addr try; - - _DIAGASSERT(hostname != NULL); - _DIAGASSERT(e != NULL); - -#ifdef YP - char trybuf[sizeof "xx:xx:xx:xx:xx:xx"]; - int trylen; - trylen = snprintf(trybuf, sizeof trybuf, "%x:%x:%x:%x:%x:%x", - e->ether_addr_octet[0], e->ether_addr_octet[1], - e->ether_addr_octet[2], e->ether_addr_octet[3], - e->ether_addr_octet[4], e->ether_addr_octet[5]); -#endif - - f = fopen(_PATH_ETHERS, "re"); - if (f == NULL) - return -1; - for (p = NULL;;) { - free(p); - p = fparseln(f, NULL, NULL, NULL, FPARSELN_UNESCALL); - if (p == NULL) - break; -#ifdef YP - /* A + in the file means try YP now. */ - if (strcmp(p, "+") == 0) { - char *ypbuf, *ypdom; - int ypbuflen; - - if (yp_get_default_domain(&ypdom)) - continue; - if (yp_match(ypdom, "ethers.byaddr", trybuf, - trylen, &ypbuf, &ypbuflen)) - continue; - ypbuflen = ether_line(ypbuf, &try, hostname); - free(ypbuf); - if (ypbuflen == 0) - goto done; - continue; - } -#endif - if (ether_line(p, &try, hostname) == 0 && - memcmp(&try, e, sizeof try) == 0) - goto done; - } - free(p); - (void)fclose(f); - errno = ENOENT; - return -1; -done: - free(p); - (void)fclose(f); - return 0; -} - -int -ether_hostton(const char *hostname, struct ether_addr *e) -{ - FILE *f; - char *p; - char try[MAXHOSTNAMELEN + 1]; -#ifdef YP - int hostlen = (int)strlen(hostname); -#endif - - _DIAGASSERT(hostname != NULL); - _DIAGASSERT(e != NULL); - - f = fopen(_PATH_ETHERS, "re"); - if (f == NULL) - return -1; - - for (p = NULL;;) { - free(p); - p = fparseln(f, NULL, NULL, NULL, FPARSELN_UNESCALL); - if (p == NULL) - break; -#ifdef YP - /* A + in the file means try YP now. */ - if (strcmp(p, "+") == 0) { - char *ypbuf, *ypdom; - int ypbuflen; - - if (yp_get_default_domain(&ypdom)) - continue; - if (yp_match(ypdom, "ethers.byname", hostname, hostlen, - &ypbuf, &ypbuflen)) - continue; - ypbuflen = ether_line(ypbuf, e, try); - free(ypbuf); - if (ypbuflen == 0) - goto done; - continue; - } -#endif - if (ether_line(p, e, try) == 0 && strcmp(hostname, try) == 0) - goto done; - } - free(p); - (void)fclose(f); - errno = ENOENT; - return -1; -done: - free(p); - (void)fclose(f); - return 0; -} - -int -ether_line(const char *l, struct ether_addr *e, char *hostname) -{ - u_int i[6]; - -#define S2(arg) #arg -#define S1(arg) S2(arg) - static const char fmt[] = " %x:%x:%x:%x:%x:%x" - " %" S1(MAXHOSTNAMELEN) "s\n"; -#undef S2 -#undef S1 - - _DIAGASSERT(l != NULL); - _DIAGASSERT(e != NULL); - _DIAGASSERT(hostname != NULL); - - if (sscanf(l, fmt, - &i[0], &i[1], &i[2], &i[3], &i[4], &i[5], hostname) == 7) { - e->ether_addr_octet[0] = (u_char)i[0]; - e->ether_addr_octet[1] = (u_char)i[1]; - e->ether_addr_octet[2] = (u_char)i[2]; - e->ether_addr_octet[3] = (u_char)i[3]; - e->ether_addr_octet[4] = (u_char)i[4]; - e->ether_addr_octet[5] = (u_char)i[5]; - return 0; - } - errno = EINVAL; - return -1; -} diff --git a/lib/libc/net/gai_strerror.3 b/lib/libc/net/gai_strerror.3 deleted file mode 100644 index d3e905935..000000000 --- a/lib/libc/net/gai_strerror.3 +++ /dev/null @@ -1,96 +0,0 @@ -.\" $NetBSD: gai_strerror.3,v 1.5 2010/03/22 19:30:54 joerg Exp $ -.\" $KAME: gai_strerror.3,v 1.1 2005/01/05 03:04:47 itojun Exp $ -.\" $OpenBSD: gai_strerror.3,v 1.4 2004/12/20 23:04:53 millert Exp $ -.\" -.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (C) 2000, 2001 Internet Software Consortium. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -.\" PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd February 22, 2006 -.Dt GAI_STRERROR 3 -.Os -.Sh NAME -.Nm gai_strerror -.Nd get error message string from EAI_xxx error code -.Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h -.In netdb.h -.Ft const char * -.Fn gai_strerror "int ecode" -.Sh DESCRIPTION -The -.Fn gai_strerror -function returns an error message string corresponding to the error code -returned by -.Xr getaddrinfo 3 -or -.Xr getnameinfo 3 . -.Pp -The following error codes and their meaning are defined in -.In netdb.h : -.Pp -.Bl -tag -width "EAI_ADDRFAMILYXX" -offset indent -compact -.It Dv EAI_ADDRFAMILY -address family for -.Fa hostname -not supported -.It Dv EAI_AGAIN -temporary failure in name resolution -.It Dv EAI_BADFLAGS -invalid value for -.Fa ai_flags -.It Dv EAI_BADHINTS -invalid value for -.Fa hints -.It Dv EAI_FAIL -non-recoverable failure in name resolution -.It Dv EAI_FAMILY -.Fa ai_family -not supported. -.It Dv EAI_MEMORY -memory allocation failure -.It Dv EAI_NODATA -no address associated with -.Fa hostname -.It Dv EAI_NONAME -.Fa hostname -or -.Fa servname -not provided, or not known -.It Dv EAI_OVERFLOW -argument buffer overflow -.It Dv EAI_PROTOCOL -resolved protocol is unknown -.It Dv EAI_SERVICE -.Fa servname -not supported for -.Fa ai_socktype -.It Dv EAI_SOCKTYPE -.Fa ai_socktype -not supported -.It Dv EAI_SYSTEM -system error returned in -.Va errno -.El -.Sh RETURN VALUES -.Fn gai_strerror -returns a pointer to the error message string corresponding to -.Fa ecode . -If -.Fa ecode -is out of range, an implementation-specific error message string is returned. -.Sh SEE ALSO -.Xr getaddrinfo 3 , -.Xr getnameinfo 3 diff --git a/lib/libc/net/getaddrinfo.3 b/lib/libc/net/getaddrinfo.3 deleted file mode 100644 index 384d6810b..000000000 --- a/lib/libc/net/getaddrinfo.3 +++ /dev/null @@ -1,491 +0,0 @@ -.\" $NetBSD: getaddrinfo.3,v 1.57 2013/05/03 21:13:34 wiz Exp $ -.\" $KAME: getaddrinfo.3,v 1.36 2005/01/05 03:23:05 itojun Exp $ -.\" $OpenBSD: getaddrinfo.3,v 1.35 2004/12/21 03:40:31 jaredy Exp $ -.\" -.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (C) 2000, 2001 Internet Software Consortium. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -.\" PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd April 30, 2013 -.Dt GETADDRINFO 3 -.Os -.Sh NAME -.Nm getaddrinfo , -.Nm freeaddrinfo , -.Nm allocaddrinfo -.Nd host and service name to socket address structure -.Sh SYNOPSIS -.In netdb.h -.Ft int -.Fn getaddrinfo "const char * restrict hostname" \ - "const char * restrict servname" \ - "const struct addrinfo * restrict hints" "struct addrinfo ** restrict res" -.Ft void -.Fn freeaddrinfo "struct addrinfo *ai" -.Ft struct addrinfo * -.Fn allocaddrinfo "socklen_t len" -.Sh DESCRIPTION -The -.Fn getaddrinfo -function is used to get a list of -.Tn IP -addresses and port numbers for host -.Fa hostname -and service -.Fa servname . -It is a replacement for and provides more flexibility than the -.Xr gethostbyname 3 -and -.Xr getservbyname 3 -functions. -.Pp -The -.Fa hostname -and -.Fa servname -arguments are either pointers to NUL-terminated strings or the null pointer. -An acceptable value for -.Fa hostname -is either a valid host name or a numeric host address string consisting -of a dotted decimal IPv4 address or an IPv6 address. -The -.Fa servname -is either a decimal port number or a service name listed in -.Xr services 5 . -At least one of -.Fa hostname -and -.Fa servname -must be non-null. -.Pp -.Fa hints -is an optional pointer to a -.Li struct addrinfo , -as defined by -.In netdb.h : -.Bd -literal -struct addrinfo { - int ai_flags; /* input flags */ - int ai_family; /* address family for socket */ - int ai_socktype; /* socket type */ - int ai_protocol; /* protocol for socket */ - socklen_t ai_addrlen; /* length of socket-address */ - struct sockaddr *ai_addr; /* socket-address for socket */ - char *ai_canonname; /* canonical name for service location */ - struct addrinfo *ai_next; /* pointer to next in list */ -}; -.Ed -.Pp -This structure can be used to provide hints concerning the type of socket -that the caller supports or wishes to use. -The caller can supply the following structure elements in -.Fa hints : -.Bl -tag -width "ai_socktypeXX" -.It Fa ai_family -The address -.Pq and protocol -family that should be used. -When -.Fa ai_family -is set to -.Dv AF_UNSPEC , -it means the caller will accept any address family supported by the -operating system. -Note that while address families -.Pq Dv AF_* -and protocol families -.Pq Dv PF_* -are theoretically distinct, in practice the distinction has been lost. -.\" (.Dv !? Consistent with usage below though...) -.Dv "RFC 3493" -defines -.Fn getaddrinfo -in terms of the address family constants -.Dv AF_* -even though -.Fa ai_family -is to be passed as a protocol family to -.Xr socket 2 . -.It Fa ai_socktype -Denotes the type of socket that is wanted: -.Dv SOCK_STREAM , -.Dv SOCK_DGRAM , -or -.Dv SOCK_RAW . -When -.Fa ai_socktype -is zero the caller will accept any socket type. -.It Fa ai_protocol -Indicates which transport protocol is desired, -.Dv IPPROTO_UDP -or -.Dv IPPROTO_TCP . -If -.Fa ai_protocol -is zero the caller will accept any protocol. -.It Fa ai_flags -.Fa ai_flags -is formed by -.Tn OR Ns 'ing -the following values: -.Bl -tag -width "AI_CANONNAMEXX" -.It Dv AI_CANONNAME -If the -.Dv AI_CANONNAME -bit is set, a successful call to -.Fn getaddrinfo -will return a NUL-terminated string containing the canonical name -of the specified hostname in the -.Fa ai_canonname -element of the first -.Li addrinfo -structure returned. -.It Dv AI_NUMERICHOST -If the -.Dv AI_NUMERICHOST -bit is set, it indicates that -.Fa hostname -should be treated as a numeric string defining an IPv4 or IPv6 address -and no name resolution should be attempted. -.It Dv AI_NUMERICSERV -If the -.Dv AI_NUMERICSERV -bit is set, it indicates that the -.Fa servname -string contains a numeric port number. -This is used to prevent service name resolution. -.It Dv AI_PASSIVE -If the -.Dv AI_PASSIVE -bit is set it indicates that the returned socket address structure -is intended for use in a call to -.Xr bind 2 . -In this case, if the -.Fa hostname -argument is the null pointer, then the IP address portion of the -socket address structure will be set to -.Dv INADDR_ANY -for an IPv4 address or -.Dv IN6ADDR_ANY_INIT -for an IPv6 address. -.Pp -If the -.Dv AI_PASSIVE -bit is not set, the returned socket address structure will be ready -for use in a call to -.Xr connect 2 -for a connection-oriented protocol or -.Xr connect 2 , -.Xr sendto 2 , -or -.Xr sendmsg 2 -if a connectionless protocol was chosen. -The -.Tn IP -address portion of the socket address structure will be set to the -loopback address if -.Fa hostname -is the null pointer and -.Dv AI_PASSIVE -is not set. -.It Dv AI_SRV -Perform SRV (RFC 2782) record lookups first. -This is a non-portable extension. -.El -.El -.Pp -All other elements of the -.Li addrinfo -structure passed via -.Fa hints -must be zero or the null pointer. -.Pp -If -.Fa hints -is the null pointer, -.Fn getaddrinfo -behaves as if the caller provided a -.Li struct addrinfo -with -.Fa ai_family -set to -.Dv AF_UNSPEC -and all other elements set to zero or -.Dv NULL . -.Pp -After a successful call to -.Fn getaddrinfo , -.Fa *res -is a pointer to a linked list of one or more -.Li addrinfo -structures. -The list can be traversed by following the -.Fa ai_next -pointer in each -.Li addrinfo -structure until a null pointer is encountered. -The three members -.Fa ai_family , -.Fa ai_socktype , -and -.Fa ai_protocol -in each returned -.Li addrinfo -structure are suitable for a call to -.Xr socket 2 . -For each -.Li addrinfo -structure in the list, the -.Fa ai_addr -member points to a filled-in socket address structure of length -.Fa ai_addrlen . -.Pp -This implementation of -.Fn getaddrinfo -allows numeric IPv6 address notation with scope identifier, -as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt. -By appending the percent character and scope identifier to addresses, -one can fill the -.Li sin6_scope_id -field for addresses. -This would make management of scoped addresses easier -and allows cut-and-paste input of scoped addresses. -.Pp -At this moment the code supports only link-local addresses with the format. -The scope identifier is hardcoded to the name of the hardware interface -associated -with the link -.Po -such as -.Li ne0 -.Pc . -An example is -.Dq Li fe80::1%ne0 , -which means -.Do -.Li fe80::1 -on the link associated with the -.Li ne0 -interface -.Dc . -.Pp -The current implementation assumes a one-to-one relationship between -the interface and link, which is not necessarily true from the specification. -.Pp -All of the information returned by -.Fn getaddrinfo -is dynamically allocated: the -.Li addrinfo -structures themselves as well as the socket address structures and -the canonical host name strings included in the -.Li addrinfo -structures. -.Pp -Memory allocated for the dynamically allocated structures created by -a successful call to -.Fn getaddrinfo -is released by the -.Fn freeaddrinfo -function. -The -.Fa ai -pointer should be an -.Li addrinfo -structure created by a call to -.Fn getaddrinfo -or -.Fn allocaddrinfo . -The -.Fn allocaddrinfo -function is intended primarily for authors of -.Xr nsdispatch 3 -plugins implementing -.Fn getaddrinfo -backends. -.Fn allocaddrinfo -allocates a -.Li struct addrinfo -in a way that is compatible with being returned from -.Fn getaddrinfo -and being ultimately freed by -.Fn freeaddrinfo . -The returned structure is zeroed, except for the -.Fa ai_addr -field, which -will point to -.Fa len -bytes of memory for storage of a socket address. -It is safe to allocate memory separately for -.Fa ai_canonname -with -.Xr malloc 3 , -or in any other way that is compatible with deallocation by -.Xr free 3 . -.Sh RETURN VALUES -.Fn getaddrinfo -returns zero on success or one of the error codes listed in -.Xr gai_strerror 3 -if an error occurs. -.Sh EXAMPLES -The following code tries to connect to -.Dq Li www.kame.net -service -.Dq Li http -via a stream socket. -It loops through all the addresses available, regardless of address family. -If the destination resolves to an IPv4 address, it will use an -.Dv AF_INET -socket. -Similarly, if it resolves to IPv6, an -.Dv AF_INET6 -socket is used. -Observe that there is no hardcoded reference to a particular address family. -The code works even if -.Fn getaddrinfo -returns addresses that are not IPv4/v6. -.Bd -literal -offset indent -struct addrinfo hints, *res, *res0; -int error; -int s; -const char *cause = NULL; - -memset(\*[Am]hints, 0, sizeof(hints)); -hints.ai_family = AF_UNSPEC; -hints.ai_socktype = SOCK_STREAM; -error = getaddrinfo("www.kame.net", "http", \*[Am]hints, \*[Am]res0); -if (error) { - errx(1, "%s", gai_strerror(error)); - /*NOTREACHED*/ -} -s = -1; -for (res = res0; res; res = res-\*[Gt]ai_next) { - s = socket(res-\*[Gt]ai_family, res-\*[Gt]ai_socktype, - res-\*[Gt]ai_protocol); - if (s \*[Lt] 0) { - cause = "socket"; - continue; - } - - if (connect(s, res-\*[Gt]ai_addr, res-\*[Gt]ai_addrlen) \*[Lt] 0) { - cause = "connect"; - close(s); - s = -1; - continue; - } - - break; /* okay we got one */ -} -if (s \*[Lt] 0) { - err(1, "%s", cause); - /*NOTREACHED*/ -} -freeaddrinfo(res0); -.Ed -.Pp -The following example tries to open a wildcard listening socket onto service -.Dq Li http , -for all the address families available. -.Bd -literal -offset indent -struct addrinfo hints, *res, *res0; -int error; -int s[MAXSOCK]; -int nsock; -const char *cause = NULL; - -memset(\*[Am]hints, 0, sizeof(hints)); -hints.ai_family = AF_UNSPEC; -hints.ai_socktype = SOCK_STREAM; -hints.ai_flags = AI_PASSIVE; -error = getaddrinfo(NULL, "http", \*[Am]hints, \*[Am]res0); -if (error) { - errx(1, "%s", gai_strerror(error)); - /*NOTREACHED*/ -} -nsock = 0; -for (res = res0; res \*[Am]\*[Am] nsock \*[Lt] MAXSOCK; res = res-\*[Gt]ai_next) { - s[nsock] = socket(res-\*[Gt]ai_family, res-\*[Gt]ai_socktype, - res-\*[Gt]ai_protocol); - if (s[nsock] \*[Lt] 0) { - cause = "socket"; - continue; - } - - if (bind(s[nsock], res-\*[Gt]ai_addr, res-\*[Gt]ai_addrlen) \*[Lt] 0) { - cause = "bind"; - close(s[nsock]); - continue; - } - (void) listen(s[nsock], 5); - - nsock++; -} -if (nsock == 0) { - err(1, "%s", cause); - /*NOTREACHED*/ -} -freeaddrinfo(res0); -.Ed -.Sh SEE ALSO -.Xr bind 2 , -.Xr connect 2 , -.Xr send 2 , -.Xr socket 2 , -.Xr gai_strerror 3 , -.Xr gethostbyname 3 , -.Xr getnameinfo 3 , -.Xr getservbyname 3 , -.Xr resolver 3 , -.Xr hosts 5 , -.Xr resolv.conf 5 , -.Xr services 5 , -.Xr hostname 7 , -.Xr named 8 -.Rs -.%A R. Gilligan -.%A S. Thomson -.%A J. Bound -.%A J. McCann -.%A W. Stevens -.%T Basic Socket Interface Extensions for IPv6 -.%R RFC 3493 -.%D February 2003 -.Re -.Rs -.%A S. Deering -.%A B. Haberman -.%A T. Jinmei -.%A E. Nordmark -.%A B. Zill -.%T "IPv6 Scoped Address Architecture" -.%R internet draft -.%N draft-ietf-ipv6-scoping-arch-02.txt -.%O work in progress material -.Re -.Rs -.%A Craig Metz -.%T "Protocol Independence Using the Sockets API" -.%I USENIX Association -.%B Proceedings of the FREENIX Track: 2000 USENIX Annual Technical Conference -.%D June 18-23, 2000 -.%P 99-108 -.%U http://www.usenix.org/events/usenix2000/freenix/metzprotocol/metzprotocol.pdf -.Re -.Sh STANDARDS -The -.Fn getaddrinfo -function is defined by the -.St -p1003.1g-2000 -draft specification and documented in -.Dv "RFC 3493" , -.Dq Basic Socket Interface Extensions for IPv6 . diff --git a/lib/libc/net/getaddrinfo.c b/lib/libc/net/getaddrinfo.c deleted file mode 100644 index b15a4267b..000000000 --- a/lib/libc/net/getaddrinfo.c +++ /dev/null @@ -1,2334 +0,0 @@ -/* $NetBSD: getaddrinfo.c,v 1.109 2015/09/10 14:05:06 christos Exp $ */ -/* $KAME: getaddrinfo.c,v 1.29 2000/08/31 17:26:57 itojun Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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. - */ - -/* - * Issues to be discussed: - * - Return values. There are nonstandard return values defined and used - * in the source code. This is because RFC2553 is silent about which error - * code must be returned for which situation. - * - IPv4 classful (shortened) form. RFC2553 is silent about it. XNET 5.2 - * says to use inet_aton() to convert IPv4 numeric to binary (alows - * classful form as a result). - * current code - disallow classful form for IPv4 (due to use of inet_pton). - * - freeaddrinfo(NULL). RFC2553 is silent about it. XNET 5.2 says it is - * invalid. - * current code - SEGV on freeaddrinfo(NULL) - * Note: - * - The code filters out AFs that are not supported by the kernel, - * when globbing NULL hostname (to loopback, or wildcard). Is it the right - * thing to do? What is the relationship with post-RFC2553 AI_ADDRCONFIG - * in ai_flags? - * - (post-2553) semantics of AI_ADDRCONFIG itself is too vague. - * (1) what should we do against numeric hostname (2) what should we do - * against NULL hostname (3) what is AI_ADDRCONFIG itself. AF not ready? - * non-loopback address configured? global address configured? - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getaddrinfo.c,v 1.109 2015/09/10 14:05:06 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include - -#ifdef YP -#include -#include -#include -#endif - -#include "servent.h" - -#ifndef RUMP_ACTION -#ifdef __weak_alias -__weak_alias(getaddrinfo,_getaddrinfo) -__weak_alias(allocaddrinfo,_allocaddrinfo) -__weak_alias(freeaddrinfo,_freeaddrinfo) -__weak_alias(gai_strerror,_gai_strerror) -#endif -#endif - -#define SUCCESS 0 -#define ANY 0 -#define YES 1 -#define NO 0 - -static const char in_addrany[] = { 0, 0, 0, 0 }; -static const char in_loopback[] = { 127, 0, 0, 1 }; -#ifdef INET6 -static const char in6_addrany[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 -}; -static const char in6_loopback[] = { - 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1 -}; -#endif - -static const struct afd { - int a_af; - int a_addrlen; - int a_socklen; - int a_off; - const char *a_addrany; - const char *a_loopback; - int a_scoped; -} afdl [] = { -#ifdef INET6 - {PF_INET6, sizeof(struct in6_addr), - sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr), - in6_addrany, in6_loopback, 1}, -#endif - {PF_INET, sizeof(struct in_addr), - sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr), - in_addrany, in_loopback, 0}, - {0, 0, 0, 0, NULL, NULL, 0}, -}; - -struct explore { - int e_af; - int e_socktype; - int e_protocol; - const char *e_protostr; - int e_wild; -#define WILD_AF(ex) ((ex)->e_wild & 0x01) -#define WILD_SOCKTYPE(ex) ((ex)->e_wild & 0x02) -#define WILD_PROTOCOL(ex) ((ex)->e_wild & 0x04) -}; - -static const struct explore explore[] = { -#if 0 - { PF_LOCAL, 0, ANY, ANY, NULL, 0x01 }, -#endif -#ifdef INET6 - { PF_INET6, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET6, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET6, SOCK_RAW, ANY, NULL, 0x05 }, -#endif - { PF_INET, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_INET, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_INET, SOCK_RAW, ANY, NULL, 0x05 }, - { PF_UNSPEC, SOCK_DGRAM, IPPROTO_UDP, "udp", 0x07 }, - { PF_UNSPEC, SOCK_STREAM, IPPROTO_TCP, "tcp", 0x07 }, - { PF_UNSPEC, SOCK_RAW, ANY, NULL, 0x05 }, - { -1, 0, 0, NULL, 0 }, -}; - -#ifdef INET6 -#define PTON_MAX 16 -#else -#define PTON_MAX 4 -#endif - -static const ns_src default_dns_files[] = { - { NSSRC_FILES, NS_SUCCESS }, - { NSSRC_DNS, NS_SUCCESS }, - { 0, 0 } -}; - -#define MAXPACKET (64*1024) - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -struct res_target { - struct res_target *next; - const char *name; /* domain name */ - int qclass, qtype; /* class and type of query */ - u_char *answer; /* buffer to put answer */ - int anslen; /* size of answer buffer */ - int n; /* result length */ -}; - -struct srvinfo { - struct srvinfo *next; - char name[MAXDNAME]; - int port, pri, weight; -}; - -static int gai_srvok(const char *); -static int str2number(const char *); -static int explore_fqdn(const struct addrinfo *, const char *, - const char *, struct addrinfo **, struct servent_data *); -static int explore_null(const struct addrinfo *, - const char *, struct addrinfo **, struct servent_data *); -static int explore_numeric(const struct addrinfo *, const char *, - const char *, struct addrinfo **, const char *, struct servent_data *); -static int explore_numeric_scope(const struct addrinfo *, const char *, - const char *, struct addrinfo **, struct servent_data *); -static int get_canonname(const struct addrinfo *, - struct addrinfo *, const char *); -static struct addrinfo *get_ai(const struct addrinfo *, - const struct afd *, const char *); -static int get_portmatch(const struct addrinfo *, const char *, - struct servent_data *); -static int get_port(const struct addrinfo *, const char *, int, - struct servent_data *); -static const struct afd *find_afd(int); -static int addrconfig(uint64_t *); -#ifdef INET6 -static int ip6_str2scopeid(char *, struct sockaddr_in6 *, u_int32_t *); -#endif - -static struct addrinfo *getanswer(const querybuf *, int, const char *, int, - const struct addrinfo *); -static void aisort(struct addrinfo *s, res_state res); -static struct addrinfo * _dns_query(struct res_target *, - const struct addrinfo *, res_state, int); -static struct addrinfo * _dns_srv_lookup(const char *, const char *, - const struct addrinfo *); -static struct addrinfo * _dns_host_lookup(const char *, - const struct addrinfo *); -static int _dns_getaddrinfo(void *, void *, va_list); -static void _sethtent(FILE **); -static void _endhtent(FILE **); -static struct addrinfo *_gethtent(FILE **, const char *, - const struct addrinfo *); -static int _files_getaddrinfo(void *, void *, va_list); -#ifdef YP -static struct addrinfo *_yphostent(char *, const struct addrinfo *); -static int _yp_getaddrinfo(void *, void *, va_list); -#endif - -static int res_queryN(const char *, struct res_target *, res_state); -static int res_searchN(const char *, struct res_target *, res_state); -static int res_querydomainN(const char *, const char *, - struct res_target *, res_state); - -static const char * const ai_errlist[] = { - "Success", - "Address family for hostname not supported", /* EAI_ADDRFAMILY */ - "Temporary failure in name resolution", /* EAI_AGAIN */ - "Invalid value for ai_flags", /* EAI_BADFLAGS */ - "Non-recoverable failure in name resolution", /* EAI_FAIL */ - "ai_family not supported", /* EAI_FAMILY */ - "Memory allocation failure", /* EAI_MEMORY */ - "No address associated with hostname", /* EAI_NODATA */ - "hostname nor servname provided, or not known", /* EAI_NONAME */ - "servname not supported for ai_socktype", /* EAI_SERVICE */ - "ai_socktype not supported", /* EAI_SOCKTYPE */ - "System error returned in errno", /* EAI_SYSTEM */ - "Invalid value for hints", /* EAI_BADHINTS */ - "Resolved protocol is unknown", /* EAI_PROTOCOL */ - "Argument buffer overflow", /* EAI_OVERFLOW */ - "Unknown error", /* EAI_MAX */ -}; - -/* XXX macros that make external reference is BAD. */ - -#define GET_AI(ai, afd, addr) \ -do { \ - /* external reference: pai, error, and label free */ \ - (ai) = get_ai(pai, (afd), (addr)); \ - if ((ai) == NULL) { \ - error = EAI_MEMORY; \ - goto free; \ - } \ -} while (/*CONSTCOND*/0) - -#define GET_PORT(ai, serv, svd) \ -do { \ - /* external reference: error and label free */ \ - error = get_port((ai), (serv), 0, (svd)); \ - if (error != 0) \ - goto free; \ -} while (/*CONSTCOND*/0) - -#define GET_CANONNAME(ai, str) \ -do { \ - /* external reference: pai, error and label free */ \ - error = get_canonname(pai, (ai), (str)); \ - if (error != 0) \ - goto free; \ -} while (/*CONSTCOND*/0) - -#define ERR(err) \ -do { \ - /* external reference: error, and label bad */ \ - error = (err); \ - goto bad; \ - /*NOTREACHED*/ \ -} while (/*CONSTCOND*/0) - -#define MATCH_FAMILY(x, y, w) \ - ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == PF_UNSPEC || \ - (y) == PF_UNSPEC))) -#define MATCH(x, y, w) \ - ((x) == (y) || (/*CONSTCOND*/(w) && ((x) == ANY || (y) == ANY))) - -const char * -gai_strerror(int ecode) -{ - if (ecode < 0 || ecode > EAI_MAX) - ecode = EAI_MAX; - return ai_errlist[ecode]; -} - -void -freeaddrinfo(struct addrinfo *ai) -{ - struct addrinfo *next; - - _DIAGASSERT(ai != NULL); - - do { - next = ai->ai_next; - if (ai->ai_canonname) - free(ai->ai_canonname); - /* no need to free(ai->ai_addr) */ - free(ai); - ai = next; - } while (ai); -} - -/* - * We don't want localization to affect us - */ -#define PERIOD '.' -#define hyphenchar(c) ((c) == '-') -#define periodchar(c) ((c) == PERIOD) -#define underschar(c) ((c) == '_') -#define alphachar(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) -#define digitchar(c) ((c) >= '0' && (c) <= '9') - -#define firstchar(c) (alphachar(c) || digitchar(c) || underschar(c)) -#define lastchar(c) (alphachar(c) || digitchar(c)) -#define middlechar(c) (lastchar(c) || hyphenchar(c)) - -static int -gai_srvok(const char *dn) -{ - int nch, pch, ch; - - for (pch = PERIOD, nch = ch = *dn++; ch != '\0'; pch = ch, ch = nch) { - if (periodchar(ch)) - continue; - if (periodchar(pch)) { - if (!firstchar(ch)) - return 0; - } else if (periodchar(nch) || nch == '\0') { - if (!lastchar(ch)) - return 0; - } else if (!middlechar(ch)) - return 0; - } - return 1; -} - -static in_port_t * -getport(struct addrinfo *ai) { - static in_port_t p; - - switch (ai->ai_family) { - case AF_INET: - return &((struct sockaddr_in *)(void *)ai->ai_addr)->sin_port; -#ifdef INET6 - case AF_INET6: - return &((struct sockaddr_in6 *)(void *)ai->ai_addr)->sin6_port; -#endif - default: - p = 0; - /* XXX: abort()? */ - return &p; - } -} - -static int -str2number(const char *p) -{ - char *ep; - unsigned long v; - - _DIAGASSERT(p != NULL); - - if (*p == '\0') - return -1; - ep = NULL; - errno = 0; - v = strtoul(p, &ep, 10); - if (errno == 0 && ep && *ep == '\0' && v <= INT_MAX) - return (int)v; - else - return -1; -} - -int -getaddrinfo(const char *hostname, const char *servname, - const struct addrinfo *hints, struct addrinfo **res) -{ - struct addrinfo sentinel; - struct addrinfo *cur; - int error = 0; - struct addrinfo ai; - struct addrinfo ai0; - struct addrinfo *pai; - const struct explore *ex; - struct servent_data svd; - uint64_t mask = (uint64_t)~0ULL; - - /* hostname is allowed to be NULL */ - /* servname is allowed to be NULL */ - /* hints is allowed to be NULL */ - _DIAGASSERT(res != NULL); - - (void)memset(&svd, 0, sizeof(svd)); - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - memset(&ai, 0, sizeof(ai)); - pai = &ai; - pai->ai_flags = 0; - pai->ai_family = PF_UNSPEC; - pai->ai_socktype = ANY; - pai->ai_protocol = ANY; - pai->ai_addrlen = 0; - pai->ai_canonname = NULL; - pai->ai_addr = NULL; - pai->ai_next = NULL; - - if (hostname == NULL && servname == NULL) - return EAI_NONAME; - if (hints) { - /* error check for hints */ - if (hints->ai_addrlen || hints->ai_canonname || - hints->ai_addr || hints->ai_next) - ERR(EAI_BADHINTS); /* xxx */ - if (hints->ai_flags & ~AI_MASK) - ERR(EAI_BADFLAGS); - switch (hints->ai_family) { - case PF_UNSPEC: - case PF_INET: -#ifdef INET6 - case PF_INET6: -#endif - break; - default: - ERR(EAI_FAMILY); - } - memcpy(pai, hints, sizeof(*pai)); - - /* - * if both socktype/protocol are specified, check if they - * are meaningful combination. - */ - if (pai->ai_socktype != ANY && pai->ai_protocol != ANY) { - for (ex = explore; ex->e_af >= 0; ex++) { - if (pai->ai_family != ex->e_af) - continue; - if (ex->e_socktype == ANY) - continue; - if (ex->e_protocol == ANY) - continue; - if (pai->ai_socktype == ex->e_socktype - && pai->ai_protocol != ex->e_protocol) { - ERR(EAI_BADHINTS); - } - } - } - } - - if ((pai->ai_flags & AI_ADDRCONFIG) != 0 && addrconfig(&mask) == -1) - ERR(EAI_FAIL); - - /* - * check for special cases. (1) numeric servname is disallowed if - * socktype/protocol are left unspecified. (2) servname is disallowed - * for raw and other inet{,6} sockets. - */ - if (MATCH_FAMILY(pai->ai_family, PF_INET, 1) -#ifdef PF_INET6 - || MATCH_FAMILY(pai->ai_family, PF_INET6, 1) -#endif - ) { - ai0 = *pai; /* backup *pai */ - - if (pai->ai_family == PF_UNSPEC) { -#ifdef PF_INET6 - pai->ai_family = PF_INET6; -#else - pai->ai_family = PF_INET; -#endif - } - error = get_portmatch(pai, servname, &svd); - if (error) - goto bad; - - *pai = ai0; - } - - ai0 = *pai; - - /* NULL hostname, or numeric hostname */ - for (ex = explore; ex->e_af >= 0; ex++) { - *pai = ai0; - - /* ADDRCONFIG check */ - if ((((uint64_t)1 << ex->e_af) & mask) == 0) - continue; - - /* PF_UNSPEC entries are prepared for DNS queries only */ - if (ex->e_af == PF_UNSPEC) - continue; - - if (!MATCH_FAMILY(pai->ai_family, ex->e_af, WILD_AF(ex))) - continue; - if (!MATCH(pai->ai_socktype, ex->e_socktype, WILD_SOCKTYPE(ex))) - continue; - if (!MATCH(pai->ai_protocol, ex->e_protocol, WILD_PROTOCOL(ex))) - continue; - if (pai->ai_family == PF_UNSPEC) - pai->ai_family = ex->e_af; - if (pai->ai_socktype == ANY && ex->e_socktype != ANY) - pai->ai_socktype = ex->e_socktype; - if (pai->ai_protocol == ANY && ex->e_protocol != ANY) - pai->ai_protocol = ex->e_protocol; - - if (hostname == NULL) - error = explore_null(pai, servname, &cur->ai_next, - &svd); - else - error = explore_numeric_scope(pai, hostname, servname, - &cur->ai_next, &svd); - - if (error) - goto free; - - while (cur->ai_next) - cur = cur->ai_next; - } - - /* - * XXX - * If numeric representation of AF1 can be interpreted as FQDN - * representation of AF2, we need to think again about the code below. - */ - if (sentinel.ai_next) - goto good; - - if (hostname == NULL) - ERR(EAI_NODATA); - if (pai->ai_flags & AI_NUMERICHOST) - ERR(EAI_NONAME); - - /* - * hostname as alphabetical name. - * we would like to prefer AF_INET6 than AF_INET, so we'll make a - * outer loop by AFs. - */ - for (ex = explore; ex->e_af >= 0; ex++) { - *pai = ai0; - - - /* ADDRCONFIG check */ - /* PF_UNSPEC entries are prepared for DNS queries only */ - if (ex->e_af != PF_UNSPEC && - (((uint64_t)1 << ex->e_af) & mask) == 0) - continue; - - /* require exact match for family field */ - if (pai->ai_family != ex->e_af) - continue; - - if (!MATCH(pai->ai_socktype, ex->e_socktype, - WILD_SOCKTYPE(ex))) { - continue; - } - if (!MATCH(pai->ai_protocol, ex->e_protocol, - WILD_PROTOCOL(ex))) { - continue; - } - - if (pai->ai_socktype == ANY && ex->e_socktype != ANY) - pai->ai_socktype = ex->e_socktype; - if (pai->ai_protocol == ANY && ex->e_protocol != ANY) - pai->ai_protocol = ex->e_protocol; - - error = explore_fqdn(pai, hostname, servname, &cur->ai_next, - &svd); - - while (cur && cur->ai_next) - cur = cur->ai_next; - } - - /* XXX */ - if (sentinel.ai_next) - error = 0; - - if (error) - goto free; - - if (sentinel.ai_next) { - good: - endservent_r(&svd); - *res = sentinel.ai_next; - return SUCCESS; - } else - error = EAI_FAIL; - free: - bad: - endservent_r(&svd); - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - *res = NULL; - return error; -} - -/* - * FQDN hostname, DNS lookup - */ -static int -explore_fqdn(const struct addrinfo *pai, const char *hostname, - const char *servname, struct addrinfo **res, struct servent_data *svd) -{ - struct addrinfo *result; - struct addrinfo *cur; - int error = 0; - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getaddrinfo, NULL) - { NSSRC_DNS, _dns_getaddrinfo, NULL }, /* force -DHESIOD */ - NS_NIS_CB(_yp_getaddrinfo, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(pai != NULL); - /* hostname may be NULL */ - /* servname may be NULL */ - _DIAGASSERT(res != NULL); - - result = NULL; - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname, svd) != 0) - return 0; - - switch (nsdispatch(&result, dtab, NSDB_HOSTS, "getaddrinfo", - default_dns_files, hostname, pai, servname)) { - case NS_TRYAGAIN: - error = EAI_AGAIN; - goto free; - case NS_UNAVAIL: - error = EAI_FAIL; - goto free; - case NS_NOTFOUND: - error = EAI_NODATA; - goto free; - case NS_SUCCESS: - error = 0; - for (cur = result; cur; cur = cur->ai_next) { - /* Check for already filled port. */ - if (*getport(cur)) - continue; - GET_PORT(cur, servname, svd); - /* canonname should be filled already */ - } - break; - } - - *res = result; - - return 0; - -free: - if (result) - freeaddrinfo(result); - return error; -} - -/* - * hostname == NULL. - * passive socket -> anyaddr (0.0.0.0 or ::) - * non-passive socket -> localhost (127.0.0.1 or ::1) - */ -static int -explore_null(const struct addrinfo *pai, const char *servname, - struct addrinfo **res, struct servent_data *svd) -{ - int s; - const struct afd *afd; - struct addrinfo *cur; - struct addrinfo sentinel; - int error; - - _DIAGASSERT(pai != NULL); - /* servname may be NULL */ - _DIAGASSERT(res != NULL); - - *res = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; - - /* - * filter out AFs that are not supported by the kernel - * XXX errno? - */ - s = socket(pai->ai_family, SOCK_DGRAM, 0); - if (s < 0) { - if (errno != EMFILE) - return 0; - } else - close(s); - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname, svd) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - if (pai->ai_flags & AI_PASSIVE) { - GET_AI(cur->ai_next, afd, afd->a_addrany); - /* xxx meaningless? - * GET_CANONNAME(cur->ai_next, "anyaddr"); - */ - GET_PORT(cur->ai_next, servname, svd); - } else { - GET_AI(cur->ai_next, afd, afd->a_loopback); - /* xxx meaningless? - * GET_CANONNAME(cur->ai_next, "localhost"); - */ - GET_PORT(cur->ai_next, servname, svd); - } - cur = cur->ai_next; - - *res = sentinel.ai_next; - return 0; - -free: - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - return error; -} - -/* - * numeric hostname - */ -static int -explore_numeric(const struct addrinfo *pai, const char *hostname, - const char *servname, struct addrinfo **res, const char *canonname, - struct servent_data *svd) -{ - const struct afd *afd; - struct addrinfo *cur; - struct addrinfo sentinel; - int error; - char pton[PTON_MAX]; - - _DIAGASSERT(pai != NULL); - /* hostname may be NULL */ - /* servname may be NULL */ - _DIAGASSERT(res != NULL); - - *res = NULL; - sentinel.ai_next = NULL; - cur = &sentinel; - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname, svd) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - switch (afd->a_af) { -#if 0 /*X/Open spec*/ - case AF_INET: - if (inet_aton(hostname, (struct in_addr *)pton) == 1) { - if (pai->ai_family == afd->a_af || - pai->ai_family == PF_UNSPEC /*?*/) { - GET_AI(cur->ai_next, afd, pton); - GET_PORT(cur->ai_next, servname, svd); - if ((pai->ai_flags & AI_CANONNAME)) { - /* - * Set the numeric address itself as - * the canonical name, based on a - * clarification in rfc2553bis-03. - */ - GET_CANONNAME(cur->ai_next, canonname); - } - while (cur && cur->ai_next) - cur = cur->ai_next; - } else - ERR(EAI_FAMILY); /*xxx*/ - } - break; -#endif - default: - if (inet_pton(afd->a_af, hostname, pton) == 1) { - if (pai->ai_family == afd->a_af || - pai->ai_family == PF_UNSPEC /*?*/) { - GET_AI(cur->ai_next, afd, pton); - GET_PORT(cur->ai_next, servname, svd); - if ((pai->ai_flags & AI_CANONNAME)) { - /* - * Set the numeric address itself as - * the canonical name, based on a - * clarification in rfc2553bis-03. - */ - GET_CANONNAME(cur->ai_next, canonname); - } - while (cur->ai_next) - cur = cur->ai_next; - } else - ERR(EAI_FAMILY); /*xxx*/ - } - break; - } - - *res = sentinel.ai_next; - return 0; - -free: -bad: - if (sentinel.ai_next) - freeaddrinfo(sentinel.ai_next); - return error; -} - -/* - * numeric hostname with scope - */ -static int -explore_numeric_scope(const struct addrinfo *pai, const char *hostname, - const char *servname, struct addrinfo **res, struct servent_data *svd) -{ -#if !defined(SCOPE_DELIMITER) || !defined(INET6) - return explore_numeric(pai, hostname, servname, res, hostname, svd); -#else - const struct afd *afd; - struct addrinfo *cur; - int error; - char *cp, *hostname2 = NULL, *scope, *addr; - struct sockaddr_in6 *sin6; - - _DIAGASSERT(pai != NULL); - /* hostname may be NULL */ - /* servname may be NULL */ - _DIAGASSERT(res != NULL); - - /* - * if the servname does not match socktype/protocol, ignore it. - */ - if (get_portmatch(pai, servname, svd) != 0) - return 0; - - afd = find_afd(pai->ai_family); - if (afd == NULL) - return 0; - - if (!afd->a_scoped) - return explore_numeric(pai, hostname, servname, res, hostname, - svd); - - cp = strchr(hostname, SCOPE_DELIMITER); - if (cp == NULL) - return explore_numeric(pai, hostname, servname, res, hostname, - svd); - - /* - * Handle special case of - */ - hostname2 = strdup(hostname); - if (hostname2 == NULL) - return EAI_MEMORY; - /* terminate at the delimiter */ - hostname2[cp - hostname] = '\0'; - addr = hostname2; - scope = cp + 1; - - error = explore_numeric(pai, addr, servname, res, hostname, svd); - if (error == 0) { - u_int32_t scopeid; - - for (cur = *res; cur; cur = cur->ai_next) { - if (cur->ai_family != AF_INET6) - continue; - sin6 = (struct sockaddr_in6 *)(void *)cur->ai_addr; - if (ip6_str2scopeid(scope, sin6, &scopeid) == -1) { - free(hostname2); - return(EAI_NODATA); /* XXX: is return OK? */ - } - sin6->sin6_scope_id = scopeid; - } - } - - free(hostname2); - - return error; -#endif -} - -static int -get_canonname(const struct addrinfo *pai, struct addrinfo *ai, const char *str) -{ - - _DIAGASSERT(pai != NULL); - _DIAGASSERT(ai != NULL); - _DIAGASSERT(str != NULL); - - if ((pai->ai_flags & AI_CANONNAME) != 0) { - ai->ai_canonname = strdup(str); - if (ai->ai_canonname == NULL) - return EAI_MEMORY; - } - return 0; -} - -struct addrinfo * -allocaddrinfo(socklen_t addrlen) -{ - struct addrinfo *ai; - - ai = calloc(sizeof(struct addrinfo) + addrlen, 1); - if (ai) { - ai->ai_addr = (void *)(ai+1); - ai->ai_addrlen = ai->ai_addr->sa_len = addrlen; - } - - return ai; -} - -static struct addrinfo * -get_ai(const struct addrinfo *pai, const struct afd *afd, const char *addr) -{ - char *p; - struct addrinfo *ai; - struct sockaddr *save; - - _DIAGASSERT(pai != NULL); - _DIAGASSERT(afd != NULL); - _DIAGASSERT(addr != NULL); - - ai = allocaddrinfo((socklen_t)afd->a_socklen); - if (ai == NULL) - return NULL; - - save = ai->ai_addr; - memcpy(ai, pai, sizeof(struct addrinfo)); - - /* since we just overwrote all of ai, we have - to restore ai_addr and ai_addrlen */ - ai->ai_addr = save; - ai->ai_addrlen = (socklen_t)afd->a_socklen; - - ai->ai_addr->sa_family = ai->ai_family = afd->a_af; - p = (char *)(void *)(ai->ai_addr); - memcpy(p + afd->a_off, addr, (size_t)afd->a_addrlen); - return ai; -} - -static int -get_portmatch(const struct addrinfo *ai, const char *servname, - struct servent_data *svd) -{ - - _DIAGASSERT(ai != NULL); - /* servname may be NULL */ - - return get_port(ai, servname, 1, svd); -} - -static int -get_port(const struct addrinfo *ai, const char *servname, int matchonly, - struct servent_data *svd) -{ - const char *proto; - struct servent *sp; - int port; - int allownumeric; - - _DIAGASSERT(ai != NULL); - /* servname may be NULL */ - - if (servname == NULL) - return 0; - switch (ai->ai_family) { - case AF_INET: -#ifdef AF_INET6 - case AF_INET6: -#endif - break; - default: - return 0; - } - - switch (ai->ai_socktype) { - case SOCK_RAW: - return EAI_SERVICE; - case SOCK_DGRAM: - case SOCK_STREAM: - allownumeric = 1; - break; - case ANY: - /* - * This was 0. It is now 1 so that queries specifying - * a NULL hint, or hint without socktype (but, hopefully, - * with protocol) and numeric address actually work. - */ - allownumeric = 1; - break; - default: - return EAI_SOCKTYPE; - } - - port = str2number(servname); - if (port >= 0) { - if (!allownumeric) - return EAI_SERVICE; - if (port < 0 || port > 65535) - return EAI_SERVICE; - port = htons(port); - } else { - struct servent sv; - if (ai->ai_flags & AI_NUMERICSERV) - return EAI_NONAME; - - switch (ai->ai_socktype) { - case SOCK_DGRAM: - proto = "udp"; - break; - case SOCK_STREAM: - proto = "tcp"; - break; - default: - proto = NULL; - break; - } - - sp = getservbyname_r(servname, proto, &sv, svd); - if (sp == NULL) - return EAI_SERVICE; - port = sp->s_port; - } - - if (!matchonly) - *getport(__UNCONST(ai)) = port; - return 0; -} - -static const struct afd * -find_afd(int af) -{ - const struct afd *afd; - - if (af == PF_UNSPEC) - return NULL; - for (afd = afdl; afd->a_af; afd++) { - if (afd->a_af == af) - return afd; - } - return NULL; -} - -/* - * AI_ADDRCONFIG check: Build a mask containing a bit set for each address - * family configured in the system. - * - */ -static int -addrconfig(uint64_t *mask) -{ - struct ifaddrs *ifaddrs, *ifa; - - if (getifaddrs(&ifaddrs) == -1) - return -1; - - *mask = 0; - for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) - if (ifa->ifa_addr && (ifa->ifa_flags & IFF_UP)) { - _DIAGASSERT(ifa->ifa_addr->sa_family < 64); - *mask |= (uint64_t)1 << ifa->ifa_addr->sa_family; - } - - freeifaddrs(ifaddrs); - return 0; -} - -#ifdef INET6 -/* convert a string to a scope identifier. XXX: IPv6 specific */ -static int -ip6_str2scopeid(char *scope, struct sockaddr_in6 *sin6, u_int32_t *scopeid) -{ - u_long lscopeid; - struct in6_addr *a6; - char *ep; - - _DIAGASSERT(scope != NULL); - _DIAGASSERT(sin6 != NULL); - _DIAGASSERT(scopeid != NULL); - - a6 = &sin6->sin6_addr; - - /* empty scopeid portion is invalid */ - if (*scope == '\0') - return -1; - - if (IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) { - /* - * We currently assume a one-to-one mapping between links - * and interfaces, so we simply use interface indices for - * like-local scopes. - */ - *scopeid = if_nametoindex(scope); - if (*scopeid == 0) - goto trynumeric; - return 0; - } - - /* still unclear about literal, allow numeric only - placeholder */ - if (IN6_IS_ADDR_SITELOCAL(a6) || IN6_IS_ADDR_MC_SITELOCAL(a6)) - goto trynumeric; - if (IN6_IS_ADDR_MC_ORGLOCAL(a6)) - goto trynumeric; - else - goto trynumeric; /* global */ - - /* try to convert to a numeric id as a last resort */ - trynumeric: - errno = 0; - lscopeid = strtoul(scope, &ep, 10); - *scopeid = (u_int32_t)(lscopeid & 0xffffffffUL); - if (errno == 0 && ep && *ep == '\0' && *scopeid == lscopeid) - return 0; - else - return -1; -} -#endif - -/* code duplicate with gethnamaddr.c */ - -static const char AskedForGot[] = - "gethostby*.getanswer: asked for \"%s\", got \"%s\""; - -static struct addrinfo * -getanswer(const querybuf *answer, int anslen, const char *qname, int qtype, - const struct addrinfo *pai) -{ - struct addrinfo sentinel, *cur; - struct addrinfo ai, *aip; - const struct afd *afd; - char *canonname; - const HEADER *hp; - const u_char *cp; - int n; - const u_char *eom; - char *bp, *ep; - int type, class, ancount, qdcount; - int haveanswer, had_error; - char tbuf[MAXDNAME]; - int (*name_ok) (const char *); - char hostbuf[8*1024]; - int port, pri, weight; - struct srvinfo *srvlist, *srv, *csrv; - - _DIAGASSERT(answer != NULL); - _DIAGASSERT(qname != NULL); - _DIAGASSERT(pai != NULL); - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - canonname = NULL; - eom = answer->buf + anslen; - switch (qtype) { - case T_A: - case T_AAAA: - case T_ANY: /*use T_ANY only for T_A/T_AAAA lookup*/ - name_ok = res_hnok; - break; - case T_SRV: - name_ok = gai_srvok; - break; - default: - return NULL; /* XXX should be abort(); */ - } - /* - * find first satisfactory answer - */ - hp = &answer->hdr; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - bp = hostbuf; - ep = hostbuf + sizeof hostbuf; - cp = answer->buf + HFIXEDSZ; - if (qdcount != 1) { - h_errno = NO_RECOVERY; - return (NULL); - } - n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !(*name_ok)(bp)) { - h_errno = NO_RECOVERY; - return (NULL); - } - cp += n + QFIXEDSZ; - if (qtype == T_A || qtype == T_AAAA || qtype == T_ANY) { - /* res_send() has already verified that the query name is the - * same as the one we sent; this just gets the expanded name - * (i.e., with the succeeding search-domain tacked on). - */ - n = (int)strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - h_errno = NO_RECOVERY; - return (NULL); - } - canonname = bp; - bp += n; - /* The qname can be abbreviated, but h_name is now absolute. */ - qname = canonname; - } - haveanswer = 0; - had_error = 0; - srvlist = NULL; - while (ancount-- > 0 && cp < eom && !had_error) { - n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !(*name_ok)(bp)) { - had_error++; - continue; - } - cp += n; /* name */ - type = _getshort(cp); - cp += INT16SZ; /* type */ - class = _getshort(cp); - cp += INT16SZ + INT32SZ; /* class, TTL */ - n = _getshort(cp); - cp += INT16SZ; /* len */ - if (class != C_IN) { - /* XXX - debug? syslog? */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - if ((qtype == T_A || qtype == T_AAAA || qtype == T_ANY) && - type == T_CNAME) { - n = dn_expand(answer->buf, eom, cp, tbuf, (int)sizeof tbuf); - if ((n < 0) || !(*name_ok)(tbuf)) { - had_error++; - continue; - } - cp += n; - /* Get canonical name. */ - n = (int)strlen(tbuf) + 1; /* for the \0 */ - if (n > ep - bp || n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - strlcpy(bp, tbuf, (size_t)(ep - bp)); - canonname = bp; - bp += n; - continue; - } - if (qtype == T_ANY) { - if (!(type == T_A || type == T_AAAA)) { - cp += n; - continue; - } - } else if (type != qtype) { - if (type != T_KEY && type != T_SIG) { - struct syslog_data sd = SYSLOG_DATA_INIT; - syslog_r(LOG_NOTICE|LOG_AUTH, &sd, - "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", - qname, p_class(C_IN), p_type(qtype), - p_type(type)); - } - cp += n; - continue; /* XXX - had_error++ ? */ - } - switch (type) { - case T_A: - case T_AAAA: - if (strcasecmp(canonname, bp) != 0) { - struct syslog_data sd = SYSLOG_DATA_INIT; - syslog_r(LOG_NOTICE|LOG_AUTH, &sd, - AskedForGot, canonname, bp); - cp += n; - continue; /* XXX - had_error++ ? */ - } - if (type == T_A && n != INADDRSZ) { - cp += n; - continue; - } - if (type == T_AAAA && n != IN6ADDRSZ) { - cp += n; - continue; - } - if (type == T_AAAA) { - struct in6_addr in6; - memcpy(&in6, cp, IN6ADDRSZ); - if (IN6_IS_ADDR_V4MAPPED(&in6)) { - cp += n; - continue; - } - } - if (!haveanswer) { - int nn; - - canonname = bp; - nn = (int)strlen(bp) + 1; /* for the \0 */ - bp += nn; - } - - /* don't overwrite pai */ - ai = *pai; - ai.ai_family = (type == T_A) ? AF_INET : AF_INET6; - afd = find_afd(ai.ai_family); - if (afd == NULL) { - cp += n; - continue; - } - cur->ai_next = get_ai(&ai, afd, (const char *)cp); - if (cur->ai_next == NULL) - had_error++; - while (cur && cur->ai_next) - cur = cur->ai_next; - cp += n; - break; - case T_SRV: - /* Add to SRV list. Insertion sort on priority. */ - pri = _getshort(cp); - cp += INT16SZ; - weight = _getshort(cp); - cp += INT16SZ; - port = _getshort(cp); - cp += INT16SZ; - n = dn_expand(answer->buf, eom, cp, tbuf, - (int)sizeof(tbuf)); - if ((n < 0) || !res_hnok(tbuf)) { - had_error++; - continue; - } - cp += n; - if (strlen(tbuf) + 1 >= MAXDNAME) { - had_error++; - continue; - } - srv = malloc(sizeof(*srv)); - if (!srv) { - had_error++; - continue; - } - strlcpy(srv->name, tbuf, sizeof(srv->name)); - srv->pri = pri; - srv->weight = weight; - srv->port = port; - /* Weight 0 is sorted before other weights. */ - if (!srvlist - || srv->pri < srvlist->pri - || (srv->pri == srvlist->pri && - (!srv->weight || srvlist->weight))) { - srv->next = srvlist; - srvlist = srv; - } else { - for (csrv = srvlist; - csrv->next && csrv->next->pri <= srv->pri; - csrv = csrv->next) { - if (csrv->next->pri == srv->pri - && (!srv->weight || - csrv->next->weight)) - break; - } - srv->next = csrv->next; - csrv->next = srv; - } - continue; /* Don't add to haveanswer yet. */ - default: - abort(); - } - if (!had_error) - haveanswer++; - } - - if (srvlist) { - res_state res; - /* - * Check for explicit rejection. - */ - if (!srvlist->next && !srvlist->name[0]) { - free(srvlist); - h_errno = HOST_NOT_FOUND; - return NULL; - } - res = __res_get_state(); - if (res == NULL) { - while (srvlist != NULL) { - srv = srvlist; - srvlist = srvlist->next; - free(srv); - } - h_errno = NETDB_INTERNAL; - return NULL; - } - - while (srvlist) { - struct res_target q, q2; - - srv = srvlist; - srvlist = srvlist->next; - - /* - * Since res_* doesn't give the additional - * section, we always look up. - */ - memset(&q, 0, sizeof(q)); - memset(&q2, 0, sizeof(q2)); - - q.name = srv->name; - q.qclass = C_IN; - q.qtype = T_AAAA; - q.next = &q2; - q2.name = srv->name; - q2.qclass = C_IN; - q2.qtype = T_A; - - aip = _dns_query(&q, pai, res, 0); - - if (aip != NULL) { - cur->ai_next = aip; - while (cur && cur->ai_next) { - cur = cur->ai_next; - *getport(cur) = htons(srv->port); - haveanswer++; - } - } - free(srv); - } - __res_put_state(res); - } - if (haveanswer) { - if (!sentinel.ai_next->ai_canonname) - (void)get_canonname(pai, sentinel.ai_next, - canonname ? canonname : qname); - h_errno = NETDB_SUCCESS; - return sentinel.ai_next; - } - - h_errno = NO_RECOVERY; - return NULL; -} - -#define SORTEDADDR(p) (((struct sockaddr_in *)(void *)(p->ai_next->ai_addr))->sin_addr.s_addr) -#define SORTMATCH(p, s) ((SORTEDADDR(p) & (s).mask) == (s).addr.s_addr) - -static void -aisort(struct addrinfo *s, res_state res) -{ - struct addrinfo head, *t, *p; - int i; - - head.ai_next = NULL; - t = &head; - - for (i = 0; i < res->nsort; i++) { - p = s; - while (p->ai_next) { - if ((p->ai_next->ai_family != AF_INET) - || SORTMATCH(p, res->sort_list[i])) { - t->ai_next = p->ai_next; - t = t->ai_next; - p->ai_next = p->ai_next->ai_next; - } else { - p = p->ai_next; - } - } - } - - /* add rest of list and reset s to the new list*/ - t->ai_next = s->ai_next; - s->ai_next = head.ai_next; -} - -static struct addrinfo * -_dns_query(struct res_target *q, const struct addrinfo *pai, - res_state res, int dosearch) -{ - struct res_target *q2 = q->next; - querybuf *buf, *buf2; - struct addrinfo sentinel, *cur, *ai; - -#ifdef DNS_DEBUG - struct res_target *iter; - for (iter = q; iter; iter = iter->next) - printf("Query type %d for %s\n", iter->qtype, iter->name); -#endif - - buf = malloc(sizeof(*buf)); - if (buf == NULL) { - h_errno = NETDB_INTERNAL; - return NULL; - } - buf2 = malloc(sizeof(*buf2)); - if (buf2 == NULL) { - free(buf); - h_errno = NETDB_INTERNAL; - return NULL; - } - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - q->answer = buf->buf; - q->anslen = sizeof(buf->buf); - if (q2) { - q2->answer = buf2->buf; - q2->anslen = sizeof(buf2->buf); - } - - if (dosearch) { - if (res_searchN(q->name, q, res) < 0) - goto out; - } else { - if (res_queryN(q->name, q, res) < 0) - goto out; - } - - ai = getanswer(buf, q->n, q->name, q->qtype, pai); - if (ai) { - cur->ai_next = ai; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - if (q2) { - ai = getanswer(buf2, q2->n, q2->name, q2->qtype, pai); - if (ai) - cur->ai_next = ai; - } - free(buf); - free(buf2); - return sentinel.ai_next; -out: - free(buf); - free(buf2); - return NULL; -} - -/*ARGSUSED*/ -static struct addrinfo * -_dns_srv_lookup(const char *name, const char *servname, - const struct addrinfo *pai) -{ - static const char * const srvprotos[] = { "tcp", "udp" }; - static const int srvnottype[] = { SOCK_DGRAM, SOCK_STREAM }; - static const int nsrvprotos = 2; - struct addrinfo sentinel, *cur, *ai; - struct servent *serv, sv; - struct servent_data svd; - struct res_target q; - res_state res; - char *tname; - int i; - - res = __res_get_state(); - if (res == NULL) - return NULL; - - memset(&svd, 0, sizeof(svd)); - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - /* - * Iterate over supported SRV protocols. - * (currently UDP and TCP only) - */ - for (i = 0; i < nsrvprotos; i++) { - /* - * Check that the caller didn't specify a hint - * which precludes this protocol. - */ - if (pai->ai_socktype == srvnottype[i]) - continue; - /* - * If the caller specified a port, - * then lookup the database for the - * official service name. - */ - serv = getservbyname_r(servname, srvprotos[i], &sv, &svd); - if (serv == NULL) - continue; - - /* - * Construct service DNS name. - */ - if (asprintf(&tname, "_%s._%s.%s", serv->s_name, serv->s_proto, - name) < 0) - continue; - - memset(&q, 0, sizeof(q)); - q.name = tname; - q.qclass = C_IN; - q.qtype = T_SRV; - - /* - * Do SRV query. - */ - ai = _dns_query(&q, pai, res, 1); - if (ai) { - cur->ai_next = ai; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - free(tname); - } - - if (res->nsort) - aisort(&sentinel, res); - - __res_put_state(res); - - return sentinel.ai_next; -} - -/*ARGSUSED*/ -static struct addrinfo * -_dns_host_lookup(const char *name, const struct addrinfo *pai) -{ - struct res_target q, q2; - struct addrinfo sentinel, *ai; - res_state res; - - res = __res_get_state(); - if (res == NULL) - return NULL; - - memset(&q, 0, sizeof(q2)); - memset(&q2, 0, sizeof(q2)); - - switch (pai->ai_family) { - case AF_UNSPEC: - /* prefer IPv6 */ - q.name = name; - q.qclass = C_IN; - q.qtype = T_AAAA; - q.next = &q2; - q2.name = name; - q2.qclass = C_IN; - q2.qtype = T_A; - break; - case AF_INET: - q.name = name; - q.qclass = C_IN; - q.qtype = T_A; - break; - case AF_INET6: - q.name = name; - q.qclass = C_IN; - q.qtype = T_AAAA; - break; - default: - __res_put_state(res); - h_errno = NETDB_INTERNAL; - return NULL; - } - - ai = _dns_query(&q, pai, res, 1); - - memset(&sentinel, 0, sizeof(sentinel)); - sentinel.ai_next = ai; - - if (ai != NULL && res->nsort) - aisort(&sentinel, res); - - __res_put_state(res); - - return sentinel.ai_next; -} - -/*ARGSUSED*/ -static int -_dns_getaddrinfo(void *rv, void *cb_data, va_list ap) -{ - struct addrinfo *ai = NULL; - const char *name, *servname; - const struct addrinfo *pai; - - name = va_arg(ap, char *); - pai = va_arg(ap, const struct addrinfo *); - servname = va_arg(ap, char *); - - /* - * Try doing SRV lookup on service first. - */ - if (servname -#ifdef AI_SRV - && (pai->ai_flags & AI_SRV) -#endif - && !(pai->ai_flags & AI_NUMERICSERV) - && str2number(servname) == -1) { - -#ifdef DNS_DEBUG - printf("%s: try SRV lookup\n", __func__); -#endif - ai = _dns_srv_lookup(name, servname, pai); - } - - /* - * Do lookup on name. - */ - if (ai == NULL) { - -#ifdef DNS_DEBUG - printf("%s: try HOST lookup\n", __func__); -#endif - ai = _dns_host_lookup(name, pai); - - if (ai == NULL) { - switch (h_errno) { - case HOST_NOT_FOUND: - return NS_NOTFOUND; - case TRY_AGAIN: - return NS_TRYAGAIN; - default: - return NS_UNAVAIL; - } - } - } - - *((struct addrinfo **)rv) = ai; - return NS_SUCCESS; -} - -static void -_sethtent(FILE **hostf) -{ - - if (!*hostf) - *hostf = fopen(_PATH_HOSTS, "re"); - else - rewind(*hostf); -} - -static void -_endhtent(FILE **hostf) -{ - - if (*hostf) { - (void) fclose(*hostf); - *hostf = NULL; - } -} - -static struct addrinfo * -_gethtent(FILE **hostf, const char *name, const struct addrinfo *pai) -{ - char *p; - char *cp, *tname, *cname; - struct addrinfo hints, *res0, *res; - int error; - const char *addr; - char hostbuf[8*1024]; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(pai != NULL); - - if (!*hostf && !(*hostf = fopen(_PATH_HOSTS, "re"))) - return (NULL); - again: - if (!(p = fgets(hostbuf, (int)sizeof hostbuf, *hostf))) - return (NULL); - if (*p == '#') - goto again; - if (!(cp = strpbrk(p, "#\n"))) - goto again; - *cp = '\0'; - if (!(cp = strpbrk(p, " \t"))) - goto again; - *cp++ = '\0'; - addr = p; - /* if this is not something we're looking for, skip it. */ - cname = NULL; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (!cname) - cname = cp; - tname = cp; - if ((cp = strpbrk(cp, " \t")) != NULL) - *cp++ = '\0'; - if (strcasecmp(name, tname) == 0) - goto found; - } - goto again; - -found: - hints = *pai; - hints.ai_flags = AI_NUMERICHOST; - error = getaddrinfo(addr, NULL, &hints, &res0); - if (error) - goto again; - for (res = res0; res; res = res->ai_next) { - /* cover it up */ - res->ai_flags = pai->ai_flags; - - if (pai->ai_flags & AI_CANONNAME) { - if (get_canonname(pai, res, cname) != 0) { - freeaddrinfo(res0); - goto again; - } - } - } - return res0; -} - -/*ARGSUSED*/ -static int -_files_getaddrinfo(void *rv, void *cb_data, va_list ap) -{ - const char *name; - const struct addrinfo *pai; - struct addrinfo sentinel, *cur; - struct addrinfo *p; -#ifndef _REENTRANT - static -#endif - FILE *hostf = NULL; - - name = va_arg(ap, char *); - pai = va_arg(ap, const struct addrinfo *); - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - _sethtent(&hostf); - while ((p = _gethtent(&hostf, name, pai)) != NULL) { - cur->ai_next = p; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - _endhtent(&hostf); - - *((struct addrinfo **)rv) = sentinel.ai_next; - if (sentinel.ai_next == NULL) - return NS_NOTFOUND; - return NS_SUCCESS; -} - -#ifdef YP -/*ARGSUSED*/ -static struct addrinfo * -_yphostent(char *line, const struct addrinfo *pai) -{ - struct addrinfo sentinel, *cur; - struct addrinfo hints, *res, *res0; - int error; - char *p; - const char *addr, *canonname; - char *nextline; - char *cp; - - _DIAGASSERT(line != NULL); - _DIAGASSERT(pai != NULL); - - p = line; - addr = canonname = NULL; - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - -nextline: - /* terminate line */ - cp = strchr(p, '\n'); - if (cp) { - *cp++ = '\0'; - nextline = cp; - } else - nextline = NULL; - - cp = strpbrk(p, " \t"); - if (cp == NULL) { - if (canonname == NULL) - return (NULL); - else - goto done; - } - *cp++ = '\0'; - - addr = p; - - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (!canonname) - canonname = cp; - if ((cp = strpbrk(cp, " \t")) != NULL) - *cp++ = '\0'; - } - - hints = *pai; - hints.ai_flags = AI_NUMERICHOST; - error = getaddrinfo(addr, NULL, &hints, &res0); - if (error == 0) { - for (res = res0; res; res = res->ai_next) { - /* cover it up */ - res->ai_flags = pai->ai_flags; - - if (pai->ai_flags & AI_CANONNAME) - (void)get_canonname(pai, res, canonname); - } - } else - res0 = NULL; - if (res0) { - cur->ai_next = res0; - while (cur->ai_next) - cur = cur->ai_next; - } - - if (nextline) { - p = nextline; - goto nextline; - } - -done: - return sentinel.ai_next; -} - -/*ARGSUSED*/ -static int -_yp_getaddrinfo(void *rv, void *cb_data, va_list ap) -{ - struct addrinfo sentinel, *cur; - struct addrinfo *ai = NULL; - char *ypbuf; - int ypbuflen, r; - const char *name; - const struct addrinfo *pai; - char *ypdomain; - - if (_yp_check(&ypdomain) == 0) - return NS_UNAVAIL; - - name = va_arg(ap, char *); - pai = va_arg(ap, const struct addrinfo *); - - memset(&sentinel, 0, sizeof(sentinel)); - cur = &sentinel; - - /* hosts.byname is only for IPv4 (Solaris8) */ - if (pai->ai_family == PF_UNSPEC || pai->ai_family == PF_INET) { - r = yp_match(ypdomain, "hosts.byname", name, - (int)strlen(name), &ypbuf, &ypbuflen); - if (r == 0) { - struct addrinfo ai4; - - ai4 = *pai; - ai4.ai_family = AF_INET; - ai = _yphostent(ypbuf, &ai4); - if (ai) { - cur->ai_next = ai; - while (cur && cur->ai_next) - cur = cur->ai_next; - } - } - free(ypbuf); - } - - /* ipnodes.byname can hold both IPv4/v6 */ - r = yp_match(ypdomain, "ipnodes.byname", name, - (int)strlen(name), &ypbuf, &ypbuflen); - if (r == 0) { - ai = _yphostent(ypbuf, pai); - if (ai) - cur->ai_next = ai; - free(ypbuf); - } - - if (sentinel.ai_next == NULL) { - h_errno = HOST_NOT_FOUND; - return NS_NOTFOUND; - } - *((struct addrinfo **)rv) = sentinel.ai_next; - return NS_SUCCESS; -} -#endif - -/* resolver logic */ - -/* - * Formulate a normal query, send, and await answer. - * Returned answer is placed in supplied buffer "answer". - * Perform preliminary check of answer, returning success only - * if no error is indicated and the answer count is nonzero. - * Return the size of the response on success, -1 on error. - * Error number is left in h_errno. - * - * Caller must parse answer and determine whether it answers the question. - */ -static int -res_queryN(const char *name, /* domain name */ struct res_target *target, - res_state res) -{ - u_char buf[MAXPACKET]; - HEADER *hp; - int n; - struct res_target *t; - int rcode; - int ancount; - - _DIAGASSERT(name != NULL); - /* XXX: target may be NULL??? */ - - rcode = NOERROR; - ancount = 0; - - for (t = target; t; t = t->next) { - int class, type; - u_char *answer; - int anslen; - - hp = (HEADER *)(void *)t->answer; - hp->rcode = NOERROR; /* default */ - - /* make it easier... */ - class = t->qclass; - type = t->qtype; - answer = t->answer; - anslen = t->anslen; -#ifdef DEBUG - if (res->options & RES_DEBUG) - printf(";; res_nquery(%s, %d, %d)\n", name, class, type); -#endif - - n = res_nmkquery(res, QUERY, name, class, type, NULL, 0, NULL, - buf, (int)sizeof(buf)); -#ifdef RES_USE_EDNS0 - if (n > 0 && (res->options & RES_USE_EDNS0) != 0) - n = res_nopt(res, n, buf, (int)sizeof(buf), anslen); -#endif - if (n <= 0) { -#ifdef DEBUG - if (res->options & RES_DEBUG) - printf(";; res_nquery: mkquery failed\n"); -#endif - h_errno = NO_RECOVERY; - return n; - } - n = res_nsend(res, buf, n, answer, anslen); -#if 0 - if (n < 0) { -#ifdef DEBUG - if (res->options & RES_DEBUG) - printf(";; res_query: send error\n"); -#endif - h_errno = TRY_AGAIN; - return n; - } -#endif - - if (n < 0 || hp->rcode != NOERROR || ntohs(hp->ancount) == 0) { - rcode = hp->rcode; /* record most recent error */ -#ifdef DEBUG - if (res->options & RES_DEBUG) - printf(";; rcode = %u, ancount=%u\n", hp->rcode, - ntohs(hp->ancount)); -#endif - continue; - } - - ancount += ntohs(hp->ancount); - - t->n = n; - } - - if (ancount == 0) { - switch (rcode) { - case NXDOMAIN: - h_errno = HOST_NOT_FOUND; - break; - case SERVFAIL: - h_errno = TRY_AGAIN; - break; - case NOERROR: - h_errno = NO_DATA; - break; - case FORMERR: - case NOTIMP: - case REFUSED: - default: - h_errno = NO_RECOVERY; - break; - } - return -1; - } - return ancount; -} - -/* - * Formulate a normal query, send, and retrieve answer in supplied buffer. - * Return the size of the response on success, -1 on error. - * If enabled, implement search rules until answer or unrecoverable failure - * is detected. Error code, if any, is left in h_errno. - */ -static int -res_searchN(const char *name, struct res_target *target, res_state res) -{ - const char *cp, * const *domain; - HEADER *hp; - u_int dots; - char buf[MAXHOSTNAMELEN]; - int trailing_dot, ret, saved_herrno; - int got_nodata = 0, got_servfail = 0, tried_as_is = 0; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(target != NULL); - - hp = (HEADER *)(void *)target->answer; /*XXX*/ - - errno = 0; - h_errno = HOST_NOT_FOUND; /* default, if we never query */ - dots = 0; - for (cp = name; *cp; cp++) - dots += (*cp == '.'); - trailing_dot = 0; - if (cp > name && *--cp == '.') - trailing_dot++; - - /* - * if there aren't any dots, it could be a user-level alias - */ - if (!dots && (cp = res_hostalias(res, name, buf, sizeof(buf))) != NULL) { - ret = res_queryN(cp, target, res); - return ret; - } - - /* - * If there are dots in the name already, let's just give it a try - * 'as is'. The threshold can be set with the "ndots" option. - */ - saved_herrno = -1; - if (dots >= res->ndots) { - ret = res_querydomainN(name, NULL, target, res); - if (ret > 0) - return (ret); - saved_herrno = h_errno; - tried_as_is++; - } - - /* - * We do at least one level of search if - * - there is no dot and RES_DEFNAME is set, or - * - there is at least one dot, there is no trailing dot, - * and RES_DNSRCH is set. - */ - if ((!dots && (res->options & RES_DEFNAMES)) || - (dots && !trailing_dot && (res->options & RES_DNSRCH))) { - int done = 0; - - for (domain = (const char * const *)res->dnsrch; - *domain && !done; - domain++) { - - ret = res_querydomainN(name, *domain, target, res); - if (ret > 0) - return ret; - - /* - * If no server present, give up. - * If name isn't found in this domain, - * keep trying higher domains in the search list - * (if that's enabled). - * On a NO_DATA error, keep trying, otherwise - * a wildcard entry of another type could keep us - * from finding this entry higher in the domain. - * If we get some other error (negative answer or - * server failure), then stop searching up, - * but try the input name below in case it's - * fully-qualified. - */ - if (errno == ECONNREFUSED) { - h_errno = TRY_AGAIN; - return -1; - } - - switch (h_errno) { - case NO_DATA: - got_nodata++; - /* FALLTHROUGH */ - case HOST_NOT_FOUND: - /* keep trying */ - break; - case TRY_AGAIN: - if (hp->rcode == SERVFAIL) { - /* try next search element, if any */ - got_servfail++; - break; - } - /* FALLTHROUGH */ - default: - /* anything else implies that we're done */ - done++; - } - /* - * if we got here for some reason other than DNSRCH, - * we only wanted one iteration of the loop, so stop. - */ - if (!(res->options & RES_DNSRCH)) - done++; - } - } - - /* - * if we have not already tried the name "as is", do that now. - * note that we do this regardless of how many dots were in the - * name or whether it ends with a dot. - */ - if (!tried_as_is) { - ret = res_querydomainN(name, NULL, target, res); - if (ret > 0) - return ret; - } - - /* - * if we got here, we didn't satisfy the search. - * if we did an initial full query, return that query's h_errno - * (note that we wouldn't be here if that query had succeeded). - * else if we ever got a nodata, send that back as the reason. - * else send back meaningless h_errno, that being the one from - * the last DNSRCH we did. - */ - if (saved_herrno != -1) - h_errno = saved_herrno; - else if (got_nodata) - h_errno = NO_DATA; - else if (got_servfail) - h_errno = TRY_AGAIN; - return -1; -} - -/* - * Perform a call on res_query on the concatenation of name and domain, - * removing a trailing dot from name if domain is NULL. - */ -static int -res_querydomainN(const char *name, const char *domain, - struct res_target *target, res_state res) -{ - char nbuf[MAXDNAME]; - const char *longname = nbuf; - size_t n, d; - - _DIAGASSERT(name != NULL); - /* XXX: target may be NULL??? */ - -#ifdef DEBUG - if (res->options & RES_DEBUG) - printf(";; res_querydomain(%s, %s)\n", - name, domain?domain:""); -#endif - if (domain == NULL) { - /* - * Check for trailing '.'; - * copy without '.' if present. - */ - n = strlen(name); - if (n + 1 > sizeof(nbuf)) { - h_errno = NO_RECOVERY; - return -1; - } - if (n > 0 && name[--n] == '.') { - strncpy(nbuf, name, n); - nbuf[n] = '\0'; - } else - longname = name; - } else { - n = strlen(name); - d = strlen(domain); - if (n + 1 + d + 1 > sizeof(nbuf)) { - h_errno = NO_RECOVERY; - return -1; - } - snprintf(nbuf, sizeof(nbuf), "%s.%s", name, domain); - } - return res_queryN(longname, target, res); -} - -#ifdef TEST -int -main(int argc, char *argv[]) { - struct addrinfo *ai, *sai; - int i, e; - char buf[1024]; - - for (i = 1; i < argc; i++) { - if ((e = getaddrinfo(argv[i], NULL, NULL, &sai)) != 0) - warnx("%s: %s", argv[i], gai_strerror(e)); - for (ai = sai; ai; ai = ai->ai_next) { - sockaddr_snprintf(buf, sizeof(buf), "%a", ai->ai_addr); - printf("flags=0x%x family=%d socktype=%d protocol=%d " - "addrlen=%zu addr=%s canonname=%s next=%p\n", - ai->ai_flags, - ai->ai_family, - ai->ai_socktype, - ai->ai_protocol, - (size_t)ai->ai_addrlen, - buf, - ai->ai_canonname, - ai->ai_next); - } - if (sai) - freeaddrinfo(sai); - } - return 0; -} -#endif diff --git a/lib/libc/net/gethnamaddr.c b/lib/libc/net/gethnamaddr.c deleted file mode 100644 index a83435ceb..000000000 --- a/lib/libc/net/gethnamaddr.c +++ /dev/null @@ -1,1363 +0,0 @@ -/* $NetBSD: gethnamaddr.c,v 1.92 2015/09/22 16:16:02 christos Exp $ */ - -/* - * ++Copyright++ 1985, 1988, 1993 - * - - * Copyright (c) 1985, 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - * - - * --Copyright-- - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)gethostnamadr.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "Id: gethnamaddr.c,v 8.21 1997/06/01 20:34:37 vixie Exp "; -#else -__RCSID("$NetBSD: gethnamaddr.c,v 1.92 2015/09/22 16:16:02 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(_LIBC) -#include "namespace.h" -#endif -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef LOG_AUTH -# define LOG_AUTH 0 -#endif - -#define MULTI_PTRS_ARE_ALIASES 1 /* XXX - experimental */ - -#include -#include -#include - -#ifdef YP -#include -#include -#include -#endif - -#include "hostent.h" - -#if defined(_LIBC) && defined(__weak_alias) -__weak_alias(gethostbyaddr,_gethostbyaddr) -__weak_alias(gethostbyname,_gethostbyname) -__weak_alias(gethostent,_gethostent) -#endif - -#define maybe_ok(res, nm, ok) (((res)->options & RES_NOCHECKNAME) != 0U || \ - (ok)(nm) != 0) -#define maybe_hnok(res, hn) maybe_ok((res), (hn), res_hnok) -#define maybe_dnok(res, dn) maybe_ok((res), (dn), res_dnok) - -#define addalias(d, s, arr, siz) do { \ - if (d >= &arr[siz]) { \ - char **xptr = realloc(arr, (siz + 10) * sizeof(*arr)); \ - if (xptr == NULL) \ - goto nospc; \ - d = xptr + (d - arr); \ - arr = xptr; \ - siz += 10; \ - } \ - *d++ = s; \ -} while (/*CONSTCOND*/0) - -#define setup(arr, siz) do { \ - arr = malloc((siz = 10) * sizeof(*arr)); \ - if (arr == NULL) \ - goto nospc; \ -} while (/*CONSTCOND*/0) - - -static const char AskedForGot[] = - "gethostby*.getanswer: asked for \"%s\", got \"%s\""; - - -#ifdef YP -static char *__ypdomain; -#endif - -#define MAXPACKET (64*1024) - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -typedef union { - int32_t al; - char ac; -} align; - -#ifdef DEBUG -static void debugprintf(const char *, res_state, ...) - __attribute__((__format__(__printf__, 1, 3))); -#endif -static struct hostent *getanswer(const querybuf *, int, const char *, int, - res_state, struct hostent *, char *, size_t, int *); -static void map_v4v6_address(const char *, char *); -static void map_v4v6_hostent(struct hostent *, char **, char *); -static void addrsort(char **, int, res_state); - -void dns_service(void); -#undef dn_skipname -int dn_skipname(const u_char *, const u_char *); - -#ifdef YP -static struct hostent *_yp_hostent(char *, int, struct getnamaddr *); -#endif - -static struct hostent *gethostbyname_internal(const char *, int, res_state, - struct hostent *, char *, size_t, int *); - -static const ns_src default_dns_files[] = { - { NSSRC_FILES, NS_SUCCESS }, - { NSSRC_DNS, NS_SUCCESS }, - { 0, 0 } -}; - - -#ifdef DEBUG -static void -debugprintf(const char *msg, res_state res, ...) -{ - _DIAGASSERT(msg != NULL); - - if (res->options & RES_DEBUG) { - int save = errno; - va_list ap; - - va_start (ap, res); - vprintf(msg, ap); - va_end (ap); - - errno = save; - } -} -#else -# define debugprintf(msg, res, num) /*nada*/ -#endif - -#define BOUNDED_INCR(x) \ - do { \ - cp += (x); \ - if (cp > eom) \ - goto no_recovery; \ - } while (/*CONSTCOND*/0) - -#define BOUNDS_CHECK(ptr, count) \ - do { \ - if ((ptr) + (count) > eom) \ - goto no_recovery; \ - } while (/*CONSTCOND*/0) - -static struct hostent * -getanswer(const querybuf *answer, int anslen, const char *qname, int qtype, - res_state res, struct hostent *hent, char *buf, size_t buflen, int *he) -{ - const HEADER *hp; - const u_char *cp; - int n; - size_t qlen; - const u_char *eom, *erdata; - char *bp, **ap, **hap, *ep; - int type, class, ancount, qdcount; - int haveanswer, had_error; - int toobig = 0; - char tbuf[MAXDNAME]; - char **aliases; - size_t maxaliases; - char *addr_ptrs[MAXADDRS]; - const char *tname; - int (*name_ok)(const char *); - - _DIAGASSERT(answer != NULL); - _DIAGASSERT(qname != NULL); - - tname = qname; - hent->h_name = NULL; - eom = answer->buf + anslen; - switch (qtype) { - case T_A: - case T_AAAA: - name_ok = res_hnok; - break; - case T_PTR: - name_ok = res_dnok; - break; - default: - *he = NO_RECOVERY; - return NULL; /* XXX should be abort(); */ - } - - setup(aliases, maxaliases); - /* - * find first satisfactory answer - */ - hp = &answer->hdr; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - bp = buf; - ep = buf + buflen; - cp = answer->buf; - BOUNDED_INCR(HFIXEDSZ); - if (qdcount != 1) - goto no_recovery; - - n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !maybe_ok(res, bp, name_ok)) - goto no_recovery; - - BOUNDED_INCR(n + QFIXEDSZ); - if (qtype == T_A || qtype == T_AAAA) { - /* res_send() has already verified that the query name is the - * same as the one we sent; this just gets the expanded name - * (i.e., with the succeeding search-domain tacked on). - */ - n = (int)strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) - goto no_recovery; - hent->h_name = bp; - bp += n; - /* The qname can be abbreviated, but h_name is now absolute. */ - qname = hent->h_name; - } - hent->h_aliases = ap = aliases; - hent->h_addr_list = hap = addr_ptrs; - *ap = NULL; - *hap = NULL; - haveanswer = 0; - had_error = 0; - while (ancount-- > 0 && cp < eom && !had_error) { - n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !maybe_ok(res, bp, name_ok)) { - had_error++; - continue; - } - cp += n; /* name */ - BOUNDS_CHECK(cp, 3 * INT16SZ + INT32SZ); - type = _getshort(cp); - cp += INT16SZ; /* type */ - class = _getshort(cp); - cp += INT16SZ + INT32SZ; /* class, TTL */ - n = _getshort(cp); - cp += INT16SZ; /* len */ - BOUNDS_CHECK(cp, n); - erdata = cp + n; - if (class != C_IN) { - /* XXX - debug? syslog? */ - cp += n; - continue; /* XXX - had_error++ ? */ - } - if ((qtype == T_A || qtype == T_AAAA) && type == T_CNAME) { - n = dn_expand(answer->buf, eom, cp, tbuf, - (int)sizeof tbuf); - if ((n < 0) || !maybe_ok(res, tbuf, name_ok)) { - had_error++; - continue; - } - cp += n; - if (cp != erdata) - goto no_recovery; - /* Store alias. */ - addalias(ap, bp, aliases, maxaliases); - n = (int)strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - bp += n; - /* Get canonical name. */ - n = (int)strlen(tbuf) + 1; /* for the \0 */ - if (n > ep - bp || n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - strlcpy(bp, tbuf, (size_t)(ep - bp)); - hent->h_name = bp; - bp += n; - continue; - } - if (qtype == T_PTR && type == T_CNAME) { - n = dn_expand(answer->buf, eom, cp, tbuf, - (int)sizeof tbuf); - if (n < 0 || !maybe_dnok(res, tbuf)) { - had_error++; - continue; - } - cp += n; - if (cp != erdata) - goto no_recovery; - /* Get canonical name. */ - n = (int)strlen(tbuf) + 1; /* for the \0 */ - if (n > ep - bp || n >= MAXHOSTNAMELEN) { - had_error++; - continue; - } - strlcpy(bp, tbuf, (size_t)(ep - bp)); - tname = bp; - bp += n; - continue; - } - if (type != qtype) { - if (type != T_KEY && type != T_SIG) - syslog(LOG_NOTICE|LOG_AUTH, - "gethostby*.getanswer: asked for \"%s %s %s\", got type \"%s\"", - qname, p_class(C_IN), p_type(qtype), - p_type(type)); - cp += n; - continue; /* XXX - had_error++ ? */ - } - switch (type) { - case T_PTR: - if (strcasecmp(tname, bp) != 0) { - syslog(LOG_NOTICE|LOG_AUTH, - AskedForGot, qname, bp); - cp += n; - continue; /* XXX - had_error++ ? */ - } - n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !maybe_hnok(res, bp)) { - had_error++; - break; - } -#if MULTI_PTRS_ARE_ALIASES - cp += n; - if (cp != erdata) - goto no_recovery; - if (!haveanswer) - hent->h_name = bp; - else - addalias(ap, bp, aliases, maxaliases); - if (n != -1) { - n = (int)strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - had_error++; - break; - } - bp += n; - } - break; -#else - hent->h_name = bp; - if (res->options & RES_USE_INET6) { - n = strlen(bp) + 1; /* for the \0 */ - if (n >= MAXHOSTNAMELEN) { - had_error++; - break; - } - bp += n; - map_v4v6_hostent(hent, &bp, ep); - } - goto success; -#endif - case T_A: - case T_AAAA: - if (strcasecmp(hent->h_name, bp) != 0) { - syslog(LOG_NOTICE|LOG_AUTH, - AskedForGot, hent->h_name, bp); - cp += n; - continue; /* XXX - had_error++ ? */ - } - if (n != hent->h_length) { - cp += n; - continue; - } - if (type == T_AAAA) { - struct in6_addr in6; - memcpy(&in6, cp, NS_IN6ADDRSZ); - if (IN6_IS_ADDR_V4MAPPED(&in6)) { - cp += n; - continue; - } - } - if (!haveanswer) { - int nn; - - hent->h_name = bp; - nn = (int)strlen(bp) + 1; /* for the \0 */ - bp += nn; - } - - bp += sizeof(align) - - (size_t)((u_long)bp % sizeof(align)); - - if (bp + n >= ep) { - debugprintf("size (%d) too big\n", res, n); - had_error++; - continue; - } - if (hap >= &addr_ptrs[MAXADDRS - 1]) { - if (!toobig++) { - debugprintf("Too many addresses (%d)\n", - res, MAXADDRS); - } - cp += n; - continue; - } - (void)memcpy(*hap++ = bp, cp, (size_t)n); - bp += n; - cp += n; - if (cp != erdata) - goto no_recovery; - break; - default: - abort(); - } - if (!had_error) - haveanswer++; - } - if (haveanswer) { - *ap = NULL; - *hap = NULL; - /* - * Note: we sort even if host can take only one address - * in its return structures - should give it the "best" - * address in that case, not some random one - */ - if (res->nsort && haveanswer > 1 && qtype == T_A) - addrsort(addr_ptrs, haveanswer, res); - if (!hent->h_name) { - n = (int)strlen(qname) + 1; /* for the \0 */ - if (n > ep - bp || n >= MAXHOSTNAMELEN) - goto no_recovery; - strlcpy(bp, qname, (size_t)(ep - bp)); - hent->h_name = bp; - bp += n; - } - if (res->options & RES_USE_INET6) - map_v4v6_hostent(hent, &bp, ep); - goto success; - } -no_recovery: - free(aliases); - *he = NO_RECOVERY; - return NULL; -success: - bp = (char *)ALIGN(bp); - n = (int)(ap - aliases); - qlen = (n + 1) * sizeof(*hent->h_aliases); - if ((size_t)(ep - bp) < qlen) - goto nospc; - hent->h_aliases = (void *)bp; - memcpy(bp, aliases, qlen); - free(aliases); - aliases = NULL; - - bp += qlen; - n = (int)(hap - addr_ptrs); - qlen = (n + 1) * sizeof(*hent->h_addr_list); - if ((size_t)(ep - bp) < qlen) - goto nospc; - hent->h_addr_list = (void *)bp; - memcpy(bp, addr_ptrs, qlen); - *he = NETDB_SUCCESS; - return hent; -nospc: - free(aliases); - errno = ENOSPC; - *he = NETDB_INTERNAL; - return NULL; -} - -struct hostent * -gethostbyname_r(const char *name, struct hostent *hp, char *buf, size_t buflen, - int *he) -{ - res_state res = __res_get_state(); - - if (res == NULL) { - *he = NETDB_INTERNAL; - return NULL; - } - - _DIAGASSERT(name != NULL); - - if (res->options & RES_USE_INET6) { - struct hostent *nhp = gethostbyname_internal(name, AF_INET6, - res, hp, buf, buflen, he); - if (nhp) { - __res_put_state(res); - return nhp; - } - } - hp = gethostbyname_internal(name, AF_INET, res, hp, buf, buflen, he); - __res_put_state(res); - return hp; -} - -struct hostent * -gethostbyname2_r(const char *name, int af, struct hostent *hp, char *buf, - size_t buflen, int *he) -{ - res_state res = __res_get_state(); - - if (res == NULL) { - *he = NETDB_INTERNAL; - return NULL; - } - hp = gethostbyname_internal(name, af, res, hp, buf, buflen, he); - __res_put_state(res); - return hp; -} - -static struct hostent * -gethostbyname_internal(const char *name, int af, res_state res, - struct hostent *hp, char *buf, size_t buflen, int *he) -{ - const char *cp; - struct getnamaddr info; - char hbuf[MAXHOSTNAMELEN]; - size_t size; - static const ns_dtab dtab[] = { - NS_FILES_CB(_hf_gethtbyname, NULL) - { NSSRC_DNS, _dns_gethtbyname, NULL }, /* force -DHESIOD */ - NS_NIS_CB(_yp_gethtbyname, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(name != NULL); - - switch (af) { - case AF_INET: - size = NS_INADDRSZ; - break; - case AF_INET6: - size = NS_IN6ADDRSZ; - break; - default: - *he = NETDB_INTERNAL; - errno = EAFNOSUPPORT; - return NULL; - } - if (buflen < size) - goto nospc; - - hp->h_addrtype = af; - hp->h_length = (int)size; - - /* - * if there aren't any dots, it could be a user-level alias. - * this is also done in res_nquery() since we are not the only - * function that looks up host names. - */ - if (!strchr(name, '.') && (cp = res_hostalias(res, name, - hbuf, sizeof(hbuf)))) - name = cp; - - /* - * disallow names consisting only of digits/dots, unless - * they end in a dot. - */ - if (isdigit((u_char) name[0])) - for (cp = name;; ++cp) { - if (!*cp) { - if (*--cp == '.') - break; - /* - * All-numeric, no dot at the end. - * Fake up a hostent as if we'd actually - * done a lookup. - */ - goto fake; - } - if (!isdigit((u_char) *cp) && *cp != '.') - break; - } - if ((isxdigit((u_char) name[0]) && strchr(name, ':') != NULL) || - name[0] == ':') - for (cp = name;; ++cp) { - if (!*cp) { - if (*--cp == '.') - break; - /* - * All-IPv6-legal, no dot at the end. - * Fake up a hostent as if we'd actually - * done a lookup. - */ - goto fake; - } - if (!isxdigit((u_char) *cp) && *cp != ':' && *cp != '.') - break; - } - - *he = NETDB_INTERNAL; - info.hp = hp; - info.buf = buf; - info.buflen = buflen; - info.he = he; - if (nsdispatch(&info, dtab, NSDB_HOSTS, "gethostbyname", - default_dns_files, name, strlen(name), af) != NS_SUCCESS) - return NULL; - *he = NETDB_SUCCESS; - return hp; -nospc: - *he = NETDB_INTERNAL; - errno = ENOSPC; - return NULL; -fake: - HENT_ARRAY(hp->h_addr_list, 1, buf, buflen); - HENT_ARRAY(hp->h_aliases, 0, buf, buflen); - - hp->h_aliases[0] = NULL; - if (size > buflen) - goto nospc; - - if (inet_pton(af, name, buf) <= 0) { - *he = HOST_NOT_FOUND; - return NULL; - } - hp->h_addr_list[0] = buf; - hp->h_addr_list[1] = NULL; - buf += size; - buflen -= size; - HENT_SCOPY(hp->h_name, name, buf, buflen); - if (res->options & RES_USE_INET6) - map_v4v6_hostent(hp, &buf, buf + buflen); - *he = NETDB_SUCCESS; - return hp; -} - -struct hostent * -gethostbyaddr_r(const void *addr, socklen_t len, int af, struct hostent *hp, - char *buf, size_t buflen, int *he) -{ - const u_char *uaddr = (const u_char *)addr; - socklen_t size; - struct getnamaddr info; - static const ns_dtab dtab[] = { - NS_FILES_CB(_hf_gethtbyaddr, NULL) - { NSSRC_DNS, _dns_gethtbyaddr, NULL }, /* force -DHESIOD */ - NS_NIS_CB(_yp_gethtbyaddr, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(addr != NULL); - - if (af == AF_INET6 && len == NS_IN6ADDRSZ && - (IN6_IS_ADDR_LINKLOCAL((const struct in6_addr *)addr) || - IN6_IS_ADDR_SITELOCAL((const struct in6_addr *)addr))) { - *he = HOST_NOT_FOUND; - return NULL; - } - if (af == AF_INET6 && len == NS_IN6ADDRSZ && - (IN6_IS_ADDR_V4MAPPED((const struct in6_addr *)addr) || - IN6_IS_ADDR_V4COMPAT((const struct in6_addr *)addr))) { - /* Unmap. */ - uaddr += NS_IN6ADDRSZ - NS_INADDRSZ; - addr = uaddr; - af = AF_INET; - len = NS_INADDRSZ; - } - switch (af) { - case AF_INET: - size = NS_INADDRSZ; - break; - case AF_INET6: - size = NS_IN6ADDRSZ; - break; - default: - errno = EAFNOSUPPORT; - *he = NETDB_INTERNAL; - return NULL; - } - if (size != len) { - errno = EINVAL; - *he = NETDB_INTERNAL; - return NULL; - } - info.hp = hp; - info.buf = buf; - info.buflen = buflen; - info.he = he; - *he = NETDB_INTERNAL; - if (nsdispatch(&info, dtab, NSDB_HOSTS, "gethostbyaddr", - default_dns_files, uaddr, len, af) != NS_SUCCESS) - return NULL; - *he = NETDB_SUCCESS; - return hp; -} - -struct hostent * -gethostent_r(FILE *hf, struct hostent *hent, char *buf, size_t buflen, int *he) -{ - char *p, *name; - char *cp, **q; - int af, len; - size_t anum; - char **aliases; - size_t maxaliases; - struct in6_addr host_addr; - - if (hf == NULL) { - *he = NETDB_INTERNAL; - errno = EINVAL; - return NULL; - } - p = NULL; - setup(aliases, maxaliases); - for (;;) { - free(p); - p = fparseln(hf, NULL, NULL, NULL, FPARSELN_UNESCALL); - if (p == NULL) { - free(aliases); - *he = HOST_NOT_FOUND; - return NULL; - } - if (!(cp = strpbrk(p, " \t"))) - continue; - *cp++ = '\0'; - if (inet_pton(AF_INET6, p, &host_addr) > 0) { - af = AF_INET6; - len = NS_IN6ADDRSZ; - } else { - if (inet_pton(AF_INET, p, &host_addr) <= 0) - continue; - - res_state res = __res_get_state(); - if (res == NULL) - goto nospc; - if (res->options & RES_USE_INET6) { - map_v4v6_address(buf, buf); - af = AF_INET6; - len = NS_IN6ADDRSZ; - } else { - af = AF_INET; - len = NS_INADDRSZ; - } - __res_put_state(res); - } - - /* if this is not something we're looking for, skip it. */ - if (hent->h_addrtype != 0 && hent->h_addrtype != af) - continue; - if (hent->h_length != 0 && hent->h_length != len) - continue; - - while (*cp == ' ' || *cp == '\t') - cp++; - if ((cp = strpbrk(name = cp, " \t")) != NULL) - *cp++ = '\0'; - q = aliases; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - addalias(q, cp, aliases, maxaliases); - if ((cp = strpbrk(cp, " \t")) != NULL) - *cp++ = '\0'; - } - break; - } - hent->h_length = len; - hent->h_addrtype = af; - HENT_ARRAY(hent->h_addr_list, 1, buf, buflen); - anum = (size_t)(q - aliases); - HENT_ARRAY(hent->h_aliases, anum, buf, buflen); - HENT_COPY(hent->h_addr_list[0], &host_addr, hent->h_length, buf, - buflen); - hent->h_addr_list[1] = NULL; - - HENT_SCOPY(hent->h_name, name, buf, buflen); - for (size_t i = 0; i < anum; i++) - HENT_SCOPY(hent->h_aliases[i], aliases[i], buf, buflen); - hent->h_aliases[anum] = NULL; - - *he = NETDB_SUCCESS; - free(p); - free(aliases); - return hent; -nospc: - free(p); - free(aliases); - errno = ENOSPC; - *he = NETDB_INTERNAL; - return NULL; -} - -static void -map_v4v6_address(const char *src, char *dst) -{ - u_char *p = (u_char *)dst; - char tmp[NS_INADDRSZ]; - int i; - - _DIAGASSERT(src != NULL); - _DIAGASSERT(dst != NULL); - - /* Stash a temporary copy so our caller can update in place. */ - (void)memcpy(tmp, src, NS_INADDRSZ); - /* Mark this ipv6 addr as a mapped ipv4. */ - for (i = 0; i < 10; i++) - *p++ = 0x00; - *p++ = 0xff; - *p++ = 0xff; - /* Retrieve the saved copy and we're done. */ - (void)memcpy(p, tmp, NS_INADDRSZ); -} - -static void -map_v4v6_hostent(struct hostent *hp, char **bpp, char *ep) -{ - char **ap; - - _DIAGASSERT(hp != NULL); - _DIAGASSERT(bpp != NULL); - _DIAGASSERT(ep != NULL); - - if (hp->h_addrtype != AF_INET || hp->h_length != NS_INADDRSZ) - return; - hp->h_addrtype = AF_INET6; - hp->h_length = NS_IN6ADDRSZ; - for (ap = hp->h_addr_list; *ap; ap++) { - int i = (int)(sizeof(align) - - (size_t)((u_long)*bpp % sizeof(align))); - - if (ep - *bpp < (i + NS_IN6ADDRSZ)) { - /* Out of memory. Truncate address list here. XXX */ - *ap = NULL; - return; - } - *bpp += i; - map_v4v6_address(*ap, *bpp); - *ap = *bpp; - *bpp += NS_IN6ADDRSZ; - } -} - -static void -addrsort(char **ap, int num, res_state res) -{ - int i, j; - char **p; - short aval[MAXADDRS]; - int needsort = 0; - - _DIAGASSERT(ap != NULL); - - p = ap; - for (i = 0; i < num; i++, p++) { - for (j = 0 ; (unsigned)j < res->nsort; j++) - if (res->sort_list[j].addr.s_addr == - (((struct in_addr *)(void *)(*p))->s_addr & - res->sort_list[j].mask)) - break; - aval[i] = j; - if (needsort == 0 && i > 0 && j < aval[i-1]) - needsort = i; - } - if (!needsort) - return; - - while (needsort < num) { - for (j = needsort - 1; j >= 0; j--) { - if (aval[j] > aval[j+1]) { - char *hp; - - i = aval[j]; - aval[j] = aval[j+1]; - aval[j+1] = i; - - hp = ap[j]; - ap[j] = ap[j+1]; - ap[j+1] = hp; - } else - break; - } - needsort++; - } -} - - -/*ARGSUSED*/ -int -_dns_gethtbyname(void *rv, void *cb_data, va_list ap) -{ - querybuf *buf; - int n, type; - struct hostent *hp; - const char *name; - res_state res; - struct getnamaddr *info = rv; - - _DIAGASSERT(rv != NULL); - - name = va_arg(ap, char *); - /* NOSTRICT skip string len */(void)va_arg(ap, int); - info->hp->h_addrtype = va_arg(ap, int); - - switch (info->hp->h_addrtype) { - case AF_INET: - info->hp->h_length = NS_INADDRSZ; - type = T_A; - break; - case AF_INET6: - info->hp->h_length = NS_IN6ADDRSZ; - type = T_AAAA; - break; - default: - return NS_UNAVAIL; - } - buf = malloc(sizeof(*buf)); - if (buf == NULL) { - *info->he = NETDB_INTERNAL; - return NS_NOTFOUND; - } - res = __res_get_state(); - if (res == NULL) { - free(buf); - *info->he = NETDB_INTERNAL; - return NS_NOTFOUND; - } - n = res_nsearch(res, name, C_IN, type, buf->buf, (int)sizeof(buf->buf)); - if (n < 0) { - free(buf); - debugprintf("res_nsearch failed (%d)\n", res, n); - __res_put_state(res); - return NS_NOTFOUND; - } - hp = getanswer(buf, n, name, type, res, info->hp, info->buf, - info->buflen, info->he); - free(buf); - __res_put_state(res); - if (hp == NULL) - switch (*info->he) { - case HOST_NOT_FOUND: - return NS_NOTFOUND; - case TRY_AGAIN: - return NS_TRYAGAIN; - default: - return NS_UNAVAIL; - } - return NS_SUCCESS; -} - -/*ARGSUSED*/ -int -_dns_gethtbyaddr(void *rv, void *cb_data, va_list ap) -{ - char qbuf[MAXDNAME + 1], *qp, *ep; - int n; - querybuf *buf; - struct hostent *hp; - const unsigned char *uaddr; - int advance; - res_state res; - char *bf; - size_t blen; - struct getnamaddr *info = rv; - - _DIAGASSERT(rv != NULL); - - uaddr = va_arg(ap, unsigned char *); - info->hp->h_length = va_arg(ap, int); - info->hp->h_addrtype = va_arg(ap, int); - - switch (info->hp->h_addrtype) { - case AF_INET: - (void)snprintf(qbuf, sizeof(qbuf), "%u.%u.%u.%u.in-addr.arpa", - (uaddr[3] & 0xff), (uaddr[2] & 0xff), - (uaddr[1] & 0xff), (uaddr[0] & 0xff)); - break; - - case AF_INET6: - qp = qbuf; - ep = qbuf + sizeof(qbuf) - 1; - for (n = NS_IN6ADDRSZ - 1; n >= 0; n--) { - advance = snprintf(qp, (size_t)(ep - qp), "%x.%x.", - uaddr[n] & 0xf, - ((unsigned int)uaddr[n] >> 4) & 0xf); - if (advance > 0 && qp + advance < ep) - qp += advance; - else - goto norecovery; - } - if (strlcat(qbuf, "ip6.arpa", sizeof(qbuf)) >= sizeof(qbuf)) - goto norecovery; - break; - default: - goto norecovery; - } - - buf = malloc(sizeof(*buf)); - if (buf == NULL) { - goto nospc; - } - res = __res_get_state(); - if (res == NULL) { - free(buf); - goto nospc; - } - n = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, (int)sizeof(buf->buf)); - if (n < 0) { - free(buf); - debugprintf("res_nquery failed (%d)\n", res, n); - __res_put_state(res); - *info->he = HOST_NOT_FOUND; - return NS_NOTFOUND; - } - hp = getanswer(buf, n, qbuf, T_PTR, res, info->hp, info->buf, - info->buflen, info->he); - free(buf); - if (hp == NULL) { - __res_put_state(res); - switch (*info->he) { - case HOST_NOT_FOUND: - return NS_NOTFOUND; - case TRY_AGAIN: - return NS_TRYAGAIN; - default: - return NS_UNAVAIL; - } - } - - bf = (void *)(hp->h_addr_list + 2); - blen = (size_t)(bf - info->buf); - if (blen + info->hp->h_length > info->buflen) - goto nospc; - hp->h_addr_list[0] = bf; - hp->h_addr_list[1] = NULL; - (void)memcpy(bf, uaddr, (size_t)info->hp->h_length); - if (info->hp->h_addrtype == AF_INET && (res->options & RES_USE_INET6)) { - if (blen + NS_IN6ADDRSZ > info->buflen) { - __res_put_state(res); - goto nospc; - } - map_v4v6_address(bf, bf); - hp->h_addrtype = AF_INET6; - hp->h_length = NS_IN6ADDRSZ; - } - - __res_put_state(res); - *info->he = NETDB_SUCCESS; - return NS_SUCCESS; -nospc: - *info->he = NETDB_INTERNAL; - return NS_UNAVAIL; -norecovery: - *info->he = NO_RECOVERY; - return NS_UNAVAIL; -} - -#ifdef YP -/*ARGSUSED*/ -static struct hostent * -_yp_hostent(char *line, int af, struct getnamaddr *info) -{ - struct in6_addr host_addrs[MAXADDRS]; - char **aliases; - size_t maxaliases; - char *p = line; - char *cp, **q, *ptr; - size_t len, anum, i; - int addrok; - int more; - size_t naddrs; - struct hostent *hp = info->hp; - - _DIAGASSERT(line != NULL); - - hp->h_name = NULL; - hp->h_addrtype = af; - switch (af) { - case AF_INET: - hp->h_length = NS_INADDRSZ; - break; - case AF_INET6: - hp->h_length = NS_IN6ADDRSZ; - break; - default: - return NULL; - } - setup(aliases, maxaliases); - naddrs = 0; - q = aliases; - -nextline: - /* check for host_addrs overflow */ - if (naddrs >= __arraycount(host_addrs)) - goto done; - - more = 0; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto done; - *cp++ = '\0'; - - /* p has should have an address */ - addrok = inet_pton(af, p, &host_addrs[naddrs]); - if (addrok != 1) { - /* skip to the next line */ - while (cp && *cp) { - if (*cp == '\n') { - cp++; - goto nextline; - } - cp++; - } - goto done; - } - naddrs++; - - while (*cp == ' ' || *cp == '\t') - cp++; - p = cp; - cp = strpbrk(p, " \t\n"); - if (cp != NULL) { - if (*cp == '\n') - more = 1; - *cp++ = '\0'; - } - if (!hp->h_name) - hp->h_name = p; - else if (strcmp(hp->h_name, p) == 0) - ; - else - addalias(q, p, aliases, maxaliases); - p = cp; - if (more) - goto nextline; - - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (*cp == '\n') { - cp++; - goto nextline; - } - addalias(q, cp, aliases, maxaliases); - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - -done: - if (hp->h_name == NULL) { - free(aliases); - return NULL; - } - - ptr = info->buf; - len = info->buflen; - - anum = (size_t)(q - aliases); - HENT_ARRAY(hp->h_addr_list, naddrs, ptr, len); - HENT_ARRAY(hp->h_aliases, anum, ptr, len); - - for (i = 0; i < naddrs; i++) - HENT_COPY(hp->h_addr_list[i], &host_addrs[i], hp->h_length, - ptr, len); - hp->h_addr_list[naddrs] = NULL; - - HENT_SCOPY(hp->h_name, hp->h_name, ptr, len); - - for (i = 0; i < anum; i++) - HENT_SCOPY(hp->h_aliases[i], aliases[i], ptr, len); - hp->h_aliases[anum] = NULL; - free(aliases); - - return hp; -nospc: - free(aliases); - *info->he = NETDB_INTERNAL; - errno = ENOSPC; - return NULL; -} - -/*ARGSUSED*/ -int -_yp_gethtbyaddr(void *rv, void *cb_data, va_list ap) -{ - struct hostent *hp = NULL; - char *ypcurrent; - int ypcurrentlen, r; - char name[INET6_ADDRSTRLEN]; /* XXX enough? */ - const unsigned char *uaddr; - int af; - const char *map; - struct getnamaddr *info = rv; - - _DIAGASSERT(rv != NULL); - - uaddr = va_arg(ap, unsigned char *); - /* NOSTRICT skip len */(void)va_arg(ap, int); - af = va_arg(ap, int); - - if (!__ypdomain) { - if (_yp_check(&__ypdomain) == 0) - return NS_UNAVAIL; - } - /* - * XXX unfortunately, we cannot support IPv6 extended scoped address - * notation here. gethostbyaddr() is not scope-aware. too bad. - */ - if (inet_ntop(af, uaddr, name, (socklen_t)sizeof(name)) == NULL) - return NS_UNAVAIL; - switch (af) { - case AF_INET: - map = "hosts.byaddr"; - break; - default: - map = "ipnodes.byaddr"; - break; - } - ypcurrent = NULL; - r = yp_match(__ypdomain, map, name, - (int)strlen(name), &ypcurrent, &ypcurrentlen); - if (r == 0) - hp = _yp_hostent(ypcurrent, af, info); - else - hp = NULL; - free(ypcurrent); - if (hp == NULL) { - *info->he = HOST_NOT_FOUND; - return NS_NOTFOUND; - } - return NS_SUCCESS; -} - -/*ARGSUSED*/ -int -_yp_gethtbyname(void *rv, void *cb_data, va_list ap) -{ - struct hostent *hp; - char *ypcurrent; - int ypcurrentlen, r; - const char *name; - int af; - const char *map; - struct getnamaddr *info = rv; - - _DIAGASSERT(rv != NULL); - - name = va_arg(ap, char *); - /* NOSTRICT skip string len */(void)va_arg(ap, int); - af = va_arg(ap, int); - - if (!__ypdomain) { - if (_yp_check(&__ypdomain) == 0) - return NS_UNAVAIL; - } - switch (af) { - case AF_INET: - map = "hosts.byname"; - break; - default: - map = "ipnodes.byname"; - break; - } - ypcurrent = NULL; - r = yp_match(__ypdomain, map, name, - (int)strlen(name), &ypcurrent, &ypcurrentlen); - if (r == 0) - hp = _yp_hostent(ypcurrent, af, info); - else - hp = NULL; - free(ypcurrent); - if (hp == NULL) { - *info->he = HOST_NOT_FOUND; - return NS_NOTFOUND; - } - return NS_SUCCESS; -} -#endif - -/* - * Non-reentrant versions. - */ -FILE *_h_file; -static struct hostent h_ent; -static char h_buf[16384]; - -struct hostent * -gethostbyaddr(const void *addr, socklen_t len, int af) { - return gethostbyaddr_r(addr, len, af, &h_ent, h_buf, sizeof(h_buf), - &h_errno); -} - -struct hostent * -gethostbyname(const char *name) { - return gethostbyname_r(name, &h_ent, h_buf, sizeof(h_buf), &h_errno); -} - -struct hostent * -gethostbyname2(const char *name, int af) { - return gethostbyname2_r(name, af, &h_ent, h_buf, sizeof(h_buf), - &h_errno); -} - -struct hostent * -gethostent(void) -{ - if (_h_file == NULL) { - sethostent_r(&_h_file); - if (_h_file == NULL) { - h_errno = NETDB_INTERNAL; - return NULL; - } - } - memset(&h_ent, 0, sizeof(h_ent)); - return gethostent_r(_h_file, &h_ent, h_buf, sizeof(h_buf), &h_errno); -} - diff --git a/lib/libc/net/gethostbyname.3 b/lib/libc/net/gethostbyname.3 deleted file mode 100644 index 4d1cb5a12..000000000 --- a/lib/libc/net/gethostbyname.3 +++ /dev/null @@ -1,333 +0,0 @@ -.\" $NetBSD: gethostbyname.3,v 1.29 2013/08/19 07:18:42 christos Exp $ -.\" -.\" Copyright (c) 1983, 1987, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)gethostbyname.3 8.4 (Berkeley) 5/25/95 -.\" -.Dd August 19, 2013 -.Dt GETHOSTBYNAME 3 -.Os -.Sh NAME -.Nm gethostbyname , -.Nm gethostbyname2 , -.Nm gethostbyaddr , -.Nm gethostent , -.Nm sethostent , -.Nm endhostent , -.Nm herror , -.Nm hstrerror -.Nd get network host entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In netdb.h -.Fd extern int h_errno; -.Ft struct hostent * -.Fn gethostbyname "const char *name" -.Ft struct hostent * -.Fn gethostbyname2 "const char *name" "int af" -.Ft struct hostent * -.Fn gethostbyaddr "const void *addr" "socklen_t len" "int type" -.Ft struct hostent * -.Fn gethostent void -.Ft void -.Fn sethostent "int stayopen" -.Ft void -.Fn endhostent void -.Ft void -.Fn herror "const char *string" -.Ft const char * -.Fn hstrerror "int err" -.Sh DESCRIPTION -The -.Fn gethostbyname , -.Fn gethostbyname2 -and -.Fn gethostbyaddr -functions -each return a pointer to an object with the -following structure describing an internet host. -.Bd -literal -struct hostent { - char *h_name; /* official name of host */ - char **h_aliases; /* alias list */ - int h_addrtype; /* host address type */ - int h_length; /* length of address */ - char **h_addr_list; /* list of addresses from name server */ -}; -#define h_addr h_addr_list[0] /* address, for backward compatibility */ -.Ed -.Pp -The members of this structure are: -.Bl -tag -width h_addr_list -.It Fa h_name -Official name of the host. -.It Fa h_aliases -A NULL-terminated array of alternative names for the host. -.It Fa h_addrtype -The type of address being returned; currently always -.Dv AF_INET . -.It Fa h_length -The length, in bytes, of the address. -.It Fa h_addr_list -A NULL-terminated array of network addresses for the host. -Host addresses are returned in network byte order. -.It Fa h_addr -The first address in -.Fa h_addr_list ; -this is for backward compatibility. -.El -.Pp -In the case of -.Fn gethostbyname -and -.Fn gethostbyname2 , -the host is specified by name, -or using a string representation of a numeric address. -In the case of -.Fn gethostbyaddr , -the host is specified using a binary representation of an address. -.Pp -The returned -.Ft "struct hostent" -structure may contain -the result of a simple string to binary conversion, -information obtained from the domain name resolver (see -.Xr resolver 3 ) , -broken-out fields from a line in -.Pa /etc/hosts , -or database entries supplied by the -.Xr yp 8 -system. -The order of the lookups is controlled by the -.Sq hosts -entry in -.Xr nsswitch.conf 5 . -.Pp -When using the domain name resolver, -.Fn gethostbyname -and -.Fn gethostbyname2 -will search for the named host in the current domain and its parents -unless the name ends in a dot. -If the name contains no dot, and if the environment variable -.Dq Ev HOSTALIASES -contains the name of an alias file, the alias file will first be searched -for an alias matching the input name. -See -.Xr hostname 7 -for the domain search procedure and the alias file format. -.Pp -The -.Fn gethostbyname2 -function is an evolution of -.Fn gethostbyname -which is intended to allow lookups in address families other than -.Dv AF_INET , -for example -.Dv AF_INET6 . -Currently the -.Fa af -argument must be specified as -.Dv AF_INET -or -.Dv AF_INET6 , -else the function will return -.Dv NULL -after having set -.Va h_errno -to -.Dv NETDB_INTERNAL . -.Pp -The -.Fn gethostent -function -reads the next line of the -.Pa /etc/hosts -file, opening the file if necessary. -.Pp -The -.Fn sethostent -function -may be used to request the use of a connected -.Tn TCP -socket for queries. -If the -.Fa stayopen -flag is non-zero, -this sets the option to send all queries to the name server using -.Tn TCP -and to retain the connection after each call to -.Fn gethostbyname , -.Fn gethostbyname2 , -or -.Fn gethostbyaddr . -Otherwise, queries are performed using -.Tn UDP -datagrams. -.Pp -The -.Fn endhostent -function -closes the -.Tn TCP -connection. -.Pp -The -.Fn herror -function writes a message to the diagnostic output consisting of the -string parameter -.Fa s , -the constant string ": ", and a message corresponding to the value of -.Va h_errno . -.Pp -The -.Fn hstrerror -function returns a string which is the message text corresponding to the -value of the -.Fa err -parameter. -.Sh FILES -.Bl -tag -width /etc/hosts -compact -.It Pa /etc/hosts -.El -.Sh DIAGNOSTICS -Error return status from -.Fn gethostbyent , -.Fn gethostbyname , -.Fn gethostbyname2 , -and -.Fn gethostbyaddr -is indicated by return of a null pointer. -The external integer -.Va h_errno -may then be checked to see whether this is a temporary failure -or an invalid or unknown host. -The routine -.Fn herror -can be used to print an error message describing the failure. -If its argument -.Fa string -is -.Pf non Dv -NULL , -it is printed, followed by a colon and a space. -The error message is printed with a trailing newline. -.Pp -The variable -.Va h_errno -can have the following values: -.Bl -tag -width HOST_NOT_FOUND -.It Dv HOST_NOT_FOUND -No such host is known. -.It Dv TRY_AGAIN -This is usually a temporary error -and means that the local server did not receive -a response from an authoritative server. -A retry at some later time may succeed. -.It Dv NO_RECOVERY -Some unexpected server failure was encountered. -This is a non-recoverable error. -.It Dv NO_DATA -The requested name is valid but does not have an IP address; -this is not a temporary error. -This means that the name is known to the name server but there is no address -associated with this name. -Another type of request to the name server using this domain name -will result in an answer; -for example, a mail-forwarder may be registered for this domain. -.El -.Sh SEE ALSO -.Xr resolver 3 , -.Xr hosts 5 , -.Xr nsswitch.conf 5 , -.Xr hostname 7 , -.Xr named 8 -.Sh HISTORY -The -.Fn herror -function appeared in -.Bx 4.3 . -The -.Fn endhostent , -.Fn gethostbyaddr , -.Fn gethostbyname , -.Fn gethostent , -and -.Fn sethostent -functions appeared in -.Bx 4.2 . -The -.Fn gethostbyname2 -function first appeared in bind-4.9.4. -IPv6 support was implemented in WIDE Hydrangea IPv6 protocol stack kit. -.Sh CAVEATS -If the search routines specified in -.Xr nsswitch.conf 5 -decide to read the -.Pa /etc/hosts -file, -.Fn gethostbyname , -.Fn gethostbyname2 , -and -.Fn gethostbyaddr -will -read the next line of the file, -re-opening the file if necessary. -.Pp -The -.Fn sethostent -function -opens and/or rewinds the file -.Pa /etc/hosts . -If the -.Fa stayopen -argument is non-zero, -the file will not be closed after each call to -.Fn gethostbyname , -.Fn gethostbyname2 , -.Fn gethostbyaddr , -or -.Fn gethostent . -.Pp -The -.Fn endhostent -function closes the file. -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. -Only the Internet -address format is currently understood. -.Pp -The -.Fn gethostent -does not currently follow the search order specified in -.Xr nsswitch.conf 5 -and only reads the -.Pa /etc/hosts -file. diff --git a/lib/libc/net/getifaddrs.3 b/lib/libc/net/getifaddrs.3 deleted file mode 100644 index be1e53079..000000000 --- a/lib/libc/net/getifaddrs.3 +++ /dev/null @@ -1,197 +0,0 @@ -.\" $NetBSD: getifaddrs.3,v 1.14 2013/04/07 23:12:36 wiz Exp $ -.\" BSDI getifaddrs.3,v 2.5 2000/02/23 14:51:59 dab Exp -.\" -.\" Copyright (c) 1995, 1999 -.\" Berkeley Software Design, Inc. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" -.\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.Dd April 7, 2013 -.Dt GETIFADDRS 3 -.Os -.Sh NAME -.Nm getifaddrs -.Nd get interface addresses -.Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h -.In ifaddrs.h -.Ft int -.Fn getifaddrs "struct ifaddrs **ifap" -.Ft void -.Fn freeifaddrs "struct ifaddrs *ifp" -.Sh DESCRIPTION -The -.Fn getifaddrs -function stores a reference to a linked list of the network interfaces -on the local machine in the memory referenced by -.Fa ifap . -The list consists of -.Nm ifaddrs -structures, as defined in the include file -.In ifaddrs.h . -The -.Nm ifaddrs -structure contains at least the following entries: -.Bd -literal - struct ifaddrs *ifa_next; /* Pointer to next struct */ - char *ifa_name; /* Interface name */ - u_int ifa_flags; /* Interface flags */ - struct sockaddr *ifa_addr; /* Interface address */ - struct sockaddr *ifa_netmask; /* Interface netmask */ - struct sockaddr *ifa_broadaddr; /* Interface broadcast address */ - struct sockaddr *ifa_dstaddr; /* P2P interface destination */ - void *ifa_data; /* Address specific data */ -.Ed -.Pp -The -.Li ifa_next -field contains a pointer to the next structure on the list. -This field is -.Dv NULL -in last structure on the list. -.Pp -The -.Li ifa_name -field contains the interface name. -.Pp -The -.Li ifa_flags -field contains the interface flags, as set by -.Xr ifconfig 8 -utility. -.Pp -The -.Li ifa_addr -field references either the address of the interface or the link level -address of the interface, if one exists, otherwise it is -.Dv NULL . -(The -.Li sa_family -field of the -.Li ifa_addr -field should be consulted to determine the format of the -.Li ifa_addr -address.) -.Pp -The -.Li ifa_netmask -field references the netmask associated with -.Li ifa_addr , -if one is set, otherwise it is -.Dv NULL . -.Pp -The -.Li ifa_broadaddr -field, -which should only be referenced for non-P2P interfaces, -references the broadcast address associated with -.Li ifa_addr , -if one exists, otherwise it is -.Dv NULL . -.Pp -The -.Li ifa_dstaddr -field references the destination address on a P2P interface, -if one exists, otherwise it is -.Dv NULL . -.Pp -The -.Li ifa_data -field references address family specific data. -For -.Dv AF_LINK -addresses it contains a pointer to the -.Fa struct if_data -.Pq as defined in include file Aq Pa net/if.h -which contains various interface attributes and statistics. -For all other address families, it is -.Dv NULL . -.Pp -The data returned by -.Fn getifaddrs -is dynamically allocated and should be freed using -.Fn freeifaddrs -when no longer needed. -.Sh RETURN VALUES -Upon successful completion, a value of 0 is returned. -Otherwise, a value of -1 is returned and -.Va errno -is set to indicate the error. -.Sh EXAMPLES -The following example program prints a list of all addresses configured -on the system. -.Bd -literal -offset indent -#include \*[Lt]sys/types.h\*[Gt] -#include \*[Lt]sys/socket.h\*[Gt] -#include \*[Lt]stdio.h\*[Gt] -#include \*[Lt]ifaddrs.h\*[Gt] -#include \*[Lt]util.h\*[Gt] -#include \*[Lt]err.h\*[Gt] -#include \*[Lt]stdlib.h\*[Gt] - -int -main(int argc, char *argv[]) -{ - struct ifaddrs *ifa, *a; - - if (getifaddrs(\*[Am]ifa) == -1) - err(EXIT_FAILURE, "getifaddrs"); - - for (a = ifa; a; a = a->ifa_next) { - char buf[1024]; - sockaddr_snprintf(buf, sizeof(buf), "%f %a", - a->ifa_addr); - printf("%s %x %s\\n", a->ifa_name, a->ifa_flags, buf); - } - freeifaddrs(ifa); - return EXIT_SUCCESS; -} -.Ed -.Sh ERRORS -The -.Fn getifaddrs -may fail and set -.Va errno -for any of the errors specified for the library routines -.Xr ioctl 2 , -.Xr socket 2 , -.Xr malloc 3 -or -.Xr sysctl 3 . -.Sh SEE ALSO -.Xr ioctl 2 , -.Xr socket 2 , -.Xr sysctl 3 , -.Xr networking 4 , -.Xr ifconfig 8 -.Sh HISTORY -The -.Nm -implementation first appeared in -.Bsx . -.Sh BUGS -If both -.In net/if.h -and -.In ifaddrs.h -are being included, -.In net/if.h -.Em must -be included before -.In ifaddrs.h . diff --git a/lib/libc/net/getifaddrs.c b/lib/libc/net/getifaddrs.c deleted file mode 100644 index b46fd2241..000000000 --- a/lib/libc/net/getifaddrs.c +++ /dev/null @@ -1,305 +0,0 @@ -/* $NetBSD: getifaddrs.c,v 1.15 2012/03/13 21:13:40 christos Exp $ */ - -/* - * Copyright (c) 1995, 1999 - * Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. - * - * BSDI getifaddrs.c,v 2.12 2000/02/23 14:51:59 dab Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getifaddrs.c,v 1.15 2012/03/13 21:13:40 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#if defined(__weak_alias) && !defined(RUMP_ACTION) -__weak_alias(getifaddrs,_getifaddrs) -__weak_alias(freeifaddrs,_freeifaddrs) -#endif - -#ifdef RUMP_ACTION -#include -#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f) -#endif - -#define SA_RLEN(sa) RT_ROUNDUP((sa)->sa_len) - -int -getifaddrs(struct ifaddrs **pif) -{ - size_t icnt = 1; - size_t dcnt = 0; - size_t ncnt = 0; - static const int mib[] = { - CTL_NET, - PF_ROUTE, - 0, /* protocol */ - 0, /* wildcard address family */ - NET_RT_IFLIST, - 0 /* no flags */ - }; - size_t needed; - char *buf; - char *next; - struct ifaddrs cif; - char *p, *p0; - struct rt_msghdr *rtm; - struct if_msghdr *ifm; - struct ifa_msghdr *ifam; - struct sockaddr *sa; - struct ifaddrs *ifa, *ift; - u_short idx = 0; - int i; - size_t len, alen; - char *data; - char *names; - - _DIAGASSERT(pif != NULL); - - if (sysctl(mib, (u_int)__arraycount(mib), NULL, &needed, NULL, 0) < 0) - return (-1); - if ((buf = malloc(needed)) == NULL) - return (-1); - if (sysctl(mib, (u_int)__arraycount(mib), buf, &needed, NULL, 0) < 0) { - free(buf); - return (-1); - } - - for (next = buf; next < buf + needed; next += rtm->rtm_msglen) { - rtm = (struct rt_msghdr *)(void *)next; - if (rtm->rtm_version != RTM_VERSION) - continue; - switch (rtm->rtm_type) { - case RTM_IFINFO: - ifm = (struct if_msghdr *)(void *)rtm; - if (ifm->ifm_addrs & RTA_IFP) { - const struct sockaddr_dl *dl; - - idx = ifm->ifm_index; - ++icnt; - dl = (struct sockaddr_dl *)(void *)(ifm + 1); - dcnt += SA_RLEN((const struct sockaddr *)(const void *)dl) + - ALIGNBYTES; - dcnt += sizeof(ifm->ifm_data); - ncnt += dl->sdl_nlen + 1; - } else - idx = 0; - break; - - case RTM_NEWADDR: - ifam = (struct ifa_msghdr *)(void *)rtm; - if (idx && ifam->ifam_index != idx) - abort(); /* this cannot happen */ - -#define RTA_MASKS (RTA_NETMASK | RTA_IFA | RTA_BRD) - if (idx == 0 || (ifam->ifam_addrs & RTA_MASKS) == 0) - break; - p = (char *)(void *)(ifam + 1); - ++icnt; - /* Scan to look for length of address */ - alen = 0; - for (p0 = p, i = 0; i < RTAX_MAX; i++) { - if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) - == 0) - continue; - sa = (struct sockaddr *)(void *)p; - len = SA_RLEN(sa); - if (i == RTAX_IFA) { - alen = len; - break; - } - p += len; - } - for (p = p0, i = 0; i < RTAX_MAX; i++) { - if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) - == 0) - continue; - sa = (struct sockaddr *)(void *)p; - len = SA_RLEN(sa); - if (i == RTAX_NETMASK && sa->sa_len == 0) - dcnt += alen; - else - dcnt += len; - p += len; - } - break; - } - } - - if (icnt + dcnt + ncnt == 1) { - *pif = NULL; - free(buf); - return (0); - } - data = malloc(sizeof(struct ifaddrs) * icnt + dcnt + ncnt); - if (data == NULL) { - free(buf); - return(-1); - } - - ifa = (struct ifaddrs *)(void *)data; - data += sizeof(struct ifaddrs) * icnt; - names = data + dcnt; - - memset(ifa, 0, sizeof(struct ifaddrs) * icnt); - ift = ifa; - - idx = 0; - for (next = buf; next < buf + needed; next += rtm->rtm_msglen) { - rtm = (struct rt_msghdr *)(void *)next; - if (rtm->rtm_version != RTM_VERSION) - continue; - switch (rtm->rtm_type) { - case RTM_IFINFO: - ifm = (struct if_msghdr *)(void *)rtm; - if (ifm->ifm_addrs & RTA_IFP) { - const struct sockaddr_dl *dl; - - idx = ifm->ifm_index; - dl = (struct sockaddr_dl *)(void *)(ifm + 1); - - memset(&cif, 0, sizeof(cif)); - - cif.ifa_name = names; - cif.ifa_flags = (int)ifm->ifm_flags; - memcpy(names, dl->sdl_data, - (size_t)dl->sdl_nlen); - names[dl->sdl_nlen] = 0; - names += dl->sdl_nlen + 1; - - cif.ifa_addr = (struct sockaddr *)(void *)data; - memcpy(data, dl, (size_t)dl->sdl_len); - data += SA_RLEN((const struct sockaddr *)(const void *)dl); - - /* ifm_data needs to be aligned */ - cif.ifa_data = data = (void *)ALIGN(data); - memcpy(data, &ifm->ifm_data, sizeof(ifm->ifm_data)); - data += sizeof(ifm->ifm_data); - } else - idx = 0; - break; - - case RTM_NEWADDR: - ifam = (struct ifa_msghdr *)(void *)rtm; - if (idx && ifam->ifam_index != idx) - abort(); /* this cannot happen */ - - if (idx == 0 || (ifam->ifam_addrs & RTA_MASKS) == 0) - break; - ift->ifa_name = cif.ifa_name; - ift->ifa_flags = cif.ifa_flags; - ift->ifa_data = NULL; - p = (char *)(void *)(ifam + 1); - /* Scan to look for length of address */ - alen = 0; - for (p0 = p, i = 0; i < RTAX_MAX; i++) { - if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) - == 0) - continue; - sa = (struct sockaddr *)(void *)p; - len = SA_RLEN(sa); - if (i == RTAX_IFA) { - alen = len; - break; - } - p += len; - } - for (p = p0, i = 0; i < RTAX_MAX; i++) { - if ((RTA_MASKS & ifam->ifam_addrs & (1 << i)) - == 0) - continue; - sa = (struct sockaddr *)(void *)p; - len = SA_RLEN(sa); - switch (i) { - case RTAX_IFA: - ift->ifa_addr = - (struct sockaddr *)(void *)data; - memcpy(data, p, len); - data += len; - if (ift->ifa_addr->sa_family == AF_LINK) - ift->ifa_data = cif.ifa_data; - break; - - case RTAX_NETMASK: - ift->ifa_netmask = - (struct sockaddr *)(void *)data; - if (sa->sa_len == 0) { - memset(data, 0, alen); - data += alen; - break; - } - memcpy(data, p, len); - data += len; - break; - - case RTAX_BRD: - ift->ifa_broadaddr = - (struct sockaddr *)(void *)data; - memcpy(data, p, len); - data += len; - break; - } - p += len; - } - - - ift = (ift->ifa_next = ift + 1); - break; - } - } - - free(buf); - if (--ift >= ifa) { - ift->ifa_next = NULL; - *pif = ifa; - } else { - *pif = NULL; - free(ifa); - } - return (0); -} - -void -freeifaddrs(struct ifaddrs *ifp) -{ - - _DIAGASSERT(ifp != NULL); - - free(ifp); -} diff --git a/lib/libc/net/getnameinfo.3 b/lib/libc/net/getnameinfo.3 deleted file mode 100644 index 01e691905..000000000 --- a/lib/libc/net/getnameinfo.3 +++ /dev/null @@ -1,272 +0,0 @@ -.\" $NetBSD: getnameinfo.3,v 1.41 2013/08/18 10:40:06 wiz Exp $ -.\" $KAME: getnameinfo.3,v 1.37 2005/01/05 03:23:05 itojun Exp $ -.\" $OpenBSD: getnameinfo.3,v 1.36 2004/12/21 09:48:20 jmc Exp $ -.\" -.\" Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC") -.\" Copyright (C) 2000, 2001 Internet Software Consortium. -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH -.\" REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY -.\" AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT, -.\" INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM -.\" LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE -.\" OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR -.\" PERFORMANCE OF THIS SOFTWARE. -.\" -.Dd August 18, 2013 -.Dt GETNAMEINFO 3 -.Os -.Sh NAME -.Nm getnameinfo -.Nd socket address structure to hostname and service name -.Sh SYNOPSIS -.In netdb.h -.Ft int -.Fn getnameinfo "const struct sockaddr * restrict sa" "socklen_t salen" \ - "char * restrict host" "socklen_t hostlen" "char * restrict serv" \ - "socklen_t servlen" "int flags" -.Sh DESCRIPTION -The -.Fn getnameinfo -function is used to convert a -.Li sockaddr -structure to a pair of host name and service strings. -It is a replacement for and provides more flexibility than the -.Xr gethostbyaddr 3 -and -.Xr getservbyport 3 -functions and is the converse of the -.Xr getaddrinfo 3 -function. -.Pp -The -.Li sockaddr -structure -.Fa sa -should point to a -.Li sockaddr_in -(for IPv4), -.Li sockaddr_in6 -(for IPv6), -.Li sockaddr_atalk -(for AppleTalk), -.Li sockaddr_link -(for link layer), -or -.Li sockaddr_local -(for local/unix) -structures that are -.Fa salen -bytes long. -.Pp -The host and service names associated with -.Fa sa -are stored in -.Fa host -and -.Fa serv -which have length parameters -.Fa hostlen -and -.Fa servlen . -The maximum value for -.Fa hostlen -is -.Dv NI_MAXHOST -and the maximum value for -.Fa servlen -is -.Dv NI_MAXSERV , -as defined by -.In netdb.h . -If a length parameter is zero, no string will be stored. -Otherwise, enough space must be provided to store the -host name or service string plus a byte for the NUL terminator. -.Pp -The -.Fa flags -argument is formed by -.Sy OR Ns 'ing -the following values: -.Bl -tag -width "NI_NUMERICHOSTXX" -.It Dv NI_NOFQDN -A fully qualified domain name is not required for local hosts. -The local part of the fully qualified domain name is returned instead. -.It Dv NI_NUMERICHOST -Return the address in numeric form, as if calling -.Xr inet_ntop 3 , -instead of a host name. -.It Dv NI_NAMEREQD -A name is required. -If the host name cannot be found in DNS and this flag is set, -a non-zero error code is returned. -If the host name is not found and the flag is not set, the -address is returned in numeric form. -.It NI_NUMERICSERV -The service name is returned as a digit string representing the port number. -.It NI_DGRAM -Specifies that the service being looked up is a datagram -service, and causes -.Xr getservbyport 3 -to be called with a second argument of -.Dq udp -instead of its default of -.Dq tcp . -This is required for the few ports (512\-514) that have different services -for -.Tn UDP -and -.Tn TCP . -.El -.Pp -This implementation allows numeric IPv6 address notation with scope identifier, -as documented in chapter 11 of draft-ietf-ipv6-scoping-arch-02.txt. -IPv6 link-local address will appear as a string like -.Dq Li fe80::1%ne0 . -Refer to -.Xr getaddrinfo 3 -for more information. -.Sh RETURN VALUES -.Fn getnameinfo -returns zero on success or one of the error codes listed in -.Xr gai_strerror 3 -if an error occurs. -.Sh EXAMPLES -The following code tries to get a numeric host name, and service name, -for a given socket address. -Observe that there is no hardcoded reference to a particular address family. -.Bd -literal -offset indent -struct sockaddr *sa; /* input */ -char hbuf[NI_MAXHOST], sbuf[NI_MAXSERV]; - -if (getnameinfo(sa, sa-\*[Gt]sa_len, hbuf, sizeof(hbuf), sbuf, - sizeof(sbuf), NI_NUMERICHOST | NI_NUMERICSERV)) { - errx(1, "could not get numeric hostname"); - /*NOTREACHED*/ -} -printf("host=%s, serv=%s\en", hbuf, sbuf); -.Ed -.Pp -The following version checks if the socket address has a reverse address mapping: -.Bd -literal -offset indent -struct sockaddr *sa; /* input */ -char hbuf[NI_MAXHOST]; - -if (getnameinfo(sa, sa-\*[Gt]sa_len, hbuf, sizeof(hbuf), NULL, 0, - NI_NAMEREQD)) { - errx(1, "could not resolve hostname"); - /*NOTREACHED*/ -} -printf("host=%s\en", hbuf); -.Ed -.Sh SEE ALSO -.Xr gai_strerror 3 , -.Xr getaddrinfo 3 , -.Xr gethostbyaddr 3 , -.Xr getservbyport 3 , -.Xr inet_ntop 3 , -.Xr resolver 3 , -.Xr hosts 5 , -.Xr resolv.conf 5 , -.Xr services 5 , -.Xr hostname 7 , -.Xr named 8 -.Rs -.%A R. Gilligan -.%A S. Thomson -.%A J. Bound -.%A W. Stevens -.%T Basic Socket Interface Extensions for IPv6 -.%R RFC 2553 -.%D March 1999 -.Re -.Rs -.%A S. Deering -.%A B. Haberman -.%A T. Jinmei -.%A E. Nordmark -.%A B. Zill -.%T "IPv6 Scoped Address Architecture" -.%R internet draft -.%N draft-ietf-ipv6-scoping-arch-02.txt -.%O work in progress material -.Re -.Rs -.%A Craig Metz -.%T Protocol Independence Using the Sockets API -.%B "Proceedings of the FREENIX track: 2000 USENIX annual technical conference" -.%D June 2000 -.Re -.Sh STANDARDS -The -.Fn getnameinfo -function is defined by the -.St -p1003.1g-2000 -draft specification and documented in -.Sy "RFC 2553" , -.Dq Basic Socket Interface Extensions for IPv6 . -.Sh CAVEATS -.Fn getnameinfo -can return both numeric and FQDN forms of the address specified in -.Fa sa . -There is no return value that indicates whether the string returned in -.Fa host -is a result of binary to numeric-text translation (like -.Xr inet_ntop 3 ) , -or is the result of a DNS reverse lookup. -Because of this, malicious parties could set up a PTR record as follows: -.Bd -literal -offset indent -1.0.0.127.in-addr.arpa. IN PTR 10.1.1.1 -.Ed -.Pp -and trick the caller of -.Fn getnameinfo -into believing that -.Fa sa -is -.Li 10.1.1.1 -when it is actually -.Li 127.0.0.1 . -.Pp -To prevent such attacks, the use of -.Dv NI_NAMEREQD -is recommended when the result of -.Fn getnameinfo -is used for access control purposes: -.Bd -literal -offset indent -struct sockaddr *sa; -socklen_t salen; -char addr[NI_MAXHOST]; -struct addrinfo hints, *res; -int error; - -error = getnameinfo(sa, salen, addr, sizeof(addr), - NULL, 0, NI_NAMEREQD); -if (error == 0) { - memset(\*[Am]hints, 0, sizeof(hints)); - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - hints.ai_flags = AI_NUMERICHOST; - if (getaddrinfo(addr, "0", \*[Am]hints, \*[Am]res) == 0) { - /* malicious PTR record */ - freeaddrinfo(res); - printf("bogus PTR record\en"); - return -1; - } - /* addr is FQDN as a result of PTR lookup */ -} else { - /* addr is numeric string */ - error = getnameinfo(sa, salen, addr, sizeof(addr), - NULL, 0, NI_NUMERICHOST); -} -.Ed -.\".Sh BUGS -.\".Ox -.\"intentionally uses a different -.\".Dv NI_MAXHOST -.\"value from what -.\".Tn "RFC 2553" -.\"suggests, to avoid buffer length handling mistakes. diff --git a/lib/libc/net/getnameinfo.c b/lib/libc/net/getnameinfo.c deleted file mode 100644 index c7186a181..000000000 --- a/lib/libc/net/getnameinfo.c +++ /dev/null @@ -1,626 +0,0 @@ -/* $NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $ */ -/* $KAME: getnameinfo.c,v 1.45 2000/09/25 22:43:56 itojun Exp $ */ - -/* - * Copyright (c) 2000 Ben Harris. - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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. - */ - -/* - * Issues to be discussed: - * - Thread safe-ness must be checked - * - RFC2553 says that we should raise error on short buffer. X/Open says - * we need to truncate the result. We obey RFC2553 (and X/Open should be - * modified). ipngwg rough consensus seems to follow RFC2553. - * - What is "local" in NI_FQDN? - * - NI_NAMEREQD and NI_NUMERICHOST conflict with each other. - * - (KAME extension) always attach textual scopeid (fe80::1%lo0), if - * sin6_scope_id is filled - standardization status? - * XXX breaks backward compat for code that expects no scopeid. - * beware on merge. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getnameinfo.c,v 1.59 2015/09/22 16:15:08 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "servent.h" -#include "hostent.h" - -#ifndef RUMP_ACTION -#ifdef __weak_alias -__weak_alias(getnameinfo,_getnameinfo) -#endif -#endif - -static const struct afd { - int a_af; - socklen_t a_addrlen; - socklen_t a_socklen; - int a_off; -} afdl [] = { -#ifdef INET6 - {PF_INET6, sizeof(struct in6_addr), sizeof(struct sockaddr_in6), - offsetof(struct sockaddr_in6, sin6_addr)}, -#endif - {PF_INET, sizeof(struct in_addr), sizeof(struct sockaddr_in), - offsetof(struct sockaddr_in, sin_addr)}, - {0, 0, 0, 0}, -}; - -struct sockinet { - u_char si_len; - u_char si_family; - u_short si_port; -}; - -static int getnameinfo_inet(const struct sockaddr *, socklen_t, char *, - socklen_t, char *, socklen_t, int); -#ifdef INET6 -static int ip6_parsenumeric(const struct sockaddr *, const char *, char *, - socklen_t, int); -static int ip6_sa2str(const struct sockaddr_in6 *, char *, size_t, int); -#endif -static int getnameinfo_atalk(const struct sockaddr *, socklen_t, char *, - socklen_t, char *, socklen_t, int); -static int getnameinfo_local(const struct sockaddr *, socklen_t, char *, - socklen_t, char *, socklen_t, int); - -static int getnameinfo_link(const struct sockaddr *, socklen_t, char *, - socklen_t, char *, socklen_t, int); -static int hexname(const uint8_t *, size_t, char *, socklen_t); - -/* - * Top-level getnameinfo() code. Look at the address family, and pick an - * appropriate function to call. - */ -int -getnameinfo(const struct sockaddr *sa, socklen_t salen, - char *host, socklen_t hostlen, - char *serv, socklen_t servlen, - int flags) -{ - - switch (sa->sa_family) { - case AF_APPLETALK: - return getnameinfo_atalk(sa, salen, host, hostlen, - serv, servlen, flags); - case AF_INET: - case AF_INET6: - return getnameinfo_inet(sa, salen, host, hostlen, - serv, servlen, flags); - case AF_LINK: - return getnameinfo_link(sa, salen, host, hostlen, - serv, servlen, flags); - case AF_LOCAL: - return getnameinfo_local(sa, salen, host, hostlen, - serv, servlen, flags); - default: - return EAI_FAMILY; - } -} - -/* - * getnameinfo_atalk(): - * Format an AppleTalk address into a printable format. - */ -/* ARGSUSED */ -static int -getnameinfo_atalk(const struct sockaddr *sa, socklen_t salen, - char *host, socklen_t hostlen, char *serv, socklen_t servlen, - int flags) -{ - char numserv[8]; - int n, m=0; - - const struct sockaddr_at *sat = - (const struct sockaddr_at *)(const void *)sa; - - if (serv != NULL && servlen > 0) { - snprintf(numserv, sizeof(numserv), "%u", sat->sat_port); - if (strlen(numserv) + 1 > servlen) - return EAI_MEMORY; - strlcpy(serv, numserv, servlen); - } - - n = snprintf(host, hostlen, "%u.%u", - ntohs(sat->sat_addr.s_net), sat->sat_addr.s_node); - - if (n < 0 || (socklen_t)(m+n) >= hostlen) - goto errout; - - m += n; - - if (sat->sat_range.r_netrange.nr_phase) { - n = snprintf(host+m, hostlen-m, " phase %u", - sat->sat_range.r_netrange.nr_phase); - - if (n < 0 || (socklen_t)(m+n) >= hostlen) - goto errout; - - m += n; - } - if (sat->sat_range.r_netrange.nr_firstnet) { - n = snprintf(host+m, hostlen-m, " range %u - %u", - ntohs(sat->sat_range.r_netrange.nr_firstnet), - ntohs(sat->sat_range.r_netrange.nr_lastnet )); - - if (n < 0 || (socklen_t)(m+n) >= hostlen) - goto errout; - - m += n; - } - - return 0; - -errout: - if (host && hostlen>0) - host[m] = '\0'; /* XXX ??? */ - - return EAI_MEMORY; -} - -/* - * getnameinfo_local(): - * Format an local address into a printable format. - */ -/* ARGSUSED */ -static int -getnameinfo_local(const struct sockaddr *sa, socklen_t salen, - char *host, socklen_t hostlen, char *serv, socklen_t servlen, - int flags) -{ - const struct sockaddr_un *sun = - (const struct sockaddr_un *)(const void *)sa; - - if (serv != NULL && servlen > 0) - serv[0] = '\0'; - - if (host && hostlen > 0) - strlcpy(host, sun->sun_path, - MIN(sizeof(sun->sun_path) + 1, hostlen)); - - return 0; -} - -/* - * getnameinfo_inet(): - * Format an IPv4 or IPv6 sockaddr into a printable string. - */ -static int -getnameinfo_inet(const struct sockaddr *sa, socklen_t salen, - char *host, socklen_t hostlen, - char *serv, socklen_t servlen, - int flags) -{ - const struct afd *afd; - struct servent *sp; - struct hostent *hp; - u_short port; - int family, i; - const char *addr; - uint32_t v4a; - char numserv[512]; - char numaddr[512]; - - /* sa is checked below */ - /* host may be NULL */ - /* serv may be NULL */ - - if (sa == NULL) - return EAI_FAIL; - - family = sa->sa_family; - for (i = 0; afdl[i].a_af; i++) - if (afdl[i].a_af == family) { - afd = &afdl[i]; - goto found; - } - return EAI_FAMILY; - - found: - if (salen != afd->a_socklen) - return EAI_FAIL; - - /* network byte order */ - port = ((const struct sockinet *)(const void *)sa)->si_port; - addr = (const char *)(const void *)sa + afd->a_off; - - if (serv == NULL || servlen == 0) { - /* - * do nothing in this case. - * in case you are wondering if "&&" is more correct than - * "||" here: rfc2553bis-03 says that serv == NULL OR - * servlen == 0 means that the caller does not want the result. - */ - } else { - struct servent_data svd; - struct servent sv; - - if (flags & NI_NUMERICSERV) - sp = NULL; - else { - (void)memset(&svd, 0, sizeof(svd)); - sp = getservbyport_r(port, - (flags & NI_DGRAM) ? "udp" : "tcp", &sv, &svd); - } - if (sp) { - if (strlen(sp->s_name) + 1 > servlen) { - endservent_r(&svd); - return EAI_MEMORY; - } - strlcpy(serv, sp->s_name, servlen); - endservent_r(&svd); - } else { - snprintf(numserv, sizeof(numserv), "%u", ntohs(port)); - if (strlen(numserv) + 1 > servlen) - return EAI_MEMORY; - strlcpy(serv, numserv, servlen); - } - } - - switch (sa->sa_family) { - case AF_INET: - v4a = (uint32_t) - ntohl(((const struct sockaddr_in *) - (const void *)sa)->sin_addr.s_addr); - if (IN_MULTICAST(v4a) || IN_EXPERIMENTAL(v4a)) - flags |= NI_NUMERICHOST; - v4a >>= IN_CLASSA_NSHIFT; - if (v4a == 0) - flags |= NI_NUMERICHOST; - break; -#ifdef INET6 - case AF_INET6: - { - const struct sockaddr_in6 *sin6; - sin6 = (const struct sockaddr_in6 *)(const void *)sa; - switch (sin6->sin6_addr.s6_addr[0]) { - case 0x00: - if (IN6_IS_ADDR_V4MAPPED(&sin6->sin6_addr)) - ; - else if (IN6_IS_ADDR_LOOPBACK(&sin6->sin6_addr)) - ; - else - flags |= NI_NUMERICHOST; - break; - default: - if (IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr)) { - flags |= NI_NUMERICHOST; - } - else if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr)) - flags |= NI_NUMERICHOST; - break; - } - } - break; -#endif - } - if (host == NULL || hostlen == 0) { - /* - * do nothing in this case. - * in case you are wondering if "&&" is more correct than - * "||" here: rfc2553bis-03 says that host == NULL or - * hostlen == 0 means that the caller does not want the result. - */ - } else if (flags & NI_NUMERICHOST) { - size_t numaddrlen; - - /* NUMERICHOST and NAMEREQD conflicts with each other */ - if (flags & NI_NAMEREQD) - return EAI_NONAME; - - switch(afd->a_af) { -#ifdef INET6 - case AF_INET6: - { - int error; - - if ((error = ip6_parsenumeric(sa, addr, host, - hostlen, flags)) != 0) - return(error); - break; - } -#endif - default: - if (inet_ntop(afd->a_af, addr, numaddr, - (socklen_t)sizeof(numaddr)) == NULL) - return EAI_SYSTEM; - numaddrlen = strlen(numaddr); - if (numaddrlen + 1 > hostlen) /* don't forget terminator */ - return EAI_MEMORY; - strlcpy(host, numaddr, hostlen); - break; - } - } else { - struct hostent hent; - char hbuf[4096]; - int he; - hp = gethostbyaddr_r(addr, afd->a_addrlen, afd->a_af, &hent, - hbuf, sizeof(hbuf), &he); - - if (hp) { -#if 0 - /* - * commented out, since "for local host" is not - * implemented here - see RFC2553 p30 - */ - if (flags & NI_NOFQDN) { - char *p; - p = strchr(hp->h_name, '.'); - if (p) - *p = '\0'; - } -#endif - if (strlen(hp->h_name) + 1 > hostlen) { - return EAI_MEMORY; - } - strlcpy(host, hp->h_name, hostlen); - } else { - switch (he) { - case NO_DATA: - case HOST_NOT_FOUND: - if (flags & NI_NAMEREQD) - return EAI_NONAME; - break; - case TRY_AGAIN: - return EAI_AGAIN; - case NETDB_SUCCESS: - case NETDB_INTERNAL: - case NO_RECOVERY: - /*FALLTHROUGH*/ - default: - return EAI_SYSTEM; - } - switch(afd->a_af) { -#ifdef INET6 - case AF_INET6: - { - int error; - - if ((error = ip6_parsenumeric(sa, addr, host, - hostlen, - flags)) != 0) - return(error); - break; - } -#endif - default: - if (inet_ntop(afd->a_af, addr, host, - hostlen) == NULL) - return EAI_SYSTEM; - break; - } - } - } - return(0); -} - -#ifdef INET6 -static int -ip6_parsenumeric(const struct sockaddr *sa, const char *addr, char *host, - socklen_t hostlen, int flags) -{ - size_t numaddrlen; - char numaddr[512]; - - _DIAGASSERT(sa != NULL); - _DIAGASSERT(addr != NULL); - _DIAGASSERT(host != NULL); - - if (inet_ntop(AF_INET6, addr, numaddr, (socklen_t)sizeof(numaddr)) - == NULL) - return EAI_SYSTEM; - - numaddrlen = strlen(numaddr); - if (numaddrlen + 1 > hostlen) /* don't forget terminator */ - return EAI_OVERFLOW; - strlcpy(host, numaddr, hostlen); - - if (((const struct sockaddr_in6 *)(const void *)sa)->sin6_scope_id) { - char zonebuf[MAXHOSTNAMELEN]; - int zonelen; - - zonelen = ip6_sa2str( - (const struct sockaddr_in6 *)(const void *)sa, - zonebuf, sizeof(zonebuf), flags); - if (zonelen < 0) - return EAI_OVERFLOW; - if ((size_t) zonelen + 1 + numaddrlen + 1 > hostlen) - return EAI_OVERFLOW; - /* construct */ - memcpy(host + numaddrlen + 1, zonebuf, - (size_t)zonelen); - host[numaddrlen] = SCOPE_DELIMITER; - host[numaddrlen + 1 + zonelen] = '\0'; - } - - return 0; -} - -/* ARGSUSED */ -static int -ip6_sa2str(const struct sockaddr_in6 *sa6, char *buf, size_t bufsiz, int flags) -{ - unsigned int ifindex; - const struct in6_addr *a6; - int n; - - _DIAGASSERT(sa6 != NULL); - _DIAGASSERT(buf != NULL); - - ifindex = (unsigned int)sa6->sin6_scope_id; - a6 = &sa6->sin6_addr; - -#ifdef NI_NUMERICSCOPE - if ((flags & NI_NUMERICSCOPE) != 0) { - n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); - if (n < 0 || (size_t)n >= bufsiz) - return -1; - else - return n; - } -#endif - - /* if_indextoname() does not take buffer size. not a good api... */ - if ((IN6_IS_ADDR_LINKLOCAL(a6) || IN6_IS_ADDR_MC_LINKLOCAL(a6)) && - bufsiz >= IF_NAMESIZE) { - char *p = if_indextoname(ifindex, buf); - if (p) { - return (int)strlen(p); - } - } - - /* last resort */ - n = snprintf(buf, bufsiz, "%u", sa6->sin6_scope_id); - if (n < 0 || (size_t) n >= bufsiz) - return -1; - else - return n; -} -#endif /* INET6 */ - - -/* - * getnameinfo_link(): - * Format a link-layer address into a printable format, paying attention to - * the interface type. - */ -/* ARGSUSED */ -static int -getnameinfo_link(const struct sockaddr *sa, socklen_t salen, - char *host, socklen_t hostlen, char *serv, socklen_t servlen, - int flags) -{ - const struct sockaddr_dl *sdl = - (const struct sockaddr_dl *)(const void *)sa; - const struct ieee1394_hwaddr *iha; - int n; - - if (serv != NULL && servlen > 0) - *serv = '\0'; - - if (sdl->sdl_nlen == 0 && sdl->sdl_alen == 0 && sdl->sdl_slen == 0) { - n = snprintf(host, hostlen, "link#%u", sdl->sdl_index); - goto out; - } - - switch (sdl->sdl_type) { -#ifdef IFT_ECONET - case IFT_ECONET: - if (sdl->sdl_alen < 2) - return EAI_FAMILY; - if (CLLADDR(sdl)[1] == 0) - n = snprintf(host, hostlen, "%u", CLLADDR(sdl)[0]); - else - n = snprintf(host, hostlen, "%u.%u", - CLLADDR(sdl)[1], CLLADDR(sdl)[0]); - goto out; -#endif - case IFT_IEEE1394: - if (sdl->sdl_alen < sizeof(iha->iha_uid)) - return EAI_FAMILY; - iha = - (const struct ieee1394_hwaddr *)(const void *)CLLADDR(sdl); - return hexname(iha->iha_uid, sizeof(iha->iha_uid), - host, hostlen); - /* - * The following have zero-length addresses. - * IFT_ATM (net/if_atmsubr.c) - * IFT_FAITH (net/if_faith.c) - * IFT_GIF (net/if_gif.c) - * IFT_LOOP (net/if_loop.c) - * IFT_PPP (net/if_ppp.c, net/if_spppsubr.c) - * IFT_SLIP (net/if_sl.c, net/if_strip.c) - * IFT_STF (net/if_stf.c) - * IFT_L2VLAN (net/if_vlan.c) - * IFT_PROPVIRTUAL (net/if_bridge.h> - */ - /* - * The following use IPv4 addresses as link-layer addresses: - * IFT_OTHER (net/if_gre.c) - */ - case IFT_ARCNET: /* default below is believed correct for all these. */ - case IFT_ETHER: - case IFT_FDDI: - case IFT_HIPPI: - case IFT_ISO88025: - default: - return hexname((const uint8_t *)CLLADDR(sdl), - (size_t)sdl->sdl_alen, host, hostlen); - } -out: - if (n < 0 || (socklen_t) n >= hostlen) { - *host = '\0'; - return EAI_MEMORY; - } - return 0; -} - -static int -hexname(const uint8_t *cp, size_t len, char *host, socklen_t hostlen) -{ - int n; - size_t i; - char *outp = host; - - *outp = '\0'; - for (i = 0; i < len; i++) { - n = snprintf(outp, hostlen, "%s%02x", - i ? ":" : "", cp[i]); - if (n < 0 || (socklen_t) n >= hostlen) { - *host = '\0'; - return EAI_MEMORY; - } - outp += n; - hostlen -= n; - } - return 0; -} diff --git a/lib/libc/net/getnetent.3 b/lib/libc/net/getnetent.3 deleted file mode 100644 index 622211ed1..000000000 --- a/lib/libc/net/getnetent.3 +++ /dev/null @@ -1,152 +0,0 @@ -.\" $NetBSD: getnetent.3,v 1.13 2004/05/08 18:52:15 kleink Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)getnetent.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd May 8, 2004 -.Dt GETNETENT 3 -.Os -.Sh NAME -.Nm getnetent , -.Nm getnetbyaddr , -.Nm getnetbyname , -.Nm setnetent , -.Nm endnetent -.Nd get network entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In netdb.h -.Ft struct netent * -.Fn getnetent -.Ft struct netent * -.Fn getnetbyname "const char *name" -.Ft struct netent * -.Fn getnetbyaddr "uint32_t net" "int type" -.Fn setnetent "int stayopen" -.Fn endnetent -.Sh DESCRIPTION -The -.Fn getnetent , -.Fn getnetbyname , -and -.Fn getnetbyaddr -functions -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the network data base as described in -.Xr networks 5 . -.Bd -literal -offset indent -struct netent { - char *n_name; /* official name of net */ - char **n_aliases; /* alias list */ - int n_addrtype; /* net number type */ - uint32_t n_net; /* net number */ -}; -.Ed -.Pp -The members of this structure are: -.Bl -tag -width n_addrtype -.It Fa n_name -The official name of the network. -.It Fa n_aliases -A zero terminated list of alternative names for the network. -.It Fa n_addrtype -The type of the network number returned; currently only AF_INET. -.It Fa n_net -The network number. Network numbers are returned in machine byte -order. -.El -.Pp -The -.Fn getnetent -function -reads the next line of the file, opening the file if necessary. -.Pp -The -.Fn setnetent -function -opens and rewinds the file. If the -.Fa stayopen -flag is non-zero, -the net data base will not be closed after each call to -.Fn getnetbyname -or -.Fn getnetbyaddr . -.Pp -The -.Fn endnetent -function -closes the file. -.Pp -The -.Fn getnetbyname -function -and -.Fn getnetbyaddr -sequentially search from the beginning -of the file until a matching -net name or -net address and type is found, -or until -.Dv EOF -is encountered. -Network numbers are supplied in host order. -.Sh FILES -.Bl -tag -width /etc/networks -compact -.It Pa /etc/networks -.El -.Sh DIAGNOSTICS -Null pointer -(0) returned on -.Dv EOF -or error. -.Sh SEE ALSO -.Xr networks 5 , -.Xr nsswitch.conf 5 -.Sh HISTORY -The -.Fn getnetent , -.Fn getnetbyaddr , -.Fn getnetbyname , -.Fn setnetent , -and -.Fn endnetent -functions appeared in -.Bx 4.2 . -.Sh BUGS -The data space used by -these functions is static; if future use requires the data, it should be -copied before any subsequent calls to these functions overwrite it. -Only Internet network -numbers are currently understood. -Expecting network numbers to fit -in no more than 32 bits is probably -naive. diff --git a/lib/libc/net/getnetent.c b/lib/libc/net/getnetent.c deleted file mode 100644 index b777d49ac..000000000 --- a/lib/libc/net/getnetent.c +++ /dev/null @@ -1,168 +0,0 @@ -/* $NetBSD: getnetent.c,v 1.21 2012/03/20 17:44:18 matt Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * Portions Copyright (c) 1993 Carlos Leandro and Rui Salgueiro - * Dep. Matematica Universidade de Coimbra, Portugal, Europe - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * from getnetent.c 1.1 (Coimbra) 93/06/02 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getnetent.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "Id: getnetent.c,v 8.4 1997/06/01 20:34:37 vixie Exp "; -#else -__RCSID("$NetBSD: getnetent.c,v 1.21 2012/03/20 17:44:18 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(endnetent,_endnetent) -__weak_alias(getnetent,_getnetent) -__weak_alias(setnetent,_setnetent) -#endif - -#define MAXALIASES 35 - -static FILE *netf; -static char line[BUFSIZ+1]; -static struct netent net; -static char *net_aliases[MAXALIASES]; -int _net_stayopen; - -static void __setnetent(int); -static void __endnetent(void); - -void -setnetent(int stayopen) -{ - - sethostent(stayopen); - __setnetent(stayopen); -} - -void -endnetent(void) -{ - - endhostent(); - __endnetent(); -} - -static void -__setnetent(int f) -{ - - if (netf == NULL) - netf = fopen(_PATH_NETWORKS, "re"); - else - rewind(netf); - _net_stayopen |= f; -} - -static void -__endnetent(void) -{ - - if (netf) { - fclose(netf); - netf = NULL; - } - _net_stayopen = 0; -} - -struct netent * -getnetent(void) -{ - char *p; - register char *cp, **q; - - if (netf == NULL && (netf = fopen(_PATH_NETWORKS, "re")) == NULL) - return (NULL); -#if (defined(__sparc__) && defined(_LP64)) || \ - defined(__alpha__) || \ - (defined(__i386__) && defined(_LP64)) || \ - (defined(__sh__) && defined(_LP64)) - net.__n_pad0 = 0; -#endif -again: - p = fgets(line, (int)sizeof line, netf); - if (p == NULL) - return (NULL); - if (*p == '#') - goto again; - cp = strpbrk(p, "#\n"); - if (cp == NULL) - goto again; - *cp = '\0'; - net.n_name = p; - cp = strpbrk(p, " \t"); - if (cp == NULL) - goto again; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - net.n_net = inet_network(cp); - net.n_addrtype = AF_INET; - q = net.n_aliases = net_aliases; - if (p != NULL) { - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &net_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - } - *q = NULL; - return (&net); -} diff --git a/lib/libc/net/getnetnamadr.c b/lib/libc/net/getnetnamadr.c deleted file mode 100644 index c3241c7c7..000000000 --- a/lib/libc/net/getnetnamadr.c +++ /dev/null @@ -1,648 +0,0 @@ -/* $NetBSD: getnetnamadr.c,v 1.42 2012/03/13 21:13:41 christos Exp $ */ - -/* Copyright (c) 1993 Carlos Leandro and Rui Salgueiro - * Dep. Matematica Universidade de Coimbra, Portugal, Europe - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - */ -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getnetbyaddr.c 8.1 (Berkeley) 6/4/93"; -static char sccsid_[] = "from getnetnamadr.c 1.4 (Coimbra) 93/06/03"; -static char rcsid[] = "Id: getnetnamadr.c,v 8.8 1997/06/01 20:34:37 vixie Exp "; -#else -__RCSID("$NetBSD: getnetnamadr.c,v 1.42 2012/03/13 21:13:41 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef YP -#include -#include -#include -#endif - -#ifdef __weak_alias -__weak_alias(getnetbyaddr,_getnetbyaddr) -__weak_alias(getnetbyname,_getnetbyname) -#endif - -extern int _net_stayopen; - -#define BYADDR 0 -#define BYNAME 1 -#define MAXALIASES 35 - -#define MAXPACKET (64*1024) - -typedef union { - HEADER hdr; - u_char buf[MAXPACKET]; -} querybuf; - -typedef union { - long al; - char ac; -} align; - -#ifdef YP -static char *__ypdomain; -static char *__ypcurrent; -static int __ypcurrentlen; -#endif - -static struct netent net_entry; -static char *net_aliases[MAXALIASES]; - -static int parse_reversed_addr(const char *, in_addr_t *); -static struct netent *getnetanswer(querybuf *, int, int); -static int _files_getnetbyaddr(void *, void *, va_list); -static int _files_getnetbyname(void *, void *, va_list); -static int _dns_getnetbyaddr(void *, void *, va_list); -static int _dns_getnetbyname(void *, void *, va_list); -#ifdef YP -static int _yp_getnetbyaddr(void *, void *, va_list); -static int _yp_getnetbyname(void *, void *, va_list); -static struct netent *_ypnetent(char *); -#endif - -/* - * parse_reversed_addr -- - * parse str, which should be of the form 'd.c.b.a.IN-ADDR.ARPA' - * (a PTR as per RFC 1101) and convert into an in_addr_t of the - * address 'a.b.c.d'. - * returns 0 on success (storing in *result), or -1 on error. - */ -static int -parse_reversed_addr(const char *str, in_addr_t *result) -{ - unsigned long octet[4]; - const char *sp; - char *ep; - int octidx; - - sp = str; - /* find the four octets 'd.b.c.a.' */ - for (octidx = 0; octidx < 4; octidx++) { - /* ensure it's a number */ - if (!isdigit((unsigned char)*sp)) - return -1; - octet[octidx] = strtoul(sp, &ep, 10); - /* with a trailing '.' */ - if (*ep != '.') - return -1; - /* and is 0 <= octet <= 255 */ - if (octet[octidx] > 255) - return -1; - sp = ep + 1; - } - /* ensure trailer is correct */ - if (strcasecmp(sp, "IN-ADDR.ARPA") != 0) - return -1; - *result = 0; - /* build result from octets in reverse */ - for (octidx = 3; octidx >= 0; octidx--) { - *result <<= 8; - *result |= (in_addr_t)(octet[octidx] & 0xff); - } - return 0; -} - -static struct netent * -getnetanswer(querybuf *answer, int anslen, int net_i) -{ - static char n_name[MAXDNAME]; - static char netbuf[PACKETSZ]; - - HEADER *hp; - u_char *cp; - int n; - u_char *eom; - int type, class, ancount, qdcount, haveanswer; - char *in, *bp, **ap, *ep; - - _DIAGASSERT(answer != NULL); - - /* - * find first satisfactory answer - * - * answer --> +------------+ ( MESSAGE ) - * | Header | - * +------------+ - * | Question | the question for the name server - * +------------+ - * | Answer | RRs answering the question - * +------------+ - * | Authority | RRs pointing toward an authority - * | Additional | RRs holding additional information - * +------------+ - */ - eom = answer->buf + anslen; - hp = &answer->hdr; - ancount = ntohs(hp->ancount); /* #/records in the answer section */ - qdcount = ntohs(hp->qdcount); /* #/entries in the question section */ - bp = netbuf; - ep = netbuf + sizeof(netbuf); - cp = answer->buf + HFIXEDSZ; - if (!qdcount) { - if (hp->aa) - h_errno = HOST_NOT_FOUND; - else - h_errno = TRY_AGAIN; - return NULL; - } - while (qdcount-- > 0) { - n = __dn_skipname(cp, eom); - if (n < 0 || (cp + n + QFIXEDSZ) > eom) { - h_errno = NO_RECOVERY; - return(NULL); - } - cp += n + QFIXEDSZ; - } - ap = net_aliases; - *ap = NULL; - net_entry.n_aliases = net_aliases; - haveanswer = 0; - n_name[0] = '\0'; - while (--ancount >= 0 && cp < eom) { - n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !res_dnok(bp)) - break; - cp += n; - (void)strlcpy(n_name, bp, sizeof(n_name)); - GETSHORT(type, cp); - GETSHORT(class, cp); - cp += INT32SZ; /* TTL */ - GETSHORT(n, cp); - if (class == C_IN && type == T_PTR) { - n = dn_expand(answer->buf, eom, cp, bp, (int)(ep - bp)); - if ((n < 0) || !res_hnok(bp)) { - cp += n; - return NULL; - } - cp += n; - *ap++ = bp; - bp += strlen(bp) + 1; - net_entry.n_addrtype = - (class == C_IN) ? AF_INET : AF_UNSPEC; - haveanswer++; - } - } - if (haveanswer) { - *ap = NULL; - switch (net_i) { - case BYADDR: - net_entry.n_name = *net_entry.n_aliases; - net_entry.n_net = 0L; - break; - case BYNAME: - ap = net_entry.n_aliases; - next_alias: - in = *ap++; - if (in == NULL) { - h_errno = HOST_NOT_FOUND; - return NULL; - } - net_entry.n_name = n_name; - if (parse_reversed_addr(in, &net_entry.n_net) == -1) - goto next_alias; - break; - } - net_entry.n_aliases++; -#if (defined(__sparc__) && defined(_LP64)) || \ - defined(__alpha__) || \ - (defined(__i386__) && defined(_LP64)) || \ - (defined(__sh__) && defined(_LP64)) - net_entry.__n_pad0 = 0; -#endif - return &net_entry; - } - h_errno = TRY_AGAIN; - return NULL; -} - -/*ARGSUSED*/ -static int -_files_getnetbyaddr(void *cbrv, void *cbdata, va_list ap) -{ - struct netent **retval = va_arg(ap, struct netent **); - uint32_t net = va_arg(ap, uint32_t); - int type = va_arg(ap, int); - - struct netent *np; - - setnetent(_net_stayopen); - while ((np = getnetent()) != NULL) - if (np->n_addrtype == type && np->n_net == net) - break; - if (!_net_stayopen) - endnetent(); - - if (np != NULL) { - *retval = np; - return NS_SUCCESS; - } else { - h_errno = HOST_NOT_FOUND; - return NS_NOTFOUND; - } -} - -/*ARGSUSED*/ -static int -_dns_getnetbyaddr(void *cbrv, void *cbdata, va_list ap) -{ - struct netent **retval = va_arg(ap, struct netent **); - uint32_t net = va_arg(ap, uint32_t); - int type = va_arg(ap, int); - - unsigned int netbr[4]; - int nn, anslen; - querybuf *buf; - char qbuf[MAXDNAME]; - uint32_t net2; - struct netent *np; - res_state res; - - if (type != AF_INET) - return NS_UNAVAIL; - - for (nn = 4, net2 = net; net2; net2 >>= 8) - netbr[--nn] = (unsigned int)(net2 & 0xff); - switch (nn) { - default: - return NS_UNAVAIL; - case 3: /* Class A */ - snprintf(qbuf, sizeof(qbuf), "0.0.0.%u.in-addr.arpa", netbr[3]); - break; - case 2: /* Class B */ - snprintf(qbuf, sizeof(qbuf), "0.0.%u.%u.in-addr.arpa", - netbr[3], netbr[2]); - break; - case 1: /* Class C */ - snprintf(qbuf, sizeof(qbuf), "0.%u.%u.%u.in-addr.arpa", - netbr[3], netbr[2], netbr[1]); - break; - case 0: /* Class D - E */ - snprintf(qbuf, sizeof(qbuf), "%u.%u.%u.%u.in-addr.arpa", - netbr[3], netbr[2], netbr[1], netbr[0]); - break; - } - buf = malloc(sizeof(*buf)); - if (buf == NULL) { - h_errno = NETDB_INTERNAL; - return NS_NOTFOUND; - } - res = __res_get_state(); - if (res == NULL) { - free(buf); - return NS_NOTFOUND; - } - anslen = res_nquery(res, qbuf, C_IN, T_PTR, buf->buf, - (int)sizeof(buf->buf)); - if (anslen < 0) { - free(buf); -#ifdef DEBUG - if (res->options & RES_DEBUG) - printf("res_query failed\n"); -#endif - __res_put_state(res); - return NS_NOTFOUND; - } - __res_put_state(res); - np = getnetanswer(buf, anslen, BYADDR); - free(buf); - if (np) { - /* maybe net should be unsigned? */ - uint32_t u_net = net; - - /* Strip trailing zeros */ - while ((u_net & 0xff) == 0 && u_net != 0) - u_net >>= 8; - np->n_net = u_net; - } - - if (np != NULL) { - *retval = np; - return NS_SUCCESS; - } else { - h_errno = HOST_NOT_FOUND; - return NS_NOTFOUND; - } -} - -struct netent * -getnetbyaddr(uint32_t net, int net_type) -{ - int rv; - struct netent *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getnetbyaddr, NULL) - { NSSRC_DNS, _dns_getnetbyaddr, NULL }, /* force -DHESIOD */ - NS_NIS_CB(_yp_getnetbyaddr, NULL) - NS_NULL_CB - }; - - retval = NULL; - h_errno = NETDB_INTERNAL; - rv = nsdispatch(NULL, dtab, NSDB_NETWORKS, "getnetbyaddr", - __nsdefaultsrc, &retval, net, net_type); - if (rv == NS_SUCCESS) { - h_errno = NETDB_SUCCESS; - return retval; - } - return NULL; -} - -/*ARGSUSED*/ -static int -_files_getnetbyname(void *cbrv, void *cbdata, va_list ap) -{ - struct netent **retval = va_arg(ap, struct netent **); - const char *name = va_arg(ap, const char *); - - struct netent *np; - char **cp; - - setnetent(_net_stayopen); - while ((np = getnetent()) != NULL) { - if (strcasecmp(np->n_name, name) == 0) - break; - for (cp = np->n_aliases; *cp != 0; cp++) - if (strcasecmp(*cp, name) == 0) - goto found; - } -found: - if (!_net_stayopen) - endnetent(); - - if (np != NULL) { - *retval = np; - return NS_SUCCESS; - } else { - h_errno = HOST_NOT_FOUND; - return NS_NOTFOUND; - } -} - -/*ARGSUSED*/ -static int -_dns_getnetbyname(void *cbrv, void *cbdata, va_list ap) -{ - struct netent **retval = va_arg(ap, struct netent **); - const char *name = va_arg(ap, const char *); - - int anslen; - querybuf *buf; - char qbuf[MAXDNAME]; - struct netent *np; - res_state res; - - strlcpy(&qbuf[0], name, sizeof(qbuf)); - buf = malloc(sizeof(*buf)); - if (buf == NULL) { - h_errno = NETDB_INTERNAL; - return NS_NOTFOUND; - } - res = __res_get_state(); - if (res == NULL) { - free(buf); - return NS_NOTFOUND; - } - anslen = res_nsearch(res, qbuf, C_IN, T_PTR, buf->buf, - (int)sizeof(buf->buf)); - if (anslen < 0) { - free(buf); -#ifdef DEBUG - if (res->options & RES_DEBUG) - printf("res_search failed\n"); -#endif - __res_put_state(res); - return NS_NOTFOUND; - } - __res_put_state(res); - np = getnetanswer(buf, anslen, BYNAME); - free(buf); - - if (np != NULL) { - *retval = np; - return NS_SUCCESS; - } else { - h_errno = HOST_NOT_FOUND; - return NS_NOTFOUND; - } -} - -struct netent * -getnetbyname(const char *name) -{ - int rv; - struct netent *retval; - - static const ns_dtab dtab[] = { - NS_FILES_CB(_files_getnetbyname, NULL) - { NSSRC_DNS, _dns_getnetbyname, NULL }, /* force -DHESIOD */ - NS_NIS_CB(_yp_getnetbyname, NULL) - NS_NULL_CB - }; - - _DIAGASSERT(name != NULL); - - retval = NULL; - h_errno = NETDB_INTERNAL; - rv = nsdispatch(NULL, dtab, NSDB_NETWORKS, "getnetbyname", - __nsdefaultsrc, &retval, name); - if (rv == NS_SUCCESS) { - h_errno = NETDB_SUCCESS; - return retval; - } - return NULL; -} - -#ifdef YP -/*ARGSUSED*/ -static int -_yp_getnetbyaddr(void *cbrv, void *cb_data, va_list ap) -{ - struct netent **retval = va_arg(ap, struct netent **); - uint32_t net = va_arg(ap, uint32_t); - int type = va_arg(ap, int); - - struct netent *np; - char qbuf[MAXDNAME]; - unsigned int netbr[4]; - uint32_t net2; - int r; - - if (type != AF_INET) - return NS_UNAVAIL; - - if (!__ypdomain) { - if (_yp_check(&__ypdomain) == 0) - return NS_UNAVAIL; - } - np = NULL; - if (__ypcurrent) - free(__ypcurrent); - __ypcurrent = NULL; - for (r = 4, net2 = net; net2; net2 >>= 8) - netbr[--r] = (unsigned int)(net2 & 0xff); - switch (r) { - default: - return NS_UNAVAIL; - case 3: /* Class A */ - snprintf(qbuf, sizeof(qbuf), "%u", netbr[3]); - break; - case 2: /* Class B */ - snprintf(qbuf, sizeof(qbuf), "%u.%u", netbr[2], netbr[3]); - break; - case 1: /* Class C */ - snprintf(qbuf, sizeof(qbuf), "%u.%u.%u", netbr[1], netbr[2], - netbr[3]); - break; - case 0: /* Class D - E */ - snprintf(qbuf, sizeof(qbuf), "%u.%u.%u.%u", netbr[0], netbr[1], - netbr[2], netbr[3]); - break; - } - r = yp_match(__ypdomain, "networks.byaddr", qbuf, (int)strlen(qbuf), - &__ypcurrent, &__ypcurrentlen); - if (r == 0) - np = _ypnetent(__ypcurrent); - - if (np != NULL) { - *retval = np; - return NS_SUCCESS; - } else { - h_errno = HOST_NOT_FOUND; - return NS_NOTFOUND; - } -} - -/*ARGSUSED*/ -static int -_yp_getnetbyname(void *cbrv, void *cbdata, va_list ap) -{ - struct netent **retval = va_arg(ap, struct netent **); - const char *name = va_arg(ap, const char *); - - struct netent *np; - int r; - - if (!__ypdomain) { - if (_yp_check(&__ypdomain) == 0) - return NS_UNAVAIL; - } - np = NULL; - if (__ypcurrent) - free(__ypcurrent); - __ypcurrent = NULL; - r = yp_match(__ypdomain, "networks.byname", name, (int)strlen(name), - &__ypcurrent, &__ypcurrentlen); - if (r == 0) - np = _ypnetent(__ypcurrent); - - if (np != NULL) { - *retval = np; - return NS_SUCCESS; - } else { - h_errno = HOST_NOT_FOUND; - return NS_NOTFOUND; - } -} - -static struct netent * -_ypnetent(char *line) -{ - char *cp, *p, **q; - - _DIAGASSERT(line != NULL); - - net_entry.n_name = line; - cp = strpbrk(line, " \t"); - if (cp == NULL) - return NULL; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - net_entry.n_net = inet_network(cp); -#if (defined(__sparc__) && defined(_LP64)) || \ - defined(__alpha__) || \ - (defined(__i386__) && defined(_LP64)) || \ - (defined(__sh__) && defined(_LP64)) - net_entry.__n_pad0 = 0; -#endif - net_entry.n_addrtype = AF_INET; - q = net_entry.n_aliases = net_aliases; - if (p != NULL) { - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (q < &net_aliases[MAXALIASES - 1]) - *q++ = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - } - *q = NULL; - - return &net_entry; -} -#endif diff --git a/lib/libc/net/getpeereid.3 b/lib/libc/net/getpeereid.3 deleted file mode 100644 index 77df2b305..000000000 --- a/lib/libc/net/getpeereid.3 +++ /dev/null @@ -1,142 +0,0 @@ -.\" -.\" Copyright (c) 2001 Dima Dorfman. -.\" 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: src/lib/libc/gen/getpeereid.3,v 1.6 2002/12/18 10:13:54 ru Exp $ -.\" -.\" $NetBSD: getpeereid.3,v 1.2 2008/01/29 13:55:27 abs Exp $ -.\" -.Dd August 8, 2007 -.Dt GETPEEREID 3 -.Os -.Sh NAME -.Nm getpeereid -.Nd get the effective credentials of a UNIX-domain peer -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In unistd.h -.Ft int -.Fn getpeereid "int s" "uid_t *euid" "gid_t *egid" -.Sh DESCRIPTION -The -.Fn getpeereid -function returns the effective user and group IDs of the -peer connected to a -.Ux Ns -domain -socket. -The argument -.Fa s -must be a -.Ux Ns -domain -socket -.Pq Xr unix 4 -of type -.Dv SOCK_STREAM -on which either -.Xr connect 2 -has been called, or one returned from -.Xr accept 2 -after -.Xr bind 2 -and -.Xr listen 2 -have been called. -If non-NULL, the effective used ID is placed in -.Fa euid , -and the effective group ID in -.Fa egid . -.Pp -The credentials returned to the -.Xr accept 2 -caller are those of its peer at the time it called -.Xr connect 2 ; -the credentials returned to the -.Xr connect 2 -caller are those of its peer at the time it called -.Xr bind 2 . -This mechanism is reliable; there is no way for either side to influence -the credentials returned to its peer except by calling the appropriate -system call (i.e., either -.Xr connect 2 -or -.Xr bind 2 ) -under different effective credentials. -.Pp -One common use of this routine is for a -.Ux Ns -domain -server -to verify the credentials of its client. -Likewise, the client can verify the credentials of the server. -.Sh IMPLEMENTATION NOTES -On -.Nx , -.Fn getpeereid -is implemented in terms of the -.Dv LOCAL_PEEREID -.Xr unix 4 -socket option. -.Sh RETURN VALUES -.Rv -std getpeereid -.Sh ERRORS -The -.Fn getpeereid -function -fails if: -.Bl -tag -width Er -.It Bq Er EBADF -The argument -.Fa s -is not a valid descriptor. -.It Bq Er ENOTSOCK -The argument -.Fa s -is a file, not a socket. -.It Bq Er ENOTCONN -The argument -.Fa s -does not refer to a socket on which -.Xr connect 2 -have been called nor one returned from -.Xr listen 2 . -.It Bq Er EINVAL -The argument -.Fa s -does not refer to a socket of type -.Dv SOCK_STREAM , -or the kernel returned invalid data. -.El -.Sh SEE ALSO -.Xr connect 2 , -.Xr getpeername 2 , -.Xr getsockname 2 , -.Xr getsockopt 2 , -.Xr listen 2 , -.Xr unix 4 -.Sh HISTORY -The -.Fn getpeereid -function appeared in -.Nx 5.0 . diff --git a/lib/libc/net/getpeereid.c b/lib/libc/net/getpeereid.c deleted file mode 100644 index 72652caeb..000000000 --- a/lib/libc/net/getpeereid.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: getpeereid.c,v 1.2 2008/04/29 06:53:01 martin Exp $ */ - -/*- - * Copyright (c) 2007 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Arne H. Juul. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getpeereid.c,v 1.2 2008/04/29 06:53:01 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include -#include - - -int -getpeereid(int s, uid_t *euid, gid_t *egid) -{ - struct unpcbid cred; - socklen_t len = sizeof(cred); - if (getsockopt(s, 0, LOCAL_PEEREID, &cred, &len) < 0) { - return -1; - } else { - if (euid != NULL) - *euid = cred.unp_euid; - if (egid != NULL) - *egid = cred.unp_egid; - return 0; - } -} diff --git a/lib/libc/net/getprotobyname.c b/lib/libc/net/getprotobyname.c deleted file mode 100644 index e5aa8300c..000000000 --- a/lib/libc/net/getprotobyname.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: getprotobyname.c,v 1.4 2008/04/28 20:23:00 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getprotobyname.c,v 1.4 2008/04/28 20:23:00 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include "protoent.h" - -#ifdef __weak_alias -__weak_alias(getprotobyname,_getprotobyname) -#endif - -#ifdef _REENTRANT -extern mutex_t _protoent_mutex; -#endif -extern struct protoent_data _protoent_data; - -struct protoent * -getprotobyname(const char *name) -{ - struct protoent *p; - - mutex_lock(&_protoent_mutex); - p = getprotobyname_r(name, &_protoent_data.proto, &_protoent_data); - mutex_unlock(&_protoent_mutex); - return (p); -} diff --git a/lib/libc/net/getprotobyname_r.c b/lib/libc/net/getprotobyname_r.c deleted file mode 100644 index 3b621e0ef..000000000 --- a/lib/libc/net/getprotobyname_r.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: getprotobyname_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getprotoname.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getprotobyname_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include - -#include "protoent.h" - -#ifdef __weak_alias -__weak_alias(getprotobyname_r,_getprotobyname_r) -#endif - -struct protoent * -getprotobyname_r(const char *name, struct protoent *pr, - struct protoent_data *pd) -{ - struct protoent *p; - char **cp; - - _DIAGASSERT(name != NULL); - - setprotoent_r(pd->stayopen, pd); - while ((p = getprotoent_r(pr, pd)) != NULL) { - if (strcmp(p->p_name, name) == 0) - break; - for (cp = p->p_aliases; *cp != NULL; cp++) - if (strcmp(*cp, name) == 0) - goto found; - } -found: - if (!pd->stayopen) - if (pd->fp != NULL) { - (void)fclose(pd->fp); - pd->fp = NULL; - } - return p; -} diff --git a/lib/libc/net/getprotobynumber.c b/lib/libc/net/getprotobynumber.c deleted file mode 100644 index 4840052d9..000000000 --- a/lib/libc/net/getprotobynumber.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: getprotobynumber.c,v 1.4 2008/04/28 20:23:00 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getprotobynumber.c,v 1.4 2008/04/28 20:23:00 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include "protoent.h" - -#ifdef __weak_alias -__weak_alias(getprotobynumber,_getprotobynumber) -#endif - -#ifdef _REENTRANT -extern mutex_t _protoent_mutex; -#endif -extern struct protoent_data _protoent_data; - -struct protoent * -getprotobynumber(int proto) -{ - struct protoent *p; - - mutex_lock(&_protoent_mutex); - p = getprotobynumber_r(proto, &_protoent_data.proto, &_protoent_data); - mutex_unlock(&_protoent_mutex); - return (p); -} diff --git a/lib/libc/net/getprotobynumber_r.c b/lib/libc/net/getprotobynumber_r.c deleted file mode 100644 index e1cb4f1ef..000000000 --- a/lib/libc/net/getprotobynumber_r.c +++ /dev/null @@ -1,66 +0,0 @@ -/* $NetBSD: getprotobynumber_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getproto.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getprotobynumber_r.c,v 1.3 2005/04/18 19:39:45 kleink Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include "protoent.h" - -#ifdef __weak_alias -__weak_alias(getprotobynumber_r,_getprotobynumber_r) -#endif - -struct protoent * -getprotobynumber_r(int proto, struct protoent *pr, struct protoent_data *pd) -{ - struct protoent *p; - - setprotoent_r(pd->stayopen, pd); - while ((p = getprotoent_r(pr, pd)) != NULL) - if (p->p_proto == proto) - break; - if (!pd->stayopen) - if (pd->fp != NULL) { - (void)fclose(pd->fp); - pd->fp = NULL; - } - return p; -} diff --git a/lib/libc/net/getprotoent.3 b/lib/libc/net/getprotoent.3 deleted file mode 100644 index 44a3d5758..000000000 --- a/lib/libc/net/getprotoent.3 +++ /dev/null @@ -1,156 +0,0 @@ -.\" $NetBSD: getprotoent.3,v 1.13 2011/07/14 22:12:30 wiz Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)getprotoent.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd July 15, 2011 -.Dt GETPROTOENT 3 -.Os -.Sh NAME -.Nm getprotoent , -.Nm getprotobynumber , -.Nm getprotobyname , -.Nm setprotoent , -.Nm endprotoent -.Nd get protocol entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In netdb.h -.Ft struct protoent * -.Fn getprotoent -.Ft struct protoent * -.Fn getprotobyname "const char *name" -.Ft struct protoent * -.Fn getprotobynumber "int proto" -.Ft void -.Fn setprotoent "int stayopen" -.Ft void -.Fn endprotoent "void" -.Sh DESCRIPTION -The -.Fn getprotoent , -.Fn getprotobyname , -and -.Fn getprotobynumber -functions -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the network protocol data base, -.Pa /etc/protocols . -.Bd -literal -offset indent -.Pp -struct protoent { - char *p_name; /* official name of protocol */ - char **p_aliases; /* alias list */ - int p_proto; /* protocol number */ -}; -.Ed -.Pp -The members of this structure are: -.Bl -tag -width p_aliases -offset indent -.It Fa p_name -The official name of the protocol. -.It Fa p_aliases -A zero terminated list of alternative names for the protocol. -.It Fa p_proto -The protocol number. -.El -.Pp -The -.Fn getprotoent -function -reads the next line of the file, opening the file if necessary. -.Pp -The -.Fn setprotoent -function -opens and rewinds the file. -If the -.Fa stayopen -flag is non-zero, -the net data base will not be closed after each call to -.Fn getprotobyname -or -.Fn getprotobynumber . -.Pp -The -.Fn endprotoent -function -closes the file. -.Pp -The -.Fn getprotobyname -function -and -.Fn getprotobynumber -sequentially search from the beginning -of the file until a matching -protocol name or -protocol number is found, -or until -.Dv EOF -is encountered. -.Sh RETURN VALUES -Upon success, -.Fn getprotoent , -.Fn getprotobyname , -and -.Fn getprotobynumber -return a pointer to the -.Vt protoent -structure as described above. -A -.Dv NULL -pointer is returned on -.Dv EOF -or error. -.Sh FILES -.Bl -tag -width /etc/protocols -compact -.It Pa /etc/protocols -.El -.Sh SEE ALSO -.Xr protocols 5 -.Sh HISTORY -The -.Fn getprotoent , -.Fn getprotobynumber , -.Fn getprotobyname , -.Fn setprotoent , -and -.Fn endprotoent -functions appeared in -.Bx 4.2 . -.Sh BUGS -These functions use a static data space; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. -Only the Internet -protocols are currently understood. diff --git a/lib/libc/net/getprotoent.c b/lib/libc/net/getprotoent.c deleted file mode 100644 index 1912b4e12..000000000 --- a/lib/libc/net/getprotoent.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $NetBSD: getprotoent.c,v 1.12 2008/04/28 20:23:00 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getprotoent.c,v 1.12 2008/04/28 20:23:00 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include "protoent.h" - -#ifdef __weak_alias -__weak_alias(endprotoent,_endprotoent) -__weak_alias(getprotoent,_getprotoent) -__weak_alias(setprotoent,_setprotoent) -#endif - -#ifdef _REENTRANT -mutex_t _protoent_mutex = MUTEX_INITIALIZER; -#endif -struct protoent_data _protoent_data; - -void -setprotoent(int f) -{ - mutex_lock(&_protoent_mutex); - setprotoent_r(f, &_protoent_data); - mutex_unlock(&_protoent_mutex); -} - -void -endprotoent(void) -{ - mutex_lock(&_protoent_mutex); - endprotoent_r(&_protoent_data); - mutex_unlock(&_protoent_mutex); -} - -struct protoent * -getprotoent(void) -{ - struct protoent *p; - - mutex_lock(&_protoent_mutex); - p = getprotoent_r(&_protoent_data.proto, &_protoent_data); - mutex_unlock(&_protoent_mutex); - return (p); -} diff --git a/lib/libc/net/getprotoent_r.c b/lib/libc/net/getprotoent_r.c deleted file mode 100644 index deae55075..000000000 --- a/lib/libc/net/getprotoent_r.c +++ /dev/null @@ -1,153 +0,0 @@ -/* $NetBSD: getprotoent_r.c,v 1.6 2011/10/15 23:00:02 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getprotoent.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getprotoent_r.c,v 1.6 2011/10/15 23:00:02 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include "protoent.h" - -#ifdef __weak_alias -__weak_alias(endprotoent_r,_endprotoent_r) -__weak_alias(getprotoent_r,_getprotoent_r) -__weak_alias(setprotoent_r,_setprotoent_r) -#endif - -void -setprotoent_r(int f, struct protoent_data *pd) -{ - if (pd->fp == NULL) - pd->fp = fopen(_PATH_PROTOCOLS, "re"); - else - rewind(pd->fp); - pd->stayopen |= f; -} - -void -endprotoent_r(struct protoent_data *pd) -{ - if (pd->fp) { - (void)fclose(pd->fp); - pd->fp = NULL; - } - if (pd->aliases) { - free(pd->aliases); - pd->aliases = NULL; - pd->maxaliases = 0; - } - if (pd->line) { - free(pd->line); - pd->line = NULL; - } - pd->stayopen = 0; -} - -struct protoent * -getprotoent_r(struct protoent *pr, struct protoent_data *pd) -{ - char *p, *cp, **q; - size_t i = 0; - int oerrno; - - if (pd->fp == NULL && (pd->fp = fopen(_PATH_PROTOCOLS, "re")) == NULL) - return NULL; - - for (;;) { - if (pd->line) - free(pd->line); - pd->line = fparseln(pd->fp, NULL, NULL, NULL, - FPARSELN_UNESCALL); - if (pd->line == NULL) - return NULL; - pr->p_name = p = pd->line; - cp = strpbrk(p, " \t"); - if (cp == NULL) - continue; - *cp++ = '\0'; - while (*cp == ' ' || *cp == '\t') - cp++; - p = strpbrk(cp, " \t"); - if (p != NULL) - *p++ = '\0'; - pr->p_proto = atoi(cp); - if (pd->aliases == NULL) { - pd->maxaliases = 10; - pd->aliases = malloc(pd->maxaliases * sizeof(char *)); - if (pd->aliases == NULL) { - oerrno = errno; - endprotoent_r(pd); - errno = oerrno; - return NULL; - } - } - q = pr->p_aliases = pd->aliases; - if (p != NULL) { - cp = p; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (i == pd->maxaliases - 2) { - pd->maxaliases *= 2; - q = realloc(q, - pd->maxaliases * sizeof(char *)); - if (q == NULL) { - oerrno = errno; - endprotoent_r(pd); - errno = oerrno; - return NULL; - } - pr->p_aliases = pd->aliases = q; - } - q[i++] = cp; - - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - } - q[i] = NULL; - return pr; - } -} diff --git a/lib/libc/net/getservbyname.c b/lib/libc/net/getservbyname.c deleted file mode 100644 index d208aded9..000000000 --- a/lib/libc/net/getservbyname.c +++ /dev/null @@ -1,61 +0,0 @@ -/* $NetBSD: getservbyname.c,v 1.14 2008/04/28 20:23:00 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getservbyname.c,v 1.14 2008/04/28 20:23:00 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include "servent.h" - -#ifdef __weak_alias -__weak_alias(getservbyname,_getservbyname) -#endif - -#ifdef _REENTRANT -extern mutex_t _servent_mutex; -#endif -extern struct servent_data _servent_data; - -struct servent * -getservbyname(const char *name, const char *proto) -{ - struct servent *s; - - mutex_lock(&_servent_mutex); - s = getservbyname_r(name, proto, &_servent_data.serv, &_servent_data); - mutex_unlock(&_servent_mutex); - return (s); -} diff --git a/lib/libc/net/getservbyname_r.c b/lib/libc/net/getservbyname_r.c deleted file mode 100644 index 35d6e4099..000000000 --- a/lib/libc/net/getservbyname_r.c +++ /dev/null @@ -1,149 +0,0 @@ -/* $NetBSD: getservbyname_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getservbyname.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getservbyname_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include - -#include "servent.h" - -#ifdef __weak_alias -__weak_alias(getservbyname_r,_getservbyname_r) -#endif - -static struct servent * -_servent_getbyname(struct servent_data *sd, struct servent *sp, - const char *name, const char *proto) -{ - - if ((sd->flags & (_SV_CDB | _SV_PLAINFILE)) == 0) - return NULL; - - if (sd->flags & _SV_CDB) { - uint8_t buf[255 * 2 + 2]; - size_t namelen, protolen; - const uint8_t *data, *data_end; - const void *data_ptr; - size_t datalen; - - namelen = strlen(name); - if (namelen == 0 || namelen > 255) - return NULL; - if (proto != NULL) { - protolen = strlen(proto); - if (protolen == 0 || protolen > 255) - return NULL; - } else - protolen = 0; - if (namelen + protolen > 255) - return NULL; - - buf[0] = (uint8_t)namelen; - buf[1] = (uint8_t)protolen; - memcpy(buf + 2, name, namelen); - memcpy(buf + 2 + namelen, proto, protolen); - - if (cdbr_find(sd->cdb, buf, 2 + namelen + protolen, - &data_ptr, &datalen)) - return NULL; - - if (datalen < namelen + protolen + 6) - return NULL; - - data = data_ptr; - data_end = data + datalen; - if (protolen) { - if (data[2] != protolen) - return NULL; - if (memcmp(data + 3, proto, protolen + 1)) - return NULL; - } - data += 3 + data[2] + 1; - if (data > data_end) - return NULL; - while (data != data_end) { - if (*data == '\0') - return NULL; - if (data + data[0] + 2 > data_end) - return NULL; - if (data[0] == namelen && - memcmp(data + 1, name, namelen + 1) == 0) - return _servent_parsedb(sd, sp, data_ptr, - datalen); - data += data[0] + 2; - } - return NULL; - } else { - while (_servent_getline(sd) != -1) { - char **cp; - if (_servent_parseline(sd, sp) == NULL) - continue; - - if (strcmp(name, sp->s_name) == 0) - goto gotname; - - for (cp = sp->s_aliases; *cp; cp++) - if (strcmp(name, *cp) == 0) - goto gotname; - continue; -gotname: - if (proto == NULL || strcmp(sp->s_proto, proto) == 0) - return sp; - } - return NULL; - } -} - -struct servent * -getservbyname_r(const char *name, const char *proto, struct servent *sp, - struct servent_data *sd) -{ - _DIAGASSERT(name != NULL); - /* proto may be NULL */ - - setservent_r(sd->flags & _SV_STAYOPEN, sd); - sp = _servent_getbyname(sd, sp, name, proto); - if (!(sd->flags & _SV_STAYOPEN)) - _servent_close(sd); - return sp; -} diff --git a/lib/libc/net/getservbyport.c b/lib/libc/net/getservbyport.c deleted file mode 100644 index 8562c3d3d..000000000 --- a/lib/libc/net/getservbyport.c +++ /dev/null @@ -1,62 +0,0 @@ -/* $NetBSD: getservbyport.c,v 1.12 2008/04/28 20:23:00 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getservbyport.c,v 1.12 2008/04/28 20:23:00 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include "servent.h" - -#ifdef __weak_alias -__weak_alias(getservbyport,_getservbyport) -#endif - -#ifdef _REENTRANT -extern mutex_t _servent_mutex; -#endif -extern struct servent_data _servent_data; - -struct servent * -getservbyport(int port, const char *proto) -{ - struct servent *s; - - mutex_lock(&_servent_mutex); - s = getservbyport_r(port, proto, &_servent_data.serv, &_servent_data); - mutex_unlock(&_servent_mutex); - return (s); -} diff --git a/lib/libc/net/getservbyport_r.c b/lib/libc/net/getservbyport_r.c deleted file mode 100644 index 3d8f365c3..000000000 --- a/lib/libc/net/getservbyport_r.c +++ /dev/null @@ -1,123 +0,0 @@ -/* $NetBSD: getservbyport_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getservbyport.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getservbyport_r.c,v 1.9 2012/03/13 21:13:41 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include - -#include "servent.h" - -#ifdef __weak_alias -__weak_alias(getservbyport_r,_getservbyport_r) -#endif - -static struct servent * -_servent_getbyport(struct servent_data *sd, struct servent *sp, int port, - const char *proto) -{ - - if ((sd->flags & (_SV_CDB | _SV_PLAINFILE)) == 0) - return NULL; - - if (sd->flags & _SV_CDB) { - uint8_t buf[255 + 4]; - size_t protolen; - const uint8_t *data; - const void *data_ptr; - size_t datalen; - - port = be16toh(port); - - if (proto != NULL) { - protolen = strlen(proto); - if (protolen == 0 || protolen > 255) - return NULL; - } else - protolen = 0; - if (port < 0 || port > 65536) - return NULL; - - buf[0] = 0; - buf[1] = (uint8_t)protolen; - be16enc(buf + 2, port); - memcpy(buf + 4, proto, protolen); - - if (cdbr_find(sd->cdb, buf, 4 + protolen, - &data_ptr, &datalen)) - return NULL; - - if (datalen < protolen + 4) - return NULL; - - data = data_ptr; - if (be16dec(data) != port) - return NULL; - if (protolen) { - if (data[2] != protolen) - return NULL; - if (memcmp(data + 3, proto, protolen + 1)) - return NULL; - } - return _servent_parsedb(sd, sp, data, datalen); - } else { - while (_servent_getline(sd) != -1) { - if (_servent_parseline(sd, sp) == NULL) - continue; - if (sp->s_port != port) - continue; - if (proto == NULL || strcmp(sp->s_proto, proto) == 0) - return sp; - } - return NULL; - } -} - -struct servent * -getservbyport_r(int port, const char *proto, struct servent *sp, - struct servent_data *sd) -{ - setservent_r(sd->flags & _SV_STAYOPEN, sd); - sp = _servent_getbyport(sd, sp, port, proto); - if (!(sd->flags & _SV_STAYOPEN)) - _servent_close(sd); - return sp; -} diff --git a/lib/libc/net/getservent.3 b/lib/libc/net/getservent.3 deleted file mode 100644 index d6bcdfe28..000000000 --- a/lib/libc/net/getservent.3 +++ /dev/null @@ -1,154 +0,0 @@ -.\" $NetBSD: getservent.3,v 1.14 2003/08/07 16:43:10 agc Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)getservent.3 8.4 (Berkeley) 5/25/95 -.\" -.Dd May 25, 1995 -.Dt GETSERVENT 3 -.Os -.Sh NAME -.Nm getservent , -.Nm getservbyport , -.Nm getservbyname , -.Nm setservent , -.Nm endservent -.Nd get service entry -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In netdb.h -.Ft struct servent * -.Fn getservent -.Ft struct servent * -.Fn getservbyname "const char *name" "const char *proto" -.Ft struct servent * -.Fn getservbyport "int port" "const char *proto" -.Ft void -.Fn setservent "int stayopen" -.Ft void -.Fn endservent void -.Sh DESCRIPTION -The -.Fn getservent , -.Fn getservbyname , -and -.Fn getservbyport -functions -each return a pointer to an object with the -following structure -containing the broken-out -fields of a line in the network services data base, -.Pa /etc/services . -.Bd -literal -offset indent -struct servent { - char *s_name; /* official name of service */ - char **s_aliases; /* alias list */ - int s_port; /* port service resides at */ - char *s_proto; /* protocol to use */ -}; -.Ed -.Pp -The members of this structure are: -.Bl -tag -width s_aliases -.It Fa s_name -The official name of the service. -.It Fa s_aliases -A NULL terminated list of alternative names for the service. -.It Fa s_port -The port number at which the service resides. -Port numbers must be given and are returned in network byte order. -.It Fa s_proto -The name of the protocol to use when contacting the -service. -.El -.Pp -The -.Fn getservent -function -reads the next line of the file, opening the file if necessary. -.Pp -The -.Fn setservent -function -opens and rewinds the file. If the -.Fa stayopen -flag is non-zero, -the net data base will not be closed after each call to -.Fn getservbyname -or -.Fn getservbyport . -.Pp -The -.Fn endservent -function -closes the file. -.Pp -The -.Fn getservbyname -and -.Fn getservbyport -functions -sequentially search from the beginning -of the file until a matching -protocol name or -port number is found, -or until -.Dv EOF -is encountered. -If a protocol name is also supplied (non-\c -.Dv NULL ) , -searches must also match the protocol. -.Sh FILES -.Bl -tag -width /etc/services -compact -.It Pa /etc/services -.El -.Sh DIAGNOSTICS -Null pointer -(0) returned on -.Dv EOF -or error. -.Sh SEE ALSO -.Xr getprotoent 3 , -.Xr services 5 -.Sh HISTORY -The -.Fn getservent , -.Fn getservbyport , -.Fn getservbyname , -.Fn setservent , -and -.Fn endservent -functions appeared in -.Bx 4.2 . -.Sh BUGS -These functions use static data storage; -if the data is needed for future use, it should be -copied before any subsequent calls overwrite it. -Expecting port numbers to fit in a 32 bit -quantity is probably naive. diff --git a/lib/libc/net/getservent.c b/lib/libc/net/getservent.c deleted file mode 100644 index 5465d6aa6..000000000 --- a/lib/libc/net/getservent.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $NetBSD: getservent.c,v 1.12 2008/04/28 20:23:00 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: getservent.c,v 1.12 2008/04/28 20:23:00 martin Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include "reentrant.h" - -#include - -#include "servent.h" - -#ifdef __weak_alias -__weak_alias(endservent,_endservent) -__weak_alias(getservent,_getservent) -__weak_alias(setservent,_setservent) -#endif - -#ifdef _REENTRANT -mutex_t _servent_mutex = MUTEX_INITIALIZER; -#endif -struct servent_data _servent_data; - -void -setservent(int f) -{ - mutex_lock(&_servent_mutex); - setservent_r(f, &_servent_data); - mutex_unlock(&_servent_mutex); -} - -void -endservent(void) -{ - mutex_lock(&_servent_mutex); - endservent_r(&_servent_data); - mutex_unlock(&_servent_mutex); -} - -struct servent * -getservent(void) -{ - struct servent *s; - - mutex_lock(&_servent_mutex); - s = getservent_r(&_servent_data.serv, &_servent_data); - mutex_unlock(&_servent_mutex); - return (s); -} diff --git a/lib/libc/net/getservent_r.c b/lib/libc/net/getservent_r.c deleted file mode 100644 index fc2ca212e..000000000 --- a/lib/libc/net/getservent_r.c +++ /dev/null @@ -1,323 +0,0 @@ -/* $NetBSD: getservent_r.c,v 1.11 2011/10/15 23:00:02 christos Exp $ */ - -/* - * Copyright (c) 1983, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)getservent.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: getservent_r.c,v 1.11 2011/10/15 23:00:02 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#include "servent.h" - -#ifdef __weak_alias -__weak_alias(endservent_r,_endservent_r) -__weak_alias(getservent_r,_getservent_r) -__weak_alias(setservent_r,_setservent_r) -#endif - -int -_servent_open(struct servent_data *sd) -{ - if (sd->flags & (_SV_CDB | _SV_PLAINFILE)) { - sd->flags |= _SV_FIRST; - return 0; - } - - free(sd->line); - sd->line = NULL; - free(sd->cdb_buf); - sd->cdb_buf = NULL; - sd->cdb_buf_len = 0; - free(sd->aliases); - sd->aliases = NULL; - sd->maxaliases = 0; - sd->flags |= _SV_FIRST; - - sd->cdb = cdbr_open(_PATH_SERVICES_CDB, CDBR_DEFAULT); - if (sd->cdb != NULL) { - sd->flags |= _SV_CDB; - return 0; - } - - sd->plainfile = fopen(_PATH_SERVICES, "re"); - if (sd->plainfile != NULL) { - sd->flags |= _SV_PLAINFILE; - return 0; - } - return -1; -} - -void -_servent_close(struct servent_data *sd) -{ - if (sd->flags & _SV_CDB) { - cdbr_close(sd->cdb); - sd->cdb = NULL; - sd->flags &= ~_SV_CDB; - } - - if (sd->flags & _SV_PLAINFILE) { - (void)fclose(sd->plainfile); - sd->plainfile = NULL; - sd->flags &= ~_SV_PLAINFILE; - } - sd->flags &= ~_SV_STAYOPEN; -} - - -int -_servent_getline(struct servent_data *sd) -{ - - if (sd->flags & _SV_CDB) - return -1; - - if ((sd->flags & _SV_PLAINFILE) == 0) - return -1; - - free(sd->line); - sd->line = NULL; - - if (sd->flags & _SV_FIRST) { - (void)rewind((FILE *)sd->plainfile); - sd->flags &= ~_SV_FIRST; - } - sd->line = fparseln(sd->plainfile, NULL, NULL, NULL, - FPARSELN_UNESCALL); - return sd->line == NULL ? -1 : 0; -} - -struct servent * -_servent_parseline(struct servent_data *sd, struct servent *sp) -{ - size_t i = 0; - int oerrno; - char *p, *cp, **q; - - if (sd->line == NULL) - return NULL; - - sp->s_name = p = sd->line; - p = strpbrk(p, " \t"); - if (p == NULL) - return NULL; - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - cp = strpbrk(p, ",/"); - if (cp == NULL) - return NULL; - *cp++ = '\0'; - sp->s_port = htons((u_short)atoi(p)); - sp->s_proto = cp; - if (sd->aliases == NULL) { - sd->maxaliases = 10; - sd->aliases = calloc(sd->maxaliases, sizeof(*sd->aliases)); - if (sd->aliases == NULL) { - oerrno = errno; - endservent_r(sd); - errno = oerrno; - return NULL; - } - } - sp->s_aliases = sd->aliases; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - while (cp && *cp) { - if (*cp == ' ' || *cp == '\t') { - cp++; - continue; - } - if (i == sd->maxaliases - 2) { - sd->maxaliases *= 2; - q = realloc(sd->aliases, sd->maxaliases * sizeof(*q)); - if (q == NULL) { - oerrno = errno; - endservent_r(sd); - errno = oerrno; - return NULL; - } - sp->s_aliases = sd->aliases = q; - } - sp->s_aliases[i++] = cp; - cp = strpbrk(cp, " \t"); - if (cp != NULL) - *cp++ = '\0'; - } - sp->s_aliases[i] = NULL; - return sp; -} - -void -setservent_r(int f, struct servent_data *sd) -{ - (void)_servent_open(sd); - sd->flags |= f ? _SV_STAYOPEN : 0; -} - -void -endservent_r(struct servent_data *sd) -{ - _servent_close(sd); - free(sd->aliases); - sd->aliases = NULL; - sd->maxaliases = 0; - free(sd->line); - sd->line = NULL; - free(sd->cdb_buf); - sd->cdb_buf = NULL; - sd->cdb_buf_len = 0; -} - -struct servent * -getservent_r(struct servent *sp, struct servent_data *sd) -{ - - if ((sd->flags & (_SV_CDB | _SV_PLAINFILE)) == 0 && - _servent_open(sd) == -1) - return NULL; - - if (sd->flags & _SV_CDB) { - const void *data; - size_t len; - - if (sd->flags & _SV_FIRST) { - sd->cdb_index = 0; - sd->flags &= ~_SV_FIRST; - } - - if (cdbr_get(sd->cdb, sd->cdb_index, &data, &len)) - return NULL; - ++sd->cdb_index; - return _servent_parsedb(sd, sp, data, len); - } - if (sd->flags & _SV_PLAINFILE) { - for (;;) { - if (_servent_getline(sd) == -1) - return NULL; - if (_servent_parseline(sd, sp) == NULL) - continue; - return sp; - } - } - return NULL; -} - -struct servent * -_servent_parsedb(struct servent_data *sd, struct servent *sp, - const uint8_t *data, size_t len) -{ - char **q; - size_t i; - int oerrno; - - if ((sd->flags & _SV_STAYOPEN) == 0) { - if (len > sd->cdb_buf_len) { - void *tmp = realloc(sd->cdb_buf, len); - if (tmp == NULL) - goto fail; - sd->cdb_buf = tmp; - sd->cdb_buf_len = len; - } - memcpy(sd->cdb_buf, data, len); - data = sd->cdb_buf; - } - - if (len < 2) - goto fail; - sp->s_port = htobe16(be16dec(data)); - data += 2; - len -= 2; - - if (len == 0 || len < (size_t)data[0] + 2) - goto fail; - sp->s_proto = __UNCONST(data + 1); - - if (sp->s_proto[data[0]] != '\0') - goto fail; - - len -= 2 + data[0]; - data += 2 + data[0]; - - if (len == 0) - goto fail; - if (len < (size_t)data[0] + 2) - goto fail; - - sp->s_name = __UNCONST(data + 1); - len -= 2 + data[0]; - data += 2 + data[0]; - - if (sd->aliases == NULL) { - sd->maxaliases = 10; - sd->aliases = malloc(sd->maxaliases * sizeof(char *)); - if (sd->aliases == NULL) - goto fail; - } - sp->s_aliases = sd->aliases; - i = 0; - while (len) { - if (len < (size_t)data[0] + 2) - goto fail; - if (i == sd->maxaliases - 2) { - sd->maxaliases *= 2; - q = realloc(sd->aliases, sd->maxaliases * sizeof(*q)); - if (q == NULL) - goto fail; - sp->s_aliases = sd->aliases = q; - } - sp->s_aliases[i++] = __UNCONST(data + 1); - len -= 2 + data[0]; - data += 2 + data[0]; - } - sp->s_aliases[i] = NULL; - return sp; - -fail: - oerrno = errno; - endservent_r(sd); - errno = oerrno; - return NULL; -} - diff --git a/lib/libc/net/hesiod.3 b/lib/libc/net/hesiod.3 deleted file mode 100644 index f2b9a3e1c..000000000 --- a/lib/libc/net/hesiod.3 +++ /dev/null @@ -1,150 +0,0 @@ -.\" $NetBSD: hesiod.3,v 1.7 2009/03/10 23:36:10 joerg Exp $ -.\" -.\" from: #Id: hesiod.3,v 1.9.2.1 1997/01/03 21:02:23 ghudson Exp # -.\" -.\" Copyright 1988, 1996 by the Massachusetts Institute of Technology. -.\" -.\" Permission to use, copy, modify, and distribute this -.\" software and its documentation for any purpose and without -.\" fee is hereby granted, provided that the above copyright -.\" notice appear in all copies and that both that copyright -.\" notice and this permission notice appear in supporting -.\" documentation, and that the name of M.I.T. not be used in -.\" advertising or publicity pertaining to distribution of the -.\" software without specific, written prior permission. -.\" M.I.T. makes no representations about the suitability of -.\" this software for any purpose. It is provided "as is" -.\" without express or implied warranty. -.\" -.Dd September 16, 2001 -.Dt HESIOD 3 -.Os -.Sh NAME -.Nm hesiod , -.Nm hesiod_init , -.Nm hesiod_resolve , -.Nm hesiod_free_list , -.Nm hesiod_to_bind , -.Nm hesiod_end -.Nd Hesiod name server interface library -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In hesiod.h -.Ft int -.Fn hesiod_init "void **context" -.Ft char -.Fn **hesiod_resolve "void *context" "const char *name" "const char *type" -.Ft void -.Fn hesiod_free_list "void *context" "char **list" -.Ft char -.Fn *hesiod_to_bind "void *context" "const char *name" "const char *type" -.Ft void -.Fn hesiod_end "void *context" -.Sh DESCRIPTION -This family of functions allows you to perform lookups of Hesiod -information, which is stored as text records in the Domain Name -Service. To perform lookups, you must first initialize a -.Fa context , -an opaque object which stores information used internally by the -library between calls. -.Fn hesiod_init -initializes a context, storing a pointer to the context in the -location pointed to by the -.Fa context -argument. -.Fn hesiod_end -frees the resources used by a context. -.Pp -.Fn hesiod_resolve -is the primary interface to the library. If successful, it returns a -list of one or more strings giving the records matching -.Fa name -and -.Fa type . -The last element of the list is followed by a -.Dv NULL -pointer. It is the caller's responsibility to call -.Fn hesiod_free_list -to free the resources used by the returned list. -.Pp -.Fn hesiod_to_bind -converts -.Fa name -and -.Fa type -into the DNS name used by -.Fn hesiod_resolve . -It is the caller's responsibility to free the returned string using -.Xr free 3 . -.Sh RETURN VALUES -If successful, -.Fn hesiod_init -returns 0; otherwise it returns \-1 and sets -.Va errno -to indicate the error. On failure, -.Fn hesiod_resolve -and -.Fn hesiod_to_bind -return -.Dv NULL -and set the global variable -.Va errno -to indicate the error. -.Sh ENVIRONMENT -If the environment variable -.Ev HES_DOMAIN -is set, it will override the domain in the Hesiod configuration file. -If the environment variable -.Ev HESIOD_CONFIG -is set, it specifies the location of the Hesiod configuration file. -.Sh ERRORS -Hesiod calls may fail because of: -.Bl -tag -width ECONNREFUSED -compact -.It Er ENOMEM -Insufficient memory was available to carry out the requested operation. -.It Er ENOEXEC -.Fn hesiod_init -failed because the Hesiod configuration file was invalid. -.It Er ECONNREFUSED -.Fn hesiod_resolve -failed because no name server could be contacted to answer the query. -.It Er EMSGSIZE -.Fn hesiod_resolve -or -.Fn hesiod_to_bind -failed because the query or response was too big to fit into the -packet buffers. -.It Er ENOENT -.Fn hesiod_resolve -failed because the name server had no text records matching -.Fa name -and -.Fa type , -or -.Fn hesiod_to_bind -failed because the -.Fa name -argument had a domain extension which could not be resolved with type -.Dq rhs-extension -in the local Hesiod domain. -.El -.Sh SEE ALSO -.Xr hesiod.conf 5 , -.Xr named 8 -.Rs -.%T Hesiod - Project Athena Technical Plan -- Name Service -.Re -.Sh AUTHORS -.An Steve Dyer, IBM/Project Athena -.An Greg Hudson, MIT Team Athena -.Pp -Copyright 1987, 1988, 1995, 1996 by the Massachusetts Institute of Technology. -.Sh BUGS -The strings corresponding to the -.Ev errno -values set by the Hesiod functions are not particularly indicative of -what went wrong, especially for -.Er ENOEXEC -and -.Er ENOENT . diff --git a/lib/libc/net/hesiod.c b/lib/libc/net/hesiod.c deleted file mode 100644 index f40df0e0d..000000000 --- a/lib/libc/net/hesiod.c +++ /dev/null @@ -1,632 +0,0 @@ -/* $NetBSD: hesiod.c,v 1.28 2014/09/18 13:58:20 christos Exp $ */ - -/* Copyright (c) 1996 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS - * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE - * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* Copyright 1996 by the Massachusetts Institute of Technology. - * - * Permission to use, copy, modify, and distribute this - * software and its documentation for any purpose and without - * fee is hereby granted, provided that the above copyright - * notice appear in all copies and that both that copyright - * notice and this permission notice appear in supporting - * documentation, and that the name of M.I.T. not be used in - * advertising or publicity pertaining to distribution of the - * software without specific, written prior permission. - * M.I.T. makes no representations about the suitability of - * this software for any purpose. It is provided "as is" - * without express or implied warranty. - */ - -/* This file is part of the hesiod library. It implements the core - * portion of the hesiod resolver. - * - * This file is loosely based on an interim version of hesiod.c from - * the BIND IRS library, which was in turn based on an earlier version - * of this file. Extensive changes have been made on each step of the - * path. - * - * This implementation is thread-safe because it uses res_nsend(). - */ - -#include - -#if defined(LIBC_SCCS) && !defined(lint) -__IDSTRING(rcsid_hesiod_c, - "#Id: hesiod.c,v 1.18.2.1 1997/01/03 20:48:20 ghudson Exp #"); -__IDSTRING(rcsid_hesiod_p_h, - "#Id: hesiod_p.h,v 1.1 1996/12/08 21:39:37 ghudson Exp #"); -__IDSTRING(rcsid_hescompat_c, - "#Id: hescompat.c,v 1.1.2.1 1996/12/16 08:37:45 ghudson Exp #"); -__RCSID("$NetBSD: hesiod.c,v 1.28 2014/09/18 13:58:20 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(hesiod_init,_hesiod_init) -__weak_alias(hesiod_end,_hesiod_end) -__weak_alias(hesiod_to_bind,_hesiod_to_bind) -__weak_alias(hesiod_resolve,_hesiod_resolve) -__weak_alias(hesiod_free_list,_hesiod_free_list) -__weak_alias(hes_init,_hes_init) -__weak_alias(hes_to_bind,_hes_to_bind) -__weak_alias(hes_resolve,_hes_resolve) -__weak_alias(hes_error,_hes_error) -__weak_alias(hes_free,_hes_free) -#endif - -struct hesiod_p { - char *lhs; /* normally ".ns" */ - char *rhs; /* AKA the default hesiod domain */ - int classes[2]; /* The class search order. */ -}; - -#define MAX_HESRESP 1024 - -static int read_config_file(struct hesiod_p *, const char *); -static char **get_txt_records(int, const char *); -static int init_context(void); -static void translate_errors(void); - - -/* - * hesiod_init -- - * initialize a hesiod_p. - */ -int -hesiod_init(void **context) -{ - struct hesiod_p *ctx; - const char *p, *configname; - int serrno; - - _DIAGASSERT(context != NULL); - - ctx = calloc(1, sizeof(struct hesiod_p)); - if (ctx) { - *context = ctx; - /* - * don't permit overrides from environment - * for set.id programs - */ - if (issetugid()) - configname = NULL; - else - configname = getenv("HESIOD_CONFIG"); - if (!configname) - configname = _PATH_HESIOD_CONF; - if (read_config_file(ctx, configname) >= 0) { - /* - * The default rhs can be overridden by an - * environment variable, unless set.id. - */ - if (issetugid()) - p = NULL; - else - p = getenv("HES_DOMAIN"); - if (p) { - if (ctx->rhs) - free(ctx->rhs); - ctx->rhs = malloc(strlen(p) + 2); - if (ctx->rhs) { - *ctx->rhs = '.'; - strcpy(ctx->rhs + 1, - (*p == '.') ? p + 1 : p); - return 0; - } else - errno = ENOMEM; - } else - return 0; - } - } else - errno = ENOMEM; - - serrno = errno; - if (ctx) { - if (ctx->lhs) - free(ctx->lhs); - if (ctx->rhs) - free(ctx->rhs); - free(ctx); - } - errno = serrno; - return -1; -} - -/* - * hesiod_end -- - * Deallocates the hesiod_p. - */ -void -hesiod_end(void *context) -{ - struct hesiod_p *ctx = (struct hesiod_p *) context; - - _DIAGASSERT(context != NULL); - - free(ctx->rhs); - if (ctx->lhs) - free(ctx->lhs); - free(ctx); -} - -/* - * hesiod_to_bind -- - * takes a hesiod (name, type) and returns a DNS - * name which is to be resolved. - */ -char * -hesiod_to_bind(void *context, const char *name, const char *type) -{ - struct hesiod_p *ctx = (struct hesiod_p *) context; - char bindname[MAXDNAME], *p, *ret, **rhs_list = NULL; - const char *rhs; - size_t len; - - _DIAGASSERT(context != NULL); - _DIAGASSERT(name != NULL); - _DIAGASSERT(type != NULL); - - if (strlcpy(bindname, name, sizeof(bindname)) >= sizeof(bindname)) { - errno = EMSGSIZE; - return NULL; - } - - /* - * Find the right right hand side to use, possibly - * truncating bindname. - */ - p = strchr(bindname, '@'); - if (p) { - *p++ = 0; - if (strchr(p, '.')) - rhs = name + (p - bindname); - else { - rhs_list = hesiod_resolve(context, p, "rhs-extension"); - if (rhs_list) - rhs = *rhs_list; - else { - errno = ENOENT; - return NULL; - } - } - } else - rhs = ctx->rhs; - - /* See if we have enough room. */ - len = strlen(bindname) + 1 + strlen(type); - if (ctx->lhs) - len += strlen(ctx->lhs) + ((ctx->lhs[0] != '.') ? 1 : 0); - len += strlen(rhs) + ((rhs[0] != '.') ? 1 : 0); - if (len > sizeof(bindname) - 1) { - if (rhs_list) - hesiod_free_list(context, rhs_list); - errno = EMSGSIZE; - return NULL; - } - /* Put together the rest of the domain. */ - strlcat(bindname, ".", sizeof(bindname)); - strlcat(bindname, type, sizeof(bindname)); - /* Only append lhs if it isn't empty. */ - if (ctx->lhs && ctx->lhs[0] != '\0' ) { - if (ctx->lhs[0] != '.') - strlcat(bindname, ".", sizeof(bindname)); - strlcat(bindname, ctx->lhs, sizeof(bindname)); - } - if (rhs[0] != '.') - strlcat(bindname, ".", sizeof(bindname)); - strlcat(bindname, rhs, sizeof(bindname)); - - /* rhs_list is no longer needed, since we're done with rhs. */ - if (rhs_list) - hesiod_free_list(context, rhs_list); - - /* Make a copy of the result and return it to the caller. */ - ret = strdup(bindname); - if (ret == NULL) - errno = ENOMEM; - return ret; -} - -/* - * hesiod_resolve -- - * Given a hesiod name and type, return an array of strings returned - * by the resolver. - */ -char ** -hesiod_resolve(void *context, const char *name, const char *type) -{ - struct hesiod_p *ctx = (struct hesiod_p *) context; - char *bindname, **retvec; - - _DIAGASSERT(context != NULL); - _DIAGASSERT(name != NULL); - _DIAGASSERT(type != NULL); - - bindname = hesiod_to_bind(context, name, type); - if (!bindname) - return NULL; - - retvec = get_txt_records(ctx->classes[0], bindname); - if (retvec == NULL && errno == ENOENT && ctx->classes[1]) - retvec = get_txt_records(ctx->classes[1], bindname); - - free(bindname); - return retvec; -} - -/*ARGSUSED*/ -void -hesiod_free_list(void *context, char **list) -{ - char **p; - - _DIAGASSERT(context != NULL); - - if (list == NULL) - return; - for (p = list; *p; p++) - free(*p); - free(list); -} - - -/* read_config_file -- - * Parse the /etc/hesiod.conf file. Returns 0 on success, - * -1 on failure. On failure, it might leave values in ctx->lhs - * or ctx->rhs which need to be freed by the caller. - */ -static int -read_config_file(struct hesiod_p *ctx, const char *filename) -{ - char *buf, *key, *data, *p, **which; - int n; - FILE *fp; - - _DIAGASSERT(ctx != NULL); - _DIAGASSERT(filename != NULL); - - /* Set default query classes. */ - ctx->classes[0] = C_IN; - ctx->classes[1] = C_HS; - - /* Try to open the configuration file. */ - fp = fopen(filename, "re"); - if (!fp) { - /* Use compiled in default domain names. */ - ctx->lhs = strdup(DEF_LHS); - ctx->rhs = strdup(DEF_RHS); - if (ctx->lhs && ctx->rhs) - return 0; - else { - errno = ENOMEM; - return -1; - } - } - ctx->lhs = NULL; - ctx->rhs = NULL; - for (; (buf = fparseln(fp, NULL, NULL, NULL, FPARSELN_UNESCALL)) - != NULL; free(buf)) { - p = buf; - while (*p == ' ' || *p == '\t') - p++; - key = p; - while (*p != ' ' && *p != '\t' && *p != '=' && *p) - p++; - - if (*p == '\0') - continue; - - *p++ = 0; - - while (isspace((u_char) *p) || *p == '=') - p++; - - if (*p == '\0') - continue; - - data = p; - while (!isspace((u_char) *p) && *p) - p++; - - *p = 0; - - if (strcasecmp(key, "lhs") == 0 || - strcasecmp(key, "rhs") == 0) { - which = (strcasecmp(key, "lhs") == 0) - ? &ctx->lhs : &ctx->rhs; - *which = strdup(data); - if (!*which) { - errno = ENOMEM; - free(buf); - (void)fclose(fp); - return -1; - } - } else { - if (strcasecmp(key, "classes") == 0) { - n = 0; - while (*data && n < 2) { - p = data; - while (*p && *p != ',') - p++; - if (*p) - *p++ = 0; - if (strcasecmp(data, "IN") == 0) - ctx->classes[n++] = C_IN; - else - if (strcasecmp(data, "HS") == 0) - ctx->classes[n++] = - C_HS; - data = p; - } - while (n < 2) - ctx->classes[n++] = 0; - } - } - } - fclose(fp); - - if (!ctx->rhs || ctx->classes[0] == 0 || - ctx->classes[0] == ctx->classes[1]) { - errno = ENOEXEC; - return -1; - } - return 0; -} - -/* - * get_txt_records -- - * Given a DNS class and a DNS name, do a lookup for TXT records, and - * return a list of them. - */ -static char ** -get_txt_records(int qclass, const char *name) -{ - HEADER *hp; - unsigned char qbuf[PACKETSZ], abuf[MAX_HESRESP], *p, *eom, *eor; - char *dst, **list; - int ancount, qdcount, i, j, n, skip, type, class, len; - res_state res = __res_get_state(); - - if (res == NULL) - return NULL; - - _DIAGASSERT(name != NULL); - - /* Construct the query. */ - n = res_nmkquery(res, QUERY, name, qclass, T_TXT, NULL, 0, - NULL, qbuf, PACKETSZ); - if (n < 0) { - errno = EMSGSIZE; - __res_put_state(res); - return NULL; - } - - /* Send the query. */ - n = res_nsend(res, qbuf, n, abuf, MAX_HESRESP); - __res_put_state(res); - if (n < 0) { - errno = ECONNREFUSED; - return NULL; - } - /* Parse the header of the result. */ - hp = (HEADER *) (void *) abuf; - ancount = ntohs(hp->ancount); - qdcount = ntohs(hp->qdcount); - p = abuf + sizeof(HEADER); - eom = abuf + n; - - /* - * Skip questions, trying to get to the answer section - * which follows. - */ - for (i = 0; i < qdcount; i++) { - skip = dn_skipname(p, eom); - if (skip < 0 || p + skip + QFIXEDSZ > eom) { - errno = EMSGSIZE; - return NULL; - } - p += skip + QFIXEDSZ; - } - - /* Allocate space for the text record answers. */ - list = malloc((ancount + 1) * sizeof(char *)); - if (!list) { - errno = ENOMEM; - return NULL; - } - /* Parse the answers. */ - j = 0; - for (i = 0; i < ancount; i++) { - /* Parse the header of this answer. */ - skip = dn_skipname(p, eom); - if (skip < 0 || p + skip + 10 > eom) - break; - type = p[skip + 0] << 8 | p[skip + 1]; - class = p[skip + 2] << 8 | p[skip + 3]; - len = p[skip + 8] << 8 | p[skip + 9]; - p += skip + 10; - if (p + len > eom) { - errno = EMSGSIZE; - break; - } - /* Skip entries of the wrong class and type. */ - if (class != qclass || type != T_TXT) { - p += len; - continue; - } - /* Allocate space for this answer. */ - list[j] = malloc((size_t)len); - if (!list[j]) { - errno = ENOMEM; - break; - } - dst = list[j++]; - - /* Copy answer data into the allocated area. */ - eor = p + len; - while (p < eor) { - n = (unsigned char) *p++; - if (p + n > eor) { - errno = EMSGSIZE; - break; - } - memcpy(dst, p, (size_t)n); - p += n; - dst += n; - } - if (p < eor) { - errno = EMSGSIZE; - break; - } - *dst = 0; - } - - /* - * If we didn't terminate the loop normally, something - * went wrong. - */ - if (i < ancount) { - for (i = 0; i < j; i++) - free(list[i]); - free(list); - return NULL; - } - if (j == 0) { - errno = ENOENT; - free(list); - return NULL; - } - list[j] = NULL; - return list; -} - -/* - * COMPATIBILITY FUNCTIONS - */ - -static int inited = 0; -static void *context; -static int errval = HES_ER_UNINIT; - -int -hes_init(void) -{ - init_context(); - return errval; -} - -char * -hes_to_bind(const char *name, const char *type) -{ - static char *bindname; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(type != NULL); - - if (init_context() < 0) - return NULL; - if (bindname) - free(bindname); - bindname = hesiod_to_bind(context, name, type); - if (!bindname) - translate_errors(); - return bindname; -} - -char ** -hes_resolve(const char *name, const char *type) -{ - static char **list; - - _DIAGASSERT(name != NULL); - _DIAGASSERT(type != NULL); - - if (init_context() < 0) - return NULL; - - /* - * In the old Hesiod interface, the caller was responsible for - * freeing the returned strings but not the vector of strings itself. - */ - if (list) - free(list); - - list = hesiod_resolve(context, name, type); - if (!list) - translate_errors(); - return list; -} - -int -hes_error(void) -{ - return errval; -} - -void -hes_free(char **hp) -{ - hesiod_free_list(context, hp); -} - -static int -init_context(void) -{ - if (!inited) { - inited = 1; - if (hesiod_init(&context) < 0) { - errval = HES_ER_CONFIG; - return -1; - } - errval = HES_ER_OK; - } - return 0; -} - -static void -translate_errors(void) -{ - switch (errno) { - case ENOENT: - errval = HES_ER_NOTFOUND; - break; - case ECONNREFUSED: - case EMSGSIZE: - errval = HES_ER_NET; - break; - default: - /* Not a good match, but the best we can do. */ - errval = HES_ER_CONFIG; - break; - } -} diff --git a/lib/libc/net/hostent.h b/lib/libc/net/hostent.h deleted file mode 100644 index 65fa5d717..000000000 --- a/lib/libc/net/hostent.h +++ /dev/null @@ -1,106 +0,0 @@ -/* $NetBSD: hostent.h,v 1.2 2013/08/27 09:56:12 christos Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#include -#include - -/* - * These are not being advertised because the interfaces are non-standard. - * There are versions by linux, aix, qnx, sun, etc. Our versions are used - * internally to provide thread safety; they mostly resemble qnx. - */ -void sethostent_r(FILE **); -struct hostent *gethostent_r(FILE *, struct hostent *, char *, size_t, int *); -void endhostent_r(FILE **); - -struct hostent *gethostbyname_r(const char *, struct hostent *, char *, size_t, - int *); -struct hostent *gethostbyname2_r(const char *, int, struct hostent *, char *, - size_t, int *); -struct hostent *gethostbyaddr_r(const void *, socklen_t, int, struct hostent *, - char *, size_t, int *); - -extern FILE *_h_file; - -/* - * The following are internal API's and are used only for testing. - */ -struct getnamaddr { - struct hostent *hp; - char *buf; - size_t buflen; - int *he; -}; - -/* /etc/hosts lookup */ -void _hf_sethostsfile(const char *); -int _hf_gethtbyaddr(void *, void *, va_list); -int _hf_gethtbyname(void *, void *, va_list); - -/* DNS lookup */ -int _dns_gethtbyaddr(void *, void *, va_list); -int _dns_gethtbyname(void *, void *, va_list); - -#ifdef YP -/* NIS lookup */ -int _yp_gethtbyaddr(void *, void *, va_list); -int _yp_gethtbyname(void *, void *, va_list); -#endif - -#define HENT_ARRAY(dst, anum, ptr, len) \ - do { \ - size_t _len = (anum + 1) * sizeof(*dst); \ - if (_len > len) \ - goto nospc; \ - dst = (void *)ptr; \ - ptr += _len; \ - len -= _len; \ - } while (/*CONSTCOND*/0) - -#define HENT_COPY(dst, src, slen, ptr, len) \ - do { \ - if ((size_t)slen > len) \ - goto nospc; \ - memcpy(ptr, src, (size_t)slen); \ - dst = ptr; \ - ptr += slen; \ - len -= slen; \ - } while (/* CONSTCOND */0) - -#define HENT_SCOPY(dst, src, ptr, len) \ - do { \ - size_t _len = strlen(src) + 1; \ - HENT_COPY(dst, src, _len, ptr, len); \ - } while (/* CONSTCOND */0) - -#define MAXALIASES 35 -#define MAXADDRS 35 diff --git a/lib/libc/net/if_indextoname.3 b/lib/libc/net/if_indextoname.3 deleted file mode 100644 index 6b27d194a..000000000 --- a/lib/libc/net/if_indextoname.3 +++ /dev/null @@ -1,138 +0,0 @@ -.\" $NetBSD: if_indextoname.3,v 1.12 2010/03/22 19:30:54 joerg Exp $ -.\" $KAME: if_indextoname.3,v 1.10 2000/11/24 08:13:51 itojun Exp $ -.\" BSDI Id: if_indextoname.3,v 2.2 2000/04/17 22:38:05 dab Exp -.\" -.\" Copyright (c) 1997, 2000 -.\" Berkeley Software Design, Inc. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" -.\" THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd March 11, 2005 -.Dt IF_NAMETOINDEX 3 -.Os -.Sh NAME -.Nm if_nametoindex , -.Nm if_indextoname , -.Nm if_nameindex , -.Nm if_freenameindex -.Nd provide mappings between interface names and indexes -.Sh SYNOPSIS -.In net/if.h -.Ft unsigned int -.Fn if_nametoindex "const char *ifname" -.Ft char * -.Fn if_indextoname "unsigned int ifindex" "char *ifname" -.Ft struct if_nameindex * -.Fn if_nameindex "void" -.Ft void -.Fn if_freenameindex "struct if_nameindex *ptr" -.Sh DESCRIPTION -The -.Fn if_nametoindex -function maps the interface name specified in -.Ar ifname -to its corresponding index. -If the specified interface does not exist, it returns 0. -.Pp -The -.Fn if_indextoname -function maps the interface index specified in -.Ar ifindex -to it corresponding name, which is copied into the -buffer pointed to by -.Ar ifname , -which must be of at least IFNAMSIZ bytes. -This pointer is also the return value of the function. -If there is no interface corresponding to the specified -index, NULL is returned. -.Pp -The -.Fn if_nameindex -function returns an array of -.Nm if_nameindex -structures, one structure per interface, as -defined in the include file -.In net/if.h . -The -.Nm if_nameindex -structure contains at least the following entries: -.Bd -literal - unsigned int if_index; /* 1, 2, ... */ - char *if_name; /* null terminated name: "le0", ... */ -.Ed -.Pp -The end of the array of structures is indicated by a structure with an -.Nm if_index -of 0 and an -.Nm if_name -of NULL. -A NULL pointer is returned upon an error. -.Pp -The -.Fn if_freenameindex -function frees the dynamic memory that was -allocated by -.Fn if_nameindex . -.Sh RETURN VALUES -Upon successful completion, -.Fn if_nametoindex -returns the index number of the interface. -If the interface is not found, a value of 0 is returned and -.Va errno -is set to -.Er ENXIO . -A value of 0 is also returned if an error -occurs while retrieving the list of interfaces via -.Xr getifaddrs 3 . -.Pp -Upon successful completion, -.Fn if_indextoname -returns -.Ar ifname . -If the interface is not found, a NULL pointer is returned and -.Va errno -is set to -.Er ENXIO . -A NULL pointer is also returned if an error -occurs while retrieving the list of interfaces via -.Xr getifaddrs 3 . -.Pp -The -.Fn if_nameindex -returns a NULL pointer if an error -occurs while retrieving the list of interfaces via -.Xr getifaddrs 3 , -or if sufficient memory cannot be allocated. -.Sh SEE ALSO -.Xr getifaddrs 3 , -.Xr networking 4 -.Sh STANDARDS -The -.Fn if_nametoindex , -.Fn if_indextoname , -.Fn if_nameindex , -and -.Fn if_freenameindex -functions conform to -.St -p1003.1-2001 , -.St -xns5.2 , -and RFC 3493. -.Sh HISTORY -The implementation first appeared in -.Bsx . diff --git a/lib/libc/net/if_indextoname.c b/lib/libc/net/if_indextoname.c deleted file mode 100644 index 32877bbd2..000000000 --- a/lib/libc/net/if_indextoname.c +++ /dev/null @@ -1,101 +0,0 @@ -/* $NetBSD: if_indextoname.c,v 1.7 2010/12/13 23:10:12 pooka Exp $ */ -/* $KAME: if_indextoname.c,v 1.7 2000/11/08 03:09:30 itojun Exp $ */ - -/*- - * Copyright (c) 1997, 2000 - * Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. - * - * BSDI Id: if_indextoname.c,v 2.3 2000/04/17 22:38:05 dab Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: if_indextoname.c,v 1.7 2010/12/13 23:10:12 pooka Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef RUMP_ACTION -#ifdef __weak_alias -__weak_alias(if_indextoname,_if_indextoname) -#endif -#endif - -/* - * From RFC 2533: - * - * The second function maps an interface index into its corresponding - * name. - * - * #include - * - * char *if_indextoname(unsigned int ifindex, char *ifname); - * - * The ifname argument must point to a buffer of at least IF_NAMESIZE - * bytes into which the interface name corresponding to the specified - * index is returned. (IF_NAMESIZE is also defined in and - * its value includes a terminating null byte at the end of the - * interface name.) This pointer is also the return value of the - * function. If there is no interface corresponding to the specified - * index, NULL is returned, and errno is set to ENXIO, if there was a - * system error (such as running out of memory), if_indextoname returns - * NULL and errno would be set to the proper value (e.g., ENOMEM). - */ - -char * -if_indextoname(unsigned int ifindex, char *ifname) -{ - struct ifaddrs *ifaddrs, *ifa; - int error = 0; - - if (getifaddrs(&ifaddrs) < 0) - return(NULL); /* getifaddrs properly set errno */ - - for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_addr && - ifa->ifa_addr->sa_family == AF_LINK && - ifindex == ((struct sockaddr_dl*) - (void *)ifa->ifa_addr)->sdl_index) - break; - } - - if (ifa == NULL) { - error = ENXIO; - ifname = NULL; - } - else - strlcpy(ifname, ifa->ifa_name, IFNAMSIZ); - - freeifaddrs(ifaddrs); - - errno = error; - return(ifname); -} diff --git a/lib/libc/net/if_nameindex.c b/lib/libc/net/if_nameindex.c deleted file mode 100644 index fdc2731cf..000000000 --- a/lib/libc/net/if_nameindex.c +++ /dev/null @@ -1,155 +0,0 @@ -/* $NetBSD: if_nameindex.c,v 1.7 2012/03/13 21:13:41 christos Exp $ */ -/* $KAME: if_nameindex.c,v 1.8 2000/11/24 08:20:01 itojun Exp $ */ - -/*- - * Copyright (c) 1997, 2000 - * Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. - * - * BSDI Id: if_nameindex.c,v 2.3 2000/04/17 22:38:05 dab Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: if_nameindex.c,v 1.7 2012/03/13 21:13:41 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(if_nameindex,_if_nameindex) -__weak_alias(if_freenameindex,_if_freenameindex) -#endif -/* - * From RFC 2553: - * - * 4.3 Return All Interface Names and Indexes - * - * The if_nameindex structure holds the information about a single - * interface and is defined as a result of including the - * header. - * - * struct if_nameindex { - * unsigned int if_index; - * char *if_name; - * }; - * - * The final function returns an array of if_nameindex structures, one - * structure per interface. - * - * struct if_nameindex *if_nameindex(void); - * - * The end of the array of structures is indicated by a structure with - * an if_index of 0 and an if_name of NULL. The function returns a NULL - * pointer upon an error, and would set errno to the appropriate value. - * - * The memory used for this array of structures along with the interface - * names pointed to by the if_name members is obtained dynamically. - * This memory is freed by the next function. - * - * 4.4. Free Memory - * - * The following function frees the dynamic memory that was allocated by - * if_nameindex(). - * - * #include - * - * void if_freenameindex(struct if_nameindex *ptr); - * - * The argument to this function must be a pointer that was returned by - * if_nameindex(). - */ - -struct if_nameindex * -if_nameindex(void) -{ - struct ifaddrs *ifaddrs, *ifa; - size_t nbytes, ni; - struct if_nameindex *ifni, *ifni2; - char *cp; - - if (getifaddrs(&ifaddrs) < 0) - return(NULL); - - /* - * First, find out how many interfaces there are, and how - * much space we need for the string names. - */ - ni = 0; - nbytes = 0; - for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_addr && - ifa->ifa_addr->sa_family == AF_LINK) { - nbytes += strlen(ifa->ifa_name) + 1; - ni++; - } - } - - /* - * Next, allocate a chunk of memory, use the first part - * for the array of structures, and the last part for - * the strings. - */ - cp = malloc((ni + 1) * sizeof(struct if_nameindex) + nbytes); - ifni = (struct if_nameindex *)(void *)cp; - if (ifni == NULL) - goto out; - cp += (ni + 1) * sizeof(struct if_nameindex); - - /* - * Now just loop through the list of interfaces again, - * filling in the if_nameindex array and making copies - * of all the strings. - */ - ifni2 = ifni; - for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_addr && - ifa->ifa_addr->sa_family == AF_LINK) { - ifni2->if_index = - ((struct sockaddr_dl*) - (void *)ifa->ifa_addr)->sdl_index; - ifni2->if_name = cp; - strcpy(cp, ifa->ifa_name); - ifni2++; - cp += strlen(cp) + 1; - } - } - /* - * Finally, don't forget to terminate the array. - */ - ifni2->if_index = 0; - ifni2->if_name = NULL; -out: - freeifaddrs(ifaddrs); - return(ifni); -} - -void -if_freenameindex(struct if_nameindex *ptr) -{ - free(ptr); -} diff --git a/lib/libc/net/if_nametoindex.c b/lib/libc/net/if_nametoindex.c deleted file mode 100644 index f69addd8a..000000000 --- a/lib/libc/net/if_nametoindex.c +++ /dev/null @@ -1,96 +0,0 @@ -/* $NetBSD: if_nametoindex.c,v 1.5 2015/09/01 09:54:34 ozaki-r Exp $ */ -/* $KAME: if_nametoindex.c,v 1.6 2000/11/24 08:18:54 itojun Exp $ */ - -/*- - * Copyright (c) 1997, 2000 - * Berkeley Software Design, Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * THIS SOFTWARE IS PROVIDED BY Berkeley Software Design, Inc. ``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 Berkeley Software Design, Inc. 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. - * - * BSDI Id: if_nametoindex.c,v 2.3 2000/04/17 22:38:05 dab Exp - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: if_nametoindex.c,v 1.5 2015/09/01 09:54:34 ozaki-r Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#ifndef RUMP_ACTION -#include "namespace.h" -#endif -#include -#include -#include -#include -#include -#include -#include -#include - -#ifndef RUMP_ACTION -#ifdef __weak_alias -__weak_alias(if_nametoindex,_if_nametoindex) -#endif -#endif - -/* - * From RFC 2553: - * - * 4.1 Name-to-Index - * - * - * The first function maps an interface name into its corresponding - * index. - * - * #include - * - * unsigned int if_nametoindex(const char *ifname); - * - * If the specified interface name does not exist, the return value is - * 0, and errno is set to ENXIO. If there was a system error (such as - * running out of memory), the return value is 0 and errno is set to the - * proper value (e.g., ENOMEM). - */ - -unsigned int -if_nametoindex(const char *ifname) -{ - struct ifaddrs *ifaddrs, *ifa; - unsigned int ni; - - if (getifaddrs(&ifaddrs) < 0) - return(0); - - ni = 0; - - for (ifa = ifaddrs; ifa != NULL; ifa = ifa->ifa_next) { - if (ifa->ifa_addr && - ifa->ifa_addr->sa_family == AF_LINK && - strcmp(ifa->ifa_name, ifname) == 0) { - ni = ((struct sockaddr_dl*) - (void *)ifa->ifa_addr)->sdl_index; - break; - } - } - - freeifaddrs(ifaddrs); - if (!ni) - errno = ENXIO; - return(ni); -} diff --git a/lib/libc/net/inet6_getscopeid.3 b/lib/libc/net/inet6_getscopeid.3 deleted file mode 100644 index 4195019c6..000000000 --- a/lib/libc/net/inet6_getscopeid.3 +++ /dev/null @@ -1,100 +0,0 @@ -.\" $NetBSD: inet6_getscopeid.3,v 1.3 2013/10/31 00:30:14 wiz Exp $ -.\"- -.\" Copyright (c) 2013 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Christos Zoulas. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.\" -.Dd October 31, 2013 -.Dt INET6_GETSCOPEID 3 -.Os -.\" -.Sh NAME -.Nm inet6_getscopeid , -.Nm inet6_putscopeid -.Nd IPv6 scope id encoding and decoding functions -.\" -.Sh SYNOPSIS -.In netinet/in.h -.Ft void -.Fn inet6_getscopeid "struct sockaddr_in6 *sin6" "int flags" -.Ft void -.Fn inet6_putscopeid "struct sockaddr_in6 *sin6" "int flags" -.\" -.Sh DESCRIPTION -These functions implement a KAME-specific extension that encodes and -decodes the scope id inside in the 3rd and 4th byte of the address, -for link-local, site-local, and multicast-link-local addresses. -The scope id helps deciding which interface is used for packets of -that type. -.Pp -Typically those two bytes are -.Dv 0 -for these kinds of addresses. -The scope id is stored in network byte order. -.Pp -The -.Fn inet6_getscopeid -function retrieves the scope id from the 3rd and the 4th address bytes -(from the -.Va sin6_addr -member of -.Fa sin6 ) , -and sets the -.Ft sin6_scope_id -from them. -It then clears the two address bytes. -.Pp -The -.Fn inet6putscopeid -function stores the scope id found in -.Ft sin6_scope_id -into the 3rd and 4th byte of the address -(into the -.Va sin6_addr -member of -.Fa sin6 ) . -It then clears the -.Va sin6_scope_id -member of -.Fa sin6 . -.Pp -The -.Fa flags -argument controls for which addresses this action is performed. -It -can be a combination of: -.Bl -bullet -.It -.Dv INET6_IS_ADDR_LINKLOCAL -.It -.Dv INET6_IS_ADDR_MC_LINKLOCAL -.It -.Dv INET6_IS_ADDR_SITELOCAL -.El -.Sh HISTORY -These functions first appeared in -.Nx 7.0 . diff --git a/lib/libc/net/inet6_opt_init.3 b/lib/libc/net/inet6_opt_init.3 deleted file mode 100644 index 17c73ed36..000000000 --- a/lib/libc/net/inet6_opt_init.3 +++ /dev/null @@ -1,337 +0,0 @@ -.\" $NetBSD: inet6_opt_init.3,v 1.2 2014/01/04 15:37:26 wiz Exp $ -.\" $KAME: inet6_opt_init.3,v 1.7 2004/12/27 05:08:23 itojun Exp $ -.\" -.\" Copyright (C) 2004 WIDE Project. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the project 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 PROJECT 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 PROJECT OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd December 23, 2004 -.Dt INET6_OPT_INIT 3 -.Os -.\" -.Sh NAME -.Nm inet6_opt_init , -.Nm inet6_opt_append , -.Nm inet6_opt_finish , -.Nm inet6_opt_set_val , -.Nm inet6_opt_next , -.Nm inet6_opt_find , -.Nm inet6_opt_get_val -.Nd IPv6 Hop-by-Hop and Destination Options manipulation -.\" -.Sh SYNOPSIS -.In netinet/in.h -.Ft "int" -.Fn inet6_opt_init "void *extbuf" "socklen_t extlen" -.Ft "int" -.Fn inet6_opt_append "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t len" "u_int8_t align" "void **databufp" -.Ft "int" -.Fn inet6_opt_finish "void *extbuf" "socklen_t extlen" "int offset" -.Ft "int" -.Fn inet6_opt_set_val "void *databuf" "int offset" "void *val" "socklen_t vallen" -.Ft "int" -.Fn inet6_opt_next "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t *typep" "socklen_t *lenp" "void **databufp" -.Ft "int" -.Fn inet6_opt_find "void *extbuf" "socklen_t extlen" "int offset" "u_int8_t type" "socklen_t *lenp" "void **databufp" -.Ft "int" -.Fn inet6_opt_get_val "void *databuf" "socklen_t offset" "void *val" "socklen_t vallen" -.\" -.Sh DESCRIPTION -Building and parsing the Hop-by-Hop and Destination options is -complicated. -The advanced sockets API defines a set of functions to -help applications create and manipulate Hop-by-Hope and Destination -options. -.\"This man page describes the functions specified in -.\"IETF Draft RFC3542 while the -.\".Xr inet6_options_space 3 -.\"man page documents the functions defined in RFC 2292. -.\"It is expected -.\"that this set of functions will supersede those in RFC 2292 but for -.\"the time being both APIs are retained. -These functions use the -formatting rules specified in Appendix B in RFC2460, i.e., that the -largest field is placed last in the option. -The function prototypes -for these functions are all contained in the -.In netinet/in.h -header file. -.\" -.Ss inet6_opt_init -The -.Fn inet6_opt_init -function -returns the number of bytes needed for an empty -extension header, one without any options. -If the -.Va extbuf -argument points to a valid section of memory -then the -.Fn inet6_opt_init -function also initializes the extension header's length field. -When attempting to initialize an extension buffer passed in the -.Va extbuf argument -.Fa extlen -must be a positive multiple of 8 or else the function fails and -returns \-1 to the caller. -.\" -.Ss inet6_opt_append -The -.Fn inet6_opt_append -function can perform to different jobs. -When a valid -.Fa extbuf -argument is supplied it appends an option to the extension buffer and -returns the updated total length as well as a pointer to the newly -created option in -.Fa databufp . -If the value -of -.Fa extbuf -is -.Dv NULL -then the -.Fn inet6_opt_append function only reports what the total length would -be if the option were actually appended. -The -.Fa len -and -.Fa align -arguments specify the length of the option and the required data -alignment which must be used when appending the option. -The -.Fa offset -argument should be the length returned by the -.Fn inet6_opt_init -function or a previous call to -.Fn inet6_opt_append . -.Pp -The -.Fa type -argument is the 8-bit option type. -.Pp -After -.Fn inet6_opt_append -has been called, the application can use the buffer pointed to by -.Fa databufp -directly, or use -.Fn inet6_opt_set_val -to specify the data to be contained in the option. -.Pp -Option types of -.Li 0 -and -.Li 1 -are reserved for the -.Li Pad1 -and -.Li PadN -options. -All other values from 2 through 255 may be used by applications. -.Pp -The length of the option data is contained in an 8-bit value and so -may contain any value from 0 through 255. -.Pp -The -.Fa align -parameter must have a value of 1, 2, 4, or 8 and cannot exceed the -value of -.Fa len . -The alignment values represent no alignment, 16 bit, 32 bit and 64 bit -alignments respectively. -.\" -.Ss inet6_opt_finish -The -.Fn inet6_opt_finish -calculates the final padding necessary to make the extension header a -multiple of 8 bytes, as required by the IPv6 extension header -specification, and returns the extension header's updated total -length. -The -.Fa offset -argument should be the length returned by -.Fn inet6_opt_init -or -.Fn inet6_opt_append . -When -.Fa extbuf -is not -.Dv NULL -the function also sets up the appropriate padding bytes by inserting a -Pad1 or PadN option of the proper length. -.Pp -If the extension header is too small to contain the proper padding -then an error of \-1 is returned to the caller. -.\" -.Ss inet6_opt_set_val -The -.Fn inet6_opt_set_val -function inserts data items of various sizes into the data portion of -the option. -The -.Fa databuf -argument is a pointer to memory that was returned by the -.Fn inet6_opt_append -call and the -.Fa offset argument specifies where the option should be placed in the -data buffer. -The -.Fa val -argument points to an area of memory containing the data to be -inserted into the extension header, and the -.Fa vallen -argument indicates how much data to copy. -.Pp -The caller should ensure that each field is aligned on its natural -boundaries as described in Appendix B of RFC2460. -.Pp -The function returns the offset for the next field which is calculated as -.Fa offset -+ -.Fa vallen -and is used when composing options with multiple fields. -.\" -.Ss inet6_opt_next -The -.Fn inet6_opt_next -function parses received extension headers. -The -.Fa extbuf -and -.Fa extlen -arguments specify the location and length of the extension header -being parsed. -The -.Fa offset -argument should either be zero, for the first option, or the length value -returned by a previous call to -.Fn inet6_opt_next -or -.Fn inet6_opt_find . -The return value specifies the position where to continue scanning the -extension buffer. -The option is returned in the arguments -.Fa typep , lenp , -and -.Fa databufp . -.Fa typep , lenp , -and -.Fa databufp -point to the 8-bit option type, the 8-bit option length and the option -data respectively. -This function does not return any PAD1 or PADN options. -When an error occurs or there are no more options the return -value is \-1. -.\" -.Ss inet6_opt_find -The -.Fn inet6_opt_find -function searches the extension buffer for a particular option type, -passed in through the -.Fa type -argument. -If the option is found then the -.Fa lenp -and -.Fa databufp -arguments are updated to point to the option's length and data -respectively. -.Fa extbuf -and -.Fa extlen -must point to a valid extension buffer and give its length. -The -.Fa offset -argument can be used to search from a location anywhere in the -extension header. -.Ss inet6_opt_get_val -The -.Fn inet6_opt_get_val -function extracts data items of various sizes in the data portion of -the option. -The -.Fa databuf -is a pointer returned by the -.Fn inet6_opt_next -or -.Fn inet6_opt_find -functions. -The -.Fa val -argument points where the data will be extracted. -The -.Fa offset -argument specifies from where in the data portion of the option the -value should be extracted; the first byte of option data is specified -by an offset of zero. -.Pp -It is expected that each field is aligned on its natural boundaries as -described in Appendix B of RFC2460. -.Pp -The function returns the offset for the next field -by calculating -.Fa offset -+ -.Fa vallen -which can be used when extracting option content with multiple fields. -Robust receivers must verify alignment before calling this function. -.\" -.Sh EXAMPLES -RFC3542 gives comprehensive examples in Section 23. -.Pp -KAME also provides examples in the -.Pa advapitest -directory of its kit. -.\" -.Sh DIAGNOSTICS -All the functions return -\-1 -on an error. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%A E. Nordmark -.%A T. Jinmei -.%T "Advanced Sockets API for IPv6" -.%N RFC3542 -.%D October 2002 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC2460 -.%D December 1998 -.Re -.Sh STANDARDS -The functions are documented in -.Dq Advanced Sockets API for IPv6 -.Pq RFC3542 . -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. diff --git a/lib/libc/net/inet6_option_space.3 b/lib/libc/net/inet6_option_space.3 deleted file mode 100644 index 28aadacc3..000000000 --- a/lib/libc/net/inet6_option_space.3 +++ /dev/null @@ -1,448 +0,0 @@ -.\" $NetBSD: inet6_option_space.3,v 1.17 2010/03/22 19:30:54 joerg Exp $ -.\" $KAME: inet6_option_space.3,v 1.7 2000/05/17 14:32:13 itojun Exp $ -.\" -.\" Copyright (c) 1983, 1987, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd December 10, 1999 -.Dt INET6_OPTION_SPACE 3 -.Os -.\" -.Sh NAME -.Nm inet6_option_space , -.Nm inet6_option_init , -.Nm inet6_option_append , -.Nm inet6_option_alloc , -.Nm inet6_option_next , -.Nm inet6_option_find -.Nd IPv6 Hop-by-Hop and Destination Options manipulation -.\" -.Sh SYNOPSIS -.In netinet/in.h -.Ft "int" -.Fn inet6_option_space "int nbytes" -.Ft "int" -.Fn inet6_option_init "void *bp" "struct cmsghdr **cmsgp" "int type" -.Ft "int" -.Fn inet6_option_append "struct cmsghdr *cmsg" "const uint8_t *typep" "int multx" "int plusy" -.Ft "uint8_t *" -.Fn inet6_option_alloc "struct cmsghdr *cmsg" "int datalen" "int multx" "int plusy" -.Ft "int" -.Fn inet6_option_next "const struct cmsghdr *cmsg" "uint8_t **tptrp" -.Ft "int" -.Fn inet6_option_find "const struct cmsghdr *cmsg" "uint8_t **tptrp" "int type" -.\" -.Sh DESCRIPTION -.\" -Building and parsing the Hop-by-Hop and Destination options is -complicated due to alignment constraints, padding and -ancillary data manipulation. -RFC 2292 defines a set of functions to help the application. -The function prototypes for -these functions are all in the -.In netinet/in.h -header. -.\" -.Ss inet6_option_space -.Fn inet6_option_space -returns the number of bytes required to hold an option when it is stored as -ancillary data, including the -.Li cmsghdr -structure at the beginning, -and any padding at the end -.Po -to make its size a multiple of 8 bytes -.Pc . -The argument is the size of the structure defining the option, -which must include any pad bytes at the beginning -.Po -the value -.Li y -in the alignment term -.Dq Li xn + y -.Pc , -the type byte, the length byte, and the option data. -.Pp -Note: If multiple options are stored in a single ancillary data -object, which is the recommended technique, this function -overestimates the amount of space required by the size of -.Li N-1 -.Li cmsghdr -structures, -where -.Li N -is the number of options to be stored in the object. -This is of little consequence, since it is assumed that most -Hop-by-Hop option headers and Destination option headers carry only -one option -.Pq appendix B of [RFC 2460] . -.\" -.Ss inet6_option_init -.Fn inet6_option_init -is called once per ancillary data object that will -contain either Hop-by-Hop or Destination options. -It returns -.Li 0 -on success or -.Li -1 -on an error. -.Pp -.Fa bp -is a pointer to previously allocated space that will contain the -ancillary data object. -It must be large enough to contain all the -individual options to be added by later calls to -.Fn inet6_option_append -and -.Fn inet6_option_alloc . -.Pp -.Fa cmsgp -is a pointer to a pointer to a -.Li cmsghdr -structure. -.Fa *cmsgp -is initialized by this function to point to the -.Li cmsghdr -structure constructed by this function in the buffer pointed to by -.Fa bp . -.Pp -.Fa type -is either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -This -.Fa type -is stored in the -.Li cmsg_type -member of the -.Li cmsghdr -structure pointed to by -.Fa *cmsgp . -.\" -.Ss inet6_option_append -This function appends a Hop-by-Hop option or a Destination option -into an ancillary data object that has been initialized by -.Fn inet6_option_init . -This function returns -.Li 0 -if it succeeds or -.Li -1 -on an error. -.Pp -.Fa cmsg -is a pointer to the -.Li cmsghdr -structure that must have been -initialized by -.Fn inet6_option_init . -.Pp -.Fa typep -is a pointer to the 8-bit option type. -It is assumed that this -field is immediately followed by the 8-bit option data length field, -which is then followed immediately by the option data. -The caller -initializes these three fields -.Pq the type-length-value, or TLV -before calling this function. -.Pp -The option type must have a value from -.Li 2 -to -.Li 255 , -inclusive. -.Po -.Li 0 -and -.Li 1 -are reserved for the -.Li Pad1 -and -.Li PadN -options, respectively. -.Pc -.Pp -The option data length must have a value between -.Li 0 -and -.Li 255 , -inclusive, and is the length of the option data that follows. -.Pp -.Fa multx -is the value -.Li x -in the alignment term -.Dq Li xn + y . -It must have a value of -.Li 1 , -.Li 2 , -.Li 4 , -or -.Li 8 . -.Pp -.Fa plusy -is the value -.Li y -in the alignment term -.Dq Li xn + y . -It must have a value between -.Li 0 -and -.Li 7 , -inclusive. -.\" -.Ss inet6_option_alloc -This function appends a Hop-by-Hop option or a Destination option -into an ancillary data object that has been initialized by -.Fn inet6_option_init . -This function returns a pointer to the 8-bit -option type field that starts the option on success, or -.Dv NULL -on an error. -.Pp -The difference between this function and -.Fn inet6_option_append -is that the latter copies the contents of a previously built option into -the ancillary data object while the current function returns a -pointer to the space in the data object where the option's TLV must -then be built by the caller. -.Pp -.Fa cmsg -is a pointer to the -.Li cmsghdr -structure that must have been -initialized by -.Fn inet6_option_init . -.Pp -.Fa datalen -is the value of the option data length byte for this option. -This value is required as an argument to allow the function to -determine if padding must be appended at the end of the option. -.Po -The -.Fn inet6_option_append -function does not need a data length argument -since the option data length must already be stored by the caller. -.Pc -.Pp -.Fa multx -is the value -.Li x -in the alignment term -.Dq Li xn + y . -It must have a value of -.Li 1 , -.Li 2 , -.Li 4 , -or -.Li 8 . -.Pp -.Fa plusy -is the value -.Li y -in the alignment term -.Dq Li xn + y . -It must have a value between -.Li 0 -and -.Li 7 , -inclusive. -.\" -.Ss inet6_option_next -This function processes the next Hop-by-Hop option or Destination -option in an ancillary data object. -If another option remains to be -processed, the return value of the function is -.Li 0 -and -.Fa *tptrp -points to -the 8-bit option type field -.Po -which is followed by the 8-bit option -data length, followed by the option data -.Pc . -If no more options remain -to be processed, the return value is -.Li -1 -and -.Fa *tptrp -is -.Dv NULL . -If an error occurs, the return value is -.Li -1 -and -.Fa *tptrp -is not -.Dv NULL . -.Pp -.Fa cmsg -is a pointer to -.Li cmsghdr -structure of which -.Li cmsg_level -equals -.Dv IPPROTO_IPV6 -and -.Li cmsg_type -equals either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -.Pp -.Fa tptrp -is a pointer to a pointer to an 8-bit byte and -.Fa *tptrp -is used -by the function to remember its place in the ancillary data object -each time the function is called. -The first time this function is -called for a given ancillary data object, -.Fa *tptrp -must be set to -.Dv NULL . -.Pp -Each time this function returns success, -.Fa *tptrp -points to the 8-bit -option type field for the next option to be processed. -.\" -.Ss inet6_option_find -This function is similar to the previously described -.Fn inet6_option_next -function, except this function lets the caller -specify the option type to be searched for, instead of always -returning the next option in the ancillary data object. -.Fa cmsg -is a -pointer to -.Li cmsghdr -structure of which -.Li cmsg_level -equals -.Dv IPPROTO_IPV6 -and -.Li cmsg_type -equals either -.Dv IPV6_HOPOPTS -or -.Dv IPV6_DSTOPTS . -.Pp -.Fa tptrp -is a pointer to a pointer to an 8-bit byte and -.Fa *tptrp -is used -by the function to remember its place in the ancillary data object -each time the function is called. -The first time this function is -called for a given ancillary data object, -.Fa *tptrp -must be set to -.Dv NULL . -.Pa -This function starts searching for an option of the specified type -beginning after the value of -.Fa *tptrp . -If an option of the specified -type is located, this function returns -.Li 0 -and -.Fa *tptrp -points to the 8- -bit option type field for the option of the specified type. -If an -option of the specified type is not located, the return value is -.Li -1 -and -.Fa *tptrp -is -.Dv NULL . -If an error occurs, the return value is -.Li -1 -and -.Fa *tptrp -is not -.Dv NULL . -.\" -.Sh EXAMPLES -RFC 2292 gives comprehensive examples in chapter 6. -.\" -.Sh DIAGNOSTICS -.Fn inet6_option_init -and -.Fn inet6_option_append -return -.Li 0 -on success or -.Li -1 -on an error. -.Pp -.Fn inet6_option_alloc -returns -.Dv NULL -on an error. -.Pp -On errors, -.Fn inet6_option_next -and -.Fn inet6_option_find -return -.Li -1 -setting -.Fa *tptrp -to non -.Dv NULL -value. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%T "Advanced Sockets API for IPv6" -.%N RFC 2292 -.%D February 1998 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC 2460 -.%D December 1998 -.Re -.\" -.Sh STANDARDS -The functions -are documented in -.Dq Advanced Sockets API for IPv6 -.Pq RFC 2292 . -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. -.\" -.Sh BUGS -The text was shamelessly copied from RFC 2292. diff --git a/lib/libc/net/inet6_rth_space.3 b/lib/libc/net/inet6_rth_space.3 deleted file mode 100644 index 5fa489dfc..000000000 --- a/lib/libc/net/inet6_rth_space.3 +++ /dev/null @@ -1,223 +0,0 @@ -.\" $NetBSD: inet6_rth_space.3,v 1.2 2014/01/04 15:37:46 wiz Exp $ -.\" $KAME: inet6_rth_space.3,v 1.7 2005/01/05 03:00:44 itojun Exp $ -.\" -.\" Copyright (C) 2004 WIDE Project. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the project 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 PROJECT 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 PROJECT OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd December 24, 2004 -.Dt INET6_RTH_SPACE 3 -.Os -.\" -.Sh NAME -.Nm inet6_rth_space , -.Nm inet6_rth_init , -.Nm inet6_rth_add , -.Nm inet6_rth_reverse , -.Nm inet6_rth_segments , -.Nm inet6_rth_getaddr -.Nd IPv6 Routing Header Options manipulation -.\" -.Sh SYNOPSIS -.In netinet/in.h -.Ft socklen_t -.Fn inet6_rth_space "int" "int" -.Ft "void *" -.Fn inet6_rth_init "void *" "socklen_t" "int" "int" -.Ft int -.Fn inet6_rth_add "void *" "const struct in6_addr *" -.Ft int -.Fn inet6_rth_reverse "const void *" "void *" -.Ft int -.Fn inet6_rth_segments "const void *" -.Ft "struct in6_addr *" -.Fn inet6_rth_getaddr "const void *" "int" -.\" -.Sh DESCRIPTION -The IPv6 Advanced API, RFC 3542, defines the functions that an -application calls to build and examine IPv6 Routing headers. -Routing headers are used to perform source routing in IPv6 networks. -The RFC uses the word -.Dq segments -to describe addresses and that is the term used here as well. -All of the functions are defined in the -.In netinet/in.h -header file. -The functions described in this manual page all operate -on routing header structures which are defined in -.In netinet/ip6.h -but which should not need to be modified outside the use of this API. -The size and shape of the route header structures may change, so using -the APIs is a more portable, long term, solution. -.Pp -The functions in the API are split into two groups, those that build a -routing header and those that parse a received routing header. -We will describe the builder functions followed by the parser functions. -.Ss inet6_rth_space -The -.Fn inet6_rth_space -function returns the number of bytes required to hold a Routing Header -of the type, specified in the -.Fa type -argument and containing the number of addresses specified in the -.Fa segments -argumment. -When the type is -.Dv IPV6_RTHDR_TYPE_0 -the number of segments must be from 0 through 127. -Routing headers of type -.Dv IPV6_RTHDR_TYPE_2 -contain only one segment, and are only used with Mobile IPv6. -The return value from this function is the number of bytes required to -store the routing header. -If the value 0 is returned then either the -route header type was not recognized or another error occurred. -.Ss inet6_rth_init -The -.Fn inet6_rth_init -function initializes the pre-allocated buffer pointed to by -.Fa bp -to contain a routing header of the specified type The -.Fa bp_len -argument is used to verify that the buffer is large enough. -The caller must allocate the buffer pointed to by bp. -The necessary buffer size should be determined by calling -.Fn inet6_rth_space -described in the previous sections. -.Pp -The -.Fn inet6_rth_init -function returns a pointer to -.Fa bp -on success and -.Dv NULL -when there is an error. -.Ss inet6_rth_add -The -.Fn inet6_rth_add -function adds the IPv6 address pointed to by -.Fa addr -to the end of the routing header being constructed. -.Pp -A successful addition results in the function returning 0, otherwise -\-1 is returned. -.Ss inet6_rth_reverse -The -.Fn inet6_rth_reverse -function takes a routing header, pointed to by the -argument -.Fa in , -and writes a new routing header into the argument pointed to by -.Fa out . -The routing header at that sends datagrams along the reverse of that -route. -Both arguments are allowed to point to the same buffer meaning -that the reversal can occur in place. -.Pp -The return value of the function is 0 on success, or \-1 when -there is an error. -.\" -.Pp -The next set of functions operate on a routing header that the -application wants to parse. -In the usual case such a routing header -is received from the network, although these functions can also be -used with routing headers that the application itself created. -.Ss inet6_rth_segments -The -.Fn inet6_rth_segments -function returns the number of segments contained in the -routing header pointed to by -.Fa bp . -The return value is the number of segments contained in the routing -header, or \-1 if an error occurred. -It is not an error for 0 to be -returned as a routing header may contain 0 segments. -.\" -.Ss inet6_rth_getaddr -The -.Fn inet6_rth_getaddr -function is used to retrieve a single address from a routing header. -The -.Fa index -is the location in the routing header from which the application wants -to retrieve an address. -The -.Fa index -parameter must have a value between 0 and one less than the number of -segments present in the routing header. -The -.Fn inet6_rth_segments -function, described in the last section, should be used to determine -the total number of segments in the routing header. -The -.Fn inet6_rth_getaddr -function returns a pointer to an IPv6 address on success or -.Dv NULL -when an error has occurred. -.\" -.Sh EXAMPLES -RFC 3542 gives extensive examples in Section 21, Appendix B. -.Pp -KAME also provides examples in the advapitest directory of its kit. -.\" -.Sh DIAGNOSTICS -The -.Fn inet6_rth_space -and -.Fn inet6_rth_getaddr -functions return 0 on errors. -.Pp -The -.Fn inet6_rthdr_init -function returns -.Dv NULL -on error. -The -.Fn inet6_rth_add -and -.Fn inet6_rth_reverse -functions return 0 on success, or \-1 upon an error. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%A E. Nordmark -.%A T. Jinmei -.%T "Advanced Sockets API for IPv6" -.%N RFC 3542 -.%D May 2003 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC2460 -.%D December 1998 -.Re -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. diff --git a/lib/libc/net/inet6_rthdr_space.3 b/lib/libc/net/inet6_rthdr_space.3 deleted file mode 100644 index 1d9a04396..000000000 --- a/lib/libc/net/inet6_rthdr_space.3 +++ /dev/null @@ -1,321 +0,0 @@ -.\" $NetBSD: inet6_rthdr_space.3,v 1.16 2010/03/22 19:30:54 joerg Exp $ -.\" $KAME: inet6_rthdr_space.3,v 1.8 2000/05/17 14:30:15 itojun Exp $ -.\" -.\" Copyright (c) 1983, 1987, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.Dd December 10, 1999 -.Dt INET6_RTHDR_SPACE 3 -.Os -.\" -.Sh NAME -.Nm inet6_rthdr_space , -.Nm inet6_rthdr_init , -.Nm inet6_rthdr_add , -.Nm inet6_rthdr_lasthop , -.Nm inet6_rthdr_reverse , -.Nm inet6_rthdr_segments , -.Nm inet6_rthdr_getaddr , -.Nm inet6_rthdr_getflags -.Nd IPv6 Routing Header Options manipulation -.\" -.Sh SYNOPSIS -.In netinet/in.h -.Ft size_t -.Fn inet6_rthdr_space "int type" "int segments" -.Ft "struct cmsghdr *" -.Fn inet6_rthdr_init "void *bp" "int type" -.Ft int -.Fn inet6_rthdr_add "struct cmsghdr *cmsg" "const struct in6_addr *addr" "unsigned int flags" -.Ft int -.Fn inet6_rthdr_lasthop "struct cmsghdr *cmsg" "unsigned int flags" -.Ft int -.Fn inet6_rthdr_reverse "const struct cmsghdr *in" "struct cmsghdr *out" -.Ft int -.Fn inet6_rthdr_segments "const struct cmsghdr *cmsg" -.Ft "struct in6_addr *" -.Fn inet6_rthdr_getaddr "struct cmsghdr *cmsg" "int index" -.Ft int -.Fn inet6_rthdr_getflags "const struct cmsghdr *cmsg" "int index" -.\" -.Sh DESCRIPTION -RFC 2292 IPv6 advanced API defines eight -functions that the application calls to build and examine a Routing -header. -Four functions build a Routing header: -.Bl -hang -.It Fn inet6_rthdr_space -return #bytes required for ancillary data -.It Fn inet6_rthdr_init -initialize ancillary data for Routing header -.It Fn inet6_rthdr_add -add IPv6 address \*[Am] flags to Routing header -.It Fn inet6_rthdr_lasthop -specify the flags for the final hop -.El -.Pp -Four functions deal with a returned Routing header: -.Bl -hang -.It Fn inet6_rthdr_reverse -reverse a Routing header -.It Fn inet6_rthdr_segments -return #segments in a Routing header -.It Fn inet6_rthdr_getaddr -fetch one address from a Routing header -.It Fn inet6_rthdr_getflags -fetch one flag from a Routing header -.El -.Pp -The function prototypes for these functions are all in the -.In netinet/in.h -header. -.\" -.Ss inet6_rthdr_space -This function returns the number of bytes required to hold a Routing -header of the specified -.Fa type -containing the specified number of -.Fa segments -.Pq addresses . -For an IPv6 Type 0 Routing header, the number -of segments must be between 1 and 23, inclusive. -The return value -includes the size of the cmsghdr structure that precedes the Routing -header, and any required padding. -.Pp -If the return value is 0, then either the type of the Routing header -is not supported by this implementation or the number of segments is -invalid for this type of Routing header. -.Pp -Note: This function returns the size but does not allocate the space -required for the ancillary data. -This allows an application to -allocate a larger buffer, if other ancillary data objects are -desired, since all the ancillary data objects must be specified to -.Xr sendmsg 2 -as a single -.Li msg_control -buffer. -.\" -.Ss inet6_rthdr_init -This function initializes the buffer pointed to by -.Fa bp -to contain a -.Li cmsghdr -structure followed by a Routing header of the specified -.Fa type . -The -.Li cmsg_len -member of the -.Li cmsghdr -structure is initialized to the -size of the structure plus the amount of space required by the -Routing header. -The -.Li cmsg_level -and -.Li cmsg_type -members are also initialized as required. -.Pp -The caller must allocate the buffer and its size can be determined by -calling -.Fn inet6_rthdr_space . -.Pp -Upon success the return value is the pointer to the -.Li cmsghdr -structure, and this is then used as the first argument to the next -two functions. -Upon an error the return value is -.Dv NULL . -.\" -.Ss inet6_rthdr_add -This function adds the address pointed to by -.Fa addr -to the end of the -Routing header being constructed and sets the type of this hop to the -value of -.Fa flags . -For an IPv6 Type 0 Routing header, -.Fa flags -must be -either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -If successful, the -.Li cmsg_len -member of the -.Li cmsghdr -structure is -updated to account for the new address in the Routing header and the -return value of the function is 0. -Upon an error the return value of -the function is -1. -.\" -.Ss inet6_rthdr_lasthop -This function specifies the Strict/Loose flag for the final hop of a -Routing header. -For an IPv6 Type 0 Routing header, -.Fa flags -must be either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -The return value of the function is 0 upon success, or -1 upon an error. -.Pp -Notice that a Routing header specifying -.Li N -intermediate nodes requires -.Li N+1 -Strict/Loose flags. -This requires -.Li N -calls to -.Fn inet6_rthdr_add -followed by one call to -.Fn inet6_rthdr_lasthop . -.\" -.Ss inet6_rthdr_reverse -This function takes a Routing header that was received as ancillary -data -.Po -pointed to by the first argument, -.Fa in -.Pc -and writes a new Routing -header that sends datagrams along the reverse of that route. -Both -arguments are allowed to point to the same buffer -.Pq that is, the reversal can occur in place . -.Pp -The return value of the function is 0 on success, or -1 upon an -error. -.\" -.Ss inet6_rthdr_segments -This function returns the number of segments -.Pq addresses -contained in -the Routing header described by -.Fa cmsg . -On success the return value is -between 1 and 23, inclusive. -The return value of the function is -1 upon an error. -.\" -.Ss inet6_rthdr_getaddr -This function returns a pointer to the IPv6 address specified by -.Fa index -.Po -which must have a value between 1 and the value returned by -.Fn inet6_rthdr_segments -.Pc -in the Routing header described by -.Fa cmsg . -An -application should first call -.Fn inet6_rthdr_segments -to obtain the number of segments in the Routing header. -.Pp -Upon an error the return value of the function is -.Dv NULL . -.\" -.Ss inet6_rthdr_getflags -This function returns the flags value specified by -.Fa index -.Po -which must -have a value between 0 and the value returned by -.Fn inet6_rthdr_segments -.Pc -in the Routing header described by -.Fa cmsg . -For an IPv6 Type 0 Routing header the return value will be either -.Dv IPV6_RTHDR_LOOSE -or -.Dv IPV6_RTHDR_STRICT . -.Pp -Upon an error the return value of the function is -1. -.Pp -Note: Addresses are indexed starting at 1, and flags starting at 0, -to maintain consistency with the terminology and figures in RFC 2460. -.\" -.Sh EXAMPLES -RFC 2292 gives comprehensive examples in chapter 8. -.\" -.Sh DIAGNOSTICS -.Fn inet6_rthdr_space -returns 0 on errors. -.Pp -.Fn inet6_rthdr_add , -.Fn inet6_rthdr_lasthop -and -.Fn inet6_rthdr_reverse -return 0 on success, and returns -1 on error. -.Pp -.Fn inet6_rthdr_init -and -.Fn inet6_rthdr_getaddr -return -.Dv NULL -on error. -.Pp -.Fn inet6_rthdr_segments -and -.Fn inet6_rthdr_getflags -return -1 on error. -.\" -.Sh SEE ALSO -.Rs -.%A W. Stevens -.%A M. Thomas -.%T "Advanced Sockets API for IPv6" -.%N RFC 2292 -.%D February 1998 -.Re -.Rs -.%A S. Deering -.%A R. Hinden -.%T "Internet Protocol, Version 6 (IPv6) Specification" -.%N RFC 2460 -.%D December 1998 -.Re -.\" -.Sh STANDARDS -The functions -are documented in -.Dq Advanced Sockets API for IPv6 -.Pq RFC 2292 . -.\" -.Sh HISTORY -The implementation first appeared in KAME advanced networking kit. -.\" -.Sh BUGS -The text was shamelessly copied from RFC 2292. -.Pp -.Fn inet6_rthdr_reverse -is not implemented yet. diff --git a/lib/libc/net/inet6_scopeid.c b/lib/libc/net/inet6_scopeid.c deleted file mode 100644 index 8369af0a4..000000000 --- a/lib/libc/net/inet6_scopeid.c +++ /dev/null @@ -1,79 +0,0 @@ -/*- - * Copyright (c) 2003 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the NetBSD - * Foundation, Inc. and its contributors. - * 4. Neither the name of The NetBSD Foundation nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -#include -__RCSID("$NetBSD: inet6_scopeid.c,v 1.2 2013/10/19 15:47:02 christos Exp $"); - -#include -#include -#include -#include -#include - -/* KAME idiosyncrasy */ -void -inet6_getscopeid(struct sockaddr_in6 *sin6, int flags) -{ -#if defined(__KAME__) - if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && - (flags & INET6_IS_ADDR_LINKLOCAL)) || - (IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) && - (flags & INET6_IS_ADDR_MC_LINKLOCAL)) || - (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) && - (flags & INET6_IS_ADDR_SITELOCAL))) { - uint16_t scope; - memcpy(&scope, &sin6->sin6_addr.s6_addr[2], sizeof(scope)); - sin6->sin6_scope_id = ntohs(scope); - sin6->sin6_addr.s6_addr[2] = sin6->sin6_addr.s6_addr[3] = 0; - } -#endif -} - -void -inet6_putscopeid(struct sockaddr_in6 *sin6, int flags) -{ -#if defined(__KAME__) - if ((IN6_IS_ADDR_LINKLOCAL(&sin6->sin6_addr) && - (flags & INET6_IS_ADDR_LINKLOCAL)) || - (IN6_IS_ADDR_MC_LINKLOCAL(&sin6->sin6_addr) && - (flags & INET6_IS_ADDR_MC_LINKLOCAL)) || - (IN6_IS_ADDR_SITELOCAL(&sin6->sin6_addr) && - (flags & INET6_IS_ADDR_SITELOCAL))) { - uint16_t scope = htons(sin6->sin6_scope_id); - memcpy(&sin6->sin6_addr.s6_addr[2], &scope, sizeof(scope)); - sin6->sin6_scope_id = 0; - } -#endif -} diff --git a/lib/libc/net/ip6opt.c b/lib/libc/net/ip6opt.c deleted file mode 100644 index 4e09f70a1..000000000 --- a/lib/libc/net/ip6opt.c +++ /dev/null @@ -1,657 +0,0 @@ -/* $NetBSD: ip6opt.c,v 1.15 2014/02/07 02:36:06 christos Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: ip6opt.c,v 1.15 2014/02/07 02:36:06 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(inet6_option_alloc,_inet6_option_alloc) -__weak_alias(inet6_option_append,_inet6_option_append) -__weak_alias(inet6_option_find,_inet6_option_find) -__weak_alias(inet6_option_init,_inet6_option_init) -__weak_alias(inet6_option_next,_inet6_option_next) -__weak_alias(inet6_option_space,_inet6_option_space) -__weak_alias(inet6_opt_init, _inet6_opt_init) -__weak_alias(inet6_opt_append, _inet6_opt_append) -__weak_alias(inet6_opt_finish, _inet6_opt_finish) -__weak_alias(inet6_opt_set_val, _inet6_opt_set_val) -__weak_alias(inet6_opt_next, _inet6_opt_next) -__weak_alias(inet6_opt_find, _inet6_opt_find) -__weak_alias(inet6_opt_get_val, _inet6_opt_get_val) -#endif - -static int ip6optlen(uint8_t *opt, uint8_t *lim); -static void inet6_insert_padopt(uint8_t *p, size_t len); - -/* - * This function returns the number of bytes required to hold an option - * when it is stored as ancillary data, including the cmsghdr structure - * at the beginning, and any padding at the end (to make its size a - * multiple of 8 bytes). The argument is the size of the structure - * defining the option, which must include any pad bytes at the - * beginning (the value y in the alignment term "xn + y"), the type - * byte, the length byte, and the option data. - */ -int -inet6_option_space(int nbytes) -{ - size_t sp; - nbytes += 2; /* we need space for nxt-hdr and length fields */ - sp = CMSG_SPACE((nbytes + 7) & ~7); - _DIAGASSERT(__type_fit(int, sp)); - return (int)sp; -} - -/* - * This function is called once per ancillary data object that will - * contain either Hop-by-Hop or Destination options. It returns 0 on - * success or -1 on an error. - */ -int -inet6_option_init(void *bp, struct cmsghdr **cmsgp, int type) -{ - register struct cmsghdr *ch; - - _DIAGASSERT(bp != NULL); - _DIAGASSERT(cmsgp != NULL); - - ch = (struct cmsghdr *)bp; - - /* argument validation */ - if (type != IPV6_HOPOPTS && type != IPV6_DSTOPTS) - return(-1); - - ch->cmsg_level = IPPROTO_IPV6; - ch->cmsg_type = type; - ch->cmsg_len = CMSG_LEN(0); - - *cmsgp = ch; - return(0); -} - -/* - * This function appends a Hop-by-Hop option or a Destination option - * into an ancillary data object that has been initialized by - * inet6_option_init(). This function returns 0 if it succeeds or -1 on - * an error. - * multx is the value x in the alignment term "xn + y" described - * earlier. It must have a value of 1, 2, 4, or 8. - * plusy is the value y in the alignment term "xn + y" described - * earlier. It must have a value between 0 and 7, inclusive. - */ -int -inet6_option_append(struct cmsghdr *cmsg, const uint8_t *typep, int multx, - int plusy) -{ - size_t padlen, optlen, off; - register uint8_t *bp; - struct ip6_ext *eh; - - _DIAGASSERT(cmsg != NULL); - _DIAGASSERT(typep != NULL); - - bp = (uint8_t *)(void *)cmsg + cmsg->cmsg_len; - eh = (struct ip6_ext *)(void *)CMSG_DATA(cmsg); - - /* argument validation */ - if (multx != 1 && multx != 2 && multx != 4 && multx != 8) - return(-1); - if (plusy < 0 || plusy > 7) - return(-1); - - /* - * If this is the first option, allocate space for the - * first 2 bytes(for next header and length fields) of - * the option header. - */ - if (bp == (uint8_t *)(void *)eh) { - bp += 2; - cmsg->cmsg_len += 2; - } - - /* calculate pad length before the option. */ - off = bp - (uint8_t *)(void *)eh; - padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) - - (off % multx); - padlen += plusy; - padlen %= multx; /* keep the pad as short as possible */ - /* insert padding */ - inet6_insert_padopt(bp, padlen); - _DIAGASSERT(__type_fit(socklen_t, padlen + cmsg->cmsg_len)); - cmsg->cmsg_len += (socklen_t)padlen; - bp += padlen; - - /* copy the option */ - if (typep[0] == IP6OPT_PAD1) - optlen = 1; - else - optlen = typep[1] + 2; - memcpy(bp, typep, (size_t)optlen); - bp += optlen; - _DIAGASSERT(__type_fit(socklen_t, optlen + cmsg->cmsg_len)); - cmsg->cmsg_len += (socklen_t)optlen; - - /* calculate pad length after the option and insert the padding */ - off = bp - (uint8_t *)(void *)eh; - padlen = ((off + 7) & ~7) - off; - inet6_insert_padopt(bp, padlen); - bp += padlen; - _DIAGASSERT(__type_fit(socklen_t, padlen + cmsg->cmsg_len)); - cmsg->cmsg_len += (socklen_t)padlen; - - /* update the length field of the ip6 option header */ - off = bp - (uint8_t *)(void *)eh; - _DIAGASSERT(__type_fit(uint8_t, (off >> 3) - 1)); - eh->ip6e_len = (uint8_t)((off >> 3) - 1); - - return(0); -} - -/* - * This function appends a Hop-by-Hop option or a Destination option - * into an ancillary data object that has been initialized by - * inet6_option_init(). This function returns a pointer to the 8-bit - * option type field that starts the option on success, or NULL on an - * error. - * The difference between this function and inet6_option_append() is - * that the latter copies the contents of a previously built option into - * the ancillary data object while the current function returns a - * pointer to the space in the data object where the option's TLV must - * then be built by the caller. - * - */ -uint8_t * -inet6_option_alloc(struct cmsghdr *cmsg, int datalen, int multx, int plusy) -{ - size_t padlen, off; - register uint8_t *bp; - uint8_t *retval; - struct ip6_ext *eh; - - _DIAGASSERT(cmsg != NULL); - - bp = (uint8_t *)(void *)cmsg + cmsg->cmsg_len; - eh = (struct ip6_ext *)(void *)CMSG_DATA(cmsg); - - /* argument validation */ - if (multx != 1 && multx != 2 && multx != 4 && multx != 8) - return(NULL); - if (plusy < 0 || plusy > 7) - return(NULL); - - /* - * If this is the first option, allocate space for the - * first 2 bytes(for next header and length fields) of - * the option header. - */ - if (bp == (uint8_t *)(void *)eh) { - bp += 2; - cmsg->cmsg_len += 2; - } - - /* calculate pad length before the option. */ - off = bp - (uint8_t *)(void *)eh; - padlen = (((off % multx) + (multx - 1)) & ~(multx - 1)) - - (off % multx); - padlen += plusy; - padlen %= multx; /* keep the pad as short as possible */ - /* insert padding */ - inet6_insert_padopt(bp, padlen); - cmsg->cmsg_len += (socklen_t)padlen; - bp += padlen; - - /* keep space to store specified length of data */ - retval = bp; - bp += datalen; - cmsg->cmsg_len += datalen; - - /* calculate pad length after the option and insert the padding */ - off = bp - (uint8_t *)(void *)eh; - padlen = ((off + 7) & ~7) - off; - inet6_insert_padopt(bp, padlen); - bp += padlen; - _DIAGASSERT(__type_fit(socklen_t, padlen + cmsg->cmsg_len)); - cmsg->cmsg_len += (socklen_t)padlen; - - /* update the length field of the ip6 option header */ - off = bp - (uint8_t *)(void *)eh; - _DIAGASSERT(__type_fit(uint8_t, (off >> 3) - 1)); - eh->ip6e_len = (uint8_t)((off >> 3) - 1); - - return(retval); -} - -/* - * This function processes the next Hop-by-Hop option or Destination - * option in an ancillary data object. If another option remains to be - * processed, the return value of the function is 0 and *tptrp points to - * the 8-bit option type field (which is followed by the 8-bit option - * data length, followed by the option data). If no more options remain - * to be processed, the return value is -1 and *tptrp is NULL. If an - * error occurs, the return value is -1 and *tptrp is not NULL. - * (RFC 2292, 6.3.5) - */ -int -inet6_option_next(const struct cmsghdr *cmsg, uint8_t **tptrp) -{ - struct ip6_ext *ip6e; - int hdrlen, optlen; - uint8_t *lim; - - _DIAGASSERT(cmsg != NULL); - _DIAGASSERT(tptrp != NULL); - - if (cmsg->cmsg_level != IPPROTO_IPV6 || - (cmsg->cmsg_type != IPV6_HOPOPTS && - cmsg->cmsg_type != IPV6_DSTOPTS)) - return(-1); - - /* message length validation */ - if (cmsg->cmsg_len < CMSG_SPACE(sizeof(struct ip6_ext))) - return(-1); - ip6e = __UNCONST(CCMSG_DATA(cmsg)); - hdrlen = (ip6e->ip6e_len + 1) << 3; - if (cmsg->cmsg_len < CMSG_SPACE(hdrlen)) - return(-1); - - /* - * If the caller does not specify the starting point, - * simply return the 1st option. - * Otherwise, search the option list for the next option. - */ - lim = (uint8_t *)(void *)ip6e + hdrlen; - if (*tptrp == NULL) - *tptrp = (uint8_t *)(void *)(ip6e + 1); - else { - if ((optlen = ip6optlen(*tptrp, lim)) == 0) - return(-1); - - *tptrp = *tptrp + optlen; - } - if (*tptrp >= lim) { /* there is no option */ - *tptrp = NULL; - return(-1); - } - /* - * Finally, checks if the next option is safely stored in the - * cmsg data. - */ - if (ip6optlen(*tptrp, lim) == 0) - return(-1); - else - return(0); -} - -/* - * This function is similar to the inet6_option_next() function, - * except this function lets the caller specify the option type to be - * searched for, instead of always returning the next option in the - * ancillary data object. - * Note: RFC 2292 says the type of tptrp is uint8_t *, but we think - * it's a typo. The variable should be type of uint8_t **. - */ -int -inet6_option_find(const struct cmsghdr *cmsg, uint8_t **tptrp, int type) -{ - struct ip6_ext *ip6e; - int hdrlen, optlen; - uint8_t *optp, *lim; - - _DIAGASSERT(cmsg != NULL); - _DIAGASSERT(tptrp != NULL); - - if (cmsg->cmsg_level != IPPROTO_IPV6 || - (cmsg->cmsg_type != IPV6_HOPOPTS && - cmsg->cmsg_type != IPV6_DSTOPTS)) - return(-1); - - /* message length validation */ - if (cmsg->cmsg_len < CMSG_SPACE(sizeof(struct ip6_ext))) - return(-1); - ip6e = __UNCONST(CCMSG_DATA(cmsg)); - hdrlen = (ip6e->ip6e_len + 1) << 3; - if (cmsg->cmsg_len < CMSG_SPACE(hdrlen)) - return(-1); - - /* - * If the caller does not specify the starting point, - * search from the beginning of the option list. - * Otherwise, search from *the next option* of the specified point. - */ - lim = (uint8_t *)(void *)ip6e + hdrlen; - if (*tptrp == NULL) - *tptrp = (uint8_t *)(void *)(ip6e + 1); - else { - if ((optlen = ip6optlen(*tptrp, lim)) == 0) - return(-1); - - *tptrp = *tptrp + optlen; - } - for (optp = *tptrp; optp < lim; optp += optlen) { - if (*optp == type) { - *tptrp = optp; - return(0); - } - if ((optlen = ip6optlen(optp, lim)) == 0) - return(-1); - } - - /* search failed */ - *tptrp = NULL; - return(-1); -} - -/* - * Calculate the length of a given IPv6 option. Also checks - * if the option is safely stored in user's buffer according to the - * calculated length and the limitation of the buffer. - */ -static int -ip6optlen(uint8_t *opt, uint8_t *lim) -{ - int optlen; - - _DIAGASSERT(opt != NULL); - _DIAGASSERT(lim != NULL); - - if (*opt == IP6OPT_PAD1) - optlen = 1; - else { - /* is there enough space to store type and len? */ - if (opt + 2 > lim) - return(0); - optlen = *(opt + 1) + 2; - } - if (opt + optlen <= lim) - return(optlen); - - return(0); -} - -static void -inet6_insert_padopt(uint8_t *p, size_t len) -{ - - _DIAGASSERT(p != NULL); - - switch(len) { - case 0: - return; - case 1: - p[0] = IP6OPT_PAD1; - return; - default: - p[0] = IP6OPT_PADN; - _DIAGASSERT(__type_fit(uint8_t, len - 2)); - p[1] = (uint8_t)(len - 2); - memset(&p[2], 0, len - 2); - return; - } -} - -/* - * The following functions are defined in RFC3542, which is a successor - * of RFC2292. - */ - -int -inet6_opt_init(void *extbuf, socklen_t extlen) -{ - struct ip6_ext *ext = (struct ip6_ext *)extbuf; - - if (ext) { - if (extlen == 0 || (extlen % 8)) - return (-1); - ext->ip6e_len = (extlen >> 3) - 1; - } - - return (2); /* sizeof the next and the length fields */ -} - -int -inet6_opt_append(void *extbuf, socklen_t extlen, int offset, uint8_t type, - socklen_t len, uint8_t align, void **databufp) -{ - int currentlen = offset; - size_t padlen = 0; - - /* - * The option type must have a value from 2 to 255, inclusive. - * (0 and 1 are reserved for the Pad1 and PadN options, respectively.) - */ - if (type < 2) - return (-1); - - /* - * The option data length must have a value between 0 and 255, - * inclusive, and is the length of the option data that follows. - */ - if (len > 255) - return (-1); - - /* - * The align parameter must have a value of 1, 2, 4, or 8. - * The align value can not exceed the value of len. - */ - if (align != 1 && align != 2 && align != 4 && align != 8) - return (-1); - if (align > len) - return (-1); - - /* Calculate the padding length. */ - currentlen += 2 + len; /* 2 means "type + len" */ - if (currentlen % align) - padlen = align - (currentlen % align); - - /* The option must fit in the extension header buffer. */ - _DIAGASSERT(__type_fit(int, currentlen + padlen)); - currentlen += (int)padlen; - if (extlen && /* XXX: right? */ - (socklen_t)currentlen > extlen) - return (-1); - - if (extbuf) { - uint8_t *optp = (uint8_t *)extbuf + offset; - - if (padlen == 1) { - /* insert a Pad1 option */ - *optp = IP6OPT_PAD1; - optp++; - } else if (padlen > 0) { - /* insert a PadN option for alignment */ - *optp++ = IP6OPT_PADN; - _DIAGASSERT(__type_fit(uint8_t, padlen - 2)); - *optp++ = (uint8_t)(padlen - 2); - memset(optp, 0, padlen - 2); - optp += (padlen - 2); - } - - *optp++ = type; - *optp++ = len; - - *databufp = optp; - } - - return (currentlen); -} - -int -inet6_opt_finish(void *extbuf, socklen_t extlen, int offset) -{ - int updatelen = offset > 0 ? (1 + ((offset - 1) | 7)) : 0; - - if (extbuf) { - uint8_t *padp; - size_t padlen = updatelen - offset; - - if ((socklen_t)updatelen > extlen || padlen >= 256 + 2) - return (-1); - - padp = (uint8_t *)extbuf + offset; - if (padlen == 1) - *padp = IP6OPT_PAD1; - else if (padlen > 0) { - *padp++ = IP6OPT_PADN; - *padp++ = (uint8_t)(padlen - 2); - memset(padp, 0, padlen - 2); - } - } - - return (updatelen); -} - -int -inet6_opt_set_val(void *databuf, int offset, void *val, socklen_t vallen) -{ - - memcpy((uint8_t *)databuf + offset, val, vallen); - return (offset + vallen); -} - -int -inet6_opt_next(void *extbuf, socklen_t extlen, int offset, uint8_t *typep, - socklen_t *lenp, void **databufp) -{ - uint8_t *optp, *lim; - int optlen; - - /* Validate extlen. XXX: is the variable really necessary?? */ - if (extlen == 0 || (extlen % 8)) - return (-1); - lim = (uint8_t *)extbuf + extlen; - - /* - * If this is the first time this function called for this options - * header, simply return the 1st option. - * Otherwise, search the option list for the next option. - */ - if (offset == 0) - optp = (uint8_t *)(void *)((struct ip6_hbh *)extbuf + 1); - else - optp = (uint8_t *)extbuf + offset; - - /* Find the next option skipping any padding options. */ - while (optp < lim) { - ptrdiff_t rv; - switch(*optp) { - case IP6OPT_PAD1: - optp++; - break; - case IP6OPT_PADN: - if ((optlen = ip6optlen(optp, lim)) == 0) - goto optend; - optp += optlen; - break; - default: /* found */ - if ((optlen = ip6optlen(optp, lim)) == 0) - goto optend; - *typep = *optp; - *lenp = optlen - 2; - *databufp = optp + 2; - rv = optp + optlen - (uint8_t *)extbuf; - _DIAGASSERT(__type_fit(int, rv)); - return (int)rv; - } - } - - optend: - *databufp = NULL; /* for safety */ - return (-1); -} - -int -inet6_opt_find(void *extbuf, socklen_t extlen, int offset, uint8_t type, - socklen_t *lenp, void **databufp) -{ - uint8_t *optp, *lim; - int optlen; - - /* Validate extlen. XXX: is the variable really necessary?? */ - if (extlen == 0 || (extlen % 8)) - return (-1); - lim = (uint8_t *)extbuf + extlen; - - /* - * If this is the first time this function called for this options - * header, simply return the 1st option. - * Otherwise, search the option list for the next option. - */ - if (offset == 0) - optp = (uint8_t *)(void *)((struct ip6_hbh *)extbuf + 1); - else - optp = (uint8_t *)extbuf + offset; - - /* Find the specified option */ - while (optp < lim) { - if ((optlen = ip6optlen(optp, lim)) == 0) - goto optend; - - if (*optp == type) { /* found */ - ptrdiff_t td; - *lenp = optlen - 2; - *databufp = optp + 2; - td = optp + optlen - (uint8_t *)extbuf; - _DIAGASSERT(__type_fit(int, td)); - return (int)td; - } - - optp += optlen; - } - - optend: - *databufp = NULL; /* for safety */ - return (-1); -} - -int -inet6_opt_get_val(void *databuf, int offset, void *val, socklen_t vallen) -{ - - /* we can't assume alignment here */ - memcpy(val, (uint8_t *)databuf + offset, vallen); - - return (offset + vallen); -} diff --git a/lib/libc/net/iso_addr.c b/lib/libc/net/iso_addr.c deleted file mode 100644 index 24ecbcd9e..000000000 --- a/lib/libc/net/iso_addr.c +++ /dev/null @@ -1,138 +0,0 @@ -/* $NetBSD: iso_addr.c,v 1.15 2013/03/01 18:25:16 joerg Exp $ */ - -/* - * Copyright (c) 1989, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)iso_addr.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: iso_addr.c,v 1.15 2013/03/01 18:25:16 joerg Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include - -#include -#include - -struct iso_addr { - uint8_t isoa_len; /* length (in bytes) */ - char isoa_genaddr[20]; /* general opaque address */ -}; - -__BEGIN_DECLS -struct iso_addr *iso_addr(const char *); -char *iso_ntoa(const struct iso_addr *); -__END_DECLS - -/* States*/ -#define VIRGIN 0 -#define GOTONE 1 -#define GOTTWO 2 -/* Inputs */ -#define DIGIT (4*0) -#define END (4*1) -#define DELIM (4*2) - -struct iso_addr * -iso_addr(const char *addr) -{ - static struct iso_addr out_addr; - register char *cp = out_addr.isoa_genaddr; - char *cplim = cp + sizeof(out_addr.isoa_genaddr); - register int byte = 0, state = VIRGIN; - register int newaddr = 0; /* pacify gcc */ - - _DIAGASSERT(addr != NULL); - - (void)memset(&out_addr, 0, sizeof (out_addr)); - do { - if ((*addr >= '0') && (*addr <= '9')) { - newaddr = *addr - '0'; - } else if ((*addr >= 'a') && (*addr <= 'f')) { - newaddr = *addr - 'a' + 10; - } else if ((*addr >= 'A') && (*addr <= 'F')) { - newaddr = *addr - 'A' + 10; - } else if (*addr == 0) - state |= END; - else - state |= DELIM; - addr++; - switch (state /* | INPUT */) { - case GOTTWO | DIGIT: - *cp++ = byte; /*FALLTHROUGH*/ - case VIRGIN | DIGIT: - state = GOTONE; byte = newaddr; continue; - case GOTONE | DIGIT: - state = GOTTWO; byte = newaddr + (byte << 4); continue; - default: /* | DELIM */ - state = VIRGIN; *cp++ = byte; byte = 0; continue; - case GOTONE | END: - case GOTTWO | END: - *cp++ = byte; /* FALLTHROUGH */ - case VIRGIN | END: - break; - } - break; - } while (cp < cplim); - _DIAGASSERT(__type_fit(uint8_t, cp - out_addr.isoa_genaddr)); - out_addr.isoa_len = (uint8_t)(cp - out_addr.isoa_genaddr); - return (&out_addr); -} - -static const char hexlist[16] = "0123456789abcdef"; - -char * -iso_ntoa(const struct iso_addr *isoa) -{ - static char obuf[64]; - char *out = obuf; - size_t i; - const u_char *in = (const u_char *)isoa->isoa_genaddr; - const u_char *inlim = in + isoa->isoa_len; - - _DIAGASSERT(isoa != NULL); - - out[1] = 0; - while (in < inlim) { - i = *in++; - *out++ = '.'; - if (i > 0xf) { - out[1] = hexlist[i & 0xf]; - i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; - } - *out = 0; - return(obuf + 1); -} diff --git a/lib/libc/net/linkaddr.3 b/lib/libc/net/linkaddr.3 deleted file mode 100644 index d0f590dff..000000000 --- a/lib/libc/net/linkaddr.3 +++ /dev/null @@ -1,134 +0,0 @@ -.\" $NetBSD: linkaddr.3,v 1.10 2003/08/07 16:43:11 agc Exp $ -.\" -.\" Copyright (c) 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Donn Seeley at BSDI. -.\" -.\" 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. -.\" -.\" @(#)linkaddr.3 8.1 (Berkeley) 7/28/93 -.\" -.Dd July 28, 1993 -.Dt LINK_ADDR 3 -.Os -.Sh NAME -.Nm link_addr , -.Nm link_ntoa -.Nd elementary address specification routines for link level access -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/types.h -.In sys/socket.h -.In net/if_dl.h -.Ft void -.Fn link_addr "const char *addr" "struct sockaddr_dl *sdl" -.Ft char * -.Fn link_ntoa "const struct sockaddr_dl *sdl" -.Sh DESCRIPTION -The routine -.Fn link_addr -interprets character strings representing link-level addresses, -returning binary information suitable for use in system calls. -The routine -.Fn link_ntoa -takes a link-level address and returns an -.Tn ASCII -string representing some of the information present, including the -link level address itself, and the interface name or number, if present. -This facility is experimental and is still subject to change. -.Pp -Prior to a call to -.Fn link_addr , -.Fa sdl-\*[Gt]sdl_len -must be initialized to the size of the link-level socket structure, -typically -.Fa sizeof(struct sockaddr_dl) . -.Pp -For -.Fn link_addr , -the string -.Fa addr -may contain -an optional network interface identifier of the form -.Dq "name unit-number" , -suitable for the first argument to -.Xr ifconfig 8 , -followed in all cases by a colon and -an interface address in the form of -groups of hexadecimal digits -separated by periods. -Each group represents a byte of address; -address bytes are filled left to right from -low order bytes through high order bytes. -.Pp -.\" A regular expression may make this format clearer: -.\" .Bd -literal -offset indent -.\" ([a-z]+[0-9]+:)?[0-9a-f]+(\e.[0-9a-f]+)* -.\" .Ed -.\" .Pp -Thus -.Li le0:8.0.9.13.d.30 -represents an ethernet address -to be transmitted on the first Lance ethernet interface. -.Sh RETURN VALUES -.Fn link_ntoa -always returns a null terminated string. -.Fn link_addr -has no return value (See -.Sx BUGS ) . -.Sh SEE ALSO -.Xr ethers 3 , -.Xr iso 4 -.Sh HISTORY -The -.Fn link_addr -and -.Fn link_ntoa -functions appeared in -.Bx 4.3 Reno . -.Sh BUGS -The returned values for -.Fn link_ntoa -reside in a static memory area. -.Pp -The function -.Fn link_addr -should diagnose improperly formed input, and there should be an unambiguous -way to recognize this. -.Pp -If the -.Va sdl_len -field of the link socket address -.Fa sdl -is 0, -.Fn link_ntoa -will not insert a colon before the interface address bytes. -If this translated address is given to -.Fn link_addr -without inserting an initial colon, -the latter will not interpret it correctly. diff --git a/lib/libc/net/linkaddr.c b/lib/libc/net/linkaddr.c deleted file mode 100644 index c807439d7..000000000 --- a/lib/libc/net/linkaddr.c +++ /dev/null @@ -1,171 +0,0 @@ -/* $NetBSD: linkaddr.c,v 1.16 2012/03/20 17:44:18 matt Exp $ */ - -/*- - * Copyright (c) 1990, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)linkaddr.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: linkaddr.c,v 1.16 2012/03/20 17:44:18 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include -#include - -#include -#include - -/* States*/ -#define NAMING 0 -#define GOTONE 1 -#define GOTTWO 2 -#define RESET 3 -/* Inputs */ -#define DIGIT (4*0) -#define END (4*1) -#define DELIM (4*2) -#define LETTER (4*3) - -void -link_addr(const char *addr, struct sockaddr_dl *sdl) -{ - register char *cp = sdl->sdl_data; - char *cplim = sdl->sdl_len + (char *)(void *)sdl; - int byte = 0, state = NAMING; - size_t newaddr = 0; /* pacify gcc */ - - _DIAGASSERT(addr != NULL); - _DIAGASSERT(sdl != NULL); - - (void)memset(&sdl->sdl_family, 0, (size_t)sdl->sdl_len - 1); - sdl->sdl_family = AF_LINK; - do { - state &= ~LETTER; - if ((*addr >= '0') && (*addr <= '9')) { - newaddr = *addr - '0'; - } else if ((*addr >= 'a') && (*addr <= 'f')) { - newaddr = *addr - 'a' + 10; - } else if ((*addr >= 'A') && (*addr <= 'F')) { - newaddr = *addr - 'A' + 10; - } else if (*addr == 0) { - state |= END; - } else if (state == NAMING && - (((*addr >= 'A') && (*addr <= 'Z')) || - ((*addr >= 'a') && (*addr <= 'z')))) - state |= LETTER; - else - state |= DELIM; - addr++; - switch (state /* | INPUT */) { - case NAMING | DIGIT: - case NAMING | LETTER: - *cp++ = addr[-1]; - continue; - case NAMING | DELIM: - state = RESET; - _DIAGASSERT(__type_fit(uint8_t, cp - sdl->sdl_data)); - sdl->sdl_nlen = (uint8_t)(cp - sdl->sdl_data); - continue; - case GOTTWO | DIGIT: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | DIGIT: - state = GOTONE; - byte = (int)newaddr; - continue; - case GOTONE | DIGIT: - state = GOTTWO; - byte = (int)newaddr + (byte << 4); - continue; - default: /* | DELIM */ - state = RESET; - *cp++ = byte; - byte = 0; - continue; - case GOTONE | END: - case GOTTWO | END: - *cp++ = byte; - /* FALLTHROUGH */ - case RESET | END: - break; - } - break; - } while (cp < cplim); - - _DIAGASSERT(__type_fit(uint8_t, cp - LLADDR(sdl))); - sdl->sdl_alen = (uint8_t)(cp - LLADDR(sdl)); - newaddr = cp - (char *)(void *)sdl; - if (newaddr > sizeof(*sdl)) { - _DIAGASSERT(__type_fit(uint8_t, newaddr)); - sdl->sdl_len = (uint8_t)newaddr; - } - return; -} - -static const char hexlist[16] = "0123456789abcdef"; - -char * -link_ntoa(const struct sockaddr_dl *sdl) -{ - static char obuf[64]; - register char *out = obuf; - register size_t i; - const u_char *in = (const u_char *)CLLADDR(sdl); - const u_char *inlim = in + sdl->sdl_alen; - int firsttime = 1; - - _DIAGASSERT(sdl != NULL); - - if (sdl->sdl_nlen) { - (void)memcpy(obuf, sdl->sdl_data, (size_t)sdl->sdl_nlen); - out += sdl->sdl_nlen; - if (sdl->sdl_alen) - *out++ = ':'; - } - while (in < inlim) { - if (firsttime) - firsttime = 0; - else - *out++ = '.'; - i = *in++; - if (i > 0xf) { - out[1] = hexlist[i & 0xf]; - i >>= 4; - out[0] = hexlist[i]; - out += 2; - } else - *out++ = hexlist[i]; - } - *out = 0; - return (obuf); -} diff --git a/lib/libc/net/nsdispatch.3 b/lib/libc/net/nsdispatch.3 deleted file mode 100644 index 8913b0ad6..000000000 --- a/lib/libc/net/nsdispatch.3 +++ /dev/null @@ -1,959 +0,0 @@ -.\" $NetBSD: nsdispatch.3,v 1.33 2015/01/04 21:38:58 wiz Exp $ -.\" -.\" Copyright (c) 1997, 1998, 1999, 2004, 2005, 2008 -.\" The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Luke Mewburn; and by Jason R. Thorpe. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd January 4, 2015 -.Dt NSDISPATCH 3 -.Os -.Sh NAME -.Nm nsdispatch -.Nd name-service switch dispatcher routine -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In nsswitch.h -.Ft int -.Fo nsdispatch -.Fa "void *nsdrv" -.Fa "const ns_dtab dtab[]" -.Fa "const char *database" -.Fa "const char *name" -.Fa "const ns_src defaults[]" -.Fa "..." -.Fc -.Sh DESCRIPTION -The -.Fn nsdispatch -function invokes the callback functions specified in -.Fa dtab -in the order given in -.Pa /etc/nsswitch.conf -for the database -.Fa database -until the action criteria for a source of that database is fulfilled. -.Pp -.Fa nsdrv -is passed to each callback function to use as necessary -(to pass back to the caller of -.Fn nsdispatch ) . -.Pp -.Fa dtab -is an array of -.Fa ns_dtab -structures, which have the following format: -.Bl -item -offset indent -.It -.Bd -literal -typedef struct { - const char *src; - nss_method cb; - void *cb_data; -} ns_dtab; -.Ed -.It -The -.Fa dtab -array should consist of one entry for each source type that has a -static implementation, -with -.Fa src -as the name of the source, -.Fa cb -as a callback function which handles that source, and -.Fa cb_data -as a pointer to arbitrary data to be passed to the callback function. -The last entry in -.Fa dtab -should contain -.Dv NULL -values for -.Fa src , -.Fa cb , -and -.Fa cb_data . -.It -The callback function signature is described by the typedef: -.Bd -ragged -offset indent -.Ft typedef int -.Fo \*(lp*nss_method\*(rp -.Fa "void *cbrv" -.Fa "void *cbdata" -.Fa "va_list ap" -.Fc ; -.Bl -tag -width cbdata -.It Fa cbrv -The -.Fa nsdrv -that -.Fn nsdispatch -was invoked with. -.It Fa cbdata -The -.Fa cb_data -member of the array entry for the source that this -callback function implements in the -.Fa dtab -argument of -.Fn nsdispatch . -.It Fa ap -The -.Fa ... -arguments to -.Fn nsdispatch , -converted to a -.Ft va_list . -.El -.Ed -.El -.Pp -.Fa database -and -.Fa name -are used to select methods from optional per-source -dynamically-loaded modules. -.Fa name -is usually the name of the function calling -.Fn nsdispatch . -Note that the callback functions provided by -.Fa dtab -take priority over those implemented in dynamically-loaded modules in the -event of a conflict. -.Pp -.Fa defaults -contains a list of default sources to try in the case of -a missing or corrupt -.Xr nsswitch.conf 5 , -or if there isn't a relevant entry for -.Fa database . -It is an array of -.Fa ns_src -structures, which have the following format: -.Bl -item -offset indent -.It -.Bd -literal -typedef struct { - const char *src; - uint32_t flags; -} ns_src; -.Ed -.It -The -.Fa defaults -array should consist of one entry for each source to consult by default -indicated by -.Fa src , -and -.Fa flags -set to the desired behavior -(usually -.Dv NS_SUCCESS ; -refer to -.Sx Callback function return values -for more information). -The last entry in -.Fa defaults -should have -.Fa src -set to -.Dv NULL -and -.Fa flags -set to 0. -.It -Some invokers of -.Fn nsdispatch -(such as -.Xr setgrent 3 ) -need to force all callback functions to be invoked, -irrespective of the action criteria listed in -.Xr nsswitch.conf 5 . -This can be achieved by adding -.Dv NS_FORCEALL -to -.Fa defaults[0].flags -before invoking -.Fn nsdispatch . -The return value of -.Fn nsdispatch -will be the result of the final callback function invoked. -.It -For convenience, a global variable defined as: -.Dl extern const ns_src __nsdefaultsrc[]; -exists which contains a single default entry for -.Sq files -for use by callers which don't require complicated default rules. -.El -.Pp -.Fa ... -are optional extra arguments, which -are passed to the appropriate callback function as a -.Xr stdarg 3 -variable argument -list of the type -.Fa va_list . -.Pp -.Nm -returns the value of the callback function that caused the dispatcher -to finish, or -.Dv NS_NOTFOUND -otherwise. -.\" -.Ss Dynamically-loaded module interface -The -.Fn nsdispatch -function loads callback functions from the run-time link-editor's search -path using the following naming convention: -.Bl -item -offset indent -.It -.Bd -literal -nss_\*[Lt]source\*[Gt].so.\*[Lt]version\*[Gt] -.Ed -.Bl -tag -width XversionX -.It Aq source -The source that the module implements. -.It Aq version -The -.Nm nsdispatch -module interface version, which is defined by the integer -.Dv NSS_MODULE_INTERFACE_VERSION , -which has the value 0. -.El -.El -.Pp -When a module is loaded, -.Fn nsdispatch -looks for and calls the following function in the module: -.Pp -.Bd -ragged -offset indent -.Ft ns_mtab * -.Fo nss_module_register -.Fa "const char *source" -.Fa "u_int *nelems" -.Fa "nss_module_unregister_fn *unreg" -.Fc ; -.Pp -.Bl -tag -width source -.It Fa source -The name of the source that the module implements, as used by -.Fn nsdispatch -to construct the module's name. -.It Fa nelems -A pointer to an unsigned integer that -.Fn nss_module_register -should set to the number of elements in the -.Ft ns_mtab -array returned by -.Fn nss_module_register , -or -.Dv 0 -if there was a failure. -.It Fa unreg -A pointer to a function pointer that -.Fn nss_module_register -can optionally set to an unregister function to be invoked when the module is -unloaded, or -.Dv NULL -if there isn't one. -.El -.Ed -.Pp -The unregister function signature is described by the typedef: -.Pp -.Bd -ragged -offset indent -.Ft typedef void -.Fo \*(lp*nss_module_unregister_fn\*(rp -.Fa "ns_mtab *mtab" -.Fa "u_int nelems" -.Fc ; -.Pp -.Bl -tag -width nelems -.It Fa mtab -The array of -.Ft ns_mtab -structures returned by -.Fn nss_module_register . -.It Fa nelems -The -.Fa *nelems -value set by -.Fn nss_module_register . -.El -.Ed -.Pp -.Fn nss_module_register -returns an array of -.Ft ns_mtab -structures -(with -.Fa *nelems -entries), or -.Dv NULL -if there was a failure. -The -.Ft ns_mtab -structures have the following format: -.Bl -item -offset indent -.It -.Bd -literal -typedef struct { - const char *database; - const char *name; - nss_method method; - void *mdata; -} ns_mtab; -.Ed -.It -The -.Fa mtab -array should consist of one entry for each callback function (method) -that is implemented, -with -.Fa database -as the name of the database, -.Fa name -as the name of the callback function, -.Fa method -as the -.Ft nss_method -callback function that implements the method, and -.Fa mdata -as a pointer to arbitrary data to be passed to the callback function as its -.Fa cbdata -argument. -.El -.\" -.Ss Valid source types -While there is support for arbitrary sources, the following -#defines for commonly implemented sources are provided: -.Bl -column NSSRC_COMPAT COMPAT -offset indent -.It Sy #define Value -.It NSSRC_FILES "files" -.It NSSRC_DNS "dns" -.It NSSRC_NIS "nis" -.It NSSRC_COMPAT "compat" -.El -.Pp -Refer to -.Xr nsswitch.conf 5 -for a complete description of what each source type is. -.\" -.Ss Valid database types -While there is support for arbitrary databases, the following -#defines for currently implemented system databases are provided: -.Bl -column NSDB_PASSWD_COMPAT PASSWD_COMPAT -offset indent -.It Sy #define Value -.It NSDB_HOSTS "hosts" -.It NSDB_GROUP "group" -.It NSDB_GROUP_COMPAT "group_compat" -.It NSDB_NETGROUP "netgroup" -.It NSDB_NETWORKS "networks" -.It NSDB_PASSWD "passwd" -.It NSDB_PASSWD_COMPAT "passwd_compat" -.It NSDB_SHELLS "shells" -.El -.Pp -Refer to -.Xr nsswitch.conf 5 -for a complete description of what each database is. -.\" -.Ss Callback function return values -The callback functions should return one of the following values -depending upon status of the lookup: -.Bl -column NS_NOTFOUND -offset indent -.It Sy "Return value" Status code -.It NS_SUCCESS The requested entry was found. -.It NS_NOTFOUND The entry is not present at this source. -.It NS_TRYAGAIN The source is busy, and may respond to retries. -.It NS_UNAVAIL The source is not responding, or entry is corrupt. -.El -.\" -.Sh CALLBACK FUNCTION API FOR STANDARD DATABASES -The organization of the -.Fa ap -argument for an -.Fn nss_method -callback function for a standard method in a standard database is: -.Bl -enum -offset indent -compact -.It -Pointer to return value of the standard function. -.It -First argument of the standard function. -.It -(etc.) -.El -.Pp -For example, given the standard function -.Xr getgrnam 3 : -.Bd -ragged -offset indent -compact -.Ft struct group * -.Fn getgrnam "const char *name" -.Ed -the -.Fa ap -organization used by the callback functions is: -.Bl -enum -offset indent -compact -.It -.Ft "struct group **" -.It -.Ft "const char *" -.El -.Pp -.Sy NOTE: -Not all standard databases are using this calling convention yet; -those that aren't are noted below. -These will be changed in the future. -.Pp -The callback function names and -.Ft va_list -organization for various standard database callback functions are: -.\" -.Ss Methods for hosts database -.Bl -tag -width 3n -.It Sy getaddrinfo -.Ft "char *name" , -.Ft "const struct addrinfo *pai" -.Pp -Returns -.Ft "struct addrinfo *" -via -.Ft "void *cbrv" . -.It Sy gethostbyaddr -.Ft "unsigned char *addr" , -.Ft "int addrlen" , -.Ft "int af" -.Pp -Returns -.Ft "struct getnamaddr *" -via -.Ft "void *cbrv" . -.It Sy gethostbyname -.Ft "char *name" , -.Ft "int namelen" , -.Ft "int af" -.Pp -Returns -.Ft "struct getnamaddr *" -via -.Ft "void *cbrv" . -.El -.Pp -The -.Ft "struct getnamaddr" -is defined internally in libc as: -.Bd -literal -struct getnamaddr { - struct hostent *hp; - char *buf; - size_t buflen; - int *he; -}; -.Ed -.\" -.Ss Methods for group and group_compat databases -.Bl -tag -width 3n -.It Sy endgrent -Empty -.Fa ap . -.Pp -All methods for all sources are invoked for this method name. -.It Sy getgrent -.Ft "struct group **retval" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct group" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getgrent 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.It Sy getgrent_r -.Ft "int *retval" , -.Ft "struct group *grp" , -.Ft "char *buffer" , -.Ft "size_t buflen" , -.Ft "struct group **result" -.Pp -.Fa *retval -should be set to an appropriate -.Xr errno 2 -on failure. -.Pp -.Xr getgrent_r 3 -returns 0 -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS -or -.Dv NS_NOTFOUND , -and -.Fa *retval -otherwise. -.It Sy getgrgid -.Ft "struct group **retval" , -.Ft "gid_t gid" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct group" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getgrgid 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.It Sy getgrgid_r -.Ft "int *retval" , -.Ft "gid_t gid" , -.Ft "struct group *grp" , -.Ft "char *buffer" , -.Ft "size_t buflen" , -.Ft "struct group **result" -.Pp -.Fa *retval -should be set to an appropriate -.Xr errno 2 -on failure. -.Pp -.Xr getgrgid_r 3 -returns 0 -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS -or -.Dv NS_NOTFOUND , -and -.Fa *retval -otherwise. -.It Sy getgrnam -.Ft "struct group **retval" , -.Ft "const char *name" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct group" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getgrnam 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.It Sy getgrnam_r -.Ft "int *retval" , -.Ft "const char *name" , -.Ft "struct group *grp" , -.Ft "char *buffer" , -.Ft "size_t buflen" , -.Ft "struct group **result" -.Pp -.Fa *retval -should be set to an appropriate -.Xr errno 2 -on failure. -.Pp -.Xr getgrnam_r 3 -returns 0 -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS -or -.Dv NS_NOTFOUND , -and -.Fa *retval -otherwise. -.It Sy getgroupmembership -.Ft "int *retval" , -.Ft "const char *name" , -.Ft "gid_t basegid" , -.Ft "gid_t *groups" , -.Ft "int maxgrp" , -.Ft "int *groupc" -.Pp -.Fa retval -is unused. -.Pp -Lookups for -.Sy group_compat -are also stopped if -.Dv NS_SUCCESS -was returned to prevent multiple -.Dq "+:" -compat entries from being expanded. -.Pp -.Xr getgroupmembership 3 -returns -is -1 if -.Fa *groupc -is greater than to -.Fa maxgrp , -and 0 otherwise. -.It Sy setgroupent -.Ft "int *retval" , -.Ft "int stayopen" -.Pp -.Fa retval -should be set to 0 on failure and 1 on success. -.Pp -All methods for all sources are invoked for this method name. -.It Sy setgrent -Empty -.Fa ap . -.Pp -All methods for all sources are invoked for this method name. -.El -.\" -.Ss Methods for netgroup database -.Sy NOTE: -The method APIs for this database will be changing in the near future. -.Bl -tag -width 3n -.It Sy endnetgrent -Empty -.Fa ap . -.It Sy lookup -.Ft "char *name" , -.Ft "char **line" , -.Ft "int bywhat" -.Pp -Find the given -.Fa name -and return its value in -.Fa line . -.Fa bywhat -is one of -.Dv _NG_KEYBYNAME , -.Dv _NG_KEYBYUSER , -or -.Dv _NG_KEYBYHOST . -.It Sy getnetgrent -.Ft "int *retval" , -.Ft "const char **host" , -.Ft "const char **user" , -.Ft "const char **domain" -.Pp -.Fa *retval -should be set to 0 for no more netgroup members and 1 otherwise. -.Pp -.Xr getnetgrent 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -0 otherwise. -.It Sy innetgr -.Ft "int *retval" , -.Ft "const char *grp" , -.Ft "const char *host" , -.Ft "const char *user" , -.Ft "const char *domain" -.Pp -.Fa *retval -should be set to 1 for a successful match and 0 otherwise. -.It Sy setnetgrent -.Ft "const char *netgroup" -.El -.\" -.Ss Methods for networks database -.Bl -tag -width 3n -.It Sy getnetbyaddr -.Ft "struct netent **retval" , -.Ft "uint32_t net" , -.Ft "int type" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct netent" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getnetbyaddr 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.It Sy getnetbyname -.Ft "struct netent **retval" , -.Ft "const char *name" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct netent" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getnetbyname 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.El -.\" -.Ss Methods for passwd and passwd_compat databases -.Bl -tag -width 3n -.It Sy endpwent -Empty -.Fa ap . -.Pp -All methods for all sources are invoked for this method name. -.It Sy getpwent -.Ft "struct passwd **retval" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct passwd" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getpwent 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.It Sy getpwent_r -.Ft "int *retval" , -.Ft "struct passwd *pw" , -.Ft "char *buffer" , -.Ft "size_t buflen" , -.Ft "struct passwd **result" -.Pp -.Fa *retval -should be set to an appropriate -.Xr errno 2 -on failure. -.Pp -.Xr getpwent_r 3 -returns 0 -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS -or -.Dv NS_NOTFOUND , -and -.Fa *retval -otherwise. -.It Sy getpwnam -.Ft "struct passwd **retval" , -.Ft "const char *name" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct passwd" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getpwnam 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.It Sy getpwnam_r -.Ft "int *retval" , -.Ft "const char *name" , -.Ft "struct passwd *pw" , -.Ft "char *buffer" , -.Ft "size_t buflen" , -.Ft "struct passwd **result" -.Pp -.Fa *retval -should be set to an appropriate -.Xr errno 2 -on failure. -.Pp -.Xr getpwnam_r 3 -returns 0 -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS -or -.Dv NS_NOTFOUND , -and -.Fa *retval -otherwise. -.It Sy getpwuid -.Ft "struct passwd **retval" , -.Ft "uid_t uid" -.Pp -.Fa *retval -should be set to a pointer to an internal static -.Ft "struct passwd" -on success, -.Dv NULL -otherwise. -.Pp -.Xr getpwuid 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -.Dv NULL -otherwise. -.It Sy getpwuid_r -.Ft "int *retval" , -.Ft "uid_t uid" , -.Ft "struct passwd *pw" , -.Ft "char *buffer" , -.Ft "size_t buflen" , -.Ft "struct passwd **result" -.Pp -.Fa *retval -should be set to an appropriate -.Xr errno 2 -on failure. -.Pp -.Xr getpwuid_r 3 -returns 0 -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS -or -.Dv NS_NOTFOUND , -and -.Fa *retval -otherwise. -.It Sy setpassent -.Ft "int *retval" , -.Ft "int stayopen" -.Pp -.Fa retval -should be set to 0 on failure and 1 on success. -.Pp -All methods for all sources are invoked for this method name. -.It Sy setpwent -Empty -.Fa ap . -.Pp -All methods for all sources are invoked for this method name. -.El -.\" -.Ss Methods for shells database -.Bl -tag -width 3n -.It Sy endusershell -Empty -.Fa ap . -.Pp -All methods for all sources are invoked for this method name. -.It Sy getusershell -.Ft "char **retval" -.Pp -.Xr getusershell 3 -returns -.Fa *retval -if -.Fn nsdispatch -returns -.Dv NS_SUCCESS , -and 0 otherwise. -.It Sy setusershell -Empty -.Fa ap . -.Pp -All methods for all sources are invoked for this method name. -.El -.\" -.Sh SEE ALSO -.Xr ld.elf_so 1 , -.Xr hesiod 3 , -.Xr stdarg 3 , -.Xr ypclnt 3 , -.Xr nsswitch.conf 5 -.Sh HISTORY -The -.Nm -routines first appeared in -.Nx 1.4 . -Support for dynamically-loaded modules first appeared in -.Nx 3.0 . -.Sh AUTHORS -.An Luke Mewburn -.Aq Mt lukem@NetBSD.org -wrote this freely distributable name-service switch implementation, -using ideas from the -.Tn ULTRIX -.Xr svc.conf 5 -and -.Tn Solaris -.Xr nsswitch.conf 4 -manual pages. -Support for dynamically-loaded modules was added by -.An Jason Thorpe -.Aq Mt thorpej@NetBSD.org , -based on code developed by the -.Fx -Project. diff --git a/lib/libc/net/nsdispatch.c b/lib/libc/net/nsdispatch.c deleted file mode 100644 index 738f52b1a..000000000 --- a/lib/libc/net/nsdispatch.c +++ /dev/null @@ -1,692 +0,0 @@ -/* $NetBSD: nsdispatch.c,v 1.38 2014/09/18 13:58:20 christos Exp $ */ - -/*- - * Copyright (c) 1997, 1998, 1999, 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn; and by Jason R. Thorpe. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -/*- - * Copyright (c) 2003 Networks Associates Technology, Inc. - * All rights reserved. - * - * Portions of this software were developed for the FreeBSD Project by - * Jacques A. Vidrine, Safeport Network Services, and Network - * Associates Laboratories, the Security Research Division of Network - * Associates, Inc. under DARPA/SPAWAR contract N66001-01-C-8035 - * ("CBOSS"), as part of the DARPA CHATS research program. - * - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nsdispatch.c,v 1.38 2014/09/18 13:58:20 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#include -#include -#include - -#include -#ifdef __ELF__ -#include -#endif /* __ELF__ */ -#include -#include -#define _NS_PRIVATE -#include -#include -#include -#include -#include -#include - -#include "reentrant.h" - -extern FILE *_nsyyin; -extern int _nsyyparse(void); - - -#ifdef __weak_alias -__weak_alias(nsdispatch,_nsdispatch) -#endif - - -/* - * default sourcelist: `files' - */ -const ns_src __nsdefaultsrc[] = { - { NSSRC_FILES, NS_SUCCESS }, - { 0, 0 }, -}; - -const ns_src __nsdefaultcompat[] = { - { NSSRC_COMPAT, NS_SUCCESS }, - { 0, 0 } -}; - -const ns_src __nsdefaultcompat_forceall[] = { - { NSSRC_COMPAT, NS_SUCCESS | NS_FORCEALL }, - { 0, 0 } -}; - -const ns_src __nsdefaultfiles[] = { - { NSSRC_FILES, NS_SUCCESS }, - { 0, 0 }, -}; - -const ns_src __nsdefaultfiles_forceall[] = { - { NSSRC_FILES, NS_SUCCESS | NS_FORCEALL }, - { 0, 0 }, -}; - -const ns_src __nsdefaultnis[] = { - { NSSRC_NIS, NS_SUCCESS }, - { 0, 0 } -}; - -const ns_src __nsdefaultnis_forceall[] = { - { NSSRC_NIS, NS_SUCCESS | NS_FORCEALL }, - { 0, 0 } -}; - - -/* Database, source mappings. */ -static u_int _nsmapsize; -static ns_dbt *_nsmap; - -/* Nsswitch modules. */ -static u_int _nsmodsize; -static ns_mod *_nsmod; - -/* Placeholder for built-in modules' dlopen() handles. */ -static void *_nsbuiltin = &_nsbuiltin; - -#ifdef _REENTRANT -/* - * Global nsswitch data structures are mostly read-only, but we update them - * when we read or re-read nsswitch.conf. - */ -static rwlock_t _nslock = RWLOCK_INITIALIZER; - -/* - * List of threads currently in nsdispatch(). We use this to detect - * recursive calls and avoid reloading configuration in such cases, - * which could cause deadlock. - */ -struct _ns_drec { - LIST_ENTRY(_ns_drec) list; - thr_t thr; -}; -static LIST_HEAD(, _ns_drec) _ns_drec = LIST_HEAD_INITIALIZER(&_ns_drec); -static mutex_t _ns_drec_lock = MUTEX_INITIALIZER; -#endif /* _REENTRANT */ - - -/* - * Runtime determination of whether we are dynamically linked or not. - */ -#ifndef __ELF__ -#define is_dynamic() (0) /* don't bother - switch to ELF! */ -#else -__weakref_visible int rtld_DYNAMIC __weak_reference(_DYNAMIC); -#define is_dynamic() (&rtld_DYNAMIC != NULL) -#endif - - -/* - * size of dynamic array chunk for _nsmap and _nsmap[x].srclist (and other - * growing arrays). - */ -#define NSELEMSPERCHUNK 8 - -/* - * Dynamically growable arrays are used for lists of databases, sources, - * and modules. The following "vector" API is used to isolate the - * common operations. - */ -typedef void (*_nsvect_free_elem)(void *); - -static void * -_nsvect_append(const void *elem, void *vec, u_int *count, size_t esize) -{ - void *p; - - if ((*count % NSELEMSPERCHUNK) == 0) { - p = realloc(vec, (*count + NSELEMSPERCHUNK) * esize); - if (p == NULL) - return (NULL); - vec = p; - } - memmove((void *)(((uintptr_t)vec) + (*count * esize)), elem, esize); - (*count)++; - return (vec); -} - -static void * -_nsvect_elem(u_int i, void *vec, u_int count, size_t esize) -{ - - if (i < count) - return ((void *)((uintptr_t)vec + (i * esize))); - else - return (NULL); -} - -static void -_nsvect_free(void *vec, u_int *count, size_t esize, _nsvect_free_elem free_elem) -{ - void *elem; - u_int i; - - for (i = 0; i < *count; i++) { - elem = _nsvect_elem(i, vec, *count, esize); - if (elem != NULL) - (*free_elem)(elem); - } - if (vec != NULL) - free(vec); - *count = 0; -} -#define _NSVECT_FREE(v, c, s, f) \ -do { \ - _nsvect_free((v), (c), (s), (f)); \ - (v) = NULL; \ -} while (/*CONSTCOND*/0) - -static int -_nsdbtcmp(const void *a, const void *b) -{ - - return (strcasecmp(((const ns_dbt *)a)->name, - ((const ns_dbt *)b)->name)); -} - -static int -_nsmodcmp(const void *a, const void *b) -{ - - return (strcasecmp(((const ns_mod *)a)->name, - ((const ns_mod *)b)->name)); -} - -static int -_nsmtabcmp(const void *a, const void *b) -{ - int cmp; - - cmp = strcmp(((const ns_mtab *)a)->name, - ((const ns_mtab *)b)->name); - if (cmp) - return (cmp); - - return (strcasecmp(((const ns_mtab *)a)->database, - ((const ns_mtab *)b)->database)); -} - -static void -_nsmodfree(ns_mod *mod) -{ - - free(__UNCONST(mod->name)); - if (mod->handle == NULL) - return; - if (mod->unregister != NULL) - (*mod->unregister)(mod->mtab, mod->mtabsize); -#ifdef __ELF__ - if (mod->handle != _nsbuiltin) - (void) dlclose(mod->handle); -#endif /* __ELF__ */ -} - -/* - * Load a built-in or dyanamically linked module. If the `reg_fn' - * argument is non-NULL, assume a built-in module and use `reg_fn' - * to register it. Otherwise, search for a dynamic nsswitch module. - */ -static int -_nsloadmod(const char *source, nss_module_register_fn reg_fn) -{ -#ifdef __ELF__ - char buf[PATH_MAX]; -#endif - ns_mod mod, *new; - - memset(&mod, 0, sizeof(mod)); - mod.name = strdup(source); - if (mod.name == NULL) - return (-1); - - if (reg_fn != NULL) { - /* - * The placeholder is required, as a NULL handle - * represents an invalid module. - */ - mod.handle = _nsbuiltin; - } else if (!is_dynamic()) { - goto out; - } else { -#ifdef __ELF__ - if (snprintf(buf, sizeof(buf), "nss_%s.so.%d", mod.name, - NSS_MODULE_INTERFACE_VERSION) >= (int)sizeof(buf)) - goto out; - mod.handle = dlopen(buf, RTLD_LOCAL | RTLD_LAZY); - if (mod.handle == NULL) { -#ifdef _NSS_DEBUG - /* - * This gets pretty annoying, since the built-in - * sources are not yet modules. - */ - /* XXX log some error? */ -#endif - goto out; - } - reg_fn = (nss_module_register_fn) dlsym(mod.handle, - "nss_module_register"); - if (reg_fn == NULL) { - (void) dlclose(mod.handle); - mod.handle = NULL; - /* XXX log some error? */ - goto out; - } -#else /* ! __ELF__ */ - mod.handle = NULL; -#endif /* __ELF__ */ - } - mod.mtab = (*reg_fn)(mod.name, &mod.mtabsize, &mod.unregister); - if (mod.mtab == NULL || mod.mtabsize == 0) { -#ifdef __ELF__ - if (mod.handle != _nsbuiltin) - (void) dlclose(mod.handle); -#endif /* __ELF__ */ - mod.handle = NULL; - /* XXX log some error? */ - goto out; - } - if (mod.mtabsize > 1) - qsort(mod.mtab, mod.mtabsize, sizeof(mod.mtab[0]), - _nsmtabcmp); - out: - new = _nsvect_append(&mod, _nsmod, &_nsmodsize, sizeof(*_nsmod)); - if (new == NULL) { - _nsmodfree(&mod); - return (-1); - } - _nsmod = new; - /* _nsmodsize already incremented */ - - qsort(_nsmod, _nsmodsize, sizeof(*_nsmod), _nsmodcmp); - return (0); -} - -static void -_nsloadbuiltin(void) -{ - - /* Do nothing, for now. */ -} - -int -_nsdbtaddsrc(ns_dbt *dbt, const ns_src *src) -{ - void *new; - const ns_mod *mod; - ns_mod modkey; - - _DIAGASSERT(dbt != NULL); - _DIAGASSERT(src != NULL); - - new = _nsvect_append(src, dbt->srclist, &dbt->srclistsize, - sizeof(*src)); - if (new == NULL) - return (-1); - dbt->srclist = new; - /* dbt->srclistsize already incremented */ - - modkey.name = src->name; - mod = bsearch(&modkey, _nsmod, _nsmodsize, sizeof(*_nsmod), _nsmodcmp); - if (mod == NULL) - return (_nsloadmod(src->name, NULL)); - - return (0); -} - -void -_nsdbtdump(const ns_dbt *dbt) -{ - unsigned int i; - - _DIAGASSERT(dbt != NULL); - - printf("%s (%d source%s):", dbt->name, dbt->srclistsize, - dbt->srclistsize == 1 ? "" : "s"); - for (i = 0; i < dbt->srclistsize; i++) { - printf(" %s", dbt->srclist[i].name); - if (!(dbt->srclist[i].flags & - (NS_UNAVAIL|NS_NOTFOUND|NS_TRYAGAIN)) && - (dbt->srclist[i].flags & NS_SUCCESS)) - continue; - printf(" ["); - if (!(dbt->srclist[i].flags & NS_SUCCESS)) - printf(" SUCCESS=continue"); - if (dbt->srclist[i].flags & NS_UNAVAIL) - printf(" UNAVAIL=return"); - if (dbt->srclist[i].flags & NS_NOTFOUND) - printf(" NOTFOUND=return"); - if (dbt->srclist[i].flags & NS_TRYAGAIN) - printf(" TRYAGAIN=return"); - printf(" ]"); - } - printf("\n"); -} - -static void -_nssrclist_free(ns_src **src, u_int srclistsize) -{ - u_int i; - - for (i = 0; i < srclistsize; i++) { - if ((*src)[i].name != NULL) - free(__UNCONST((*src)[i].name)); - } - free(*src); - *src = NULL; -} - -static void -_nsdbtfree(ns_dbt *dbt) -{ - - _nssrclist_free(&dbt->srclist, dbt->srclistsize); - if (dbt->name != NULL) - free(__UNCONST(dbt->name)); -} - -int -_nsdbtput(const ns_dbt *dbt) -{ - ns_dbt *p; - void *new; - u_int i; - - _DIAGASSERT(dbt != NULL); - - for (i = 0; i < _nsmapsize; i++) { - p = _nsvect_elem(i, _nsmap, _nsmapsize, sizeof(*_nsmap)); - if (strcasecmp(dbt->name, p->name) == 0) { - /* overwrite existing entry */ - if (p->srclist != NULL) - _nssrclist_free(&p->srclist, p->srclistsize); - memmove(p, dbt, sizeof(*dbt)); - return (0); - } - } - new = _nsvect_append(dbt, _nsmap, &_nsmapsize, sizeof(*_nsmap)); - if (new == NULL) - return (-1); - _nsmap = new; - /* _nsmapsize already incremented */ - - return (0); -} - -/* - * This function is called each time nsdispatch() is called. If this - * is the first call, or if the configuration has changed, (re-)prepare - * the global data used by NSS. - */ -static int -_nsconfigure(void) -{ -#ifdef _REENTRANT - static mutex_t _nsconflock = MUTEX_INITIALIZER; -#endif - static time_t _nsconfmod; - struct stat statbuf; - - mutex_lock(&_nsconflock); - - if (stat(_PATH_NS_CONF, &statbuf) == -1) { - /* - * No nsswitch.conf; just use whatever configuration we - * currently have, or fall back on the defaults specified - * by the caller. - */ - mutex_unlock(&_nsconflock); - return (0); - } - - if (statbuf.st_mtime <= _nsconfmod) { - /* Internal state is up-to-date with nsswitch.conf. */ - mutex_unlock(&_nsconflock); - return (0); - } - - /* - * Ok, we've decided we need to update the nsswitch configuration - * structures. Acquire a write-lock on _nslock while continuing - * to hold _nsconflock. Acquiring a write-lock blocks while - * waiting for other threads already holding a read-lock to clear. - * We hold _nsconflock for the duration, and update the time stamp - * at the end of the update operation, at which time we release - * both locks. - */ - rwlock_wrlock(&_nslock); - - _nsyyin = fopen(_PATH_NS_CONF, "re"); - if (_nsyyin == NULL) { - /* - * Unable to open nsswitch.conf; behave as though the - * stat() above failed. Even though we have already - * updated _nsconfmod, if the file reappears, the - * mtime will change. - */ - goto out; - } - - _NSVECT_FREE(_nsmap, &_nsmapsize, sizeof(*_nsmap), - (_nsvect_free_elem) _nsdbtfree); - _NSVECT_FREE(_nsmod, &_nsmodsize, sizeof(*_nsmod), - (_nsvect_free_elem) _nsmodfree); - - _nsloadbuiltin(); - - _nsyyparse(); - (void) fclose(_nsyyin); - if (_nsmapsize != 0) - qsort(_nsmap, _nsmapsize, sizeof(*_nsmap), _nsdbtcmp); - - _nsconfmod = statbuf.st_mtime; - - out: - rwlock_unlock(&_nslock); - mutex_unlock(&_nsconflock); - return (0); -} - -static nss_method -_nsmethod(const char *source, const char *database, const char *method, - const ns_dtab disp_tab[], void **cb_data) -{ - int curdisp; - ns_mod *mod, modkey; - ns_mtab *mtab, mtabkey; - - if (disp_tab != NULL) { - for (curdisp = 0; disp_tab[curdisp].src != NULL; curdisp++) { - if (strcasecmp(source, disp_tab[curdisp].src) == 0) { - *cb_data = disp_tab[curdisp].cb_data; - return (disp_tab[curdisp].callback); - } - } - } - - modkey.name = source; - mod = bsearch(&modkey, _nsmod, _nsmodsize, sizeof(*_nsmod), - _nsmodcmp); - if (mod != NULL && mod->handle != NULL) { - mtabkey.database = database; - mtabkey.name = method; - mtab = bsearch(&mtabkey, mod->mtab, mod->mtabsize, - sizeof(mod->mtab[0]), _nsmtabcmp); - if (mtab != NULL) { - *cb_data = mtab->mdata; - return (mtab->method); - } - } - - *cb_data = NULL; - return (NULL); -} - -int -/*ARGSUSED*/ -nsdispatch(void *retval, const ns_dtab disp_tab[], const char *database, - const char *method, const ns_src defaults[], ...) -{ - static int _nsdispatching; -#ifdef _REENTRANT - struct _ns_drec drec, *ldrec; -#endif - va_list ap; - int i, result; - ns_dbt key; - const ns_dbt *dbt; - const ns_src *srclist; - int srclistsize; - nss_method cb; - void *cb_data; - - /* retval may be NULL */ - /* disp_tab may be NULL */ - _DIAGASSERT(database != NULL); - _DIAGASSERT(method != NULL); - _DIAGASSERT(defaults != NULL); - if (database == NULL || method == NULL || defaults == NULL) - return (NS_UNAVAIL); - - /* - * In both the threaded and non-threaded cases, avoid reloading - * the configuration if the current thread is already running - * nsdispatch() (i.e. recursive call). - * - * In the non-threaded case, this avoids changing the data structures - * while we're using them. - * - * In the threaded case, this avoids trying to take a write lock - * while the current thread holds a read lock (which would result - * in deadlock). - */ -#ifdef _REENTRANT - if (__isthreaded) { - drec.thr = thr_self(); - mutex_lock(&_ns_drec_lock); - LIST_FOREACH(ldrec, &_ns_drec, list) { - if (ldrec->thr == drec.thr) - break; - } - LIST_INSERT_HEAD(&_ns_drec, &drec, list); - mutex_unlock(&_ns_drec_lock); - if (ldrec == NULL && _nsconfigure()) { - mutex_lock(&_ns_drec_lock); - LIST_REMOVE(&drec, list); - mutex_unlock(&_ns_drec_lock); - return (NS_UNAVAIL); - } - } else -#endif /* _REENTRANT */ - if (_nsdispatching++ == 0 && _nsconfigure()) { - _nsdispatching--; - return (NS_UNAVAIL); - } - - rwlock_rdlock(&_nslock); - - key.name = database; - dbt = bsearch(&key, _nsmap, _nsmapsize, sizeof(*_nsmap), _nsdbtcmp); - if (dbt != NULL) { - srclist = dbt->srclist; - srclistsize = dbt->srclistsize; - } else { - srclist = defaults; - srclistsize = 0; - while (srclist[srclistsize].name != NULL) - srclistsize++; - } - result = 0; - - for (i = 0; i < srclistsize; i++) { - cb = _nsmethod(srclist[i].name, database, method, - disp_tab, &cb_data); - result = 0; - if (cb != NULL) { - va_start(ap, defaults); - result = (*cb)(retval, cb_data, ap); - va_end(ap); - if (defaults[0].flags & NS_FORCEALL) - continue; - if (result & srclist[i].flags) - break; - } - } - result &= NS_STATUSMASK; /* clear private flags in result */ - - rwlock_unlock(&_nslock); - -#ifdef _REENTRANT - if (__isthreaded) { - mutex_lock(&_ns_drec_lock); - LIST_REMOVE(&drec, list); - mutex_unlock(&_ns_drec_lock); - } else -#endif /* _REENTRANT */ - _nsdispatching--; - - return (result ? result : NS_NOTFOUND); -} diff --git a/lib/libc/net/nslexer.l b/lib/libc/net/nslexer.l deleted file mode 100644 index 4c15aef7a..000000000 --- a/lib/libc/net/nslexer.l +++ /dev/null @@ -1,108 +0,0 @@ -%{ -/* $NetBSD: nslexer.l,v 1.13 2012/06/25 22:32:45 abs Exp $ */ - -/*- - * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nslexer.l,v 1.13 2012/06/25 22:32:45 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#define _NS_PRIVATE -#include -#include -#include - -#include "nsparser.h" - -%} - -%option yylineno nounput noinput -%option never-interactive - -BLANK [ \t] -CR \n -STRING [a-zA-Z][a-zA-Z0-9_]* - -%% - -{BLANK}+ ; /* skip whitespace */ - -#.* ; /* skip comments */ - -\\{CR} ; /* allow continuation */ - -{CR} return NL; - -[sS][uU][cC][cC][eE][sS][sS] return SUCCESS; -[uU][nN][aA][vV][aA][iI][lL] return UNAVAIL; -[nN][oO][tT][fF][oO][uU][nN][dD] return NOTFOUND; -[tT][rR][yY][aA][gG][aA][iI][nN] return TRYAGAIN; - -[rR][eE][tT][uU][rR][nN] return RETURN; -[cC][oO][nN][tT][iI][nN][uU][eE] return CONTINUE; - -{STRING} { - char *p; - size_t i; - - if ((p = strdup(yytext)) == NULL) { - syslog(LOG_ERR, "libc nsdispatch: %m"); - return NL; - } - - for (i = 0; i < strlen(p); i++) { - if (isupper((unsigned char)p[i])) - p[i] = tolower((unsigned char)p[i]); - } - _nsyylval.str = p; - return STRING; - } - -. return yytext[0]; - -%% - -#undef _nsyywrap -int -_nsyywrap(void) -{ - return 1; -} /* _nsyywrap */ - -void -_nsyyerror(const char *msg) -{ - - syslog(LOG_WARNING, "libc nsdispatch: %s line %d: %s at '%s'", - _PATH_NS_CONF, yylineno, msg, yytext); -} /* _nsyyerror */ diff --git a/lib/libc/net/nsparser.y b/lib/libc/net/nsparser.y deleted file mode 100644 index 4156d6264..000000000 --- a/lib/libc/net/nsparser.y +++ /dev/null @@ -1,191 +0,0 @@ -%{ -/* $NetBSD: nsparser.y,v 1.12 2012/03/20 17:44:18 matt Exp $ */ - -/*- - * Copyright (c) 1997, 1998, 1999 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Luke Mewburn. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: nsparser.y,v 1.12 2012/03/20 17:44:18 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" - -#include -#define _NS_PRIVATE -#include -#include -#include -#include - - -static void _nsaddsrctomap(const char *); - -static ns_dbt curdbt; -static ns_src cursrc; - -extern char * _nsyytext; -extern int _nsyylineno; -%} - -%union { - char *str; - int mapval; -} - -%token NL -%token SUCCESS UNAVAIL NOTFOUND TRYAGAIN -%token RETURN CONTINUE -%token STRING - -%type Status Action - -%% - -File - : /* empty */ - | Lines - ; - -Lines - : Entry - | Lines Entry - ; - -Entry - : NL - | Database ':' NL - | Database ':' Srclist NL - { - int lineno; - - lineno = _nsyylineno - (*_nsyytext == '\n' ? 1 : 0); - if (_nsdbtput(&curdbt) == -1) - syslog(LOG_WARNING, - "libc nsdispatch: %s line %d: %s", - _PATH_NS_CONF, lineno, - "error adding entry"); - } - | error NL - { - yyerrok; - } - ; - -Database - : STRING - { - curdbt.name = yylval.str; - curdbt.srclist = NULL; - curdbt.srclistsize = 0; - } - ; - -Srclist - : Item - | Srclist Item - ; - -Item - : STRING - { - cursrc.flags = NS_SUCCESS; - _nsaddsrctomap($1); - } - | STRING '[' { cursrc.flags = NS_SUCCESS; } Criteria ']' - { - _nsaddsrctomap($1); - } - ; - -Criteria - : Criterion - | Criteria Criterion - ; - -Criterion - : Status '=' Action - { - if ($3) /* if action == RETURN set RETURN bit */ - cursrc.flags |= $1; - else /* else unset it */ - cursrc.flags &= ~$1; - } - ; - -Status - : SUCCESS { $$ = NS_SUCCESS; } - | UNAVAIL { $$ = NS_UNAVAIL; } - | NOTFOUND { $$ = NS_NOTFOUND; } - | TRYAGAIN { $$ = NS_TRYAGAIN; } - ; - -Action - : RETURN { $$ = 1L; } - | CONTINUE { $$ = 0L; } - ; - -%% - -static void -_nsaddsrctomap(const char *elem) -{ - unsigned int i; - int lineno; - - _DIAGASSERT(elem != NULL); - - lineno = _nsyylineno - (*_nsyytext == '\n' ? 1 : 0); - if (curdbt.srclistsize > 0) { - if ((strcasecmp(elem, NSSRC_COMPAT) == 0) || - (strcasecmp(curdbt.srclist[0].name, NSSRC_COMPAT) == 0)) { - syslog(LOG_WARNING, - "libc nsdispatch: %s line %d: %s", - _PATH_NS_CONF, lineno, - "'compat' used with other sources"); - return; - } - } - for (i = 0; i < curdbt.srclistsize; i++) { - if (strcasecmp(curdbt.srclist[i].name, elem) == 0) { - syslog(LOG_WARNING, - "libc nsdispatch: %s line %d: %s '%s'", - _PATH_NS_CONF, lineno, - "duplicate source", elem); - return; - } - } - cursrc.name = elem; - if (_nsdbtaddsrc(&curdbt, &cursrc) == -1) { - syslog(LOG_WARNING, - "libc nsdispatch: %s line %d: %s '%s'", - _PATH_NS_CONF, lineno, - "error adding", elem); - } -} diff --git a/lib/libc/net/protoent.h b/lib/libc/net/protoent.h deleted file mode 100644 index 4c98a64f3..000000000 --- a/lib/libc/net/protoent.h +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: protoent.h,v 1.2 2008/04/28 20:23:00 martin Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -struct protoent_data { - FILE *fp; - struct protoent proto; - char **aliases; - size_t maxaliases; - int stayopen; - char *line; - void *dummy; -}; - -struct protoent *getprotoent_r(struct protoent *, struct protoent_data *); -struct protoent *getprotobyname_r(const char *, - struct protoent *, struct protoent_data *); -struct protoent *getprotobynumber_r(int, - struct protoent *, struct protoent_data *); -void setprotoent_r(int, struct protoent_data *); -void endprotoent_r(struct protoent_data *); diff --git a/lib/libc/net/rcmd.3 b/lib/libc/net/rcmd.3 deleted file mode 100644 index 41b8ef0ed..000000000 --- a/lib/libc/net/rcmd.3 +++ /dev/null @@ -1,311 +0,0 @@ -.\" $NetBSD: rcmd.3,v 1.28 2010/03/22 19:30:54 joerg Exp $ -.\" -.\" Copyright (c) 1983, 1991, 1993 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. 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. -.\" -.\" @(#)rcmd.3 8.1 (Berkeley) 6/4/93 -.\" -.Dd March 30, 2005 -.Dt RCMD 3 -.Os -.Sh NAME -.Nm rcmd , -.Nm orcmd , -.Nm rcmd_af , -.Nm orcmd_af , -.Nm rresvport , -.Nm rresvport_af , -.Nm iruserok , -.Nm ruserok , -.Nm iruserok_sa -.Nd routines for returning a stream to a remote command -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In unistd.h -.Ft int -.Fn rcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" -.Ft int -.Fn orcmd "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" -.Ft int -.Fn rcmd_af "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" "int af" -.Ft int -.Fn orcmd_af "char **ahost" "int inport" "const char *locuser" "const char *remuser" "const char *cmd" "int *fd2p" "int af" -.Ft int -.Fn rresvport "int *port" -.Ft int -.Fn rresvport_af "int *port" "int family" -.Ft int -.Fn iruserok "uint32_t raddr" "int superuser" "const char *ruser" "const char *luser" -.Ft int -.Fn ruserok "const char *rhost" "int superuser" "const char *ruser" "const char *luser" -.Ft int -.Fn iruserok_sa "const void *raddr" "int rlen" "int superuser" "const char *ruser" "const char *luser" -.Sh DESCRIPTION -The -.Fn rcmd -function is available for use by anyone to run commands on a -remote system. It acts like the -.Fn orcmd -command, with the exception that it makes a call out to the -.Xr rcmd 1 -command, or any other user-specified command, to perform the -actual connection (thus not requiring -that the caller be running as the super-user), and is only -available for the -.Dq shell/tcp -port. -The -.Fn orcmd -function -is used by the super-user to execute a command on -a remote machine using an authentication scheme based -on reserved port numbers. -While -.Fn rcmd -and -.Fn orcmd -can only handle IPv4 address in the first argument, -.Fn rcmd_af -and -.Fn orcmd_af -can handle other cases as well. -The -.Fn rresvport -function -returns a descriptor to a socket -with an address in the privileged port space. -The -.Fn rresvport_af -function is similar to -.Fn rresvport , -but you can explicitly specify the address family to use. -Calling -.Fn rresvport_af -with -.Dv AF_INET -has the same effect as -.Fn rresvport . -The -.Fn iruserok -and -.Fn ruserok -functions are used by servers -to authenticate clients requesting service with -.Fn rcmd . -All six functions are present in the same file and are used -by the -.Xr rshd 8 -server (among others). -.Fn iruserok_sa -is an address family independent variant of -.Fn iruserok . -.Pp -The -.Fn rcmd -function -looks up the host -.Fa *ahost -using -.Xr gethostbyname 3 , -returning \-1 if the host does not exist. -Otherwise -.Fa *ahost -is set to the standard name of the host -and a connection is established to a server -residing at the well-known Internet port -.Fa inport . -.Pp -If the connection succeeds, -a socket in the Internet domain of type -.Dv SOCK_STREAM -is returned to the caller, and given to the remote -command as -.Em stdin -and -.Em stdout . -If -.Fa fd2p -is non-zero, then an auxiliary channel to a control -process will be set up, and a descriptor for it will be placed -in -.Fa *fd2p . -The control process will return diagnostic -output from the command (unit 2) on this channel, and will also -accept bytes on this channel as being -.Ux -signal numbers, to be -forwarded to the process group of the command. -If -.Fa fd2p -is 0, then the -.Em stderr -(unit 2 of the remote -command) will be made the same as the -.Em stdout -and no -provision is made for sending arbitrary signals to the remote process, -although you may be able to get its attention by using out-of-band data. -.Pp -.Fn rcmd_af -and -.Fn orcmd_af -take address family in the last argument. -If the last argument is -.Dv PF_UNSPEC , -interpretation of -.Fa *ahost -will obey the underlying address resolution like DNS. -.Pp -The protocol is described in detail in -.Xr rshd 8 . -.Pp -The -.Fn rresvport -and -.Fn rresvport_af -functions are used to obtain a socket with a privileged -address bound to it. This socket is suitable for use -by -.Fn rcmd -and several other functions. Privileged Internet ports are those -in the range 0 to 1023. Only the super-user -is allowed to bind an address of this sort to a socket. -.Pp -The -.Fn iruserok -and -.Fn ruserok -functions take a remote host's IP address or name, respectively, -two user names and a flag indicating whether the local user's -name is that of the super-user. -Then, if the user is -.Em NOT -the super-user, it checks the -.Pa /etc/hosts.equiv -file. -If that lookup is not done, or is unsuccessful, the -.Pa .rhosts -in the local user's home directory is checked to see if the request for -service is allowed. -.Pp -If this file does not exist, is not a regular file, is owned by anyone -other than the user or the super-user, or is writable by anyone other -than the owner, the check automatically fails. -Zero is returned if the machine name is listed in the -.Dq Pa hosts.equiv -file, or the host and remote user name are found in the -.Dq Pa .rhosts -file; otherwise -.Fn iruserok -and -.Fn ruserok -return \-1. -If the local domain (as obtained from -.Xr gethostname 3 ) -is the same as the remote domain, only the machine name need be specified. -.Pp -If the IP address of the remote host is known, -.Fn iruserok -should be used in preference to -.Fn ruserok , -as it does not require trusting the DNS server for the remote host's domain. -.Pp -While -.Fn iruserok -can handle IPv4 addresses only, -.Fn iruserok_sa -and -.Fn ruserok -can handle other address families as well, like IPv6. -The first argument of -.Fn iruserok_sa -is typed as -.Fa "void *" -to avoid dependency between -.In unistd.h -and -.In sys/socket.h . -.Sh ENVIRONMENT -.Bl -tag -width RCMD_CMDxx -compact -.It Ev RCMD_CMD -When using the -.Fn rcmd -function, this variable is used as the program to run instead of -.Xr rcmd 1 . -.El -.Sh DIAGNOSTICS -The -.Fn rcmd -function -returns a valid socket descriptor on success. -It returns \-1 on error and prints a diagnostic message on the standard error. -.Pp -The -.Fn rresvport -and -.Fn rresvport_af -function -return a valid, bound socket descriptor on success. -They return \-1 on error with the global value -.Va errno -set according to the reason for failure. -The error code -.Dv EAGAIN -is overloaded to mean ``All network ports in use.'' -.Sh SEE ALSO -.Xr rcmd 1 , -.Xr rlogin 1 , -.Xr rsh 1 , -.Xr intro 2 , -.Xr rexec 3 , -.Xr hosts.equiv 5 , -.Xr rhosts 5 , -.Xr rexecd 8 , -.Xr rlogind 8 , -.Xr rshd 8 -.Sh HISTORY -The -.Fn orcmd , -.Fn rresvport , -.Fn iruserok -and -.Fn ruserok -functions appeared in -.Bx 4.2 , -where the -.Fn orcmd -function was called -.Fn rcmd . -The (newer) -.Fn rcmd -function appeared in -.Nx 1.3 . -.Fn rcmd_af -and -.Fn rresvport_af -were defined in RFC2292. diff --git a/lib/libc/net/rcmd.c b/lib/libc/net/rcmd.c deleted file mode 100644 index cacb7075a..000000000 --- a/lib/libc/net/rcmd.c +++ /dev/null @@ -1,1021 +0,0 @@ -/* $NetBSD: rcmd.c,v 1.71 2014/11/26 23:44:21 enami Exp $ */ - -/* - * Copyright (c) 1983, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)rcmd.c 8.3 (Berkeley) 3/26/94"; -#else -__RCSID("$NetBSD: rcmd.c,v 1.71 2014/11/26 23:44:21 enami Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef _LIBC -#include "namespace.h" -#endif -#include -#include -#include -#include -#include - -#include -#if !defined(__minix) -#include -#endif /* !defined(__minix) */ -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "pathnames.h" - -int orcmd(char **, u_int, const char *, const char *, const char *, int *); -int orcmd_af(char **, u_int, const char *, const char *, const char *, - int *, int); -int __ivaliduser(FILE *, u_int32_t, const char *, const char *); -int __ivaliduser_sa(FILE *, const struct sockaddr *, socklen_t, - const char *, const char *); -static int rshrcmd(int, char **, u_int32_t, const char *, - const char *, const char *, int *, const char *); -static int resrcmd(struct addrinfo *, char **, u_int32_t, const char *, - const char *, const char *, int *); -static int __icheckhost(const struct sockaddr *, socklen_t, - const char *); -static char *__gethostloop(const struct sockaddr *, socklen_t); - -int -rcmd(char **ahost, int rport, const char *locuser, const char *remuser, - const char *cmd, int *fd2p) -{ - - return rcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); -} - -int -rcmd_af(char **ahost, int rport, const char *locuser, const char *remuser, - const char *cmd, int *fd2p, int af) -{ - static char hbuf[MAXHOSTNAMELEN]; - char pbuf[NI_MAXSERV]; - struct addrinfo hints, *res; - int error; - struct servent *sp; - - _DIAGASSERT(ahost != NULL); - _DIAGASSERT(locuser != NULL); - _DIAGASSERT(remuser != NULL); - _DIAGASSERT(cmd != NULL); - /* fd2p may be NULL */ - - snprintf(pbuf, sizeof(pbuf), "%u", ntohs(rport)); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = af; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - error = getaddrinfo(*ahost, pbuf, &hints, &res); - if (error) { - warnx("%s: %s", *ahost, gai_strerror(error)); /*XXX*/ - return -1; - } - if (res->ai_canonname) { - /* - * Canonicalise hostname. - * XXX: Should we really do this? - */ - strlcpy(hbuf, res->ai_canonname, sizeof(hbuf)); - *ahost = hbuf; - } - - /* - * Check if rport is the same as the shell port, and that the fd2p. If - * it is not, the program isn't expecting 'rsh' and so we can't use the - * RCMD_CMD environment. - */ - sp = getservbyname("shell", "tcp"); - if (sp != NULL && sp->s_port == rport) - error = rshrcmd(af, ahost, (u_int32_t)rport, - locuser, remuser, cmd, fd2p, getenv("RCMD_CMD")); - else - error = resrcmd(res, ahost, (u_int32_t)rport, - locuser, remuser, cmd, fd2p); - freeaddrinfo(res); - return error; -} - -/* this is simply a wrapper around hprcmd() that handles ahost first */ -int -orcmd(char **ahost, u_int rport, const char *locuser, const char *remuser, - const char *cmd, int *fd2p) -{ - return orcmd_af(ahost, rport, locuser, remuser, cmd, fd2p, AF_INET); -} - -int -orcmd_af(char **ahost, u_int rport, const char *locuser, const char *remuser, - const char *cmd, int *fd2p, int af) -{ - static char hbuf[MAXHOSTNAMELEN]; - char pbuf[NI_MAXSERV]; - struct addrinfo hints, *res; - int error; - - _DIAGASSERT(ahost != NULL); - _DIAGASSERT(locuser != NULL); - _DIAGASSERT(remuser != NULL); - _DIAGASSERT(cmd != NULL); - /* fd2p may be NULL */ - - snprintf(pbuf, sizeof(pbuf), "%u", ntohs(rport)); - memset(&hints, 0, sizeof(hints)); - hints.ai_family = af; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = AI_CANONNAME; - error = getaddrinfo(*ahost, pbuf, &hints, &res); - if (error) { - warnx("%s: %s", *ahost, gai_strerror(error)); /*XXX*/ - return -1; - } - if (res->ai_canonname) { - strlcpy(hbuf, res->ai_canonname, sizeof(hbuf)); - *ahost = hbuf; - } - - error = resrcmd(res, ahost, rport, locuser, remuser, cmd, fd2p); - freeaddrinfo(res); - return error; -} - -/*ARGSUSED*/ -static int -resrcmd(struct addrinfo *res, char **ahost, u_int32_t rport, - const char *locuser, const char *remuser, const char *cmd, int *fd2p) -{ - struct addrinfo *r; - struct sockaddr_storage from; - struct pollfd reads[2]; - sigset_t nmask, omask; - pid_t pid; - int s, lport, timo; - int pollr; - char c; - int refused; - - _DIAGASSERT(res != NULL); - _DIAGASSERT(ahost != NULL); - _DIAGASSERT(locuser != NULL); - _DIAGASSERT(remuser != NULL); - _DIAGASSERT(cmd != NULL); - /* fd2p may be NULL */ - - r = res; - refused = 0; - pid = getpid(); - sigemptyset(&nmask); - sigaddset(&nmask, SIGURG); - if (sigprocmask(SIG_BLOCK, &nmask, &omask) == -1) - return -1; - for (timo = 1, lport = IPPORT_RESERVED - 1;;) { - s = rresvport_af(&lport, r->ai_family); - if (s < 0) { - if (errno == EAGAIN) - warnx("rcmd: socket: All ports in use"); - else - warn("rcmd: socket"); - if (r->ai_next) { - r = r->ai_next; - continue; - } else { - (void)sigprocmask(SIG_SETMASK, &omask, NULL); - return -1; - } - } - fcntl(s, F_SETOWN, pid); - if (connect(s, r->ai_addr, r->ai_addrlen) >= 0) - break; - (void)close(s); - if (errno == EADDRINUSE) { - lport--; - continue; - } else if (errno == ECONNREFUSED) - refused++; - if (r->ai_next) { - int oerrno = errno; - char hbuf[NI_MAXHOST]; - const int niflags = NI_NUMERICHOST; - - hbuf[0] = '\0'; - if (getnameinfo(r->ai_addr, r->ai_addrlen, - hbuf, (socklen_t)sizeof(hbuf), NULL, 0, niflags) != - 0) - strlcpy(hbuf, "(invalid)", sizeof(hbuf)); - errno = oerrno; - warn("rcmd: connect to address %s", hbuf); - r = r->ai_next; - hbuf[0] = '\0'; - if (getnameinfo(r->ai_addr, r->ai_addrlen, - hbuf, (socklen_t)sizeof(hbuf), NULL, 0, niflags) != - 0) - strlcpy(hbuf, "(invalid)", sizeof(hbuf)); - (void)fprintf(stderr, "Trying %s...\n", hbuf); - continue; - } - if (refused && timo <= 16) { - (void)sleep((unsigned int)timo); - timo *= 2; - r = res; - refused = 0; - continue; - } - (void)fprintf(stderr, "%s: %s\n", res->ai_canonname, - strerror(errno)); - (void)sigprocmask(SIG_SETMASK, &omask, NULL); - return -1; - } - lport--; - if (fd2p == 0) { - write(s, "", 1); - lport = 0; - } else { - char num[8]; - int s2 = rresvport_af(&lport, r->ai_family), s3; - socklen_t len = sizeof(from); - - if (s2 < 0) - goto bad; - listen(s2, 1); - (void)snprintf(num, sizeof(num), "%d", lport); - if (write(s, num, strlen(num) + 1) != - (ssize_t) (strlen(num) + 1)) { - warn("rcmd: write (setting up stderr)"); - (void)close(s2); - goto bad; - } - reads[0].fd = s; - reads[0].events = POLLIN; - reads[1].fd = s2; - reads[1].events = POLLIN; - errno = 0; - pollr = poll(reads, 2, INFTIM); - if (pollr < 1 || (reads[1].revents & POLLIN) == 0) { - if (errno != 0) - warn("poll: setting up stderr"); - else - warnx( - "poll: protocol failure in circuit setup"); - (void)close(s2); - goto bad; - } - s3 = accept(s2, (struct sockaddr *)(void *)&from, &len); - (void)close(s2); - if (s3 < 0) { - warn("rcmd: accept"); - lport = 0; - goto bad; - } - *fd2p = s3; - switch (((struct sockaddr *)(void *)&from)->sa_family) { - case AF_INET: -#ifdef INET6 - case AF_INET6: -#endif - if (getnameinfo((struct sockaddr *)(void *)&from, len, - NULL, 0, num, (socklen_t)sizeof(num), - NI_NUMERICSERV) != 0 || - (atoi(num) >= IPPORT_RESERVED || - atoi(num) < IPPORT_RESERVED / 2)) { - warnx( - "rcmd: protocol failure in circuit setup."); - goto bad2; - } - break; - default: - break; - } - } - - (void)write(s, locuser, strlen(locuser)+1); - (void)write(s, remuser, strlen(remuser)+1); - (void)write(s, cmd, strlen(cmd)+1); - if (read(s, &c, 1) != 1) { - warn("%s", *ahost); - goto bad2; - } - if (c != 0) { - while (read(s, &c, 1) == 1) { - (void)write(STDERR_FILENO, &c, 1); - if (c == '\n') - break; - } - goto bad2; - } - (void)sigprocmask(SIG_SETMASK, &omask, NULL); - return s; -bad2: - if (lport) - (void)close(*fd2p); -bad: - (void)close(s); - (void)sigprocmask(SIG_SETMASK, &omask, NULL); - return -1; -} - -/* - * based on code written by Chris Siebenmann - */ -/* ARGSUSED */ -static int -rshrcmd(int af, char **ahost, u_int32_t rport, const char *locuser, - const char *remuser, const char *cmd, int *fd2p, const char *rshcmd) -{ - pid_t pid; - int sp[2], ep[2]; - char *p; - struct passwd *pw, pwres; - char pwbuf[1024]; - - _DIAGASSERT(ahost != NULL); - _DIAGASSERT(locuser != NULL); - _DIAGASSERT(remuser != NULL); - _DIAGASSERT(cmd != NULL); - /* fd2p may be NULL */ - - /* What rsh/shell to use. */ - if (rshcmd == NULL) - rshcmd = _PATH_BIN_RCMD; - - /* locuser must exist on this host. */ - if (getpwnam_r(locuser, &pwres, pwbuf, sizeof(pwbuf), &pw) != 0 || - pw == NULL) { - warnx("%s: unknown user: %s", __func__, locuser); - return -1; - } - - /* get a socketpair we'll use for stdin and stdout. */ - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, sp) < 0) { - warn("%s: socketpair", __func__); - return -1; - } - /* we will use this for the fd2 pointer */ - if (fd2p) { - if (socketpair(AF_LOCAL, SOCK_STREAM, 0, ep) < 0) { - warn("%s: socketpair", __func__); - return -1; - } - *fd2p = ep[0]; - } - - pid = fork(); - if (pid < 0) { - warn("%s: fork", __func__); - return -1; - } - if (pid == 0) { - /* - * child - * - we use sp[1] to be stdin/stdout, and close sp[0] - * - with fd2p, we use ep[1] for stderr, and close ep[0] - */ - (void)close(sp[0]); - if (dup2(sp[1], 0) < 0 || dup2(0, 1) < 0) { - warn("%s: dup2", __func__); - _exit(1); - } - (void)close(sp[1]); - if (fd2p) { - if (dup2(ep[1], 2) < 0) { - warn("%s: dup2", __func__); - _exit(1); - } - (void)close(ep[0]); - (void)close(ep[1]); - } else if (dup2(0, 2) < 0) { - warn("%s: dup2", __func__); - _exit(1); - } - /* fork again to lose parent. */ - pid = fork(); - if (pid < 0) { - warn("%s: second fork", __func__); - _exit(1); - } - if (pid > 0) - _exit(0); - - /* Orphan. Become local user for rshprog. */ - if (setuid(pw->pw_uid)) { - warn("%s: setuid(%lu)", __func__, (u_long)pw->pw_uid); - _exit(1); - } - - /* - * If we are rcmd'ing to "localhost" as the same user as we - * are, then avoid running remote shell for efficiency. - */ - if (strcmp(*ahost, "localhost") == 0 && - strcmp(locuser, remuser) == 0) { - if (pw->pw_shell[0] == '\0') - rshcmd = _PATH_BSHELL; - else - rshcmd = pw->pw_shell; - p = strrchr(rshcmd, '/'); - execlp(rshcmd, p ? p + 1 : rshcmd, "-c", cmd, NULL); - } else { - const char *program; - program = strrchr(rshcmd, '/'); - program = program ? program + 1 : rshcmd; - if (fd2p) - /* ask rcmd to relay signal information */ - setenv("RCMD_RELAY_SIGNAL", "YES", 1); - switch (af) { - case AF_INET: - execlp(rshcmd, program, "-4", "-l", remuser, - *ahost, cmd, NULL); - break; - - case AF_INET6: - execlp(rshcmd, program, "-6", "-l", remuser, - *ahost, cmd, NULL); - break; - - default: - /* typically AF_UNSPEC, plus whatever */ - execlp(rshcmd, program, "-l", remuser, - *ahost, cmd, NULL); - break; - } - } - warn("%s: exec %s", __func__, rshcmd); - _exit(1); - } - /* Parent */ - (void)close(sp[1]); - if (fd2p) - (void)close(ep[1]); - - (void)waitpid(pid, NULL, 0); - return sp[0]; -} - -int -rresvport(int *alport) -{ - - _DIAGASSERT(alport != NULL); - - return rresvport_af(alport, AF_INET); -} - -int -rresvport_af(int *alport, int family) -{ - return rresvport_af_addr(alport, family, NULL); -} - -int -rresvport_af_addr(int *alport, int family, void *addr) -{ - struct sockaddr_storage ss; - struct sockaddr *sa; - socklen_t salen; - int s; - u_int16_t *portp; - - _DIAGASSERT(alport != NULL); - - memset(&ss, 0, sizeof(ss)); - sa = (struct sockaddr *)(void *)&ss; - switch (family) { - case AF_INET: -#ifdef BSD4_4 - sa->sa_len = -#endif - salen = sizeof(struct sockaddr_in); - if (addr) - ((struct sockaddr_in *)(void *)sa)->sin_addr = - ((struct sockaddr_in *)addr)->sin_addr; - portp = &((struct sockaddr_in *)(void *)sa)->sin_port; - break; -#ifdef INET6 - case AF_INET6: -#ifdef BSD4_4 - sa->sa_len = -#endif - salen = sizeof(struct sockaddr_in6); - if (addr) - ((struct sockaddr_in6 *)(void *)sa)->sin6_addr = - ((struct sockaddr_in6 *)addr)->sin6_addr; - portp = &((struct sockaddr_in6 *)(void *)sa)->sin6_port; - break; -#endif - default: - errno = EAFNOSUPPORT; - return -1; - } - sa->sa_family = family; - s = socket(family, SOCK_STREAM, 0); - if (s < 0) - return -1; -#if defined(BSD4_4) && !defined(__minix) - switch (family) { - case AF_INET: - case AF_INET6: - *portp = 0; - if (bindresvport(s, (struct sockaddr_in *)(void *)sa) < 0) { - int sverr = errno; - - (void)close(s); - errno = sverr; - return -1; - } - *alport = (int)ntohs(*portp); - return s; - default: - /* is it necessary to try keep code for other AFs? */ - break; - } -#endif - for (;;) { - *portp = htons((u_short)*alport); - if (bind(s, sa, salen) >= 0) - return s; - if (errno != EADDRINUSE) { - (void)close(s); - return -1; - } - (*alport)--; - if (*alport == IPPORT_RESERVED/2) { - (void)close(s); - errno = EAGAIN; /* close */ - return -1; - } - } -} - -int __check_rhosts_file = 1; -const char *__rcmd_errstr; - -int -ruserok(const char *rhost, int superuser, const char *ruser, const char *luser) -{ - struct addrinfo hints, *res, *r; - int error; - - _DIAGASSERT(rhost != NULL); - _DIAGASSERT(ruser != NULL); - _DIAGASSERT(luser != NULL); - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = PF_UNSPEC; - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - error = getaddrinfo(rhost, "0", &hints, &res); - if (error) - return -1; - - for (r = res; r; r = r->ai_next) { - if (iruserok_sa(r->ai_addr, (int)r->ai_addrlen, superuser, - ruser, luser) == 0) { - freeaddrinfo(res); - return 0; - } - } - freeaddrinfo(res); - return -1; -} - -/* - * New .rhosts strategy: We are passed an ip address. We spin through - * hosts.equiv and .rhosts looking for a match. When the .rhosts only - * has ip addresses, we don't have to trust a nameserver. When it - * contains hostnames, we spin through the list of addresses the nameserver - * gives us and look for a match. - * - * Returns 0 if ok, -1 if not ok. - */ -int -iruserok(u_int32_t raddr, int superuser, const char *ruser, const char *luser) -{ - struct sockaddr_in irsin; - - memset(&irsin, 0, sizeof(irsin)); - irsin.sin_family = AF_INET; -#ifdef BSD4_4 - irsin.sin_len = sizeof(irsin); -#endif - memcpy(&irsin.sin_addr, &raddr, sizeof(irsin.sin_addr)); - return iruserok_sa(&irsin, (socklen_t)sizeof(irsin), superuser, ruser, - luser); -} - -/* - * 2nd and 3rd arguments are typed like this, to avoid dependency between - * unistd.h and sys/socket.h. There's no better way. - */ -int -iruserok_sa(const void *raddr, int rlen, int superuser, const char *ruser, - const char *luser) -{ - const struct sockaddr *sa; - struct stat sbuf; - struct passwd *pwd, pwres; - FILE *hostf; - uid_t uid; - gid_t gid; - int isvaliduser; - char pbuf[MAXPATHLEN]; - char pwbuf[1024]; - - _DIAGASSERT(raddr != NULL); - _DIAGASSERT(ruser != NULL); - _DIAGASSERT(luser != NULL); - - sa = raddr; - - __rcmd_errstr = NULL; - - hostf = superuser ? NULL : fopen(_PATH_HEQUIV, "re"); - - if (hostf) { - if (__ivaliduser_sa(hostf, sa, (socklen_t)rlen, luser, - ruser) == 0) { - (void)fclose(hostf); - return 0; - } - (void)fclose(hostf); - } - - isvaliduser = -1; - if (__check_rhosts_file || superuser) { - - if (getpwnam_r(luser, &pwres, pwbuf, sizeof(pwbuf), &pwd) != 0 - || pwd == NULL) - return -1; - (void)strlcpy(pbuf, pwd->pw_dir, sizeof(pbuf)); - (void)strlcat(pbuf, "/.rhosts", sizeof(pbuf)); - - /* - * Change effective uid while opening and reading .rhosts. - * If root and reading an NFS mounted file system, can't - * read files that are protected read/write owner only. - */ - uid = geteuid(); - gid = getegid(); - (void)setegid(pwd->pw_gid); - (void)initgroups(pwd->pw_name, pwd->pw_gid); - (void)seteuid(pwd->pw_uid); - hostf = fopen(pbuf, "re"); - - if (hostf != NULL) { - /* - * If not a regular file, or is owned by someone other - * than user or root or if writable by anyone but the - * owner, quit. - */ - if (lstat(pbuf, &sbuf) < 0) - __rcmd_errstr = ".rhosts lstat failed"; - else if (!S_ISREG(sbuf.st_mode)) - __rcmd_errstr = ".rhosts not regular file"; - else if (fstat(fileno(hostf), &sbuf) < 0) - __rcmd_errstr = ".rhosts fstat failed"; - else if (sbuf.st_uid && sbuf.st_uid != pwd->pw_uid) - __rcmd_errstr = "bad .rhosts owner"; - else if (sbuf.st_mode & (S_IWGRP|S_IWOTH)) - __rcmd_errstr = - ".rhosts writable by other than owner"; - else - isvaliduser = - __ivaliduser_sa(hostf, sa, (socklen_t)rlen, - luser, ruser); - - (void)fclose(hostf); - } - (void)seteuid(uid); - (void)setegid(gid); - - } - return isvaliduser; -} - -/* - * XXX - * Don't make static, used by lpd(8). We will be able to change the function - * into static function, when we bump libc major #. - * - * Returns 0 if ok, -1 if not ok. - */ -#ifdef notdef /*_LIBC*/ -static -#endif -int -__ivaliduser(FILE *hostf, u_int32_t raddr, const char *luser, - const char *ruser) -{ - struct sockaddr_in ivusin; - - memset(&ivusin, 0, sizeof(ivusin)); - ivusin.sin_family = AF_INET; -#ifdef BSD4_4 - ivusin.sin_len = sizeof(ivusin); -#endif - memcpy(&ivusin.sin_addr, &raddr, sizeof(ivusin.sin_addr)); - return __ivaliduser_sa(hostf, (struct sockaddr *)(void *)&ivusin, - (socklen_t)sizeof(ivusin), luser, ruser); -} - -#ifdef notdef /*_LIBC*/ -static -#endif -int -__ivaliduser_sa(FILE *hostf, const struct sockaddr *raddr, socklen_t salen, - const char *luser, const char *ruser) -{ - char *user, *p; - int ch; - char buf[MAXHOSTNAMELEN + 128]; /* host + login */ - const char *auser, *ahost; - int hostok, userok; - char *rhost = NULL; - int firsttime = 1; - char domain[MAXHOSTNAMELEN]; - - getdomainname(domain, sizeof(domain)); - - _DIAGASSERT(hostf != NULL); - _DIAGASSERT(luser != NULL); - _DIAGASSERT(ruser != NULL); - - while (fgets(buf, (int)sizeof(buf), hostf)) { - p = buf; - /* Skip lines that are too long. */ - if (strchr(p, '\n') == NULL) { - while ((ch = getc(hostf)) != '\n' && ch != EOF) - ; - continue; - } - while (*p != '\n' && *p != ' ' && *p != '\t' && *p != '\0') { - *p = isupper((unsigned char)*p) ? - tolower((unsigned char)*p) : *p; - p++; - } - if (*p == ' ' || *p == '\t') { - *p++ = '\0'; - while (*p == ' ' || *p == '\t') - p++; - user = p; - while (*p != '\n' && *p != ' ' && - *p != '\t' && *p != '\0') - p++; - } else - user = p; - *p = '\0'; - - if (p == buf) - continue; - - auser = *user ? user : luser; - ahost = buf; - - if (ahost[0] == '+') - switch (ahost[1]) { - case '\0': - hostok = 1; - break; - - case '@': - if (firsttime) { - rhost = __gethostloop(raddr, salen); - firsttime = 0; - } - if (rhost) - hostok = innetgr(&ahost[2], rhost, - NULL, domain); - else - hostok = 0; - break; - - default: - hostok = __icheckhost(raddr, salen, &ahost[1]); - break; - } - else if (ahost[0] == '-') - switch (ahost[1]) { - case '\0': - hostok = -1; - break; - - case '@': - if (firsttime) { - rhost = __gethostloop(raddr, salen); - firsttime = 0; - } - if (rhost) - hostok = -innetgr(&ahost[2], rhost, - NULL, domain); - else - hostok = 0; - break; - - default: - hostok = - -__icheckhost(raddr, salen, &ahost[1]); - break; - } - else - hostok = __icheckhost(raddr, salen, ahost); - - - if (auser[0] == '+') - switch (auser[1]) { - case '\0': - userok = 1; - break; - - case '@': - userok = innetgr(&auser[2], NULL, ruser, - domain); - break; - - default: - userok = strcmp(ruser, &auser[1]) == 0; - break; - } - else if (auser[0] == '-') - switch (auser[1]) { - case '\0': - userok = -1; - break; - - case '@': - userok = -innetgr(&auser[2], NULL, ruser, - domain); - break; - - default: - userok = - -(strcmp(ruser, &auser[1]) == 0 ? 1 : 0); - break; - } - else - userok = strcmp(ruser, auser) == 0; - - /* Check if one component did not match */ - if (hostok == 0 || userok == 0) - continue; - - /* Check if we got a forbidden pair */ - if (userok == -1 || hostok == -1) - return -1; - - /* Check if we got a valid pair */ - if (hostok == 1 && userok == 1) - return 0; - } - return -1; -} - -/* - * Returns "true" if match, 0 if no match. - */ -static int -__icheckhost(const struct sockaddr *raddr, socklen_t salen, const char *lhost) -{ - struct addrinfo hints, *res, *r; - char h1[NI_MAXHOST], h2[NI_MAXHOST]; - int error; - const int niflags = NI_NUMERICHOST; - - _DIAGASSERT(raddr != NULL); - _DIAGASSERT(lhost != NULL); - - h1[0] = '\0'; - if (getnameinfo(raddr, salen, h1, (socklen_t)sizeof(h1), NULL, 0, - niflags) != 0) - return 0; - - /* Resolve laddr into sockaddr */ - memset(&hints, 0, sizeof(hints)); - hints.ai_family = raddr->sa_family; - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - res = NULL; - error = getaddrinfo(lhost, "0", &hints, &res); - if (error) - return 0; - - /* - * Try string comparisons between raddr and laddr. - */ - for (r = res; r; r = r->ai_next) { - h2[0] = '\0'; - if (getnameinfo(r->ai_addr, r->ai_addrlen, h2, - (socklen_t)sizeof(h2), NULL, 0, niflags) != 0) - continue; - if (strcmp(h1, h2) == 0) { - freeaddrinfo(res); - return 1; - } - } - - /* No match. */ - freeaddrinfo(res); - return 0; -} - -/* - * Return the hostname associated with the supplied address. - * Do a reverse lookup as well for security. If a loop cannot - * be found, pack the numeric IP address into the string. - */ -static char * -__gethostloop(const struct sockaddr *raddr, socklen_t salen) -{ - static char remotehost[NI_MAXHOST]; - char h1[NI_MAXHOST], h2[NI_MAXHOST]; - struct addrinfo hints, *res, *r; - int error; - const int niflags = NI_NUMERICHOST; - - _DIAGASSERT(raddr != NULL); - - h1[0] = remotehost[0] = '\0'; - if (getnameinfo(raddr, salen, remotehost, (socklen_t)sizeof(remotehost), - NULL, 0, NI_NAMEREQD) != 0) - return NULL; - if (getnameinfo(raddr, salen, h1, (socklen_t)sizeof(h1), NULL, 0, - niflags) != 0) - return NULL; - - /* - * Look up the name and check that the supplied - * address is in the list - */ - memset(&hints, 0, sizeof(hints)); - hints.ai_family = raddr->sa_family; - hints.ai_socktype = SOCK_DGRAM; /*dummy*/ - hints.ai_flags = AI_CANONNAME; - res = NULL; - error = getaddrinfo(remotehost, "0", &hints, &res); - if (error) - return NULL; - - for (r = res; r; r = r->ai_next) { - h2[0] = '\0'; - if (getnameinfo(r->ai_addr, r->ai_addrlen, h2, - (socklen_t)sizeof(h2), NULL, 0, niflags) != 0) - continue; - if (strcmp(h1, h2) == 0) { - freeaddrinfo(res); - return remotehost; - } - } - - /* - * either the DNS adminstrator has made a configuration - * mistake, or someone has attempted to spoof us - */ - syslog(LOG_NOTICE, "rcmd: address %s not listed for host %s", - h1, res->ai_canonname ? res->ai_canonname : remotehost); - freeaddrinfo(res); - return NULL; -} diff --git a/lib/libc/net/recv.c b/lib/libc/net/recv.c deleted file mode 100644 index deb03d096..000000000 --- a/lib/libc/net/recv.c +++ /dev/null @@ -1,50 +0,0 @@ -/* $NetBSD: recv.c,v 1.10 2012/03/20 17:44:18 matt Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)recv.c 8.2 (Berkeley) 2/21/94"; -#else -__RCSID("$NetBSD: recv.c,v 1.10 2012/03/20 17:44:18 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include -#include - -#include - -ssize_t -recv(int s, void *buf, size_t len, int flags) -{ - return (recvfrom(s, buf, len, flags, NULL, NULL)); -} diff --git a/lib/libc/net/resolver.3 b/lib/libc/net/resolver.3 deleted file mode 100644 index 2e7821e99..000000000 --- a/lib/libc/net/resolver.3 +++ /dev/null @@ -1,756 +0,0 @@ -.\" $NetBSD: resolver.3,v 1.28 2013/11/14 00:13:41 wiz Exp $ -.\" Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") -.\" -.\" Permission to use, copy, modify, and distribute this software for any -.\" purpose with or without fee is hereby granted, provided that the above -.\" copyright notice and this permission notice appear in all copies. -.\" -.\" THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES -.\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR -.\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -.\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT -.\" OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -.\" -.\" Copyright (c) 1985, 1995 The Regents of the University of California. -.\" All rights reserved. -.\" -.\" Redistribution and use in source and binary forms are permitted provided -.\" that: (1) source distributions retain this entire copyright notice and -.\" comment, and (2) distributions including binaries display the following -.\" acknowledgement: ``This product includes software developed by the -.\" University of California, Berkeley and its contributors'' in the -.\" documentation or other materials provided with the distribution and in -.\" all advertising materials mentioning features or use of this software. -.\" 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 ``AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED -.\" WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF -.\" MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. -.\" -.\" @(#)resolver.3 6.5 (Berkeley) 6/23/90 -.\" Id: resolver.man3,v 1.2 2009/01/21 00:12:34 each Exp -.\" -.Dd November 13, 2013 -.Dt RESOLVER 3 -.Os -.Sh NAME -.Nm res_ninit , -.Nm res_ourserver_p , -.Nm fp_resstat , -.Nm res_hostalias , -.Nm res_pquery , -.Nm res_nquery , -.Nm res_nsearch , -.Nm res_nquerydomain , -.Nm res_nmkquery , -.Nm res_nsend , -.Nm res_nupdate , -.Nm res_nmkupdate , -.Nm res_nclose , -.Nm res_nsendsigned , -.Nm res_findzonecut , -.Nm res_getservers , -.Nm res_setservers , -.Nm res_ndestroy , -.Nm dn_comp , -.Nm dn_expand , -.\" .Nm hstrerror , -.Nm res_init , -.Nm res_isourserver , -.Nm fp_nquery , -.Nm p_query , -.Nm hostalias , -.Nm res_query , -.Nm res_search , -.Nm res_querydomain , -.Nm res_mkquery , -.Nm res_send , -.Nm res_update , -.Nm res_close , -.\" .Nm herror -.Nd resolver routines -.Sh LIBRARY -.Lb libc -.Lb libresolv -.Sh SYNOPSIS -.In resolv.h -.In res_update.h -.Vt typedef struct __res_state *res_state ; -.Pp -.Ft int -.Fn res_ninit "res_state statp" -.Ft int -.Fn res_ourserver_p "const res_state statp" "const struct sockaddr_in *addr" -.Ft void -.Fn fp_resstat "const res_state statp" "FILE *fp" -.Ft "const char *" -.Fn res_hostalias "const res_state statp" "const char *name" "char *buf" "size_t buflen" -.Ft int -.Fn res_pquery "const res_state statp" "const u_char *msg" "int msglen" "FILE *fp" -.Ft int -.Fn res_nquery "res_state statp" "const char *dname" "int class" "int type" "u_char *answer" "int anslen" -.Ft int -.Fn res_nsearch "res_state statp" "const char *dname" "int class" "int type" "u_char * answer" "int anslen" -.Ft int -.Fn res_nquerydomain "res_state statp" "const char *name" "const char *domain" "int class" "int type" "u_char *answer" "int anslen" -.Ft int -.Fo res_nmkquery -.Fa "res_state statp" -.Fa "int op" -.Fa "const char *dname" -.Fa "int class" -.Fa "int type" -.Fa "const u_char *data" -.Fa "int datalen" -.Fa "const u_char *newrr" -.Fa "u_char *buf" -.Fa "int buflen" -.Fc -.Ft int -.Fn res_nsend "res_state statp" "const u_char *msg" "int msglen" "u_char *answer" "int anslen" -.Ft int -.Fn res_nupdate "res_state statp" "ns_updrec *rrecp_in" -.Ft int -.Fn res_nmkupdate "res_state statp" "ns_updrec *rrecp_in" "u_char *buf" "int buflen" -.Ft void -.Fn res_nclose "res_state statp" -.Ft int -.Fn res_nsendsigned "res_state statp" "const u_char *msg" "int msglen" "ns_tsig_key *key" "u_char *answer" "int anslen" -.Ft int -.Fn res_findzonecut "res_state statp" "const char *dname" "ns_class class" "int options" "char *zname" "size_t zsize" "struct in_addr *addrs" "int naddrs" -.Ft int -.Fn res_getservers "res_state statp" "union res_sockaddr_union *set" "int cnt" -.Ft void -.Fn res_setservers "res_state statp" "const union res_sockaddr_union *set" "int cnt" -.Ft void -.Fn res_ndestroy "res_state statp" -.Ft int -.Fn dn_comp "const char *exp_dn" "u_char *comp_dn" "int length" "u_char **dnptrs" "u_char **lastdnptr" -.Ft int -.Fn dn_expand "const u_char *msg" "const u_char *eomorig" "const u_char *comp_dn" "char *exp_dn" "int length" -.\" .Ft "const char *" -.\" .Fn hstrerror "int err" -.Ss DEPRECATED -.In sys/types.h -.In netinet/in.h -.In arpa/nameser.h -.In resolv.h -.In res_update.h -.Ft int -.Fn res_init "void" -.Ft int -.Fn res_isourserver "const struct sockaddr_in *addr" -.Ft int -.Fn fp_nquery "const u_char *msg" "int msglen" "FILE *fp" -.Ft void -.Fn p_query "const u_char *msg" "FILE *fp" -.Ft "const char *" -.Fn hostalias "const char *name" -.Ft int -.Fn res_query "const char *dname" "int class" "int type" "u_char *answer" "int anslen" -.Ft int -.Fn res_search "const char *dname" "int class" "int type" "u_char *answer" "int anslen" -.Ft int -.Fn res_querydomain "const char *name" "const char *domain" "int class" "int type" "u_char *answer" "int anslen" -.Ft int -.Fo res_mkquery -.Fa "int op" -.Fa "const char *dname" -.Fa "int class" -.Fa "int type" -.Fa "const char *data" -.Fa "int datalen" -.Fa "struct rrec *newrr" -.Fa "u_char *buf" -.Fa "int buflen" -.Fc -.Ft int -.Fn res_send "const u_char *msg" "int msglen" "u_char *answer" "int anslen" -.Ft int -.Fn res_update "ns_updrec *rrecp_in" -.Ft void -.Fn res_close "void" -.\" .Ft void -.\" .Fn herror "const char *s" -.Sh DESCRIPTION -These routines are used for making, sending and interpreting -query and reply messages with Internet domain name servers. -.Pp -State information is kept in -.Fa statp -and is used to control the behavior of these functions. -.Fa statp -should be set to all zeros prior to the first call to any of these functions. -.Pp -The functions -.Fn res_init , -.Fn res_isourserver , -.Fn fp_nquery , -.Fn p_query , -.Fn hostalias , -.Fn res_query , -.Fn res_search , -.Fn res_querydomain , -.Fn res_mkquery , -.Fn res_send , -.Fn res_update , -.Fn res_close -.\" and -.\" .Fn herror -are deprecated and are supplied for compatability with old source -code. -They use global configuration and state information that is -kept in the structure -.Ft _res -rather than that referenced through -.Ft statp . -.Pp -Most of the values in -.Ft statp -and -.Ft _res -are initialized on the first call to -.Fn res_ninit -/ -.Fn res_init -to reasonable defaults and can be ignored. -Options -stored in -.Ft statp->options -/ -.Ft _res.options -are defined in -.Pa resolv.h -and are as follows. -Options are stored as a simple bit mask containing the bitwise -.Dq OR -of the options enabled. -.Bl -tag -width "RES_USE_INET6" -.It Dv RES_INIT -True if the initial name server address and default domain name are -initialized (i.e., -.Fn res_ninit -/ -.Fn res_init -has been called). -.It Dv RES_DEBUG -Print debugging messages. -.It Dv RES_AAONLY -Accept authoritative answers only. -Should continue until it finds an authoritative answer or finds an error. -Currently this is not implemented. -.It Dv RES_USEVC -Use TCP connections for queries instead of UDP datagrams. -.It Dv RES_STAYOPEN -Used with -.Dv RES_USEVC -to keep the TCP connection open between queries. -This is useful only in programs that regularly do many queries. -UDP should be the normal mode used. -.It Dv RES_IGNTC -Ignore truncation errors, i.e., don't retry with TCP. -.It Dv RES_RECURSE -Set the recursion-desired bit in queries. -This is the default. -(\c -.Fn res_nsend -/ -.Fn res_send -does not do iterative queries and expects the name server -to handle recursion.) -.It Dv RES_DEFNAMES -If set, -.Fn res_nsearch -/ -.Fn res_search -will append the default domain name to single-component names -(those that do not contain a dot). -This option is enabled by default. -.It Dv RES_DNSRCH -If this option is set, -.Fn res_nsearch -/ -.Fn res_search -will search for host names in the current domain and in parent domains; see -.Xr hostname 7 . -This is used by the standard host lookup routine -.Xr gethostbyname 3 . -This option is enabled by default. -.It Dv RES_USE_INET6 -Enables support for IPv6-only applications. -This causes IPv4 addresses to be returned as an IPv4 mapped address. -For example, 10.1.1.1 will be returned as ::ffff:10.1.1.1. -The option is meaningful with certain kernel configuration only. -.It Dv RES_USE_EDNS0 -Enables support for OPT pseudo-RR for EDNS0 extension. -With the option, resolver code will attach OPT pseudo-RR into DNS queries, -to inform of our receive buffer size. -The option will allow DNS servers to take advantage of non-default receive -buffer size, and to send larger replies. -DNS query packets with EDNS0 extension is not compatible with -non-EDNS0 DNS servers. -.It Dv RES_NOALIASES -This option turns off the user level aliasing feature controlled by -the -.Ev HOSTALIASES -environment variable. -Network daemons should set this option. -.It Dv RES_ROTATE -This options causes the -.Fn res_nsend -/ -.Fn res_send -to rotate the list of nameservers in -.Fa statp->nsaddr_list -/ -.Fa _res.nsaddr_list . -.It Dv RES_KEEPTSIG -This option causes -.Fn res_nsendsigned -to leave the message unchanged after TSIG verification; otherwise the TSIG -record would be removed and the header updated. -.It Dv RES_NOTLDQUERY -This option causes -.Fn res_nsearch -to not attempt to resolve an unqualified name as if it were a top level -domain (TLD). -This option can cause problems if the site has "localhost" as a TLD rather -than having localhost on one or more elements of the search list. -This option has no effect if neither -.Dv RES_DEFNAMES -or -.Dv RES_DNSRCH -is set. -.El -.Pp -The -.Fn res_ninit -/ -.Fn res_init -routine -reads the configuration file (if any; see -.Xr resolv.conf 5 ) -to get the default domain name, search list and -the Internet address of the local name server(s). -If no server is configured, the host running the resolver is tried. -The current domain name is defined by the hostname -if not specified in the configuration file; -it can be overridden by the environment variable -.Ev LOCALDOMAIN . -This environment variable may contain several blank-separated -tokens if you wish to override the -.Fa search list -on a per-process basis. -This is similar to the -.Fa search -command in the configuration file. -Another environment variable -.Ev RES_OPTIONS -can be set to override certain internal resolver options which are otherwise -set by changing fields in the -.Ft statp -/ -.Ft _res -structure or are inherited from the configuration file's -.Fa options -command. -The syntax of the -.Ev RES_OPTIONS -environment variable is explained in -.Xr resolv.conf 5 . -Initialization normally occurs on the first call -to one of the other resolver routines. -.Pp -In -.Nx -the initialization code also sets up a -.Xr kqueue 2 -and creates a -.Xr kevent 2 -watching a file descriptor that points to the resolver file. -Every resolver function calls the internal function -.Fn __res_check -which checks for a new -.Xr kevent 2 -related to the -.Xr resolv.conf 5 -file, and reloads the file if necessary. -This does not work if the file is accessed through a symlink and the symlink -changes to point to a different file. -To fix the symlink issue one could add a system call per resolver call to -get the current time, and reload every so often. -This is not done currently, but it is under consideration. -.Pp -The memory referred to by -.Ft statp -must be set to all zeros prior to the first call to -.Fn res_ninit . -.Fn res_ndestroy -should be call to free memory allocated by -.Fn res_ninit -after last use. -.Pp -The -.Fn res_nquery -/ -.Fn res_query -functions provides interfaces to the server query mechanism. -They constructs a query, sends it to the local server, -awaits a response, and makes preliminary checks on the reply. -The query requests information of the specified -.Fa type -and -.Fa class -for the specified fully-qualified domain name -.Fa dname . -The reply message is left in the -.Fa answer -buffer with length -.Fa anslen -supplied by the caller. -.Fn res_nquery -/ -.Fn res_query -return \-1 on error or the length of the answer. -.Pp -The -.Fn res_nsearch -/ -.Fn res_search -routines make a query and awaits a response like -.Fn res_nquery -/ -.Fn res_query , -but in addition, it implements the default and search rules -controlled by the -.Dv RES_DEFNAMES -and -.Dv RES_DNSRCH -options. -It returns the length of the first successful reply which is stored in -.Ft answer -or \-1 on error. -.Pp -The remaining routines are lower-level routines used by -.Fn res_nquery -/ -.Fn res_query . -The -.Fn res_nmkquery -/ -.Fn res_mkquery -functions -constructs a standard query message and places it in -.Fa buf . -It returns the size of the query, or \-1 if the query is -larger than -.Fa buflen . -The query type -.Fa op -is usually -.Dv QUERY , -but can be any of the query types defined in -.Aq Pa arpa/nameser.h . -The domain name for the query is given by -.Fa dname . -.Fa newrr -is currently unused but is intended for making update messages. -.Pp -The -.Fn res_nsend -/ -.Fn res_send -/ -.Fn res_nsendsigned -routines -sends a pre-formatted query and returns an answer. -It will call -.Fn res_ninit -/ -.Fn res_init -if -.Dv RES_INIT -is not set, send the query to the local name server, and -handle timeouts and retries. -Additionally, -.Fn res_nsendsigned -will use TSIG signatures to add authentication to the query and verify the -response. -In this case, only one nameserver will be contacted. -The length of the reply message is returned, or \-1 if there were errors. -.Pp -.Fn res_nquery -/ -.Fn res_query , -.Fn res_nsearch -/ -.Fn res_search -and -.Fn res_nsend -/ -.Fn res_send -return a length that may be bigger than -.Fa anslen . -In that case the query should be retried with a bigger buffer. -NOTE the answer to the second query may be larger still so supplying -a buffer that bigger that the answer returned by the previous -query is recommended. -.Pp -.Fa answer -MUST be big enough to receive a maximum UDP response from the server or -parts of the answer will be silently discarded. -The default maximum UDP response size is 512 bytes. -.Pp -The function -.Fn res_ourserver_p -returns true when -.Fa inp -is one of the servers in -.Fa statp->nsaddr_list -/ -.Fa _res.nsaddr_list . -.Pp -The functions -.Fn fp_nquery -/ -.Fn p_query -print out the query and any answer in -.Fa msg -on -.Fa fp . -.Fn p_query -is equivalent to -.Fn fp_nquery -with -.Fa msglen -set to 512. -.Pp -The function -.Fn fp_resstat -prints out the active flag bits in -.Fa statp->options -preceeded by the text ";; res options:" on -.Fa file . -.Pp -The functions -.Fn res_hostalias -/ -.Fn hostalias -lookup up name in the file referred to by the -.Ev HOSTALIASES -files return a fully qualified hostname if found or NULL if -not found or an error occurred. -.Fn res_hostalias -uses -.Fa buf -to store the result in, -.Fn hostalias -uses a static buffer. -.Pp -The functions -.Fn res_getservers -and -.Fn res_setservers -are used to get and set the list of server to be queried. -.Pp -The functions -.Fn res_nupdate -/ -.Fn res_update -take a list of ns_updrec -.Fa rrecp_in . -Identifies the containing zone for each record and groups the records -according to containing zone maintaining in zone order then sends and update -request to the servers for these zones. -The number of zones updated is returned or \-1 on error. -Note that -.Fn res_nupdate -will perform TSIG authenticated dynamic update operations if the key is not -NULL. -.Pp -The function -.Fn res_findzonecut -discovers the closest enclosing zone cut for a specified domain name, -and finds the IP addresses of the zone's master servers. -.Pp -The functions -.Fn res_nmkupdate -/ -.Fn res_mkupdate -take a linked list of ns_updrec -.Fa rrecp_in -and construct a UPDATE message in -.Fa buf . -.Fn res_nmkupdate -/ -.Fn res_mkupdate -return the length of the constructed message on no error or one of the -following error values. -.Bl -inset -width "-5" -.It \-1 -An error occurred parsing -.Fa rrecp_in . -.It \-2 -The buffer -.Fa buf -was too small. -.It \-3 -The first record was not a zone section or there was a section order problem. -The section order is S_ZONE, S_PREREQ and S_UPDATE. -.It \-4 -A number overflow occurred. -.It \-5 -Unknown operation or no records. -.El -.Pp -The functions -.Fn res_nclose -/ -.Fn res_close -close any open files referenced through -.Fa statp -/ -.Fa _res . -.Pp -The function -.Fn res_ndestroy -calls -.Fn res_nclose -then frees any memory allocated by -.Fn res_ninit . -.Pp -The -.Fn dn_comp -function -compresses the domain name -.Fa exp_dn -and stores it in -.Fa comp_dn . -The size of the compressed name is returned or \-1 if there were errors. -The size of the array pointed to by -.Fa comp_dn -is given by -.Fa length . -The compression uses -an array of pointers -.Fa dnptrs -to previously-compressed names in the current message. -The first pointer points to -the beginning of the message and the list ends with -.Dv NULL . -The limit to the array is specified by -.Fa lastdnptr . -A side effect of -.Fn dn_comp -is to update the list of pointers for labels inserted into the message -as the name is compressed. -If -.Fa dnptr -is -.Dv NULL , -names are not compressed. -If -.Fa lastdnptr -is -.Dv NULL , -the list of labels is not updated. -.Pp -The -.Fn dn_expand -entry expands the compressed domain name -.Fa comp_dn -to a full domain name. -The compressed name is contained in a query or reply message; -.Fa msg -is a pointer to the beginning of the message. -.Fa eomorig -is a pointer to the first location after the message. -The uncompressed name is placed in the buffer indicated by -.Fa exp_dn -which is of size -.Fa length . -The size of compressed name is returned or \-1 if there was an error. -.Pp -The variables -.Ft statp->res_h_errno -/ -.Ft _res.res_h_errno -and external variable -.Ft h_errno -is set whenever an error occurs during resolver operation. -The following -definitions are given in -.Aq Pa netdb.h : -.Bd -literal -#define NETDB_INTERNAL -1 -/* see errno */ -#define NETDB_SUCCESS 0 -/* no problem */ -#define HOST_NOT_FOUND 1 -/* Authoritative Answer Host not found */ -#define TRY_AGAIN 2 -/* Non-Authoritative not found, or SERVFAIL */ -#define NO_RECOVERY 3 -/* Non-Recoverable: FORMERR, REFUSED, NOTIMP */ -#define NO_DATA 4 -/* Valid name, no data for requested type */ -.Ed -.\" .Pp -.\" The -.\" .Fn herror -.\" function writes a message to the diagnostic output consisting of the string -.\" parameter -.\" .Fa s , -.\" the constant string ": ", and a message corresponding to the value of -.\" .Ft h_errno . -.\" .Pp -.\" The -.\" .Fn hstrerror -.\" function returns a string which is the message text corresponding to the -.\" value of the -.\" .Fa err -.\" parameter. -.Pp -The following functions are only in -.Dv libresolv : -.Fn res_findzonecut , -.Fn res_nmkupdate , -.Fn res_nsendsigned , -and -.Fn res_nupdate . -All the rest are in both -.Dv libc -and -.Dv libresolv . -.Sh FILES -.Bl -tag -width "/etc/resolv.conf " -.It Pa /etc/resolv.conf -The configuration file, see -.Xr resolv.conf 5 . -.El -.Sh SEE ALSO -.Xr getaddrinfo 3 , -.Xr gethostbyaddr 3 , -.Xr gethostbyname 3 , -.Xr getnameinfo 3 , -.Xr resolv.conf 5 , -.Xr hostname 7 , -.Xr named 8 -.Pp -.%T RFC 974 , -.%T RFC 1032 , -.%T RFC 1033 , -.%T RFC 1034 , -.%T RFC 1035 , -.%T RFC 1535 -.Rs -.%T "Name Server Operations Guide for BIND" -.Re -.Sh HISTORY -The -.Nm -function appeared in -.Bx 4.3 . diff --git a/lib/libc/net/rthdr.c b/lib/libc/net/rthdr.c deleted file mode 100644 index 9517cc0cc..000000000 --- a/lib/libc/net/rthdr.c +++ /dev/null @@ -1,459 +0,0 @@ -/* $NetBSD: rthdr.c,v 1.18 2012/03/13 21:13:42 christos Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: rthdr.c,v 1.18 2012/03/13 21:13:42 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include - -#include -#include - -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(inet6_rthdr_add,_inet6_rthdr_add) -__weak_alias(inet6_rthdr_getaddr,_inet6_rthdr_getaddr) -__weak_alias(inet6_rthdr_getflags,_inet6_rthdr_getflags) -__weak_alias(inet6_rthdr_init,_inet6_rthdr_init) -__weak_alias(inet6_rthdr_lasthop,_inet6_rthdr_lasthop) -__weak_alias(inet6_rthdr_segments,_inet6_rthdr_segments) -__weak_alias(inet6_rthdr_space,_inet6_rthdr_space) -__weak_alias(inet6_rth_space, _inet6_rth_space) -__weak_alias(inet6_rth_init, _inet6_rth_init) -__weak_alias(inet6_rth_add, _inet6_rth_add) -__weak_alias(inet6_rth_reverse, _inet6_rth_reverse) -__weak_alias(inet6_rth_segments, _inet6_rth_segments) -__weak_alias(inet6_rth_getaddr, _inet6_rth_getaddr) -#endif - -/* - * RFC2292 API - */ - -size_t -inet6_rthdr_space(int type, int seg) -{ - switch (type) { - case IPV6_RTHDR_TYPE_0: - if (seg < 1 || seg > 23) - return (0); - return (CMSG_SPACE(sizeof(struct in6_addr) * seg + - sizeof(struct ip6_rthdr0))); - default: - return (0); - } -} - -struct cmsghdr * -inet6_rthdr_init(void *bp, int type) -{ - struct cmsghdr *ch; - struct ip6_rthdr *rthdr; - - _DIAGASSERT(bp != NULL); - - ch = (struct cmsghdr *)bp; - rthdr = (struct ip6_rthdr *)(void *)CMSG_DATA(ch); - - ch->cmsg_level = IPPROTO_IPV6; - ch->cmsg_type = IPV6_RTHDR; - - switch (type) { - case IPV6_RTHDR_TYPE_0: -#ifdef COMPAT_RFC2292 - ch->cmsg_len = CMSG_LEN(sizeof(struct ip6_rthdr0) - - sizeof(struct in6_addr)); -#else - ch->cmsg_len = CMSG_LEN(sizeof(struct ip6_rthdr0)); -#endif - (void)memset(rthdr, 0, sizeof(struct ip6_rthdr0)); - rthdr->ip6r_type = IPV6_RTHDR_TYPE_0; - return (ch); - default: - return (NULL); - } -} - -int -inet6_rthdr_add(struct cmsghdr *cmsg, const struct in6_addr *addr, u_int flags) -{ - struct ip6_rthdr *rthdr; - - _DIAGASSERT(cmsg != NULL); - _DIAGASSERT(addr != NULL); - - rthdr = (struct ip6_rthdr *)(void *)CMSG_DATA(cmsg); - - switch (rthdr->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - { - size_t len; - struct ip6_rthdr0 *rt0 = (struct ip6_rthdr0 *)(void *)rthdr; - if (flags != IPV6_RTHDR_LOOSE && flags != IPV6_RTHDR_STRICT) - return (-1); - if (rt0->ip6r0_segleft == 23) - return (-1); - if (flags != IPV6_RTHDR_LOOSE) - return (-1); - rt0->ip6r0_segleft++; - (void)memcpy(((caddr_t)(void *)rt0) + - ((rt0->ip6r0_len + 1) << 3), addr, sizeof(struct in6_addr)); - rt0->ip6r0_len += sizeof(struct in6_addr) >> 3; - len = CMSG_LEN((rt0->ip6r0_len + 1) << 3); - _DIAGASSERT(__type_fit(socklen_t, len)); - cmsg->cmsg_len = (socklen_t)len; - break; - } - default: - return (-1); - } - - return (0); -} - -int -inet6_rthdr_lasthop(struct cmsghdr *cmsg, unsigned int flags) -{ - struct ip6_rthdr *rthdr; - - _DIAGASSERT(cmsg != NULL); - - rthdr = (struct ip6_rthdr *)(void *)CMSG_DATA(cmsg); - - switch (rthdr->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - { - struct ip6_rthdr0 *rt0 = (struct ip6_rthdr0 *)(void *)rthdr; - if (rt0->ip6r0_segleft > 23) - return (-1); - if (flags != IPV6_RTHDR_LOOSE) - return (-1); - break; - } - default: - return (-1); - } - - return (0); -} - -#if 0 -int -inet6_rthdr_reverse(const struct cmsghdr *in, struct cmsghdr *out) -{ - - return (-1); -} -#endif - -int -inet6_rthdr_segments(const struct cmsghdr *cmsg) -{ - const struct ip6_rthdr *rthdr; - - _DIAGASSERT(cmsg != NULL); - - rthdr = __UNCONST(CCMSG_DATA(cmsg)); - - switch (rthdr->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - { - const struct ip6_rthdr0 *rt0 = - (const struct ip6_rthdr0 *)(const void *)rthdr; - size_t len; - - if (rt0->ip6r0_len % 2 || 46 < rt0->ip6r0_len) - return (-1); - - len = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr); - _DIAGASSERT(__type_fit(int, len)); - return (int)len; - } - - default: - return (-1); - } -} - -struct in6_addr * -inet6_rthdr_getaddr(struct cmsghdr *cmsg, int idx) -{ - struct ip6_rthdr *rthdr; - - _DIAGASSERT(cmsg != NULL); - - rthdr = (struct ip6_rthdr *)(void *)CMSG_DATA(cmsg); - - switch (rthdr->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - { - struct ip6_rthdr0 *rt0 = (struct ip6_rthdr0 *)(void *)rthdr; - int naddr; - size_t len; - - if (rt0->ip6r0_len % 2 || 46 < rt0->ip6r0_len) - return NULL; - len = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr); - _DIAGASSERT(__type_fit(int, len)); - naddr = (int)len; - if (idx <= 0 || naddr < idx) - return NULL; -#ifdef COMPAT_RFC2292 - return ((struct in6_addr *)(void *)(rt0 + 1)) + idx - 1; -#else - return ((struct in6_addr *)(void *)(rt0 + 1)) + idx; -#endif - } - - default: - return NULL; - } -} - -int -inet6_rthdr_getflags(const struct cmsghdr *cmsg, int idx) -{ - const struct ip6_rthdr *rthdr; - - _DIAGASSERT(cmsg != NULL); - - rthdr = __UNCONST(CCMSG_DATA(cmsg)); - - switch (rthdr->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - { - const struct ip6_rthdr0 *rt0 = (const struct ip6_rthdr0 *) - (const void *)rthdr; - int naddr; - size_t len; - - if (rt0->ip6r0_len % 2 || 46 < rt0->ip6r0_len) - return (-1); - len = (rt0->ip6r0_len * 8) / sizeof(struct in6_addr); - _DIAGASSERT(__type_fit(int, len)); - naddr = (int)len; - if (idx < 0 || naddr < idx) - return (-1); - return IPV6_RTHDR_LOOSE; - } - - default: - return (-1); - } -} - -/* - * RFC3542 (2292bis) API - */ - -socklen_t -inet6_rth_space(int type, int segments) -{ - switch (type) { - case IPV6_RTHDR_TYPE_0: - return (((segments * 2) + 1) << 3); - default: - return (0); /* type not suppported */ - } -} - -void * -inet6_rth_init(void *bp, socklen_t bp_len, int type, int segments) -{ - struct ip6_rthdr *rth; - struct ip6_rthdr0 *rth0; - - _DIAGASSERT(bp != NULL); - - rth = (struct ip6_rthdr *)bp; - - switch (type) { - case IPV6_RTHDR_TYPE_0: - /* length validation */ - if (bp_len < inet6_rth_space(IPV6_RTHDR_TYPE_0, segments)) - return (NULL); - - memset(bp, 0, bp_len); - rth0 = (struct ip6_rthdr0 *)(void *)rth; - rth0->ip6r0_len = segments * 2; - rth0->ip6r0_type = IPV6_RTHDR_TYPE_0; - rth0->ip6r0_segleft = 0; - rth0->ip6r0_reserved = 0; - break; - default: - return (NULL); /* type not supported */ - } - - return (bp); -} - -int -inet6_rth_add(void *bp, const struct in6_addr *addr) -{ - struct ip6_rthdr *rth; - struct ip6_rthdr0 *rth0; - struct in6_addr *nextaddr; - - _DIAGASSERT(bp != NULL); - - rth = (struct ip6_rthdr *)bp; - - switch (rth->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - rth0 = (struct ip6_rthdr0 *)(void *)rth; - nextaddr = (struct in6_addr *)(void *)(rth0 + 1) - + rth0->ip6r0_segleft; - *nextaddr = *addr; - rth0->ip6r0_segleft++; - break; - default: - return (-1); /* type not supported */ - } - - return (0); -} - -int -inet6_rth_reverse(const void *in, void *out) -{ - const struct ip6_rthdr *rth_in; - const struct ip6_rthdr0 *rth0_in; - struct ip6_rthdr0 *rth0_out; - int i, segments; - - _DIAGASSERT(in != NULL); - _DIAGASSERT(out != NULL); - - rth_in = (const struct ip6_rthdr *)in; - - switch (rth_in->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - rth0_in = (const struct ip6_rthdr0 *)in; - rth0_out = (struct ip6_rthdr0 *)out; - - /* parameter validation XXX too paranoid? */ - if (rth0_in->ip6r0_len % 2) - return (-1); - segments = rth0_in->ip6r0_len / 2; - - /* we can't use memcpy here, since in and out may overlap */ - memmove((void *)rth0_out, (const void *)rth0_in, - (unsigned int)(((rth0_in->ip6r0_len) + 1) << 3)); - rth0_out->ip6r0_segleft = segments; - - /* reverse the addresses */ - for (i = 0; i < segments / 2; i++) { - struct in6_addr addr_tmp, *addr1, *addr2; - - addr1 = (struct in6_addr *)(void *)(rth0_out + 1) + i; - addr2 = (struct in6_addr *)(void *)(rth0_out + 1) + - (segments - i - 1); - addr_tmp = *addr1; - *addr1 = *addr2; - *addr2 = addr_tmp; - } - - break; - default: - return (-1); /* type not supported */ - } - - return (0); -} - -int -inet6_rth_segments(const void *bp) -{ - const struct ip6_rthdr *rh; - const struct ip6_rthdr0 *rh0; - unsigned int addrs; - - _DIAGASSERT(bp != NULL); - - rh = (const struct ip6_rthdr *)bp; - - switch (rh->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - rh0 = (const struct ip6_rthdr0 *)bp; - - /* - * Validation for a type-0 routing header. - * Is this too strict? - */ - if ((rh0->ip6r0_len % 2) != 0 || - (addrs = (rh0->ip6r0_len / 2)) < rh0->ip6r0_segleft) - return (-1); - - return (addrs); - default: - return (-1); /* unknown type */ - } -} - -struct in6_addr * -inet6_rth_getaddr(const void *bp, int idx) -{ - const struct ip6_rthdr *rh; - const struct ip6_rthdr0 *rh0; - unsigned int addrs; - - _DIAGASSERT(bp != NULL); - - rh = (const struct ip6_rthdr *)bp; - - switch (rh->ip6r_type) { - case IPV6_RTHDR_TYPE_0: - rh0 = (const struct ip6_rthdr0 *)bp; - - /* - * Validation for a type-0 routing header. - * Is this too strict? - */ - if ((rh0->ip6r0_len % 2) != 0 || - (addrs = (rh0->ip6r0_len / 2)) < rh0->ip6r0_segleft) - return (NULL); - - if (idx < 0 || addrs <= (unsigned int)idx) - return (NULL); - - return (((struct in6_addr *)(void *)__UNCONST(rh0 + 1)) + idx); - default: - return (NULL); /* unknown type */ - } -} diff --git a/lib/libc/net/send.c b/lib/libc/net/send.c deleted file mode 100644 index 8cf95d8f2..000000000 --- a/lib/libc/net/send.c +++ /dev/null @@ -1,56 +0,0 @@ -/* $NetBSD: send.c,v 1.10 2012/03/20 17:44:18 matt Exp $ */ - -/* - * Copyright (c) 1988, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)send.c 8.2 (Berkeley) 2/21/94"; -#else -__RCSID("$NetBSD: send.c,v 1.10 2012/03/20 17:44:18 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#include - -#ifdef __weak_alias -__weak_alias(send, _send) -#endif - -ssize_t -send(int s, const void *msg, size_t len, int flags) -{ - - return (sendto(s, msg, len, flags, NULL, 0)); -} diff --git a/lib/libc/net/servent.h b/lib/libc/net/servent.h deleted file mode 100644 index c7dfcc214..000000000 --- a/lib/libc/net/servent.h +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: servent.h,v 1.4 2010/04/25 00:54:46 joerg Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include - -struct servent_data { - FILE *plainfile; - struct cdbr *cdb; - struct servent serv; - char **aliases; - size_t maxaliases; - int flags; -#define _SV_STAYOPEN 1 -#define _SV_CDB 2 -#define _SV_PLAINFILE 4 -#define _SV_FIRST 8 - uint32_t cdb_index; - uint8_t *cdb_buf; - size_t cdb_buf_len; - char *line; - void *dummy; -}; - -struct servent *getservent_r(struct servent *, struct servent_data *); -struct servent *getservbyname_r(const char *, const char *, - struct servent *, struct servent_data *); -struct servent *getservbyport_r(int, const char *, - struct servent *, struct servent_data *); -void setservent_r(int, struct servent_data *); -void endservent_r(struct servent_data *); - -int _servent_open(struct servent_data *); -void _servent_close(struct servent_data *); -int _servent_getline(struct servent_data *); -struct servent *_servent_parseline(struct servent_data *, struct servent *); -struct servent *_servent_parsedb(struct servent_data *, struct servent *, - const uint8_t *, size_t); diff --git a/lib/libc/net/sethostent.c b/lib/libc/net/sethostent.c deleted file mode 100644 index b5f7ac8f2..000000000 --- a/lib/libc/net/sethostent.c +++ /dev/null @@ -1,292 +0,0 @@ -/* $NetBSD: sethostent.c,v 1.20 2014/03/17 13:24:23 christos Exp $ */ - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)sethostent.c 8.1 (Berkeley) 6/4/93"; -static char rcsid[] = "Id: sethostent.c,v 8.5 1996/09/28 06:51:07 vixie Exp "; -#else -__RCSID("$NetBSD: sethostent.c,v 1.20 2014/03/17 13:24:23 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "hostent.h" - -#ifdef __weak_alias -__weak_alias(sethostent,_sethostent) -__weak_alias(endhostent,_endhostent) -#endif - -#ifndef _REENTRANT -void res_close(void); -#endif - -static struct hostent *_hf_gethtbyname2(const char *, int, struct getnamaddr *); - -void -/*ARGSUSED*/ -sethostent(int stayopen) -{ -#ifndef _REENTRANT - if ((_res.options & RES_INIT) == 0 && res_init() == -1) - return; - if (stayopen) - _res.options |= RES_STAYOPEN | RES_USEVC; -#endif - sethostent_r(&_h_file); -} - -void -endhostent(void) -{ -#ifndef _REENTRANT - _res.options &= ~(RES_STAYOPEN | RES_USEVC); - res_close(); -#endif - endhostent_r(&_h_file); -} -static const char *_h_hosts = _PATH_HOSTS; - -void -_hf_sethostsfile(const char *f) { - _h_hosts = f; -} - -void -sethostent_r(FILE **hf) -{ - if (!*hf) - *hf = fopen(_h_hosts, "re"); - else - rewind(*hf); -} - -void -endhostent_r(FILE **hf) -{ - if (*hf) { - (void)fclose(*hf); - *hf = NULL; - } -} - -/*ARGSUSED*/ -int -_hf_gethtbyname(void *rv, void *cb_data, va_list ap) -{ - struct hostent *hp; - const char *name; - int af; - struct getnamaddr *info = rv; - - _DIAGASSERT(rv != NULL); - - name = va_arg(ap, char *); - /* NOSTRICT skip string len */(void)va_arg(ap, int); - af = va_arg(ap, int); - -#if 0 - { - res_state res = __res_get_state(); - if (res == NULL) - return NS_NOTFOUND; - if (res->options & RES_USE_INET6) - hp = _hf_gethtbyname2(name, AF_INET6, info); - else - hp = NULL; - if (hp == NULL) - hp = _hf_gethtbyname2(name, AF_INET, info); - __res_put_state(res); - } -#else - hp = _hf_gethtbyname2(name, af, info); -#endif - if (hp == NULL) { - *info->he = HOST_NOT_FOUND; - return NS_NOTFOUND; - } - return NS_SUCCESS; -} - -struct hostent * -_hf_gethtbyname2(const char *name, int af, struct getnamaddr *info) -{ - struct hostent *hp, hent; - char *buf, *ptr; - size_t len, anum, num, i; - FILE *hf; - char *aliases[MAXALIASES]; - char *addr_ptrs[MAXADDRS]; - - _DIAGASSERT(name != NULL); - - hf = NULL; - sethostent_r(&hf); - if (hf == NULL) { - errno = EINVAL; - *info->he = NETDB_INTERNAL; - return NULL; - } - - if ((ptr = buf = malloc(len = info->buflen)) == NULL) { - *info->he = NETDB_INTERNAL; - return NULL; - } - - anum = 0; /* XXX: gcc */ - hent.h_name = NULL; /* XXX: gcc */ - hent.h_addrtype = 0; /* XXX: gcc */ - hent.h_length = 0; /* XXX: gcc */ - - for (num = 0; num < MAXADDRS;) { - info->hp->h_addrtype = af; - info->hp->h_length = 0; - - hp = gethostent_r(hf, info->hp, info->buf, info->buflen, - info->he); - if (hp == NULL) - break; - - if (strcasecmp(hp->h_name, name) != 0) { - char **cp; - for (cp = hp->h_aliases; *cp != NULL; cp++) - if (strcasecmp(*cp, name) == 0) - break; - if (*cp == NULL) continue; - } - - if (num == 0) { - hent.h_addrtype = af = hp->h_addrtype; - hent.h_length = hp->h_length; - - HENT_SCOPY(hent.h_name, hp->h_name, ptr, len); - for (anum = 0; hp->h_aliases[anum]; anum++) { - if (anum >= __arraycount(aliases)) - goto nospc; - HENT_SCOPY(aliases[anum], hp->h_aliases[anum], - ptr, len); - } - ptr = (void *)ALIGN(ptr); - if ((size_t)(ptr - buf) >= info->buflen) - goto nospc; - } - - if (num >= __arraycount(addr_ptrs)) - goto nospc; - HENT_COPY(addr_ptrs[num], hp->h_addr_list[0], hp->h_length, ptr, - len); - num++; - } - endhostent_r(&hf); - - if (num == 0) { - *info->he = HOST_NOT_FOUND; - free(buf); - return NULL; - } - - hp = info->hp; - ptr = info->buf; - len = info->buflen; - - hp->h_addrtype = hent.h_addrtype; - hp->h_length = hent.h_length; - - HENT_ARRAY(hp->h_aliases, anum, ptr, len); - HENT_ARRAY(hp->h_addr_list, num, ptr, len); - - for (i = 0; i < num; i++) - HENT_COPY(hp->h_addr_list[i], addr_ptrs[i], hp->h_length, ptr, - len); - hp->h_addr_list[num] = NULL; - - HENT_SCOPY(hp->h_name, hent.h_name, ptr, len); - - for (i = 0; i < anum; i++) - HENT_SCOPY(hp->h_aliases[i], aliases[i], ptr, len); - hp->h_aliases[anum] = NULL; - - free(buf); - return hp; -nospc: - *info->he = NETDB_INTERNAL; - free(buf); - errno = ENOSPC; - return NULL; -} - -/*ARGSUSED*/ -int -_hf_gethtbyaddr(void *rv, void *cb_data, va_list ap) -{ - struct hostent *hp; - const unsigned char *addr; - struct getnamaddr *info = rv; - FILE *hf; - - _DIAGASSERT(rv != NULL); - - addr = va_arg(ap, unsigned char *); - info->hp->h_length = va_arg(ap, int); - info->hp->h_addrtype = va_arg(ap, int); - - hf = NULL; - sethostent_r(&hf); - if (hf == NULL) { - *info->he = NETDB_INTERNAL; - return NS_UNAVAIL; - } - while ((hp = gethostent_r(hf, info->hp, info->buf, info->buflen, - info->he)) != NULL) - if (!memcmp(hp->h_addr_list[0], addr, (size_t)hp->h_length)) - break; - endhostent_r(&hf); - - if (hp == NULL) { - *info->he = HOST_NOT_FOUND; - return NS_NOTFOUND; - } - return NS_SUCCESS; -} diff --git a/lib/libc/net/sockatmark.3 b/lib/libc/net/sockatmark.3 deleted file mode 100644 index 58183f434..000000000 --- a/lib/libc/net/sockatmark.3 +++ /dev/null @@ -1,103 +0,0 @@ -.\" $NetBSD: sockatmark.3,v 1.9 2008/04/30 13:10:50 martin Exp $ -.\" -.\" Copyright (c) 2001 The NetBSD Foundation, Inc. -.\" All rights reserved. -.\" -.\" This code is derived from software contributed to The NetBSD Foundation -.\" by Klaus Klein. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS -.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED -.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS -.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -.\" POSSIBILITY OF SUCH DAMAGE. -.\" -.Dd May 15, 2003 -.Dt SOCKATMARK 3 -.Os -.Sh NAME -.Nm sockatmark -.Nd determine whether a socket is at the out-of-band mark -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In sys/socket.h -.Ft int -.Fn sockatmark "int s" -.Sh DESCRIPTION -The -.Nm sockatmark -function determines whether the socket referenced by the file descriptor -.Fa s -is at the out-of-band mark. -.Sh RETURN VALUES -If successful, the -.Nm sockatmark -function returns 1 to indicate that the socket is at an out-of-band mark; -0 is returned if there is no out-of-band mark or the mark is preceded -by in-band data. -Otherwise, -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -The -.Nm sockatmark -function will fail if: -.Bl -tag -width Er -.It Bq Er EBADF -The argument -.Fa s -is not a valid file descriptor. -.It Bq Er ENOTTY -The file descriptor -.Fa s -does not refer to a socket. -.El -.Sh SEE ALSO -.Xr ioctl 2 , -.Xr recv 2 , -.Xr socket 2 -.Rs -.%T "An Introductory 4.4BSD Interprocess Communication Tutorial" -.%A Stuart Sechrest -.Re -.Pq see Pa /usr/share/doc/psd/20.ipctut -.Rs -.%T "Advanced 4.4BSD IPC Tutorial" -.%A Samuel J. Leffler -.%A Robert S. Fabry -.%A William N. Joy -.%A Phil Lapsley -.%A Steve Miller -.%A Chris Torek -.Re -.Pq see Pa /usr/share/doc/psd/21.ipc -.Sh STANDARDS -The -.Nm sockatmark -function conforms to -.St -p1003.1-2001 . -.Sh HISTORY -The -.Nm sockatmark -function appeared in -.St -p1003.1g-2000 -as a replacement for the -.Dv SIOCATMARK -.Xr ioctl 2 -interface. diff --git a/lib/libc/net/sockatmark.c b/lib/libc/net/sockatmark.c deleted file mode 100644 index 40bedaa84..000000000 --- a/lib/libc/net/sockatmark.c +++ /dev/null @@ -1,55 +0,0 @@ -/* $NetBSD: sockatmark.c,v 1.3 2012/03/20 17:44:18 matt Exp $ */ - -/*- - * Copyright (c) 2001 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Klaus Klein. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: sockatmark.c,v 1.3 2012/03/20 17:44:18 matt Exp $"); -#endif - -#include "namespace.h" - -#include -#include - -#include - -int -sockatmark(int s) -{ - int val; - - _DIAGASSERT(s != -1); - - if (ioctl(s, SIOCATMARK, &val) == -1) - return (-1); - - return (val); -} diff --git a/lib/libc/net/vars6.c b/lib/libc/net/vars6.c deleted file mode 100644 index 09abc4c90..000000000 --- a/lib/libc/net/vars6.c +++ /dev/null @@ -1,57 +0,0 @@ -/* $NetBSD: vars6.c,v 1.7 2005/08/07 16:00:01 christos Exp $ */ - -/* - * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: vars6.c,v 1.7 2005/08/07 16:00:01 christos Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include -#include - -#ifdef __weak_alias -__weak_alias(in6addr_any, _in6addr_any) -__weak_alias(in6addr_loopback, _in6addr_loopback) -__weak_alias(in6addr_nodelocal_allnodes, _in6addr_nodelocal_allnodes) -__weak_alias(in6addr_linklocal_allnodes, _in6addr_linklocal_allnodes) -__weak_alias(in6addr_linklocal_allrouters, _in6addr_linklocal_allrouters) -#endif - -/* - * Definitions of some constant IPv6 addresses. - */ -const struct in6_addr in6addr_any = IN6ADDR_ANY_INIT; -const struct in6_addr in6addr_loopback = IN6ADDR_LOOPBACK_INIT; -const struct in6_addr in6addr_nodelocal_allnodes = IN6ADDR_NODELOCAL_ALLNODES_INIT; -const struct in6_addr in6addr_linklocal_allnodes = IN6ADDR_LINKLOCAL_ALLNODES_INIT; -const struct in6_addr in6addr_linklocal_allrouters = IN6ADDR_LINKLOCAL_ALLROUTERS_INIT; - diff --git a/lib/libc/nls/C.msg b/lib/libc/nls/C.msg deleted file mode 100644 index cdc7c6853..000000000 --- a/lib/libc/nls/C.msg +++ /dev/null @@ -1,258 +0,0 @@ -$set 1 -$ EPERM -1 Operation not permitted -$ ENOENT -2 No such file or directory -$ ESRCH -3 No such process -$ EINTR -4 Interrupted system call -$ EIO -5 Input/output error -$ ENXIO -6 Device not configured -$ E2BIG -7 Argument list too long -$ ENOEXEC -8 Exec format error -$ EBADF -9 Bad file descriptor -$ ECHILD -10 No child processes -$ EDEADLK -11 Resource deadlock avoided -$ ENOMEM -12 Cannot allocate memory -$ EACCES -13 Permission denied -$ EFAULT -14 Bad address -$ ENOTBLK -15 Block device required -$ EBUSY -16 Device busy -$ EEXIST -17 File exists -$ EXDEV -18 Cross-device link -$ ENODEV -19 Operation not supported by device -$ ENOTDIR -20 Not a directory -$ EISDIR -21 Is a directory -$ EINVAL -22 Invalid argument -$ ENFILE -23 Too many open files in system -$ EMFILE -24 Too many open files -$ ENOTTY -25 Inappropriate ioctl for device -$ ETXTBSY -26 Text file busy -$ EFBIG -27 File too large -$ ENOSPC -28 No space left on device -$ ESPIPE -29 Illegal seek -$ EROFS -30 Read-only file system -$ EMLINK -31 Too many links -$ EPIPE -32 Broken pipe -$ EDOM -33 Numerical argument out of domain -$ ERANGE -34 Result too large or too small -$ EAGAIN, EWOULDBLOCK -35 Resource temporarily unavailable -$ EINPROGRESS -36 Operation now in progress -$ EALREADY -37 Operation already in progress -$ ENOTSOCK -38 Socket operation on non-socket -$ EDESTADDRREQ -39 Destination address required -$ EMSGSIZE -40 Message too long -$ EPROTOTYPE -41 Protocol wrong type for socket -$ ENOPROTOOPT -42 Protocol option not available -$ EPROTONOSUPPORT -43 Protocol not supported -$ ESOCKTNOSUPPORT -44 Socket type not supported -$ EOPNOTSUPP -45 Operation not supported -$ EPFNOSUPPORT -46 Protocol family not supported -$ EAFNOSUPPORT -47 Address family not supported by protocol family -$ EADDRINUSE -48 Address already in use -$ EADDRNOTAVAIL -49 Can't assign requested address -$ ENETDOWN -50 Network is down -$ ENETUNREACH -51 Network is unreachable -$ ENETRESET -52 Network dropped connection on reset -$ ECONNABORTED -53 Software caused connection abort -$ ECONNRESET -54 Connection reset by peer -$ ENOBUFS -55 No buffer space available -$ EISCONN -56 Socket is already connected -$ ENOTCONN -57 Socket is not connected -$ ESHUTDOWN -58 Can't send after socket shutdown -$ ETOOMANYREFS -59 Too many references: can't splice -$ ETIMEDOUT -60 Connection timed out -$ ECONNREFUSED -61 Connection refused -$ ELOOP -62 Too many levels of symbolic links -$ ENAMETOOLONG -63 File name too long -$ EHOSTDOWN -64 Host is down -$ EHOSTUNREACH -65 No route to host -$ ENOTEMPTY -66 Directory not empty -$ EPROCLIM -67 Too many processes -$ EUSERS -68 Too many users -$ EDQUOT -69 Disc quota exceeded -$ ESTALE -70 Stale NFS file handle -$ EREMOTE -71 Too many levels of remote in path -$ EBADRPC -72 RPC struct is bad -$ ERPCMISMATCH -73 RPC version wrong -$ EPROGUNAVAIL -74 RPC prog. not avail -$ EPROGMISMATCH -75 Program version wrong -$ EPROCUNAVAIL -76 Bad procedure for program -$ ENOLCK -77 No locks available -$ ENOSYS -78 Function not implemented -$ EFTYPE -79 Inappropriate file type or format -$ EAUTH -80 Authentication error -$ ENEEDAUTH -81 Need authenticator -$ EIDRM -82 Identifier removed -$ ENOMSG -83 No message of desired type -$ EOVERFLOW -84 Value too large to be stored in data type -$ EILSEQ -85 Illegal byte sequence -$ ENOTSUP -86 Not supported -$ ECANCELED -87 Operation Canceled -$ EBADMSG -88 Bad or Corrupt message -$ ENODATA -89 No message available -$ ENOSR -90 No STREAM resources -$ ENOSTR -91 Not a STREAM -$ ETIME -92 STREAM ioctl timeout -$ ENOATTR -93 Attribute not found -$ EMULTIHOP -94 Multihop attempted -$ ENOLINK -95 Link has been severed -$ EPROTO -96 Protocol error -$set 2 -$ SIGHUP -1 Hangup -$ SIGINT -2 Interrupt -$ SIGQUIT -3 Quit -$ SIGILL -4 Illegal instruction -$ SIGTRAP -5 Trace/BPT trap -$ SIGABRT -6 Abort trap -$ SIGEMT -7 EMT trap -$ SIGFPE -8 Floating point exception -$ SIGKILL -9 Killed -$ SIGBUS -10 Bus error -$ SIGSEGV -11 Segmentation fault -$ SIGSYS -12 Bad system call -$ SIGPIPE -13 Broken pipe -$ SIGALRM -14 Alarm clock -$ SIGTERM -15 Terminated -$ SIGURG -16 Urgent I/O condition -$ SIGSTOP -17 Stopped (signal) -$ SIGTSTP -18 Stopped -$ SIGCONT -19 Continued -$ SIGCHLD -20 Child exited -$ SIGTTIN -21 Stopped (tty input) -$ SIGTTOU -22 Stopped (tty output) -$ SIGIO -23 I/O possible -$ SIGXCPU -24 Cputime limit exceeded -$ SIGXFSZ -25 Filesize limit exceeded -$ SIGVTALRM -26 Virtual timer expired -$ SIGPROF -27 Profiling timer expired -$ SIGWINCH -28 Window size changes -$ SIGINFO -29 Information request -$ SIGUSR1 -30 User defined signal 1 -$ SIGUSR2 -31 User defined signal 2 -$ SIGPWR -32 Power fail/restart diff --git a/lib/libc/nls/Makefile.inc b/lib/libc/nls/Makefile.inc deleted file mode 100644 index a505851a6..000000000 --- a/lib/libc/nls/Makefile.inc +++ /dev/null @@ -1,9 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.12 2013/08/19 08:03:34 joerg Exp $ - -.PATH: ${.CURDIR}/nls - -SRCS+= catclose.c catgets.c catopen.c -MAN+= catclose.3 catgets.3 catopen.3 - -CPPFLAGS.catopen.c+= -I${LIBCDIR}/citrus - diff --git a/lib/libc/nls/Pig.msg b/lib/libc/nls/Pig.msg deleted file mode 100644 index edff3cd69..000000000 --- a/lib/libc/nls/Pig.msg +++ /dev/null @@ -1,236 +0,0 @@ -$set 1 -$ EPERM -1 Operationway otnay ermittedpay -$ ENOENT -2 Onay uchsay ilefay orway irectoryday -$ ESRCH -3 Onay uchsay ocesspray -$ EINTR -4 Interruptedway ystemsay allcay -$ EIO -5 Inputway/outputway errorway -$ ENXIO -6 Eviceday otnay onfiguredcay -$ E2BIG -7 Argumentway istlay ootay onglay -$ ENOEXEC -8 Execway ormatfay errorway -$ EBADF -9 Adbay ilefay escriptorday -$ ECHILD -10 Onay ildchay ocessespray -$ EDEADLK -11 Esourceray eadlockday avoidedway -$ ENOMEM -12 Annotcay allocateway emorymay -$ EACCES -13 Ermissionpay eniedday -$ EFAULT -14 Adbay addressway -$ ENOTBLK -15 Ockblay eviceday equiredray -$ EBUSY -16 Eviceday usybay -$ EEXIST -17 Ilefay existsway -$ EXDEV -18 Osscray-eviceday inklay -$ ENODEV -19 Operationway otnay upportedsay ybay eviceday -$ ENOTDIR -20 Otnay away irectoryday -$ EISDIR -21 Isway away irectoryday -$ EINVAL -22 Invalidway argumentway -$ ENFILE -23 Ootay anymay openway ilesfay inway ystemsay -$ EMFILE -24 Ootay anymay openway ilesfay -$ ENOTTY -25 Inappropriateway ioctlway orfay eviceday -$ ETXTBSY -26 Exttay ilefay usybay -$ EFBIG -27 Ilefay ootay argelay -$ ENOSPC -28 Onay acespay eftlay onway eviceday -$ ESPIPE -29 Illegalway eeksay -$ EROFS -30 Eadray-onlyway ilefay ystemsay -$ EMLINK -31 Ootay anymay inkslay -$ EPIPE -32 Okenbray ipepay -$ EDOM -33 Umericalnay argumentway outway ofway omainday -$ ERANGE -34 Esultray ootay argelay -$ EAGAIN, EWOULDBLOCK -35 Esourceray emporarilytay unavailableway -$ EINPROGRESS -36 Operationway ownay inway ogresspray -$ EALREADY -37 Operationway alreadyway inway ogresspray -$ ENOTSOCK -38 Ocketsay operationway onway onnay-ocketsay -$ EDESTADDRREQ -39 Estinationday addressway equiredray -$ EMSGSIZE -40 Essagemay ootay onglay -$ EPROTOTYPE -41 Otocolpray ongwray ypetay orfay ocketsay -$ ENOPROTOOPT -42 Otocolpray otnay availableway -$ EPROTONOSUPPORT -43 Otocolpray otnay upportedsay -$ ESOCKTNOSUPPORT -44 Ocketsay ypetay otnay upportedsay -$ EOPNOTSUPP -45 Operationway otnay upportedsay -$ EPFNOSUPPORT -46 Otocolpray amilyfay otnay upportedsay -$ EAFNOSUPPORT -47 Addressway amilyfay otnay upportedsay ybay otocolpray amilyfay -$ EADDRINUSE -48 Addressway alreadyway inway useway -$ EADDRNOTAVAIL -49 Ancay'tay assignway equestedray addressway -$ ENETDOWN -50 Etworknay isway ownday -$ ENETUNREACH -51 Etworknay isway unreachableway -$ ENETRESET -52 Etworknay oppeddray onnectioncay onway esetray -$ ECONNABORTED -53 Oftwaresay ausedcay onnectioncay abortway -$ ECONNRESET -54 Onnectioncay esetray ybay eerpay -$ ENOBUFS -55 Onay ufferbay acespay availableway -$ EISCONN -56 Ocketsay isway alreadyway onnectedcay -$ ENOTCONN -57 Ocketsay isway otnay onnectedcay -$ ESHUTDOWN -58 Ancay'tay endsay afterway ocketsay utdownshay -$ ETOOMANYREFS -59 Ootay anymay eferencesray: ancay'tay icesplay -$ ETIMEDOUT -60 Onnectioncay imedtay outway -$ ECONNREFUSED -61 Onnectioncay efusedray -$ ELOOP -62 Ootay anymay evelslay ofway ymbolicsay inkslay -$ ENAMETOOLONG -63 Ilefay amenay ootay onglay -$ EHOSTDOWN -64 Osthay isway ownday -$ EHOSTUNREACH -65 Onay outeray otay osthay -$ ENOTEMPTY -66 Irectoryday otnay emptyway -$ EPROCLIM -67 Ootay anymay ocessespray -$ EUSERS -68 Ootay anymay usersway -$ EDQUOT -69 Iscday otaquay exceededway -$ ESTALE -70 Alestay NFSay ilefay andlehay -$ EREMOTE -71 Ootay anymay evelslay ofway emoteray inway athpay -$ EBADRPC -72 RPCay uctstray isway adbay -$ ERPCMISMATCH -73 RPCay ersionvay ongwray -$ EPROGUNAVAIL -74 RPCay ogpray. otnay availway -$ EPROGMISMATCH -75 Ogrampray ersionvay ongwray -$ EPROCUNAVAIL -76 Adbay ocedurepray orfay ogrampray -$ ENOLCK -77 Onay ockslay availableway -$ ENOSYS -78 Unctionfay otnay implementedway -$ EFTYPE -79 Inappropriateway ilefay ypetay orway ormatfay -$ EAUTH -80 Authenticationway errorway -$ ENEEDAUTH -81 Eednay authenticatorway -$ EIDRM -82 Identifierway emovedray -$ ENOMSG -83 Onay essagemay ofway esiredday ypetay -$ EOVERFLOW -84 Aluevay ootay argelay otay ebay oredstay inway ataday ypetay -$ EILSEQ -85 Illegalway ytebay equencesay -$set 2 -$ SIGHUP -1 Anguphay -$ SIGINT -2 Interruptway -$ SIGQUIT -3 Itquay -$ SIGILL -4 Illegalway instructionway -$ SIGTRAP -5 aceTray/BPTay aptray -$ SIGABRT -6 Abortway aptray -$ SIGEMT -7 EMTway aptray -$ SIGFPE -8 Oatingflay ointpay exceptionway -$ SIGKILL -9 Illedkay -$ SIGBUS -10 Usbay errorway -$ SIGSEGV -11 Egmentationsay aultfay -$ SIGSYS -12 Adbay ystemsay allcay -$ SIGPIPE -13 Okenbray ipepay -$ SIGALRM -14 Alarmway ockclay -$ SIGTERM -15 Erminatedtay -$ SIGURG -16 Urgentway Iway/Oway onditioncay -$ SIGSTOP -17 Oppedstay (ignalsay) -$ SIGTSTP -18 Oppedstay -$ SIGCONT -19 Ontinuedcay -$ SIGCHLD -20 Ildchay exitedway -$ SIGTTIN -21 Oppedstay (yttay inputway) -$ SIGTTOU -22 Oppedstay (yttay outputway) -$ SIGIO -23 Iway/Oway ossiblepay -$ SIGXCPU -24 Utimecpay imitlay exceededway -$ SIGXFSZ -25 Ilesizefay imitlay exceededway -$ SIGVTALRM -26 Irtualvay imertay expiredway -$ SIGPROF -27 Ofilingpray imertay expiredway -$ SIGWINCH -28 Indowway izesay angeschay -$ SIGINFO -29 Informationway equestray -$ SIGUSR1 -30 Userway efinedday ignalsay 1 -$ SIGUSR2 -31 Userway efinedday ignalsay 2 -$ SIGPWR -32 Owerpay ailfay/estartray diff --git a/lib/libc/nls/ca.msg b/lib/libc/nls/ca.msg deleted file mode 100644 index 740028fb8..000000000 --- a/lib/libc/nls/ca.msg +++ /dev/null @@ -1,258 +0,0 @@ -$set 1 -$ EPERM -1 Operació no permesa -$ ENOENT -2 Arxiu o directori inexistent -$ ESRCH -3 Procés inexistent -$ EINTR -4 Crida del sistema interrompuda -$ EIO -5 Error d'entrada/sortida -$ ENXIO -6 Dispositiu no configurat -$ E2BIG -7 Llista de paràmetres massa llarga -$ ENOEXEC -8 Error en el format de l'executable -$ EBADF -9 Descriptor d'arxiu incorrecte -$ ECHILD -10 No hi ha processos fills -$ EDEADLK -11 S'ha evitat el bloqueig del recurs -$ ENOMEM -12 No es pot assignar la memòria demanada -$ EACCES -13 Permís denegat -$ EFAULT -14 Adreça incorrecta -$ ENOTBLK -15 Es necessita un dispositiu de blocs -$ EBUSY -16 Dispositiu ocupat -$ EEXIST -17 L'arxiu ja existeix -$ EXDEV -18 Enllaç entre dispositius -$ ENODEV -19 Operació no suportada pel dispositiu -$ ENOTDIR -20 No és un directori -$ EISDIR -21 És un directori -$ EINVAL -22 Paràmetre incorrecte -$ ENFILE -23 Hi ha massa arxius oberts al sistema -$ EMFILE -24 Hi ha massa arxius oberts -$ ENOTTY -25 L'ioctl no és adecuat per al dispositiu -$ ETXTBSY -26 Arxiu de text ocupat -$ EFBIG -27 Arxiu massa gran -$ ENOSPC -28 No queda espai lliure en el dispositiu -$ ESPIPE -29 Cerca il·legal -$ EROFS -30 Sistema d'arxius de només lectura -$ EMLINK -31 Massa enllaços -$ EPIPE -32 Canal (pipe) trencat -$ EDOM -33 El resultat surt fora de rang -$ ERANGE -34 Resultat massa gran -$ EAGAIN, EWOULDBLOCK -35 El recurs no està disponible temporalment -$ EINPROGRESS -36 L'operació es troba en progrés actualment -$ EALREADY -37 L'operació ja es troba en progrés -$ ENOTSOCK -38 Operació de tipus socket en quelcom que no ho és -$ EDESTADDRREQ -39 Es requereix l'adreça de destí -$ EMSGSIZE -40 Missatge massa llarg -$ EPROTOTYPE -41 Tipus de protocol incorrecte per al socket -$ ENOPROTOOPT -42 Protocol no disponible -$ EPROTONOSUPPORT -43 Protocol no suportat -$ ESOCKTNOSUPPORT -44 Tipus de socket no suportat -$ EOPNOTSUPP -45 Operació no suportada -$ EPFNOSUPPORT -46 Família de protocols no suportada -$ EAFNOSUPPORT -47 Família d'adreces no suportada per la família de protocols -$ EADDRINUSE -48 L'adreça ja es troba en ús -$ EADDRNOTAVAIL -49 No es pot assignar l'adreça demanada -$ ENETDOWN -50 La xarxa no es troba disponible -$ ENETUNREACH -51 No es pot accedir a la xarxa -$ ENETRESET -52 La connexió a la xarxa s'ha perdut durant la reinicialització -$ ECONNABORTED -53 El programari ha causat l'avort de la connexió -$ ECONNRESET -54 L'interlocutor ha reinicialitzat la comunicació -$ ENOBUFS -55 No hi ha prou espai per a la memoria intermèdia (buffer) -$ EISCONN -56 El socket ja es troba connectat -$ ENOTCONN -57 El socket no es troba connectat -$ ESHUTDOWN -58 No es pot enviar desprès de la desconnexió del socket -$ ETOOMANYREFS -59 Hi ha massa referències: no es poden unir -$ ETIMEDOUT -60 El temps de connexió s'ha esgotat -$ ECONNREFUSED -61 Connexió rebutjada -$ ELOOP -62 Hi ha massa nivells d'enllaços simbòlics -$ ENAMETOOLONG -63 Nom d'arxiu massa llarg -$ EHOSTDOWN -64 La màquina no es troba disponible -$ EHOSTUNREACH -65 No hi ha cap camí fins a la màquina -$ ENOTEMPTY -66 El directori no està buit -$ EPROCLIM -67 Hi ha massa processos -$ EUSERS -68 Hi ha massa usuaris -$ EDQUOT -69 Quota de disc sobrepassada -$ ESTALE -70 Descriptor d'arxiu NFS incorrecte -$ EREMOTE -71 Massa nivells en el camí de destí -$ EBADRPC -72 L'estructura RPC es incorrecta -$ ERPCMISMATCH -73 La versió del RPC es incorrecta -$ EPROGUNAVAIL -74 El programa RPC no es troba disponible -$ EPROGMISMATCH -75 Versió incorrecta del programa -$ EPROCUNAVAIL -76 Procediment erroni per al programa -$ ENOLCK -77 No hi ha bloquejos disponibles -$ ENOSYS -78 Funció no implementada -$ EFTYPE -79 Tipus d'arxiu o de format inadequat -$ EAUTH -80 Error d'autenticació -$ ENEEDAUTH -81 Es necessita un autenticador -$ EIDRM -82 Identificador eliminat -$ ENOMSG -83 No hi ha missatges del tipus desitjat -$ EOVERFLOW -84 Valor massa gran per a ésser emmagatzemat en el tipus de dades -$ EILSEQ -85 Seqüència de bytes il·legal -$ ENOTSUP -86 No suportat -$ ECANCELED -87 Operació cancel·lada -$ EBADMSG -88 Missatje incorrecte o corrupte -$ ENODATA -89 No hi ha missatges disponibles -$ ENOSR -90 No hi ha recursos de tipus STREAM -$ ENOSTR -91 No és un STREAM -$ ETIME -92 Temps d'espera esgotat en el ioctl STREAM -$ ENOATTR -93 Atribut inexistent -$ EMULTIHOP -94 S'ha intentat un multisalt -$ ENOLINK -95 L'enllaç s'ha servit -$ EPROTO -96 Error de protocol -$set 2 -$ SIGHUP -1 Fí de línia (hangup) -$ SIGINT -2 Interrupció -$ SIGQUIT -3 Finalització -$ SIGILL -4 Instrucció il·legal -$ SIGTRAP -5 Depuració (Trace/BPT) -$ SIGABRT -6 Crida d'avort -$ SIGEMT -7 Captura d'EMT -$ SIGFPE -8 Excepció de coma flotant -$ SIGKILL -9 Matat -$ SIGBUS -10 Error del bus -$ SIGSEGV -11 Error de segmentació -$ SIGSYS -12 Crida al sistema incorrecta -$ SIGPIPE -13 Canal (pipe) trencat -$ SIGALRM -14 Alarma de rellotge -$ SIGTERM -15 Finalitzat -$ SIGURG -16 Condició urgent d'E/S -$ SIGSTOP -17 Parat (per senyal) -$ SIGTSTP -18 Parat -$ SIGCONT -19 Continuant -$ SIGCHLD -20 El fill ha acabat -$ SIGTTIN -21 Parat (entrada de tty) -$ SIGTTOU -22 Parat (sortida de tty) -$ SIGIO -23 I/O permesa -$ SIGXCPU -24 S'ha sobrepassat el límit de temps de la CPU -$ SIGXFSZ -25 S'ha sobrepassat el límit de la longitud de l'arxiu -$ SIGVTALRM -26 El temporitzador virtual ha expirat -$ SIGPROF -27 El temporitzador del perfilador ha expirat -$ SIGWINCH -28 Canvis en la mida de la finestra -$ SIGINFO -29 Demanda d'informació -$ SIGUSR1 -30 Senyal 1 definida per l'usuari -$ SIGUSR2 -31 Senyal 2 definida per l'usuari -$ SIGPWR -32 Fallada/reinicialització de l'alimentació diff --git a/lib/libc/nls/catclose.3 b/lib/libc/nls/catclose.3 deleted file mode 100644 index abfada75b..000000000 --- a/lib/libc/nls/catclose.3 +++ /dev/null @@ -1,32 +0,0 @@ -.\" $NetBSD: catclose.3,v 1.12 2003/07/26 19:24:49 salo Exp $ -.\" -.\" Written by J.T. Conklin . -.\" Public domain. -.\" -.Dd May 29, 1994 -.Dt CATCLOSE 3 -.Os -.Sh NAME -.Nm catclose -.Nd close message catalog -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In nl_types.h -.Ft int -.Fn catclose "nl_catd catd" -.Sh DESCRIPTION -The -.Fn catclose -function closes the message catalog specified by the argument -.Fa catd . -.Sh SEE ALSO -.Xr gencat 1 , -.Xr catgets 3 , -.Xr catopen 3 , -.Xr nls 7 -.Sh STANDARDS -The -.Fn catclose -function conforms to -.St -xpg3 . diff --git a/lib/libc/nls/catclose.c b/lib/libc/nls/catclose.c deleted file mode 100644 index 760b0d0c7..000000000 --- a/lib/libc/nls/catclose.c +++ /dev/null @@ -1,64 +0,0 @@ -/* $NetBSD: catclose.c,v 1.14 2012/06/25 22:32:45 abs Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: catclose.c,v 1.14 2012/06/25 22:32:45 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define _NLS_PRIVATE - -#include "namespace.h" -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(catclose, _catclose) -#endif - -int -_catclose(nl_catd catd) -{ - if (catd == (nl_catd) -1) { - errno = EBADF; - return -1; - } - - if (catd) { - munmap(catd->__data, (size_t)catd->__size); - free (catd); - } - - return 0; -} diff --git a/lib/libc/nls/catgets.3 b/lib/libc/nls/catgets.3 deleted file mode 100644 index 87c798f78..000000000 --- a/lib/libc/nls/catgets.3 +++ /dev/null @@ -1,73 +0,0 @@ -.\" $NetBSD: catgets.3,v 1.16 2003/07/26 19:24:49 salo Exp $ -.\" -.\" Written by J.T. Conklin . -.\" Public domain. -.\" -.Dd February 12, 2003 -.Dt CATGETS 3 -.Os -.Sh NAME -.Nm catgets -.Nd retrieve string from message catalog -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In nl_types.h -.Ft char * -.Fn catgets "nl_catd catd" "int set_id" "int msg_id" "const char *s" -.Sh DESCRIPTION -The -.Fn catgets -function attempts to retrieve message -.Fa msg_id -of set -.Fa set_id -from the message catalog referenced by the descriptor -.Fa catd . -The argument -.Fa s -points to a default message which is returned if the function -is unable to retrieve the specified message. -.Sh RETURN VALUES -If the specified message was retrieved successfully, -.Fn catgets -returns a pointer to an internal buffer containing the message string; -otherwise it returns -.Fa s . -.Sh ERRORS -The -.Fn catgets -function will fail if: -.Bl -tag -width Er -.It Bq Er EBADF -The -.Fa catd -argument is not a valid message catalog descriptor open for reading. -.It Bq Er EINTR -The operation was interrupted by a signal. -.It Bq Er ENOMSG -The message identified by -.Fa set_id -and -.Fa msg_id -is not in the message catalog. -.El -.Sh SEE ALSO -.Xr gencat 1 , -.Xr catclose 3 , -.Xr catopen 3 , -.Xr nls 7 -.Sh STANDARDS -The -.Fn catgets -function conforms to -.St -xpg4.2 . -.Pp -Major Unix vendors are split over the adoption of the two most -important message catalog specifications: catgets or -.Xr gettext 3 . -The primary concern with the catgets interface is that every -translatable string has to define a number (or a symbolic constant) -which must correspond to the message in the catalog. -Duplicate message IDs are not allowed. -Constructing message catalogs is difficult. diff --git a/lib/libc/nls/catgets.c b/lib/libc/nls/catgets.c deleted file mode 100644 index 32eb17c74..000000000 --- a/lib/libc/nls/catgets.c +++ /dev/null @@ -1,113 +0,0 @@ -/* $NetBSD: catgets.c,v 1.19 2012/06/25 22:32:45 abs Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: catgets.c,v 1.19 2012/06/25 22:32:45 abs Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#define _NLS_PRIVATE - -#include "namespace.h" -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(catgets, _catgets) -#endif - -char * -_catgets(nl_catd catd, int set_id, int msg_id, const char *s) -{ - struct _nls_cat_hdr *cat_hdr; - struct _nls_set_hdr *set_hdr; - struct _nls_msg_hdr *msg_hdr; - int l, u, i, r; - - if (catd == (nl_catd) -1) { - errno = EBADF; - return __UNCONST(s); - } - - cat_hdr = (struct _nls_cat_hdr *)catd->__data; - set_hdr = (struct _nls_set_hdr *)(void *)((char *)catd->__data - + sizeof(struct _nls_cat_hdr)); - - /* binary search, see knuth algorithm b */ - l = 0; - u = ntohl((u_int32_t)cat_hdr->__nsets) - 1; - while (l <= u) { - i = (l + u) / 2; - r = set_id - ntohl((u_int32_t)set_hdr[i].__setno); - - if (r == 0) { - msg_hdr = (struct _nls_msg_hdr *) - (void *)((char *)catd->__data + - sizeof(struct _nls_cat_hdr) + - ntohl((u_int32_t)cat_hdr->__msg_hdr_offset)); - - l = ntohl((u_int32_t)set_hdr[i].__index); - u = l + ntohl((u_int32_t)set_hdr[i].__nmsgs) - 1; - while (l <= u) { - i = (l + u) / 2; - r = msg_id - - ntohl((u_int32_t)msg_hdr[i].__msgno); - if (r == 0) { - return ((char *) catd->__data + - sizeof(struct _nls_cat_hdr) + - ntohl((u_int32_t) - cat_hdr->__msg_txt_offset) + - ntohl((u_int32_t) - msg_hdr[i].__offset)); - } else if (r < 0) { - u = i - 1; - } else { - l = i + 1; - } - } - - /* not found */ - goto notfound; - - } else if (r < 0) { - u = i - 1; - } else { - l = i + 1; - } - } - -notfound: - /* not found */ - errno = ENOMSG; - return __UNCONST(s); -} diff --git a/lib/libc/nls/catopen.3 b/lib/libc/nls/catopen.3 deleted file mode 100644 index c26364f75..000000000 --- a/lib/libc/nls/catopen.3 +++ /dev/null @@ -1,61 +0,0 @@ -.\" $NetBSD: catopen.3,v 1.14 2003/07/26 19:24:49 salo Exp $ -.\" -.\" Written by J.T. Conklin . -.\" Public domain. -.\" -.Dd May 29, 1994 -.Dt CATOPEN 3 -.Os -.Sh NAME -.Nm catopen -.Nd open message catalog -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In nl_types.h -.Ft nl_catd -.Fn catopen "const char *name" "int oflag" -.Sh DESCRIPTION -The -.Fn catopen -function opens the message catalog specified by -.Fa name -and returns a message catalog descriptor. -If -.Fa name -contains a -.Sq / -then -.Fa name -specifies the full pathname for the message catalog, otherwise the value -of the environment variable -.Ev NLSPATH -is used with -.Fa name -substituted for %N. -.Pp -The -.Fa oflag -argument is reserved for future use and should be set to zero. -.Sh RETURN VALUES -Upon successful completion, -.Fn catopen -returns a message catalog descriptor. -Otherwise, (nl_catd) -1 is returned and -.Va errno -is set to indicate the error. -.Sh ERRORS -.Bl -tag -width Er -.It Bq Er ENOMEM -Insufficient memory is available. -.El -.Sh SEE ALSO -.Xr gencat 1 , -.Xr catclose 3 , -.Xr catgets 3 , -.Xr nls 7 -.Sh STANDARDS -The -.Fn catopen -function conforms to -.St -xpg3 . diff --git a/lib/libc/nls/catopen.c b/lib/libc/nls/catopen.c deleted file mode 100644 index d4a74981f..000000000 --- a/lib/libc/nls/catopen.c +++ /dev/null @@ -1,196 +0,0 @@ -/* $NetBSD: catopen.c,v 1.33 2014/09/16 01:30:28 christos Exp $ */ - -/*- - * Copyright (c) 1996 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by J.T. Conklin. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -__RCSID("$NetBSD: catopen.c,v 1.33 2014/09/16 01:30:28 christos Exp $"); - -#define _NLS_PRIVATE -#define __SETLOCALE_SOURCE__ - -#include "namespace.h" -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "citrus_namespace.h" -#include "citrus_bcs.h" -#include "citrus_region.h" -#include "citrus_lookup.h" -#include "citrus_aliasname_local.h" -#include "setlocale_local.h" - -#define NLS_ALIAS_DB "/usr/share/nls/nls.alias" - -#define NLS_DEFAULT_PATH "/usr/share/nls/%L/%N.cat:/usr/share/nls/%N/%L" -#define NLS_DEFAULT_LANG "C" - -__weak_alias(catopen, _catopen) -__weak_alias(catopen_l, _catopen_l) - -static nl_catd load_msgcat(const char *); - -nl_catd -catopen(const char *name, int oflag) -{ - - return catopen_l(name, oflag, _current_locale()); -} - -nl_catd -catopen_l(const char *name, int oflag, locale_t loc) -{ - char tmppath[PATH_MAX+1]; - const char *nlspath; - const char *lang, *reallang; - char *t; - const char *s, *u; - nl_catd catd; - char langbuf[PATH_MAX]; - - if (name == NULL || *name == '\0') - return (nl_catd)-1; - - /* absolute or relative path? */ - if (strchr(name, '/')) - return load_msgcat(name); - - if (issetugid() || (nlspath = getenv("NLSPATH")) == NULL) - nlspath = NLS_DEFAULT_PATH; - /* - * Historical note: - * http://www.hauN.org/ml/b-l-j/a/800/828.html (in japanese) - */ - if (oflag == NL_CAT_LOCALE) { - lang = loc->part_name[LC_MESSAGES]; - } else { - lang = getenv("LANG"); - } - if (lang == NULL || strchr(lang, '/')) - lang = NLS_DEFAULT_LANG; - - reallang = __unaliasname(NLS_ALIAS_DB, lang, langbuf, sizeof(langbuf)); - if (reallang == NULL) - reallang = lang; - - s = nlspath; - t = tmppath; - do { - while (*s && *s != ':') { - if (*s == '%') { - switch (*(++s)) { - case 'L': /* locale */ - u = reallang; - while (*u && t < tmppath + PATH_MAX) - *t++ = *u++; - break; - case 'N': /* name */ - u = name; - while (*u && t < tmppath + PATH_MAX) - *t++ = *u++; - break; - case 'l': /* lang */ - case 't': /* territory */ - case 'c': /* codeset */ - break; - default: - if (t < tmppath + PATH_MAX) - *t++ = *s; - } - } else { - if (t < tmppath + PATH_MAX) - *t++ = *s; - } - s++; - } - - *t = '\0'; - catd = load_msgcat(tmppath); - if (catd != (nl_catd)-1) - return catd; - - if (*s) - s++; - t = tmppath; - } while (*s); - - return (nl_catd)-1; -} - -static nl_catd -load_msgcat(const char *path) -{ - struct stat st; - nl_catd catd; - void *data; - int fd; - - _DIAGASSERT(path != NULL); - - if ((fd = open(path, O_RDONLY|O_CLOEXEC)) == -1) - return (nl_catd)-1; - - if (fstat(fd, &st) != 0) { - close (fd); - return (nl_catd)-1; - } - - data = mmap(0, (size_t)st.st_size, PROT_READ, MAP_FILE|MAP_SHARED, fd, - (off_t)0); - close (fd); - - if (data == MAP_FAILED) { - return (nl_catd)-1; - } - - if (ntohl((u_int32_t)((struct _nls_cat_hdr *)data)->__magic) != - _NLS_MAGIC) { - munmap(data, (size_t)st.st_size); - return (nl_catd)-1; - } - - if ((catd = malloc(sizeof (*catd))) == NULL) { - munmap(data, (size_t)st.st_size); - return (nl_catd)-1; - } - - catd->__data = data; - catd->__size = (int)st.st_size; - return catd; -} diff --git a/lib/libc/nls/cs.msg b/lib/libc/nls/cs.msg deleted file mode 100644 index 97e6cbff4..000000000 --- a/lib/libc/nls/cs.msg +++ /dev/null @@ -1,258 +0,0 @@ -$set 1 -$ EPERM -1 Operace není povolena -$ ENOENT -2 Neexistující soubor nebo adresáø -$ ESRCH -3 Proces neexistuje -$ EINTR -4 Systémové volání pøeru¹eno -$ EIO -5 Vstupní/výstupní chyba -$ ENXIO -6 Zaøízení není nakonfigurováno -$ E2BIG -7 Seznam argumentù je pøíli¹ dlouhý -$ ENOEXEC -8 Chyba formátu spu¹tìného souboru -$ EBADF -9 ©patný souborový deskriptor -$ ECHILD -10 Neexistuje ¾ádný potomek procesu -$ EDEADLK -11 Zabránìno uváznutí (deadlock) prostøedku -$ ENOMEM -12 Nedostatek pamìti -$ EACCES -13 Pøístup odmítnut -$ EFAULT -14 Chybná adresa -$ ENOTBLK -15 Vy¾adováno blokové zaøízení -$ EBUSY -16 Zdroj nebo zaøízení je zaneprázdnìno -$ EEXIST -17 Soubor existuje -$ EXDEV -18 Odkaz vede na jiné zaøízení -$ ENODEV -19 Operace není zaøízením podporována -$ ENOTDIR -20 Toto není adresáø -$ EISDIR -21 Toto je adresáø -$ EINVAL -22 Chybný argument -$ ENFILE -23 Pøíli¹ mnoho otevøených souborù v systému -$ EMFILE -24 Pøíli¹ mnoho otevøených souborù -$ ENOTTY -25 Pro dané zaøízení nevhodné ioctl -$ ETXTBSY -26 S textovým souborem se pracuje -$ EFBIG -27 Soubor je pøíli¹ velký -$ ENOSPC -28 Na zaøízení není volné místo -$ ESPIPE -29 Neplatný lseek(2) -$ EROFS -30 Souborový systém je pouze pro ètení -$ EMLINK -31 Pøíli¹ mnoho odkazù -$ EPIPE -32 Pøeru¹ená roura -$ EDOM -33 Èíselný argument mimo definièní obor -$ ERANGE -34 Výsledek pøíli¹ velký nebo pøíli¹ malý -$ EAGAIN, EWOULDBLOCK -35 Prostøedek je doèasnì nedostupný -$ EINPROGRESS -36 Operace nyní probíhá -$ EALREADY -37 Operace ji¾ probíhá -$ ENOTSOCK -38 Socketová operace na neèem, co není socket -$ EDESTADDRREQ -39 Vy¾adována adresa cíle -$ EMSGSIZE -40 Zpráva je pøíli¹ dlouhá -$ EPROTOTYPE -41 Protokol nepodporuje daný typ socketu -$ ENOPROTOOPT -42 Protokol není dostupný -$ EPROTONOSUPPORT -43 Protokol není podporován -$ ESOCKTNOSUPPORT -44 Typ socketu není podporován -$ EOPNOTSUPP -45 Operace není podporována -$ EPFNOSUPPORT -46 Rodina protokolù není podporována -$ EAFNOSUPPORT -47 Rodina adres není protokolem podporována -$ EADDRINUSE -48 Adresa je ji¾ pou¾ívána -$ EADDRNOTAVAIL -49 Není mo¾no pøidìlit po¾adovanou adresu -$ ENETDOWN -50 Sí» je odpojena -$ ENETUNREACH -51 Sí» je nedosa¾itelná -$ ENETRESET -52 Sí» zru¹ila spojení po resetu -$ ECONNABORTED -53 Program zpùsobil ukonèení spojení -$ ECONNRESET -54 Spojení zru¹eno partnerem -$ ENOBUFS -55 Vyrovnávací pamì» není k dispozici -$ EISCONN -56 Socket je ji¾ u¾ pøipojen -$ ENOTCONN -57 Socket není pøipojen -$ ESHUTDOWN -58 Není mo¾no posílat po shutdownu socketu -$ ETOOMANYREFS -59 Pøíli¹ mnoho referencí: nelze spojit -$ ETIMEDOUT -60 Pøekroèen èasový limit pokusu o spojení -$ ECONNREFUSED -61 Spojení odmítnuto -$ ELOOP -62 Pøíli¹ mnoho úrovní symbolických odkazù -$ ENAMETOOLONG -63 Jméno souboru pøíli¹ dlouhé -$ EHOSTDOWN -64 Vzdálený uzel je odpojen -$ EHOSTUNREACH -65 Neexistuje cesta ke vzdálenému uzlu -$ ENOTEMPTY -66 Adresáø není prázdný -$ EPROCLIM -67 Pøíli¹ mnoho procesù -$ EUSERS -68 Pøíli¹ mnoho u¾ivatelù -$ EDQUOT -69 Disková kvóta pøekroèena -$ ESTALE -70 Propadnutý souborový ukazatel pro NFS -$ EREMOTE -71 Pøíli¹ mnoho úrovní vzdáleného v cestì -$ EBADRPC -72 ©patná RPC struktura -$ ERPCMISMATCH -73 RPC: Nekompatibilní verze RPC -$ EPROGUNAVAIL -74 RPC: Program není dostupný -$ EPROGMISMATCH -75 RPC: Neshoda programu nebo verze -$ EPROCUNAVAIL -76 RPC: Procedura není dostupná -$ ENOLCK -77 Zámky souborových záznamù nejsou dostupné -$ ENOSYS -78 Funkce není implementována -$ EFTYPE -79 Nevhodný typ nebo formát souboru -$ EAUTH -80 Chyba autentifikace -$ ENEEDAUTH -81 Je tøeba se autentifikovat -$ EIDRM -82 Identifikátor zru¹en -$ ENOMSG -83 Neexistuje zpráva ¾ádaného typu -$ EOVERFLOW -84 Hodnota je pro daný datový typ pøíli¹ velká -$ EILSEQ -85 Neplatná posloupnost bajtù -$ ENOTSUP -86 Nepodporováno -$ ECANCELED -87 Operace strornována -$ EBADMSG -88 ©patná nebo poru¹ená zpráva -$ ENODATA -89 ®ádná zpráva není dostupná -$ ENOSR -90 ®ádné STREAM prostøedky -$ ENOSTR -91 Není STREAM -$ ETIME -92 Vypr¹el èasový limit STREAM ioctl -$ ENOATTR -93 Atribut nebyl nalezen -$ EMULTIHOP -94 Pokus o spojení pøes více uzlù -$ ENOLINK -95 Odkaz byl zpøetrhán -$ EPROTO -96 Chyba protokolu -$set 2 -$ SIGHUP -1 Terminál odpojen -$ SIGINT -2 Pøeru¹ení -$ SIGQUIT -3 Konec -$ SIGILL -4 Chybná instrukce -$ SIGTRAP -5 Ladící instrukce -$ SIGABRT -6 Násilné ukonèení -$ SIGEMT -7 Emulovaná instrukce -$ SIGFPE -8 Výjimka pohyblivé èárky -$ SIGKILL -9 Zabito -$ SIGBUS -10 Chyba sbìrnice -$ SIGSEGV -11 Chyba segmentace -$ SIGSYS -12 ©patné systémove volání -$ SIGPIPE -13 Broken pipe -$ SIGALRM -14 Alarm èasovaè -$ SIGTERM -15 Ukonèeno -$ SIGURG -16 Naléhavý I/O po¾adavek -$ SIGSTOP -17 Pozastaveno (signál) -$ SIGTSTP -18 Pozastaveno -$ SIGCONT -19 Pokraèování -$ SIGCHLD -20 Potomek procesu ukonèen -$ SIGTTIN -21 Pozastaveno (terminálový vstup) -$ SIGTTOU -22 Pozastaveno (terminálový výstup) -$ SIGIO -23 Vstup/výstup mo¾ný -$ SIGXCPU -24 Pøekroèen èasový limit pro CPU -$ SIGXFSZ -25 Pøekroèen limit velikosti souboru -$ SIGVTALRM -26 Vypr¹el virtuální èasovaè -$ SIGPROF -27 Vypr¹el profilovací èasovaè -$ SIGWINCH -28 Velikost okna zmìnìna -$ SIGINFO -29 Informaèní po¾adavek -$ SIGUSR1 -30 U¾ivatelský signál 1 -$ SIGUSR2 -31 U¾ivatelský signál 2 -$ SIGPWR -32 Selhání/nastartování napájení diff --git a/lib/libc/nls/de.msg b/lib/libc/nls/de.msg deleted file mode 100644 index 32d4101d2..000000000 --- a/lib/libc/nls/de.msg +++ /dev/null @@ -1,258 +0,0 @@ -$set 1 -$ EPERM -1 Operation nicht erlaubt -$ ENOENT -2 Datei oder Verzeichnis nicht gefunden -$ ESRCH -3 Prozess nicht gefunden -$ EINTR -4 Interrupt innerhalb eines Systemaufrufs -$ EIO -5 Ein/Ausgabefehler -$ ENXIO -6 Gerät ist nicht konfiguriert -$ E2BIG -7 Argumentliste ist zu lang -$ ENOEXEC -8 Die Datei hat kein bekanntes ausführbares Format -$ EBADF -9 Ungültiger Dateideskriptor -$ ECHILD -10 Kein Kindprozess -$ EDEADLK -11 Ein Deadlock wurde vermieden -$ ENOMEM -12 Kann nicht genug Speicher belegen -$ EACCES -13 Zugriff verboten -$ EFAULT -14 Ungültige Adresse -$ ENOTBLK -15 Es wird ein Blockgerät benötigt -$ EBUSY -16 Das Gerät ist belegt -$ EEXIST -17 Datei existiert bereits -$ EXDEV -18 Link zwischen verschiedenen Geräten -$ ENODEV -19 Die Operation wird von diesem Gerät nicht unterstützt -$ ENOTDIR -20 Kein Verzeichnis -$ EISDIR -21 Ist ein Verzeichnis -$ EINVAL -22 Ungültiges Argument -$ ENFILE -23 Zu viele offene Dateien im gesamten System -$ EMFILE -24 Zu viele offene Dateien -$ ENOTTY -25 Ungültiger Ioctl für dieses Gerät -$ ETXTBSY -26 Ausführbare Datei wird benutzt -$ EFBIG -27 Datei zu groß -$ ENOSPC -28 Kein Platz mehr auf dem Gerät -$ ESPIPE -29 Ungültige Positionierung -$ EROFS -30 Dateisystem ist schreibgeschützt -$ EMLINK -31 Zu viele Links -$ EPIPE -32 Unterbrochene Pipe -$ EDOM -33 Numerisches Argument ausserhalb des Wertebereichs -$ ERANGE -34 Ergebnis zu groß oder zu klein -$ EAGAIN, EWOULDBLOCK -35 Ressource vorübergehend nicht verfügbar -$ EINPROGRESS -36 Operation wird jetzt fortgesetzt -$ EALREADY -37 Operation wird bereits ausgeführt -$ ENOTSOCK -38 Deskriptor ist kein Socket -$ EDESTADDRREQ -39 Zieladresse benötigt -$ EMSGSIZE -40 Nachricht zu lang -$ EPROTOTYPE -41 Ungültiger Protokolltyp für diesen Socket -$ ENOPROTOOPT -42 Protokoll nicht verfügbar -$ EPROTONOSUPPORT -43 Protokoll nicht unterstützt -$ ESOCKTNOSUPPORT -44 Sockettyp nicht unterstützt -$ EOPNOTSUPP -45 Operation nicht unterstützt -$ EPFNOSUPPORT -46 Protokollfamilie nicht unterstützt -$ EAFNOSUPPORT -47 Addressart wird von der Protokollfamilie nicht unterstützt -$ EADDRINUSE -48 Adresse wird bereits benutzt -$ EADDRNOTAVAIL -49 Kann angeforderte Adresse nicht belegen -$ ENETDOWN -50 Netzwerk nicht verfügbar -$ ENETUNREACH -51 Netzwerk nicht erreichbar -$ ENETRESET -52 Netzwerk hat Verbindung mit Reset abgebrochen -$ ECONNABORTED -53 Software verursachte einen Verbindungsabbruch -$ ECONNRESET -54 Verbindung wurde von der Gegenstelle geschlossen -$ ENOBUFS -55 Keine Buffer verfügbar -$ EISCONN -56 Socket ist schon verbunden -$ ENOTCONN -57 Socket ist nicht verbunden -$ ESHUTDOWN -58 Kann nach einem Socket-Shutdown nicht mehr senden -$ ETOOMANYREFS -59 Zu viele Referenzen, kann nicht verbinden -$ ETIMEDOUT -60 Verbindungsabbruch durch Zeitüberschreitung -$ ECONNREFUSED -61 Verbindung wurde abgelehnt -$ ELOOP -62 Zu viele symbolische Links (zirkulär?) -$ ENAMETOOLONG -63 Dateiname zu lang -$ EHOSTDOWN -64 Host nicht verfügbar -$ EHOSTUNREACH -65 Keine Route zum Host -$ ENOTEMPTY -66 Verzeichnis ist nicht leer -$ EPROCLIM -67 Zu viele Prozesse -$ EUSERS -68 Zu viele Benutzer -$ EDQUOT -69 Plattenplatzlimit erschöpft -$ ESTALE -70 Verwaister NFS-Dateideskriptor -$ EREMOTE -71 Zu viele Fernverweise in diesem Zugriff -$ EBADRPC -72 RPC-Struktur ist ungültig -$ ERPCMISMATCH -73 RPC-Version stimmt nicht -$ EPROGUNAVAIL -74 RPC-Programm nicht verfügbar -$ EPROGMISMATCH -75 Falsche Programmversion -$ EPROCUNAVAIL -76 Falsche Prozedur für dieses Programm -$ ENOLCK -77 Keine Dateisperren verfügbar -$ ENOSYS -78 Funktion nicht implementiert -$ EFTYPE -79 Ungültiger Dateityp oder Dateiformat -$ EAUTH -80 Authentikationsfehler -$ ENEEDAUTH -81 Authentikator benötigt -$ EIDRM -82 Identifizierung entfernt -$ ENOMSG -83 Keine Nachricht vom gewünschten Typ -$ EOVERFLOW -84 Wert zu groß, um in Datentyp zu speichern -$ EILSEQ -85 Illegale Byte-Sequenz -$ ENOTSUP -86 Operation nicht unterstützt -$ ECANCELED -87 Operation abgebrochen -$ EBADMSG -88 Ungültige Nachricht -$ ENODATA -89 Keine Nachricht verfügbar -$ ENOSR -90 Keine STREAM-Ressourcen verfügbar -$ ENOSTR -91 Kein STREAM -$ ETIME -92 Zeitüberschreitung bei STREAM Ioctl -$ ENOATTR -93 Attribut nicht gefunden -$ EMULTIHOP -94 Multihopversuch -$ ENOLINK -95 Verbindung wurde getrennt -$ EPROTO -96 Protokollfehler -$set 2 -$ SIGHUP -1 Verbindungsende -$ SIGINT -2 Unterbrechung -$ SIGQUIT -3 Programmende -$ SIGILL -4 Ungültiger Maschinenbefehl -$ SIGTRAP -5 Trace/BPT trap -$ SIGABRT -6 Abort trap -$ SIGEMT -7 EMT trap -$ SIGFPE -8 Fließkommafehler -$ SIGKILL -9 Unbedingter Programmabbruch -$ SIGBUS -10 Bus-Zugriffsfehler -$ SIGSEGV -11 Illegaler Speicherzugriff -$ SIGSYS -12 Ungültiger Systemaufruf -$ SIGPIPE -13 Unterbrochene Pipe -$ SIGALRM -14 Wecker -$ SIGTERM -15 Beendet -$ SIGURG -16 Dringende Ein/Ausgabeanforderung -$ SIGSTOP -17 Gestoppt (Signal) -$ SIGTSTP -18 Gestoppt -$ SIGCONT -19 Fortgesetzt -$ SIGCHLD -20 Kindprozess beendet -$ SIGTTIN -21 Gestoppt (Eingabe) -$ SIGTTOU -22 Gestoppt (Ausgabe) -$ SIGIO -23 Ein/Ausgabe ist möglich -$ SIGXCPU -24 CPU-Zeitlimit erschöpft -$ SIGXFSZ -25 Dateigröße hat das Limit erreicht -$ SIGVTALRM -26 Virtueller Wecker abgelaufen -$ SIGPROF -27 Profil-Wecker abgelaufen -$ SIGWINCH -28 Fenstergröße hat sich geändert -$ SIGINFO -29 Informationsanforderung -$ SIGUSR1 -30 Benutzerdefiniertes Signal 1 -$ SIGUSR2 -31 Benutzerdefiniertes Signal 2 -$ SIGPWR -32 Statusänderung der Energieversorgung diff --git a/lib/libc/nls/es.msg b/lib/libc/nls/es.msg deleted file mode 100644 index 7428ed6be..000000000 --- a/lib/libc/nls/es.msg +++ /dev/null @@ -1,258 +0,0 @@ -$set 1 -$ EPERM -1 Operación no permitida -$ ENOENT -2 Archivo o directorio inexistente -$ ESRCH -3 Proceso inexistente -$ EINTR -4 Llamada del sistema interrumpida -$ EIO -5 Error de E/S -$ ENXIO -6 Dispositivo no configurado -$ E2BIG -7 La lista de argumentos es demasiado larga -$ ENOEXEC -8 Error en el formato del ejecutable -$ EBADF -9 Descriptor de archivo incorrecto -$ ECHILD -10 No hay procesos hijo -$ EDEADLK -11 Se ha evitado bloqueo del recurso -$ ENOMEM -12 No se pudo asignar la memoria pedida -$ EACCES -13 Permiso denegado -$ EFAULT -14 Dirección incorrecta -$ ENOTBLK -15 Se necesita un dispositivo de bloques -$ EBUSY -16 Dispositivo ocupado -$ EEXIST -17 El archivo ya existe -$ EXDEV -18 Enlace entre dispositivos -$ ENODEV -19 Operación inadecuada para este dispositivo -$ ENOTDIR -20 No es un directorio -$ EISDIR -21 Es un directorio -$ EINVAL -22 Argumento inadecuado -$ ENFILE -23 Hay demasiados archivos abiertos en el sistema -$ EMFILE -24 Hay demasiados archivos abiertos -$ ENOTTY -25 IOCTL inapropiado para el dispositivo -$ ETXTBSY -26 Archivo de texto ocupado -$ EFBIG -27 Archivo demasiado grande -$ ENOSPC -28 No queda espacio libre en el dispositivo -$ ESPIPE -29 Búsqueda ilegal -$ EROFS -30 Archivo del sistema de sólo lectura -$ EMLINK -31 Demasiados enlaces -$ EPIPE -32 Canal (pipe) roto -$ EDOM -33 El argumento numérico está fuera de rango -$ ERANGE -34 El resultado es demasiado grande -$ EAGAIN, EWOULDBLOCK -35 El recurso no está disponible temporalmente -$ EINPROGRESS -36 Operación actualmente en proceso -$ EALREADY -37 La operación ya estaba realizándose -$ ENOTSOCK -38 Operación de socket inaceptable por el dispositivo -$ EDESTADDRREQ -39 Se necesita una dirección de destino -$ EMSGSIZE -40 Mensaje demasiado largo -$ EPROTOTYPE -41 Tipo erróneo de protocolo para el socket -$ ENOPROTOOPT -42 Protocolo no disponible -$ EPROTONOSUPPORT -43 Protocolo no contemplado -$ ESOCKTNOSUPPORT -44 Tipo de socket no contemplado -$ EOPNOTSUPP -45 Operación no contemplada -$ EPFNOSUPPORT -46 Familia de protocolos no contemplada -$ EAFNOSUPPORT -47 Familia de direcciones no contemplada por la familia de protocolos -$ EADDRINUSE -48 La dirección ya está en uso -$ EADDRNOTAVAIL -49 No se pudo asignar la dirección pedida -$ ENETDOWN -50 La red no funciona -$ ENETUNREACH -51 No se puede acceder a la red -$ ENETRESET -52 La conexión a la red se interrumpió al reinicializar -$ ECONNABORTED -53 La conexión se ha abortado debido a problemas en el software -$ ECONNRESET -54 El interlocutor ha reinicializado la comunicación -$ ENOBUFS -55 No queda espacio en el buffer -$ EISCONN -56 El socket ya estaba conectado -$ ENOTCONN -57 El socket no está conectado -$ ESHUTDOWN -58 No se puede enviar tras la desconexión del socket -$ ETOOMANYREFS -59 Demasiadas referencias: no se pueden unir -$ ETIMEDOUT -60 El tiempo de conexión ha expirado -$ ECONNREFUSED -61 Conexión rehusada -$ ELOOP -62 Demasiados niveles de enlaces simbólicos -$ ENAMETOOLONG -63 Nombre de archivo demasiado largo -$ EHOSTDOWN -64 La máquina está fuera de servicio -$ EHOSTUNREACH -65 No hay ruta hasta la máquina -$ ENOTEMPTY -66 Directorio no vacío -$ EPROCLIM -67 Demasiados procesos -$ EUSERS -68 Demasiados usuarios -$ EDQUOT -69 Cuota de disco sobrepasada -$ ESTALE -70 Descriptor de archivo NFS inválido -$ EREMOTE -71 Ruta con demasiados niveles -$ EBADRPC -72 La estructura de la RPC es errónea -$ ERPCMISMATCH -73 La versión de la RPC es errónea -$ EPROGUNAVAIL -74 La RPC no está accesible -$ EPROGMISMATCH -75 Versión errónea del programa -$ EPROCUNAVAIL -76 Procedimiento erróneo para el programa -$ ENOLCK -77 No hay bloqueos disponibles -$ ENOSYS -78 Función no realizada -$ EFTYPE -79 Tipo de archivo o formato inapropiado -$ EAUTH -80 Error de la autentificación -$ ENEEDAUTH -81 Se necesita un autenticador -$ EIDRM -82 Identificador quitado -$ ENOMSG -83 No hay mensajes del tipo deseado -$ EOVERFLOW -84 Valor demasiado grande para ser almacenado en el tipo de datos -$ EILSEQ -85 Secuencia de bytes no legal -$ ENOTSUP -86 No soportado -$ ECANCELED -87 Operación cancelada -$ EBADMSG -88 Mensaje incorrecto o corrupto -$ ENODATA -89 No hay mensajes disponibles -$ ENOSR -90 No hay recursos de tipo STREAM -$ ENOSTR -91 No es un STREAM -$ ETIME -92 Tiempo de espera agotado en el ioctl STREAM -$ ENOATTR -93 Atributo no encontrado -$ EMULTIHOP -94 Se ha intentado un multisalto -$ ENOLINK -95 El enlace se ha servido -$ EPROTO -96 Error de protocolo -$set 2 -$ SIGHUP -1 Fín de línea (hangup) -$ SIGINT -2 Interrumpido -$ SIGQUIT -3 Terminado -$ SIGILL -4 Instrucción ilegal -$ SIGTRAP -5 Depuración -$ SIGABRT -6 Llamada de aborto -$ SIGEMT -7 Captura de EMT -$ SIGFPE -8 Excepción de coma flotante -$ SIGKILL -9 Matado -$ SIGBUS -10 Error en el bus -$ SIGSEGV -11 Fallo de segmentación -$ SIGSYS -12 Llamada al sistema errónea -$ SIGPIPE -13 Canal (pipe) roto -$ SIGALRM -14 Alarma del reloj -$ SIGTERM -15 Terminado -$ SIGURG -16 Condición urgente de E/S -$ SIGSTOP -17 Detenido (señal) -$ SIGTSTP -18 Detenido -$ SIGCONT -19 Continuando -$ SIGCHLD -20 Proceso hijo finalizado -$ SIGTTIN -21 Detenido (entrada tty) -$ SIGTTOU -22 Detenido (salida tty) -$ SIGIO -23 E/S posible -$ SIGXCPU -24 Se ha sobrepasado el tiempo límite de la CPU -$ SIGXFSZ -25 Se ha sobrepasado el límite de longitud de archivo -$ SIGVTALRM -26 Temporizador virtual expirado -$ SIGPROF -27 Temporizador de perfilación expirado -$ SIGWINCH -28 Cambios en el tamaño de la ventana -$ SIGINFO -29 Petición de información -$ SIGUSR1 -30 Señal definida por el usuario nº 1 -$ SIGUSR2 -31 Señal definida por el usuario nº 2 -$ SIGPWR -32 Fallo o reinicio de la alimentación diff --git a/lib/libc/nls/fi.msg b/lib/libc/nls/fi.msg deleted file mode 100644 index d9475498a..000000000 --- a/lib/libc/nls/fi.msg +++ /dev/null @@ -1,224 +0,0 @@ -$set 1 -$ EPERM -1 Toimintoa ei sallita -$ ENOENT -2 Tiedostoa tai hakemistoa ei löydy -$ ESRCH -3 Prosessia ei löydy -$ EINTR -4 Systeemikutsu keskeytyi -$ EIO -5 Syöttö/tulostusvirhe -$ ENXIO -6 Laitetta ei määritelty -$ E2BIG -7 Liikaa argumentteja -$ ENOEXEC -8 Tuntematon ohjelmatyyppi -$ EBADF -9 Virheellinen tiedosto-osoitin -$ ECHILD -10 Ei lapsiprosesseja -$ EDEADLK -11 Resurssin ristiinlukitus vältetty -$ ENOMEM -12 Muistinvaraus epäonnistui -$ EACCES -13 Lupa kielletty -$ EFAULT -14 Virheellinen osoite -$ ENOTBLK -15 Tarvitaan lohko-osoitettava laite -$ EBUSY -16 Laite käytössä -$ EEXIST -17 Tiedosto on jo olemassa -$ EXDEV -18 Laitteiden välinen linkki -$ ENODEV -19 Laite ei tue toimintoa -$ ENOTDIR -20 Kohde ei ole hakemisto -$ EISDIR -21 Kohde on hakemisto -$ EINVAL -22 Virheellinen argumentti -$ ENFILE -23 Järjestelmässä on liian monta avointa tiedostoa -$ EMFILE -24 Liian monta avointa tiedostoa -$ ENOTTY -25 Virheellinen ohjaustoiminto laitteelle -$ ETXTBSY -26 Tiedosto on käytössä -$ EFBIG -27 Tiedosto liian suuri -$ ENOSPC -28 Laitteella ei ole tilaa -$ ESPIPE -29 Virheellinen haku -$ EROFS -30 Vain luettava tiedostojärjestelmä -$ EMLINK -31 Liian monta linkkiä -$ EPIPE -32 Katkennut putki -$ EDOM -33 Numeerinen syöte virheellinen -$ ERANGE -34 Tulos liian suuri -$ EAGAIN, EWOULDBLOCK -35 Resurssi ei ole tilapäisesti saatavilla -$ EINPROGRESS -36 Toiminta on käynnissä -$ EALREADY -37 Toiminta oli jo käynnissä -$ ENOTSOCK -38 Socket-operaatio muulla kuin socketilla -$ EDESTADDRREQ -39 Tarvitaan kohdeosoite -$ EMSGSIZE -40 Sanoma liian pitkä -$ EPROTOTYPE -41 Väärä protokolla socketille -$ ENOPROTOOPT -42 Protokolla ei ole käytettävissä -$ EPROTONOSUPPORT -43 Protokollaa ei tueta -$ ESOCKTNOSUPPORT -44 Socket-tyyppiä ei tueta -$ EOPNOTSUPP -45 Toimintoa ei tueta -$ EPFNOSUPPORT -46 Protokollaperhettä ei tueta -$ EAFNOSUPPORT -47 Protokollaperhe ei tue osoiteperhettä -$ EADDRINUSE -48 Osoite on jo käytössä -$ EADDRNOTAVAIL -49 Ei pysty antamaan pyydettyä osoitetta -$ ENETDOWN -50 Verkko ei ole käytettävissä -$ ENETUNREACH -51 Verkkoon ei ole yhteyttä -$ ENETRESET -52 Verkko sulki yhteyden -$ ECONNABORTED -53 Ohjelmiston aiheuttama yhteyden keskeytyminen -$ ECONNRESET -54 Isäntä nollasi yhteyden -$ ENOBUFS -55 Puskuritila on lopussa -$ EISCONN -56 Yhteys on jo olemassa -$ ENOTCONN -57 Yhteyttä ei ole olemassa -$ ESHUTDOWN -58 Lähettäminen ei ole mahdollista yhteyden katkaisun jälkeen -$ ETOOMANYREFS -59 Liikaa viittauksia: ei voi yhdistää -$ ETIMEDOUT -60 Yhteyden aikavalvontakatkaisu -$ ECONNREFUSED -61 Yhteys hylätty -$ ELOOP -62 Liian monta peräkkäistä symbolista linkkiä -$ ENAMETOOLONG -63 Tiedoston nimi on liian pitkä -$ EHOSTDOWN -64 Isäntä ei vastaa -$ EHOSTUNREACH -65 Ei reittiä isäntään -$ ENOTEMPTY -66 Hakemisto ei ole tyhjä -$ EPROCLIM -67 Liian monta prosessia -$ EUSERS -68 Liian monta käyttäjää -$ EDQUOT -69 Levytilarajoitus ylittyi -$ ESTALE -70 Vanhentunut NFS-yhteys -$ EREMOTE -71 Liian monta verkkolevyä polussa -$ EBADRPC -72 Virheellinen RPC-pyyntö -$ ERPCMISMATCH -73 Väärä RPC-versio -$ EPROGUNAVAIL -74 RPC ei käytettävissä -$ EPROGMISMATCH -75 Väärä ohjelmaversio -$ EPROCUNAVAIL -76 Väärä RPC-pyyntö ohjelmalle -$ ENOLCK -77 Lukitus ei käytettävissä -$ ENOSYS -78 Toimintoa ei ole -$ EFTYPE -79 Väärä tiedostotyyppi tai -formaatti -$set 2 -$ SIGHUP -1 Katkaisu -$ SIGINT -2 Keskeytys -$ SIGQUIT -3 Lopetus -$ SIGILL -4 Laiton käsky -$ SIGTRAP -5 Jäljitys/BPT ansa -$ SIGABRT -6 Poistumisansa -$ SIGEMT -7 EMT-ansa -$ SIGFPE -8 Liukulukuvirhe -$ SIGKILL -9 Tapettu -$ SIGBUS -10 Väylävirhe -$ SIGSEGV -11 Suojausvirhe -$ SIGSYS -12 Virheellinen systeemikutsu -$ SIGPIPE -13 Katkennut putki -$ SIGALRM -14 Hälytyskello -$ SIGTERM -15 Lopetettu -$ SIGURG -16 Kiireellinen syöttö/tulostus -$ SIGSTOP -17 Pysäytetty (signaali) -$ SIGTSTP -18 Pysäytetty -$ SIGCONT -19 Jatkettu -$ SIGCHLD -20 Lapsiprosessi päättynyt -$ SIGTTIN -21 Pysäytetty (tty-syöte) -$ SIGTTOU -22 Pysäytetty (tty-tuloste) -$ SIGIO -23 Syöttö ja tulostus mahdollisia -$ SIGXCPU -24 Keskusyksikköaikarajoitus ylitetty -$ SIGXFSZ -25 Tiedoston kokorajoitus ylitetty -$ SIGVTALRM -26 Virtuaali-ajastin laukesi -$ SIGPROF -27 Profilointiajastin laukesi -$ SIGWINCH -28 Ikkunan koko muuttuu -$ SIGINFO -29 Informaatiopyyntö -$ SIGUSR1 -30 Käyttäjän määriteltävä signaali 1 -$ SIGUSR2 -31 Käyttäjän määriteltävä signaali 2 -$ SIGPWR -32 Virransaannin tilassa muutos diff --git a/lib/libc/nls/fr.msg b/lib/libc/nls/fr.msg deleted file mode 100644 index 099670e53..000000000 --- a/lib/libc/nls/fr.msg +++ /dev/null @@ -1,252 +0,0 @@ -$set 1 -$ EPERM -1 Opération non autorisée -$ ENOENT -2 Fichier ou répertoire introuvable -$ ESRCH -3 Processus introuvable -$ EINTR -4 Appel système interrompu -$ EIO -5 Erreur d'entrée/sortie -$ ENXIO -6 Périphérique non configuré -$ E2BIG -7 Liste de paramètres trop longue -$ ENOEXEC -8 Erreur de format d'exécutable -$ EBADF -9 Descripteur de fichier invalide -$ ECHILD -10 Pas de processus fils -$ EDEADLK -11 Etreinte fatale évitée -$ ENOMEM -12 Plus de mémoire -$ EACCES -13 Autorisation refusée -$ EFAULT -14 Adresse invalide -$ ENOTBLK -15 Nécessite un périphérique en mode bloc -$ EBUSY -16 Périphérique occupé -$ EEXIST -17 Fichier existant -$ EXDEV -18 Lien hors du périphérique -$ ENODEV -19 Opération non supportée par le périphérique -$ ENOTDIR -20 N'est pas un répertoire -$ EISDIR -21 C'est un réperoire -$ EINVAL -22 Paramètre invalide -$ ENFILE -23 Trop de fichiers ouverts dans le système -$ EMFILE -24 Trop de fichiers ouverts -$ ENOTTY -25 Ioctl inconnu du périphérique -$ ETXTBSY -26 Fichier exécutable utilisé -$ EFBIG -27 Fichier trop grand -$ ENOSPC -28 Plus de place sur le périphérique -$ ESPIPE -29 Positionnement illégal -$ EROFS -30 Système de fichier protégé en écriture -$ EMLINK -31 Trop de liens -$ EPIPE -32 Tube cassé -$ EDOM -33 Paramètre numérique hors du domaine -$ ERANGE -34 Résultat trop grand -$ EAGAIN, EWOULDBLOCK -35 Ressource temporairement indisponible -$ EINPROGRESS -36 Opération actuellement en cours -$ EALREADY -37 Opération déjà en cours -$ ENOTSOCK -38 Opération réservée aux sockets -$ EDESTADDRREQ -39 Adresse de destination nécéssaire -$ EMSGSIZE -40 Message trop long -$ EPROTOTYPE -41 Protocole inadapté au socket -$ ENOPROTOOPT -42 Protocole non disponible -$ EPROTONOSUPPORT -43 Protocole non supporté -$ ESOCKTNOSUPPORT -44 Type de socket non supporté -$ EOPNOTSUPP -45 Opération non supportée -$ EPFNOSUPPORT -46 Famille de protocoles non supportée -$ EAFNOSUPPORT -47 Famille d'adresses non supporté par cette famille de protocoles -$ EADDRINUSE -48 Adresse déjà utilisée -$ EADDRNOTAVAIL -49 Impossible d'affecter l'adresse demandée -$ ENETDOWN -50 Réseau arrêté -$ ENETUNREACH -51 Réseau non atteignable -$ ENETRESET -52 Connexion perdue après un RAZ du réseau -$ ECONNABORTED -53 Fin de connexion causée par logiciel -$ ECONNRESET -54 Connexion terminée par le correspondant -$ ENOBUFS -55 Plus de place pour la mémoire tampon -$ EISCONN -56 Socket déjà connecté -$ ENOTCONN -57 Socket non connecté -$ ESHUTDOWN -58 Impossible de transmettre après fermeture du socket -$ ETOOMANYREFS -59 Trop de références: impossible à réassembler -$ ETIMEDOUT -60 Délai de connexion expiré -$ ECONNREFUSED -61 Connexion refusée -$ ELOOP -62 Trop de niveaux de liens symboliques -$ ENAMETOOLONG -63 Nom de fichier trop long -$ EHOSTDOWN -64 Machine arrêtée -$ EHOSTUNREACH -65 Pas de route vers cette machine -$ ENOTEMPTY -66 Répertoire non vide -$ EPROCLIM -67 Trop de processus -$ EUSERS -68 Trop d'utilisateurs -$ EDQUOT -69 Quota disque épuisé -$ ESTALE -70 Identificateur NFS périmé -$ EREMOTE -71 Trop de points de montages dans le chemin -$ EBADRPC -72 Structure RPC invalide -$ ERPCMISMATCH -73 Mauvaise version RPC -$ EPROGUNAVAIL -74 Programme RPC non disponible -$ EPROGMISMATCH -75 Mauvaise version de programme -$ EPROCUNAVAIL -76 Procédure inexistante -$ ENOLCK -77 Pas de verrous disponibles -$ ENOSYS -78 Fonction non implémentée -$ EFTYPE -79 Type ou format de fichier inadapté -$ EAUTH -80 Erreur lors de l'authentification -$ ENEEDAUTH -81 Authentication nécessaire -$ EIDRM -82 Identifiant supprimé -$ ENOMSG -83 Pas de message du type demandé -$ EOVERFLOW -84 Valeur trop grande pour stocker dans le type de données -$ EILSEQ -85 Séquence d'octets illégale -$ ENOTSUP -86 Non supporté -$ ECANCELED -87 Opération annulée -$ EBADMSG -88 Message invalide ou corrompu -$ ENODATA -89 Pas de message disponible -$ ENOSR -90 Pas de ressource de type STREAM disponible -$ ENOSTR -91 N'est pas un STREAM -$ ETIME -92 Délai expiré pour un ioctl STREAM -$ ENOATTR -93 Attribut non trouvé -$set 2 -$ SIGHUP -1 Raccroché -$ SIGINT -2 Interruption -$ SIGQUIT -3 Quitte -$ SIGILL -4 Instruction illégale -$ SIGTRAP -5 Point de trace/arrêt -$ SIGABRT -6 Avorté -$ SIGEMT -7 Appel émulateur -$ SIGFPE -8 Exception numérique -$ SIGKILL -9 Tué -$ SIGBUS -10 Erreur bus -$ SIGSEGV -11 Erreur de segmentation -$ SIGSYS -12 Appel système invalide -$ SIGPIPE -13 Tube cassé -$ SIGALRM -14 Alarme -$ SIGTERM -15 Terminé -$ SIGURG -16 Condition d'E/S urgente -$ SIGSTOP -17 Arrêté par un signal -$ SIGTSTP -18 Arrêté -$ SIGCONT -19 Reprise -$ SIGCHLD -20 Fin d'un fils -$ SIGTTIN -21 Arrêté (lecture sur tty) -$ SIGTTOU -22 Arrêté (écriture sur tty) -$ SIGIO -23 E/S possible -$ SIGXCPU -24 Limite du temps CPU atteinte -$ SIGXFSZ -25 Limite de taille de fichier atteinte -$ SIGVTALRM -26 Timer virtuel expiré -$ SIGPROF -27 Timer de profiling expiré -$ SIGWINCH -28 Changement de taille de la fenêtre -$ SIGINFO -29 Demande d'informations -$ SIGUSR1 -30 Signal utilisateur 1 -$ SIGUSR2 -31 Signal utilisateur 2 -$ SIGPWR -32 Coupure/reprise d'alimentation diff --git a/lib/libc/nls/nl.msg b/lib/libc/nls/nl.msg deleted file mode 100644 index dc63a290f..000000000 --- a/lib/libc/nls/nl.msg +++ /dev/null @@ -1,258 +0,0 @@ -$set 1 -$ EPERM -1 Bewerking niet toegestaan -$ ENOENT -2 Bestand of directory niet gevonden -$ ESRCH -3 Taak bestaat niet -$ EINTR -4 Onderbroken systeemaanroep -$ EIO -5 Invoer/uitvoer fout -$ ENXIO -6 Apparaat niet geconfigureerd -$ E2BIG -7 Argumenten lijst is te lang -$ ENOEXEC -8 Programma kan niet worden uitgevoerd -$ EBADF -9 Ongeldige bestandsverwijzing -$ ECHILD -10 Geen kind processen -$ EDEADLK -11 Een "deadlock" is vermeden -$ ENOMEM -12 Kan geen geheugen meer verkrijgen -$ EACCES -13 Toegang geweigerd -$ EFAULT -14 Ongeldig adres -$ ENOTBLK -15 Een per blok adresseerbaar apparaat is vereist -$ EBUSY -16 Apparaat is bezig -$ EEXIST -17 Bestand bestaat reeds -$ EXDEV -18 Verwijzing tussen bestanden op verschillende bestandssystemen -$ ENODEV -19 Bewerking wordt niet ondersteund door dit apparaat -$ ENOTDIR -20 Dit is geen directory -$ EISDIR -21 Dit is een directory -$ EINVAL -22 Ongeldig argument -$ ENFILE -23 Te veel open bestanden in het systeem -$ EMFILE -24 Te veel open bestanden -$ ENOTTY -25 ioctl niet van toepassing op dit apparaat -$ ETXTBSY -26 Programma bestand is bezig -$ EFBIG -27 Bestand is te groot -$ ENOSPC -28 Geen ruimte meer op dit apparaat -$ ESPIPE -29 Onuitvoerbare zoekopdracht -$ EROFS -30 Van dit bestandssysteem kan alleen worden gelezen -$ EMLINK -31 Te veel bestandsverwijzingen -$ EPIPE -32 Verbroken pijp -$ EDOM -33 Numeriek argument valt buiten domein -$ ERANGE -34 Resultaat te groot of te klein -$ EAGAIN, EWOULDBLOCK -35 Middel tijdelijk onbeschikbaar -$ EINPROGRESS -36 Bewerking in gang gezet -$ EALREADY -37 Bewerking is al in gang gezet -$ ENOTSOCK -38 Voor deze bewerking is een contactpunt vereist -$ EDESTADDRREQ -39 Een bestemmingsadres is vereist -$ EMSGSIZE -40 Te grote boodschap -$ EPROTOTYPE -41 Protocol past niet bij dit contactpunt -$ ENOPROTOOPT -42 Protocol is niet beschikbaar -$ EPROTONOSUPPORT -43 Protocol is niet ondersteund -$ ESOCKTNOSUPPORT -44 Dit soort contactpunt is niet ondersteund -$ EOPNOTSUPP -45 Bewerking niet ondersteund -$ EPFNOSUPPORT -46 Protocol familie niet ondersteund -$ EAFNOSUPPORT -47 Adressen familie niet ondersteund door protocol familie -$ EADDRINUSE -48 Adres is al in gebruik -$ EADDRNOTAVAIL -49 Het gevraagde adres kan niet worden toegekend -$ ENETDOWN -50 Netwerk is plat -$ ENETUNREACH -51 Netwerk is onbereikbaar -$ ENETRESET -52 Netwerk onderbrak verbinding tijdens herstart -$ ECONNABORTED -53 Verbroken verbinding veroorzaakt door software -$ ECONNRESET -54 Verbinding werd aan de andere kant verbroken -$ ENOBUFS -55 Geen buffer ruimte meer beschikbaar -$ EISCONN -56 Dit contactpunt is al verbonden -$ ENOTCONN -57 Contactpunt is niet verbonden -$ ESHUTDOWN -58 Een afgesloten contactpunt kan geen gegevens meer verzenden -$ ETOOMANYREFS -59 Te veel verwijzingen: splitsen niet mogelijk -$ ETIMEDOUT -60 Verbinding te lang niet mogelijk -$ ECONNREFUSED -61 Verbinding geweigerd -$ ELOOP -62 Te veel niveaus van symbolische verwijzingen -$ ENAMETOOLONG -63 Bestandsnaam te lang -$ EHOSTDOWN -64 Bestemming niet actief -$ EHOSTUNREACH -65 Bestemming niet bereikbaar -$ ENOTEMPTY -66 Directory is niet leeg -$ EPROCLIM -67 Te veel taken -$ EUSERS -68 Te veel gebruikers -$ EDQUOT -69 Schijf quota overschreden -$ ESTALE -70 Verlopen NFS bestandsverwijzing -$ EREMOTE -71 Te veel verwijzingen op afstand in dit pad -$ EBADRPC -72 RPC argument structuur is incorrect -$ ERPCMISMATCH -73 RPC versie is verkeerd -$ EPROGUNAVAIL -74 RPC programma niet beschikbaar -$ EPROGMISMATCH -75 Programma versie is verkeerd -$ EPROCUNAVAIL -76 Taak kan door dit programma niet worden uitgevoerd -$ ENOLCK -77 Geen locks beschikbaar -$ ENOSYS -78 Deze systeem functie is niet geimplementeerd -$ EFTYPE -79 Bestandsformaat niet van toepassing -$ EAUTH -80 Aanmeldingsfout -$ ENEEDAUTH -81 Aanmeldingsprocedure benodigd -$ EIDRM -82 De aanwijzer is verwijderd -$ ENOMSG -83 Geen boodschap van het gewenste type -$ EOVERFLOW -84 Waarde te groot om te bewaren in data type -$ EILSEQ -85 Ongeldige byte reeks -$ ENOTSUP -86 Niet ondersteund -$ ECANCELED -87 Bewerking geannuleerd -$ EBADMSG -88 Verkeerde of defecte boodschap -$ ENODATA -89 Geen boodschap beschikbaar -$ ENOSR -90 Geen STREAM voorraad -$ ENOSTR -91 Dit is geen STREAM -$ ETIME -92 STREAM ioctl verlopen -$ ENOATTR -93 Attribuut niet gevonden -$ EMULTIHOP -94 Multihopverzoek -$ ENOLINK -95 Verbinding werd verstoord -$ EPROTO -96 Protocolfout -$set 2 -$ SIGHUP -1 Opgehangen -$ SIGINT -2 Onderbroken -$ SIGQUIT -3 Opgegeven -$ SIGILL -4 Verboden instructie -$ SIGTRAP -5 Spoor/BPT val -$ SIGABRT -6 Abort val -$ SIGEMT -7 EMT val -$ SIGFPE -8 Drijvende komma fout -$ SIGKILL -9 Gedood -$ SIGBUS -10 Bus fout -$ SIGSEGV -11 Segmentatie fout -$ SIGSYS -12 Verkeerde systeemaanroep -$ SIGPIPE -13 Gebroken pijp -$ SIGALRM -14 Wekker -$ SIGTERM -15 Beeindigd -$ SIGURG -16 Dringende I/O opgemerkt -$ SIGSTOP -17 Gestopt (signaal) -$ SIGTSTP -18 Gestopt -$ SIGCONT -19 Voortgezet -$ SIGCHLD -20 Kindproces beeindigd -$ SIGTTIN -21 Gestopt (tty invoer) -$ SIGTTOU -22 Gestopt (tty uitvoer) -$ SIGIO -23 I/O mogelijk -$ SIGXCPU -24 Te veel CPU tijd verbruikt -$ SIGXFSZ -25 Maximum bestandsgrootte overschreden -$ SIGVTALRM -26 Virtuele wekker -$ SIGPROF -27 Profiling wekker -$ SIGWINCH -28 Venstergrootte veranderd -$ SIGINFO -29 Informatie verzoek -$ SIGUSR1 -30 Gebruikersignaal 1 -$ SIGUSR2 -31 Gebruikersignaal 2 -$ SIGPWR -32 Stroom uitval/inschakeling diff --git a/lib/libc/nls/no.msg b/lib/libc/nls/no.msg deleted file mode 100644 index 762f45c50..000000000 --- a/lib/libc/nls/no.msg +++ /dev/null @@ -1,222 +0,0 @@ -$set 1 -$ EPERM -1 Operasjonen er ikke tillatt -$ ENOENT -2 Filen eller katalogen finnes ikke -$ ESRCH -3 Prosessen finnes ikke -$ EINTR -4 Avbrudt systemkall -$ EIO -5 I/O feil -$ ENXIO -6 Enheten er ikke konfigurert -$ E2BIG -7 Argumentlisten er for lang -$ ENOEXEC -8 Ukjent kjørbart format -$ EBADF -9 Ugyldig fildeskriptor -$ ECHILD -10 Ingen barneprosess -$ EDEADLK -11 Vranglås unngått -$ ENOMEM -12 Kan ikke allokere nok minne -$ EACCES -13 Ingen adgang -$ EFAULT -14 Ugyldig adresse -$ ENOTBLK -15 Blokk-enhet påkrevd -$ EBUSY -16 Enheten er opptatt -$ EEXIST -17 Filen finnes -$ EXDEV -18 Link mellom forskjellige enheter -$ ENODEV -19 Operasjonen er ikke støttet av enheten -$ ENOTDIR -20 Ikke en katalog -$ EISDIR -21 Er en katalog -$ EINVAL -22 Ugyldig argument -$ ENFILE -23 For mange åpne filer i systemet -$ EMFILE -24 For mange åpne filer -$ ENOTTY -25 Ugyldig ioctl for enheten -$ ETXTBSY -26 Kjørbar fil i bruk -$ EFBIG -27 Filen er for stor -$ ENOSPC -28 Ingen ledig plass på enheten -$ ESPIPE -29 Ugyldig seek operasjon -$ EROFS -30 Filsystemet er skrivebeskyttet -$ EMLINK -31 For mange linker -$ EPIPE -32 Brudt pipe -$ EDOM -33 Numerisk argument utenfor arbeidsområdet -$ ERANGE -34 Resultatet er for stort -$ EAGAIN, EWOULDBLOCK -35 Ressurs midlertidig utilgjengelig -$ EINPROGRESS -36 Operasjonen er nå i gang -$ EALREADY -37 Operasjonen er allerede i gang -$ ENOTSOCK -38 Deskriptoren er ikke en socket -$ EDESTADDRREQ -39 Mottakeradresse er påkrevd -$ EMSGSIZE -40 Meldingen er for lang -$ EPROTOTYPE -41 Ugyldig protokolltype for denne socketen -$ ENOPROTOOPT -42 Protokollen er ikke tilgjengelig -$ EPROTONOSUPPORT -43 Protokollen er ikke støttet -$ ESOCKTNOSUPPORT -44 Socket-typen er ikke støttet -$ EOPNOTSUPP -45 Operasjonen er ikke støttet -$ EPFNOSUPPORT -46 Protokollfamilien er ikke støttet -$ EAFNOSUPPORT -47 Adressetypen er ikke støttet av protokollfamilien -$ EADDRINUSE -48 Adressen er allerede i bruk -$ EADDRNOTAVAIL -49 Kan ikke bruke den ønskede adressen -$ ENETDOWN -50 Nettverket er nede -$ ENETUNREACH -51 Nettverket er utilgjengelig -$ ENETRESET -52 Nettverket kuttet forbindelsen ved reset -$ ECONNABORTED -53 Programvaren forårsaket brudd av forbindelsen -$ ECONNRESET -54 Forbindelsen avbrudt av korrespondenten -$ ENOBUFS -55 Buffer-plass ikke tilgjengelig -$ EISCONN -56 Socketen er allerede forbundet -$ ENOTCONN -57 Socketen er ikke forbundet -$ ESHUTDOWN -58 Kan ikke sende etter at socketen er tatt ned -$ ETOOMANYREFS -59 For mange referanser: kan ikke slå dem sammen -$ ETIMEDOUT -60 Tiden til forbindelsen utløp -$ ECONNREFUSED -61 Forbindelse nektet -$ ELOOP -62 For mange nivåer med symbolske linker -$ ENAMETOOLONG -63 Filnavnet er for langt -$ EHOSTDOWN -64 Maskinen er nede -$ EHOSTUNREACH -65 Ingen rute til maskinen -$ ENOTEMPTY -66 Katalogen er ikke tom -$ EPROCLIM -67 For mange prosesser -$ EUSERS -68 For mange brukere -$ EDQUOT -69 Diskkvote overskredet -$ ESTALE -70 Fastlåst NFS fildeskriptor -$ EREMOTE -71 For mange nivåer med remote i stien -$ EBADRPC -72 Ugyldig RPC struktur -$ ERPCMISMATCH -73 Feil RPC versjon -$ EPROGUNAVAIL -74 RPC program ikke tilgjengelig -$ EPROGMISMATCH -75 Feil programversjon -$ EPROCUNAVAIL -76 Prosedyren finnes ikke i programmet -$ ENOLCK -77 Ingen låsing tilgjengelig -$ ENOSYS -78 Funksjonen er ikke implementert -$ EFTYPE -79 Ugyldig filtype eller format -$set 2 -$ SIGHUP -1 Hangup -$ SIGINT -2 Avbrudd -$ SIGQUIT -3 Avslutt -$ SIGILL -4 Ugyldig instruksjon -$ SIGTRAP -5 Trace/BPT trap -$ SIGABRT -6 Abort trap -$ SIGEMT -7 EMT trap -$ SIGFPE -8 Flyttallsfeil -$ SIGKILL -9 Drept -$ SIGBUS -10 Buss feil -$ SIGSEGV -11 Segmenteringsfeil -$ SIGSYS -12 Ugyldig systemkall -$ SIGPIPE -13 Brudt pipe -$ SIGALRM -14 Alarmklokke -$ SIGTERM -15 Terminert -$ SIGURG -16 Urgent I/O condition -$ SIGSTOP -17 Stoppet (signal) -$ SIGTSTP -18 Stoppet -$ SIGCONT -19 Fortsetter -$ SIGCHLD -20 Barn avsluttet -$ SIGTTIN -21 Stoppet (tty input) -$ SIGTTOU -22 Stoppet (tty output) -$ SIGIO -23 I/O mulig -$ SIGXCPU -24 CPU-tid overskredet -$ SIGXFSZ -25 Maksimal filstørrelse overskredet -$ SIGVTALRM -26 Virtuell timer utløpt -$ SIGPROF -27 Profileringstimer utløpt -$ SIGWINCH -28 Vindustørrelse endres -$ SIGINFO -29 Informasjonsforespørsel -$ SIGUSR1 -30 Brukerdefinert signal 1 -$ SIGUSR2 -31 Brukerdefinert signal 2 diff --git a/lib/libc/nls/pl.msg b/lib/libc/nls/pl.msg deleted file mode 100644 index 4c5d2533d..000000000 --- a/lib/libc/nls/pl.msg +++ /dev/null @@ -1,236 +0,0 @@ -$set 1 -$ EPERM -1 Operacja nie dozwolona -$ ENOENT -2 Nie ma takiego pliku ani katalogu -$ ESRCH -3 Nie ma takiego procesu -$ EINTR -4 Przerwane wywo³anie systemowe -$ EIO -5 B³±d wej¶cia/wyj¶cia -$ ENXIO -6 Urz±dzenie nie skonfigurowane -$ E2BIG -7 Lista argumentów jest za d³uga -$ ENOEXEC -8 B³êdny format pliku wykonywalnego -$ EBADF -9 Z³y deskryptor pliku -$ ECHILD -10 Brak procesów potomnych -$ EDEADLK -11 Unikniêto zakleszczenia zasobów -$ ENOMEM -12 Brak pamiêci do przydzia³u -$ EACCES -13 Brak dostêpu -$ EFAULT -14 Z³y adres -$ ENOTBLK -15 Wymagane urz±dzenie blokowe -$ EBUSY -16 Urz±dzenie zajête -$ EEXIST -17 Plik istnieje -$ EXDEV -18 Powi±zanie miedzy urz±dzeniami -$ ENODEV -19 Operacja nie obs³ugiwana przez urz±dzenie -$ ENOTDIR -20 To nie jest katalog -$ EISDIR -21 To jest katalog -$ EINVAL -22 B³êdny argument -$ ENFILE -23 Za du¿o otwrtych plików w systemie -$ EMFILE -24 Za du¿o otwartych plików -$ ENOTTY -25 Niew³a¶ciwy dostêp do urz±dzenia -$ ETXTBSY -26 Plik tekstowy zajêty -$ EFBIG -27 Plik zbyt du¿y -$ ENOSPC -28 Nie ma miejsca na urz±dzeniu -$ ESPIPE -29 B³êdne przesuniêcie -$ EROFS -30 System plików tylko do odczytu -$ EMLINK -31 Za du¿o linków -$ EPIPE -32 Przerwany potok -$ EDOM -33 Argument liczbowy spoza zakresu -$ ERANGE -34 Za du¿y wynik -$ EAGAIN, EWOULDBLOCK -35 Zasoby chwilowo niedostêpne -$ EINPROGRESS -36 Operacja jest w³a¶nie wykonywana -$ EALREADY -37 Operacja jest ju¿ wykonywana -$ ENOTSOCK -38 Operacja na obiekcie, który nie jest gniazdem -$ EDESTADDRREQ -39 Wymagany adres przeznaczenia -$ EMSGSIZE -40 Wiadomo¶æ za d³uga -$ EPROTOTYPE -41 Ty protoko³u nie pasuje do gniazda -$ ENOPROTOOPT -42 Protocó³ nie jest dostêpny -$ EPROTONOSUPPORT -43 Protocó³ nie jest obs³ugiwany -$ ESOCKTNOSUPPORT -44 Nie obs³ugiwany typ gniazda -$ EOPNOTSUPP -45 Operacja nie obs³ugiwana -$ EPFNOSUPPORT -46 Nie obs³ugiwana rodzina protoko³ów -$ EAFNOSUPPORT -47 Rodzina adresów nie obs³ugiwana przez rodzinê protoko³ów -$ EADDRINUSE -48 Adres jest aktualnie w u¿yciu -$ EADDRNOTAVAIL -49 Nie mo¿na przypisaæ ¿±danego adresu -$ ENETDOWN -50 Sieæ nie dzia³a -$ ENETUNREACH -51 Sieæ jest niedostêpna -$ ENETRESET -52 Sieæ przerwa³a po³±czenie po resecie -$ ECONNABORTED -53 Oprogramowanie spowodowa³o przerwanie po³±czenia -$ ECONNRESET -54 Po³±czenie zerwane przez drug± stronê -$ ENOBUFS -55 Brak miejsca w buforze -$ EISCONN -56 Gniazdo jest ju¿ po³±czone -$ ENOTCONN -57 Gniazdo nie jest po³±czone -$ ESHUTDOWN -58 Nie mo¿na wysy³aæ po zamkniêciu gniazda -$ ETOOMANYREFS -59 Za du¿o powi±zañ: dowi±zanie nie mo¿liwe -$ ETIMEDOUT -60 Przekroczono czas oczekiwania na po³±czenie -$ ECONNREFUSED -61 Po³±czenie odrzucone -$ ELOOP -62 Za du¿o wzajemnych symlinków -$ ENAMETOOLONG -63 Zbyt d³uga nazwa pliku -$ EHOSTDOWN -64 Host jest wy³±czony -$ EHOSTUNREACH -65 Brak drogi do hosta -$ ENOTEMPTY -66 Katalog nie jest pusty -$ EPROCLIM -67 Za du¿o procesów -$ EUSERS -68 Zbyt wielu u¿ytkowników -$ EDQUOT -69 Przekroczono limit miejsca na dysku -$ ESTALE -70 Uchwyt pliku NFS jest nieaktualny -$ EREMOTE -71 Za du¿o poziomów zagnie¿d¿enia w ¶cie¿ce -$ EBADRPC -72 RPC b³êdna struktura -$ ERPCMISMATCH -73 RPC z³a wersja -$ EPROGUNAVAIL -74 RPC program niedostêpny -$ EPROGMISMATCH -75 Z³a wersja programu -$ EPROCUNAVAIL -76 Z³a procedura dla programu -$ ENOLCK -77 Blokady nie s± dostêpne -$ ENOSYS -78 Niezaimplementowana funkcja -$ EFTYPE -79 Niew³a¶ciwy typ lub format pliku -$ EAUTH -80 B³±d uwierzytelnienia -$ ENEEDAUTH -81 Wymagane uwierzytelnienie -$ EIDRM -82 Identyfikator zosta³ usuniêty -$ ENOMSG -83 Brak komunikatu po¿adanego typu -$ EOVERFLOW -84 Warto¶æ za du¿a aby zapamiêtaæ j± w zdefiniowanym typie danych -$ EILSEQ -85 B³êdna sekwencja bajtów -$set 2 -$ SIGHUP -1 Roz³±czenie -$ SIGINT -2 Przerwanie -$ SIGQUIT -3 Wyj¶cie -$ SIGILL -4 Nieznana instrukcja -$ SIGTRAP -5 Pu³apka debuggera/BPT -$ SIGABRT -6 Przerwanana pu³apka -$ SIGEMT -7 Pu³apka EMT -$ SIGFPE -8 B³±d w obliczeniach zmiennoprzecinkowych -$ SIGKILL -9 Unicestwiony -$ SIGBUS -10 B³±d szyny -$ SIGSEGV -11 Naruszenie ochrony pamiêci -$ SIGSYS -12 B³êdne wywo³anie systemowe -$ SIGPIPE -13 Przerwany potok -$ SIGALRM -14 Budzik -$ SIGTERM -15 Zakoñczony -$ SIGURG -16 Nag³y wypadek I/O -$ SIGSTOP -17 Zatrzymany (sygna³) -$ SIGTSTP -18 Zatrzymany -$ SIGCONT -19 Kontynuacja -$ SIGCHLD -20 Proces potomny zakoñczy³ pracê -$ SIGTTIN -21 Zatrzymany (wej¶cie z tty) -$ SIGTTOU -22 Zatrzymany (wyj¶cie z tty) -$ SIGIO -23 Wej/Wyj dozwolone -$ SIGXCPU -24 Przekroczony limit czasu procesora -$ SIGXFSZ -25 przekroczony limit wielko¶ci pliku -$ SIGVTALRM -26 Wirtualny stoper wyczerpany -$ SIGPROF -27 Koniec stopera profiluj±cego -$ SIGWINCH -28 Zmiana rozmiaru okna -$ SIGINFO -29 ¯±danie infromacji -$ SIGUSR1 -30 Sygna³ u¿ytkownika 1 -$ SIGUSR2 -31 Sygna³ u¿ytkownika 2 -$ SIGPWR -32 Awaria zasilania/restart diff --git a/lib/libc/nls/sk.msg b/lib/libc/nls/sk.msg deleted file mode 100644 index d784d375c..000000000 --- a/lib/libc/nls/sk.msg +++ /dev/null @@ -1,258 +0,0 @@ -$set 1 -$ EPERM -1 Operácia nie je povolená -$ ENOENT -2 Neexistujúci súbor alebo adresár -$ ESRCH -3 Proces neexistuje -$ EINTR -4 Systémové volanie preru¹ené -$ EIO -5 Chyba vstupu/výstupu -$ ENXIO -6 Zariadenie nie je nakonfigurované -$ E2BIG -7 Príli¹ dlhý zoznam argumentov -$ ENOEXEC -8 Chybný formát spusteného súboru -$ EBADF -9 Chybný deskriptor súboru -$ ECHILD -10 Neexistuje ¾iaden potomok procesu -$ EDEADLK -11 Bolo zabránené zablokovaniu prostriedku -$ ENOMEM -12 Nie je mo¾né prideli» pamä» -$ EACCES -13 Prístup odmietnutý -$ EFAULT -14 Chybná adresa -$ ENOTBLK -15 Vy¾adované blokové zariadenie -$ EBUSY -16 Zariadenie je pou¾ívané -$ EEXIST -17 Súbor existuje -$ EXDEV -18 Odkaz medzi zariadeniami -$ ENODEV -19 Operácia nie je zariadením podporovaná -$ ENOTDIR -20 Nie je adresár -$ EISDIR -21 Je adresár -$ EINVAL -22 Chybný argument -$ ENFILE -23 Priveµa otvorených súborov v systéme -$ EMFILE -24 Priveµa otvorených súborov -$ ENOTTY -25 Nevhodné ioctl pre dané zariadenie -$ ETXTBSY -26 Textový súbor je pou¾ívaný -$ EFBIG -27 Súbor je príli¹ veµký -$ ENOSPC -28 Na zariadení nie je voµné miesto -$ ESPIPE -29 Neprípustné nastavenie pozície -$ EROFS -30 Súborový systém je len na èítanie -$ EMLINK -31 Priveµa odkazov -$ EPIPE -32 Preru¹ená rúra -$ EDOM -33 Èíselný argument mimo definièný obor -$ ERANGE -34 Výsledok príli¹ veµký alebo príli¹ malý -$ EAGAIN, EWOULDBLOCK -35 Zdroj je doèasne nedostupný -$ EINPROGRESS -36 Operácia práve prebieha -$ EALREADY -37 Operácia u¾ prebieha -$ ENOTSOCK -38 Socketová operácia na objekte, ktorý nie je socket -$ EDESTADDRREQ -39 Vy¾adovaná cieµová adresa -$ EMSGSIZE -40 Príli¹ dlhá správa -$ EPROTOTYPE -41 Protokol nie je socketom podporovaný -$ ENOPROTOOPT -42 Protokol nie je k dispozícii -$ EPROTONOSUPPORT -43 Protokol nie je podporovaný -$ ESOCKTNOSUPPORT -44 Typ socketu nie je podporovaný -$ EOPNOTSUPP -45 Operácia nie je podporovaná -$ EPFNOSUPPORT -46 Rodina protokolov nie je podporovaná -$ EAFNOSUPPORT -47 Rodina adries nie je podporovaná rodinou protokolov -$ EADDRINUSE -48 Adresa je u¾ pou¾ívaná -$ EADDRNOTAVAIL -49 Nie je mo¾né prideli» po¾adovanú adresu -$ ENETDOWN -50 Sie» je nefunkèná -$ ENETUNREACH -51 Sie» je nedostupná -$ ENETRESET -52 Sie» zru¹ila spojenie po resete -$ ECONNABORTED -53 Program spôsobil ukonèenie spojenia -$ ECONNRESET -54 Spojenie zru¹ené druhou stranou -$ ENOBUFS -55 Vyrovnávacia pamä» nie je k dispozícii -$ EISCONN -56 Socket je u¾ pripojený -$ ENOTCONN -57 Socket nie je pripojený -$ ESHUTDOWN -58 Nie je mo¾né posiela» po uzavretí socketu -$ ETOOMANYREFS -59 Príli¹ mnoho odkazov: nie je mo¾né spoji» -$ ETIMEDOUT -60 Èasový limit pre spojenie vypr¹al -$ ECONNREFUSED -61 Spojenie odmietnuté -$ ELOOP -62 Priveµa úrovní symbolických odkazov -$ ENAMETOOLONG -63 Meno súboru príli¹ dlhé -$ EHOSTDOWN -64 Vzdialený uzol je odpojený -$ EHOSTUNREACH -65 Neexistuje cesta k vzdialenému uzlu -$ ENOTEMPTY -66 Adresár nie je prázdny -$ EPROCLIM -67 Priveµa procesov -$ EUSERS -68 Priveµa pou¾ívateµov -$ EDQUOT -69 Disková kvóta prekroèená -$ ESTALE -70 Zastaralý NFS súborový ukazateµ -$ EREMOTE -71 Priveµa úrovní vzdialeného v ceste -$ EBADRPC -72 RPC ¹truktúra je chybná -$ ERPCMISMATCH -73 Chybná verzia RPC -$ EPROGUNAVAIL -74 RPC program nie je k dispozícii -$ EPROGMISMATCH -75 Chybná verzia RPC programu -$ EPROCUNAVAIL -76 Chybná RPC procedúra pre program -$ ENOLCK -77 Zámky nie sú k dispozícii -$ ENOSYS -78 Funkcia nie je implementovaná -$ EFTYPE -79 Nevhodný typ alebo formát súboru -$ EAUTH -80 Overenie práv neúspe¹né -$ ENEEDAUTH -81 Vy¾adovaný overovací objekt -$ EIDRM -82 Identifikátor odstránený -$ ENOMSG -83 Neexistuje správa ¾elaného typu -$ EOVERFLOW -84 Hodnota je pre daný dátový typ priveµká -$ EILSEQ -85 Neprípustná postupnos» bajtov -$ ENOTSUP -86 Nie je podporované -$ ECANCELED -87 Operácia zru¹ená -$ EBADMSG -88 Chybná alebo poru¹ená správa -$ ENODATA -89 ®iadna správa nie je k dispozícii -$ ENOSR -90 ®iadne STREAM zdroje -$ ENOSTR -91 Nie je STREAM -$ ETIME -92 Èasový limit pre STREAM ioctl vypr¹al -$ ENOATTR -93 Atribút nenájdený -$ EMULTIHOP -94 Pokus o spojenie cez viacero uzlov -$ ENOLINK -95 Odkaz bol pretrhnutý -$ EPROTO -96 Chyba protokolu -$set 2 -$ SIGHUP -1 Terminál odpojený -$ SIGINT -2 Preru¹enie -$ SIGQUIT -3 Koniec -$ SIGILL -4 Chybná in¹trukcia -$ SIGTRAP -5 Trasovacia/ladiaca in¹trukcia -$ SIGABRT -6 Násilné ukonèenie -$ SIGEMT -7 Emulovaná in¹trukcia -$ SIGFPE -8 Výnimka pohyblivej rádovej èiarky -$ SIGKILL -9 Zabité -$ SIGBUS -10 Chyba na zbernici -$ SIGSEGV -11 Chyba segmentácie -$ SIGSYS -12 Chybné systémové volanie -$ SIGPIPE -13 Preru¹ená rúra -$ SIGALRM -14 Budík -$ SIGTERM -15 Ukonèené -$ SIGURG -16 Naliehavý vstupný/výstupný stav -$ SIGSTOP -17 Pozastavené (signál) -$ SIGTSTP -18 Pozastavené -$ SIGCONT -19 Pokraèovanie -$ SIGCHLD -20 Potomok procesu ukonèený -$ SIGTTIN -21 Pozastavené (terminálový vstup) -$ SIGTTOU -22 Pozastavené (terminálový výstup) -$ SIGIO -23 Vstup/výstup mo¾ný -$ SIGXCPU -24 Prekroèený èasový limit pre procesor -$ SIGXFSZ -25 Prekroèený limit veµkosti súboru -$ SIGVTALRM -26 Vypr¹al virtuálny èasovaè -$ SIGPROF -27 Vypr¹al profilovací èasovaè -$ SIGWINCH -28 Veµkos» okna zmenená -$ SIGINFO -29 ®iados» o informáciu -$ SIGUSR1 -30 Pou¾ívateµom definovaný signál 1 -$ SIGUSR2 -31 Pou¾ívateµom definovaný signál 2 -$ SIGPWR -32 Zlyhanie/opakované spustenie napájania diff --git a/lib/libc/nls/sv.msg b/lib/libc/nls/sv.msg deleted file mode 100644 index a309983a8..000000000 --- a/lib/libc/nls/sv.msg +++ /dev/null @@ -1,224 +0,0 @@ -$set 1 -$ EPERM -1 Otillåten operation -$ ENOENT -2 Filen eller katalogen finns ej -$ ESRCH -3 Denna process finns ej -$ EINTR -4 Avbrutet systemanrop -$ EIO -5 In-/utmatningsfel -$ ENXIO -6 Enheten är ej konfigurerad -$ E2BIG -7 Argumentlistan är för lång -$ ENOEXEC -8 Ej körbar fil -$ EBADF -9 Felaktigt filhandtag -$ ECHILD -10 Inga barnprocesser -$ EDEADLK -11 Undvek resursdödläge -$ ENOMEM -12 Kan ej erhålla minne -$ EACCES -13 Tillstånd nekas -$ EFAULT -14 Felaktig adress -$ ENOTBLK -15 Blockenhet krävs -$ EBUSY -16 Enheten är upptagen -$ EEXIST -17 Filen finns redan -$ EXDEV -18 Länken korsar enheter -$ ENODEV -19 Enheten stöder ej operationen -$ ENOTDIR -20 Är ej en katalog -$ EISDIR -21 Är en katalog -$ EINVAL -22 Ogiltigt argument -$ ENFILE -23 För många öppna filer i systemet -$ EMFILE -24 För många öppna filer -$ ENOTTY -25 Olämplig ioctl för enheten -$ ETXTBSY -26 Programfilen är upptagen -$ EFBIG -27 Filen är för stor -$ ENOSPC -28 Inget utrymme kvar på enheten -$ ESPIPE -29 Otillåten sökning -$ EROFS -30 Skrivskyddat filsystem -$ EMLINK -31 För många länkar -$ EPIPE -32 Avbruten kommunikationskanal -$ EDOM -33 Numeriskt argument utanför domänen -$ ERANGE -34 Resultatet är för stort -$ EAGAIN, EWOULDBLOCK -35 Resursen är tillfälligt otillgänglig -$ EINPROGRESS -36 Operationen är igång -$ EALREADY -37 Operationen är redan igång -$ ENOTSOCK -38 Sockeloperation på icke-sockel -$ EDESTADDRREQ -39 Destinationsadress erfordras -$ EMSGSIZE -40 För långt meddelande -$ EPROTOTYPE -41 Fel protokolltyp för sockeln -$ ENOPROTOOPT -42 Protokollet otillgängligt -$ EPROTONOSUPPORT -43 Protokollet är ej understött -$ ESOCKTNOSUPPORT -44 Sockeltypen är ej understödd -$ EOPNOTSUPP -45 Operationen är ej understödd -$ EPFNOSUPPORT -46 Protokollfamiljen är ej understödd -$ EAFNOSUPPORT -47 Adressfamiljen är ej understödd av protokollfamiljen -$ EADDRINUSE -48 Adressen är upptagen -$ EADDRNOTAVAIL -49 Kan ej tilldela den begärda adressen -$ ENETDOWN -50 Nätverket fungerar inte -$ ENETUNREACH -51 Nätverket är ej kontaktbart -$ ENETRESET -52 Nätverket tappade kontakten vid återställningen -$ ECONNABORTED -53 Mjukvara orsakade nedkoppling -$ ECONNRESET -54 Motparten avbröt uppkopplingen -$ ENOBUFS -55 Inget buffertutrymme tillgängligt -$ EISCONN -56 Sockeln är redan uppkopplad -$ ENOTCONN -57 Sockeln är ej uppkopplad -$ ESHUTDOWN -58 Kan ej sända efter att sockeln nedkopplats -$ ETOOMANYREFS -59 För många referenser: kan inte delas -$ ETIMEDOUT -60 Uppkopplingstiden tog slut -$ ECONNREFUSED -61 Uppkopplingen nekad -$ ELOOP -62 För många nivåer av symboliska länkar -$ ENAMETOOLONG -63 Alldeles för långt filnamn -$ EHOSTDOWN -64 Värddatorn är nere -$ EHOSTUNREACH -65 Väg till värddatorn saknas -$ ENOTEMPTY -66 Katalogen ej tom -$ EPROCLIM -67 För många processer -$ EUSERS -68 För många användare -$ EDQUOT -69 Diskkvot överskriden -$ ESTALE -70 Inaktuellt NFS-filhandtag -$ EREMOTE -71 För många fjärrnivåer i sökvägen -$ EBADRPC -72 Felaktig RPC-struktur -$ ERPCMISMATCH -73 Felaktig RPC-version -$ EPROGUNAVAIL -74 RPC-programmet otillgängligt -$ EPROGMISMATCH -75 Fel programversion -$ EPROCUNAVAIL -76 Felaktig procedur för programmet -$ ENOLCK -77 Inga lås tillgängliga -$ ENOSYS -78 Funktionen är ej implementerad -$ EFTYPE -79 Olämplig filtyp eller format -$set 2 -$ SIGHUP -1 Lägg på -$ SIGINT -2 Avbryt -$ SIGQUIT -3 Avsluta -$ SIGILL -4 Olaglig instruktion -$ SIGTRAP -5 Spår- eller brytpunktsfälla -$ SIGABRT -6 Avslutsfälla -$ SIGEMT -7 Emuleringsfälla -$ SIGFPE -8 Flyttalsavbrott -$ SIGKILL -9 Dräpt -$ SIGBUS -10 Bussfel -$ SIGSEGV -11 Segmentfel -$ SIGSYS -12 Felaktigt systemanrop -$ SIGPIPE -13 Avbruten kommunikationskanal -$ SIGALRM -14 Äggklocka -$ SIGTERM -15 Terminerad -$ SIGURG -16 Brådskande In/Ut-tillstånd -$ SIGSTOP -17 Stoppad (signal) -$ SIGTSTP -18 Stoppad -$ SIGCONT -19 Fortsätter -$ SIGCHLD -20 Barn avslutat -$ SIGTTIN -21 Stoppad (terminalinmatning) -$ SIGTTOU -22 Stoppad (terminalutmatning) -$ SIGIO -23 In- och utmatning möjlig -$ SIGXCPU -24 Cputidsgränsen överskriden -$ SIGXFSZ -25 Filstorleksgränsen överskriden -$ SIGVTALRM -26 Virtuella äggklockan ringde -$ SIGPROF -27 Profileringsäggklockan ringde -$ SIGWINCH -28 Fönsterstorleken ändras -$ SIGINFO -29 Informationsförfrågan -$ SIGUSR1 -30 Användardefinierad signal 1 -$ SIGUSR2 -31 Användardefinierad signal 2 -$ SIGPWR -32 Kraftbortfall/omstart diff --git a/lib/libc/quad/Makefile.inc b/lib/libc/quad/Makefile.inc deleted file mode 100644 index 1652b3f6d..000000000 --- a/lib/libc/quad/Makefile.inc +++ /dev/null @@ -1,37 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.17 2013/08/24 00:51:48 matt Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -# Quad support -SRCS.quad= cmpdi2.c ucmpdi2.c -SRCS.quad+= divdi3.c moddi3.c -.if empty(LIBC_MACHINE_ARCH:Mearm*) -SRCS.quad+= fixdfdi.c fixsfdi.c -SRCS.quad+= fixunsdfdi.c fixunssfdi.c -SRCS.quad+= floatdidf.c floatdisf.c -SRCS.quad+= floatundidf.c floatundisf.c -.endif -SRCS.quad+= muldi3.c -SRCS.quad+= negdi2.c -SRCS.quad+= qdivrem.c -SRCS.quad+= udivdi3.c umoddi3.c - -.if (${MACHINE_ARCH} == "m68k") -SRCS.quad+= ashldi3.S ashrdi3.S lshrdi3.S -.elif (${MACHINE_ARCH} == "m68000") -SRCS.quad+= ashldi3.S lshrdi3.S -.elif !empty(LIBC_MACHINE_ARCH:Mearm*) -SRCS.quad+= ashldi3.c ashrdi3.c lshrdi3.c lshldi3.c -SRCS.quad+= floatdidf_ieee754.c floatdisf_ieee754.c -SRCS.quad+= floatundidf_ieee754.c floatundisf_ieee754.c -SRCS.quad+= fixdfdi_ieee754.c fixsfdi_ieee754.c -SRCS.quad+= fixunsdfdi_ieee754.c fixunssfdi_ieee754.c -.else -SRCS.quad+= ashldi3.c ashrdi3.c lshrdi3.c -.endif - -# XXX as far as I can tell, these are never used and can be removed -SRCS.quad+= adddi3.c anddi3.c iordi3.c notdi2.c subdi3.c xordi3.c - -SRCS+= ${SRCS.quad} - -.PATH: ${ARCHDIR}/quad ${.CURDIR}/quad diff --git a/lib/libc/quad/TESTS/Makefile b/lib/libc/quad/TESTS/Makefile deleted file mode 100644 index decf428a2..000000000 --- a/lib/libc/quad/TESTS/Makefile +++ /dev/null @@ -1,12 +0,0 @@ -# $NetBSD: Makefile,v 1.2 1995/02/27 17:31:26 cgd Exp $ -# @(#)Makefile 8.1 (Berkeley) 6/4/93 - -all: mul divrem - -MUL= mul.c ../muldi3.c -mul: ${MUL} - gcc -g -DSPARC_XXX ${MUL} -o $@ - -DIVREM= divrem.c ../qdivrem.c -divrem: ${DIVREM} - gcc -g -DSPARC_XXX ${DIVREM} -o $@ diff --git a/lib/libc/quad/TESTS/divrem.c b/lib/libc/quad/TESTS/divrem.c deleted file mode 100644 index 7c2139d85..000000000 --- a/lib/libc/quad/TESTS/divrem.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $NetBSD: divrem.c,v 1.4 2003/08/07 16:43:18 agc Exp $ */ - -/*- - * 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. - * 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. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)divrem.c 8.1 (Berkeley) 6/4/93"; -#else -static char rcsid[] = "$NetBSD: divrem.c,v 1.4 2003/08/07 16:43:18 agc Exp $"; -#endif -#endif /* not lint */ - -#include - -main() -{ - union { long long q; unsigned int v[2]; } a, b, q, r; - char buf[300]; - extern long long __qdivrem(unsigned long long, unsigned long long, - unsigned long long *); - - for (;;) { - printf("> "); - if (fgets(buf, sizeof buf, stdin) == NULL) - break; - if (sscanf(buf, "%u:%u %u:%u", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 && - sscanf(buf, "0x%x:%x 0x%x:%x", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) { - printf("eh?\n"); - continue; - } - q.q = __qdivrem(a.q, b.q, &r.q); - printf("%x:%x /%% %x:%x => q=%x:%x r=%x:%x\n", - a.v[0], a.v[1], b.v[0], b.v[1], - q.v[0], q.v[1], r.v[0], r.v[1]); - printf(" = %X%08X / %X%08X => %X%08X\n\ - = %X%08X %% %X%08X => %X%08X\n", - a.v[0], a.v[1], b.v[0], b.v[1], q.v[0], q.v[1], - a.v[0], a.v[1], b.v[0], b.v[1], r.v[0], r.v[1]); - } - exit(0); -} diff --git a/lib/libc/quad/TESTS/mul.c b/lib/libc/quad/TESTS/mul.c deleted file mode 100644 index 2826d7a7b..000000000 --- a/lib/libc/quad/TESTS/mul.c +++ /dev/null @@ -1,76 +0,0 @@ -/* $NetBSD: mul.c,v 1.4 2003/08/07 16:43:19 agc Exp $ */ - -/*- - * 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. - * 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. - */ - -#ifndef lint -static char copyright[] = -"@(#) Copyright (c) 1992, 1993\n\ - The Regents of the University of California. All rights reserved.\n"; -#endif /* not lint */ - -#ifndef lint -#if 0 -static char sccsid[] = "@(#)mul.c 8.1 (Berkeley) 6/4/93"; -#else -static char rcsid[] = "$NetBSD: mul.c,v 1.4 2003/08/07 16:43:19 agc Exp $"; -#endif -#endif /* not lint */ - -#include - -main() -{ - union { long long q; unsigned int v[2]; } a, b, m; - char buf[300]; - extern long long __muldi3(long long, long long); - - for (;;) { - printf("> "); - if (fgets(buf, sizeof buf, stdin) == NULL) - break; - if (sscanf(buf, "%u:%u %u:%u", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4 && - sscanf(buf, "0x%x:%x 0x%x:%x", - &a.v[0], &a.v[1], &b.v[0], &b.v[1]) != 4) { - printf("eh?\n"); - continue; - } - m.q = __muldi3(a.q, b.q); - printf("%x:%x * %x:%x => %x:%x\n", - a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]); - printf(" = %X%08X * %X%08X => %X%08X\n", - a.v[0], a.v[1], b.v[0], b.v[1], m.v[0], m.v[1]); - } - exit(0); -} diff --git a/lib/libc/quad/fixdfdi.c b/lib/libc/quad/fixdfdi.c deleted file mode 100644 index b45f4a80b..000000000 --- a/lib/libc/quad/fixdfdi.c +++ /dev/null @@ -1,68 +0,0 @@ -/* $NetBSD: fixdfdi.c,v 1.7 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fixdfdi.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: fixdfdi.c,v 1.7 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -/* - * Convert double to (signed) quad. - * We clamp anything that is out of range. - */ -quad_t -__fixdfdi(double x) -{ - if (x < 0) - if (x <= QUAD_MIN) - return (QUAD_MIN); - else - return ((quad_t)-(u_quad_t)-x); - else - if (x >= QUAD_MAX) - return (QUAD_MAX); - else - return ((quad_t)(u_quad_t)x); -} diff --git a/lib/libc/quad/fixdfdi_ieee754.c b/lib/libc/quad/fixdfdi_ieee754.c deleted file mode 100644 index 9fc89c3ff..000000000 --- a/lib/libc/quad/fixdfdi_ieee754.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: fixdfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixdfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" -#include -#include -#include - -/* - * Convert double to signed quad. - * Not sure what to do with negative numbers---for now, anything out - * of range becomes UQUAD_MAX. - */ -quad_t -__fixdfdi(double x) -{ - const union ieee_double_u ux = { .dblu_d = x }; - signed int exp = ux.dblu_exp - DBL_EXP_BIAS; - const bool neg = ux.dblu_sign; - quad_t r; - - if (exp >= 62) - return neg ? QUAD_MIN : QUAD_MAX; - - r = 1 << DBL_FRACHBITS; /* implicit bit */ - r |= ux.dblu_frach; - exp -= DBL_FRACHBITS; - if (exp < 0) { - r >>= -exp; - } else if (exp > 0) { - r <<= DBL_FRACLBITS; - r |= ux.dblu_fracl; - exp -= DBL_FRACLBITS; - if (exp < 0) { - r >>= -exp; - } else if (exp > 0) { - r <<= exp; - } - } - return neg ? -r : r; -} diff --git a/lib/libc/quad/fixsfdi.c b/lib/libc/quad/fixsfdi.c deleted file mode 100644 index c2647c082..000000000 --- a/lib/libc/quad/fixsfdi.c +++ /dev/null @@ -1,70 +0,0 @@ -/* $NetBSD: fixsfdi.c,v 1.6 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * Copyright (c) 1992 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fixsfdi.c 5.1 (Berkeley) 7/7/92"; -#else -__RCSID("$NetBSD: fixsfdi.c,v 1.6 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -/* - * Convert float to (signed) quad. - * We clamp anything that is out of range. - * - * N.B.: must use new ANSI syntax (sorry). - */ -quad_t -__fixsfdi(float x) -{ - if (x < 0) - if (x <= QUAD_MIN) - return (QUAD_MIN); - else - return ((quad_t)-(u_quad_t)-x); - else - if (x >= QUAD_MAX) - return (QUAD_MAX); - else - return ((quad_t)(u_quad_t)x); -} diff --git a/lib/libc/quad/fixsfdi_ieee754.c b/lib/libc/quad/fixsfdi_ieee754.c deleted file mode 100644 index 9376f8d26..000000000 --- a/lib/libc/quad/fixsfdi_ieee754.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: fixsfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixsfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" -#include -#include -#include - -/* - * Convert float to signed quad. - */ -quad_t -__fixsfdi(float x) -{ - const union ieee_single_u ux = { .sngu_f = x }; - signed int exp = ux.sngu_exp - SNG_EXP_BIAS; - const bool neg = ux.sngu_sign; - quad_t r; - - if (exp < 0) - return 0; - if (exp > 62) - return neg ? QUAD_MIN : QUAD_MAX; - - r = 1 << SNG_FRACBITS; /* implicit bit */ - r |= ux.sngu_frac; - exp -= SNG_FRACBITS; - if (exp < 0) { - r >>= -exp; - } else if (exp > 0) { - r <<= exp; - } - return neg ? -r : r; -} diff --git a/lib/libc/quad/fixunsdfdi.c b/lib/libc/quad/fixunsdfdi.c deleted file mode 100644 index 60090f0a8..000000000 --- a/lib/libc/quad/fixunsdfdi.c +++ /dev/null @@ -1,86 +0,0 @@ -/* $NetBSD: fixunsdfdi.c,v 1.11 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fixunsdfdi.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: fixunsdfdi.c,v 1.11 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -#define ONE_FOURTH ((int)1 << (unsigned int)(INT_BITS - 2)) -#define ONE_HALF (ONE_FOURTH * 2.0) -#define ONE (ONE_FOURTH * 4.0) - -/* - * Convert double to (unsigned) quad. - * Not sure what to do with negative numbers---for now, anything out - * of range becomes UQUAD_MAX. - */ -u_quad_t -__fixunsdfdi(double x) -{ - union uu t; - unsigned int tmp; - - if (x < 0) - return (UQUAD_MAX); /* ??? should be 0? ERANGE??? */ -#ifdef notdef /* this falls afoul of a GCC bug */ - if (x >= UQUAD_MAX) - return (UQUAD_MAX); -#else /* so we wire in 2^64-1 instead */ - if (x >= 18446744073709551615.0) /* XXX */ - return (UQUAD_MAX); -#endif - /* - * Now we know that 0 <= x <= 18446744073709549568. The upper - * limit is one ulp less than 18446744073709551615 tested for above. - * Dividing this by 2^32 will *not* round irrespective of any - * rounding modes (except if the result is an IEEE denorm). - * Furthermore, the quotient will fit into a 32-bit integer. - */ - tmp = x / ONE; - t.ul[L] = (unsigned int) (x - tmp * ONE); - t.ul[H] = tmp; - return (t.uq); -} diff --git a/lib/libc/quad/fixunsdfdi_ieee754.c b/lib/libc/quad/fixunsdfdi_ieee754.c deleted file mode 100644 index 32058c1cd..000000000 --- a/lib/libc/quad/fixunsdfdi_ieee754.c +++ /dev/null @@ -1,85 +0,0 @@ -/* $NetBSD: fixunsdfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunsdfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" -#include -#include - -/* - * Convert double to unsigned quad. - * Not sure what to do with negative numbers---for now, anything out - * of range becomes UQUAD_MAX. - */ -u_quad_t -__fixunsdfdi(double x) -{ - const union ieee_double_u ux = { .dblu_d = x }; - signed int exp = ux.dblu_exp - DBL_EXP_BIAS; - u_quad_t r; - - if (ux.dblu_sign) - return UQUAD_MAX; - if (exp > 63) - return UQUAD_MAX; - if (exp < 0) - return 0; - - r = 1 << DBL_FRACHBITS; /* implicit bit */ - r |= ux.dblu_frach; - exp -= DBL_FRACHBITS; - if (exp == 0) - return r; - if (exp < 0) - return r >> -exp; - - r <<= DBL_FRACLBITS; - r |= ux.dblu_fracl; - exp -= DBL_FRACLBITS; - if (exp == 0) - return r; - if (exp < 0) - return r >> -exp; - - return r << exp; -} diff --git a/lib/libc/quad/fixunssfdi.c b/lib/libc/quad/fixunssfdi.c deleted file mode 100644 index c7f7942d3..000000000 --- a/lib/libc/quad/fixunssfdi.c +++ /dev/null @@ -1,107 +0,0 @@ -/* $NetBSD: fixunssfdi.c,v 1.9 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)fixunssfdi.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: fixunssfdi.c,v 1.9 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -#define ONE_FOURTH ((int)1 << (unsigned int)(INT_BITS - 2)) -#define ONE_HALF (ONE_FOURTH * 2.0) -#define ONE (ONE_FOURTH * 4.0) - -/* - * Convert float to (unsigned) quad. We do most of our work in double, - * out of sheer paranoia. - * - * Not sure what to do with negative numbers---for now, anything out - * of range becomes UQUAD_MAX. - * - * N.B.: must use new ANSI syntax (sorry). - */ -u_quad_t -__fixunssfdi(float f) -{ - double x, toppart; - union uu t; - - if (f < 0) - return (UQUAD_MAX); /* ??? should be 0? ERANGE??? */ -#ifdef notdef /* this falls afoul of a GCC bug */ - if (f >= UQUAD_MAX) - return (UQUAD_MAX); -#else /* so we wire in 2^64-1 instead */ - if (f >= 18446744073709551615.0) /* XXX */ - return (UQUAD_MAX); -#endif - x = f; - /* - * Get the upper part of the result. Note that the divide - * may round up; we want to avoid this if possible, so we - * subtract `1/2' first. - */ - toppart = (x - ONE_HALF) / ONE; - /* - * Now build a u_quad_t out of the top part. The difference - * between x and this is the bottom part (this may introduce - * a few fuzzy bits, but what the heck). With any luck this - * difference will be nonnegative: x should wind up in the - * range [0..UINT_MAX]. For paranoia, we assume [INT_MIN.. - * 2*UINT_MAX] instead. - */ - t.ul[H] = (unsigned int)toppart; - t.ul[L] = 0; - x -= (double)t.uq; - if (x < 0) { - t.ul[H]--; - x += UINT_MAX; - } - if (x > UINT_MAX) { - t.ul[H]++; - x -= UINT_MAX; - } - t.ul[L] = (u_int)x; - return (t.uq); -} diff --git a/lib/libc/quad/fixunssfdi_ieee754.c b/lib/libc/quad/fixunssfdi_ieee754.c deleted file mode 100644 index 180e31e81..000000000 --- a/lib/libc/quad/fixunssfdi_ieee754.c +++ /dev/null @@ -1,77 +0,0 @@ -/* $NetBSD: fixunssfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: fixunssfdi_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" -#include -#include - -/* - * Convert float to unsigned quad. - * Not sure what to do with negative numbers---for now, anything out - * of range becomes UQUAD_MAX. - */ -u_quad_t -__fixunssfdi(float x) -{ - const union ieee_single_u ux = { .sngu_f = x }; - signed int exp = ux.sngu_exp - SNG_EXP_BIAS; - u_quad_t r; - - if (ux.sngu_sign) - return UQUAD_MAX; - if (exp > 63) - return UQUAD_MAX; - if (exp < 0) - return 0; - - r = 1 << SNG_FRACBITS; /* implicit bit */ - r |= ux.sngu_frac; - exp -= SNG_FRACBITS; - if (exp == 0) - return r; - if (exp < 0) - return r >> -exp; - - return r << exp; -} diff --git a/lib/libc/quad/floatdidf.c b/lib/libc/quad/floatdidf.c deleted file mode 100644 index 967d4b2a5..000000000 --- a/lib/libc/quad/floatdidf.c +++ /dev/null @@ -1,80 +0,0 @@ -/* $NetBSD: floatdidf.c,v 1.10 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)floatdidf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: floatdidf.c,v 1.10 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -/* - * Convert (signed) quad to double. - */ -double -__floatdidf(quad_t x) -{ - double d; - union uu u; - int neg; - - /* - * Get an unsigned number first, by negating if necessary. - */ - if (x < 0) - u.q = -x, neg = 1; - else - u.q = x, neg = 0; - - /* - * Now u.ul[H] has the factor of 2^32 (or whatever) and u.ul[L] - * has the units. Ideally we could just set d, add INT_BITS to - * its exponent, and then add the units, but this is portable - * code and does not know how to get at an exponent. Machine- - * specific code may be able to do this more efficiently. - */ - d = (double)u.ul[H] * (((int)1 << (unsigned int)(INT_BITS - 2)) * 4.0); - d += u.ul[L]; - - return (neg ? -d : d); -} diff --git a/lib/libc/quad/floatdidf_ieee754.c b/lib/libc/quad/floatdidf_ieee754.c deleted file mode 100644 index 8e6895d25..000000000 --- a/lib/libc/quad/floatdidf_ieee754.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: floatdidf_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: floatdidf_ieee754.c,v 1.1 2013/08/24 00:51:48 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include -#include -#include "quad.h" - -double __floatdidf(quad_t); - -/* - * Convert signed quad to double. - */ -double -__floatdidf(quad_t x) -{ - union ieee_double_u ux = { .dblu_d = 0.0 }; - - if (x == 0) - return 0.0; - if (x == 1) - return 1.0; - - if (x < 0) { - if (x == QUAD_MIN) - return -0x1.0p63; - ux.dblu_sign = 1; - x = -x; - } - u_int l = __builtin_clzll(x); - x <<= (l + 1); /* clear implicit bit */ - x >>= 64 - (DBL_FRACHBITS + DBL_FRACLBITS); - union uu u = { .uq = x }; - ux.dblu_frach = u.ul[H]; - ux.dblu_fracl = u.ul[L]; - ux.dblu_exp = DBL_EXP_BIAS + 63 - l; - - return ux.dblu_d; -} diff --git a/lib/libc/quad/floatdisf.c b/lib/libc/quad/floatdisf.c deleted file mode 100644 index 0a1092b95..000000000 --- a/lib/libc/quad/floatdisf.c +++ /dev/null @@ -1,82 +0,0 @@ -/* $NetBSD: floatdisf.c,v 1.10 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)floatdisf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: floatdisf.c,v 1.10 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -/* - * Convert (signed) quad to float. - */ -float -__floatdisf(quad_t x) -{ - float f; - union uu u; - int neg; - - /* - * Get an unsigned number first, by negating if necessary. - */ - if (x < 0) - u.q = -x, neg = 1; - else - u.q = x, neg = 0; - - /* - * Now u.ul[H] has the factor of 2^32 (or whatever) and u.ul[L] - * has the units. Ideally we could just set f, add INT_BITS to - * its exponent, and then add the units, but this is portable - * code and does not know how to get at an exponent. Machine- - * specific code may be able to do this more efficiently. - * - * Using double here may be excessive paranoia. - */ - f = (double)u.ul[H] * (((int)1 << (unsigned int)(INT_BITS - 2)) * 4.0); - f += u.ul[L]; - - return (neg ? -f : f); -} diff --git a/lib/libc/quad/floatdisf_ieee754.c b/lib/libc/quad/floatdisf_ieee754.c deleted file mode 100644 index 6301fcfe8..000000000 --- a/lib/libc/quad/floatdisf_ieee754.c +++ /dev/null @@ -1,90 +0,0 @@ -/* $NetBSD: floatdisf_ieee754.c,v 1.2 2013/08/24 00:51:48 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: floatdisf_ieee754.c,v 1.2 2013/08/24 00:51:48 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include -#include -#include "quad.h" - -float __floatdisf(quad_t); - -/* - * Convert signed quad to float. - */ -float -__floatdisf(quad_t x) -{ - union ieee_single_u ux = { .sngu_f = 0.0 }; - - if (x == 0) - return 0.0; - if (x == 1) - return 1.0; - - if (x < 0) { - if (x == QUAD_MIN) - return -0x1.0p63; - ux.sngu_sign = 1; - x = -x; - } -#if defined(_LP64) || defined(__mips_n32) - u_int l = __builtin_clzll(x); - x <<= (l + 1); /* clear implicit bit */ - - ux.sngu_frac = (u_quad_t)x >> (64 - SNG_FRACBITS); -#else - union uu u = { .uq = x }; - uint32_t frac; - u_int l; - if (u.ul[H] == 0) { - l = __builtin_clz(u.ul[L]); - frac = u.ul[L] << (l + 1); /* clear implicit bit */ - l += 32; - } else { - l = __builtin_clz(u.ul[H]); - frac = u.ul[H] << (l + 1); /* clear implicit bit */ - frac |= u.ul[L] >> (32 - (l + 1)); - } - - ux.sngu_frac = frac >> (32 - SNG_FRACBITS); -#endif - ux.sngu_exp = SNG_EXP_BIAS + 63 - l; - - return ux.sngu_f; -} diff --git a/lib/libc/quad/floatundidf.c b/lib/libc/quad/floatundidf.c deleted file mode 100644 index c2df84f0d..000000000 --- a/lib/libc/quad/floatundidf.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: floatundidf.c,v 1.4 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)floatunsdidf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: floatundidf.c,v 1.4 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -/* - * Convert (unsigned) quad to double. - * This is exactly like floatdidf.c except that negatives never occur. - */ -double -__floatundidf(u_quad_t x) -{ - double d; - union uu u; - - u.uq = x; - d = (double)u.ul[H] * (((int)1 << (unsigned int)(INT_BITS - 2)) * 4.0); - d += u.ul[L]; - return (d); -} diff --git a/lib/libc/quad/floatundidf_ieee754.c b/lib/libc/quad/floatundidf_ieee754.c deleted file mode 100644 index 171945f5c..000000000 --- a/lib/libc/quad/floatundidf_ieee754.c +++ /dev/null @@ -1,65 +0,0 @@ -/* $NetBSD: floatundidf_ieee754.c,v 1.2 2013/09/30 19:32:14 mlelstv Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: floatundidf_ieee754.c,v 1.2 2013/09/30 19:32:14 mlelstv Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include -#include -#include "quad.h" - -/* - * Convert unsigned quad to double. - */ -double -__floatundidf(u_quad_t x) -{ - union ieee_double_u ux = { .dblu_d = 0.0 }; - - if (x == 0) - return 0.0; - - u_int l = __builtin_clzll(x); - x <<= (l + 1); /* clear implicit bit */ - x >>= 64 - (DBL_FRACHBITS + DBL_FRACLBITS); - union uu u = { .uq = x }; - ux.dblu_frach = u.ul[H]; - ux.dblu_fracl = u.ul[L]; - ux.dblu_exp = DBL_EXP_BIAS + 63 - l; - - return ux.dblu_d; -} diff --git a/lib/libc/quad/floatundisf.c b/lib/libc/quad/floatundisf.c deleted file mode 100644 index a2ad3ea50..000000000 --- a/lib/libc/quad/floatundisf.c +++ /dev/null @@ -1,75 +0,0 @@ -/* $NetBSD: floatundisf.c,v 1.4 2013/02/03 01:48:53 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)floatdisf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: floatundisf.c,v 1.4 2013/02/03 01:48:53 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" - -/* - * Convert (unsigned) quad to float. - */ -float -__floatundisf(u_quad_t x) -{ - float f; - union uu u; - - u.q = x; - - /* - * Now u.ul[H] has the factor of 2^32 (or whatever) and u.ul[L] - * has the units. Ideally we could just set f, add INT_BITS to - * its exponent, and then add the units, but this is portable - * code and does not know how to get at an exponent. Machine- - * specific code may be able to do this more efficiently. - * - * Using double here may be excessive paranoia. - */ - f = (double)u.ul[H] * (((int)1 << (unsigned int)(INT_BITS - 2)) * 4.0); - f += u.ul[L]; - - return f; -} diff --git a/lib/libc/quad/floatundisf_ieee754.c b/lib/libc/quad/floatundisf_ieee754.c deleted file mode 100644 index eebbcf807..000000000 --- a/lib/libc/quad/floatundisf_ieee754.c +++ /dev/null @@ -1,83 +0,0 @@ -/* $NetBSD: floatundisf_ieee754.c,v 1.2 2013/08/24 00:51:48 matt Exp $ */ - -/*- - * Copyright (c) 2013 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Matt Thomas of 3am Software Foundry. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: floatundisf_ieee754.c,v 1.2 2013/08/24 00:51:48 matt Exp $"); -#endif /* LIBC_SCCS and not lint */ - -#if defined(SOFTFLOAT) || defined(__ARM_EABI__) -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include -#include "quad.h" - -float __floatundisf(u_quad_t); - -/* - * Convert unsigned quad to float. - */ -float -__floatundisf(u_quad_t x) -{ - union ieee_single_u ux = { .sngu_f = 0.0 }; - - if (x == 0) - return 0.0; - if (x == 1) - return 1.0; - -#if defined(_LP64) || defined(__mips_n32) - u_int l = __builtin_clzll(x); - x <<= (l + 1); /* clear implicit bit */ - - ux.sngu_frac = x >> (64 - SNG_FRACBITS); -#else - union uu u = { .uq = x }; - uint32_t frac; - u_int l; - if (u.ul[H] == 0) { - l = __builtin_clz(u.ul[L]); - frac = u.ul[L] << (l + 1); /* clear implicit bit */ - l += 32; - } else { - l = __builtin_clz(u.ul[H]); - frac = u.ul[H] << (l + 1); /* clear implicit bit */ - frac |= u.ul[L] >> (32 - (l + 1)); - } - - ux.sngu_frac = frac >> (32 - SNG_FRACBITS); -#endif - ux.sngu_exp = SNG_EXP_BIAS + 63 - l; - - return ux.sngu_f; -} diff --git a/lib/libc/quad/floatunditf_ieee754.c b/lib/libc/quad/floatunditf_ieee754.c deleted file mode 100644 index 0d30a9033..000000000 --- a/lib/libc/quad/floatunditf_ieee754.c +++ /dev/null @@ -1,108 +0,0 @@ -/* $NetBSD: floatunditf_ieee754.c,v 1.4 2012/08/05 04:28:58 matt Exp $ */ - -/*- - * 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. - * 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 -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)floatunsdidf.c 8.1 (Berkeley) 6/4/93"; -#else -__RCSID("$NetBSD: floatunditf_ieee754.c,v 1.4 2012/08/05 04:28:58 matt Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#ifdef SOFTFLOAT -#include "softfloat/softfloat-for-gcc.h" -#endif - -#include "quad.h" -#ifdef __vax__ -#error vax does not support a distinct long double -#endif -#include - -/* - * Convert (unsigned) quad to long double. - * This is exactly like floatdidf.c except that negatives never occur. - */ -long double -__floatunditf(u_quad_t x) -{ -#if 0 - long double ld; - union uu u; - - u.uq = x; - ld = (long double)u.ul[H] * (((int)1 << (INT_BITS - 2)) * 4.0); - ld += u.ul[L]; - return (ld); -#else - union ieee_ext_u extu; - quad_t tmp = x; /* must be signed */ - unsigned int width = 64; - unsigned int bit = 0; - quad_t mask = ~(quad_t)0; - - if (x == 0) - return 0.0L; - if (x == 1) - return 1.0L; - - while (mask != 0 && (tmp >= 0)) { - width >>= 1; - mask <<= width; - if ((tmp & mask) == 0) { - tmp <<= width; - bit += width; - } - } - - x <<= (bit + 1); - extu.extu_sign = 0; - extu.extu_exp = EXT_EXP_BIAS + (64 - (bit + 1)); - extu.extu_frach = (unsigned int)(x >> (64 - EXT_FRACHBITS)); - x <<= EXT_FRACHBITS; -#ifdef EXT_FRACHMBITS - extu.extu_frachm =(unsigned int)(x >> (64 - EXT_FRACHMBITS)); - x <<= EXT_FRACHMBITS; -#endif -#ifdef EXT_FRACLMBITS - extu.extu_fraclm =(unsigned int)(x >> (64 - EXT_FRACLMBITS)); - x <<= EXT_FRACLMBITS; -#endif - extu.extu_fracl =(unsigned int)(x >> (64 - EXT_FRACLBITS)); - - return extu.extu_ld; -#endif -} diff --git a/lib/libc/regex/COPYRIGHT b/lib/libc/regex/COPYRIGHT deleted file mode 100644 index f7a8f20c3..000000000 --- a/lib/libc/regex/COPYRIGHT +++ /dev/null @@ -1,54 +0,0 @@ -$NetBSD: COPYRIGHT,v 1.5 2003/08/07 16:43:19 agc Exp $ - -Copyright 1992, 1993, 1994 Henry Spencer. All rights reserved. -This software is not subject to any license of the American Telephone -and Telegraph Company or of the Regents of the University of California. - -Permission is granted to anyone to use this software for any purpose on -any computer system, and to alter it and redistribute it, subject -to the following restrictions: - -1. The author is not responsible for the consequences of use of this - software, no matter how awful, even if they arise from flaws in it. - -2. The origin of this software must not be misrepresented, either by - explicit claim or by omission. Since few users ever read sources, - credits must appear in the documentation. - -3. Altered versions must be plainly marked as such, and must not be - misrepresented as being the original software. Since few users - ever read sources, credits must appear in the documentation. - -4. This notice may not be removed or altered. - -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= -/*- - * Copyright (c) 1994 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)COPYRIGHT 8.1 (Berkeley) 3/16/94 - */ diff --git a/lib/libc/regex/Makefile.inc b/lib/libc/regex/Makefile.inc deleted file mode 100644 index 4dd74cf84..000000000 --- a/lib/libc/regex/Makefile.inc +++ /dev/null @@ -1,14 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.7 1997/11/14 02:04:46 mrg Exp $ -# @(#)Makefile.inc 8.1 (Berkeley) 6/4/93 - -# regex sources -.PATH: ${.CURDIR}/regex - -CPPFLAGS+=-DPOSIX_MISTAKE - -SRCS+= regcomp.c regerror.c regexec.c regfree.c - -MAN+= regex.3 re_format.7 - -MLINKS+=regex.3 regcomp.3 regex.3 regexec.3 regex.3 regerror.3 \ - regex.3 regfree.3 diff --git a/lib/libc/regex/WHATSNEW b/lib/libc/regex/WHATSNEW deleted file mode 100644 index 93eb93606..000000000 --- a/lib/libc/regex/WHATSNEW +++ /dev/null @@ -1,95 +0,0 @@ -# $NetBSD: WHATSNEW,v 1.6 1995/02/27 13:28:25 cgd Exp $ -# @(#)WHATSNEW 8.3 (Berkeley) 3/18/94 - -New in alpha3.4: The complex bug alluded to below has been fixed (in a -slightly kludgey temporary way that may hurt efficiency a bit; this is -another "get it out the door for 4.4" release). The tests at the end of -the tests file have accordingly been uncommented. The primary sign of -the bug was that something like a?b matching ab matched b rather than ab. -(The bug was essentially specific to this exact situation, else it would -have shown up earlier.) - -New in alpha3.3: The definition of word boundaries has been altered -slightly, to more closely match the usual programming notion that "_" -is an alphabetic. Stuff used for pre-ANSI systems is now in a subdir, -and the makefile no longer alludes to it in mysterious ways. The -makefile has generally been cleaned up some. Fixes have been made -(again!) so that the regression test will run without -DREDEBUG, at -the cost of weaker checking. A workaround for a bug in some folks' - has been added. And some more things have been added to -tests, including a couple right at the end which are commented out -because the code currently flunks them (complex bug; fix coming). -Plus the usual minor cleanup. - -New in alpha3.2: Assorted bits of cleanup and portability improvement -(the development base is now a BSDI system using GCC instead of an ancient -Sun system, and the newer compiler exposed some glitches). Fix for a -serious bug that affected REs using many [] (including REG_ICASE REs -because of the way they are implemented), *sometimes*, depending on -memory-allocation patterns. The header-file prototypes no longer name -the parameters, avoiding possible name conflicts. The possibility that -some clot has defined CHAR_MIN as (say) `-128' instead of `(-128)' is -now handled gracefully. "uchar" is no longer used as an internal type -name (too many people have the same idea). Still the same old lousy -performance, alas. - -New in alpha3.1: Basically nothing, this release is just a bookkeeping -convenience. Stay tuned. - -New in alpha3.0: Performance is no better, alas, but some fixes have been -made and some functionality has been added. (This is basically the "get -it out the door in time for 4.4" release.) One bug fix: regfree() didn't -free the main internal structure (how embarrassing). It is now possible -to put NULs in either the RE or the target string, using (resp.) a new -REG_PEND flag and the old REG_STARTEND flag. The REG_NOSPEC flag to -regcomp() makes all characters ordinary, so you can match a literal -string easily (this will become more useful when performance improves!). -There are now primitives to match beginnings and ends of words, although -the syntax is disgusting and so is the implementation. The REG_ATOI -debugging interface has changed a bit. And there has been considerable -internal cleanup of various kinds. - -New in alpha2.3: Split change list out of README, and moved flags notes -into Makefile. Macro-ized the name of regex(7) in regex(3), since it has -to change for 4.4BSD. Cleanup work in engine.c, and some new regression -tests to catch tricky cases thereof. - -New in alpha2.2: Out-of-date manpages updated. Regerror() acquires two -small extensions -- REG_ITOA and REG_ATOI -- which avoid debugging kludges -in my own test program and might be useful to others for similar purposes. -The regression test will now compile (and run) without REDEBUG. The -BRE \$ bug is fixed. Most uses of "uchar" are gone; it's all chars now. -Char/uchar parameters are now written int/unsigned, to avoid possible -portability problems with unpromoted parameters. Some unsigned casts have -been introduced to minimize portability problems with shifting into sign -bits. - -New in alpha2.1: Lots of little stuff, cleanup and fixes. The one big -thing is that regex.h is now generated, using mkh, rather than being -supplied in the distribution; due to circularities in dependencies, -you have to build regex.h explicitly by "make h". The two known bugs -have been fixed (and the regression test now checks for them), as has a -problem with assertions not being suppressed in the absence of REDEBUG. -No performance work yet. - -New in alpha2: Backslash-anything is an ordinary character, not an -error (except, of course, for the handful of backslashed metacharacters -in BREs), which should reduce script breakage. The regression test -checks *where* null strings are supposed to match, and has generally -been tightened up somewhat. Small bug fixes in parameter passing (not -harmful, but technically errors) and some other areas. Debugging -invoked by defining REDEBUG rather than not defining NDEBUG. - -New in alpha+3: full prototyping for internal routines, using a little -helper program, mkh, which extracts prototypes given in stylized comments. -More minor cleanup. Buglet fix: it's CHAR_BIT, not CHAR_BITS. Simple -pre-screening of input when a literal string is known to be part of the -RE; this does wonders for performance. - -New in alpha+2: minor bits of cleanup. Notably, the number "32" for the -word width isn't hardwired into regexec.c any more, the public header -file prototypes the functions if __STDC__ is defined, and some small typos -in the manpages have been fixed. - -New in alpha+1: improvements to the manual pages, and an important -extension, the REG_STARTEND option to regexec(). diff --git a/lib/libc/regex/cclass.h b/lib/libc/regex/cclass.h deleted file mode 100644 index 3ab2ccba4..000000000 --- a/lib/libc/regex/cclass.h +++ /dev/null @@ -1,104 +0,0 @@ -/* $NetBSD: cclass.h,v 1.7 2003/08/07 16:43:19 agc Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)cclass.h 8.3 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)cclass.h 8.3 (Berkeley) 3/20/94 - */ - -/* character-class table */ -static const struct cclass { - const char *name; - const char *chars; - const char *multis; -} cclasses[] = { - { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789", "" }, - { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", - "" }, - { "blank", " \t", "" }, - { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\ -\25\26\27\30\31\32\33\34\35\36\37\177", "" }, - { "digit", "0123456789", "" }, - { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - "" }, - { "lower", "abcdefghijklmnopqrstuvwxyz", - "" }, - { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz\ -0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", - "" }, - { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", - "" }, - { "space", "\t\n\v\f\r ", "" }, - { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", - "" }, - { "xdigit", "0123456789ABCDEFabcdef", - "" }, - { NULL, 0, "" } -}; diff --git a/lib/libc/regex/cname.h b/lib/libc/regex/cname.h deleted file mode 100644 index 4b9ef3919..000000000 --- a/lib/libc/regex/cname.h +++ /dev/null @@ -1,175 +0,0 @@ -/* $NetBSD: cname.h,v 1.7 2003/08/07 16:43:19 agc Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)cname.h 8.3 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)cname.h 8.3 (Berkeley) 3/20/94 - */ - -/* character-name table */ -static const struct cname { - const char *name; - char code; -} cnames[] = { - { "NUL", '\0' }, - { "SOH", '\001' }, - { "STX", '\002' }, - { "ETX", '\003' }, - { "EOT", '\004' }, - { "ENQ", '\005' }, - { "ACK", '\006' }, - { "BEL", '\007' }, - { "alert", '\007' }, - { "BS", '\010' }, - { "backspace", '\b' }, - { "HT", '\011' }, - { "tab", '\t' }, - { "LF", '\012' }, - { "newline", '\n' }, - { "VT", '\013' }, - { "vertical-tab", '\v' }, - { "FF", '\014' }, - { "form-feed", '\f' }, - { "CR", '\015' }, - { "carriage-return", '\r' }, - { "SO", '\016' }, - { "SI", '\017' }, - { "DLE", '\020' }, - { "DC1", '\021' }, - { "DC2", '\022' }, - { "DC3", '\023' }, - { "DC4", '\024' }, - { "NAK", '\025' }, - { "SYN", '\026' }, - { "ETB", '\027' }, - { "CAN", '\030' }, - { "EM", '\031' }, - { "SUB", '\032' }, - { "ESC", '\033' }, - { "IS4", '\034' }, - { "FS", '\034' }, - { "IS3", '\035' }, - { "GS", '\035' }, - { "IS2", '\036' }, - { "RS", '\036' }, - { "IS1", '\037' }, - { "US", '\037' }, - { "space", ' ' }, - { "exclamation-mark", '!' }, - { "quotation-mark", '"' }, - { "number-sign", '#' }, - { "dollar-sign", '$' }, - { "percent-sign", '%' }, - { "ampersand", '&' }, - { "apostrophe", '\'' }, - { "left-parenthesis", '(' }, - { "right-parenthesis", ')' }, - { "asterisk", '*' }, - { "plus-sign", '+' }, - { "comma", ',' }, - { "hyphen", '-' }, - { "hyphen-minus", '-' }, - { "period", '.' }, - { "full-stop", '.' }, - { "slash", '/' }, - { "solidus", '/' }, - { "zero", '0' }, - { "one", '1' }, - { "two", '2' }, - { "three", '3' }, - { "four", '4' }, - { "five", '5' }, - { "six", '6' }, - { "seven", '7' }, - { "eight", '8' }, - { "nine", '9' }, - { "colon", ':' }, - { "semicolon", ';' }, - { "less-than-sign", '<' }, - { "equals-sign", '=' }, - { "greater-than-sign", '>' }, - { "question-mark", '?' }, - { "commercial-at", '@' }, - { "left-square-bracket", '[' }, - { "backslash", '\\' }, - { "reverse-solidus", '\\' }, - { "right-square-bracket", ']' }, - { "circumflex", '^' }, - { "circumflex-accent", '^' }, - { "underscore", '_' }, - { "low-line", '_' }, - { "grave-accent", '`' }, - { "left-brace", '{' }, - { "left-curly-bracket", '{' }, - { "vertical-line", '|' }, - { "right-brace", '}' }, - { "right-curly-bracket", '}' }, - { "tilde", '~' }, - { "DEL", '\177' }, - { NULL, 0 }, -}; diff --git a/lib/libc/regex/engine.c b/lib/libc/regex/engine.c deleted file mode 100644 index 2a800d4ff..000000000 --- a/lib/libc/regex/engine.c +++ /dev/null @@ -1,1188 +0,0 @@ -/* $NetBSD: engine.c,v 1.24 2012/03/13 21:13:42 christos Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)engine.c 8.5 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)engine.c 8.5 (Berkeley) 3/20/94 - */ - -/* - * The matching engine and friends. This file is #included by regexec.c - * after suitable #defines of a variety of macros used herein, so that - * different state representations can be used without duplicating masses - * of code. - */ - -#ifdef SNAMES -#define matcher smatcher -#define fast sfast -#define slow sslow -#define dissect sdissect -#define backref sbackref -#define step sstep -#define print sprint -#define at sat -#define match smat -#define nope snope -#endif -#ifdef LNAMES -#define matcher lmatcher -#define fast lfast -#define slow lslow -#define dissect ldissect -#define backref lbackref -#define step lstep -#define print lprint -#define at lat -#define match lmat -#define nope lnope -#endif - -/* another structure passed up and down to avoid zillions of parameters */ -struct match { - struct re_guts *g; - int eflags; - regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ - const char *offp; /* offsets work from here */ - const char *beginp; /* start of string -- virtual NUL precedes */ - const char *endp; /* end of string -- virtual NUL here */ - const char *coldp; /* can be no match starting before here */ - const char **lastpos; /* [nplus+1] */ - STATEVARS; - states st; /* current states */ - states fresh; /* states for a fresh start */ - states tmp; /* temporary */ - states empty; /* empty set of states */ -}; - -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === engine.c === */ -static int matcher(struct re_guts *g, const char *string, size_t nmatch, regmatch_t pmatch[], int eflags); -static const char *dissect(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst); -static const char *backref(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst, sopno lev); -static const char *fast(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst); -static const char *slow(struct match *m, const char *start, const char *stop, sopno startst, sopno stopst); -static states step(struct re_guts *g, sopno start, sopno stop, states bef, int ch, states aft); -#define BOL (OUT+1) -#define EOL (BOL+1) -#define BOLEOL (BOL+2) -#define NOTHING (BOL+3) -#define BOW (BOL+4) -#define EOW (BOL+5) -#define CODEMAX (BOL+5) /* highest code used */ -#define NONCHAR(c) ((c) > CHAR_MAX) -#define NNONCHAR (CODEMAX-CHAR_MAX) -#ifdef REDEBUG -static void print(struct match *m, char *caption, states st, int ch, FILE *d); -#endif -#ifdef REDEBUG -static void at(struct match *m, char *title, char *start, char *stop, sopno startst, sopno stopst); -#endif -#ifdef REDEBUG -static char *pchar(int ch); -#endif - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ - -#ifdef REDEBUG -#define SP(t, s, c) print(m, t, s, c, stdout) -#define AT(t, p1, p2, s1, s2) at(m, t, p1, p2, s1, s2) -#define NOTE(str) { if (m->eflags®_TRACE) printf("=%s\n", (str)); } -static int nope = 0; -#else -#define SP(t, s, c) /* nothing */ -#define AT(t, p1, p2, s1, s2) /* nothing */ -#define NOTE(s) /* nothing */ -#endif - -/* - - matcher - the actual matching engine - == static int matcher(struct re_guts *g, char *string, \ - == size_t nmatch, regmatch_t pmatch[], int eflags); - */ -static int /* 0 success, REG_NOMATCH failure */ -matcher( - struct re_guts *g, - const char *string, - size_t nmatch, - regmatch_t pmatch[], - int eflags) -{ - const char *endp; - size_t i; - struct match mv; - struct match *m = &mv; - const char *dp; - const sopno gf = g->firststate+1; /* +1 for OEND */ - const sopno gl = g->laststate; - const char *start; - const char *stop; - int error = 0; - - _DIAGASSERT(g != NULL); - _DIAGASSERT(string != NULL); - /* pmatch checked below */ - - /* simplify the situation where possible */ - if (g->cflags®_NOSUB) - nmatch = 0; - if (eflags®_STARTEND) { - _DIAGASSERT(pmatch != NULL); - start = string + (size_t)pmatch[0].rm_so; - stop = string + (size_t)pmatch[0].rm_eo; - } else { - start = string; - stop = start + strlen(start); - } - if (stop < start) - return(REG_INVARG); - - /* prescreening; this does wonders for this rather slow code */ - if (g->must != NULL) { - for (dp = start; dp < stop; dp++) - if (*dp == g->must[0] && (size_t)(stop - dp) >= g->mlen && - memcmp(dp, g->must, g->mlen) == 0) - break; - if (dp == stop) /* we didn't find g->must */ - return(REG_NOMATCH); - } - - /* match struct setup */ - m->g = g; - m->eflags = eflags; - m->pmatch = NULL; - m->lastpos = NULL; - m->offp = string; - m->beginp = start; - m->endp = stop; - STATESETUP(m, 4); - SETUP(m->st); - SETUP(m->fresh); - SETUP(m->tmp); - SETUP(m->empty); - CLEAR(m->empty); - - /* this loop does only one repetition except for backrefs */ - for (;;) { - endp = fast(m, start, stop, gf, gl); - if (endp == NULL) { /* a miss */ - error = REG_NOMATCH; - goto done; - } - if (nmatch == 0 && !g->backrefs) - break; /* no further info needed */ - - /* where? */ - assert(m->coldp != NULL); - for (;;) { - NOTE("finding start"); - endp = slow(m, m->coldp, stop, gf, gl); - if (endp != NULL) - break; - assert(m->coldp < m->endp); - m->coldp++; - } - if (nmatch == 1 && !g->backrefs) - break; /* no further info needed */ - - /* oh my, he wants the subexpressions... */ - if (m->pmatch == NULL) - m->pmatch = (regmatch_t *)malloc((m->g->nsub + 1) * - sizeof(regmatch_t)); - if (m->pmatch == NULL) { - error = REG_ESPACE; - goto done; - } - for (i = 1; i <= m->g->nsub; i++) - m->pmatch[i].rm_so = m->pmatch[i].rm_eo = (regoff_t)-1; - if (!g->backrefs && !(m->eflags®_BACKR)) { - NOTE("dissecting"); - dp = dissect(m, m->coldp, endp, gf, gl); - } else { - if (g->nplus > 0 && m->lastpos == NULL) - m->lastpos = malloc((g->nplus+1) * - sizeof(const char *)); - if (g->nplus > 0 && m->lastpos == NULL) { - error = REG_ESPACE; - goto done; - } - NOTE("backref dissect"); - dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); - } - if (dp != NULL) - break; - - /* uh-oh... we couldn't find a subexpression-level match */ - assert(g->backrefs); /* must be back references doing it */ - assert(g->nplus == 0 || m->lastpos != NULL); - for (;;) { - if (dp != NULL || endp <= m->coldp) - break; /* defeat */ - NOTE("backoff"); - endp = slow(m, m->coldp, endp-1, gf, gl); - if (endp == NULL) - break; /* defeat */ - /* try it on a shorter possibility */ -#ifndef NDEBUG - for (i = 1; i <= m->g->nsub; i++) { - assert(m->pmatch[i].rm_so == (regoff_t)-1); - assert(m->pmatch[i].rm_eo == (regoff_t)-1); - } -#endif - NOTE("backoff dissect"); - dp = backref(m, m->coldp, endp, gf, gl, (sopno)0); - } - assert(dp == NULL || dp == endp); - if (dp != NULL) /* found a shorter one */ - break; - - /* despite initial appearances, there is no match here */ - NOTE("false alarm"); - start = m->coldp + 1; /* recycle starting later */ - assert(start <= stop); - } - - /* fill in the details if requested */ - if (nmatch > 0) { - _DIAGASSERT(pmatch != NULL); - pmatch[0].rm_so = m->coldp - m->offp; - pmatch[0].rm_eo = endp - m->offp; - } - if (nmatch > 1) { - assert(m->pmatch != NULL); - for (i = 1; i < nmatch; i++) - if (i <= m->g->nsub) - pmatch[i] = m->pmatch[i]; - else { - pmatch[i].rm_so = (regoff_t)-1; - pmatch[i].rm_eo = (regoff_t)-1; - } - } - -done: - if (m->pmatch != NULL) { - free(m->pmatch); - m->pmatch = NULL; - } - if (m->lastpos != NULL) { - free(m->lastpos); - m->lastpos = NULL; - } - STATETEARDOWN(m); - return error; -} - -/* - - dissect - figure out what matched what, no back references - == static const char *dissect(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst); - */ -static const char * /* == stop (success) always */ -dissect( - struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst) -{ - int i; - sopno ss; /* start sop of current subRE */ - sopno es; /* end sop of current subRE */ - const char *sp; /* start of string matched by it */ - const char *stp; /* string matched by it cannot pass here */ - const char *rest; /* start of rest of string */ - const char *tail; /* string unmatched by rest of RE */ - sopno ssub; /* start sop of subsubRE */ - sopno esub; /* end sop of subsubRE */ - const char *ssp; /* start of string matched by subsubRE */ - const char *sep; /* end of string matched by subsubRE */ - const char *oldssp; /* previous ssp */ -#ifndef NDEBUG - const char *dp; -#endif - - _DIAGASSERT(m != NULL); - _DIAGASSERT(start != NULL); - _DIAGASSERT(stop != NULL); - - AT("diss", start, stop, startst, stopst); - sp = start; - for (ss = startst; ss < stopst; ss = es) { - /* identify end of subRE */ - es = ss; - switch (OP(m->g->strip[es])) { - case OPLUS_: - case OQUEST_: - es += OPND(m->g->strip[es]); - break; - case OCH_: - while (OP(m->g->strip[es]) != O_CH) - es += OPND(m->g->strip[es]); - break; - } - es++; - - /* figure out what it matched */ - switch (OP(m->g->strip[ss])) { - case OEND: - assert(nope); - break; - case OCHAR: - sp++; - break; - case OBOL: - case OEOL: - case OBOW: - case OEOW: - break; - case OANY: - case OANYOF: - sp++; - break; - case OBACK_: - case O_BACK: - assert(nope); - break; - /* cases where length of match is hard to find */ - case OQUEST_: - stp = stop; - for (;;) { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = es - 1; - /* did innards match? */ - if (slow(m, sp, rest, ssub, esub) != NULL) { -#ifdef NDEBUG - (void) -#else - dp = -#endif - dissect(m, sp, rest, ssub, esub); - assert(dp == rest); - } else /* no */ - assert(sp == rest); - sp = rest; - break; - case OPLUS_: - stp = stop; - for (;;) { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = es - 1; - ssp = sp; - oldssp = ssp; - for (;;) { /* find last match of innards */ - sep = slow(m, ssp, rest, ssub, esub); - if (sep == NULL || sep == ssp) - break; /* failed or matched null */ - oldssp = ssp; /* on to next try */ - ssp = sep; - } - if (sep == NULL) { - /* last successful match */ - sep = ssp; - ssp = oldssp; - } - assert(sep == rest); /* must exhaust substring */ - assert(slow(m, ssp, sep, ssub, esub) == rest); -#ifdef NDEBUG - (void) -#else - dp = -#endif - dissect(m, ssp, sep, ssub, esub); - assert(dp == sep); - sp = rest; - break; - case OCH_: - stp = stop; - for (;;) { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = ss + OPND(m->g->strip[ss]) - 1; - assert(OP(m->g->strip[esub]) == OOR1); - for (;;) { /* find first matching branch */ - if (slow(m, sp, rest, ssub, esub) == rest) - break; /* it matched all of it */ - /* that one missed, try next one */ - assert(OP(m->g->strip[esub]) == OOR1); - esub++; - assert(OP(m->g->strip[esub]) == OOR2); - ssub = esub + 1; - esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) - esub--; - else - assert(OP(m->g->strip[esub]) == O_CH); - } -#ifdef NDEBUG - (void) -#else - dp = -#endif - dissect(m, sp, rest, ssub, esub); - assert(dp == rest); - sp = rest; - break; - case O_PLUS: - case O_QUEST: - case OOR1: - case OOR2: - case O_CH: - assert(nope); - break; - case OLPAREN: - i = OPND(m->g->strip[ss]); - assert(0 < i && i <= m->g->nsub); - m->pmatch[i].rm_so = sp - m->offp; - break; - case ORPAREN: - i = OPND(m->g->strip[ss]); - assert(0 < i && i <= m->g->nsub); - m->pmatch[i].rm_eo = sp - m->offp; - break; - default: /* uh oh */ - assert(nope); - break; - } - } - - assert(sp == stop); - return(sp); -} - -/* - - backref - figure out what matched what, figuring in back references - == static const char *backref(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst, sopno lev); - */ -static const char * /* == stop (success) or NULL (failure) */ -backref( - struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst, - sopno lev) /* PLUS nesting level */ -{ - int i; - sopno ss; /* start sop of current subRE */ - const char *sp; /* start of string matched by it */ - sopno ssub; /* start sop of subsubRE */ - sopno esub; /* end sop of subsubRE */ - const char *ssp; /* start of string matched by subsubRE */ - const char *dp; - size_t len; - int hard; - sop s; - regoff_t offsave; - cset *cs; - - _DIAGASSERT(m != NULL); - _DIAGASSERT(start != NULL); - _DIAGASSERT(stop != NULL); - - AT("back", start, stop, startst, stopst); - sp = start; - - /* get as far as we can with easy stuff */ - hard = 0; - for (ss = startst; !hard && ss < stopst; ss++) - switch (OP(s = m->g->strip[ss])) { - case OCHAR: - if (sp == stop || *sp++ != (char)OPND(s)) - return(NULL); - break; - case OANY: - if (sp == stop) - return(NULL); - sp++; - break; - case OANYOF: - cs = &m->g->sets[OPND(s)]; - if (sp == stop || !CHIN(cs, *sp++)) - return(NULL); - break; - case OBOL: - if ( (sp == m->beginp && !(m->eflags®_NOTBOL)) || - (sp < m->endp && *(sp-1) == '\n' && - (m->g->cflags®_NEWLINE)) ) - { /* yes */ } - else - return(NULL); - break; - case OEOL: - if ( (sp == m->endp && !(m->eflags®_NOTEOL)) || - (sp < m->endp && *sp == '\n' && - (m->g->cflags®_NEWLINE)) ) - { /* yes */ } - else - return(NULL); - break; - case OBOW: - if (( (sp == m->beginp && !(m->eflags®_NOTBOL)) || - (sp < m->endp && *(sp-1) == '\n' && - (m->g->cflags®_NEWLINE)) || - (sp > m->beginp && - !ISWORD(*(sp-1))) ) && - (sp < m->endp && ISWORD(*sp)) ) - { /* yes */ } - else - return(NULL); - break; - case OEOW: - if (( (sp == m->endp && !(m->eflags®_NOTEOL)) || - (sp < m->endp && *sp == '\n' && - (m->g->cflags®_NEWLINE)) || - (sp < m->endp && !ISWORD(*sp)) ) && - (sp > m->beginp && ISWORD(*(sp-1))) ) - { /* yes */ } - else - return(NULL); - break; - case O_QUEST: - break; - case OOR1: /* matches null but needs to skip */ - ss++; - s = m->g->strip[ss]; - do { - assert(OP(s) == OOR2); - ss += OPND(s); - } while (OP(s = m->g->strip[ss]) != O_CH); - /* note that the ss++ gets us past the O_CH */ - break; - default: /* have to make a choice */ - hard = 1; - break; - } - if (!hard) { /* that was it! */ - if (sp != stop) - return(NULL); - return(sp); - } - ss--; /* adjust for the for's final increment */ - - /* the hard stuff */ - AT("hard", sp, stop, ss, stopst); - s = m->g->strip[ss]; - switch (OP(s)) { - case OBACK_: /* the vilest depths */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - if (m->pmatch[i].rm_eo == (regoff_t)-1) - return(NULL); - assert(m->pmatch[i].rm_so != (regoff_t)-1); - len = (size_t)(m->pmatch[i].rm_eo - m->pmatch[i].rm_so); - if (len == 0) - return(NULL); - assert(stop - m->beginp >= len); - if (sp > stop - len) - return(NULL); /* not enough left to match */ - ssp = m->offp + (size_t)m->pmatch[i].rm_so; - if (memcmp(sp, ssp, len) != 0) - return(NULL); - while (m->g->strip[ss] != SOP(O_BACK, i)) - ss++; - return(backref(m, sp+len, stop, ss+1, stopst, lev)); - - case OQUEST_: /* to null or not */ - dp = backref(m, sp, stop, ss+1, stopst, lev); - if (dp != NULL) - return(dp); /* not */ - return(backref(m, sp, stop, ss+OPND(s)+1, stopst, lev)); - - case OPLUS_: - assert(m->lastpos != NULL); - assert(lev+1 <= m->g->nplus); - m->lastpos[lev+1] = sp; - return(backref(m, sp, stop, ss+1, stopst, lev+1)); - - case O_PLUS: - if (sp == m->lastpos[lev]) /* last pass matched null */ - return(backref(m, sp, stop, ss+1, stopst, lev-1)); - /* try another pass */ - m->lastpos[lev] = sp; - dp = backref(m, sp, stop, ss-OPND(s)+1, stopst, lev); - if (dp == NULL) - dp = backref(m, sp, stop, ss+1, stopst, lev-1); - return(dp); - - case OCH_: /* find the right one, if any */ - ssub = ss + 1; - esub = ss + OPND(s) - 1; - assert(OP(m->g->strip[esub]) == OOR1); - for (;;) { /* find first matching branch */ - dp = backref(m, sp, stop, ssub, esub, lev); - if (dp != NULL) - return(dp); - /* that one missed, try next one */ - if (OP(m->g->strip[esub]) == O_CH) - return(NULL); /* there is none */ - esub++; - assert(OP(m->g->strip[esub]) == OOR2); - ssub = esub + 1; - esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) - esub--; - else - assert(OP(m->g->strip[esub]) == O_CH); - } - - case OLPAREN: /* must undo assignment if rest fails */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - offsave = m->pmatch[i].rm_so; - m->pmatch[i].rm_so = sp - m->offp; - dp = backref(m, sp, stop, ss+1, stopst, lev); - if (dp != NULL) - return(dp); - m->pmatch[i].rm_so = offsave; - return(NULL); - - case ORPAREN: /* must undo assignment if rest fails */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - offsave = m->pmatch[i].rm_eo; - m->pmatch[i].rm_eo = sp - m->offp; - dp = backref(m, sp, stop, ss+1, stopst, lev); - if (dp != NULL) - return(dp); - m->pmatch[i].rm_eo = offsave; - return(NULL); - - default: /* uh oh */ - assert(nope); - break; - } - - /* "can't happen" */ - assert(nope); - /* NOTREACHED */ - return NULL; -} - -/* - - fast - step through the string at top speed - == static const char *fast(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst); - */ -static const char * /* where tentative match ended, or NULL */ -fast( - struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst) -{ - states st = m->st; - states fresh = m->fresh; - states tmp = m->tmp; - const char *p = start; - int c = (start == m->beginp) ? OUT : *(start-1); - int lastc; /* previous c */ - int flagch; - size_t i; - const char *coldp; /* last p after which no match was underway */ - - _DIAGASSERT(m != NULL); - _DIAGASSERT(start != NULL); - _DIAGASSERT(stop != NULL); - - CLEAR(st); - SET1(st, startst); - st = step(m->g, startst, stopst, st, NOTHING, st); - ASSIGN(fresh, st); - SP("start", st, *p); - coldp = NULL; - for (;;) { - /* next character */ - lastc = c; - c = (p == m->endp) ? OUT : *p; - if (EQ(st, fresh)) - coldp = p; - - /* is there an EOL and/or BOL between lastc and c? */ - flagch = '\0'; - i = 0; - if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || - (lastc == OUT && !(m->eflags®_NOTBOL)) ) { - flagch = BOL; - i = m->g->nbol; - } - if ( (c == '\n' && m->g->cflags®_NEWLINE) || - (c == OUT && !(m->eflags®_NOTEOL)) ) { - flagch = (flagch == BOL) ? BOLEOL : EOL; - i += m->g->neol; - } - if (i != 0) { - for (; i > 0; i--) - st = step(m->g, startst, stopst, st, flagch, st); - SP("boleol", st, c); - } - - /* how about a word boundary? */ - if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && - (c != OUT && ISWORD(c)) ) { - flagch = BOW; - } - if ( (lastc != OUT && ISWORD(lastc)) && - (flagch == EOL || (c != OUT && !ISWORD(c))) ) { - flagch = EOW; - } - if (flagch == BOW || flagch == EOW) { - st = step(m->g, startst, stopst, st, flagch, st); - SP("boweow", st, c); - } - - /* are we done? */ - if (ISSET(st, stopst) || p == stop) - break; /* NOTE BREAK OUT */ - - /* no, we must deal with this character */ - ASSIGN(tmp, st); - ASSIGN(st, fresh); - assert(c != OUT); - st = step(m->g, startst, stopst, tmp, c, st); - SP("aft", st, c); - assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); - p++; - } - - assert(coldp != NULL); - m->coldp = coldp; - if (ISSET(st, stopst)) - return(p+1); - else - return(NULL); -} - -/* - - slow - step through the string more deliberately - == static const char *slow(struct match *m, const char *start, \ - == const char *stop, sopno startst, sopno stopst); - */ -static const char * /* where it ended */ -slow( - struct match *m, - const char *start, - const char *stop, - sopno startst, - sopno stopst) -{ - states st = m->st; - states empty = m->empty; - states tmp = m->tmp; - const char *p = start; - int c = (start == m->beginp) ? OUT : *(start-1); - int lastc; /* previous c */ - int flagch; - size_t i; - const char *matchp; /* last p at which a match ended */ - - _DIAGASSERT(m != NULL); - _DIAGASSERT(start != NULL); - _DIAGASSERT(stop != NULL); - - AT("slow", start, stop, startst, stopst); - CLEAR(st); - SET1(st, startst); - SP("sstart", st, *p); - st = step(m->g, startst, stopst, st, NOTHING, st); - matchp = NULL; - for (;;) { - /* next character */ - lastc = c; - c = (p == m->endp) ? OUT : *p; - - /* is there an EOL and/or BOL between lastc and c? */ - flagch = '\0'; - i = 0; - if ( (lastc == '\n' && m->g->cflags®_NEWLINE) || - (lastc == OUT && !(m->eflags®_NOTBOL)) ) { - flagch = BOL; - i = m->g->nbol; - } - if ( (c == '\n' && m->g->cflags®_NEWLINE) || - (c == OUT && !(m->eflags®_NOTEOL)) ) { - flagch = (flagch == BOL) ? BOLEOL : EOL; - i += m->g->neol; - } - if (i != 0) { - for (; i > 0; i--) - st = step(m->g, startst, stopst, st, flagch, st); - SP("sboleol", st, c); - } - - /* how about a word boundary? */ - if ( (flagch == BOL || (lastc != OUT && !ISWORD(lastc))) && - (c != OUT && ISWORD(c)) ) { - flagch = BOW; - } - if ( (lastc != OUT && ISWORD(lastc)) && - (flagch == EOL || (c != OUT && !ISWORD(c))) ) { - flagch = EOW; - } - if (flagch == BOW || flagch == EOW) { - st = step(m->g, startst, stopst, st, flagch, st); - SP("sboweow", st, c); - } - - /* are we done? */ - if (ISSET(st, stopst)) - matchp = p; - if (EQ(st, empty) || p == stop) - break; /* NOTE BREAK OUT */ - - /* no, we must deal with this character */ - ASSIGN(tmp, st); - ASSIGN(st, empty); - assert(c != OUT); - st = step(m->g, startst, stopst, tmp, c, st); - SP("saft", st, c); - assert(EQ(step(m->g, startst, stopst, st, NOTHING, st), st)); - p++; - } - - return(matchp); -} - - -/* - - step - map set of states reachable before char to set reachable after - == static states step(struct re_guts *g, sopno start, sopno stop, \ - == states bef, int ch, states aft); - == #define BOL (OUT+1) - == #define EOL (BOL+1) - == #define BOLEOL (BOL+2) - == #define NOTHING (BOL+3) - == #define BOW (BOL+4) - == #define EOW (BOL+5) - == #define CODEMAX (BOL+5) // highest code used - == #define NONCHAR(c) ((c) > CHAR_MAX) - == #define NNONCHAR (CODEMAX-CHAR_MAX) - */ -static states -step( - struct re_guts *g, - sopno start, /* start state within strip */ - sopno stop, /* state after stop state within strip */ - states bef, /* states reachable before */ - int ch, /* character or NONCHAR code */ - states aft) /* states already known reachable after */ -{ - cset *cs; - sop s; - sopno pc; - onestate here; /* note, macros know this name */ - sopno look; - int i; - - _DIAGASSERT(g != NULL); - - for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) { - s = g->strip[pc]; - switch (OP(s)) { - case OEND: - assert(pc == stop-1); - break; - case OCHAR: - /* only characters can match */ - assert(!NONCHAR(ch) || ch != (char)OPND(s)); - if (ch == (char)OPND(s)) - FWD(aft, bef, 1); - break; - case OBOL: - if (ch == BOL || ch == BOLEOL) - FWD(aft, bef, 1); - break; - case OEOL: - if (ch == EOL || ch == BOLEOL) - FWD(aft, bef, 1); - break; - case OBOW: - if (ch == BOW) - FWD(aft, bef, 1); - break; - case OEOW: - if (ch == EOW) - FWD(aft, bef, 1); - break; - case OANY: - if (!NONCHAR(ch)) - FWD(aft, bef, 1); - break; - case OANYOF: - cs = &g->sets[OPND(s)]; - if (!NONCHAR(ch) && CHIN(cs, ch)) - FWD(aft, bef, 1); - break; - case OBACK_: /* ignored here */ - case O_BACK: - FWD(aft, aft, 1); - break; - case OPLUS_: /* forward, this is just an empty */ - FWD(aft, aft, 1); - break; - case O_PLUS: /* both forward and back */ - FWD(aft, aft, 1); - i = ISSETBACK(aft, OPND(s)); - BACK(aft, aft, OPND(s)); - if (!i && ISSETBACK(aft, OPND(s))) { - /* oho, must reconsider loop body */ - pc -= OPND(s) + 1; - INIT(here, pc); - } - break; - case OQUEST_: /* two branches, both forward */ - FWD(aft, aft, 1); - FWD(aft, aft, OPND(s)); - break; - case O_QUEST: /* just an empty */ - FWD(aft, aft, 1); - break; - case OLPAREN: /* not significant here */ - case ORPAREN: - FWD(aft, aft, 1); - break; - case OCH_: /* mark the first two branches */ - FWD(aft, aft, 1); - assert(OP(g->strip[pc+OPND(s)]) == OOR2); - FWD(aft, aft, OPND(s)); - break; - case OOR1: /* done a branch, find the O_CH */ - if (ISSTATEIN(aft, here)) { - for (look = 1; - OP(s = g->strip[pc+look]) != O_CH; - look += OPND(s)) - assert(OP(s) == OOR2); - FWD(aft, aft, look); - } - break; - case OOR2: /* propagate OCH_'s marking */ - FWD(aft, aft, 1); - if (OP(g->strip[pc+OPND(s)]) != O_CH) { - assert(OP(g->strip[pc+OPND(s)]) == OOR2); - FWD(aft, aft, OPND(s)); - } - break; - case O_CH: /* just empty */ - FWD(aft, aft, 1); - break; - default: /* ooooops... */ - assert(nope); - break; - } - } - - return(aft); -} - -#ifdef REDEBUG -/* - - print - print a set of states - == #ifdef REDEBUG - == static void print(struct match *m, char *caption, states st, \ - == int ch, FILE *d); - == #endif - */ -static void -print( - struct match *m, - char *caption, - states st, - int ch, - FILE *d) -{ - struct re_guts *g = m->g; - int i; - int first = 1; - - _DIAGASSERT(m != NULL); - _DIAGASSERT(caption != NULL); - - if (!(m->eflags®_TRACE)) - return; - - _DIAGASSERT(d != NULL); - - fprintf(d, "%s", caption); - if (ch != '\0') - fprintf(d, " %s", pchar(ch)); - for (i = 0; i < g->nstates; i++) - if (ISSET(st, i)) { - fprintf(d, "%s%d", (first) ? "\t" : ", ", i); - first = 0; - } - fprintf(d, "\n"); -} - -/* - - at - print current situation - == #ifdef REDEBUG - == static void at(struct match *m, char *title, char *start, char *stop, \ - == sopno startst, sopno stopst); - == #endif - */ -static void -at( - struct match *m, - char *title, - char *start, - char *stop, - sopno startst, - sopno stopst) -{ - - _DIAGASSERT(m != NULL); - _DIAGASSERT(title != NULL); - _DIAGASSERT(start != NULL); - _DIAGASSERT(stop != NULL); - - if (!(m->eflags®_TRACE)) - return; - - printf("%s %s-", title, pchar(*start)); - printf("%s ", pchar(*stop)); - printf("%ld-%ld\n", (long)startst, (long)stopst); -} - -#ifndef PCHARDONE -#define PCHARDONE /* never again */ -/* - - pchar - make a character printable - == #ifdef REDEBUG - == static char *pchar(int ch); - == #endif - * - * Is this identical to regchar() over in debug.c? Well, yes. But a - * duplicate here avoids having a debugging-capable regexec.o tied to - * a matching debug.o, and this is convenient. It all disappears in - * the non-debug compilation anyway, so it doesn't matter much. - */ -static char * /* -> representation */ -pchar( - int ch) -{ - static char pbuf[10]; - - if (isprint(ch) || ch == ' ') - (void)snprintf(pbuf, sizeof pbuf, "%c", ch); - else - (void)snprintf(pbuf, sizeof pbuf, "\\%o", ch); - return(pbuf); -} -#endif -#endif - -#undef matcher -#undef fast -#undef slow -#undef dissect -#undef backref -#undef step -#undef print -#undef at -#undef match -#undef nope diff --git a/lib/libc/regex/re_format.7 b/lib/libc/regex/re_format.7 deleted file mode 100644 index 653b558e3..000000000 --- a/lib/libc/regex/re_format.7 +++ /dev/null @@ -1,315 +0,0 @@ -.\" $NetBSD: re_format.7,v 1.11 2015/08/22 14:04:54 wiz Exp $ -.\" -.\" Copyright (c) 1992, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Henry Spencer. -.\" -.\" 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. -.\" -.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Henry Spencer. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)re_format.7 8.3 (Berkeley) 3/20/94 -.\" -.Dd March 20, 1994 -.Dt RE_FORMAT 7 -.Os -.Sh NAME -.Nm re_format -.Nd POSIX 1003.2 regular expressions -.Sh DESCRIPTION -Regular expressions (``RE''s), -as defined in POSIX 1003.2, come in two forms: -modern REs (roughly those of -.Xr egrep 1 ; -1003.2 calls these ``extended'' REs) -and obsolete REs (roughly those of -.Xr ed 1 ; -1003.2 ``basic'' REs). -Obsolete REs mostly exist for backward compatibility in some old programs; -they will be discussed at the end. -1003.2 leaves some aspects of RE syntax and semantics open; -`(*)' marks decisions on these aspects that -may not be fully portable to other 1003.2 implementations. -.Pp -A (modern) RE is one(*) or more non-empty(*) -.Em branches , -separated by `|'. -It matches anything that matches one of the branches. -.Pp -A branch is one(*) or more -.Em pieces , -concatenated. -It matches a match for the first, followed by a match for the second, etc. -.Pp -A piece is an -.Em atom -possibly followed -by a single(*) `*', `+', `?', or -.Em bound . -An atom followed by `*' matches a sequence of 0 or more matches of the atom. -An atom followed by `+' matches a sequence of 1 or more matches of the atom. -An atom followed by `?' matches a sequence of 0 or 1 matches of the atom. -.Pp -A -.Em bound -is `{' followed by an unsigned decimal integer, possibly followed by `,' -possibly followed by another unsigned decimal integer, -always followed by `}'. -The integers must lie between 0 and RE_DUP_MAX (255(*)) inclusive, -and if there are two of them, the first may not exceed the second. -An atom followed by a bound containing one integer -.Em i -and no comma matches a sequence of exactly -.Em i -matches of the atom. -An atom followed by a bound containing one integer -.Em i -and a comma matches a sequence of -.Em i -or more matches of the atom. -An atom followed by a bound containing two integers -.Em i -and -.Em j -matches a sequence of -.Em i -through -.Em j -(inclusive) matches of the atom. -.Pp -An atom is a regular expression enclosed in `()' (matching a match for the -regular expression), an empty set of `()' (matching the null string)(*), a -.Em bracket expression -(see below), `.' (matching any single character), -`^' (matching the null string at the beginning of a line), -`$' (matching the null string at the end of a line), -a `\e' followed by one of the characters `^.[$()|*+?{\e' -(matching that character taken as an ordinary character), -a `\e' followed by any other character(*) -(matching that character taken as an ordinary character, -as if the `\e' had not been present(*)), -or a single character with no other significance (matching that character). -A `{' followed by a character other than a digit is an ordinary -character, not the beginning of a bound(*). -It is illegal to end an RE with `\e'. -.Pp -A -.Em bracket expression -is a list of characters enclosed in `[]'. -It normally matches any single character from the list (but see below). -If the list begins with `^', -it matches any single character (but see below) -.Em not -from the rest of the list. -If two characters in the list are separated by `\-', this is shorthand -for the full -.Em range -of characters between those two (inclusive) in the collating sequence, -e.g. `[0-9]' in ASCII matches any decimal digit. -It is illegal(*) for two ranges to share an endpoint, e.g. `a-c-e'. -Ranges are very collating-sequence-dependent, -and portable programs should avoid relying on them. -.Pp -To include a literal `]' in the list, make it the first character -(following a possible `^'). -To include a literal `\-', make it the first or last character, -or the second endpoint of a range. -To use a literal `\-' as the first endpoint of a range, -enclose it in `[.' and `.]' to make it a collating element (see below). -With the exception of these and some combinations using `[' (see next -paragraphs), all other special characters, including `\e', lose their -special significance within a bracket expression. -.Pp -Within a bracket expression, a collating element (a character, -a multi-character sequence that collates as if it were a single character, -or a collating-sequence name for either) -enclosed in `[.' and `.]' stands for the -sequence of characters of that collating element. -The sequence is a single element of the bracket expression's list. -A bracket expression containing a multi-character collating element -can thus match more than one character, -e.g. if the collating sequence includes a `ch' collating element, -then the RE `[[.ch.]]*c' matches the first five characters -of `chchcc'. -.Pp -Within a bracket expression, a collating element enclosed in `[=' and -`=]' is an equivalence class, standing for the sequences of characters -of all collating elements equivalent to that one, including itself. -(If there are no other equivalent collating elements, -the treatment is as if the enclosing delimiters were `[.' and `.]'.) -For example, if o and '\(^o' are the members of an equivalence class, -then `[[=o=]]', `[[=\(^o'=]]', and `[o\(^o']' are all synonymous. -An equivalence class may not(*) be an endpoint -of a range. -.Pp -Within a bracket expression, the name of a -.Em character class -enclosed in `[:' and `:]' stands for the list of all characters -belonging to that class. -Standard character class names are: -.Bl -column "alnum" "digit" "xdigit" -.It alnum digit punct -.It alpha graph space -.It blank lower upper -.It cntrl print xdigit -.El -.Pp -These stand for the character classes defined in -.Xr ctype 3 . -A locale may provide others. -A character class may not be used as an endpoint of a range. -.Pp -There are two special cases(*) of bracket expressions: -the bracket expressions `[[:\*[Lt]:]]' and `[[:\*[Gt]:]]' match -the null string at the beginning and end of a word respectively. -A word is defined as a sequence of word characters -which is neither preceded nor followed by word characters. -A word character is an -.Em alnum -character (as defined by -.Xr ctype 3 ) -or an underscore. -This is an extension, compatible with but not specified by POSIX 1003.2, -and should be used with caution in software intended to be portable -to other systems. -.Pp -In the event that an RE could match more than one substring of a given -string, the RE matches the one starting earliest in the string. -If the RE could match more than one substring starting at that point, -it matches the longest. -Subexpressions also match the longest possible substrings, subject to -the constraint that the whole match be as long as possible, -with subexpressions starting earlier in the RE taking priority over -ones starting later. -Note that higher-level subexpressions thus take priority over -their lower-level component subexpressions. -.Pp -Match lengths are measured in characters, not collating elements. -A null string is considered longer than no match at all. -For example, -`bb*' matches the three middle characters of `abbbc', -`(wee|week)(knights|nights)' matches all ten characters of `weeknights', -when `(.*).*' is matched against `abc' the parenthesized subexpression -matches all three characters, and -when `(a*)*' is matched against `bc' both the whole RE and the parenthesized -subexpression match the null string. -.Pp -If case-independent matching is specified, -the effect is much as if all case distinctions had vanished from the -alphabet. -When an alphabetic that exists in multiple cases appears as an -ordinary character outside a bracket expression, it is effectively -transformed into a bracket expression containing both cases, -e.g. `x' becomes `[xX]'. -When it appears inside a bracket expression, all case counterparts -of it are added to the bracket expression, so that (e.g.) `[x]' -becomes `[xX]' and `[^x]' becomes `[^xX]'. -.Pp -No particular limit is imposed on the length of REs(*). -Programs intended to be portable should not employ REs longer -than 256 bytes, -as an implementation can refuse to accept such REs and remain -POSIX-compliant. -.Pp -Obsolete (``basic'') regular expressions differ in several respects. -`|', `+', and `?' are ordinary characters and there is no equivalent -for their functionality. -The delimiters for bounds are `\e{' and `\e}', -with `{' and `}' by themselves ordinary characters. -The parentheses for nested subexpressions are `\e(' and `\e)', -with `(' and `)' by themselves ordinary characters. -`^' is an ordinary character except at the beginning of the -RE or(*) the beginning of a parenthesized subexpression, -`$' is an ordinary character except at the end of the -RE or(*) the end of a parenthesized subexpression, -and `*' is an ordinary character if it appears at the beginning of the -RE or the beginning of a parenthesized subexpression -(after a possible leading `^'). -Finally, there is one new type of atom, a -.Em back reference : -`\e' followed by a non-zero decimal digit -.Em d -matches the same sequence of characters -matched by the -.Em d Ns th parenthesized subexpression -(numbering subexpressions by the positions of their opening parentheses, -left to right), -so that (e.g.) `\e([bc]\e)\e1' matches `bb' or `cc' but not `bc'. -.Sh SEE ALSO -.Xr regex 3 -.Pp -POSIX 1003.2, section 2.8 (Regular Expression Notation). -.Sh BUGS -Having two kinds of REs is a botch. -.Pp -The current 1003.2 spec says that `)' is an ordinary character in -the absence of an unmatched `('; -this was an unintentional result of a wording error, and change is likely. -Avoid relying on it. -.Pp -Back references are a dreadful botch, -posing major problems for efficient implementations. -They are also somewhat vaguely defined -(does `a\e(\e(b\e)*\e2\e)*d' match `abbbd'?). -Avoid using them. -.Pp -1003.2's specification of case-independent matching is vague. -The ``one case implies all cases'' definition given above -is current consensus among implementors as to the right interpretation. -.Pp -The syntax for word boundaries is incredibly ugly. diff --git a/lib/libc/regex/regcomp.c b/lib/libc/regex/regcomp.c deleted file mode 100644 index 6af97347c..000000000 --- a/lib/libc/regex/regcomp.c +++ /dev/null @@ -1,1925 +0,0 @@ -/* $NetBSD: regcomp.c,v 1.36 2015/09/12 19:08:47 christos Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)regcomp.c 8.5 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)regcomp.c 8.5 (Berkeley) 3/20/94 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; -#else -__RCSID("$NetBSD: regcomp.c,v 1.36 2015/09/12 19:08:47 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(regcomp,_regcomp) -#endif - -#include "utils.h" -#include "regex2.h" - -#include "cclass.h" -#include "cname.h" - -/* - * parse structure, passed up and down to avoid global variables and - * other clumsinesses - */ -struct parse { - const char *next; /* next character in RE */ - const char *end; /* end of string (-> NUL normally) */ - int error; /* has an error been seen? */ - sop *strip; /* malloced strip */ - sopno ssize; /* malloced strip size (allocated) */ - sopno slen; /* malloced strip length (used) */ - size_t ncsalloc; /* number of csets allocated */ - struct re_guts *g; -# define NPAREN 10 /* we need to remember () 1-9 for back refs */ - sopno pbegin[NPAREN]; /* -> ( ([0] unused) */ - sopno pend[NPAREN]; /* -> ) ([0] unused) */ -}; - -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === regcomp.c === */ -static void p_ere(struct parse *p, int stop, size_t reclimit); -static void p_ere_exp(struct parse *p, size_t reclimit); -static void p_str(struct parse *p); -static void p_bre(struct parse *p, int end1, int end2, size_t reclimit); -static int p_simp_re(struct parse *p, int starordinary, size_t reclimit); -static int p_count(struct parse *p); -static void p_bracket(struct parse *p); -static void p_b_term(struct parse *p, cset *cs); -static void p_b_cclass(struct parse *p, cset *cs); -static void p_b_eclass(struct parse *p, cset *cs); -static char p_b_symbol(struct parse *p); -static char p_b_coll_elem(struct parse *p, int endc); -static int othercase(int ch); -static void bothcases(struct parse *p, int ch); -static void ordinary(struct parse *p, int ch); -static void nonnewline(struct parse *p); -static void repeat(struct parse *p, sopno start, int from, int to, size_t reclimit); -static int seterr(struct parse *p, int e); -static cset *allocset(struct parse *p); -static void freeset(struct parse *p, cset *cs); -static sopno freezeset(struct parse *p, cset *cs); -static int firstch(struct parse *p, cset *cs); -static int nch(struct parse *p, cset *cs); -static void mcadd(struct parse *p, cset *cs, const char *cp); -#if 0 -static void mcsub(cset *cs, char *cp); -static int mcin(cset *cs, char *cp); -static char *mcfind(cset *cs, char *cp); -#endif -static void mcinvert(struct parse *p, cset *cs); -static void mccase(struct parse *p, cset *cs); -static int isinsets(struct re_guts *g, int c); -static int samesets(struct re_guts *g, int c1, int c2); -static void categorize(struct parse *p, struct re_guts *g); -static sopno dupl(struct parse *p, sopno start, sopno finish); -static void doemit(struct parse *p, sop op, sopno opnd); -static void doinsert(struct parse *p, sop op, sopno opnd, sopno pos); -static void dofwd(struct parse *p, sopno pos, sopno value); -static int enlarge(struct parse *p, sopno size); -static void stripsnug(struct parse *p, struct re_guts *g); -static void findmust(struct parse *p, struct re_guts *g); -static sopno pluscount(struct parse *p, struct re_guts *g); - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ - -static char nuls[10]; /* place to point scanner in event of error */ - -/* - * macros for use with parse structure - * BEWARE: these know that the parse structure is named `p' !!! - */ -#define PEEK() (*p->next) -#define PEEK2() (*(p->next+1)) -#define MORE() (p->next < p->end) -#define MORE2() (p->next+1 < p->end) -#define SEE(c) (MORE() && PEEK() == (c)) -#define SEETWO(a, b) (MORE() && MORE2() && PEEK() == (a) && PEEK2() == (b)) -#define EAT(c) ((SEE(c)) ? (NEXT(), 1) : 0) -#define EATTWO(a, b) ((SEETWO(a, b)) ? (NEXT2(), 1) : 0) -#define NEXT() (p->next++) -#define NEXT2() (p->next += 2) -#define NEXTn(n) (p->next += (n)) -#define GETNEXT() (*p->next++) -#define SETERROR(e) seterr(p, (e)) -#define REQUIRE(co, e) (void) ((co) || SETERROR(e)) -#define MUSTSEE(c, e) (REQUIRE(MORE() && PEEK() == (c), e)) -#define MUSTEAT(c, e) (void) (REQUIRE(MORE() && GETNEXT() == (c), e)) -#define MUSTNOTSEE(c, e) (REQUIRE(!MORE() || PEEK() != (c), e)) -#define EMIT(op, sopnd) doemit(p, (sop)(op), sopnd) -#define INSERT(op, pos) doinsert(p, (sop)(op), HERE()-(pos)+1, pos) -#define AHEAD(pos) dofwd(p, pos, HERE()-(pos)) -#define ASTERN(sop, pos) EMIT(sop, HERE()-pos) -#define HERE() (p->slen) -#define THERE() (p->slen - 1) -#define THERETHERE() (p->slen - 2) -#define DROP(n) (p->slen -= (n)) - -#ifndef NDEBUG -static int never = 0; /* for use in asserts; shuts lint up */ -#else -#define never 0 /* some s have bugs too */ -#endif - -#define MEMLIMIT 0x8000000 -#define MEMSIZE(p) \ - ((p)->ncsalloc / CHAR_BIT * (p)->g->csetsize + \ - (p)->ncsalloc * sizeof(cset) + \ - (p)->ssize * sizeof(sop)) -#define RECLIMIT 256 - -/* - - regcomp - interface for parser and compilation - = extern int regcomp(regex_t *, const char *, int); - = #define REG_BASIC 0000 - = #define REG_EXTENDED 0001 - = #define REG_ICASE 0002 - = #define REG_NOSUB 0004 - = #define REG_NEWLINE 0010 - = #define REG_NOSPEC 0020 - = #define REG_PEND 0040 - = #define REG_DUMP 0200 - */ -int /* 0 success, otherwise REG_something */ -regcomp( - regex_t *preg, - const char *pattern, - int cflags) -{ - struct parse pa; - struct re_guts *g; - struct parse *p = &pa; - int i; - size_t len; -#ifdef REDEBUG -# define GOODFLAGS(f) (f) -#else -# define GOODFLAGS(f) ((f)&~REG_DUMP) -#endif - - _DIAGASSERT(preg != NULL); - _DIAGASSERT(pattern != NULL); - - cflags = GOODFLAGS(cflags); - if ((cflags®_EXTENDED) && (cflags®_NOSPEC)) - return(REG_INVARG); - - if (cflags®_PEND) { - if (preg->re_endp < pattern) - return(REG_INVARG); - len = preg->re_endp - pattern; - } else - len = strlen(pattern); - - /* do the mallocs early so failure handling is easy */ - g = malloc(sizeof(struct re_guts) + (NC - 1) * sizeof(cat_t)); - if (g == NULL) - return(REG_ESPACE); - p->ssize = len/(size_t)2*(size_t)3 + (size_t)1; /* ugh */ - p->strip = calloc(p->ssize, sizeof(sop)); - p->slen = 0; - if (p->strip == NULL) { - free(g); - return(REG_ESPACE); - } - - /* set things up */ - p->g = g; - p->next = pattern; - p->end = p->next + len; - p->error = 0; - p->ncsalloc = 0; - for (i = 0; i < NPAREN; i++) { - p->pbegin[i] = 0; - p->pend[i] = 0; - } - g->csetsize = NC; - g->sets = NULL; - g->setbits = NULL; - g->ncsets = 0; - g->cflags = cflags; - g->iflags = 0; - g->nbol = 0; - g->neol = 0; - g->must = NULL; - g->mlen = 0; - g->nsub = 0; - g->ncategories = 1; /* category 0 is "everything else" */ - g->categories = &g->catspace[-(CHAR_MIN)]; - (void) memset((char *)g->catspace, 0, NC*sizeof(cat_t)); - g->backrefs = 0; - - /* do it */ - EMIT(OEND, 0); - g->firststate = THERE(); - if (cflags®_EXTENDED) - p_ere(p, OUT, 0); - else if (cflags®_NOSPEC) - p_str(p); - else - p_bre(p, OUT, OUT, 0); - EMIT(OEND, 0); - g->laststate = THERE(); - - /* tidy up loose ends and fill things in */ - categorize(p, g); - stripsnug(p, g); - findmust(p, g); - g->nplus = pluscount(p, g); - g->magic = MAGIC2; - preg->re_nsub = g->nsub; - preg->re_g = g; - preg->re_magic = MAGIC1; -#ifndef REDEBUG - /* not debugging, so can't rely on the assert() in regexec() */ - if (g->iflags&BAD) - SETERROR(REG_ASSERT); -#endif - - /* win or lose, we're done */ - if (p->error != 0) /* lose */ - regfree(preg); - return(p->error); -} - -/* - - p_ere - ERE parser top level, concatenation and alternation - == static void p_ere(struct parse *p, int stop, size_t reclimit); - */ -static void -p_ere( - struct parse *p, - int stop, /* character this ERE should end at */ - size_t reclimit) -{ - char c; - sopno prevback = 0; /* pacify gcc */ - sopno prevfwd = 0; /* pacify gcc */ - sopno conc; - int first = 1; /* is this the first alternative? */ - - _DIAGASSERT(p != NULL); - - if (reclimit++ > RECLIMIT || p->error == REG_ESPACE) { - p->error = REG_ESPACE; - return; - } - - for (;;) { - /* do a bunch of concatenated expressions */ - conc = HERE(); - while (MORE() && (c = PEEK()) != '|' && c != stop) - p_ere_exp(p, reclimit); - REQUIRE(HERE() != conc, REG_EMPTY); /* require nonempty */ - - if (!EAT('|')) - break; /* NOTE BREAK OUT */ - - if (first) { - INSERT(OCH_, conc); /* offset is wrong */ - prevfwd = conc; - prevback = conc; - first = 0; - } - ASTERN(OOR1, prevback); - prevback = THERE(); - AHEAD(prevfwd); /* fix previous offset */ - prevfwd = HERE(); - EMIT(OOR2, 0); /* offset is very wrong */ - } - - if (!first) { /* tail-end fixups */ - AHEAD(prevfwd); - ASTERN(O_CH, prevback); - } - - assert(!MORE() || SEE(stop)); -} - -/* - - p_ere_exp - parse one subERE, an atom possibly followed by a repetition op - == static void p_ere_exp(struct parse *p, size_t reclimit); - */ -static void -p_ere_exp( - struct parse *p, - size_t reclimit) -{ - char c; - sopno pos; - int count; - int count2; - sopno subno; - int wascaret = 0; - - _DIAGASSERT(p != NULL); - - assert(MORE()); /* caller should have ensured this */ - c = GETNEXT(); - - pos = HERE(); - switch (c) { - case '(': - REQUIRE(MORE(), REG_EPAREN); - p->g->nsub++; - subno = p->g->nsub; - if (subno < NPAREN) - p->pbegin[subno] = HERE(); - EMIT(OLPAREN, subno); - if (!SEE(')')) - p_ere(p, ')', reclimit); - if (subno < NPAREN) { - p->pend[subno] = HERE(); - assert(p->pend[subno] != 0); - } - EMIT(ORPAREN, subno); - MUSTEAT(')', REG_EPAREN); - break; -#ifndef POSIX_MISTAKE - case ')': /* happens only if no current unmatched ( */ - /* - * You may ask, why the ifndef? Because I didn't notice - * this until slightly too late for 1003.2, and none of the - * other 1003.2 regular-expression reviewers noticed it at - * all. So an unmatched ) is legal POSIX, at least until - * we can get it fixed. - */ - SETERROR(REG_EPAREN); - break; -#endif - case '^': - EMIT(OBOL, 0); - p->g->iflags |= USEBOL; - p->g->nbol++; - wascaret = 1; - break; - case '$': - EMIT(OEOL, 0); - p->g->iflags |= USEEOL; - p->g->neol++; - break; - case '|': - SETERROR(REG_EMPTY); - break; - case '*': - case '+': - case '?': - SETERROR(REG_BADRPT); - break; - case '.': - if (p->g->cflags®_NEWLINE) - nonnewline(p); - else - EMIT(OANY, 0); - break; - case '[': - p_bracket(p); - break; - case '\\': - REQUIRE(MORE(), REG_EESCAPE); - c = GETNEXT(); - ordinary(p, c); - break; - case '{': /* okay as ordinary except if digit follows */ - REQUIRE(!MORE() || !isdigit((unsigned char)PEEK()), REG_BADRPT); - /* FALLTHROUGH */ - default: - ordinary(p, c); - break; - } - - if (!MORE()) - return; - c = PEEK(); - /* we call { a repetition if followed by a digit */ - if (!( c == '*' || c == '+' || c == '?' || - (c == '{' && MORE2() && isdigit((unsigned char)PEEK2())) )) - return; /* no repetition, we're done */ - NEXT(); - - REQUIRE(!wascaret, REG_BADRPT); - switch (c) { - case '*': /* implemented as +? */ - /* this case does not require the (y|) trick, noKLUDGE */ - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - INSERT(OQUEST_, pos); - ASTERN(O_QUEST, pos); - break; - case '+': - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - break; - case '?': - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, pos); /* offset slightly wrong */ - ASTERN(OOR1, pos); /* this one's right */ - AHEAD(pos); /* fix the OCH_ */ - EMIT(OOR2, 0); /* offset very wrong... */ - AHEAD(THERE()); /* ...so fix it */ - ASTERN(O_CH, THERETHERE()); - break; - case '{': - count = p_count(p); - if (EAT(',')) { - if (isdigit((unsigned char)PEEK())) { - count2 = p_count(p); - REQUIRE(count <= count2, REG_BADBR); - } else /* single number with comma */ - count2 = INFINITY; - } else /* just a single number */ - count2 = count; - repeat(p, pos, count, count2, 0); - if (!EAT('}')) { /* error heuristics */ - while (MORE() && PEEK() != '}') - NEXT(); - REQUIRE(MORE(), REG_EBRACE); - SETERROR(REG_BADBR); - } - break; - } - - if (!MORE()) - return; - c = PEEK(); - if (!( c == '*' || c == '+' || c == '?' || - (c == '{' && MORE2() && isdigit((unsigned char)PEEK2())) ) ) - return; - SETERROR(REG_BADRPT); -} - -/* - - p_str - string (no metacharacters) "parser" - == static void p_str(struct parse *p); - */ -static void -p_str( - struct parse *p) -{ - - _DIAGASSERT(p != NULL); - - REQUIRE(MORE(), REG_EMPTY); - while (MORE()) - ordinary(p, GETNEXT()); -} - -/* - - p_bre - BRE parser top level, anchoring and concatenation - == static void p_bre(struct parse *p, int end1, \ - == int end2, size_t reclimit); - * Giving end1 as OUT essentially eliminates the end1/end2 check. - * - * This implementation is a bit of a kludge, in that a trailing $ is first - * taken as an ordinary character and then revised to be an anchor. The - * only undesirable side effect is that '$' gets included as a character - * category in such cases. This is fairly harmless; not worth fixing. - * The amount of lookahead needed to avoid this kludge is excessive. - */ -static void -p_bre( - struct parse *p, - int end1, /* first terminating character */ - int end2, /* second terminating character */ - size_t reclimit) -{ - sopno start; - int first = 1; /* first subexpression? */ - int wasdollar = 0; - - _DIAGASSERT(p != NULL); - - if (reclimit++ > RECLIMIT || p->error == REG_ESPACE) { - p->error = REG_ESPACE; - return; - } - - start = HERE(); - - if (EAT('^')) { - EMIT(OBOL, 0); - p->g->iflags |= USEBOL; - p->g->nbol++; - } - while (MORE() && !SEETWO(end1, end2)) { - wasdollar = p_simp_re(p, first, reclimit); - first = 0; - } - if (wasdollar) { /* oops, that was a trailing anchor */ - DROP(1); - EMIT(OEOL, 0); - p->g->iflags |= USEEOL; - p->g->neol++; - } - - REQUIRE(HERE() != start, REG_EMPTY); /* require nonempty */ -} - -/* - - p_simp_re - parse a simple RE, an atom possibly followed by a repetition - == static int p_simp_re(struct parse *p, int starordinary, size_t reclimit); - */ -static int /* was the simple RE an unbackslashed $? */ -p_simp_re( - struct parse *p, - int starordinary, /* is a leading * an ordinary character? */ - size_t reclimit) -{ - int c; - int count; - int count2; - sopno pos, i; - sopno subno; -# define BACKSL (1<g->cflags®_NEWLINE) - nonnewline(p); - else - EMIT(OANY, 0); - break; - case '[': - p_bracket(p); - break; - case BACKSL|'{': - SETERROR(REG_BADRPT); - break; - case BACKSL|'(': - p->g->nsub++; - subno = p->g->nsub; - if (subno < NPAREN) - p->pbegin[subno] = HERE(); - EMIT(OLPAREN, subno); - /* the MORE here is an error heuristic */ - if (MORE() && !SEETWO('\\', ')')) - p_bre(p, '\\', ')', reclimit); - if (subno < NPAREN) { - p->pend[subno] = HERE(); - assert(p->pend[subno] != 0); - } - EMIT(ORPAREN, subno); - REQUIRE(EATTWO('\\', ')'), REG_EPAREN); - break; - case BACKSL|')': /* should not get here -- must be user */ - case BACKSL|'}': - SETERROR(REG_EPAREN); - break; - case BACKSL|'1': - case BACKSL|'2': - case BACKSL|'3': - case BACKSL|'4': - case BACKSL|'5': - case BACKSL|'6': - case BACKSL|'7': - case BACKSL|'8': - case BACKSL|'9': - i = (c&~BACKSL) - '0'; - assert(i < NPAREN); - if (p->pend[i] != 0) { - assert(i <= p->g->nsub); - EMIT(OBACK_, i); - assert(p->pbegin[i] != 0); - assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); - assert(OP(p->strip[p->pend[i]]) == ORPAREN); - (void) dupl(p, p->pbegin[i]+1, p->pend[i]); - EMIT(O_BACK, i); - } else - SETERROR(REG_ESUBREG); - p->g->backrefs = 1; - break; - case '*': - REQUIRE(starordinary, REG_BADRPT); - /* FALLTHROUGH */ - default: - ordinary(p, c &~ BACKSL); - break; - } - - if (EAT('*')) { /* implemented as +? */ - /* this case does not require the (y|) trick, noKLUDGE */ - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - INSERT(OQUEST_, pos); - ASTERN(O_QUEST, pos); - } else if (EATTWO('\\', '{')) { - count = p_count(p); - if (EAT(',')) { - if (MORE() && isdigit((unsigned char)PEEK())) { - count2 = p_count(p); - REQUIRE(count <= count2, REG_BADBR); - } else /* single number with comma */ - count2 = INFINITY; - } else /* just a single number */ - count2 = count; - repeat(p, pos, count, count2, 0); - if (!EATTWO('\\', '}')) { /* error heuristics */ - while (MORE() && !SEETWO('\\', '}')) - NEXT(); - REQUIRE(MORE(), REG_EBRACE); - SETERROR(REG_BADBR); - } - } else if (c == (unsigned char)'$') /* $ (but not \$) ends it */ - return(1); - - return(0); -} - -/* - - p_count - parse a repetition count - == static int p_count(struct parse *p); - */ -static int /* the value */ -p_count( - struct parse *p) -{ - int count = 0; - int ndigits = 0; - - _DIAGASSERT(p != NULL); - - while (MORE() && isdigit((unsigned char)PEEK()) && count <= DUPMAX) { - count = count*10 + (GETNEXT() - '0'); - ndigits++; - } - - REQUIRE(ndigits > 0 && count <= DUPMAX, REG_BADBR); - return(count); -} - -/* - - p_bracket - parse a bracketed character list - == static void p_bracket(struct parse *p); - * - * Note a significant property of this code: if the allocset() did SETERROR, - * no set operations are done. - */ -static void -p_bracket( - struct parse *p) -{ - cset *cs; - int invert = 0; - _DIAGASSERT(p != NULL); - - cs = allocset(p); - if (cs == NULL) - return; - - /* Dept of Truly Sickening Special-Case Kludges */ - if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", - (size_t)6) == 0) { - EMIT(OBOW, 0); - NEXTn(6); - return; - } - if (p->next + 5 < p->end && strncmp(p->next, "[:>:]]", - (size_t)6) == 0) { - EMIT(OEOW, 0); - NEXTn(6); - return; - } - - if (EAT('^')) - invert++; /* make note to invert set at end */ - if (EAT(']')) - CHadd(cs, ']'); - else if (EAT('-')) - CHadd(cs, '-'); - while (MORE() && PEEK() != ']' && !SEETWO('-', ']')) - p_b_term(p, cs); - if (EAT('-')) - CHadd(cs, '-'); - MUSTEAT(']', REG_EBRACK); - - if (p->error != 0) /* don't mess things up further */ - return; - - if (p->g->cflags®_ICASE) { - ssize_t i; - int ci; - - for (i = p->g->csetsize - 1; i >= 0; i--) - if (CHIN(cs, i) && isalpha(i)) { - ci = othercase((int)i); - if (ci != i) - CHadd(cs, ci); - } - if (cs->multis != NULL) - mccase(p, cs); - } - if (invert) { - ssize_t i; - - for (i = p->g->csetsize - 1; i >= 0; i--) - if (CHIN(cs, i)) - CHsub(cs, (int)i); - else - CHadd(cs, (int)i); - if (p->g->cflags®_NEWLINE) - CHsub(cs, '\n'); - if (cs->multis != NULL) - mcinvert(p, cs); - } - - assert(cs->multis == NULL); /* xxx */ - - if (nch(p, cs) == 1) { /* optimize singleton sets */ - ordinary(p, firstch(p, cs)); - freeset(p, cs); - } else - EMIT(OANYOF, freezeset(p, cs)); -} - -/* - - p_b_term - parse one term of a bracketed character list - == static void p_b_term(struct parse *p, cset *cs); - */ -static void -p_b_term( - struct parse *p, - cset *cs) -{ - char c; - char start, finish; - int i; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - /* classify what we've got */ - switch ((MORE()) ? PEEK() : '\0') { - case '[': - c = (MORE2()) ? PEEK2() : '\0'; - break; - - case '-': - SETERROR(REG_ERANGE); - return; /* NOTE RETURN */ - - default: - c = '\0'; - break; - } - - switch (c) { - case ':': /* character class */ - NEXT2(); - REQUIRE(MORE(), REG_EBRACK); - c = PEEK(); - REQUIRE(c != '-' && c != ']', REG_ECTYPE); - p_b_cclass(p, cs); - REQUIRE(MORE(), REG_EBRACK); - REQUIRE(EATTWO(':', ']'), REG_ECTYPE); - break; - case '=': /* equivalence class */ - NEXT2(); - REQUIRE(MORE(), REG_EBRACK); - c = PEEK(); - REQUIRE(c != '-' && c != ']', REG_ECOLLATE); - p_b_eclass(p, cs); - REQUIRE(MORE(), REG_EBRACK); - REQUIRE(EATTWO('=', ']'), REG_ECOLLATE); - break; - default: /* symbol, ordinary character, or range */ -/* xxx revision needed for multichar stuff */ - start = p_b_symbol(p); - if (SEE('-') && MORE2() && PEEK2() != ']') { - /* range */ - NEXT(); - if (EAT('-')) - finish = '-'; - else - finish = p_b_symbol(p); - } else - finish = start; -/* xxx what about signed chars here... */ - REQUIRE(start <= finish, REG_ERANGE); - for (i = start; i <= finish; i++) - CHadd(cs, i); - break; - } -} - -/* - - p_b_cclass - parse a character-class name and deal with it - == static void p_b_cclass(struct parse *p, cset *cs); - */ -static void -p_b_cclass( - struct parse *p, - cset *cs) -{ - const char *sp; - const struct cclass *cp; - size_t len; - const char *u; - char c; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - sp = p->next; - - while (MORE() && isalpha((unsigned char)PEEK())) - NEXT(); - len = p->next - sp; - for (cp = cclasses; cp->name != NULL; cp++) - if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') - break; - if (cp->name == NULL) { - /* oops, didn't find it */ - SETERROR(REG_ECTYPE); - return; - } - - u = cp->chars; - while ((c = *u++) != '\0') - CHadd(cs, c); - for (u = cp->multis; *u != '\0'; u += strlen(u) + 1) - MCadd(p, cs, u); -} - -/* - - p_b_eclass - parse an equivalence-class name and deal with it - == static void p_b_eclass(struct parse *p, cset *cs); - * - * This implementation is incomplete. xxx - */ -static void -p_b_eclass( - struct parse *p, - cset *cs) -{ - char c; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - c = p_b_coll_elem(p, '='); - CHadd(cs, c); -} - -/* - - p_b_symbol - parse a character or [..]ed multicharacter collating symbol - == static char p_b_symbol(struct parse *p); - */ -static char /* value of symbol */ -p_b_symbol( - struct parse *p) -{ - char value; - - _DIAGASSERT(p != NULL); - - REQUIRE(MORE(), REG_EBRACK); - if (!EATTWO('[', '.')) - return(GETNEXT()); - - /* collating symbol */ - value = p_b_coll_elem(p, '.'); - REQUIRE(EATTWO('.', ']'), REG_ECOLLATE); - return(value); -} - -/* - - p_b_coll_elem - parse a collating-element name and look it up - == static char p_b_coll_elem(struct parse *p, int endc); - */ -static char /* value of collating element */ -p_b_coll_elem( - struct parse *p, - int endc) /* name ended by endc,']' */ -{ - const char *sp; - const struct cname *cp; - size_t len; - - _DIAGASSERT(p != NULL); - - sp = p->next; - - while (MORE() && !SEETWO(endc, ']')) - NEXT(); - if (!MORE()) { - SETERROR(REG_EBRACK); - return(0); - } - len = p->next - sp; - for (cp = cnames; cp->name != NULL; cp++) - if (strncmp(cp->name, sp, len) == 0 && cp->name[len] == '\0') - return(cp->code); /* known name */ - if (len == 1) - return(*sp); /* single character */ - SETERROR(REG_ECOLLATE); /* neither */ - return(0); -} - -/* - - othercase - return the case counterpart of an alphabetic - == static int othercase(int ch); - */ -static int /* if no counterpart, return ch */ -othercase( - int ch) -{ - assert(isalpha(ch)); - if (isupper(ch)) - return(tolower(ch)); - else if (islower(ch)) - return(toupper(ch)); - else /* peculiar, but could happen */ - return(ch); -} - -/* - - bothcases - emit a dualcase version of a two-case character - == static void bothcases(struct parse *p, int ch); - * - * Boy, is this implementation ever a kludge... - */ -static void -bothcases( - struct parse *p, - int ch) -{ - const char *oldnext; - const char *oldend; - char bracket[3]; - - _DIAGASSERT(p != NULL); - - oldnext = p->next; - oldend = p->end; - - assert(othercase(ch) != ch); /* p_bracket() would recurse */ - p->next = bracket; - p->end = bracket+2; - bracket[0] = ch; - bracket[1] = ']'; - bracket[2] = '\0'; - p_bracket(p); - assert(p->next == bracket+2); - p->next = oldnext; - p->end = oldend; -} - -/* - - ordinary - emit an ordinary character - == static void ordinary(struct parse *p, int ch); - */ -static void -ordinary( - struct parse *p, - int ch) -{ - cat_t *cap; - unsigned char uc = (unsigned char)ch; - - _DIAGASSERT(p != NULL); - - cap = p->g->categories; - if ((p->g->cflags & REG_ICASE) && isalpha(uc) && othercase(uc) != uc) - bothcases(p, uc); - else { - EMIT(OCHAR, (sopno)uc); - if (cap[uc] == 0) { - _DIAGASSERT(__type_fit(unsigned char, - p->g->ncategories + 1)); - cap[uc] = (unsigned char)p->g->ncategories++; - } - } -} - -/* - - nonnewline - emit REG_NEWLINE version of OANY - == static void nonnewline(struct parse *p); - * - * Boy, is this implementation ever a kludge... - */ -static void -nonnewline( - struct parse *p) -{ - const char *oldnext; - const char *oldend; - char bracket[4]; - - _DIAGASSERT(p != NULL); - - oldnext = p->next; - oldend = p->end; - - p->next = bracket; - p->end = bracket+3; - bracket[0] = '^'; - bracket[1] = '\n'; - bracket[2] = ']'; - bracket[3] = '\0'; - p_bracket(p); - assert(p->next == bracket+3); - p->next = oldnext; - p->end = oldend; -} - -/* - - repeat - generate code for a bounded repetition, recursively if needed - == static void repeat(struct parse *p, sopno start, int from, int to, - == size_t reclimit); - */ -static void -repeat( - struct parse *p, - sopno start, /* operand from here to end of strip */ - int from, /* repeated from this number */ - int to, /* to this number of times (maybe INFINITY) */ - size_t reclimit) -{ - sopno finish; -# define N 2 -# define INF 3 -# define REP(f, t) ((f)*8 + (t)) -# define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N) - sopno copy; - - _DIAGASSERT(p != NULL); - - if (reclimit++ > RECLIMIT) - p->error = REG_ESPACE; - if (p->error) - return; - - finish = HERE(); - - assert(from <= to); - - switch (REP(MAP(from), MAP(to))) { - case REP(0, 0): /* must be user doing this */ - DROP(finish-start); /* drop the operand */ - break; - case REP(0, 1): /* as x{1,1}? */ - case REP(0, N): /* as x{1,n}? */ - case REP(0, INF): /* as x{1,}? */ - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, start); /* offset is wrong... */ - repeat(p, start+1, 1, to, reclimit); - ASTERN(OOR1, start); - AHEAD(start); /* ... fix it */ - EMIT(OOR2, 0); - AHEAD(THERE()); - ASTERN(O_CH, THERETHERE()); - break; - case REP(1, 1): /* trivial case */ - /* done */ - break; - case REP(1, N): /* as x?x{1,n-1} */ - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, start); - ASTERN(OOR1, start); - AHEAD(start); - EMIT(OOR2, 0); /* offset very wrong... */ - AHEAD(THERE()); /* ...so fix it */ - ASTERN(O_CH, THERETHERE()); - copy = dupl(p, start+1, finish+1); - assert(copy == finish+4); - repeat(p, copy, 1, to-1, reclimit); - break; - case REP(1, INF): /* as x+ */ - INSERT(OPLUS_, start); - ASTERN(O_PLUS, start); - break; - case REP(N, N): /* as xx{m-1,n-1} */ - copy = dupl(p, start, finish); - repeat(p, copy, from-1, to-1, reclimit); - break; - case REP(N, INF): /* as xx{n-1,INF} */ - copy = dupl(p, start, finish); - repeat(p, copy, from-1, to, reclimit); - break; - default: /* "can't happen" */ - SETERROR(REG_ASSERT); /* just in case */ - break; - } -} - -/* - - seterr - set an error condition - == static int seterr(struct parse *p, int e); - */ -static int /* useless but makes type checking happy */ -seterr( - struct parse *p, - int e) -{ - - _DIAGASSERT(p != NULL); - - if (p->error == 0) /* keep earliest error condition */ - p->error = e; - p->next = nuls; /* try to bring things to a halt */ - p->end = nuls; - return(0); /* make the return value well-defined */ -} - -/* - - allocset - allocate a set of characters for [] - == static cset *allocset(struct parse *p); - */ -static cset * -allocset( - struct parse *p) -{ - size_t no; - size_t nc; - size_t nbytes; - cset *cs; - size_t css; - size_t i; - void *old_ptr; - - _DIAGASSERT(p != NULL); - - no = p->g->ncsets++; - css = (size_t)p->g->csetsize; - if (no >= p->ncsalloc) { /* need another column of space */ - p->ncsalloc += CHAR_BIT; - nc = p->ncsalloc; - assert(nc % CHAR_BIT == 0); - nbytes = nc / CHAR_BIT * css; - if (MEMSIZE(p) > MEMLIMIT) - goto oomem; - if (reallocarr(&p->g->sets, nc, sizeof(cset))) - goto oomem; - old_ptr = p->g->setbits; - if (reallocarr(&p->g->setbits, nc / CHAR_BIT, css)) { - free(old_ptr); - goto oomem; - } - if (old_ptr != p->g->setbits) { - for (i = 0; i < no; i++) - p->g->sets[i].ptr = p->g->setbits + css*(i/CHAR_BIT); - } - (void) memset((char *)p->g->setbits + (nbytes - css), 0, css); - } - - cs = &p->g->sets[no]; - cs->ptr = p->g->setbits + css*((no)/CHAR_BIT); - cs->mask = 1 << (unsigned int)((no) % CHAR_BIT); - cs->hash = 0; - cs->smultis = 0; - cs->multis = NULL; - - return(cs); - -oomem: - SETERROR(REG_ESPACE); - /* caller's responsibility not to do set ops */ - return NULL; -} - -/* - - freeset - free a now-unused set - == static void freeset(struct parse *p, cset *cs); - */ -static void -freeset( - struct parse *p, - cset *cs) -{ - size_t i; - cset *top; - size_t css; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - top = &p->g->sets[p->g->ncsets]; - css = (size_t)p->g->csetsize; - - for (i = 0; i < css; i++) - CHsub(cs, (int)i); - if (cs == top-1) /* recover only the easy case */ - p->g->ncsets--; -} - -/* - - freezeset - final processing on a set of characters - == static int freezeset(struct parse *p, cset *cs); - * - * The main task here is merging identical sets. This is usually a waste - * of time (although the hash code minimizes the overhead), but can win - * big if REG_ICASE is being used. REG_ICASE, by the way, is why the hash - * is done using addition rather than xor -- all ASCII [aA] sets xor to - * the same value! - */ -static sopno /* set number */ -freezeset( - struct parse *p, - cset *cs) -{ - uch h; - size_t i; - cset *top; - cset *cs2; - size_t css; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - h = cs->hash; - top = &p->g->sets[p->g->ncsets]; - css = (size_t)p->g->csetsize; - - /* look for an earlier one which is the same */ - for (cs2 = &p->g->sets[0]; cs2 < top; cs2++) - if (cs2->hash == h && cs2 != cs) { - /* maybe */ - for (i = 0; i < css; i++) - if (!!CHIN(cs2, i) != !!CHIN(cs, i)) - break; /* no */ - if (i == css) - break; /* yes */ - } - - if (cs2 < top) { /* found one */ - freeset(p, cs); - cs = cs2; - } - - return (sopno)(cs - p->g->sets); -} - -/* - - firstch - return first character in a set (which must have at least one) - == static int firstch(struct parse *p, cset *cs); - */ -static int /* character; there is no "none" value */ -firstch( - struct parse *p, - cset *cs) -{ - size_t i; - size_t css; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - css = (size_t)p->g->csetsize; - - for (i = 0; i < css; i++) - if (CHIN(cs, i)) - return((char)i); - assert(never); - return(0); /* arbitrary */ -} - -/* - - nch - number of characters in a set - == static int nch(struct parse *p, cset *cs); - */ -static int -nch( - struct parse *p, - cset *cs) -{ - size_t i; - size_t css; - int n = 0; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - css = (size_t)p->g->csetsize; - - for (i = 0; i < css; i++) - if (CHIN(cs, i)) - n++; - return(n); -} - -/* - - mcadd - add a collating element to a cset - == static void mcadd(struct parse *p, cset *cs, \ - == char *cp); - */ -static void -mcadd( - struct parse *p, - cset *cs, - const char *cp) -{ - size_t oldend; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - _DIAGASSERT(cp != NULL); - - oldend = cs->smultis; - - cs->smultis += strlen(cp) + 1; - if (cs->multis == NULL) - cs->multis = malloc(cs->smultis); - else - cs->multis = realloc(cs->multis, cs->smultis); - if (cs->multis == NULL) { - SETERROR(REG_ESPACE); - return; - } - - (void) strcpy(cs->multis + oldend - 1, cp); - cs->multis[cs->smultis - 1] = '\0'; -} - -#if 0 -/* - - mcsub - subtract a collating element from a cset - == static void mcsub(cset *cs, char *cp); - */ -static void -mcsub( - cset *cs, - char *cp) -{ - char *fp; - size_t len; - - _DIAGASSERT(cs != NULL); - _DIAGASSERT(cp != NULL); - - fp = mcfind(cs, cp); - len = strlen(fp); - - assert(fp != NULL); - (void) memmove(fp, fp + len + 1, - cs->smultis - (fp + len + 1 - cs->multis)); - cs->smultis -= len; - - if (cs->smultis == 0) { - free(cs->multis); - cs->multis = NULL; - return; - } - - cs->multis = realloc(cs->multis, cs->smultis); - assert(cs->multis != NULL); -} - -/* - - mcin - is a collating element in a cset? - == static int mcin(cset *cs, char *cp); - */ -static int -mcin( - cset *cs, - char *cp) -{ - - _DIAGASSERT(cs != NULL); - _DIAGASSERT(cp != NULL); - - return(mcfind(cs, cp) != NULL); -} - -/* - - mcfind - find a collating element in a cset - == static char *mcfind(cset *cs, char *cp); - */ -static char * -mcfind( - cset *cs, - char *cp) -{ - char *p; - - _DIAGASSERT(cs != NULL); - _DIAGASSERT(cp != NULL); - - if (cs->multis == NULL) - return(NULL); - for (p = cs->multis; *p != '\0'; p += strlen(p) + 1) - if (strcmp(cp, p) == 0) - return(p); - return(NULL); -} -#endif - -/* - - mcinvert - invert the list of collating elements in a cset - == static void mcinvert(struct parse *p, cset *cs); - * - * This would have to know the set of possibilities. Implementation - * is deferred. - */ -/* ARGSUSED */ -static void -mcinvert( - struct parse *p, - cset *cs) -{ - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - assert(cs->multis == NULL); /* xxx */ -} - -/* - - mccase - add case counterparts of the list of collating elements in a cset - == static void mccase(struct parse *p, cset *cs); - * - * This would have to know the set of possibilities. Implementation - * is deferred. - */ -/* ARGSUSED */ -static void -mccase( - struct parse *p, - cset *cs) -{ - - _DIAGASSERT(p != NULL); - _DIAGASSERT(cs != NULL); - - assert(cs->multis == NULL); /* xxx */ -} - -/* - - isinsets - is this character in any sets? - == static int isinsets(struct re_guts *g, int c); - */ -static int /* predicate */ -isinsets( - struct re_guts *g, - int c) -{ - uch *col; - size_t i; - size_t ncols; - unsigned uc = (unsigned char)c; - - _DIAGASSERT(g != NULL); - - if (g->setbits == NULL) - return 0; - - ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; - - for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) - if (col[uc] != 0) - return(1); - return(0); -} - -/* - - samesets - are these two characters in exactly the same sets? - == static int samesets(struct re_guts *g, int c1, int c2); - */ -static int /* predicate */ -samesets( - struct re_guts *g, - int c1, - int c2) -{ - uch *col; - size_t i; - size_t ncols; - unsigned uc1 = (unsigned char)c1; - unsigned uc2 = (unsigned char)c2; - - _DIAGASSERT(g != NULL); - - ncols = (g->ncsets+(CHAR_BIT-1)) / CHAR_BIT; - - for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) - if (col[uc1] != col[uc2]) - return(0); - return(1); -} - -/* - - categorize - sort out character categories - == static void categorize(struct parse *p, struct re_guts *g); - */ -static void -categorize( - struct parse *p, - struct re_guts *g) -{ - cat_t *cats; - int c; - int c2; - cat_t cat; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(g != NULL); - - cats = g->categories; - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - for (c = CHAR_MIN; c <= CHAR_MAX; c++) - if (cats[c] == 0 && isinsets(g, c)) { - _DIAGASSERT(__type_fit(unsigned char, - g->ncategories + 1)); - cat = g->ncategories++; - cats[c] = cat; - for (c2 = c+1; c2 <= CHAR_MAX; c2++) - if (cats[c2] == 0 && samesets(g, c, c2)) - cats[c2] = cat; - } -} - -/* - - dupl - emit a duplicate of a bunch of sops - == static sopno dupl(struct parse *p, sopno start, sopno finish); - */ -static sopno /* start of duplicate */ -dupl( - struct parse *p, - sopno start, /* from here */ - sopno finish) /* to this less one */ -{ - sopno ret; - sopno len = finish - start; - - _DIAGASSERT(p != NULL); - - ret = HERE(); - - assert(finish >= start); - if (len == 0) - return(ret); - if (!enlarge(p, p->ssize + len))/* this many unexpected additions */ - return ret; - (void)memcpy(p->strip + p->slen, p->strip + start, - (size_t)len * sizeof(sop)); - p->slen += len; - return(ret); -} - -/* - - doemit - emit a strip operator - == static void doemit(struct parse *p, sop op, size_t opnd); - * - * It might seem better to implement this as a macro with a function as - * hard-case backup, but it's just too big and messy unless there are - * some changes to the data structures. Maybe later. - */ -static void -doemit( - struct parse *p, - sop op, - sopno opnd) -{ - _DIAGASSERT(p != NULL); - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - /* deal with oversize operands ("can't happen", more or less) */ - assert(opnd < 1<slen >= p->ssize) - if (!enlarge(p, (p->ssize+1) / 2 * 3)) /* +50% */ - return; - - /* finally, it's all reduced to the easy case */ - p->strip[p->slen++] = (sop)SOP(op, opnd); -} - -/* - - doinsert - insert a sop into the strip - == static void doinsert(struct parse *p, sop op, size_t opnd, sopno pos); - */ -static void -doinsert( - struct parse *p, - sop op, - sopno opnd, - sopno pos) -{ - sopno sn; - sop s; - int i; - - _DIAGASSERT(p != NULL); - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - sn = HERE(); - EMIT(op, opnd); /* do checks, ensure space */ - assert(HERE() == sn+1); - s = p->strip[sn]; - - /* adjust paren pointers */ - assert(pos > 0); - for (i = 1; i < NPAREN; i++) { - if (p->pbegin[i] >= pos) { - p->pbegin[i]++; - } - if (p->pend[i] >= pos) { - p->pend[i]++; - } - } - - memmove(&p->strip[pos+1], &p->strip[pos], (HERE()-pos-1)*sizeof(sop)); - p->strip[pos] = s; -} - -/* - - dofwd - complete a forward reference - == static void dofwd(struct parse *p, sopno pos, sop value); - */ -static void -dofwd( - struct parse *p, - sopno pos, - sopno value) -{ - - _DIAGASSERT(p != NULL); - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - assert(value < 1<strip[pos] = (sop)(OP(p->strip[pos]) | value); -} - -/* - - enlarge - enlarge the strip - == static void enlarge(struct parse *p, sopno size); - */ -static int -enlarge(struct parse *p, sopno size) -{ - _DIAGASSERT(p != NULL); - - if (p->ssize >= size) - return 1; - - if (MEMSIZE(p) > MEMLIMIT || reallocarr(&p->strip, size, sizeof(sop))) { - SETERROR(REG_ESPACE); - return 0; - } - p->ssize = size; - return 1; -} - -/* - - stripsnug - compact the strip - == static void stripsnug(struct parse *p, struct re_guts *g); - */ -static void -stripsnug( - struct parse *p, - struct re_guts *g) -{ - - _DIAGASSERT(p != NULL); - _DIAGASSERT(g != NULL); - - g->nstates = p->slen; - g->strip = p->strip; - reallocarr(&g->strip, p->slen, sizeof(sop)); - /* Ignore error as tries to free memory only. */ -} - -/* - - findmust - fill in must and mlen with longest mandatory literal string - == static void findmust(struct parse *p, struct re_guts *g); - * - * This algorithm could do fancy things like analyzing the operands of | - * for common subsequences. Someday. This code is simple and finds most - * of the interesting cases. - * - * Note that must and mlen got initialized during setup. - */ -static void -findmust( - struct parse *p, - struct re_guts *g) -{ - sop *scan; - sop *start = NULL; - sop *newstart = NULL; - sopno newlen; - sop s; - char *cp; - sopno i; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(g != NULL); - - /* avoid making error situations worse */ - if (p->error != 0) - return; - - /* find the longest OCHAR sequence in strip */ - newlen = 0; - scan = g->strip + 1; - do { - s = *scan++; - switch (OP(s)) { - case OCHAR: /* sequence member */ - if (newlen == 0) /* new sequence */ - newstart = scan - 1; - newlen++; - break; - case OPLUS_: /* things that don't break one */ - case OLPAREN: - case ORPAREN: - break; - case OQUEST_: /* things that must be skipped */ - case OCH_: - scan--; - do { - scan += OPND(s); - s = *scan; - /* assert() interferes w debug printouts */ - if (OP(s) != O_QUEST && OP(s) != O_CH && - OP(s) != OOR2) { - g->iflags |= BAD; - return; - } - } while (OP(s) != O_QUEST && OP(s) != O_CH); - /* FALLTHROUGH */ - default: /* things that break a sequence */ - if (newlen > g->mlen) { /* ends one */ - start = newstart; - g->mlen = newlen; - } - newlen = 0; - break; - } - } while (OP(s) != OEND); - - if (start == NULL) - g->mlen = 0; - - if (g->mlen == 0) /* there isn't one */ - return; - - /* turn it into a character string */ - g->must = malloc((size_t)g->mlen + 1); - if (g->must == NULL) { /* argh; just forget it */ - g->mlen = 0; - return; - } - cp = g->must; - scan = start; - for (i = g->mlen; i > 0; i--) { - while (OP(s = *scan++) != OCHAR) - continue; - assert(cp < g->must + g->mlen); - *cp++ = (char)OPND(s); - } - assert(cp == g->must + g->mlen); - *cp++ = '\0'; /* just on general principles */ -} - -/* - - pluscount - count + nesting - == static sopno pluscount(struct parse *p, struct re_guts *g); - */ -static sopno /* nesting depth */ -pluscount( - struct parse *p, - struct re_guts *g) -{ - sop *scan; - sop s; - sopno plusnest = 0; - sopno maxnest = 0; - - _DIAGASSERT(p != NULL); - _DIAGASSERT(g != NULL); - - if (p->error != 0) - return(0); /* there may not be an OEND */ - - scan = g->strip + 1; - do { - s = *scan++; - switch (OP(s)) { - case OPLUS_: - plusnest++; - break; - case O_PLUS: - if (plusnest > maxnest) - maxnest = plusnest; - plusnest--; - break; - } - } while (OP(s) != OEND); - if (plusnest != 0) - g->iflags |= BAD; - return(maxnest); -} diff --git a/lib/libc/regex/regerror.c b/lib/libc/regex/regerror.c deleted file mode 100644 index e00d7c035..000000000 --- a/lib/libc/regex/regerror.c +++ /dev/null @@ -1,223 +0,0 @@ -/* $NetBSD: regerror.c,v 1.23 2007/02/09 23:44:18 junyoung Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)regerror.c 8.4 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)regerror.c 8.4 (Berkeley) 3/20/94 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; -#else -__RCSID("$NetBSD: regerror.c,v 1.23 2007/02/09 23:44:18 junyoung Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(regerror,_regerror) -#endif - -#include "utils.h" - -/* ========= begin header generated by ./mkh ========= */ -#ifdef __cplusplus -extern "C" { -#endif - -/* === regerror.c === */ -static const char *regatoi(const regex_t *preg, char *localbuf, size_t buflen); - -#ifdef __cplusplus -} -#endif -/* ========= end header generated by ./mkh ========= */ -/* - = #define REG_NOMATCH 1 - = #define REG_BADPAT 2 - = #define REG_ECOLLATE 3 - = #define REG_ECTYPE 4 - = #define REG_EESCAPE 5 - = #define REG_ESUBREG 6 - = #define REG_EBRACK 7 - = #define REG_EPAREN 8 - = #define REG_EBRACE 9 - = #define REG_BADBR 10 - = #define REG_ERANGE 11 - = #define REG_ESPACE 12 - = #define REG_BADRPT 13 - = #define REG_EMPTY 14 - = #define REG_ASSERT 15 - = #define REG_INVARG 16 - = #define REG_ATOI 255 // convert name to number (!) - = #define REG_ITOA 0400 // convert number to name (!) - */ -static const struct rerr { - int code; - const char *name; - const char *explain; -} rerrs[] = { - { REG_NOMATCH, "REG_NOMATCH", "regexec() failed to match" }, - { REG_BADPAT, "REG_BADPAT", "invalid regular expression" }, - { REG_ECOLLATE, "REG_ECOLLATE", "invalid collating element" }, - { REG_ECTYPE, "REG_ECTYPE", "invalid character class" }, - { REG_EESCAPE, "REG_EESCAPE", "trailing backslash (\\)" }, - { REG_ESUBREG, "REG_ESUBREG", "invalid backreference number" }, - { REG_EBRACK, "REG_EBRACK", "brackets ([ ]) not balanced" }, - { REG_EPAREN, "REG_EPAREN", "parentheses not balanced" }, - { REG_EBRACE, "REG_EBRACE", "braces not balanced" }, - { REG_BADBR, "REG_BADBR", "invalid repetition count(s)" }, - { REG_ERANGE, "REG_ERANGE", "invalid character range" }, - { REG_ESPACE, "REG_ESPACE", "out of memory" }, - { REG_BADRPT, "REG_BADRPT", "repetition-operator operand invalid" }, - { REG_EMPTY, "REG_EMPTY", "empty (sub)expression" }, - { REG_ASSERT, "REG_ASSERT", "\"can't happen\" -- you found a bug" }, - { REG_INVARG, "REG_INVARG", "invalid argument to regex routine" }, - { 0, "", "*** unknown regexp error code ***" } -}; - -/* - * regerror - the interface to error numbers - * extern size_t regerror(int, const regex_t *, char *, size_t); - */ -/* ARGSUSED */ -size_t -regerror( - int errcode, - const regex_t *preg, - char *errbuf, - size_t errbuf_size) -{ - const struct rerr *r; - size_t len; - int target = errcode &~ REG_ITOA; - const char *s; - char convbuf[50]; - - _DIAGASSERT(errcode != REG_ATOI || preg != NULL); - _DIAGASSERT(errbuf != NULL); - - if (errcode == REG_ATOI) - s = regatoi(preg, convbuf, sizeof convbuf); - else { - for (r = rerrs; r->code != 0; r++) - if (r->code == target) - break; - - if (errcode & REG_ITOA) { - if (r->code != 0) { - (void)strlcpy(convbuf, r->name, sizeof convbuf); - } else - (void)snprintf(convbuf, sizeof convbuf, - "REG_0x%x", target); - s = convbuf; - } else - s = r->explain; - } - - len = strlen(s) + 1; - if (errbuf_size > 0) - (void)strlcpy(errbuf, s, errbuf_size); - - return(len); -} - -/* - * regatoi - internal routine to implement REG_ATOI - * static const char *regatoi(const regex_t *preg, char *localbuf, - * size_t buflen); - */ -static const char * -regatoi( - const regex_t *preg, - char *localbuf, - size_t buflen) -{ - const struct rerr *r; - - for (r = rerrs; r->code != 0; r++) - if (strcmp(r->name, preg->re_endp) == 0) - break; - if (r->code == 0) - return "0"; - - (void)snprintf(localbuf, buflen, "%d", r->code); - return localbuf; -} diff --git a/lib/libc/regex/regex.3 b/lib/libc/regex/regex.3 deleted file mode 100644 index 78ae7eaa1..000000000 --- a/lib/libc/regex/regex.3 +++ /dev/null @@ -1,631 +0,0 @@ -.\" $NetBSD: regex.3,v 1.22 2011/05/17 03:35:38 enami Exp $ -.\" -.\" Copyright (c) 1992, 1993, 1994 -.\" The Regents of the University of California. All rights reserved. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Henry Spencer. -.\" -.\" 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. -.\" -.\" Copyright (c) 1992, 1993, 1994 Henry Spencer. -.\" -.\" This code is derived from software contributed to Berkeley by -.\" Henry Spencer. -.\" -.\" Redistribution and use in source and binary forms, with or without -.\" modification, are permitted provided that the following conditions -.\" are met: -.\" 1. Redistributions of source code must retain the above copyright -.\" notice, this list of conditions and the following disclaimer. -.\" 2. Redistributions in binary form must reproduce the above copyright -.\" notice, this list of conditions and the following disclaimer in the -.\" documentation and/or other materials provided with the distribution. -.\" 3. All advertising materials mentioning features or use of this software -.\" must display the following acknowledgement: -.\" This product includes software developed by the University of -.\" California, Berkeley and its contributors. -.\" 4. Neither the name of the University nor the names of its contributors -.\" may be used to endorse or promote products derived from this software -.\" without specific prior written permission. -.\" -.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND -.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE -.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL -.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS -.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) -.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT -.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF -.\" SUCH DAMAGE. -.\" -.\" @(#)regex.3 8.4 (Berkeley) 3/20/94 -.\" -.Dd December 29, 2003 -.Dt REGEX 3 -.Os -.Sh NAME -.Nm regex , -.Nm regcomp , -.Nm regexec , -.Nm regerror , -.Nm regfree -.Nd regular-expression library -.Sh LIBRARY -.Lb libc -.Sh SYNOPSIS -.In regex.h -.Ft int -.Fn regcomp "regex_t * restrict preg" "const char * restrict pattern" "int cflags" -.Ft int -.Fn regexec "const regex_t * restrict preg" "const char * restrict string" "size_t nmatch" "regmatch_t pmatch[]" "int eflags" -.Ft size_t -.Fn regerror "int errcode" "const regex_t * restrict preg" "char * restrict errbuf" "size_t errbuf_size" -.Ft void -.Fn regfree "regex_t *preg" -.Sh DESCRIPTION -These routines implement -.St -p1003.2-92 -regular expressions (``RE''s); -see -.Xr re_format 7 . -.Fn regcomp -compiles an RE written as a string into an internal form, -.Fn regexec -matches that internal form against a string and reports results, -.Fn regerror -transforms error codes from either into human-readable messages, -and -.Fn regfree -frees any dynamically-allocated storage used by the internal form -of an RE. -.Pp -The header -.In regex.h -declares two structure types, -.Fa regex_t -and -.Fa regmatch_t , -the former for compiled internal forms and the latter for match reporting. -It also declares the four functions, -a type -.Fa regoff_t , -and a number of constants with names starting with ``REG_''. -.Pp -.Fn regcomp -compiles the regular expression contained in the -.Fa pattern -string, -subject to the flags in -.Fa cflags , -and places the results in the -.Fa regex_t -structure pointed to by -.Fa preg . -.Fa cflags -is the bitwise OR of zero or more of the following flags: -.Bl -tag -width XXXREG_EXTENDED -.It Dv REG_EXTENDED -Compile modern (``extended'') REs, rather than the obsolete -(``basic'') REs that are the default. -.It Dv REG_BASIC -This is a synonym for 0, -provided as a counterpart to REG_EXTENDED to improve readability. -.It Dv REG_NOSPEC -Compile with recognition of all special characters turned off. -All characters are thus considered ordinary, so the ``RE'' is a literal -string. -This is an extension, compatible with but not specified by -.St -p1003.2-92 , -and should be used with caution in software intended to be portable to -other systems. -.Dv REG_EXTENDED -and -.Dv REG_NOSPEC -may not be used in the same call to -.Fn regcomp . -.It Dv REG_ICASE -Compile for matching that ignores upper/lower case distinctions. -See -.Xr re_format 7 . -.It Dv REG_NOSUB -Compile for matching that need only report success or failure, not -what was matched. -.It Dv REG_NEWLINE -Compile for newline-sensitive matching. -By default, newline is a completely ordinary character with no special -meaning in either REs or strings. -With this flag, -`[^' bracket expressions and `.' never match newline, -a `^' anchor matches the null string after any newline in the string -in addition to its normal function, -and the `$' anchor matches the null string before any newline in the -string in addition to its normal function. -.It Dv REG_PEND -The regular expression ends, not at the first NUL, but just before the -character pointed to by the -.Fa re_endp -member of the structure pointed to by -.Fa preg . -The -.Fa re_endp -member is of type -.Fa "const\ char\ *" . -This flag permits inclusion of NULs in the RE; they are considered -ordinary characters. -This is an extension, compatible with but not specified by -.St -p1003.2-92 , -and should be used with caution in software intended to be portable to -other systems. -.El -.Pp -When successful, -.Fn regcomp -returns 0 and fills in the structure pointed to by -.Fa preg . -One member of that structure (other than -.Fa re_endp ) -is publicized: -.Fa re_nsub , -of type -.Fa size_t , -contains the number of parenthesized subexpressions within the RE -(except that the value of this member is undefined if the -.Dv REG_NOSUB -flag was used). -If -.Fn regcomp -fails, it returns a non-zero error code; -see -.Sx DIAGNOSTICS . -.Pp -.Fn regexec -matches the compiled RE pointed to by -.Fa preg -against the -.Fa string , -subject to the flags in -.Fa eflags , -and reports results using -.Fa nmatch , -.Fa pmatch , -and the returned value. -The RE must have been compiled by a previous invocation of -.Fn regcomp . -The compiled form is not altered during execution of -.Fn regexec , -so a single compiled RE can be used simultaneously by multiple threads. -.Pp -By default, -the NUL-terminated string pointed to by -.Fa string -is considered to be the text of an entire line, minus any terminating -newline. -The -.Fa eflags -argument is the bitwise OR of zero or more of the following flags: -.Bl -tag -width XXXREG_NOTBOL -.It Dv REG_NOTBOL -The first character of the string -is not the beginning of a line, so the `^' anchor should not match before it. -This does not affect the behavior of newlines under -.Dv REG_NEWLINE . -.It Dv REG_NOTEOL -The NUL terminating the string does not end a line, so the `$' anchor -should not match before it. -This does not affect the behavior of newlines under -.Dv REG_NEWLINE . -.It Dv REG_STARTEND -The string is considered to start at -.Fa string -+ -.Fa pmatch[0].rm_so -and to have a terminating NUL located at -.Fa string -+ -.Fa pmatch[0].rm_eo -(there need not actually be a NUL at that location), -regardless of the value of -.Fa nmatch . -See below for the definition of -.Fa pmatch -and -.Fa nmatch . -This is an extension, compatible with but not specified by -.St -p1003.2-92 , -and should be used with caution in software intended to be portable to -other systems. -Note that a non-zero -.Fa rm_so -does not imply -.Dv REG_NOTBOL ; -.Dv REG_STARTEND -affects only the location of the string, not how it is matched. -.El -.Pp -See -.Xr re_format 7 -for a discussion of what is matched in situations where an RE or a -portion thereof could match any of several substrings of -.Fa string . -.Pp -Normally, -.Fn regexec -returns 0 for success and the non-zero code -.Dv REG_NOMATCH -for failure. -Other non-zero error codes may be returned in exceptional situations; -see -.Sx DIAGNOSTICS . -.Pp -If -.Dv REG_NOSUB -was specified in the compilation of the RE, or if -.Fa nmatch -is 0, -.Fn regexec -ignores the -.Fa pmatch -argument (but see below for the case where -.Dv REG_STARTEND -is specified). -Otherwise, -.Fa pmatch -points to an array of -.Fa nmatch -structures of type -.Fa regmatch_t . -Such a structure has at least the members -.Fa rm_so -and -.Fa rm_eo , -both of type -.Fa regoff_t -(a signed arithmetic type at least as large as an -.Fa off_t -and a -.Fa ssize_t ) , -containing respectively the offset of the first character of a substring -and the offset of the first character after the end of the substring. -Offsets are measured from the beginning of the -.Fa string -argument given to -.Fn regexec . -An empty substring is denoted by equal offsets, -both indicating the character following the empty substring. -.Pp -The 0th member of the -.Fa pmatch -array is filled in to indicate what substring of -.Fa string -was matched by the entire RE. -Remaining members report what substring was matched by parenthesized -subexpressions within the RE; -member -.Fa i -reports subexpression -.Fa i , -with subexpressions counted (starting at 1) by the order of their -opening parentheses in the RE, left to right. -Unused entries in the array\(emcorresponding either to subexpressions that -did not participate in the match at all, or to subexpressions that do not -exist in the RE (that is, -.Fa i -\*[Gt] -.Fa preg-\*[Gt]re_nsub ) -\(emhave both -.Fa rm_so -and -.Fa rm_eo -set to -1. -If a subexpression participated in the match several times, -the reported substring is the last one it matched. -(Note, as an example in particular, that when the RE `(b*)+' matches `bbb', -the parenthesized subexpression matches each of the three `b's and then -an infinite number of empty strings following the last `b', -so the reported substring is one of the empties.) -.Pp -If -.Dv REG_STARTEND -is specified, -.Fa pmatch -must point to at least one -.Fa regmatch_t -(even if -.Fa nmatch -is 0 or -.Dv REG_NOSUB -was specified), -to hold the input offsets for -.Dv REG_STARTEND . -Use for output is still entirely controlled by -.Fa nmatch ; -if -.Fa nmatch -is 0 or -.Dv REG_NOSUB -was specified, -the value of -.Fa pmatch [0] -will not be changed by a successful -.Fn regexec . -.Pp -.Fn regerror -maps a non-zero -.Fa errcode -from either -.Fn regcomp -or -.Fn regexec -to a human-readable, printable message. -If -.Fa preg -is non-NULL, -the error code should have arisen from use of the -.Fa regex_t -pointed to by -.Fa preg , -and if the error code came from -.Fn regcomp , -it should have been the result from the most recent -.Fn regcomp -using that -.Fa regex_t . -.Po Fn regerror -may be able to supply a more detailed message using information -from the -.Fa regex_t . Pc -.Fn regerror -places the NUL-terminated message into the buffer pointed to by -.Fa errbuf , -limiting the length (including the NUL) to at most -.Fa errbuf_size -bytes. -If the whole message won't fit, -as much of it as will fit before the terminating NUL is supplied. -In any case, -the returned value is the size of buffer needed to hold the whole -message (including terminating NUL). -If -.Fa errbuf_size -is 0, -.Fa errbuf -is ignored but the return value is still correct. -.Pp -If the -.Fa errcode -given to -.Fn regerror -is first ORed with -.Dv REG_ITOA , -the ``message'' that results is the printable name of the error code, -e.g. ``REG_NOMATCH'', -rather than an explanation thereof. -If -.Fa errcode -is -.Dv REG_ATOI , -then -.Fa preg -shall be non-NULL and the -.Fa re_endp -member of the structure it points to -must point to the printable name of an error code; -in this case, the result in -.Fa errbuf -is the decimal digits of -the numeric value of the error code -(0 if the name is not recognized). -.Dv REG_ITOA -and -.Dv REG_ATOI -are intended primarily as debugging facilities; -they are extensions, compatible with but not specified by -.St -p1003.2-92 , -and should be used with caution in software intended to be portable to -other systems. -Be warned also that they are considered experimental and changes are possible. -.Pp -.Fn regfree -frees any dynamically-allocated storage associated with the compiled RE -pointed to by -.Fa preg . -The remaining -.Fa regex_t -is no longer a valid compiled RE -and the effect of supplying it to -.Fn regexec -or -.Fn regerror -is undefined. -.Pp -None of these functions references global variables except for tables -of constants; -all are safe for use from multiple threads if the arguments are safe. -.Sh IMPLEMENTATION CHOICES -There are a number of decisions that -.St -p1003.2-92 -leaves up to the implementor, -either by explicitly saying ``undefined'' or by virtue of them being -forbidden by the RE grammar. -This implementation treats them as follows. -.Pp -See -.Xr re_format 7 -for a discussion of the definition of case-independent matching. -.Pp -There is no particular limit on the length of REs, -except insofar as memory is limited. -Memory usage is approximately linear in RE size, and largely insensitive -to RE complexity, except for bounded repetitions. -See BUGS for one short RE using them -that will run almost any system out of memory. -.Pp -A backslashed character other than one specifically given a magic meaning -by -.St -p1003.2-92 -(such magic meanings occur only in obsolete [``basic''] REs) -is taken as an ordinary character. -.Pp -Any unmatched [ is a -.Dv REG_EBRACK -error. -.Pp -Equivalence classes cannot begin or end bracket-expression ranges. -The endpoint of one range cannot begin another. -.Pp -.Dv RE_DUP_MAX , -the limit on repetition counts in bounded repetitions, is 255. -.Pp -A repetition operator (?, *, +, or bounds) cannot follow another -repetition operator. -A repetition operator cannot begin an expression or subexpression -or follow `^' or `|'. -.Pp -`|' cannot appear first or last in a (sub)expression or after another `|', -i.e. an operand of `|' cannot be an empty subexpression. -An empty parenthesized subexpression, `()', is legal and matches an -empty (sub)string. -An empty string is not a legal RE. -.Pp -A `{' followed by a digit is considered the beginning of bounds for a -bounded repetition, which must then follow the syntax for bounds. -A `{' -.Em not -followed by a digit is considered an ordinary character. -.Pp -`^' and `$' beginning and ending subexpressions in obsolete (``basic'') -REs are anchors, not ordinary characters. -.Sh DIAGNOSTICS -Non-zero error codes from -.Fn regcomp -and -.Fn regexec -include the following: -.Pp -.Bl -tag -width XXXREG_ECOLLATE -compact -.It Dv REG_NOMATCH -.Fn regexec -failed to match -.It Dv REG_BADPAT -invalid regular expression -.It Dv REG_ECOLLATE -invalid collating element -.It Dv REG_ECTYPE -invalid character class -.It Dv REG_EESCAPE -\e applied to unescapable character -.It Dv REG_ESUBREG -invalid backreference number -.It Dv REG_EBRACK -brackets [ ] not balanced -.It Dv REG_EPAREN -parentheses ( ) not balanced -.It Dv REG_EBRACE -braces { } not balanced -.It Dv REG_BADBR -invalid repetition count(s) in { } -.It Dv REG_ERANGE -invalid character range in [ ] -.It Dv REG_ESPACE -ran out of memory -.It Dv REG_BADRPT -?, *, or + operand invalid -.It Dv REG_EMPTY -empty (sub)expression -.It Dv REG_ASSERT -``can't happen''\(emyou found a bug -.It Dv REG_INVARG -invalid argument, e.g. negative-length string -.El -.Sh SEE ALSO -.Xr grep 1 , -.Xr sed 1 , -.Xr re_format 7 -.Pp -.St -p1003.2-92 , -sections 2.8 (Regular Expression Notation) -and -B.5 (C Binding for Regular Expression Matching). -.Sh HISTORY -Originally written by Henry Spencer. -Altered for inclusion in the -.Bx 4.4 -distribution. -.Sh BUGS -There is one known functionality bug. -The implementation of internationalization is incomplete: -the locale is always assumed to be the default one of -.St -p1003.2-92 , -and only the collating elements etc. of that locale are available. -.Pp -The back-reference code is subtle and doubts linger about its correctness -in complex cases. -.Pp -.Fn regexec -performance is poor. -This will improve with later releases. -.Fa nmatch -exceeding 0 is expensive; -.Fa nmatch -exceeding 1 is worse. -.Fa regexec -is largely insensitive to RE complexity -.Em except -that back references are massively expensive. -RE length does matter; in particular, there is a strong speed bonus -for keeping RE length under about 30 characters, -with most special characters counting roughly double. -.Pp -.Fn regcomp -implements bounded repetitions by macro expansion, -which is costly in time and space if counts are large -or bounded repetitions are nested. -An RE like, say, -`((((a{1,100}){1,100}){1,100}){1,100}){1,100}' -will (eventually) run almost any existing machine out of swap space. -.Pp -There are suspected problems with response to obscure error conditions. -Notably, -certain kinds of internal overflow, -produced only by truly enormous REs or by multiply nested bounded repetitions, -are probably not handled well. -.Pp -Due to a mistake in -.St -p1003.2-92 , -things like `a)b' are legal REs because `)' is a special character -only in the presence of a previous unmatched `('. -This can't be fixed until the spec is fixed. -.Pp -The standard's definition of back references is vague. -For example, does -`a\e(\e(b\e)*\e2\e)*d' match `abbbd'? -Until the standard is clarified, behavior in such cases should not be -relied on. -.Pp -The implementation of word-boundary matching is a bit of a kludge, -and bugs may lurk in combinations of word-boundary matching and anchoring. diff --git a/lib/libc/regex/regex2.h b/lib/libc/regex/regex2.h deleted file mode 100644 index 7c877ee87..000000000 --- a/lib/libc/regex/regex2.h +++ /dev/null @@ -1,209 +0,0 @@ -/* $NetBSD: regex2.h,v 1.13 2011/10/09 18:23:00 christos Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)regex2.h 8.4 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)regex2.h 8.4 (Berkeley) 3/20/94 - */ - -/* - * First, the stuff that ends up in the outside-world include file - = typedef off_t regoff_t; - = typedef struct { - = int re_magic; - = size_t re_nsub; // number of parenthesized subexpressions - = const char *re_endp; // end pointer for REG_PEND - = struct re_guts *re_g; // none of your business :-) - = } regex_t; - = typedef struct { - = regoff_t rm_so; // start of match - = regoff_t rm_eo; // end of match - = } regmatch_t; - */ -/* - * internals of regex_t - */ -#define MAGIC1 ((('r'^0200)<<8) | 'e') - -/* - * The internal representation is a *strip*, a sequence of - * operators ending with an endmarker. (Some terminology etc. is a - * historical relic of earlier versions which used multiple strips.) - * Certain oddities in the representation are there to permit running - * the machinery backwards; in particular, any deviation from sequential - * flow must be marked at both its source and its destination. Some - * fine points: - * - * - OPLUS_ and O_PLUS are *inside* the loop they create. - * - OQUEST_ and O_QUEST are *outside* the bypass they create. - * - OCH_ and O_CH are *outside* the multi-way branch they create, while - * OOR1 and OOR2 are respectively the end and the beginning of one of - * the branches. Note that there is an implicit OOR2 following OCH_ - * and an implicit OOR1 preceding O_CH. - * - * In state representations, an operator's bit is on to signify a state - * immediately *preceding* "execution" of that operator. - */ -typedef u_int32_t sop; /* strip operator */ -typedef size_t sopno; -#define OPRMASK ((u_int32_t)0xf8000000UL) -#define OPDMASK ((u_int32_t)0x07ffffffUL) -#define OPSHIFT ((unsigned)27) -#define OP(n) ((n)&OPRMASK) -#define OPND(n) ((int)((n)&OPDMASK)) -#define SOP(op, opnd) ((op)|(opnd)) - -#define OPC(n) (((u_int32_t)(n))< uch [csetsize] */ - uch mask; /* bit within array */ - uch hash; /* hash code */ - size_t smultis; - char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ -} cset; -/* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ -#define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) -#define CHsub(cs, c) ((cs)->ptr[(uch)(c)] &= ~(cs)->mask, (cs)->hash -= (c)) -#define CHIN(cs, c) ((cs)->ptr[(uch)(c)] & (cs)->mask) -#define MCadd(p, cs, cp) mcadd(p, cs, cp) /* regcomp() internal fns */ -#define MCsub(p, cs, cp) mcsub(p, cs, cp) -#define MCin(p, cs, cp) mcin(p, cs, cp) - -/* stuff for character categories */ -typedef unsigned char cat_t; - -/* - * main compiled-expression structure - */ -struct re_guts { - int magic; -# define MAGIC2 ((('R'^0200)<<8)|'E') - sop *strip; /* malloced area for strip */ - size_t csetsize; /* number of bits in a cset vector */ - size_t ncsets; /* number of csets in use */ - cset *sets; /* -> cset [ncsets] */ - uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */ - int cflags; /* copy of regcomp() cflags argument */ - sopno nstates; /* = number of sops */ - sopno firststate; /* the initial OEND (normally 0) */ - sopno laststate; /* the final OEND */ - int iflags; /* internal flags */ -# define USEBOL 01 /* used ^ */ -# define USEEOL 02 /* used $ */ -# define BAD 04 /* something wrong */ - size_t nbol; /* number of ^ used */ - size_t neol; /* number of $ used */ - size_t ncategories; /* how many character categories */ - cat_t *categories; /* ->catspace[-CHAR_MIN] */ - char *must; /* match must contain this string */ - size_t mlen; /* length of must */ - size_t nsub; /* copy of re_nsub */ - int backrefs; /* does it use back references? */ - sopno nplus; /* how deep does it nest +s? */ - /* catspace must be last */ - cat_t catspace[1]; /* actually [NC] */ -}; - -/* misc utilities */ -#define OUT (CHAR_MAX+1) /* a non-character value */ -#define ISWORD(c) (isalnum((unsigned char)c) || (c) == '_') diff --git a/lib/libc/regex/regexec.c b/lib/libc/regex/regexec.c deleted file mode 100644 index f16e0b6b4..000000000 --- a/lib/libc/regex/regexec.c +++ /dev/null @@ -1,234 +0,0 @@ -/* $NetBSD: regexec.c,v 1.22 2012/03/13 21:13:43 christos Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)regexec.c 8.3 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)regexec.c 8.3 (Berkeley) 3/20/94 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; -#else -__RCSID("$NetBSD: regexec.c,v 1.22 2012/03/13 21:13:43 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -/* - * the outer shell of regexec() - * - * This file includes engine.c *twice*, after muchos fiddling with the - * macros that code uses. This lets the same code operate on two different - * representations for state sets. - */ -#include "namespace.h" -#include - -#include -#include -#include -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(regexec,_regexec) -#endif - -#include "utils.h" -#include "regex2.h" - -/* macros for manipulating states, small version */ -#define states unsigned long -#define states1 unsigned long /* for later use in regexec() decision */ -#define CLEAR(v) ((v) = 0) -#define SET0(v, n) ((v) &= ~((unsigned long)1 << (n))) -#define SET1(v, n) ((v) |= (unsigned long)1 << (n)) -#define ISSET(v, n) (((v) & ((unsigned long)1 << (n))) != 0) -#define ASSIGN(d, s) ((d) = (s)) -#define EQ(a, b) ((a) == (b)) -#define STATEVARS int dummy /* dummy version */ -#define STATESETUP(m, n) /* nothing */ -#define STATETEARDOWN(m) /* nothing */ -#define SETUP(v) ((v) = 0) -#define onestate unsigned long -#define INIT(o, n) ((o) = (unsigned long)1 << (n)) -#define INC(o) ((o) <<= 1) -#define ISSTATEIN(v, o) (((v) & (o)) != 0) -/* some abbreviations; note that some of these know variable names! */ -/* do "if I'm here, I can also be there" etc without branches */ -#define FWD(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) << (n)) -#define BACK(dst, src, n) ((dst) |= ((unsigned long)(src)&(here)) >> (n)) -#define ISSETBACK(v, n) (((v) & ((unsigned long)here >> (n))) != 0) -/* function names */ -#define SNAMES /* engine.c looks after details */ - -#include "engine.c" - -/* now undo things */ -#undef states -#undef CLEAR -#undef SET0 -#undef SET1 -#undef ISSET -#undef ASSIGN -#undef EQ -#undef STATEVARS -#undef STATESETUP -#undef STATETEARDOWN -#undef SETUP -#undef onestate -#undef INIT -#undef INC -#undef ISSTATEIN -#undef FWD -#undef BACK -#undef ISSETBACK -#undef SNAMES - -/* macros for manipulating states, large version */ -#define states char * -#define CLEAR(v) memset(v, 0, (size_t)m->g->nstates) -#define SET0(v, n) ((v)[n] = 0) -#define SET1(v, n) ((v)[n] = 1) -#define ISSET(v, n) ((v)[n]) -#define ASSIGN(d, s) memcpy(d, s, (size_t)m->g->nstates) -#define EQ(a, b) (memcmp(a, b, (size_t)m->g->nstates) == 0) -#define STATEVARS int vn; char *space -#define STATESETUP(m, nv) \ - if (((m)->space = malloc((size_t)((nv)*(m)->g->nstates))) == NULL) \ - return(REG_ESPACE); \ - else \ - (m)->vn = 0 - -#define STATETEARDOWN(m) { free((m)->space); m->space = NULL; } -#define SETUP(v) ((v) = &m->space[(size_t)(m->vn++ * m->g->nstates)]) -#define onestate int -#define INIT(o, n) ((o) = (int)(n)) -#define INC(o) ((o)++) -#define ISSTATEIN(v, o) ((v)[o]) -/* some abbreviations; note that some of these know variable names! */ -/* do "if I'm here, I can also be there" etc without branches */ -#define FWD(dst, src, n) ((dst)[here+(n)] |= (src)[here]) -#define BACK(dst, src, n) ((dst)[here-(n)] |= (src)[here]) -#define ISSETBACK(v, n) ((v)[here - (n)]) -/* function names */ -#define LNAMES /* flag */ - -#include "engine.c" - -/* - - regexec - interface for matching - = extern int regexec(const regex_t *, const char *, size_t, \ - = regmatch_t [], int); - = #define REG_NOTBOL 00001 - = #define REG_NOTEOL 00002 - = #define REG_STARTEND 00004 - = #define REG_TRACE 00400 // tracing of execution - = #define REG_LARGE 01000 // force large representation - = #define REG_BACKR 02000 // force use of backref code - * - * We put this here so we can exploit knowledge of the state representation - * when choosing which matcher to call. Also, by this point the matchers - * have been prototyped. - */ -int /* 0 success, REG_NOMATCH failure */ -regexec( - const regex_t *preg, - const char *string, - size_t nmatch, - regmatch_t pmatch[], - int eflags) -{ - struct re_guts *g = preg->re_g; - char *s; -#ifdef REDEBUG -# define GOODFLAGS(f) (f) -#else -# define GOODFLAGS(f) ((f)&(REG_NOTBOL|REG_NOTEOL|REG_STARTEND)) -#endif - - _DIAGASSERT(preg != NULL); - _DIAGASSERT(string != NULL); - - if (preg->re_magic != MAGIC1 || g->magic != MAGIC2) - return(REG_BADPAT); - assert(!(g->iflags&BAD)); - if (g->iflags&BAD) /* backstop for no-debug case */ - return(REG_BADPAT); - eflags = GOODFLAGS(eflags); - - s = __UNCONST(string); - - if (g->nstates <= (sopno)(CHAR_BIT*sizeof(states1)) && !(eflags®_LARGE)) - return(smatcher(g, s, nmatch, pmatch, eflags)); - else - return(lmatcher(g, s, nmatch, pmatch, eflags)); -} diff --git a/lib/libc/regex/regfree.c b/lib/libc/regex/regfree.c deleted file mode 100644 index ce011eade..000000000 --- a/lib/libc/regex/regfree.c +++ /dev/null @@ -1,129 +0,0 @@ -/* $NetBSD: regfree.c,v 1.15 2007/02/09 23:44:18 junyoung Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)regfree.c 8.3 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)regfree.c 8.3 (Berkeley) 3/20/94 - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#if 0 -static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; -#else -__RCSID("$NetBSD: regfree.c,v 1.15 2007/02/09 23:44:18 junyoung Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "namespace.h" -#include - -#include -#include -#include -#include - -#ifdef __weak_alias -__weak_alias(regfree,_regfree) -#endif - -#include "utils.h" -#include "regex2.h" - -/* - - regfree - free everything - = extern void regfree(regex_t *); - */ -void -regfree( - regex_t *preg) -{ - struct re_guts *g; - - _DIAGASSERT(preg != NULL); - - _DIAGASSERT(preg->re_magic == MAGIC1); - if (preg->re_magic != MAGIC1) /* oops */ - return; /* nice to complain, but hard */ - - g = preg->re_g; - if (g == NULL || g->magic != MAGIC2) /* oops again */ - return; - preg->re_magic = 0; /* mark it invalid */ - g->magic = 0; /* mark it invalid */ - - if (g->strip != NULL) - free(g->strip); - if (g->sets != NULL) - free(g->sets); - if (g->setbits != NULL) - free(g->setbits); - if (g->must != NULL) - free(g->must); - free(g); -} diff --git a/lib/libc/regex/utils.h b/lib/libc/regex/utils.h deleted file mode 100644 index 762caeeb6..000000000 --- a/lib/libc/regex/utils.h +++ /dev/null @@ -1,91 +0,0 @@ -/* $NetBSD: utils.h,v 1.6 2003/08/07 16:43:21 agc Exp $ */ - -/*- - * Copyright (c) 1992, 1993, 1994 - * The Regents of the University of California. All rights reserved. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * 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. - * - * @(#)utils.h 8.3 (Berkeley) 3/20/94 - */ - -/*- - * Copyright (c) 1992, 1993, 1994 Henry Spencer. - * - * This code is derived from software contributed to Berkeley by - * Henry Spencer. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * @(#)utils.h 8.3 (Berkeley) 3/20/94 - */ - -/* utility definitions */ -#define DUPMAX _POSIX2_RE_DUP_MAX /* xxx is this right? */ -#define INFINITY (DUPMAX + 1) -#define NC (CHAR_MAX - CHAR_MIN + 1) -typedef unsigned char uch; - -/* switch off assertions (if not already off) if no REDEBUG */ -#ifndef REDEBUG -#ifndef NDEBUG -#define NDEBUG /* no assertions please */ -#endif -#endif -#include - -/* for old systems with bcopy() but no memmove() */ -#ifdef USEBCOPY -#define memmove(d, s, c) bcopy(s, d, c) -#endif diff --git a/lib/libc/resolv/Makefile.inc b/lib/libc/resolv/Makefile.inc deleted file mode 100644 index e4c560222..000000000 --- a/lib/libc/resolv/Makefile.inc +++ /dev/null @@ -1,15 +0,0 @@ -# $NetBSD: Makefile.inc,v 1.5 2014/01/16 20:31:43 christos Exp $ - -# net sources -.PATH: ${.CURDIR}/resolv -.if defined(__MINIX) -CPPFLAGS+=-DCOMPAT__RES -DUSE_SELECT -DNEED_PSELECT -.else -CPPFLAGS+=-DCOMPAT__RES -DUSE_POLL -.endif - -SRCS+= h_errno.c herror.c res_comp.c res_data.c res_debug.c \ - res_init.c res_mkquery.c res_query.c res_send.c \ - res_state.c mtctxres.c -# For COMPAT__RES -SRCS+= res_compat.c diff --git a/lib/libc/resolv/h_errno.c b/lib/libc/resolv/h_errno.c deleted file mode 100644 index ec18d35f7..000000000 --- a/lib/libc/resolv/h_errno.c +++ /dev/null @@ -1,58 +0,0 @@ -/* $NetBSD: h_errno.c,v 1.3 2008/06/21 20:41:48 christos Exp $ */ - -/*- - * Copyright (c) 2004 The NetBSD Foundation, Inc. - * All rights reserved. - * - * This code is derived from software contributed to The NetBSD Foundation - * by Christos Zoulas. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS - * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS - * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -__RCSID("$NetBSD: h_errno.c,v 1.3 2008/06/21 20:41:48 christos Exp $"); -#endif - -#include -#include -#include -#include -#include - -#undef h_errno - -extern int h_errno; -extern struct __res_state _nres; - -int * -__h_errno(void) -{ - return &_nres.res_h_errno; -} - -void -__h_errno_set(res_state res, int err) -{ - h_errno = res->res_h_errno = err; -} diff --git a/lib/libc/resolv/herror.c b/lib/libc/resolv/herror.c deleted file mode 100644 index 4ce1a82fd..000000000 --- a/lib/libc/resolv/herror.c +++ /dev/null @@ -1,136 +0,0 @@ -/* $NetBSD: herror.c,v 1.10 2015/02/24 17:56:20 christos Exp $ */ - -/* - * Copyright (c) 1987, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Portions Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ - -#include -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef -static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "Id: herror.c,v 1.4 2005/04/27 04:56:41 sra Exp"; -#else -__RCSID("$NetBSD: herror.c,v 1.10 2015/02/24 17:56:20 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include - -#include -#include - -#include -#include -#include -#include - -#include "port_after.h" - -const char *h_errlist[] = { - "Resolver Error 0 (no error)", - "Unknown host", /*%< 1 HOST_NOT_FOUND */ - "Host name lookup failure", /*%< 2 TRY_AGAIN */ - "Unknown server error", /*%< 3 NO_RECOVERY */ - "No address associated with name", /*%< 4 NO_ADDRESS */ -}; -int h_nerr = { sizeof h_errlist / sizeof h_errlist[0] }; - -#if !(__GLIBC__ > 2 || __GLIBC__ == 2 && __GLIBC_MINOR__ >= 3) -#undef h_errno -int h_errno; -#endif - -#ifdef __weak_alias -__weak_alias(herror,_herror) -#endif - -/*% - * herror -- - * print the error indicated by the h_errno value. - */ -void -herror(const char *s) { - struct iovec iov[4], *v = iov; - char *t; - - if (s != NULL && *s != '\0') { - DE_CONST(s, t); - v->iov_base = t; - v->iov_len = strlen(t); - v++; - DE_CONST(": ", t); - v->iov_base = t; - v->iov_len = 2; - v++; - } - DE_CONST(hstrerror(*__h_errno()), t); - v->iov_base = t; - v->iov_len = strlen(v->iov_base); - v++; - DE_CONST("\n", t); - v->iov_base = t; - v->iov_len = 1; - (void)writev(STDERR_FILENO, iov, (int)((v - iov) + 1)); -} - -/*% - * hstrerror -- - * return the string associated with a given "host" errno value. - */ -const char * -hstrerror(int err) { - if (err < 0) - return ("Resolver internal error"); - else if (err < h_nerr) - return (h_errlist[err]); - return ("Unknown resolver error"); -} - -/*! \file */ diff --git a/lib/libc/resolv/mtctxres.c b/lib/libc/resolv/mtctxres.c deleted file mode 100644 index 6e3281a75..000000000 --- a/lib/libc/resolv/mtctxres.c +++ /dev/null @@ -1,130 +0,0 @@ -/* $NetBSD: mtctxres.c,v 1.4 2007/03/30 20:40:52 ghen Exp $ */ - -#include -#ifdef DO_PTHREADS -#include -#endif -#include -#include -#include -#include -#include -#include - -#ifdef DO_PTHREADS -static pthread_key_t key; -static int mt_key_initialized = 0; - -static int __res_init_ctx(void); -static void __res_destroy_ctx(void *); - -#if defined(sun) && !defined(__GNUC__) -#pragma init (_mtctxres_init) -#endif -#endif - -static mtctxres_t sharedctx; - -#ifdef DO_PTHREADS -/* - * Initialize the TSD key. By doing this at library load time, we're - * implicitly running without interference from other threads, so there's - * no need for locking. - */ -static void -_mtctxres_init(void) { - int pthread_keycreate_ret; - - pthread_keycreate_ret = pthread_key_create(&key, __res_destroy_ctx); - if (pthread_keycreate_ret == 0) - mt_key_initialized = 1; -} -#endif - -/* - * To support binaries that used the private MT-safe interface in - * Solaris 8, we still need to provide the __res_enable_mt() - * and __res_disable_mt() entry points. They're do-nothing routines. - */ -int -__res_enable_mt(void) { - return (-1); -} - -int -__res_disable_mt(void) { - return (0); -} - -#ifdef DO_PTHREADS -static int -__res_init_ctx(void) { - - mtctxres_t *mt; - int ret; - - - if (pthread_getspecific(key) != 0) { - /* Already exists */ - return (0); - } - - if ((mt = malloc(sizeof (mtctxres_t))) == 0) { - errno = ENOMEM; - return (-1); - } - - memset(mt, 0, sizeof (mtctxres_t)); - - if ((ret = pthread_setspecific(key, mt)) != 0) { - free(mt); - errno = ret; - return (-1); - } - - return (0); -} - -static void -__res_destroy_ctx(void *value) { - - mtctxres_t *mt = (mtctxres_t *)value; - - if (mt != 0) - free(mt); -} -#endif - -mtctxres_t * -___mtctxres(void) { -#ifdef DO_PTHREADS - mtctxres_t *mt; - - /* - * This if clause should only be executed if we are linking - * statically. When linked dynamically _mtctxres_init() should - * be called at binding time due the #pragma above. - */ - if (!mt_key_initialized) { - static pthread_mutex_t keylock = PTHREAD_MUTEX_INITIALIZER; - if (pthread_mutex_lock(&keylock) == 0) { - _mtctxres_init(); - (void) pthread_mutex_unlock(&keylock); - } - } - - /* - * If we have already been called in this thread return the existing - * context. Otherwise recreat a new context and return it. If - * that fails return a global context. - */ - if (mt_key_initialized) { - if (((mt = pthread_getspecific(key)) != 0) || - (__res_init_ctx() == 0 && - (mt = pthread_getspecific(key)) != 0)) { - return (mt); - } - } -#endif - return (&sharedctx); -} diff --git a/lib/libc/resolv/res_comp.c b/lib/libc/resolv/res_comp.c deleted file mode 100644 index a7d273178..000000000 --- a/lib/libc/resolv/res_comp.c +++ /dev/null @@ -1,283 +0,0 @@ -/* $NetBSD: res_comp.c,v 1.13 2015/02/24 17:56:20 christos Exp $ */ - -/* - * Copyright (c) 1985, 1993 - * The Regents of the University of California. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * 3. Neither the name of the University nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -/* - * Portions Copyright (c) 1993 by Digital Equipment Corporation. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies, and that - * the name of Digital Equipment Corporation not be used in advertising or - * publicity pertaining to distribution of the document or software without - * specific, written prior permission. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL - * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT - * CORPORATION BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL - * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR - * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS - * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS - * SOFTWARE. - */ - -/* - * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC") - * Portions Copyright (c) 1996-1999 by Internet Software Consortium. - * - * Permission to use, copy, modify, and distribute this software for any - * purpose with or without fee is hereby granted, provided that the above - * copyright notice and this permission notice appear in all copies. - * - * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES - * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR - * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT - * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. - */ -#include -#if defined(LIBC_SCCS) && !defined(lint) -#ifdef notdef -static const char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93"; -static const char rcsid[] = "Id: res_comp.c,v 1.5 2005/07/28 06:51:50 marka Exp"; -#else -__RCSID("$NetBSD: res_comp.c,v 1.13 2015/02/24 17:56:20 christos Exp $"); -#endif -#endif /* LIBC_SCCS and not lint */ - -#include "port_before.h" - -#include "namespace.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "port_after.h" - -#ifdef __weak_alias -__weak_alias(dn_expand,_dn_expand) -__weak_alias(dn_comp,__dn_comp) -#if defined(__minix) -__weak_alias(dn_skipname,__dn_skipname) -__weak_alias(res_hnok,__res_hnok) -__weak_alias(res_ownok,__res_ownok) -__weak_alias(res_mailok,__res_mailok) -__weak_alias(res_dnok,__res_dnok) -#endif /* defined(__minix) */ -#endif - -/*% - * Expand compressed domain name 'src' to full domain name. - * - * \li 'msg' is a pointer to the begining of the message, - * \li 'eom' points to the first location after the message, - * \li 'dst' is a pointer to a buffer of size 'dstsiz' for the result. - * \li Return size of compressed name or -1 if there was an error. - */ -int -dn_expand(const u_char *msg, const u_char *eom, const u_char *src, - char *dst, int dstsiz) -{ - int n = ns_name_uncompress(msg, eom, src, dst, (size_t)dstsiz); - - if (n > 0 && dst[0] == '.') - dst[0] = '\0'; - return (n); -} - -/*% - * Pack domain name 'exp_dn' in presentation form into 'comp_dn'. - * - * \li Return the size of the compressed name or -1. - * \li 'length' is the size of the array pointed to by 'comp_dn'. - */ -int -dn_comp(const char *src, u_char *dst, int dstsiz, - u_char **dnptrs, u_char **lastdnptr) -{ - return (ns_name_compress(src, dst, (size_t)dstsiz, - (void *)dnptrs, - (void *)lastdnptr)); -} - -/*% - * Skip over a compressed domain name. Return the size or -1. - */ -int -dn_skipname(const u_char *ptr, const u_char *eom) { - const u_char *saveptr = ptr; - - if (ns_name_skip(&ptr, eom) == -1) - return (-1); - _DIAGASSERT(__type_fit(int, ptr - saveptr)); - return (int)(ptr - saveptr); -} - -/*% - * Verify that a domain name uses an acceptable character set. - * - * Note the conspicuous absence of ctype macros in these definitions. On - * non-ASCII hosts, we can't depend on string literals or ctype macros to - * tell us anything about network-format data. The rest of the BIND system - * is not careful about this, but for some reason, we're doing it right here. - */ -#define PERIOD 0x2e -#define hyphenchar(c) ((c) == 0x2d) -#define bslashchar(c) ((c) == 0x5c) -#define periodchar(c) ((c) == PERIOD) -#define asterchar(c) ((c) == 0x2a) -#define alphachar(c) (((c) >= 0x41 && (c) <= 0x5a) \ - || ((c) >= 0x61 && (c) <= 0x7a)) -#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39) - -#define borderchar(c) (alphachar(c) || digitchar(c)) -#define middlechar(c) (borderchar(c) || hyphenchar(c)) -#define domainchar(c) ((c) > 0x20 && (c) < 0x7f) - -int -res_hnok(const char *dn) { - int pch = PERIOD, ch = *dn++; - - while (ch != '\0') { - int nch = *dn++; - - if (periodchar(ch)) { - ; - } else if (periodchar(pch)) { - if (!borderchar(ch)) - return (0); - } else if (periodchar(nch) || nch == '\0') { - if (!borderchar(ch)) - return (0); - } else { - if (!middlechar(ch)) - return (0); - } - pch = ch, ch = nch; - } - return (1); -} - -/*% - * hostname-like (A, MX, WKS) owners can have "*" as their first label - * but must otherwise be as a host name. - */ -int -res_ownok(const char *dn) { - if (asterchar(dn[0])) { - if (periodchar(dn[1])) - return (res_hnok(dn+2)); - if (dn[1] == '\0') - return (1); - } - return (res_hnok(dn)); -} - -/*% - * SOA RNAMEs and RP RNAMEs can have any printable character in their first - * label, but the rest of the name has to look like a host name. - */ -int -res_mailok(const char *dn) { - int ch, escaped = 0; - - /* "." is a valid missing representation */ - if (*dn == '\0') - return (1); - - /* otherwise